/*
 * Hone layout primitives — safe-edge tokens, edge frame, and overlay/sheet
 * frame. Canonical contract: docs/WEBSITE_RESPONSIVE_CONTRACT.md
 * ("Safe areas, overlays, and viewport").
 *
 * Everything lives in the `hone-layout` cascade layer, so any unlayered
 * consumer rule wins and this file can never silently override app styling.
 * Selectors are limited to :root custom properties, `html[data-hone-overlay-open]`,
 * and `.hone-*` classes. There is no reset.
 *
 * Ownership rule: exactly one independently viewport-rooted surface owns each
 * physical edge. Edge clearance is max(gutter, remaining unsafe inset), never
 * gutter + inset and never a guessed device constant.
 */
@layer hone-layout {
  :root {
    /* The only sanctioned raw safe-area source. Consumers read these tokens;
       a zero inset is legitimate and is never replaced by a device guess. */
    --hone-safe-top: env(safe-area-inset-top, 0px);
    --hone-safe-right: env(safe-area-inset-right, 0px);
    --hone-safe-bottom: env(safe-area-inset-bottom, 0px);
    --hone-safe-left: env(safe-area-inset-left, 0px);
    /* Written only by the viewport owner (viewport.mjs) while an editable
       control is focused and the on-screen keyboard occludes the layout
       viewport. Zero otherwise, including during pinch zoom. */
    --hone-keyboard-inset: 0px;
    /* The part of the bottom inset the keyboard does not already cover.
       Keyboard occlusion and the home-indicator inset are never added. */
    --hone-safe-bottom-uncovered: max(0px, calc(var(--hone-safe-bottom) - var(--hone-keyboard-inset)));
    /* App-frame height: the dynamic viewport, never taller than the measured
       window. Android Chrome can size 100dvh/100vh against browser controls
       that are not on screen (an installed app's hidden toolbar), pushing a
       bottom-docked composer under the gesture bar. The viewport owner
       publishes the measured height; until it runs this is plain 100dvh.
       Use for root shells, full-height rails and viewport-relative maxima. */
    --hone-viewport-height: 100dvh;
    --hone-app-height: min(100dvh, var(--hone-viewport-height));
    /* Normal component gutter. Consumers override on :root or per surface. */
    --hone-gutter: 16px;
    /* Hone design minimum for close/primary icon controls (not a WCAG claim). */
    --hone-touch-target: 44px;
  }

  /* While any modal overlay is open the document does not scroll behind it. */
  html[data-hone-overlay-open] {
    overflow: hidden;
  }

  /* A viewport-rooted screen that owns all four physical edges. */
  .hone-edge-frame {
    box-sizing: border-box;
    padding:
      max(var(--hone-gutter), var(--hone-safe-top))
      max(var(--hone-gutter), var(--hone-safe-right))
      max(var(--hone-gutter), var(--hone-safe-bottom))
      max(var(--hone-gutter), var(--hone-safe-left));
  }

  /* Independently rooted overlay. The backdrop paints to every physical edge;
     only the sheet inside it (or, for centered dialogs, this backdrop's
     padding) owns edge protection. The keyboard occludes the bottom, so it is
     subtracted from the safe bottom instead of being added to it. */
  .hone-overlay {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    padding: 0 0 var(--hone-keyboard-inset);
    overflow: hidden;
    overscroll-behavior: contain;
  }

  .hone-sheet {
    --hone-sheet-width: min(var(--hone-sheet-inline-size, 560px), 100%);
    --hone-sheet-pad-top: var(--hone-gutter);
    --hone-sheet-pad-right: var(--hone-gutter);
    --hone-sheet-pad-bottom: var(--hone-gutter);
    --hone-sheet-pad-left: var(--hone-gutter);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    padding: var(--hone-sheet-pad-top) var(--hone-sheet-pad-right) var(--hone-sheet-pad-bottom) var(--hone-sheet-pad-left);
    overflow: hidden;
  }

  .hone-sheet__head,
  .hone-sheet__foot {
    flex: none;
    min-width: 0;
  }

  /* The only scroller inside a sheet: the close control in the head and the
     actions in the foot stay reachable while long content scrolls. */
  .hone-sheet__body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }

  /* A short sheet with no head/body split (a confirmation) may scroll as one
     unit. Register it as an exception if it can grow long. */
  .hone-sheet--scroll {
    display: block;
    overflow: auto;
    overscroll-behavior: contain;
  }

  /* End (inline-end) drawer: touches top, end, bottom, and — when narrower
     than its preferred width — the start edge too. Its start padding consumes
     only the part of the start inset it actually overlaps. */
  .hone-overlay--end {
    justify-items: end;
    align-items: stretch;
  }

  .hone-overlay--end > .hone-sheet {
    width: var(--hone-sheet-width);
    height: 100%;
    --hone-sheet-pad-top: max(var(--hone-gutter), var(--hone-safe-top));
    --hone-sheet-pad-right: max(var(--hone-gutter), var(--hone-safe-right));
    --hone-sheet-pad-bottom: max(var(--hone-gutter), var(--hone-safe-bottom-uncovered));
    --hone-sheet-pad-left: max(var(--hone-gutter), calc(var(--hone-safe-left) - (100% - var(--hone-sheet-width))));
  }

  /* Bottom sheet and centered dialog share one parametric geometry.
     --hone-overlay-floating: 0 attaches the sheet to the bottom edge (the
       sheet owns the bottom inset and whatever side inset it overlaps);
       1 floats it (the backdrop padding owns every edge once and the sheet
       keeps only its gutter).
     --hone-overlay-align: end | center | start (block-axis position).
     --hone-overlay-obstacle-bottom: extra clearance for an app-docked control
       the sheet must not cover (e.g. a composer); use with floating: 1.
     Apps switch placement at their OWN breakpoints by setting these
     properties in their media queries; the geometry itself stays here. */
  .hone-overlay--bottom,
  .hone-overlay--center {
    --hone-overlay-floating: 0;
    --hone-overlay-align: end;
    --hone-overlay-obstacle-bottom: 0px;
    align-items: var(--hone-overlay-align);
    justify-items: center;
    padding:
      max(var(--hone-gutter), var(--hone-safe-top))
      calc(var(--hone-overlay-floating) * max(var(--hone-gutter), var(--hone-safe-right)))
      calc(var(--hone-keyboard-inset) + var(--hone-overlay-obstacle-bottom) + var(--hone-overlay-floating) * max(var(--hone-gutter), var(--hone-safe-bottom-uncovered)))
      calc(var(--hone-overlay-floating) * max(var(--hone-gutter), var(--hone-safe-left)));
  }

  .hone-overlay--center {
    --hone-overlay-floating: 1;
    --hone-overlay-align: center;
  }

  .hone-overlay--bottom > .hone-sheet,
  .hone-overlay--center > .hone-sheet {
    width: var(--hone-sheet-width);
    --hone-sheet-pad-bottom: calc((1 - var(--hone-overlay-floating)) * max(var(--hone-gutter), var(--hone-safe-bottom-uncovered)) + var(--hone-overlay-floating) * var(--hone-gutter));
    --hone-sheet-pad-left: calc((1 - var(--hone-overlay-floating)) * max(var(--hone-gutter), calc(var(--hone-safe-left) - (100% - var(--hone-sheet-width)) / 2)) + var(--hone-overlay-floating) * var(--hone-gutter));
    --hone-sheet-pad-right: calc((1 - var(--hone-overlay-floating)) * max(var(--hone-gutter), calc(var(--hone-safe-right) - (100% - var(--hone-sheet-width)) / 2)) + var(--hone-overlay-floating) * var(--hone-gutter));
  }

  .hone-overlay--center > .hone-sheet {
    --hone-sheet-inline-size: 520px;
  }

  /* Full-bleed media (lightbox): content may reach every edge; controls are
     placed with .hone-overlay__edge-action inside the safe rectangle. */
  .hone-overlay--full {
    place-items: center;
  }

  .hone-overlay__edge-action {
    position: absolute;
    top: max(var(--hone-gutter), var(--hone-safe-top));
    right: max(var(--hone-gutter), var(--hone-safe-right));
  }

  .hone-touch-target {
    box-sizing: border-box;
    min-width: var(--hone-touch-target);
    min-height: var(--hone-touch-target);
  }
}

@font-face { font-family: "Figtree"; src: url(fonts/figtree.woff2) format("woff2"); font-weight: 300 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url(fonts/inter.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }
* { box-sizing: border-box; }
:root {
  --molten: #F4511E; --molten-deep: #D9420F; --mineral: #E6E6E1; --charcoal: #343532;
  --paper: #F5F3EE; --card: #FBFAF7; --mute: #77766F; --line: #D9D7D0;
  --display: "Figtree", system-ui, sans-serif;
  color-scheme: light; background: var(--paper); color: var(--charcoal);
  font: 400 100%/1.5 "Inter", system-ui, sans-serif;
}
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
.frame { display: grid; min-height: calc(100dvh - 2 * var(--hone-gutter, 16px)); grid-template-rows: auto 1fr; gap: 8px; }
.art { display: grid; place-items: center start; }
.art svg { width: 76px; height: 76px; overflow: visible; }
.art path { fill: none; stroke: var(--molten); stroke-linecap: round; stroke-linejoin: round; }
main { width: 100%; max-width: 26rem; overflow-wrap: anywhere; align-self: start; padding-block: 8px 24px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wordmark { margin: 0; }
.space { margin: 0 0 6px; font-size: .875rem; color: var(--mute); letter-spacing: .02em; }
h1 { font: 300 clamp(2.6rem, 9vw, 4.4rem)/.98 var(--display); letter-spacing: -.035em; margin: 8px 0 14px; }
.lede { margin: 0 0 28px; color: var(--mute); max-width: 24rem; }
form { display: grid; gap: 10px; margin-block: 12px; min-width: 0; }
label { font-size: .875rem; font-weight: 500; }
input, button { min-height: 48px; width: 100%; min-width: 0; font: inherit; border-radius: 12px; padding: .7rem 1rem; }
input { background: var(--card); color: var(--charcoal); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #A4A39B; }
input:hover { border-color: #BDBBB3; }
input:focus { border-color: var(--molten); box-shadow: 0 0 0 4px rgba(244, 81, 30, .14); outline: none; }
input.code { font-size: 1.6rem; letter-spacing: .5em; text-align: center; padding-inline: .5em 0; font-variant-numeric: tabular-nums; }
button { cursor: pointer; white-space: normal; border: 1px solid transparent; font-weight: 500; transition: background .15s, border-color .15s, transform .1s; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: progress; }
.primary { background: var(--molten); color: #fff; }
.primary:hover { background: var(--molten-deep); }
.provider { display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--card); color: var(--charcoal); border-color: var(--line); }
.provider:hover { border-color: #BDBBB3; background: #fff; }
.provider .g { width: 20px; height: 20px; flex: none; }
.or { display: flex; align-items: center; gap: 14px; margin: 22px 0 6px; color: var(--mute); font-size: .8125rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.quiet { margin-top: 18px; gap: 2px; }
.link { background: none; color: var(--charcoal); min-height: 44px; width: auto; justify-self: start; padding: 0; text-decoration: underline; text-decoration-color: var(--molten); text-underline-offset: 4px; }
.hint, #form-status { margin: 0; font-size: .8125rem; color: var(--mute); }
#form-status { color: var(--molten-deep); margin-top: 4px; }
:focus-visible { outline: 3px solid var(--molten); outline-offset: 3px; }
footer { margin-top: 40px; font-size: .8125rem; color: var(--mute); }
@media (min-width: 900px) {
  .frame { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: 1fr; gap: clamp(32px, 6vw, 96px); align-items: center; }
  .art { place-items: center; align-self: stretch; background: var(--mineral); border-radius: 28px; min-height: 520px; }
  .art svg { width: min(62%, 440px); height: auto; aspect-ratio: 1; }
  main { align-self: center; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Staging only: link back to the internal library. */
.staging-home { position: fixed; bottom: 12px; left: 12px; z-index: 5; padding: 8px 14px; border-radius: 999px; background: #1f1d1a; color: #f6f4ed; font-size: .8125rem; text-decoration: none; }
