/* ==========================================================================
   Primary navigation — rooms, mega-menu, and the drawer it becomes
   Converted from design-reference/showroom-floor.css §3.

   One set of markup, two presentations. From 1024px each room is a disclosure
   button with a full-width panel dropped under the header; below that the same
   list is a full-screen drawer and the same panels are accordions. Rendering it
   twice and hiding a copy would double the header's markup on every page and
   give a screen reader two navigations to tell apart.

   The panel's collection name is set in the display face at 20px in the
   export, under the 28px floor CLAUDE.md holds display type to; it takes the
   body face here, as the room landing page's tile name already did.

   Three of the export's values had no token and are converted rather than
   copied: the 28px row gap is step--28, the 10px link gap is step--12, and the
   6px meta offset is step--8. The export's own `--space-5` is undefined in its
   token block and falls back to 40px, which is not a step in this scale; the
   header row uses spacing--40 (32px). Recorded in design-reference/README.md.

   The export opens a panel on `:focus-within`. That is not carried over — see
   assets/js/primary-nav.js for why a menu that opens on focus alone is a trap
   for the keyboard users it is supposed to help. Hover still opens, on devices
   that have a pointer.
   ========================================================================== */

/*
 * The template part's own wrapper. It exists because CLAUDE.md's map asks for
 * parts/mega-menu.html, and it should contribute nothing to the header row —
 * the <nav> inside it is the flex item.
 */
.tfs-header__nav {
	display: contents;
}

.tfs-nav {
	display: flex;
	align-items: center;
	min-width: 0;
}

/* --------------------------------------------------------------------------
   The hamburger — below 1024px only
   -------------------------------------------------------------------------- */

.tfs-nav__toggle,
.tfs-nav__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--wp--custom--control--tap-target-minimum);
	min-height: var(--wp--custom--control--tap-target-minimum);
	padding: 0;
	font: inherit;
	color: var(--wp--preset--color--ink);
	background: none;
	border: 0;
	cursor: pointer;
}

.tfs-nav__toggle:hover,
.tfs-nav__close:hover {
	color: var(--wp--preset--color--accent-hover);
}

/* Focus indicators are exempt from the no-shadow rule: outline, never shadow. */
.tfs-nav__toggle:focus-visible,
.tfs-nav__close:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: var(--wp--custom--focus--offset);
}

@media (min-width: 1024px) {
	.tfs-nav__toggle {
		display: none;
	}
}

/* --------------------------------------------------------------------------
   The drawer — below 1024px

   A full-screen panel rather than a partial one: at 360px a menu that leaves a
   strip of the page showing invites a mis-tap on whatever is behind it, and
   the strip is not wide enough to be a useful escape either. The scrim is
   there for the pointer; Escape and the close button are there for everyone
   else.
   -------------------------------------------------------------------------- */

.tfs-nav__scrim {
	position: fixed;
	inset: 0;
	z-index: 60;
	background-color: var(--wp--custom--scrim);
}

.tfs-nav__panel {
	position: fixed;
	inset: 0;
	z-index: 61;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	overscroll-behavior: contain;
	background-color: var(--wp--preset--color--surface);
	transform: translateX(-100%);
	visibility: hidden;
	transition:
		transform var(--wp--custom--motion--duration) var(--wp--custom--motion--easing),
		visibility var(--wp--custom--motion--duration) var(--wp--custom--motion--easing);
}

.tfs-nav__panel[data-open="true"] {
	transform: translateX(0);
	visibility: visible;
}

.tfs-nav__panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--20);
	padding: var(--wp--custom--step--12) var(--wp--custom--gutter--mobile);
	border-bottom: var(--wp--custom--hairline);
}

.tfs-nav__panel-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--utility);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--tracking--utility);
	color: var(--wp--preset--color--muted);
}

.tfs-nav__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tfs-nav__item {
	border-bottom: var(--wp--custom--hairline);
}

/* --------------------------------------------------------------------------
   A room

   The trigger is a button because it controls a panel. The route to the room
   landing page is the first link inside that panel, so a keyboard never has to
   guess whether Enter navigates or expands.
   -------------------------------------------------------------------------- */

.tfs-nav__link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--custom--step--12);
	width: 100%;
	min-height: var(--wp--custom--control--tap-target-minimum);
	padding: var(--wp--custom--step--12) var(--wp--custom--gutter--mobile);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--body);
	text-align: start;
	color: var(--wp--preset--color--ink);
	background: none;
	border: 0;
	cursor: pointer;
	text-decoration: none;
}

.tfs-nav__link:hover {
	color: var(--wp--preset--color--accent-hover);
	text-decoration: none;
}

.tfs-nav__link:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: calc(var(--wp--custom--focus--offset) * -1);
}

.tfs-nav__chevron {
	flex: 0 0 auto;
	transition: transform var(--wp--custom--motion--duration) var(--wp--custom--motion--easing);
}

.tfs-nav__link[aria-expanded="true"] .tfs-nav__chevron {
	transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   The panel
   -------------------------------------------------------------------------- */

/*
 * Closed means display:none, not visibility or opacity: a shut panel has to be
 * out of the accessibility tree and its links out of the tab order, or the
 * header hands a keyboard forty invisible stops to cross.
 */
.tfs-mega[data-open="false"] {
	display: none;
}

.tfs-mega {
	display: block;
	background-color: var(--wp--preset--color--ground);
	border-top: var(--wp--custom--hairline);
}

.tfs-mega__inner {
	padding: var(--wp--preset--spacing--30) var(--wp--custom--gutter--mobile);
}

.tfs-mega__links {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tfs-mega__links-item {
	break-inside: avoid;
}

.tfs-mega__link {
	display: block;
	min-height: var(--wp--custom--control--tap-target-minimum);
	padding-block: var(--wp--custom--step--12);
	font-size: var(--wp--preset--font-size--small);
	line-height: var(--wp--custom--line-height--body);
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

.tfs-mega__link:hover {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
}

.tfs-mega__link:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: var(--wp--custom--focus--offset);
}

/* The way to the room landing page, and the first thing a keyboard reaches. */
.tfs-mega__link--all {
	font-weight: 600;
}

/* --------------------------------------------------------------------------
   The featured collection
   -------------------------------------------------------------------------- */

.tfs-mega__feature {
	display: block;
	margin-block-start: var(--wp--preset--spacing--30);
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

.tfs-mega__feature:hover {
	text-decoration: none;
}

.tfs-mega__feature:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: var(--wp--custom--focus--offset);
}

.tfs-mega__feature-media {
	display: block;
	overflow: hidden;
	aspect-ratio: var(--wp--custom--aspect--room);
	background-color: var(--wp--preset--color--placeholder);
	border-radius: var(--wp--custom--radius);
}

.tfs-mega__feature-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--wp--custom--motion--duration) var(--wp--custom--motion--easing);
}

.tfs-mega__feature:hover .tfs-mega__feature-image {
	transform: scale(var(--wp--custom--motion--tile-scale));
}

/* Nothing in the collection has been photographed yet. The frame holds the
   column's shape; it does not pretend to be a picture. */
.tfs-mega__feature-empty {
	display: block;
	width: 100%;
	height: 100%;
	background-color: var(--wp--preset--color--placeholder);
}

/* Collection tags are the one thing besides provenance that gets the saddle
   colour, per CLAUDE.md. `saddle-text`, not `saddle`: this is 12px type on
   `ground`, and the decorative value is 3.53:1 there — under the 4.5:1 text
   floor. The darkened one is 4.61:1. */
.tfs-mega__feature-eyebrow {
	display: block;
	margin-block-start: var(--wp--custom--step--8);
	font-size: var(--wp--preset--font-size--utility);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--tracking--utility);
	color: var(--wp--preset--color--saddle-text);
}

/*
 * Body face, not display — the same correction the header's wordmark takes, and
 * the same one the room landing page's tile name already carried. The export
 * sets this at display/20px; CLAUDE.md floors display type at 28px and reserves
 * that face for H1 and H2. Recorded in design-reference/README.md.
 */
.tfs-mega__feature-name {
	display: block;
	margin-block-start: var(--wp--custom--step--4);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--sub);
	letter-spacing: 0;
	line-height: var(--wp--custom--line-height--tight);
}

/* --------------------------------------------------------------------------
   Drawer foot — the two things that do not fit the header row on a phone
   -------------------------------------------------------------------------- */

.tfs-nav__foot {
	display: grid;
	gap: var(--wp--custom--step--12);
	margin-block-start: auto;
	padding: var(--wp--preset--spacing--30) var(--wp--custom--gutter--mobile);
	border-top: var(--wp--custom--hairline);
}

.tfs-nav__foot-link {
	min-height: var(--wp--custom--control--tap-target-minimum);
	display: flex;
	align-items: center;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
}

.tfs-nav__foot-link:hover {
	color: var(--wp--preset--color--accent-hover);
}

.tfs-nav__foot-link:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: var(--wp--custom--focus--offset);
}

/* ==========================================================================
   From 1024px — the row of rooms and the dropdown
   ========================================================================== */

@media (min-width: 1024px) {
	.tfs-nav__scrim,
	.tfs-nav__panel-head,
	.tfs-nav__foot {
		display: none;
	}

	/* The drawer becomes an ordinary part of the header row again. Every
	   overlay property is unset rather than overridden piecemeal, so a state
	   left behind by a resize cannot survive the breakpoint. */
	.tfs-nav__panel {
		position: static;
		z-index: auto;
		flex-direction: row;
		overflow: visible;
		background: none;
		transform: none;
		visibility: visible;
		transition: none;
	}

	.tfs-nav__list {
		display: flex;
		align-items: center;
		gap: var(--wp--custom--step--28);
	}

	.tfs-nav__item {
		border-bottom: 0;
	}

	.tfs-nav__link {
		width: auto;
		min-height: 0;
		padding: var(--wp--custom--step--4) 0;
		font-size: var(--wp--preset--font-size--utility);
		text-transform: uppercase;
		letter-spacing: var(--wp--custom--tracking--utility);
		color: var(--wp--preset--color--muted);
		border-bottom: 1px solid transparent;
	}

	.tfs-nav__link:hover,
	.tfs-nav__link[aria-expanded="true"] {
		color: var(--wp--preset--color--ink);
		border-bottom-color: var(--wp--preset--color--ink);
	}

	.tfs-nav__link:focus-visible {
		outline-offset: var(--wp--custom--focus--offset);
	}

	/*
	 * The panel hangs off the header, not off the room it belongs to: the
	 * sticky header is the nearest positioned ancestor, so `inset-inline: 0`
	 * spans the whole bar and the panel is full width however narrow the room
	 * name is. Nothing between here and there may be positioned.
	 */
	.tfs-mega {
		position: absolute;
		inset-inline: 0;
		top: 100%;
		z-index: 1;
		background-color: var(--wp--preset--color--surface);
		border-bottom: var(--wp--custom--hairline);
	}

	.tfs-mega__inner {
		display: grid;
		max-width: var(--wp--style--global--content-size);
		margin-inline: auto;
		/* The distance from the viewport edge to the content column, which core
		   derives from the gutter tokens. Reading it here is what keeps the
		   panel's columns lined up with the header above them at both
		   breakpoints without this file restating the gutter. */
		padding: var(--wp--preset--spacing--50) var(--wp--style--root--padding-left);
		gap: var(--wp--preset--spacing--50);
	}

	/* Only make room for a second column when there is a collection to put in
	   it. A room with no featured collection gets the full width for links. */
	.tfs-mega__inner:has(.tfs-mega__feature) {
		grid-template-columns: 3fr 1fr;
	}

	/*
	 * Multi-column rather than a grid, so the list reads down a column and
	 * then across — which is the order the DOM is in, and therefore the order
	 * the arrow keys move in. A row-major grid would have made the two
	 * disagree.
	 */
	.tfs-mega__links {
		column-count: 3;
		column-gap: var(--wp--preset--spacing--40);
	}

	.tfs-mega__link {
		min-height: 0;
		padding-block: var(--wp--custom--step--12);
	}

	.tfs-mega__feature {
		margin-block-start: 0;
	}
}
