/*
 * Content grid: [margin][content][content][content][nav] — margin and
 * nav are real, dedicated tracks (--margin-col / --nav-col, defined in
 * base.css), not page padding. Content genuinely stops before the nav
 * track — it does not extend under it — so there is no text/nav
 * collision at any scroll position, without needing an opaque backing
 * on the nav panel: the illustration layer still shows through it
 * cleanly since nothing else is ever there to collide with.
 *
 * The nav *panel* itself is still position:fixed (so it stays on screen
 * while the page scrolls) — that's independent of it also owning a
 * reserved grid track for layout purposes.
 */

.page-grid {
	display: grid;
	grid-template-columns: var(--margin-col) repeat(3, 1fr) var(--nav-col);
	column-gap: var(--grid-gap);
	row-gap: var(--gutter);
	max-width: 1600px;
	margin: 0 auto;
	padding: var(--gutter);
	padding-bottom: 0;
}

.content-columns {
	grid-column: 2 / -2;
	display: grid;
	grid-template-columns: subgrid;
	column-gap: inherit;
	row-gap: inherit;
	/* Reading measure is ~4/5 of the full content width (box-sizing:
	   border-box keeps the grid item's own outer box exactly matching
	   its allocated track span — this only insets what renders inside). */
	padding: 0 var(--content-inset);
	box-sizing: border-box;
}

@supports not (grid-template-columns: subgrid) {
	.content-columns {
		grid-template-columns: repeat(3, 1fr);
	}
}

/*
 * True one-page site: every section is always in the document, stacked
 * in normal flow (like bryanboyer.com) — nav does not hide/show sections,
 * it only scrolls to them and reflects which one is currently in view
 * (see main.js IntersectionObserver "scrollspy").
 */
.content-columns > .section {
	grid-column: 1 / -1;
	scroll-margin-top: 2rem;
	padding-bottom: var(--section-gap);
	margin-bottom: var(--section-gap);
}

/* Gallery is the last section, ending in a full-bleed photo — its own
   trailing space, plus .page-grid's own bottom padding, plus the
   footer's usual top margin, compounded into a big empty gray gap
   between the last hero banner and the footer (each was already there
   for ordinary section-to-section spacing, just invisible until a
   full-bleed image made the gap after it obvious). Same "flush"
   treatment as .gallery-single-page + .site-footer below. */
#gallery {
	padding-bottom: 0;
	margin-bottom: 0;
}

.section__heading {
	margin-bottom: 1.5em;
}

/* --- EN|KO ---
 * Wide/medium: rendered inline as the last item inside .nav-column
 * (left-aligned, below the links — see .nav-column .lang-switch below).
 * Narrow: a second copy lives in .mobile-topbar instead, since
 * .nav-column isn't rendered at all in that mode. */

.lang-switch {
	display: flex;
	gap: 0.4em;
}

.nav-column .lang-switch {
	margin-top: 2rem;
	font-size: 0.6em;
	justify-content: flex-start;
}

/* --- Nav panel: fixed overlay on wide/medium screens ---
 * top is 2x the base gutter — extra clearance from the browser's top
 * edge, on top of the page's own edge padding.
 *
 * right can't just be var(--gutter): position:fixed is always relative
 * to the viewport, but .page-grid stops growing past 1600px and
 * centers itself with equal auto-margins on very wide screens. Past
 * that point var(--gutter) alone left the nav drifting further right
 * than the grid's own (now inset) right edge, off in what should be
 * blank centering space. Adding half of whatever's left over past
 * 1600px keeps it pinned to the grid's actual edge at any width. */

.nav-column {
	position: fixed;
	top: calc(var(--gutter) * 2);
	right: calc(max(0px, (100vw - 1600px) / 2) + var(--gutter));
	width: var(--nav-col);
	max-height: calc(100vh - var(--gutter) * 3);
	overflow-y: auto;
}

/* --- Mobile topbar: narrow screens only ---
 * One fixed full-width row — logo, EN|한국어, hamburger, in that
 * order — instead of the hamburger and EN|KO each floating as their
 * own separately-fixed elements. That older approach hid the logo
 * entirely below 820px (it only lived inside .nav-column, which is
 * display:none there) and needed a hand-tuned padding-top on
 * .page-grid to clear two stacked fixed elements, which drifted out
 * of sync with their actual height. Here there's exactly one bar with
 * one real height to clear. */

.mobile-topbar {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 150;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem var(--gutter);
	box-sizing: border-box;
}

.mobile-topbar .site-mark {
	margin-bottom: 0;
}

/* EN|한국어 grouped right next to the hamburger — both fixed together
   in the corner — rather than spread across the row by the topbar's
   own space-between (which now only splits logo vs. this group). */
.mobile-topbar__right {
	display: flex;
	align-items: center;
	gap: 0.9rem;
}

.mobile-topbar .lang-switch {
	font-size: 0.84em;
}

/* --- Hamburger + drawer: narrow screens only --- */

.nav-hamburger {
	display: none;
	flex: none;
	width: 40px;
	height: 40px;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 5px;
}

.nav-hamburger span {
	display: block;
	width: 22px;
	height: 2px;
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-hamburger span:nth-child(1) {
	background: #1cb0c0;
}

.nav-hamburger span:nth-child(2) {
	background: #fcd700;
}

.nav-hamburger span:nth-child(3) {
	background: #e76b5e;
}

/* Hamburger -> X: the button itself morphs in place (same element, same
   position) rather than swapping in a separate close button. Top/bottom
   bars rotate to cross right where the middle bar already is — the
   middle (yellow) bar doesn't move or fade, it just stays put; fading
   it out read as the whole icon briefly collapsing to a dot mid-animation. */
.nav-hamburger.is-open span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.nav-hamburger.is-open span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* A minimal column, not a full-screen takeover: slides in from the
   right edge, only as wide as the nav content needs. */
.nav-drawer {
	display: none;
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: auto;
	width: min(300px, 80vw);
	background: var(--color-bg);
	z-index: 100;
	padding: var(--gutter) 1.5rem;
	box-shadow: -8px 0 24px rgba(23, 21, 58, 0.12);
	transform: translateX(100%);
	transition: transform 0.25s ease;
}

.nav-drawer.is-open {
	transform: translateX(0);
}

@media (max-width: 819px) {
	:root {
		--nav-col: 0px;
	}
	.nav-column {
		display: none;
	}
	.mobile-topbar {
		display: flex;
	}
	.nav-hamburger {
		display: flex;
	}
	.nav-drawer {
		display: block;
		/* The topbar sits fixed on top (z-index above the drawer), so the
		   drawer's own links need the same top clearance as .page-grid or
		   its first item would render partly underneath it. */
		padding-top: calc(40px + 1.5rem + var(--gutter));
	}
	/* Clear the topbar's own height (40px hamburger + its 0.75rem
	   top/bottom padding) plus a comfortable gap before content starts. */
	.page-grid {
		padding-top: calc(40px + 1.5rem + var(--gutter));
	}
}
