/* Cokoon app shell — loaded AFTER the prototype runtime CSS (public/cokoon/design/).
   The prototype styles .phone as a device mock inside a design studio; in the
   product the same #phone container is the whole app: full viewport on mobile,
   a centred phone-width column on desktop. Overrides only — runtime CSS files
   stay as copied. */
html, body.cokoon-app { height: 100%; }
/* The on-screen keyboard's motion (native-feel #6): everything that moves with it uses this one curve, and
   design/native-ui.js scrolls the focused field into view on the same 250ms (C.keyboard). */
:root { --kb-duration: .25s; --kb-ease: cubic-bezier(.38,.7,.125,1); }
/* C.keyboard reads the final layout in one synchronous pass: nothing may be mid-transition then. */
html.kb-measure *, html.kb-measure *::before, html.kb-measure *::after { transition: none !important; }
body.cokoon-app { margin: 0; background: var(--surface-muted); overflow: hidden; }
body.cokoon-app .cokoon-shell { display: flex; justify-content: center; height: 100dvh; }
body.cokoon-app .phone {
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: 0 0 0 1px var(--shadow-color), 0 28px 65px color-mix(in srgb, var(--shadow-color) 10.98%, transparent);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  /* Native shell: the app shrinks with the on-screen keyboard as it slides (NativeBridge). */
  padding-bottom: var(--keyboard-height, 0px);
  transition: padding-bottom var(--kb-duration) var(--kb-ease);
  box-sizing: border-box;
}
/* Status bar (NOTES #3): paper screens keep the inset on the paper-coloured shell (seamless), but the
   Home scene bleeds to the physical top and its own controls take the inset (immersive-home.css). */
body.cokoon-app .phone.immersive-preview-home { padding-top: 0; }
body.cokoon-app .app-scroll { flex: 1; min-height: 0; height: auto; }
body.cokoon-app .tabbar { position: relative; bottom: auto; flex: none; }
/* Native shell: no tab bar riding on the on-screen keyboard (NativeBridge toggles the class). */
/* It slides down under the keyboard and fades on the keyboard's curve instead of vanishing in one frame
   (native-feel #7). It keeps its place in the layout: the app's keyboard padding is shortened by the bar's
   height instead, so the bar's own slot is what goes under the keyboard and nothing jumps. */
body.cokoon-app #tabbar { transition: transform var(--kb-duration) var(--kb-ease), opacity var(--kb-duration) var(--kb-ease); }
body.keyboard-open #tabbar { transform: translateY(100%); opacity: 0; pointer-events: none; visibility: hidden; transition: transform var(--kb-duration) var(--kb-ease), opacity var(--kb-duration) var(--kb-ease), visibility 0s linear var(--kb-duration); }
body.cokoon-app.keyboard-open .phone:not(.no-tabs):not(.focused-flow) { padding-bottom: max(0px, calc(var(--keyboard-height, 0px) - 49px - env(safe-area-inset-bottom))); }
@media (max-width: 720px) {
  body.cokoon-app { background: var(--page-background); }
  body.cokoon-app .phone { max-width: none; box-shadow: none; }
}
/* Elements core.js writes to that belonged to the design-studio chrome. */
.cokoon-studio-stubs { display: none !important; }
/* Dev-only preview tools (NEXT_PUBLIC_PREVIEW_TOOLS=true), rendered by design/dev-panel.js. */
.cokoon-dev-panel { position: fixed; right: calc(8px + env(safe-area-inset-right)); top: calc(8px + env(safe-area-inset-top)); z-index: 2000; max-width: 220px;
  background: var(--card-background); border: 1px dashed var(--accent); border-radius: 12px; padding: 4px; font: 12px/1.3 system-ui, sans-serif; color: var(--text-primary); box-shadow: 0 6px 18px color-mix(in srgb, var(--shadow-color) 13.33%, transparent); }
.cokoon-dev-panel .dev-toggle { font: inherit; border: 0; background: var(--surface-tinted); color: var(--accent-pressed); border-radius: 8px; padding: 6px 10px; cursor: pointer; width: 100%; }
.cokoon-dev-panel .dev-body { display: grid; gap: 6px; padding: 6px 4px 4px; }
.cokoon-dev-panel select, .cokoon-dev-panel .dev-actions button { font: inherit; width: 100%; }
.cokoon-dev-panel .dev-actions { display: grid; gap: 4px; max-height: 50vh; overflow: auto; }
.cokoon-dev-panel .dev-actions button { text-align: left; border: 1px solid var(--border-default); background: var(--card-background); border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.cokoon-dev-panel .dev-hint { margin: 0; color: var(--text-secondary); }
.cokoon-dev-panel .dev-code { display: grid; gap: 2px; padding: 6px 8px; margin-bottom: 4px; border-radius: 8px; background: var(--warning-background); border: 1px solid var(--warning-border); }
.cokoon-dev-panel .dev-code small { color: var(--text-secondary); overflow-wrap: anywhere; }
.cokoon-dev-panel .dev-code strong { font: 600 18px/1.2 ui-monospace, monospace; letter-spacing: .12em; }
/* Reduced motion also covers sheets rendered outside #phone (UI_SPEC §16). */
body:has(#phone.reduced-motion) #modal-root *, body:has(#phone.reduced-motion) #modal-root *::before, body:has(#phone.reduced-motion) #modal-root *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { #phone *, #modal-root * { animation-iteration-count: 1 !important; } }
/* Visible focus for every control, in the app and in sheets. */
#app-screen :is(button, a, input, select, textarea, summary):focus-visible, #modal-root :is(button, a, input, select, textarea, summary):focus-visible, #tabbar button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Sheet headings receive programmatic focus (C.modal); keep the outline for keyboard users only and clear the close button. */
#modal-root :is(h1, h2, h3)[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
#modal-root .modal-card > :is(h2, div, section) > h2:first-child, #modal-root .modal-card > h2:first-of-type { padding-right: 48px; }
/* The immersive Home puts the stars/shop control top-right, so the dev toggle lives in the left gutter
   as a slim vertical tab (opens rightwards). */
.cokoon-dev-panel { right: auto; left: env(safe-area-inset-left); top: 50%; transform: translateY(-50%); }
.cokoon-dev-panel:not(:has(.dev-body)) { padding: 0; border-left: 0; border-radius: 0 8px 8px 0; }
.cokoon-dev-panel:not(:has(.dev-body)) .dev-toggle { writing-mode: vertical-rl; padding: 8px 2px; font-size: 10px; border-radius: 0 8px 8px 0; }

/* Sheets ride the keyboard (NOTES #1): the backdrop keeps the card above the keyboard as it slides,
   the card scrolls inside itself (never the page) and never runs under the status bar. */
body.cokoon-app .modal-root { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(20px + max(var(--keyboard-height, 0px), env(safe-area-inset-bottom))); transition: padding-bottom var(--kb-duration) var(--kb-ease); }
body.cokoon-app .modal-card { max-height: 100%; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.cokoon-app #modal-root :is(input, textarea, select), body.cokoon-app #app-screen :is(input, textarea, select) { scroll-margin: 24px; }
/* No web text selection or long-press callout on interface chrome (NOTES #5). Fields stay editable;
   a partner's note and revealed answers stay selectable so they can be copied. */
body.cokoon-app, body.cokoon-app #modal-root { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.cokoon-app img, body.cokoon-app svg { -webkit-user-drag: none; }
body.cokoon-app :is(input, textarea, [contenteditable="true"]),
body.cokoon-app :is(.note-full-text, .act-answer-card p, .act-guess-dl dd, .memory-response p, .memory-caption p) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* No double-tap zoom anywhere (NOTES #2); pinch is handled by design/native-feel.js. */
html { touch-action: manipulation; }
/* Boot screen (core.js: signed in, nothing loaded yet). It continues the native splash exactly (same
   color, same 200pt logo centred on the whole screen), so it only shows if the first load outlasts the
   splash's 10 s safety net (NativeBridge), or on the web, and never as an off-brand cream loader.
   .boot-cover is the same picture laid over the whole app by NativeBridge in the native app: it takes over
   from the native splash (which cannot move) and fades into Home once Home is drawn. */
.boot-splash { position: fixed; inset: 0; z-index: 60; background: var(--splash-background); }
.boot-cover { z-index: 2147483000; transition: opacity .25s ease-out; }
.boot-cover.is-leaving { opacity: 0; pointer-events: none; }
.boot-splash-logo {
  position: absolute; left: calc(50% - 100px); top: calc(50% - 100px); width: 200px; height: 200px;
  animation: boot-splash-beat 2.2s ease-in-out infinite; will-change: transform;
}
/* A very discreet heartbeat while the app opens (Vincent 2026-11-20): a rest at the native splash's exact
   size, then a "lub-dub" (4 % then 3 %) over about 1.2 s. Every cycle starts at rest, so the logo is
   still when it takes over from the native splash. The phase comes from window.__cokoonBeatT0 (set as
   an inline animation-delay), so the cover and the boot screen beat together. */
@keyframes boot-splash-beat {
  0%, 45%, 100% { transform: scale(1); }
  55% { transform: scale(1.04); }
  66% { transform: scale(1); }
  76% { transform: scale(1.03); }
  92% { transform: scale(1); }
}
.boot-splash-wait {
  position: absolute; left: 0; right: 0; top: calc(50% + 124px);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  opacity: 0; animation: boot-splash-in .4s ease-out 1.2s forwards;
}
.boot-splash-wait p { margin: 0; font-size: .9375rem; color: var(--page-background); }
.boot-splash-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--page-background) 25%, transparent);
  border-top-color: var(--page-background);
  animation: boot-splash-spin .9s linear infinite;
}
@keyframes boot-splash-in { to { opacity: 1; } }
@keyframes boot-splash-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-splash-logo { animation: none; }
  .boot-cover { transition-duration: .01s; }
  .boot-splash-wait { animation-duration: .01s; }
  .boot-splash-spinner { animation: none; }
}
