/* Front door page styles. Every colour, shadow, radius and font comes from tokens.css;
   the few mixes below (color-mix) only lighten or darken those tokens.
   Papercut: flat stacked layers, the token shadow, 1.5 px gold linework, no gloss. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --page: var(--tuck-bg);
  --text: var(--tuck-ink);
  --text-soft: color-mix(in srgb, var(--tuck-ink) 78%, var(--tuck-bg));
  --paper: var(--tuck-surface);
  --paper-light: color-mix(in srgb, var(--tuck-surface) 45%, #fff);
  --gold-soft: color-mix(in srgb, var(--tuck-gold) 60%, transparent);
  --focus: var(--tuck-teal);
  --hill-back: color-mix(in srgb, var(--tuck-surface) 80%, var(--tuck-bg));
  --hill-front: color-mix(in srgb, var(--tuck-surface) 78%, var(--tuck-gold));
  --gutter: clamp(16px, 4vw, 40px);
  /* The top bar floats over the scene (fix round 2026-11-12), so the lantern string hangs from the
     top of the page exactly as on the family sign-in page; content below keeps this much room. */
  --bar: 56px;
  color-scheme: light;
}

/* Night look: the page's own choice, using the night background token. */
:root.night {
  --page: var(--tuck-bg-night);
  --text: var(--tuck-bg);
  --text-soft: color-mix(in srgb, var(--tuck-bg) 80%, var(--tuck-bg-night));
  --focus: var(--tuck-glow);
  --hill-back: color-mix(in srgb, var(--tuck-bg-night) 82%, var(--tuck-sky));
  --hill-front: color-mix(in srgb, var(--tuck-bg-night) 70%, var(--tuck-teal));
  color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font-family: var(--tuck-font-text);
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color .4s ease, color .4s ease;
}

main { display: flex; flex-direction: column; flex: 1 0 auto; }

h1, h2, h3 { margin: 0; font-family: var(--tuck-font-display); font-weight: 600; line-height: 1.15; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}
/* Headings take focus only programmatically (tabindex -1) so a screen reader lands on the new view.
   They are not controls, so no ring: a ring on a heading looked like a stray box. */
h1:focus, h2:focus, h1:focus-visible, h2:focus-visible { outline: none; }
/* Except the tiles page's name (shipit NITPICK 10, fix round 2 2026-11-12): focus lands there after
   sign-in, and a sighted keyboard user must see where it is. */
/* Fix round 3 (2026-11-12, finding C): keyboard only. app.js always moves focus to #me-name, and a
   script focus on a page the person has not touched yet matches :focus-visible in Chromium, so the
   ring also needs app.js's keyboard flag (<html data-kbd>, set by a key press, cleared by a pointer). */
:root[data-kbd] .me-name:focus-visible { outline: 3px solid var(--focus); outline-offset: 6px; border-radius: 6px; }

/* ------------------------------------------------------------ top bar */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter) 0;
}

.ribbon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 10px;
  background: var(--paper);
  color: var(--tuck-ink);
  border: var(--tuck-line) solid var(--tuck-gold);
  border-radius: var(--tuck-radius-pill);
  box-shadow: var(--tuck-shadow-edge);
  font-size: .875rem;
  font-weight: 700;
}
/* Empty until the page knows its mode: no mock-mode text ever shows in keycloak mode. */
.ribbon:empty { visibility: hidden; }
.ribbon::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tuck-slate);
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 16px;
  background: var(--paper);
  color: var(--tuck-ink);
  border: var(--tuck-line) solid var(--gold-soft);
  border-radius: var(--tuck-radius-pill);
  box-shadow: var(--tuck-shadow-edge);
  font-weight: 700;
  font-size: .9375rem;
  cursor: pointer;
}
.btn-pill:hover { border-color: var(--tuck-gold); }
.btn-pill:active { transform: translateY(1px); box-shadow: none; }
.btn-night[aria-pressed="true"] { background: var(--tuck-ink); color: var(--tuck-bg); border-color: var(--tuck-gold); }
:root.night .btn-night[aria-pressed="true"] { background: var(--tuck-surface); color: var(--tuck-ink); }

/* ------------------------------------------------------------ wordmark */

.wordmark {
  font-family: var(--tuck-font-display);
  font-weight: 700;
  font-size: clamp(2.75rem, 9vw, 4.75rem);
  letter-spacing: -.01em;
  line-height: 1;
  color: var(--text);
  text-align: center;
}
.wordmark::after {
  content: "";
  display: block;
  width: 3.2em;
  height: 12px;
  margin: .22em auto 0;
  background:
    radial-gradient(circle at 50% 50%, var(--tuck-glow) 0 4px, transparent 4.5px),
    linear-gradient(var(--tuck-gold), var(--tuck-gold)) center / 100% var(--tuck-line) no-repeat;
}
.wordmark--small {
  font-size: 1.5rem;
  text-align: left;
}
.wordmark--small::after { width: 100%; height: 8px; margin-top: 4px; background:
  linear-gradient(var(--tuck-gold), var(--tuck-gold)) left center / 100% var(--tuck-line) no-repeat; }

/* ------------------------------------------------------------ door (views a and b) */

.door {
  /* The stage band has one height per viewport and never follows the card, so a figure is
     never resized mid-clip when the card grows, shrinks or shows a message. */
  --stage-h: clamp(240px, calc(100dvh - 476px), 460px);
  position: relative;
  /* The figures' canvases reach past the band's bottom edge (transparent padding); clip at the
     door so they never add a page scroll. Heads draw above the band and stay inside the door. */
  overflow: clip;
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

.lanterns {
  position: absolute;
  inset: -8px 0 auto 0;
  height: 120px;
  overflow: hidden;
  pointer-events: none;
}
.lanterns svg { width: 100%; height: 100%; display: block; }
.lanterns .string { fill: none; stroke: var(--tuck-gold); stroke-width: 1.5; }
.lanterns .tie { stroke: var(--tuck-gold); stroke-width: 1.5; }
.lanterns .cap { fill: var(--tuck-gold); }
.lanterns .body { fill: var(--tuck-glow); transition: fill .6s ease; }
.lanterns .rib { fill: none; stroke: rgba(43,31,26,.22); stroke-width: 1.5; }
.lanterns .lantern { filter: drop-shadow(0 2px 0 rgba(43,31,26,.10)); }
:root.night .lanterns .lantern { filter: drop-shadow(0 0 10px var(--tuck-glow)); }
/* Lantern red is for celebration only: the lanterns turn red when someone comes in. */
.lanterns.celebrate .body { fill: var(--tuck-accent); }
.lanterns.celebrate .lantern:nth-child(odd) .body { transition-delay: .15s; }
.lanterns.celebrate .lantern { filter: drop-shadow(0 0 12px var(--tuck-glow)); }
/* Narrow: the sign-in card sits under the lantern string, so the lanterns hang over its top edge. */
@media (max-width: 899px) { body[data-step="signin"] .lanterns { z-index: 3; } }

.door-top {
  position: relative;
  z-index: 2;
  flex: 1 0 auto;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: calc(clamp(76px, 11vh, 112px) + var(--bar)) var(--gutter) 8px;
}
/* Fix round 11 (owner's Chrome, 2026-11-13: the line-up page was cut off at the bottom). Where the name
   row is one line (680 px and wider), the line-up's head never sets the page's height: the door is the
   window, the stage band keeps its place at the bottom, and a taller head (an error line, a node a
   browser extension adds) runs into the empty sky at the top of the band instead of pushing it down.
   Fix round 11b: only on windows tall enough for the head above the figures. Measured in Chromium, the
   name row ends at 400 px and the highest head starts 222 px above the window's bottom, so below a
   622 px window the figures would be drawn behind the title and the box (932x430, 844x390). There the
   page scrolls as in round 10. 640 px keeps 18 px to spare.
   Fix round 15: with the compact head below (under 640 px tall) the guard holds lower.
   Follow-up (H2): the floor is geometric, at idle no figure's ink meets a text or control box of
   #who grown by 8 px (0 px for the shown name row). Measured in Chromium: 522 px from 1090 px wide
   up (the figures under the text stand lower than the tallest one), 551 px from 680 to 1080 px
   wide (the shown name row then spans a taller figure). Rounded up to 5, with 10 px of width to
   spare. Below these (and on landscape phones) the page scrolls. */
@media (min-width: 1100px) and (min-height: 525px), (min-width: 680px) and (min-height: 555px) {
  body[data-step="who"] .door-top { flex: 1 1 0; min-height: 0; }
}
/* Fix round 15, H (2026-11-15): short, wide windows (Windows laptops at display scaling, 1280x585).
   Under 640 px tall the head shrinks with the window height so the guard above can apply. */
@media (min-width: 680px) and (max-height: 639.98px) {
  .door-top { padding-top: calc(clamp(54px, 9.4vh, 76px) + var(--bar)); }
  #who .wordmark { font-size: clamp(2.75rem, min(9vw, 11vh), 4.75rem); }
  .door-top .who { gap: clamp(10px, 2.2vh, 18px); }
}

.who {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(100%, 30rem);
  text-align: center;
}
.door-title {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  margin-top: 6px;
}

.field-label {
  display: block;
  font-weight: 700;
  font-size: .9375rem;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.name-form { width: 100%; }
/* Fix round 14 (E): the quiet link that shows the name row; a 44 px touch target. */
.type-link { min-height: 44px; }
/* Fix round 10 (owner, 2026-11-13: "the text box should be centered"): the name box alone is centred
   under the title and the hint, at its built width (the row's 30rem less the button and the gap); the
   button hangs to its right with the built gap, outside the box's centred track. Source order stays
   box, then button. Narrow screens stack them (below). */
.name-row {
  --name-box: 21.25rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(var(--name-box), 100%) minmax(0, 1fr);
  column-gap: 10px;
  position: relative;
}
.name-row #username { grid-area: 1 / 2; width: 100%; min-width: 0; }
.name-row .btn { grid-area: 1 / 3; justify-self: start; white-space: nowrap; }
/* Fix round 11 (owner's Chrome, 2026-11-13): a password manager puts its own element beside the box.
   Auto-placed, it took the button's cell and pushed the button to a second row. The box and the
   button have fixed cells (above), and any other child takes no cell and no height. */
.name-row > :not(#username):not(.btn) { position: absolute; }
/* Where the centred box and the button at its right no longer fit inside the side gutters
   (2 x (box/2 + gap + button) + 2 x gutter, about 674 px), the box takes its own line, centred, and
   the button sits under it: the layout phones already had. */
@media (max-width: 679px) {
  .name-row { grid-template-columns: minmax(0, 1fr); row-gap: 10px; }
  .name-row #username { grid-area: 1 / 1; }
  .name-row .btn { grid-area: 2 / 1; }
  .name-row .btn { width: 100%; justify-self: stretch; }
}

input[type="text"], input[type="password"] {
  min-height: 52px;
  padding: 10px 16px;
  background: var(--paper-light);
  color: var(--tuck-ink);
  border: var(--tuck-line) solid var(--tuck-gold);
  border-radius: var(--tuck-radius-card);
  box-shadow: inset 0 2px 0 rgba(43,31,26,.06);
  font-size: 1.125rem;
}
input[type="text"]:focus-visible, input[type="password"]:focus-visible { outline-offset: 2px; border-radius: var(--tuck-radius-card); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 22px;
  border-radius: var(--tuck-radius-pill);
  font-family: var(--tuck-font-display);
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--tuck-shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: translateY(2px); box-shadow: var(--tuck-shadow-edge); }
.btn:disabled { cursor: progress; opacity: .75; }
.btn-primary { background: var(--tuck-teal); color: var(--tuck-bg); border: var(--tuck-line) solid var(--tuck-gold); }
.btn-quiet { background: var(--tuck-surface); color: var(--tuck-ink); border: var(--tuck-line) solid var(--tuck-gold); }

.note {
  min-height: 1.5em;
  color: var(--text-soft);
  font-size: .9375rem;
}

/* Keycloak mode with no way to sign in (AUTH.md): a plain, readable line in place of the form. */
.note.auth-problem {
  max-width: 34rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ sign-in card (view b) */

.signin { width: min(100%, 28rem); }

.card {
  position: relative;
  background: var(--tuck-surface);
  color: var(--tuck-ink);
  border-radius: var(--tuck-radius-panel);
  box-shadow: var(--tuck-shadow);
  padding: 28px clamp(20px, 5vw, 32px) 22px;
  isolation: isolate;
}
/* Inside the card the ring sits on day paper in either look; the night glow ring is 1.4:1 there,
   teal is 3.15:1, so the card keeps teal, as the family sign-in page's card does (fix round 5). */
:root.night .card { --focus: var(--tuck-teal); }
/* the paper layer stacked behind the card */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: color-mix(in srgb, var(--tuck-surface) 70%, var(--tuck-gold));
  transform: rotate(-1.6deg) translate(-4px, 6px);
  box-shadow: var(--tuck-shadow-edge);
}
.card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: var(--tuck-line) solid var(--tuck-gold);
  border-radius: 14px;
  pointer-events: none;
}

.signin-card { display: grid; gap: 14px; text-align: center; }
.signin-hi { font-size: clamp(1.8rem, 6vw, 2.25rem); font-weight: 700; }
.signin-lead { color: color-mix(in srgb, var(--tuck-ink) 80%, var(--tuck-surface)); text-wrap: balance; }
.btn-passkey { width: 100%; min-height: 60px; font-size: 1.3rem; }
.key-glyph { display: inline-flex; }

.link-btn {
  justify-self: center;
  padding: 8px 6px;
  background: none;
  border: 0;
  color: var(--tuck-ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--tuck-gold);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  cursor: pointer;
}

.pw-form { display: grid; gap: 10px; text-align: left; position: relative; z-index: 1; }
.pw-form .field-label { color: var(--tuck-ink); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--tuck-teal); }

/* "needs a fix" is slate, never red */
.refusal {
  text-align: left;
  padding: 10px 14px;
  border-left: 4px solid var(--tuck-slate);
  border-radius: 8px;
  background: color-mix(in srgb, var(--tuck-slate) 16%, var(--tuck-surface));
  color: var(--tuck-ink);
  font-weight: 700;
}
.signin-status { font-weight: 700; }
.signin-status:empty { display: none; }
/* Reserved message slot: the same height empty, waiting or refused, so the card never jumps. */
.signin-msg { display: grid; align-content: center; min-height: 1.6em; }
.is-parent .signin-msg { min-height: 4.6rem; }
.signin-msg .refusal { padding: 8px 12px; }
/* Fix round 15 K.3 (2026-11-15): a short window wider than a phone takes round 14 F's phone rule, no
   reserved band: the slot is as tall as its message and is gone when empty, so the whole picked card,
   "Go back" included, fits 525 px at the passkey and password steps (not yet the refusal). 640+ unchanged. */
@media (min-width: 561px) and (max-height: 639.98px) {
  .signin-msg, .is-parent .signin-msg { min-height: 0; }
  .signin-msg:not(:has(> .refusal:not([hidden]), > .signin-status:not(:empty))) { display: none; }
}

.btn-back {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 14px 6px 8px;
  background: none;
  border: 0;
  border-radius: var(--tuck-radius-pill);
  color: var(--tuck-ink);
  font-weight: 700;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.btn-back:hover { background: color-mix(in srgb, var(--tuck-gold) 22%, transparent); }

/* While signing in, keep the card compact so the stage (and the covered eyes) stays in view. */
body[data-step="signin"] .door-top { padding-top: calc(clamp(40px, 7vh, 72px) + var(--bar)); }
.signin-card.with-password { gap: 10px; padding-top: 22px; padding-bottom: 16px; }
.pw-form .check { justify-self: start; }
/* Wide screens: the card stands in the left column, clear of the lanterns, and the right part of
   the stage band stays free for the picked figure (see PAGE.md, sign-in layout). */
@media (min-width: 900px) {
  body[data-step="signin"] .door-top {
    justify-items: start;
    padding-top: calc(112px + var(--bar));
    padding-left: max(var(--gutter), calc(50% - 560px));
  }
}
.signin-card.with-password .signin-lead { display: none; }
.signin-card.with-password .btn-passkey { min-height: 52px; font-size: 1.2rem; }
.signin-card.with-password input[type="password"], .signin-card.with-password input[type="text"] { min-height: 48px; }

/* ------------------------------------------------------------ stage */

.stage-wrap {
  position: relative;
  flex: 0 0 var(--stage-h);
  height: var(--stage-h);
  margin-top: 12px;
  /* Clip only sideways (figures walking off); raised arms and heads may draw above the band. */
  overflow-x: clip;
  overflow-y: visible;
}
/* Picked composition, shared: begin. The card is centred and the picked figure stands with it
   (fix round 7, 2026-11-13; hint-contract.md, "Picked composition"). Word for word the same in
   site/app.css and the theme's tuck.css (a test compares them), so the hop carries the figure to
   the same pixel. The stage reads these only for a pick, so they hold in every state.
   Side by side (wide, or a short window): the figure at the card's right edge, leaning in.
   Corner (narrower): the figure tucked at the card's lower right corner, in front of its edge. */
.stage-wrap {
  --fd-card-half: min(14rem, 50% - var(--gutter));
  --fd-stand-x: calc(50% + var(--fd-card-half) + 12px);
  --fd-stand-lean: -0.39;
}
@media (min-width: 1064px), (min-width: 900px) and (max-height: 820px) {
  .stage-wrap {
    --fd-stand-x: calc(50% + var(--fd-card-half) - 24px);
    --fd-stand-lean: 0.43;
  }
}
/* Picked composition, shared: end. */
/* While signing in the card floats over the door and may overlap the top of the band;
   the band stays at the bottom with the same height, whatever the card does. */
body[data-step="signin"] .door-top { position: absolute; inset: 0 0 auto 0; }
body[data-step="signin"] .stage-wrap { margin-top: auto; }
/* The hop (fix round 7): the name form under the hop card stays out of the flow too, so the band
   sits on the window's bottom edge exactly as on the Keycloak page it came from. */
:is(:root[data-hop]:not([data-out]) body, :root:not([data-out]) body[data-step="hop"]) .door-top { position: absolute; inset: 0 0 auto 0; }
:is(:root[data-hop]:not([data-out]) body, :root:not([data-out]) body[data-step="hop"]) .stage-wrap { margin-top: auto; }
.hills {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 46%;
  display: block;
}
.hill-back { fill: var(--hill-back); filter: drop-shadow(0 -2px 0 rgba(43,31,26,.06)); }
.hill-front { fill: var(--hill-front); filter: drop-shadow(0 -3px 6px rgba(43,31,26,.10)); }
.hill-line { fill: none; stroke: var(--tuck-gold); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.stage {
  position: absolute;
  inset: 0;
  z-index: 1;
}
/* While figures walk after a pick (data-walking on the stage root), the stage lets every click
   through to the card. Fix round 8 (S1): it also stays under the card (.door-top is z-index 2), so
   no walking figure is ever drawn over a control. Fix round 11 C: the stage stays under the card at
   rest too. */
.stage[data-walking="true"], .stage[data-walking="true"] *,
.stage:has([data-walking="true"]), .stage:has([data-walking="true"]) * { pointer-events: none !important; }

/* Fallback stage: stills with a gentle bob (used when the stage module is missing). */
.still-row {
  position: absolute;
  inset: 0 0 4% 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(0px, 1vw, 16px);
  padding: 0 var(--gutter);
}
.still-figure {
  position: relative;
  height: calc(var(--h) * 92%);
  flex: 0 1 auto;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform .7s cubic-bezier(.5, 0, .4, 1), opacity .5s ease .2s;
}
.still-figure:nth-child(2) { transition-delay: .08s; }
.still-figure:nth-child(3) { transition-delay: .16s; }
.still-figure:nth-child(4) { transition-delay: .24s; }
.still-figure:nth-child(5) { transition-delay: .32s; }
.still-figure:nth-child(6) { transition-delay: .40s; }
.still-img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: bottom;
  transform-origin: 50% 100%;
  animation: bob 3.4s ease-in-out var(--delay, 0s) infinite;
  filter: drop-shadow(0 6px 6px rgba(43,31,26,.18));
}
.still-img.disc, .me-still.disc {
  display: block;
  aspect-ratio: 1;
  height: 40%;
  border-radius: 50%;
  background: var(--tuck-surface);
  border: var(--tuck-line) solid var(--tuck-gold);
  box-shadow: var(--tuck-shadow);
}
.still-name {
  position: absolute;
  bottom: -2px;
  left: 50%;
  translate: -50% 0;
  padding: 2px 10px;
  background: var(--tuck-surface);
  color: var(--tuck-ink);
  border: var(--tuck-line) solid var(--tuck-gold);
  border-radius: var(--tuck-radius-pill);
  font-weight: 700;
  font-size: .875rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s ease;
}
.still-figure:hover .still-name, .still-figure:focus-visible .still-name, .still-figure.is-picked .still-name { opacity: 1; }
.still-figure.is-away { transform: translateX(60vw); opacity: 0; pointer-events: none; }
.still-figure.is-away.to-left { transform: translateX(-60vw); }
.still-figure.is-picked .still-img { animation-duration: 1.6s; }
/* The picked still stands where the live stage would put it: clear of the sign-in card (--fd-stand-x). */
.still-row.has-pick .still-figure.is-picked { position: absolute; bottom: 0; left: var(--fd-stand-x, 50%); translate: -50% 0; }
/* Narrow: the open password card reaches lower, so the picked still is drawn a little smaller to stay below it. */
@media (max-width: 899px) { .still-row.has-pick .still-figure.is-picked { height: calc(var(--h) * 80%); } }
.stage[data-mode="success"] .still-figure.is-picked .still-img { animation: hop .5s ease-in-out 3; }
.stage[data-mode="refused"] .still-figure.is-picked .still-img { animation: shrug .9s ease-in-out 1; }
.stage[data-mode="password"] .still-figure.is-picked .still-img { animation-play-state: paused; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px); } }
@keyframes shrug { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-3deg); } 65% { transform: rotate(3deg); } }

/* ------------------------------------------------------------ entry page (view c) */

.entry {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: calc(20px + var(--bar)) var(--gutter) 64px;
}
.entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hello {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: clamp(16px, 4vw, 40px);
  margin: clamp(20px, 5vh, 44px) 0 clamp(24px, 5vh, 48px);
}
.me-moon {
  position: relative;
  width: clamp(150px, 22vw, 210px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--tuck-surface);
  box-shadow: var(--tuck-shadow), inset 0 0 0 8px color-mix(in srgb, var(--tuck-surface) 60%, #fff);
  outline: var(--tuck-line) solid var(--tuck-gold);
  outline-offset: -14px;
}
.me-avatar {
  position: absolute;
  left: 50%;
  bottom: 0;
  translate: -50% 0;
  height: 128%;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.me-avatar > * { max-height: 100%; }
.me-avatar canvas, .me-avatar img { max-width: 100%; }
.me-still {
  height: 100%;
  width: auto;
  object-fit: contain;
  object-position: bottom;
  animation: bob 3.4s ease-in-out infinite;
  filter: drop-shadow(0 6px 6px rgba(43,31,26,.18));
}
.me-still.disc { height: 70%; margin-bottom: 15%; }
.greet { font-size: clamp(1.15rem, 3vw, 1.4rem); color: var(--text-soft); font-weight: 700; }
.me-name { font-size: clamp(2.75rem, 9vw, 4.5rem); font-weight: 700; letter-spacing: -.01em; }
/* Fix round 15, I (2026-11-15): under 800 px tall the hello block follows the window height in the
   proportion it has at 1280x800 (circle 210/800, name 72/800, greeting 22.4/800); the smaller of the
   width value and the height value wins. Its margins already scale with vh. Tiles do not scale.
   Fix round 15 K.1: wider than a phone only (min-width 561px, as I.1 and app.js SHORT_HOME_MQ). */
@media (min-width: 561px) and (max-height: 799.98px) {
  .me-moon { width: min(clamp(150px, 22vw, 210px), max(120px, 26.25vh)); }
  .greet { font-size: min(clamp(1.15rem, 3vw, 1.4rem), max(1.15rem, 2.8vh)); }
  .me-name { font-size: min(clamp(2.75rem, 9vw, 4.5rem), max(2.25rem, 9vh)); }
}

.tiles-area { display: grid; gap: clamp(28px, 5vh, 44px); }
.tile-section { display: grid; gap: 14px; }
.sec-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.375rem;
}
.sec-title::after {
  content: "";
  flex: 1;
  height: var(--tuck-line);
  background: var(--gold-soft);
}

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}
.tile-item { display: flex; }

.tile {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: start;
  gap: 14px;
  padding: 16px 16px 16px 14px;
  min-height: 96px;
  background: var(--tuck-surface);
  color: var(--tuck-ink);
  text-decoration: none;
  border: var(--tuck-line) solid var(--gold-soft);
  border-radius: var(--tuck-radius-card);
  box-shadow: var(--tuck-shadow);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
a.tile:hover { transform: translateY(-3px); border-color: var(--tuck-gold); box-shadow: var(--tuck-shadow-edge), 0 14px 26px rgba(43,31,26,.18); }
a.tile:active { transform: translateY(1px); box-shadow: var(--tuck-shadow-edge); }
a.tile:focus-visible { outline-offset: 4px; border-radius: var(--tuck-radius-card); }

.tile-icon { display: block; width: 60px; height: 60px; }
.tile-icon .ic { width: 100%; height: 100%; display: block; }
.ic .d { fill: var(--ic, var(--tuck-gold)); }
.ic .ring { fill: none; stroke: var(--tuck-gold); stroke-width: 1.5; }
.ic .p { fill: color-mix(in srgb, var(--tuck-bg) 70%, #fff); }
.ic .w { fill: var(--tuck-glow); }
.ic .gf { fill: var(--tuck-gold); }
.ic .k { fill: var(--tuck-ink); }
.ic .sk { fill: var(--tuck-sky); }
.ic .t { fill: var(--tuck-teal); }
.ic .hole { fill: var(--ic, var(--tuck-gold)); }
.ic .g { fill: none; stroke: var(--tuck-gold); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ic .kl { fill: none; stroke: var(--tuck-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ic .s * { fill: rgba(43,31,26,.22); stroke: none; }
.ic .s .g, .ic .s .kl, .ic .s .hole { display: none; }

.tile-words { display: grid; gap: 4px; min-width: 0; }
.tile-title { font-family: var(--tuck-font-display); font-weight: 600; font-size: 1.25rem; line-height: 1.2; }
.tile-desc { font-size: .9375rem; color: color-mix(in srgb, var(--tuck-ink) 80%, var(--tuck-surface)); }
.tile-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tile-tags:empty { display: none; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border-radius: var(--tuck-radius-pill);
  font-size: .8125rem;
  font-weight: 700;
  color: var(--tuck-ink);
  background: color-mix(in srgb, var(--tuck-surface) 50%, #fff);
  border: var(--tuck-line) solid var(--tuck-gold);
}
.tag-proto::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tuck-teal); }
.tag-soon { border-style: dashed; border-color: color-mix(in srgb, var(--tuck-ink) 40%, transparent); }
.tag-down { border-color: var(--tuck-slate); background: color-mix(in srgb, var(--tuck-slate) 18%, var(--tuck-surface)); }
.tag-down::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tuck-slate); }
.tile-hint { font-size: .875rem; color: var(--tuck-ink); }
.tile-hint code {
  white-space: nowrap;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .8125rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--tuck-slate) 14%, var(--tuck-surface));
  overflow-wrap: anywhere;
}

.tile-soon { background: color-mix(in srgb, var(--tuck-surface) 45%, var(--page)); border-style: dashed; box-shadow: none; }
.tile-soon .tile-icon { filter: grayscale(.85); opacity: .6; }
.tile-soon .tile-title, .tile-soon .tile-desc { color: color-mix(in srgb, var(--tuck-ink) 72%, var(--tuck-surface)); }
:root.night .tile-soon { background: color-mix(in srgb, var(--tuck-surface) 70%, var(--page)); } :root.night .tile-soon .tile-title, :root.night .tile-soon .tile-desc { color: color-mix(in srgb, var(--tuck-ink) 88%, var(--tuck-surface)); } /* 4.96:1 on the night tile (was 3.07:1); below full ink's 6.89:1 so it still reads inactive */
.tile.is-down .tile-icon { filter: grayscale(.5); }

/* Children: larger, friendlier tiles, stacked icon over title. */
.for-children .tiles {
  grid-template-columns: repeat(auto-fit, minmax(200px, 240px));
  justify-content: center;
  align-items: start;
  gap: 18px;
}
.for-children .tile-item { align-self: stretch; }
.for-children .tile { align-content: start; grid-template-rows: auto 1fr; }
.for-children .tile-words { align-content: start; justify-items: center; }
.for-children .tile {
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
  padding: 22px 16px 20px;
  min-height: 200px;
  border-radius: var(--tuck-radius-panel);
}
.for-children .tile-icon { width: 96px; height: 96px; }
.for-children .tile-title { font-size: 1.6rem; font-weight: 700; }
.for-children .tile-tags { justify-content: center; }
.for-children .tile-desc { font-size: 1rem; }
/* Fix round 15 follow-up, I.1 (2026-11-15): under 800 px tall, wider than a phone, the first row
   of tiles fits the window. (a) The space under the hello block and between sections falls
   faster than 5vh: 40 px at 800 tall as before, 8 px (16 px between sections) at 585. The space
   above the hello block stays: the figure stands 28% above its circle, under the wordmark.
   (b) The child tile's icon, vertical padding and gap follow the window height (96 px icon at 800
   tall, 70 px at 585). Text sizes do not change. Phones keep their own tile rules (max-width 560). */
@media (min-width: 561px) and (max-height: 799.98px) {
  /* K.5: 82 px, not 80, so a child with one tile fits 1536x730 (was 1.8 px over). */
  .hello { margin-bottom: clamp(8px, calc(15vh - 82px), 48px); }
  .tiles-area { gap: clamp(16px, calc(15vh - 80px), 44px); }
  .for-children .tile { padding-top: clamp(12px, 2.75vh, 22px); padding-bottom: clamp(10px, 2.5vh, 20px); row-gap: clamp(8px, 1.75vh, 14px); }
  .for-children .tile-icon { width: clamp(56px, 12vh, 96px); height: clamp(56px, 12vh, 96px); }
}

.empty {
  justify-self: start;
  padding: 18px 22px;
  background: var(--tuck-surface);
  color: var(--tuck-ink);
  border: var(--tuck-line) dashed var(--tuck-gold);
  border-radius: var(--tuck-radius-card);
  font-family: var(--tuck-font-display);
  font-weight: 600;
  font-size: 1.35rem;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 560px) {
  .topbar .btn-night { padding: 6px 12px; font-size: .875rem; }
  .hello { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .door { --stage-h: clamp(250px, calc(100dvh - 540px), 400px); }
  body[data-step="signin"] .door-top { padding-top: calc(40px + var(--bar)); }
  .signin-card { gap: 10px; padding-top: 20px; padding-bottom: 14px; }
  /* Fix round 14 (F): no reserved band on the phone. The slot is as tall as its message and is
     gone when empty, so "Go back" sits one gap under the last control; app.js eases the change. */
  .signin-msg, .is-parent .signin-msg { min-height: 0; }
  .signin-msg:not(:has(> .refusal:not([hidden]), > .signin-status:not(:empty))) { display: none; }
  .tile { grid-template-columns: 52px 1fr; }
  .tile-icon { width: 52px; height: 52px; }
  .for-children .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .for-children .tile { min-height: 170px; padding: 18px 10px 16px; }
  .for-children .tile-icon { width: 76px; height: 76px; }
  .for-children .tile-title { font-size: 1.3rem; }
  .for-children .tile-desc { display: none; }
}

/* Phones (fix round 3, 2026-11-12, hub default): nothing in the top bar may cover a lantern, its
   tassel or its glow, and no pill text may wrap. At 390 px the two lanterns in view hang at about
   x 60 to 90 and x 303 to 327 (top 20 to 86), right where the ribbon and the Night look pill sat.
   So the Night look control becomes a 44 px icon button in the top right corner (its name stays for
   screen readers in .night-label, made visually hidden), and the demo ribbon moves to the bottom edge
   of the page, one line. body is the containing block for both. */
@media (max-width: 479px) {
  body { position: relative; }
  .topbar { position: static; height: 0; padding: 0; }
  .topbar .btn-night {
    position: absolute; top: 10px; right: 6px; z-index: 5;
    width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 50%;
  }
  .night-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .ribbon {
    position: absolute; bottom: 8px; left: 50%; translate: -50% 0; z-index: 5;
    max-width: calc(100% - 2 * var(--gutter)); white-space: nowrap; font-size: .8125rem;
  }
  /* Keycloak mode's bare scene and welcome stand where the family sign-in page stood, which has no
     ribbon, and the person at the stand reaches the bottom edge: the ribbon waits for the tiles page. */
  body[data-view="door"][data-step="loading"] .ribbon, body[data-view="door"][data-step="hop"] .ribbon,
  body[data-view="door"][data-step="bare"] .ribbon, body[data-view="door"][data-step="welcome"] .ribbon { visibility: hidden; }
  /* The demo's door: the line-up fills the bottom edge (the front row's feet reach it), so the ribbon
     sits at the top instead, between the two lanterns and below their string (measured at 390x844:
     lanterns end at x 90 and start at x 303, the ribbon is about 172 px wide). */
  body[data-view="door"] .ribbon { bottom: auto; top: 48px; }
  /* The tiles page: the waving figure reaches about 0.6 of the moon's width above the moon (the raised
     hand, measured 91 px at a 150 px moon), so the moon starts that far plus a gap below the title. */
  .hello { margin-top: 104px; }
}

/* ------------------------------------------------------------ keycloak mode: one page */

/* Until the page knows its mode, and while it goes to the family sign-in page: the bare scene
   only (background, lantern string, hills). The demo leaves "loading" as soon as the door shows. */
body[data-step="hop"] .door-top,
body[data-step="loading"] .door-top,
body[data-step="loading"] .stage,
body[data-step="bare"] .door-top,
body[data-step="bare"] .stage { visibility: hidden; }

/* The last hop back from the family sign-in page (shared contract 1, 2026-11-12). hop.js marks
   <html data-hop> before the first paint when the address carries the issuer's answer; this card
   stands where the sign-in card stood (same box as .tk-top and .tk-card in the theme's tuck.css)
   until the token exchange ends, then fades out. The top bar is not on the sign-in page, so it
   waits too. */
.hop {
  display: none;
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  justify-items: center;
  align-content: start;
  gap: 14px;
  padding: 40px var(--gutter) 8px;
}
:root[data-hop] body[data-step="loading"] .hop,
body[data-step="hop"] .hop,
.hop.leaving { display: grid; }
.hop.leaving { opacity: 0; transition: opacity .35s ease; pointer-events: none; }
:root[data-hop] .lanterns { z-index: 3; }
/* Fix round 4 (item 5): the bounce after sign out, on its way to the sign-in page. hop.js marks
   <html data-out>; the card stands where the sign-in card will be (no title: nobody is signing in),
   so no frame shows the scene without a card. The top bar is not on the sign-in page either. */
:root[data-out] body[data-step="loading"] .hop,
:root[data-out] body[data-step="bare"] .hop { display: grid; }
:root[data-out] .hop-title { visibility: hidden; }
/* Fix round 9 (SF1): never a greeting on the way out (app.js removes it in showEntry; this is the second guard). */
:root[data-out] .welcome-name { display: none; }
:root[data-out] .lanterns { z-index: 3; }
:root[data-out] .topbar { visibility: hidden; opacity: 0; transition: none; }
/* Fix round 4 (N1): the top bar is not on the sign-in page, so it waits with opacity 0 and fades in
   with the card's fade out (same .35 s) when data-hop goes. visibility rides the same transition:
   hidden to visible flips at the start, so the fade shows; visible to hidden waits for the end.
   Reduced motion: the global rule below makes both one frame, so the bar comes with the card. */
.topbar { transition: opacity .35s ease, visibility .35s; }
:root[data-hop] .topbar { visibility: hidden; opacity: 0; transition: none; }
.hop-wordmark {
  font-family: var(--tuck-font-display);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 2.75rem);
  letter-spacing: -.01em;
  line-height: 1;
  color: var(--text);
  text-align: center;
}
.hop-wordmark::after {
  content: "";
  display: block;
  width: 3.2em;
  height: 12px;
  margin: .2em auto 0;
  background:
    radial-gradient(circle at 50% 50%, var(--tuck-glow) 0 4px, transparent 4.5px),
    linear-gradient(var(--tuck-gold), var(--tuck-gold)) center / 100% var(--tuck-line) no-repeat;
}
.hop-card {
  width: min(100%, 28rem);
  /* Fix round 8 (M2): the height of the card the person just left on the family sign-in page, from
     the hop hint (hop.js sets --hop-card-h before the first paint); without one, the default. */
  min-height: var(--hop-card-h, 15rem);
  display: grid;
  align-content: center;
  text-align: center;
  padding: 22px clamp(20px, 5vw, 32px) 18px;
}
.hop-title {
  position: relative;
  z-index: 1;
  font-family: var(--tuck-font-display);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 700;
  line-height: 1.15;
}
@media (min-width: 900px) {
  .hop { justify-items: start; padding-top: 112px; padding-left: max(var(--gutter), calc(50% - 560px)); }
  .hop-wordmark { width: 28rem; }
}
@media (max-width: 560px) {
  .hop { padding-top: 34px; gap: 10px; }
  .hop-card { padding: 20px 20px 14px; }
}

/* Picked composition, card and stage, shared: begin. Side by side (wide): the title and card are
   centred on the page's height, the figure beside the card's lower right, feet on the ground line
   (owner, 2026-11-13). Corner (narrower): the card's bottom just over the tallest figure's head. */
body[data-step="signin"] .door-top, body[data-step="welcome"] .door-top, :root[data-hop]:not([data-out]) .hop, :root:not([data-out]) body[data-step="hop"] .hop, :root:not([data-out]) body[data-step="welcome"] .hop, :root:not([data-out]) .hop.leaving {
  position: absolute;
  inset: 0;
  justify-items: center;
  align-content: safe end;
  padding: calc(40px + var(--bar, 0px)) var(--gutter) calc(var(--stage-h) * 0.945 - 21px);
  pointer-events: none;
}
:is(body[data-step="signin"] .door-top, body[data-step="welcome"] .door-top, :root[data-hop]:not([data-out]) .hop, :root:not([data-out]) body[data-step="hop"] .hop, :root:not([data-out]) body[data-step="welcome"] .hop, :root:not([data-out]) .hop.leaving) > * { pointer-events: auto; }
@media (max-width: 560px) {
  body[data-step="signin"] .door-top, body[data-step="welcome"] .door-top, :root[data-hop]:not([data-out]) .hop, :root:not([data-out]) body[data-step="hop"] .hop, :root:not([data-out]) body[data-step="welcome"] .hop, :root:not([data-out]) .hop.leaving { padding-bottom: calc(var(--stage-h) * 0.83 + 4px); }
}
@media (min-width: 1064px), (min-width: 900px) and (max-height: 820px) {
  body[data-step="signin"] .door-top, body[data-step="welcome"] .door-top, :root[data-hop]:not([data-out]) .hop, :root:not([data-out]) body[data-step="hop"] .hop, :root:not([data-out]) body[data-step="welcome"] .hop, :root:not([data-out]) .hop.leaving { align-content: safe center; padding-bottom: calc(40px + var(--bar, 0px)); }
}
/* The stage stays under the card in every state, at rest and on the move (fix round 11 C,
   2026-11-13): the card is in front of every figure. Only the figures' own hit bands take clicks. */
:is(body[data-step="signin"], body[data-step="welcome"], :root[data-hop]:not([data-out]) body, body[data-step="hop"]) .stage-wrap .stage { pointer-events: none; }
:is(body[data-step="signin"], body[data-step="welcome"], :root[data-hop]:not([data-out]) body, body[data-step="hop"]) .stage-wrap .stage .fd-hit { pointer-events: auto; }
/* Picked composition, card and stage, shared: end. */
/* Fix round 8 (M1): the welcome is the hop card with new words, in the hop's place: the card stays
   (the composition selectors above), the band stays on the bottom edge, the words cross-fade. */
:root:not([data-out]) body[data-step="welcome"] .hop { display: grid; }
body[data-step="welcome"] .stage-wrap { margin-top: auto; }
body[data-step="welcome"] .door-top { visibility: hidden; }
.hop-card > * { grid-area: 1 / 1; }
body[data-step="welcome"] .hop-title { opacity: 0; transition: opacity .35s ease; }
/* Fix round 9 (NT1): the greeting waits until the title is nearly gone; never two readable texts in one place. */
.hop-card .welcome-name { animation: fd-fade .5s ease .2s both; }
@keyframes fd-fade { from { opacity: 0; } }
:root:not([data-out]) body .hop.leaving > * { pointer-events: none; }

/* Fresh return: the name over the scene while the person cheers at the stand. */
.welcome-name {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  animation: fd-rise .5s ease both;
}
.welcome-first {
  font-family: var(--tuck-font-display);
  font-size: clamp(2.75rem, 9vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1;
  view-transition-name: fd-me-name;
}
.entry .me-name { view-transition-name: fd-me-name; }
body[data-step="welcome"] .signin,
body[data-step="failed"] .signin { width: min(100%, 32rem); }

/* Then the entry page discloses itself: the header and greeting first, then the tiles in turn. */
@keyframes fd-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.entry.disclose .entry-head { animation: fd-rise .4s ease both; }
.entry.disclose .hello { animation: fd-rise .5s ease .1s both; }
.entry.disclose .sec-title { animation: fd-rise .4s ease .3s both; }
.entry.disclose .tile-item { animation: fd-rise .45s ease both; animation-delay: calc(.35s + var(--i, 0) * 70ms); }

/* ------------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  .welcome-name, .entry.disclose .entry-head, .entry.disclose .hello,
  .entry.disclose .sec-title, .entry.disclose .tile-item { animation: none !important; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  a.tile:hover { transform: none; }
  /* Follow-up R1 (round 9): even a .01ms transition paints the title at 1.0 for one frame while the
     greeting is already shown; the title goes in the same frame the greeting comes. */
  body[data-step="welcome"] .hop-title { transition: none !important; visibility: hidden; }
}
