/* CSS Variables - Light Theme (Default) */
:root
{
	--primary: #4a90e2; /* Main brand blue */
	--secondary: #5c677d; /* Subdued text color */
	--tertiary: #999999; /* Light grey for labels */
	--accent: #f5a623; /* Donate button orange */
	--bg: #f9fbff; /* Page background */
	--text: #333333; /* Main text color */
	--white: #ffffff;
	--section-bg: #ffffff; /* Card background */
	--buddy-bg: #e1efff; /* Light blue section background */
	--blockquote-color: #5c677d;
	--shadow: rgba(0, 0, 0, 0.05);
	--tooltip-bg: #fff5e6; /* Light orange for tooltips */
	--tooltip-text: #333333;
	--footer-color: #5c677d;
}


/* CSS Variables - Dark Theme Overrides */
.dark-theme
{
	--primary: #64b5f6;
	--secondary: #a0aec0;
	--tertiary: #888888;
	--accent: #f5a623;
	--bg: #121212;
	--text: #e0e0e0;
	--white: #ffffff;
	--section-bg: #1e1e1e;
	--buddy-bg: #1a2733;
	--blockquote-color: #cbd5e0;
	--shadow: rgba(0, 0, 0, 0.3);
	--tooltip-bg: #444444;
	--tooltip-text: #ffffff;
	--footer-color: #a0aec0;
}


/* Global Resets */
*
{
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}


body
{
	font-family: "Inter", sans-serif;
	background-color: var(--bg);
	color: var(--text);
	line-height: 1.6;
}


.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}


.container
{
	max-width: 1000px;
	margin: 0 auto;
	padding: 20px;
}


/* Hero Section - Header with Background Image */
.hero
{
	background: linear-gradient(rgba(74, 144, 226, 0.8), rgba(74, 144, 226, 0.8)), url("bella.jpg");
	background-size: cover;
	background-position: center 65%;
	color: var(--white);
	text-align: center;
	padding: 80px 20px;
}


.hero h1
{
	font-family: "Playfair Display", serif;
	font-size: 3rem;
	margin-bottom: 10px;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}


.subtitle
{
	font-size: 1.2rem;
	font-weight: 300;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}


/* Content Sections - Cards */
section
{
	background: var(--section-bg);
	margin: 40px 0;
	padding: 40px;
	border-radius: 15px;
	box-shadow: 0 10px 30px var(--shadow);
}


/* Grid Layouts for Story and Buddy sections */
.intro-grid, .buddy-section
{
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 40px;
	align-items: center;
}


.buddy-section
{
	background: var(--buddy-bg);
}


img
{
	max-width: 100%;
	border-radius: 10px;
	display: block;
}


h2
{
	font-family: "Playfair Display", serif;
	color: var(--primary);
	margin-bottom: 20px;
	font-size: 2rem;
}


section p:not(:last-child)
{
	margin-bottom: 0.5rem;
}


a
{
	color: var(--primary);
	text-decoration: none;
	transition: color 0.2s, text-decoration 0.2s;
}


a:hover
{
	color: #2a6dbd; /* A slightly darker blue for hover */
	text-decoration: underline;
}


/* Styling the Bus Quote */
blockquote
{
	font-family: "Playfair Display", serif;
	font-style: italic;
	font-size: 1.2rem;
	border-left: 4px solid var(--primary);
	padding-left: 20px;
	margin: 25px 0;
	color: var(--blockquote-color);
}


.cta-box a:not(.donate-btn)
{
	text-decoration: underline;
}


/* Donation Call to Action Box */
.cta-box
{
	text-align: center;
	background: var(--section-bg);
	border: 2px solid var(--primary);
}


.read-more-container
{
	margin-top: 15px;
	font-style: italic;
}


.read-more-link
{
	color: var(--primary);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color 0.3s;
	font-weight: 600;
}


.read-more-link:hover
{
	border-bottom: 1px solid var(--primary);
}


/* Styling for the image of Buddy */
.buddy-img
{
	width: 100%;
	border-radius: 10px;
	display: block;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
	filter: grayscale(100%);
	transition: filter 0.6s ease-in-out;
	cursor: help; /* A subtle hint that the dog is the help she needs */
}


.buddy-img:hover
{
	filter: grayscale(0%);
}


/* Styling for the caption text under Buddy */
.caption
{
	font-size: 0.85rem;
	color: var(--secondary);
	margin-top: 10px;
	text-align: center;
	font-style: italic;
	line-height: 1.4;
}


/* Ensure the profile image of Bella matches the quality look */
.profile-img
{
	width: 100%;
	border-radius: 10px;
	display: block;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}


.last-updated
{
	font-size: 0.67rem;
	font-style: italic;
	color: var(--tertiary);
	margin-top: 20px;
	margin-bottom: 20px;
}


/* Visual Progress Bar Component */
.progress-container
{
	width: 100%;
	background-color: var(--buddy-bg);
	border-radius: 25px;
	margin: 25px 0 10px;
	height: 30px;
	overflow: hidden;
}


.progress-bar
{
	height: 100%;
	background-color: var(--primary);
	text-align: right;
	padding-right: 10px;
	line-height: 30px;
	color: white;
	font-weight: bold;
	width: 0; /* Managed by JS */
	min-width: 2.5rem;
	white-space: nowrap;
	transition: width 1s ease-in-out;
}


/* Tooltips */
/* Medical Condition Tooltips (Desktop) */
.tooltip-trigger
{
	position: relative;
	font-weight: 600;
	color: var(--primary);
	text-decoration: underline dotted;
	cursor: help;
}


	/* Custom Tooltip Content (Nested Span) */
.tooltip-trigger .tooltip-content
{
	position: absolute;
	bottom: 150%;
	left: 50%;
	transform: translateX(-50%);
	background: var(--tooltip-bg);
	color: var(--tooltip-text);
	padding: 10px 15px;
	border-radius: 8px;
	font-size: 0.85rem;
	font-weight: 400;
	line-height: 1.4;
	width: 250px;
	text-align: left;
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.3s, visibility 0.3s;
	z-index: 100;
	pointer-events: none;
	box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}


.tooltip-trigger::after
{
	content: "";
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.3s, visibility 0.3s;
}


/* Bold the acronym expansion within the tooltip */
.tooltip-trigger .tooltip-content strong
{
	color: inherit;
	font-weight: 600;
	display: block;
	margin-bottom: 0.4rem;
}


/* Tooltip Arrow */
.tooltip-trigger::before
{
	content: "";
	position: absolute;
	bottom: 130%;
	left: 50%;
	transform: translateX(-50%);
	border: 8px solid transparent;
	border-top-color: var(--tooltip-bg);
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.3s, visibility 0.3s;
	z-index: 100;
}


.tooltip-trigger:hover .tooltip-content,
.tooltip-trigger:hover::before,
.tooltip-trigger:hover::after
{
	visibility: visible;
	opacity: 1;
}


/* Adjust tooltips for mobile */
@media (max-width: 768px)
{
	.tooltip-trigger .tooltip-content
	{
		width: calc(100vw - 30px);
		max-width: 280px;
		/* Use fixed positioning to center globally on viewport */
		position: fixed;
		left: 50%;
		bottom: auto;
		top: 50%;
		transform: translate(-50%, -50%);
		z-index: 1000;
	}

	.tooltip-trigger::before
	{
		display: none;
	}

	/* Darken background slightly when tooltip is active to focus attention */
	.tooltip-trigger::after
	{
		content: "";
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		background: rgba(0, 0, 0, 0.4);
		z-index: 99;
		pointer-events: none;
	}
}


.progress-text
{
	line-height: 1;
	margin-bottom: 0;
}


/* Donate Button - Floating Action Style */
.donate-btn
{
	display: inline-block;
	background-color: var(--accent);
	color: var(--white);
	padding: 15px 40px;
	text-decoration: none;
	font-weight: bold;
	font-size: 1.2rem;
	border-radius: 50px;
	margin-top: 20px;
	border: 2px solid transparent; /* Added to prevent layout shift when hover border appears */
	transition: transform 0.35s, background-color 0.35s, border-color 0.35s, text-shadow 0.35s;
}


.donate-btn:hover
{
	transform: scale(1.15);
	color: var(--white);
	text-decoration: none;
	background-color: #e0961d; /* Slightly darker shade of #f5a623 */
	border-color: #c4821a;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}


.secure-note
{
	font-size: 0.8rem;
	color: var(--secondary);
	margin-top: 15px;
}


footer
{
	text-align: center;
	padding: 40px;
	color: var(--footer-color);
	font-size: 0.9rem;
}


.donate-link-print
{
	display: none;
}


.offline-info
{
	font-size: 0.8rem;
	color: var(--footer-color);
}


/* Theme Toggle Button - Floating in Hero */
.theme-toggle
{
	position: absolute;
	top: 20px;
	right: 20px;
	background: none;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 50%;
	width: 45px;
	height: 45px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.3s, transform 0.3s;
	z-index: 10;
}


.theme-toggle:hover
{
	background: rgba(255, 255, 255, 0.1);
	transform: scale(1.1);
}


.theme-toggle svg
{
	width: 24px;
	height: 24px;
	fill: none;
	stroke: white;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}


.theme-toggle svg .sun
{
	fill: white;
}


.dark-theme .theme-toggle svg .sun
{
	display: block;
}


.dark-theme .theme-toggle svg .moon
{
	display: none;
}


.theme-toggle svg .sun
{
	display: none;
}


.theme-toggle svg .moon
{
	display: block;
}


/* Mobile Responsiveness (Screen width up to 768px) */
@media (max-width: 768px)
{
	.container
	{
		padding: 15px;
	}

	section
	{
		padding: 20px;
		margin: 20px 0;
	}

	.hero
	{
		padding: 40px 15px;
	}

	.intro-grid, .buddy-section
	{
		grid-template-columns: 1fr;
		gap: 20px;
	}

	.buddy-section .text-box
	{
		order: 2;
	}

	.buddy-section .image-box
	{
		order: 1;
	}

	.hero h1
	{
		font-size: 2rem;
	}

	body
	{
		font-size: 0.95rem;
		line-height: 1.5;
	}

	h2
	{
		line-height: 1.1;
	}

	.theme-toggle
	{
		width: 36px;
		height: 36px;
		top: 10px;
		right: 10px;
	}

	.theme-toggle svg
	{
		width: 16px;
		height: 16px;
	}
}


/* Print Styling - Forced to Light Theme for Paper Savings/Readability */
@media print
{
	.theme-toggle
	{
		display: none !important;
	}

	/* Reset all colors to light theme equivalents for printing */
	:root, .dark-theme
	{
		--bg: #f9fbff;
		--text: #333333;
		--section-bg: #ffffff;
		--white: #ffffff;
		--primary: #4a90e2;
		--secondary: #5c677d;
		--tertiary: #999999;
		--accent: #f5a623;
		--buddy-bg: #e1efff;
		--shadow: rgba(0, 0, 0, 0.05);
		--blockquote-color: #5c677d;
		--tooltip-bg: #fff5e6;
		--tooltip-text: #333333;
		--footer-color: #5c677d;
	}

	@page
	{
		size: A4;
		margin: 1.5cm;
	}

	/* Issue 1: Add 8mm margins to sides for a smarter look */
	.container
	{
		max-width: calc(100% - 16mm) !important;
		width: calc(100% - 16mm) !important;
		margin: 0 auto !important;
		padding: 0 !important;
	}

	body
	{
		background-color: var(--bg) !important;
		color: var(--text) !important;
	}

	.hero
	{
		background: linear-gradient(rgba(74, 144, 226, 0.8), rgba(74, 144, 226, 0.8)), url("bella.jpg") !important;
		background-size: cover !important;
		background-position: center 65% !important;
		color: #ffffff !important;
		padding: 40px 0 !important;
		border-bottom: 2px solid var(--primary);
	}

	.hero h1, .subtitle
	{
		color: #ffffff !important;
		text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
	}

	section
	{
		background: var(--section-bg) !important;
		break-inside: avoid;
		border: 1px solid #eeeeee !important;
		margin: 20px 0 !important;
		padding: 20px !important;
		width: 100% !important;
		box-shadow: 0 10px 30px var(--shadow) !important;
		/* Ensure a gap even if the section starts at the top of a page */
		display: inline-block !important; /* Forces margin-top to be respected at top of page in many browsers */
	}

	.buddy-section
	{
		background: var(--buddy-bg) !important;
	}


	.intro-grid h2
	{
		margin-top: 20px !important;
	}


	.intro-grid p:last-child
	{
		padding-bottom: 0 !important;
	}


	/* Issue 2: Add a gap before the image when stacked */
	img
	{
		width: auto !important;
		max-width: 80% !important;
		max-height: 350px !important;
		margin: 25px auto 0 auto !important; /* Issue 3: Reduced bottom margin to 5px */
		display: block !important;
		filter: none !important;
	}


	img:first-child
	{
		margin-top: 0 !important;
	}


	.buddy-section img
	{
		margin-top: 25px !important;
	}

	/* Issue 3: Ensure caption is close to the image */
	.caption
	{
		margin-top: 5px !important;
		padding-top: 0 !important;
		color: #000000 !important;
	}


	.donate-btn
	{
		display: none !important;
	}


	.cta-box,
	.read-more-container,
	.text-box
	{
		container-type: inline-size;
	}


	/* Replace button with a text link for donors */
	.donate-link-print
	{
		container-type: inline-size;
		display: block;
		margin-top: 15px;
		font-weight: bold;
		font-size: clamp(0.5rem, 2.7cqi, 1.5rem);
		color: #000000;
		text-align: center;
	}


	/* Ensure the 'Read more' link displays the URL */
	.read-more-link::after
	{
		content: "(https://www.backabuddy.co.za/campaign/service-dog-for-bella)";
		display: block;
		font-weight: normal;
		color: #000000;
	}


	.text-box a[href]::after
	{
		content: " (" attr(href) ")";
		font-weight: normal;
		color: #000000;
	}
}
