/* The frame's stylesheet, on every page. Linked from the rer:header block
   (frame/README.md), so it loads after the page's own sheets.

   1. The look of the skip link, nav and footer, as the three.js pages set
      them (story/src/base.css and sections.css), inside :where() so they
      weigh nothing: a page whose own sheet styles the frame (the three.js
      pages) keeps its rules, and a page whose sheet does not (the catalogue,
      the plain pages) gets these. The skip link's colours alone outweigh a
      page's bare link rule (below). Tokens fall back to the story's values.
   2. The frame's own parts, which every page gets: the phone menu and the
      footer's end row.
   3. The design language's tokens (v0), on every page: the buttons' and
      tags' wordmark corner reads them on every page, and the components in
      story/src/language/language.css are built from them. */

/* 1. The frame's look */

:where(.skip-link, .nav, .nav *, .footer, .footer *) { box-sizing: border-box; }
:where(.nav, .footer, .skip-link) {
  --frame-gutter: var(--gutter, clamp(16px, 5.21vw, 80px));
  --frame-ui: var(--ui, "Inter Tight", "Helvetica Neue", Arial, sans-serif);
  --frame-mono: var(--mono, "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace);
  font-family: var(--frame-ui);
}
:where(.nav a, .footer a) { color: inherit; text-decoration: none; }
:where(.nav a:focus-visible, .footer a:focus-visible) { outline: 2px solid #fff; outline-offset: 3px; }

/* The skip link: the page's first keyboard stop, to its <main>, shown only
   while it has the focus. */
:where(.skip-link) {
  position: absolute;
  z-index: 10;
  left: var(--frame-gutter);
  top: 12px;
  --rer-h: calc(1lh + 20px);
  padding: 10px 18px;
  border-radius: calc(var(--rer-h) * var(--rer-corner)) var(--rer-radius);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(calc(-100% - 24px));
}
/* Its colours weigh two elements (html a), more than a page's bare link
   rule and less than a class: the three.js pages' `a { color: inherit }`
   (story/src/base.css) would otherwise set their light text on the light
   pill, and a page's own .skip-link rule (the plain pages') still wins. */
html a:where(.skip-link) { background: #f3f1ec; color: #0d0d0d; }
:where(.skip-link:focus) { transform: none; outline: 2px solid #fff; outline-offset: 3px; }

/* Navigation */
:where(.nav) {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  display: flex;
  align-items: center;
  padding: clamp(18px, 3.9vw, 40px) clamp(16px, 4.95vw, 76px) 0 var(--frame-gutter);
  color: #ecebe7;
}
:where(.nav .wordmark) { display: block; width: clamp(64px, 6.64vw, 102px); line-height: 0; }
:where(.nav .wordmark svg, .footer .footer-mark svg) { display: block; width: 100%; height: auto; }
:where(.nav .nav-links) {
  display: flex;
  gap: clamp(28px, 4.2vw, 65px);
  margin-left: clamp(40px, 6.6vw, 101px);
  font-size: clamp(15px, 1.1vw, 17px);
  font-weight: 400;
  letter-spacing: 0.005em;
  color: #d9d8d3;
}
:where(.nav .nav-links a) { transition: color 160ms ease; }
:where(.nav .nav-links a:hover) { color: #fff; }
:where(.nav .nav-cta) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  --rer-h: clamp(40px, 3.3vw, 51px);
  height: var(--rer-h);
  margin-left: auto;
  padding: 0 clamp(18px, 1.95vw, 30px);
  border-radius: calc(var(--rer-h) * var(--rer-corner)) var(--rer-radius);
  background: #f3f1ec;
  color: #0d0d0d;
  font-size: clamp(15px, 1.17vw, 18px);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color 160ms ease;
}
:where(.nav .nav-cta:hover) { background: #fff; }

/* Footer: the links run down their columns, in the owner's order; the
   company line and the copyright under them. */
:where(.footer) {
  margin-top: var(--section-space, clamp(120px, 12vw, 230px));
  padding: clamp(48px, 5vw, 88px) var(--frame-gutter) clamp(28px, 3vw, 48px);
  border-top: 1px solid rgba(236, 235, 231, 0.16);
  color: #ecebe7;
}
:where(.footer .footer-top) { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 48px; }
:where(.footer .footer-mark) { display: block; width: clamp(96px, 8.4vw, 140px); line-height: 0; }
:where(.footer .footer-links) {
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(3, max-content);
  grid-template-rows: repeat(3, auto);
  gap: 16px clamp(40px, 5.5vw, 104px);
  font-size: clamp(15px, 1.05vw, 17px);
  color: #d9d8d3;
}
:where(.footer .footer-links a) { transition: color 160ms ease; }
:where(.footer .footer-links a:hover) { color: #fff; }
:where(.footer .footer-base) {
  margin: clamp(64px, 6.5vw, 112px) 0 0;
  text-align: right;
  font-family: var(--frame-mono);
  font-size: 13px;
  line-height: 1.4;
  color: #a9a8a4;
}

@media (max-width: 900px) {
  :where(.nav) { position: relative; flex-wrap: wrap; row-gap: 14px; padding: 18px var(--frame-gutter) 0; }
  :where(.footer) { margin-top: var(--section-space, clamp(96px, 16vw, 136px)); }
}
@media (max-width: 640px) {
  :where(.footer .footer-links) { grid-template-rows: repeat(4, auto); }
}
@media (max-width: 480px) {
  :where(.nav, .footer, .skip-link) { --frame-gutter: var(--gutter, 16px); }
  :where(.footer) { margin-top: var(--section-space, 96px); }
  :where(.footer .footer-links) { grid-template-columns: repeat(2, max-content); grid-template-rows: repeat(6, auto); gap: 14px 48px; }
  :where(.footer .footer-base) { text-align: left; }
}

/* 2. The frame's own parts */

/* The menu button: shown only where the links fold (900 px and narrower). */

.nav-menu {
  display: none;
  align-items: center;
  gap: 10px;
  --rer-h: 40px;
  height: var(--rer-h);
  padding: 0 16px;
  border: 1px solid rgba(236, 235, 231, 0.78);
  border-radius: calc(var(--rer-h) * var(--rer-corner)) var(--rer-radius);
  background: transparent;
  color: #ecebe7;
  font: 500 14px/1 "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  cursor: pointer;
}
.nav-menu:hover { border-color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-menu:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.nav-menu-bars, .nav-menu-bars::before {
  display: block;
  width: 14px;
  height: 1.5px;
  background: currentColor;
}
.nav-menu-bars { position: relative; transform: translateY(-2.5px); }
.nav-menu-bars::before { content: ''; position: absolute; top: 5px; left: 0; }
.nav-open .nav-menu-bars { transform: translateY(0) rotate(45deg); }
.nav-open .nav-menu-bars::before { top: 0; transform: rotate(-90deg); }

/* 900 px and narrower: the nav keeps the mark, the menu button and Sign in
   on one row; the three links open below it as a panel over the page. */

@media (max-width: 900px) {
  .nav .nav-menu { display: inline-flex; margin-left: auto; }
  .nav .nav-cta { margin-left: 12px; }
  .nav .nav-links { display: none; }
  .nav.nav-open { z-index: 60; }
  .nav.nav-open .nav-links {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    order: 0;
    width: auto;
    margin: 0;
    padding: 12px var(--gutter, 16px) 20px;
    gap: 0;
    background: #000;
    border-bottom: 1px solid rgba(236, 235, 231, 0.16);
    font-size: 18px;
    color: #ecebe7;
  }
  .nav.nav-open .nav-links a { display: flex; align-items: center; min-height: 48px; }
  .nav.nav-open .nav-links a + a { border-top: 1px solid rgba(236, 235, 231, 0.12); }
}

/* Without scripting the button could not open anything: the links stay in
   the header instead, on a row of their own. */

@media (max-width: 900px) and (scripting: none) {
  .nav .nav-menu { display: none; }
  .nav .nav-cta { margin-left: auto; }
  .nav .nav-links { display: flex; order: 3; width: 100%; margin-left: 0; gap: 24px; font-size: 15px; }
}

/* Footer: the copyright on the last row, right-aligned (left under 480px). */

.footer .footer-end {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 32px;
  margin-top: clamp(64px, 6.5vw, 112px);
}
.footer .footer-end .footer-base { margin: 0 0 0 auto; }
.nav-links a[aria-current="page"], .footer-links a[aria-current="page"] { color: #fff; }

@media (max-width: 480px) {
  .footer .footer-end { flex-direction: column; align-items: flex-start; }
  .footer .footer-end .footer-base { margin-left: 0; }
}

/* 3. The design language's tokens (v0, decided 2026-10-01; the style guide
   is design/language-v0/). White on black; the nods come from the RUN / EDIT
   / RUN mark. Prefixed --rer- so they never meet a page's own tokens. */

:root {
  /* Colour. Faint is 3.2:1 on the ground: lines and disabled edges only,
     never text. Lit is reserved for the one lit or active element in a
     view. Signal (cobalt) marks exactly one small thing per view (a live or
     update-ready capsule, a cursor, an active marker), plus at most one
     full-bleed field on the whole site, and never crosses a glyph. Pull red
     belongs to the 3D PULL tab alone and is never used in UI. */
  --rer-ground: #000;
  --rer-ink: #f3f1ec;
  --rer-muted: #a9a8a4;
  --rer-faint: #5e5d5a;
  --rer-lit: #fff;
  --rer-signal: #0647eb;
  --rer-pull: #e03a26;
  --rer-surface: #0b0b0b;

  /* Lines: hairlines 1 px at 14% ink; a tag's edge at 28%; a control's edge
     at 78% (3:1 and more on the ground, as the outline pill has it); 2 px
     only for a lit edge. */
  --rer-hairline: rgba(243, 241, 236, 0.14);
  --rer-line: rgba(243, 241, 236, 0.28);
  --rer-line-strong: rgba(243, 241, 236, 0.78);
  --rer-slot-line: rgba(243, 241, 236, 0.55);

  /* Radii. Blocks take 2 px. Buttons and tags take the wordmark corner:
     0.4 of their own height on the top-left and bottom-right corners, 2 px on
     the other two (`border-radius: calc(var(--rer-h) * var(--rer-corner))
     var(--rer-radius)`, with --rer-h the element's height). */
  --rer-radius: 2px;
  --rer-corner: 0.4;

  /* Type. RER lettering sets one display statement per view (its font-size
     is the cap height); Inter Tight everything else (headline 700, lead
     300, body 400); IBM Plex Mono the metadata and every version, in lower
     case. */
  --rer-ui: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  --rer-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --rer-cap-display: clamp(30px, 8.8vw, 220px); /* POST-SAAS. fits a 343 px column at 375 */
  --rer-cap-price: clamp(56px, 6.4vw, 112px);
  --rer-cap-statement: clamp(34px, 4.4vw, 80px); /* the page statement: Projects. fits a 343 px column at 390 */
  --rer-size-headline: clamp(28px, 3vw, 48px);
  --rer-size-lead: clamp(19px, 1.6vw, 26px);
  --rer-size-body: 17px;
  --rer-size-small: 15px;
  --rer-size-meta: 13px;
  --rer-size-label: 12px;

  /* Space and text (the spacing pass, 2026-10-01: "space things out a lot
     more"). One rhythm for every page in the frame that is not a three.js
     page: the ledger pages (language.css), the plain and legal pages
     (site/page.css, site/legal.css) and the project pages (catalogue.css).
     Each value reaches its widest at about 1440 px; 900 px and narrower the
     nav no longer sits over the page, and phones (640 px and narrower) take
     about 1.4 times the earlier phone rhythm. */
  --rer-space-top: clamp(176px, 17.5vw, 264px);   /* the top of main: the nav to the statement */
  --rer-space-head: clamp(72px, 8.4vw, 136px);    /* the header to the strip; a head's last line to what follows */
  --rer-space-section: clamp(120px, 15.6vw, 240px); /* between major sections */
  --rer-space-inset: clamp(32px, 3vw, 48px);      /* a section's rule to its head, a head to its content */
  --rer-space-row: clamp(26px, 2.3vw, 34px);      /* inside a ruled row, above and below */
  --rer-space-cell: clamp(24px, 2.2vw, 32px);     /* inside a strip cell */
  --rer-space-label: clamp(40px, 4.4vw, 72px);    /* the label column to its content */
  --rer-space-end: clamp(136px, 13vw, 208px);     /* the last section to the footer */
  --rer-space-gap: clamp(20px, 1.8vw, 28px);      /* between parts of one block: a lead and its body, a sentence and its command */
  --rer-leading: 1.6;                             /* running text */
  --rer-measure: 40em;                            /* running text's line length (about 75 characters) */

  /* Motion: run, edit, run. Things arrive leaning and settle upright; nothing
     loops or bounces. Under reduced motion an arrival is a 120 ms fade. */
  --rer-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --rer-fast: 120ms;
  --rer-quick: 200ms;
  --rer-settle: 320ms;
  --rer-slow: 560ms;
  --rer-lean: -12deg;
}

/* 900 px and narrower the nav is a bar above the page, not over it. */
@media (max-width: 900px) {
  :root {
    --rer-space-top: clamp(76px, 12vw, 112px);
    --rer-space-section: clamp(112px, 15.6vw, 140px);
  }
}

/* Phones: about 1.4 times the earlier phone rhythm, no empty screens. */
@media (max-width: 640px) {
  :root {
    --rer-space-top: 76px;
    --rer-space-head: 64px;
    --rer-space-section: 112px;
    --rer-space-inset: 28px;
    --rer-space-row: 26px;
    --rer-space-cell: 20px;
    --rer-space-label: 12px;
    --rer-space-end: 96px;
    --rer-space-gap: 16px;
  }
}
