/* app.css — tokens, layout and components of the app shell (BRIEF-section-5.md §1).
   Values are the comps' own: design/canvas-src/Main.dc.html (chat screen) and Menu.dc.html (briefcase menu), design/COLORS.md.
   Every colour is one of the six theme tokens or #FFFFFF; nothing is dark-filled. Built so far: header, briefcase button and menu,
   stage block, chat column, bubbles, composer, the portrait-only card. Drawers and the other screens come with their steps. */

@font-face { font-family: Nunito; font-weight: 600; font-style: normal; font-display: swap; src: url("../assets/fonts/Nunito-600.woff2") format("woff2"); }
@font-face { font-family: Nunito; font-weight: 700; font-style: normal; font-display: swap; src: url("../assets/fonts/Nunito-700.woff2") format("woff2"); }
@font-face { font-family: Nunito; font-weight: 800; font-style: normal; font-display: swap; src: url("../assets/fonts/Nunito-800.woff2") format("woff2"); }
@font-face { font-family: Nunito; font-weight: 900; font-style: normal; font-display: swap; src: url("../assets/fonts/Nunito-900.woff2") format("woff2"); }

:root {
  /* the theme: cream until js/themes.js applies the saved one */
  --bg: #F7F0E4; --bubble: #EAD7B8; --button: #D9B98C; --line: #E3D6C2; --text: #3F2E22; --muted: #7A5C44;
  --lift: 0 2px 0 rgba(63, 46, 34, 0.15);                                  /* the comps' soft bottom shadow under white controls … */
  /* geometry at 390 x 844: the header row starts just under the status bar (47 + 8 = 55 px down) and is 52 px tall; the stage
     block is the next 280 px (top edge at 113). Dan, 2026-11-12: top gap 12 (the safe area + 8 wins wherever there is a status bar over
     the page), he stands 232 px tall with his horn tips 16 px under the block's top. The comps: 58, 258 and 40, a 330 px block at 116. */
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);   /* the safe area (frame.html's simulated phone overrides these) */
  --hdr-top: max(12px, calc(var(--sat) + 8px));
  --hdr-h: 52px;
  --stage-top: calc(var(--hdr-top) + var(--hdr-h) + 6px);
  --stage-h: 280px;
  --composer-rest: max(30px, var(--sab));                    /* the room under the composer pill: the comp's 30, or the home indicator's */
  --composer-h: calc(14px + 52px + var(--composer-rest));    /* the comp's 14 / 52 / 30 */
  /* the on-screen keyboard (js/composer.js keeps these): --kb is how much of the bottom of the page it covers, --vvt how far the phone
     has panned the page up to show the field. Both are 0 until she types. */
  --kb: 0px; --vvt: 0px;
  --col: 430px;   /* on anything wider than a phone the column stays phone-sized and centred */
}
@supports (color: color-mix(in srgb, red 50%, blue)) { :root { --lift: 0 2px 0 color-mix(in srgb, var(--text) 15%, transparent); } }   /* … in the theme's own text colour */

html.kb-open { --composer-rest: 8px; }   /* sitting on the keyboard, the composer needs no room for the home indicator */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font: 600 16px/1.35 Nunito, system-ui, sans-serif;
  overflow: hidden; touch-action: manipulation;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- header: name + one-word status centred, the briefcase top-right (the only button on the chat screen) */
.hdr {
  position: fixed; z-index: 4; top: var(--vvt); left: 0; right: 0; margin: 0 auto; max-width: var(--col);
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--hdr-top) 20px 0 20px; pointer-events: none;   /* the row itself never takes a tap meant for the character */
}
.hdr-side { position: relative; width: 52px; height: var(--hdr-h); }
.hdr-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hdr-name { font-size: 17px; font-weight: 800; letter-spacing: 0.2px; }
.hdr-status { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- briefcase button and its menu (js/briefcase.js) */
.bc-btn, .bc-circle {
  width: 52px; height: 52px; border-radius: 26px; background: #FFFFFF; box-shadow: var(--lift);
  display: flex; align-items: center; justify-content: center; color: var(--text); flex: 0 0 auto;
}
.bc-btn { border: 0; padding: 0; cursor: pointer; pointer-events: auto; }
.bc-btn[aria-expanded="true"] { background: var(--button); }
.bc-menu {
  position: absolute; right: 0; top: calc(100% + 12px); margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 12px; align-items: flex-end;
}
.bc-menu[hidden] { display: none; }
.bc-item {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  border: 0; padding: 0; background: none; cursor: pointer; pointer-events: auto; white-space: nowrap;
  animation: bc-drop 160ms ease-out backwards;
}
.bc-item:nth-child(2) { animation-delay: 30ms; } .bc-item:nth-child(3) { animation-delay: 60ms; } .bc-item:nth-child(4) { animation-delay: 90ms; }
@keyframes bc-drop { from { opacity: 0; transform: translateY(-10px); } }
.bc-label { background: #FFFFFF; border-radius: 16px; padding: 6px 12px; font-size: 14px; font-weight: 800; line-height: 1.35; box-shadow: var(--lift); }
.bc-circle { position: relative; }
.bc-item.is-full .bc-circle { background: #B9D1A8; }                       /* the cone when he is full (COLORS.md fixed accent) */
.bc-item.is-due .bc-circle::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 4px; background: var(--button); }   /* something timed is due within the hour */
.bc-btn:focus-visible, .bc-item:focus-visible { outline: 3px solid var(--button); outline-offset: 3px; border-radius: 26px; }

/* ---------- the stage block: the character controller draws into it; it never moves or resizes during a session. With the keyboard up
   it stays where it is on the glass: only the chat column gives way (--vvt undoes any pan the phone makes to reveal the field) */
.stage {
  position: fixed; z-index: 1; top: calc(var(--vvt) + var(--stage-top)); left: 0; right: 0; margin: 0 auto; max-width: var(--col);
  height: var(--stage-h);
}

/* ---------- chat column: its own scroller under his feet; bubbles dissolve 36 px before the stage */
.chat {
  position: fixed; z-index: 2; top: calc(var(--vvt) + var(--stage-top) + var(--stage-h)); bottom: calc(var(--kb) + var(--composer-h)); left: 0; right: 0; margin: 0 auto; max-width: var(--col);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 36px 20px 0 20px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 36px); mask-image: linear-gradient(to bottom, transparent 0, #000 36px);
}
.chat::before { content: ""; flex: 1 1 0; margin-bottom: -10px; }   /* newest at the bottom: a few messages sit low, many scroll up under the fade */
.bubble { max-width: 290px; border-radius: 20px 20px 20px 6px; padding: 10px 14px; font-size: 16px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.bubble.his { align-self: flex-start; background: #FFFFFF; border: 2px solid var(--line); }
.bubble.hers { align-self: flex-end; max-width: 270px; background: var(--bubble); border: 2px solid var(--button); border-radius: 20px 20px 6px 20px; }
.turn-hers { align-self: flex-end; max-width: 270px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }   /* a photo above her text */
.turn-hers .bubble.hers { padding: 8px 12px; }
.bubble-photo { width: 150px; height: 110px; border-radius: 16px 16px 6px 16px; border: 2px solid var(--button); background: #FFFFFF; object-fit: cover; }

/* ---------- composer: pill (camera + field) and the round send button. It sits on top of the keyboard while she types (--kb) */
.composer {
  position: fixed; z-index: 3; bottom: var(--kb); left: 0; right: 0; margin: 0 auto; max-width: var(--col); height: var(--composer-h);
  display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 0 16px;
}
.composer-pill { flex: 1 1 0; min-width: 0; height: 52px; border-radius: 26px; border: 2px solid var(--line); background: #FFFFFF; display: flex; align-items: center; padding-right: 14px; }
.composer-cam { width: 44px; height: 44px; border-radius: 22px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0; margin-left: 2px; flex: 0 0 auto; cursor: pointer; }
.composer-field { flex: 1 1 0; min-width: 0; height: 48px; border: 0; background: transparent; padding: 0 4px; font: 600 16px Nunito, system-ui, sans-serif; color: var(--text); outline: none; }
.composer-field::placeholder { color: var(--muted); opacity: 0.75; }
.composer-send { width: 52px; height: 52px; border-radius: 26px; border: 0; background: var(--button); color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; flex: 0 0 auto; cursor: pointer; }
.composer-pill:focus-within { border-color: var(--button); }
.composer-cam:focus-visible, .composer-send:focus-visible { outline: 3px solid var(--button); outline-offset: 2px; }

/* ---------- PREVIEW, not decided, off unless js/composer.js is asked for it (over()): while the keyboard is up the chat column may
   rise over the stage, as far as a line the page gives it (--chat-over-top, px from the top of the page: just under his face), and its
   bubbles turn part see-through so he shows through them. He does not move or change, and when the keyboard goes the column slides
   back under the stage, solid again. Plain alpha only: no blur and no backdrop-filter over the canvas. The column keeps its top fade,
   which moves up with its top edge, and stays anchored on the composer with the newest message showing. */
html.chat-over .chat { transition: top 220ms ease-out, bottom 220ms ease-out; }
html.chat-over .composer { transition: bottom 220ms ease-out; }
html.chat-over .bubble, html.chat-over .bubble-photo { transition: opacity 220ms linear, background-color 220ms linear, border-color 220ms linear; }
html.chat-over.kb-open .chat { top: calc(var(--vvt) + min(var(--chat-over-top, 9999px), var(--stage-top) + var(--stage-h))); }
html.chat-over.kb-open .bubble.his, html.chat-over.kb-open .bubble-photo { opacity: var(--chat-over-his, 0.85); }
html.chat-over.kb-open .bubble.hers { opacity: var(--chat-over-hers, 0.85); }
/* the other way to ghost a bubble: fill and outline see-through, the words solid */
html.chat-over.chat-over-fill.kb-open .bubble { opacity: 1; }
html.chat-over.chat-over-fill.kb-open .bubble.his { background: color-mix(in srgb, #FFFFFF var(--chat-over-his-pc, 85%), transparent); border-color: color-mix(in srgb, var(--line) var(--chat-over-his-pc, 85%), transparent); }
html.chat-over.chat-over-fill.kb-open .bubble.hers { background: color-mix(in srgb, var(--bubble) var(--chat-over-hers-pc, 85%), transparent); border-color: color-mix(in srgb, var(--button) var(--chat-over-hers-pc, 85%), transparent); }
@media (prefers-reduced-motion: reduce) { html.chat-over .chat, html.chat-over .composer, html.chat-over .bubble, html.chat-over .bubble-photo { transition: none; } }

/* ---------- the app page (index.html) only. Dimmed briefcase items: the drawers do not exist yet, so the four items show but take no tap */
.bc-item:disabled { cursor: default; }
/* theme tokens only, fully opaque (he never shows through them): white pills with no lift, words and icons in muted */
.bc-item:disabled .bc-label, .bc-item:disabled .bc-circle { color: var(--muted); box-shadow: none; border: 2px solid var(--line); }
.bc-item:disabled .bc-label { padding: 4px 10px; }   /* (the border takes 2 px of the comp's 6 / 12 padding, so the pill keeps its size) */
.chat[hidden], .composer[hidden] { display: none; }   /* (their own display rules would otherwise win over the hidden attribute) */
/* With the keyboard up and the chat kept under the stage (as designed), the room left can be less than the column's 36 px top padding:
   drop the padding then, so the column closes to nothing instead of showing a strip under the composer */
html.app.kb-open:not(.chat-over) .chat { padding-top: 0; }
/* a composer with no camera button (photos come with a later backend step): the field starts where the pill's curve allows */
.composer-pill.no-cam { padding-left: 14px; }
.composer-send[aria-disabled="true"] { background: var(--line); color: var(--muted); cursor: default; }   /* §2.7: a send button that cannot send is in `line` */
/* a long name never runs into the briefcase: it is cut short with "…" */
html.app .hdr-mid { flex: 1 1 0; min-width: 0; padding: 0 8px; }
html.app .hdr-name, html.app .hdr-status { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* [ui:highlight x]: a two-pulse ring on the briefcase, 1.2 s (§2.8) */
.bc-btn.pulse { animation: bc-pulse 600ms ease-out 2; }
@keyframes bc-pulse { from { box-shadow: var(--lift), 0 0 0 0 var(--button); } to { box-shadow: var(--lift), 0 0 0 12px transparent; } }
/* which way this copy is running, on every page that is not the live product: the header's empty left cell, small, muted */
.mode-tag { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 52px; font-size: 9.5px; font-weight: 800; line-height: 1.25; color: var(--muted); white-space: pre-line; }
.mode-tag[hidden] { display: none; }
/* setting up, or "ask your parent": the character and one card in the chat column's place; no chat, no composer, no briefcase */
.gate { position: fixed; z-index: 2; top: calc(var(--vvt) + var(--stage-top) + var(--stage-h)); bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: var(--col);
  padding: 20px 20px calc(var(--sab) + 20px) 20px; overflow-y: auto; display: flex; flex-direction: column; align-items: stretch; }
.gate[hidden] { display: none; }
.gate-card { background: #FFFFFF; border: 2px solid var(--line); border-radius: 20px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.gate-card[hidden] { display: none; }
.gate-title { margin: 0; font-size: 17px; font-weight: 800; }
.gate-text { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; }
.gate-msg { margin: 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.gate-msg:empty { display: none; }
.gate-field { height: 52px; border-radius: 26px; border: 2px solid var(--line); background: #FFFFFF; padding: 0 18px; font: 800 18px Nunito, system-ui, sans-serif; letter-spacing: 2px; color: var(--text); outline: none; text-transform: uppercase; width: 100%; }
.gate-field:focus { border-color: var(--button); }
.gate-field::placeholder { color: var(--muted); opacity: 1; letter-spacing: 0.5px; text-transform: none; font-weight: 600; }
.gate-btn { height: 52px; border-radius: 26px; border: 0; background: var(--button); color: var(--text); font-weight: 800; font-size: 16px; cursor: pointer; }
.gate-btn.plain { background: transparent; border: 2px solid var(--line); }
.gate-btn:disabled { background: var(--line); color: var(--muted); cursor: default; }
.gate-btn:focus-visible { outline: 3px solid var(--button); outline-offset: 2px; }
/* the moves gallery (tap the character): a white sheet in the chat column's place, never over him */
.gallery { position: fixed; z-index: 3; top: calc(var(--vvt) + var(--stage-top) + var(--stage-h) + 8px); bottom: var(--composer-h); left: 0; right: 0; margin: 0 auto; max-width: calc(var(--col) - 24px);
  width: calc(100% - 24px); background: #FFFFFF; border: 2px solid var(--line); border-radius: 28px 28px 20px 20px; display: flex; flex-direction: column; overflow: hidden; }
.gallery[hidden] { display: none; }
.gallery-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px 18px; }
.gallery-title { margin: 0; font-size: 16px; font-weight: 800; }
.gallery-done { border: 0; background: var(--button); border-radius: 18px; height: 36px; padding: 0 16px; font-weight: 800; font-size: 14px; cursor: pointer; }
.gallery-grid { flex: 1 1 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 14px 14px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; align-content: start; }
.gallery-grid button { border: 2px solid var(--line); background: #FFFFFF; border-radius: 14px; padding: 8px 10px; font-size: 13px; font-weight: 700; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.gallery-grid button:active, .gallery-grid button[aria-pressed="true"] { background: var(--bubble); border-color: var(--button); }
@media (prefers-reduced-motion: reduce) { .bc-btn.pulse { animation: none; } }

/* ---------- portrait only */
.turn { display: none; position: fixed; z-index: 10; inset: 0; background: var(--bg); align-items: center; justify-content: center; padding: 24px; }
.turn-card { background: #FFFFFF; border: 2px solid var(--line); border-radius: 20px; padding: 18px 22px; font-size: 17px; font-weight: 800; }
@media (orientation: landscape) and (max-height: 520px) { .turn { display: flex; } }

@media (prefers-reduced-motion: reduce) { .bc-item { animation: none; } * { scroll-behavior: auto; } }
