/* base.css : reset, Act 1, act shells, u- utilities, .u-consent, HUD shell.
   Owner: Integrator. Layer order is declared in tokens.css. */

/* Registered properties (bible 2.2). Inherited numbers, animatable. */
@property --mono { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --casl { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --wght { syntax: "<number>"; inherits: true; initial-value: 400; }
@property --slnt { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --d { syntax: "<number>"; inherits: true; initial-value: 0; }

@layer base {
  /* Reset */
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  img, svg, canvas { display: block; max-width: 100%; }
  button { font: inherit; color: inherit; touch-action: manipulation; }
  [hidden]:not([hidden="until-found"]) { display: none !important; }

  html {
    background: var(--c0-bg);
    color: var(--c0-ink);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: auto;
    color-scheme: light;
    /* No scroll anchoring: it cancelled ctx.nudge (Act 5's 3 px). Shells have fixed heights, so
       nothing above the reader resizes and anchoring has nothing to fix. */
    overflow-anchor: none;
  }
  body {
    min-height: 100vh;
    font: 400 var(--t-body)/1.6 var(--f-body);
    background: var(--c0-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  main { display: block; }
  ::selection { background: var(--c0-hl); color: var(--c0-ink); }
  :focus-visible { outline: 2px solid var(--c0-accent); outline-offset: 2px; }

  /* Skip link: first focusable element, visible on focus */
  .u-skip {
    position: absolute; left: 12px; top: 12px; z-index: var(--z-skip);
    padding: 10px 14px; border-radius: 8px;
    background: var(--c0-ink); color: var(--c0-bg);
    font: 600 var(--t-small)/1.2 var(--f-body); text-decoration: none;
    transform: translateY(-300%);
  }
  .u-skip:focus, .u-skip:focus-visible { transform: none; }

  /* Act shells (bible 4.2, 5.2). Pre-load background follows the shell's key. */
  .act {
    position: relative;
    min-height: var(--h);
    overflow-x: clip;
    contain: layout style;
    content-visibility: auto;
    contain-intrinsic-size: auto var(--h);
  }
  .act[data-key="S0"] { background: var(--c-s0-bg); color: var(--c-s0-ink); }
  .act[data-key="S1"] { background: var(--c-s1-bg); color: var(--c-s1-ink); }
  .act[data-key="S2"] { background: var(--c-s2-bg); color: var(--c-s2-ink); }
  .act[data-key="S3"] { background: var(--c-s3-bg); color: var(--c-s3-ink); }
  .act[data-key="S4"] { background: var(--c-s4-bg); color: var(--c-s4-ink); }
  .act[data-key="H"] { background: var(--c-h-bg); color: var(--c-h-ink); }
  .act[data-key="S5"] { background: var(--c-s5-bg); color: var(--c-s5-ink); }
  .act[data-key="S6"] { background: var(--c-s6-bg); color: var(--c-s6-ink); }
  .act[data-key="S7"] { background: var(--c-s7-bg); color: var(--c-s7-plate-ink); }
  .act[data-key="S8"] { background: var(--c-s8-bg); color: var(--c-s8-ink); }
  .act.is-failed .u-stage { position: relative; height: auto; overflow: visible; }
  .act.is-failed .u-safe { position: relative; height: auto; }

  /* Shared type, so Act 11 can be a pixel copy of Act 1 */
  .u-col { max-width: var(--col); margin-inline: auto; }
  .u-hero {
    font-family: var(--f-hero); font-weight: 700; font-size: var(--t-hero);
    line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance;
  }
  .u-sub { font: 400 var(--t-sub)/1.5 var(--f-body); color: var(--c0-muted); }
  .u-avatar { width: 72px; height: 72px; }
  @media (min-width: 900px) { .u-avatar { width: 88px; height: 88px; } }

  /* Act 1 ("Hey! I'm Jeff"), bible section 1 and docs/copy/act01-home.md. Static. */
  .u-avatar text { font-family: var(--f-hero); font-weight: 700; fill: #FFFFFF; }
  .a01 { background: var(--c0-bg); color: var(--c0-ink); }
  .a01-page { min-height: 1200px; padding-inline: var(--gutter); }
  .a01-head {
    padding-top: max(72px, 18vh); padding-top: max(72px, 18svh);
    min-height: calc(100vh - 136px); min-height: calc(100svh - 136px);
  }
  .a01-avatar { margin-bottom: var(--s5); }
  .a01-sub { margin-top: var(--s3); }
  .a01-secret { color: transparent; }
  .a01-secret::selection { color: var(--c0-ink); background: var(--c0-hl); }
  .a01-about {
    margin-top: var(--s9); padding: var(--s5);
    background: var(--c0-surface); border: 1px solid var(--c0-rule); border-radius: 12px;
  }
  .a01-label {
    margin-bottom: var(--s2); font: 600 var(--t-label)/1.4 var(--f-body);
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--c0-muted);
  }
  .a01-about p { font-size: var(--t-body); line-height: 1.6; }
  .a01-about .a01-stamp, .a01-foot {
    font-size: var(--t-small); line-height: 1.5; color: var(--c0-muted); font-variant-numeric: tabular-nums;
  }
  .a01-stamp { margin-top: var(--s1); }
  /* The hairline is one row of 2px text (copy 01-04). */
  .a01-rule { margin-top: var(--s8); height: 2px; }
  .a01-rule svg { width: 100%; height: 2px; overflow: hidden; }
  .a01-rule text { font: 400 2px var(--f-body); fill: var(--c0-rule); }
  .a01-foot { padding: 0 var(--gutter) var(--s7); text-align: center; }
  .a01-below { padding: 80vh var(--gutter) 0; padding-top: 80svh; }
  .a01-line { font: 400 var(--t-sub)/1.5 var(--f-body); }
  .a01-line + .a01-line { margin-top: var(--s3); }
  .a01-oh { margin-bottom: var(--s5); }
  .a01-pebble { position: relative; top: 2px; }
  .a01-boxes {
    list-style: none; margin: var(--s6) 0 0; padding: 0;
    display: grid; grid-template-columns: 1fr 1fr; row-gap: 120px; /* Task 15: the below-footer stuff spreads (density) */
  }
  .a01-box { position: relative; width: 136px; }
  .a01-box:nth-child(even) { justify-self: end; text-align: right; margin-top: 40px; }
  .a01-crate { width: 64px; height: 48px; }
  .a01-box:nth-child(even) .a01-crate { margin-left: auto; }
  .a01-tape {
    display: inline-block; margin-top: 6px; padding: 3px 6px;
    background: #F3EBDA; color: var(--c0-muted);
    font: 600 var(--t-label)/1.35 var(--f-body); text-transform: uppercase; letter-spacing: 0.08em;
    transform: rotate(-1.5deg);
  }
  .a01-box:nth-child(even) .a01-tape { transform: rotate(1.5deg); }
  .a01-sticker {
    position: absolute; top: 14px; right: 30px; width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center; text-align: center;
    background: var(--c0-hl); color: var(--c0-muted);
    font: 700 7px/1.1 var(--f-body); letter-spacing: 0.04em; transform: rotate(12deg);
  }
  .a01-pretend-wrap { margin-top: 160px; text-align: center; }
  .a01-pretend {
    min-height: 44px; padding: 0 18px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--c0-rule); background: transparent; color: var(--c0-muted);
    font: 500 var(--t-small)/1 var(--f-body);
  }
  .a01-pretend-out { margin-top: var(--s3); font: 400 var(--t-body)/1.5 var(--f-body); color: var(--c0-muted); }
  .a01-tag { font-size: var(--t-label); color: var(--c0-muted); white-space: nowrap; }
  .a01-fact { position: absolute; left: 0; right: 0; bottom: 190px; padding-inline: var(--gutter); }

  /* Utilities (bible 4.4) */
  .u-stage { position: sticky; top: 0; height: 100vh; height: 100lvh; overflow: clip; }
  .u-safe { position: absolute; top: 0; left: 0; right: 0; height: 100vh; height: 100svh; }
  .u-plate {
    background: var(--u-plate-bg, #FBF8F3); color: var(--u-plate-ink, #1F1B16);
    border-radius: var(--u-plate-r, 10px); padding: var(--u-plate-pad, 12px 16px);
  }
  .u-sr {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .u-rec {
    font-family: var(--f-rec);
    font-variation-settings: "MONO" var(--mono), "CASL" var(--casl), "wght" var(--wght), "slnt" var(--slnt);
  }
  .u-w { display: inline-block; white-space: nowrap; }
  .u-c { display: inline-block; }
  .u-probe { position: fixed; top: 0; left: 0; width: 1px; visibility: hidden; pointer-events: none; }
  .u-probe-s { height: 100vh; height: 100svh; }
  .u-probe-l { height: 100vh; height: 100lvh; }

  /* The consent bar (bible 2.4). One component everywhere: HUD and acts.
     Size and tilt via --u-consent-scale and --u-consent-tilt. Looks like no real product. */
  .u-consent {
    --u-consent-scale: 1; --u-consent-tilt: 0deg;
    display: grid; gap: var(--s3);
    width: min(100%, 34rem); max-height: 22vh; max-height: 22svh; overflow: clip;
    padding: var(--s4) var(--s4) 14px;
    background: #2B2B2B; color: #FBF8F3; border-radius: 14px;
    box-shadow: 0 8px 24px rgba(31, 27, 22, .18);
    font: 500 0.9375rem/1.4 var(--f-body);
    transform: rotate(var(--u-consent-tilt)) scale(var(--u-consent-scale));
    transform-origin: 50% 100%;
    pointer-events: auto;
  }
  .u-consent__text { margin: 0; }
  .u-consent__fine { margin: 0; font-size: 0.75rem; line-height: 1.4; color: #BDB6AC; }
  .u-consent__actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .u-consent__btn {
    min-height: 44px; padding: 0 var(--s4); border-radius: 999px;
    border: 1px solid rgba(251, 248, 243, .5); background: transparent; color: inherit;
    font: 600 var(--t-small)/1 var(--f-body); cursor: pointer;
  }
  .u-consent__btn--primary { background: #FBF8F3; border-color: #FBF8F3; color: #2B2B2B; }
  .u-consent__btn:focus-visible { outline-color: #FFE9A8; }

  /* Easter eggs (docs/patches/eggs-index.md). Invisible ink (E18): transparent text that ::selection
     reveals; iOS ignores ::selection, so the eggs module reads selected ink aloud in a toast.
     Ink and micro text are absolutely positioned inside existing whitespace, so nothing moves. */
  .u-ink { color: transparent; }
  .u-ink::selection { color: var(--c0-ink); background: var(--c0-hl); }
  .a01-stamp, .a01-foot p { position: relative; }
  .u-ink-under { position: absolute; left: 0; right: 0; top: 100%; }
  /* Zoom-only micro text (E19): 12px scaled to 3px with transform, so minimum-font-size settings can't enlarge it. */
  .u-micro {
    position: absolute; left: 50%; top: calc(100% + 24px); width: max-content;
    font: 400 12px/1.2 var(--f-body); color: var(--c0-muted); white-space: nowrap;
    transform: translateX(-50%) scale(.25); transform-origin: 50% 0; pointer-events: none;
  }
  /* The face takes taps (E16) without the long-press callout; panning and pinch zoom still work. */
  .a01-avatar { touch-action: manipulation; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  /* JavaScript off (E25). */
  .u-noscript { max-width: var(--col); margin: 0 auto; padding: var(--s8) var(--gutter); display: grid; gap: var(--s4); }

  /* HUD shell (bible 4.1, 5.3). Mounts are fixed and click-through;
     modules set pointer-events: auto on their own interactive parts. */
  .hud-mount { position: fixed; pointer-events: none; }
  #hud-counter {
    top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
    z-index: var(--z-hud);
  }
  #hud-eggs { inset: 0; z-index: var(--z-hud); }
  #hud-cookie {
    left: calc(12px + env(safe-area-inset-left)); right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex; justify-content: center; z-index: var(--z-cookie);
  }
  #hud-controls {
    top: calc(12px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left));
    z-index: var(--z-controls);
  }
}
