/* ============================================================================
   layout.css

   Structural frames only: the masthead, the hero composition, section rhythm,
   grids, the footer. Surfaces come from components.css, colour from theme.css.
   ========================================================================= */

:root { --mh: 4.25rem; }        /* masthead height, referenced by sticky heads */

/* ══ Shell ════════════════════════════════════════════════════════════════ */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.shell--wide { max-width: var(--shell-w); }

/* ══ Masthead ═════════════════════════════════════════════════════════════
   A quiet bar with one bronze edge along the bottom. It is chrome, so it gets
   no ornament at all.                                                        */
.masthead {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: color-mix(in srgb, var(--c-ground) 86%, transparent);
  backdrop-filter: blur(10px) saturate(115%);
  transition: background var(--t-mid) var(--ease-out);
}

/* Once the page has moved, the bar earns a little more body. Chrome only. */
.masthead.is-scrolled {
  background: color-mix(in srgb, var(--c-ground) 96%, transparent);
}

.masthead__rail {
  height: 1px;
  background: linear-gradient(90deg,
      transparent 0%,
      var(--c-rule-brass) 18%,
      var(--c-brass) 50%,
      var(--c-rule-brass) 82%,
      transparent 100%);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  height: var(--mh);
}

/* ── Brand: a stamped part number, not a logotype ─────────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  width: 2rem; height: 2rem;
  flex: none;
  stroke: var(--c-brass);
  fill: none;
  stroke-width: 1.5;
  transition: stroke var(--t-mid) var(--ease-mech), rotate var(--t-slow) var(--ease-mech);
}
.brand:hover .brand__mark { stroke: var(--c-brass-lt); rotate: 30deg; }

.brand__text { display: flex; flex-direction: column; line-height: 1.15; }

.brand__name {
  font-family: var(--ff-display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--c-fg);
}

.brand__role {
  font-family: var(--ff-mono);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--c-fg-mute);
}

/* ── Nav: a filament under the active link ────────────────────────────────── */
.nav { display: flex; align-items: center; gap: var(--sp-1); }

.nav__link {
  position: relative;
  padding: 0.5rem 0.7rem;
  color: var(--c-fg-dim);
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-mech);
}

.nav__link::after {
  content: "";
  position: absolute;
  bottom: 0.28rem;
  left: 0.7rem;
  right: 0.7rem;
  height: 1px;
  background: var(--c-mark);
  scale: 0 1;
  transform-origin: left;
  transition: scale var(--t-mid) var(--ease-mech);
}

.nav__link:hover { color: var(--c-fg); }
.nav__link:hover::after,
.nav__link[aria-current="true"]::after,
.nav__link[aria-current="page"]::after { scale: 1 1; }
.nav__link[aria-current="page"] { color: var(--c-mark-txt); }

.nav__sep {
  width: 1px;
  height: 1.1rem;
  margin-inline: var(--sp-2);
  background: var(--c-rule);
}

/* ── Burger ───────────────────────────────────────────────────────────────── */
.burger {
  display: none;
  width: 2.5rem; height: 2.5rem;
  border: 1px solid var(--c-rule-hi);
  border-radius: var(--r-ctl);
  background: transparent;
  cursor: pointer;
}

.burger__bars {
  position: relative;
  display: block;
  width: 1.1rem; height: 1.5px;
  margin-inline: auto;
  background: var(--c-fg);
  transition: background var(--t-fast) linear;
}
.burger__bars::before,
.burger__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%; height: 1.5px;
  background: var(--c-fg);
  transition: transform var(--t-mid) var(--ease-mech);
}
.burger__bars::before { top: -5px; }
.burger__bars::after  { top:  5px; }
.burger[aria-expanded="true"] .burger__bars { background: transparent; }
.burger[aria-expanded="true"] .burger__bars::before { transform: translateY(5px) rotate(45deg); }
.burger[aria-expanded="true"] .burger__bars::after  { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 54rem) {
  .burger { display: block; }
  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--sp-3) var(--gutter) var(--sp-5);
    border-bottom: 1px solid var(--c-rule);
    background: color-mix(in srgb, var(--c-ground) 97%, transparent);
    backdrop-filter: blur(12px);
    clip-path: inset(0 0 100% 0);
    transition: clip-path var(--t-mid) var(--ease-mech);
  }
  .nav[data-open="true"] { clip-path: inset(0 0 0 0); }
  .nav__link { padding: 0.85rem 0.25rem; font-size: 0.9rem; }
  .nav__link::after { left: 0.25rem; right: auto; width: 1.5rem; }
  .nav__sep { width: auto; height: 1px; margin: 0.35rem 0.25rem; }
}

/* ══ Hero ═════════════════════════════════════════════════════════════════
   One drawing, hung on the wall behind the copy and weighted to the right; the
   lamp above it; a few wheels turning at the left edge. The copy itself sits on
   nothing at all — no panel, no card — so the drawing behind it stays the
   thing you look at. On scroll the whole drawing rides away to the right.     */
.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: min(calc(100svh - var(--mh)), 56rem);
  padding-block: clamp(var(--sp-7), 8vh, var(--sp-9)) var(--sp-8);
  overflow: hidden;
}

/* ── The background drawing ───────────────────────────────────────────────────
   Anchored by height so it bleeds past the top and bottom edges, and masked so
   it dissolves before it reaches the copy. CSS owns the resting offset and
   tilt through `translate`/`rotate`; hero-scroll.js writes `transform`, and the
   browser composes the two — they never fight over one declaration.           */
.hero__draft {
  position: absolute;
  z-index: 0;
  top: 50%;
  right: clamp(-6rem, -2vw, 0rem);
  translate: 0 -50%;
  rotate: -1.4deg;
  height: min(126%, 54rem);
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
  will-change: transform, opacity;
  /* The fade softens the sheet's left edge; it is not protecting the copy, which
     at this width never reaches the drawing. Lifted so the parts list and the
     mesh detail on that side are legible rather than merely present. */
  -webkit-mask-image: linear-gradient(97deg,
      transparent 0%, rgba(0, 0, 0, 0.3) 14%, rgba(0, 0, 0, 0.82) 38%, #000 58%);
          mask-image: linear-gradient(97deg,
      transparent 0%, rgba(0, 0, 0, 0.3) 14%, rgba(0, 0, 0, 0.82) 38%, #000 58%);
}
.hero__draft img { height: 100%; width: auto; max-width: none; }

/* ── Lamplight, spilling from the top-right corner over the drawing ───────── */
.hero__glow {
  position: absolute;
  z-index: 1;
  top: -22%;
  right: -12%;
  width: min(62vw, 48rem);
  aspect-ratio: 1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%,
      var(--glow-warm) 0%, var(--glow-soft) 36%, transparent 68%);
  animation: glowPulse 7.3s var(--ease-mech) infinite;
}

/* Uneven on purpose: a flame, not a metronome. */
@keyframes glowPulse {
  0%   { opacity: 0.86; transform: scale(1); }
  17%  { opacity: 1;    transform: scale(1.035); }
  29%  { opacity: 0.9;  transform: scale(1.01); }
  46%  { opacity: 1;    transform: scale(1.05); }
  58%  { opacity: 0.82; transform: scale(0.995); }
  74%  { opacity: 0.97; transform: scale(1.03); }
  88%  { opacity: 0.88; transform: scale(1.005); }
  100% { opacity: 0.86; transform: scale(1); }
}

/* ── Wheels and rose at the left edge ─────────────────────────────────────── */
.hero__decor {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.hero .gear--a { top: -7rem;    left: -9rem;   width: clamp(13rem, 24vw, 22rem); --spin: 74s; --gear-op: .3; }
.hero .gear--b { bottom: -5rem; left: 3rem;    width: clamp(8rem, 13vw, 12rem);  --spin: 52s; --gear-op: .24; }
.hero .gear--c { bottom: 24%;   left: -3.2rem; width: clamp(5rem, 8vw, 7.5rem);  --spin: 38s; --gear-op: .26; }
.hero .compass--hero { bottom: -7rem; left: 27%; width: clamp(9rem, 15vw, 14rem); --compass-op: .13; }

/* ── The lamp itself, hanging over the board ──────────────────────────────── */
.hero__lamp {
  position: absolute;
  z-index: var(--z-lamp);
  top: -3.2rem;                      /* the mount goes off-frame: a hanging lamp
                                        comes down from somewhere, it does not
                                        float on its own hook mid-air */
  right: clamp(0.5rem, 5vw, 4.5rem);
  width: clamp(7rem, 12vw, 11rem);
  transform-origin: 50% 0;
  animation: sway 11s ease-in-out infinite;
  filter: drop-shadow(0 0 20px var(--glow-soft)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}
@keyframes sway {
  0%, 100% { transform: rotate(-0.9deg); }
  50%      { transform: rotate(0.9deg); }
}

/* ── The copy ─────────────────────────────────────────────────────────────── */
.hero__inner {
  position: relative;
  z-index: var(--z-content);
  width: 100%;
}

.hero__card { max-width: min(62ch, 56%); }

.hero__over { margin-bottom: var(--sp-3); }

.hero__name {
  font-family: var(--ff-display);
  font-size: var(--fs-hero);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  color: var(--c-fg);
}

/* One bronze rule under the name, the width of a title block. */
.hero__name::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 2px;
  margin-top: var(--sp-4);
  background: linear-gradient(90deg, var(--c-brass), transparent);
}

.hero__tag {
  max-width: 52ch;
  margin-top: var(--sp-5);
  font-size: var(--fs-lead);
  line-height: 1.62;
  color: var(--c-fg-dim);
}

.hero__readout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-6);
}

.hero__cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-6); }

/* ── Scroll hint: a plumb line ────────────────────────────────────────────── */
.hero__hint {
  position: absolute;
  z-index: var(--z-content);
  bottom: var(--sp-5);
  left: 50%;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}
.hero__hint .label { font-size: 0.64rem; color: var(--c-brass); }

.hero__hint-line {
  width: 1px;
  height: 2.4rem;
  background: linear-gradient(180deg, transparent, var(--c-brass));
  animation: plumb 2.9s var(--ease-mech) infinite;
}
@keyframes plumb {
  0%, 100% { opacity: 0.3; transform: scaleY(0.55); transform-origin: top; }
  50%      { opacity: 1;   transform: scaleY(1);    transform-origin: top; }
}

@media (max-width: 62rem) {
  /* The drawing gives up its column and becomes a full-bleed backdrop. */
  .hero__card { max-width: none; }
  .hero__draft {
    right: -14vw;
    height: min(112%, 44rem);
    opacity: 0.2;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.35) 74%, transparent 100%);
            mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.35) 74%, transparent 100%);
  }
  .hero__lamp { top: -2.6rem; right: -1rem; width: clamp(5rem, 20vw, 7.5rem); }
  .hero .compass--hero { display: none; }
  .hero__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero__glow, .hero__lamp, .hero__hint-line, .gear { animation: none; }
}

/* ══ Page head — the hero's quieter cousin on the subpages ════════════════ */
.pagehead {
  position: relative;
  isolation: isolate;
  padding-block: clamp(var(--sp-7), 9vh, var(--sp-9)) clamp(var(--sp-6), 5vh, var(--sp-8));
  overflow: hidden;
  border-bottom: 1px solid var(--c-rule);
}

.pagehead__decor {
  position: absolute;
  inset: 0;
  z-index: var(--z-decor);
  pointer-events: none;
}

.pagehead .gear--a { top: -6.5rem;  right: -7rem; width: clamp(11rem, 19vw, 17rem); --spin: 88s; --gear-op: .13; }
.pagehead .gear--b { bottom: -5rem; left: -3rem;  width: clamp(7rem, 12vw, 11rem);  --spin: 60s; --gear-op: .14; }

/* the lamp signs the subpages the way it signs the hero */
.pagehead__lamp {
  position: absolute;
  z-index: var(--z-lamp);
  top: -2.6rem;
  right: clamp(0.5rem, 6vw, 5rem);
  width: clamp(5rem, 9vw, 8rem);
  transform-origin: 50% 0;
  animation: sway 13s ease-in-out infinite;
  filter: drop-shadow(0 0 16px var(--glow-soft));
  pointer-events: none;
}

.pagehead__glow {
  position: absolute;
  z-index: var(--z-decor);
  top: -40%;
  right: -8%;
  width: min(48vw, 34rem);
  aspect-ratio: 1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 44%,
      var(--glow-warm) 0%, var(--glow-soft) 38%, transparent 70%);
}

.pagehead__inner { position: relative; z-index: var(--z-content); }
.pagehead__over { margin-bottom: var(--sp-3); }

.pagehead__title {
  font-family: var(--ff-display);
  font-size: clamp(2.2rem, 5.4vw, 3.6rem);
  font-weight: 600;
  line-height: var(--lh-head);
  letter-spacing: var(--ls-display);
  color: var(--c-fg);
}

.pagehead__sub {
  max-width: 64ch;
  margin-top: var(--sp-4);
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--c-fg-dim);
}

.pagehead__cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }

@media (max-width: 62rem) {
  .pagehead__lamp { width: clamp(4rem, 14vw, 5.5rem); right: -0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pagehead__lamp { animation: none; }
}

/* ══ Sections ═════════════════════════════════════════════════════════════ */
.section {
  position: relative;
  padding-block: clamp(var(--sp-7), 8vh, var(--sp-9));
}
.section--tight { padding-block: clamp(var(--sp-6), 5vh, var(--sp-7)); }

/* An alternate band: one step up from the ground, ruled top and bottom. */
.section--alt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: var(--z-decor);
  border-block: 1px solid var(--c-rule);
  background: color-mix(in srgb, var(--c-ground-hi) 70%, transparent);
}

/* ── Section head: index numeral, title, rule ─────────────────────────────── */
.section__head {
  position: relative;
  z-index: var(--z-content);
  display: flex;
  align-items: baseline;
  gap: clamp(var(--sp-4), 2vw, var(--sp-6));
  margin-bottom: clamp(var(--sp-5), 3vw, var(--sp-7));
}

.section__idx {
  flex: none;
  font-family: var(--ff-mono);
  font-size: clamp(1.3rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-mark-txt);
  opacity: 0.82;
}

.section__titles { min-width: 0; }

.section__title {
  font-family: var(--ff-display);
  font-size: var(--fs-h2);
  font-weight: 600;
  line-height: var(--lh-head);
  letter-spacing: var(--ls-display);
  color: var(--c-fg);
}

.section__sub {
  max-width: 68ch;
  margin-top: var(--sp-3);
  font-size: var(--fs-body);
  color: var(--c-fg-dim);
}

.section__rule {
  flex: 1 1 auto;
  height: 1px;
  min-width: var(--sp-6);
  align-self: center;
  background: linear-gradient(90deg, var(--c-rule-brass), transparent);
}

/* A drawn rule between sections — decor, so it may be as elaborate as it likes. */
.section__flourish {
  width: 100%;
  max-width: var(--shell);
  margin: clamp(var(--sp-6), 5vh, var(--sp-8)) auto 0;
  padding-inline: var(--gutter);
  opacity: 0.4;
  pointer-events: none;
}

/* ══ Grids ════════════════════════════════════════════════════════════════ */
.grid { display: grid; gap: clamp(var(--sp-4), 2.4vw, var(--sp-6)); }

/* Four plates in a 2×2 block reads as a template. So the work grid is three-up
   with the lead card taking the whole first row: the arrangement says which one
   to read first, and nothing has to shout to say it. */
.grid--cards  { grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.grid--feature { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--feature > .plate--feature { grid-column: 1 / -1; }

/* Below the three-up width there is no room for the arrangement, so the lead
   card drops back into the ordinary flow instead of stranding an orphan. */
@media (max-width: 62rem) {
  .grid--feature { grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr)); }
  .grid--feature > .plate--feature { grid-column: auto; }
}
.grid--halves { grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }

/* Three rails hung side by side. A 16rem floor keeps all three in one row on
   the desktop shell, drops to two, then to one — no media query needed. */
.grid--rails  { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid--about  { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }

@media (max-width: 58rem) {
  .grid--about { grid-template-columns: 1fr; }
}

/* ══ Footer ═══════════════════════════════════════════════════════════════ */
.footer {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-top: clamp(var(--sp-7), 8vh, var(--sp-9));
  border-top: 1px solid var(--c-rule);
  background: var(--c-ground-lo);
}

.footer__decor {
  position: absolute;
  inset: 0;
  z-index: var(--z-decor);
  pointer-events: none;
}

.footer__glow {
  position: absolute;
  top: -30%;
  left: 8%;
  width: min(44vw, 30rem);
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 50%,
      var(--glow-soft) 0%, transparent 62%);
}

.footer .gear--a { bottom: -6rem; right: -4rem; width: clamp(9rem, 16vw, 14rem); --spin: 96s; --gear-op: .13; }

.footer__inner {
  position: relative;
  z-index: var(--z-content);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4) var(--sp-6);
  padding-block: clamp(var(--sp-5), 4vh, var(--sp-7));
}

/* What the thing is made of, under the sheet designation. */
.footer__build {
  margin-top: var(--sp-2);
  color: var(--fg-mute);
  font-size: var(--fs-sm);
}

.footer__links { display: flex; flex-wrap: wrap; gap: var(--sp-4); }

.footer__links a {
  color: var(--c-fg-dim);
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-mono);
  text-decoration: none;
}
.footer__links a:hover { color: var(--c-brass-lt); }

/* ── Colophon ─────────────────────────────────────────────────────────────────
   A printer's note at the very end: what the thing is set in and how the plates
   were struck. Landing page only, the way a colophon appears once in a book.   */
.footer__colophon {
  position: relative;
  z-index: var(--z-content);
  padding-block: var(--sp-5) clamp(var(--sp-5), 4vh, var(--sp-6));
  border-top: 1px solid var(--c-rule);
}

.footer__note {
  max-width: 66ch;
  margin-top: var(--sp-3);
  color: var(--fg-mute);
  font-size: var(--fs-sm);
}

/* The one instruction on the page, kept at the size of a footnote. */
.footer__hint {
  margin-top: var(--sp-3);
  color: var(--fg-mute);
  font-size: var(--fs-sm);
}

.footer__hint kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0.1em 0.35em;
  border: 1px solid var(--c-rule-brass);
  color: var(--c-brass-lt);
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  text-align: center;
}

/* His own line, in the register the rest of the sheet uses for part numbers.
   The one sentence here that is not explaining anything. */
.footer__btw {
  margin-top: var(--sp-4);
  color: var(--fg-dim);
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-mono);
}
