/* ============================================================
   RESPONSIVE & LAYOUT
   Supports: Chrome, Opera, Firefox, Safari (iOS + macOS)
   ============================================================ */

/* Ensure all elements respect box-sizing (belt-and-braces with main CSS) */
* { box-sizing: border-box; }

/* ============================================================
   BASE — BODY & CONTAINER (mobile-first)
   ============================================================ */

body {
	display: block;     /* explicit block avoids quirks in some browsers */
	margin: 0;
	padding: 0;
}

.container {
	display: -webkit-box;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: wrap;
	flex-wrap: wrap;
	-webkit-box-pack: start;
	-webkit-justify-content: flex-start;
	justify-content: flex-start;
	padding: 20px;
	gap: 26px;
	/* Fallback for browsers without gap support (old Safari < 14.1) */
}

/* gap fallback: add margin to items when gap is not supported.
   "@supports not (gap: 1px)" is the correct way to detect this. */
@supports not (gap: 1px) {
	.container > * { margin: 13px; }
}

.container-wrapper {
	display: -webkit-box;
	display: -webkit-flex;
	display: flex;
	-webkit-box-flex: auto;
	-webkit-flex: auto;
	flex: auto;
	-webkit-flex-wrap: wrap;
	flex-wrap: wrap;
	-webkit-box-orient: horizontal;
	-webkit-box-direction: normal;
	-webkit-flex-direction: row;
	flex-direction: row;
	-webkit-box-pack: end;
	-webkit-justify-content: flex-end;
	justify-content: flex-end;
	-webkit-box-align: auto;
	-webkit-align-items: auto;
	align-items: auto;
	-webkit-align-content: start;
	align-content: flex-start;
}

.content-wrapper {
	display: -webkit-box;
	display: -webkit-flex;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	-webkit-flex-direction: column;
	flex-direction: column;
}

/* ============================================================
   MAIN HEADER — mobile default
   (overridden per breakpoint below)
   ============================================================ */

.main-header {
	display: -webkit-box;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: wrap;
	flex-wrap: wrap;
	-webkit-box-pack: justify;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	color: var(--white);
	padding: 20px 20px 0px 20px;
	background-color: var(--darkgrey);
	border-radius: var(--border-curve);
	/* Use min-height instead of height so the header grows
	   if content (model-viewer, bio text) needs more room.  */
	min-height: 800px;
	height: auto;
}

/* ============================================================
   DESKTOP (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {

	.main-header {
		-webkit-box-orient: horizontal;
		-webkit-box-direction: normal;
		-webkit-flex-direction: row;
		flex-direction: row;
		-webkit-box-flex: 1;
		-webkit-flex-grow: 1;
		flex-grow: 1;
		max-width: 99%;
	}

	.contact-info {
		width: 40%;
		overflow-y: hidden;
	}

	.ai-chat-frame {
		width: 88%;
	}

	.container-wrapper {
		gap: 26px;
		-webkit-box-orient: horizontal;
		-webkit-box-direction: normal;
		-webkit-flex-direction: row;
		flex-direction: row;
	}

	/* 3-column card grid on desktop.
	   Using flex-basis so the browser lays columns out reliably
	   across Chrome, Firefox, Safari and Opera.               */
	.expandable-card {
		-webkit-flex: 0 0 calc(33.333% - 18px);
		flex: 0 0 calc(33.333% - 18px);
		width: calc(33.333% - 18px);
		max-width: calc(33.333% - 18px);
		height: 225px;
		max-height: 225px;
		overflow: hidden;
	}

	/* Expanded card stays within its column width */
	.card-checkbox:checked + .expandable-card {
		-webkit-flex: 0 0 calc(33.333% - 18px);
		flex: 0 0 calc(33.333% - 18px);
		width: calc(33.333% - 18px);
		max-width: calc(33.333% - 18px);
		height: auto;
		max-height: none;
		overflow: visible;
	}

	model-viewer {
		position: absolute;
		right: 60%;
		top: 15%;
		width: 50%;
		height: 43rem;
	}
}


/* ============================================================
   TABLET (641px – 1023px)
   ============================================================ */
@media (min-width: 641px) and (max-width: 1023px) {

	.main-header {
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-webkit-flex-direction: column;
		flex-direction: column;
		-webkit-box-flex: 1;
		-webkit-flex-grow: 1;
		flex-grow: 1;
		max-width: 99%;
	}

	.contact-info {
		width: 60%;
		overflow-y: hidden;
	}

	.ai-chat-frame {
		width: 88%;
	}

	.container-wrapper {
		gap: 26px;
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-webkit-flex-direction: column;
		flex-direction: column;
	}

	.expandable-card {
		width: calc(100vw - 40px);
		max-width: 99%;
		height: 225px;
		max-height: 225px;
		overflow: hidden;
		-webkit-flex-grow: 0;
		flex-grow: 0;
		/* Reset desktop flex-basis back to full width */
		-webkit-flex: 0 0 auto;
		flex: 0 0 auto;
	}

	.card-checkbox:checked + .expandable-card {
		max-width: 99%;
		height: auto;
		max-height: none;
		overflow: visible;
		-webkit-flex: 0 0 auto;
		flex: 0 0 auto;
	}

	model-viewer {
		width: 100%;
		height: 43rem;
	}
}


/* ============================================================
   MOBILE (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {

	.main-header {
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-webkit-flex-direction: column;
		flex-direction: column;
		-webkit-box-flex: 1;
		-webkit-flex-grow: 1;
		flex-grow: 1;
		max-width: 99%;
		/* Remove fixed height entirely — let content define it */
		height: auto;
		min-height: 0;
		-webkit-box-pack: center;
		-webkit-justify-content: center;
		justify-content: center;
	}

	.contact-info {
		width: 100%;
		overflow-y: hidden;
	}

	.ai-chat-frame {
		/* Full bleed on small screens */
		width: 100%;
		padding-top: 20px;
	}

	.hr-title-container {
		width: 88%;
		margin-top: 0.5rem;
		margin-bottom: 1rem;
	}

	.p-contact-info {
		width: 88%;
		overflow-y: hidden;
	}

	.container-wrapper {
		gap: 26px;
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-webkit-flex-direction: column;
		flex-direction: column;
		height: auto;
		-webkit-align-content: center;
		align-content: center;
	}

	.expandable-card {
		width: calc(100vw - 40px);
		max-width: 99%;
		height: 225px;
		max-height: 225px;
		overflow: hidden;
		-webkit-flex-grow: 0;
		flex-grow: 0;
		-webkit-flex: 0 0 auto;
		flex: 0 0 auto;
	}

	.card-checkbox:checked + .expandable-card {
		width: calc(100vw - 40px);
		max-width: 99%;
		height: auto;
		max-height: none;
		overflow: visible;
		-webkit-flex: 0 0 auto;
		flex: 0 0 auto;
	}

	/* Scale model-viewer down on small screens so it doesn't
	   dominate the viewport or cause horizontal overflow.     */
	model-viewer {
		width: 88%;
		/* Use vh units so tall phones don't get a monster model */
		height: min(30rem, 55vw);
		/* Fallback for browsers without min() support */
		height: 30rem;
		height: min(30rem, 60vh);
		margin: 0 auto; /* centre the model on narrow screens */
	}

	/* Slightly smaller title on very small phones */
	.text-title-big-arvo {
		font-size: 7rem;
	}

	.text-title-small-arvo {
		font-size: 5rem;
	}
}

/* ============================================================
   EXTRA-SMALL PHONES (< 380px)
   Prevents the "G©R" monogram from overflowing its container.
   ============================================================ */
@media (max-width: 379px) {
	.text-title-big-arvo   { font-size: 5.5rem; }
	.text-title-small-arvo { font-size: 4rem;   }

	model-viewer {
		width: 100%;
		height: 22rem;
	}
}
