/* ==========================================================================
   Cooking Classes prototype — foundation
   Fonts, design tokens (from Figma styles), device shell, screen stack,
   sheets/toasts. Screen-specific styles live in css/screens/*.css.
   ========================================================================== */

/* ---------- Fonts ---------- */
@font-face { font-family: "Moret"; src: url("../fonts/Moret-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-Light.otf") format("opentype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-RegularItalic.otf") format("opentype"); font-weight: 400; font-style: italic; font-display: swap; }
/* Figma uses Proxima Nova Medium (500); no Medium file was supplied, so 500 maps to Regular. */
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-Regular.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-Semibold.otf") format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-BoldItalic.otf") format("opentype"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Proxima Nova"; src: url("../fonts/ProximaNova-Extrabold.otf") format("opentype"); font-weight: 800; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  /* Neutral */
  --caviar: #2c2c2c;            /* Neutral/Dark/Shade, Neutral/Caviar */
  --neutral-dark: #555250;      /* Neutral/Dark/Base */
  --neutral-light: #f4f4f3;     /* Neutral/Light/Base */
  --neutral-light-shade: #d2cdca; /* Neutral/Light/Shade */
  --white: #ffffff;
  --bg: #fefdfb;                /* app background (screens, bars, sheets); cards stay white */
  /* Primary */
  --tomato: #d73a15;            /* Primary/Mid/Base */
  --tomato-tint: #e8593b;       /* Primary/Mid/Tint */
  --wine: #81363b;              /* Primary/Dark/Tint */
  --wine-shade: #370614;        /* Primary/Dark/Shade */
  /* Secondary / status */
  --cream: #ffe6b5;             /* Secondary/Mid/Tint */
  --success: #65cd73;

  /* Spacing scale (8pt) */
  --s-4: 4px; --s-8: 8px; --s-12: 12px; --s-16: 16px; --s-24: 24px;
  --s-32: 32px; --s-40: 40px; --s-48: 48px; --s-64: 64px;

  --radius-card: 16px;
  --radius-pill: 80px;

  --font-serif: "Moret", Georgia, serif;
  --font-sans: "Proxima Nova", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  /* Device geometry. Desktop frame mimics iPhone 15 Pro (393×852) with a
     54px status bar and 34px home indicator; on a real phone these come
     from the device's safe areas. */
  --device-w: 393px;
  --device-h: 852px;
  --safe-top: 54px;
  --safe-bottom: 34px;

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
}

html.is-mobile {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
}

/* ---------- Type styles (Figma text styles) ---------- */
.t-moret-xxl { font: 700 48px/54px var(--font-serif); }
.t-moret-xl  { font: 700 36px/40px var(--font-serif); }
.t-moret-lg  { font: 700 32px/36.16px var(--font-serif); }
.t-moret-md  { font: 700 24px/27px var(--font-serif); }
.t-sm        { font: 400 14px/19.6px var(--font-sans); }
.t-sm-med    { font: 500 14px/19.6px var(--font-sans); }
.t-sm-bold   { font: 700 14px/19.6px var(--font-sans); }
.t-md        { font: 400 16px/22.4px var(--font-sans); }
.t-md-bold   { font: 700 16px/22.4px var(--font-sans); }
.t-lg-open   { font: 400 18px/29.25px var(--font-sans); }
.t-label     { font: 500 12px/normal var(--font-sans); letter-spacing: 1.2px; }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #faf8f5;   /* desktop page behind the phone */
  color: var(--caviar);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
p, h1, h2, h3, h4 { margin: 0; }
img { display: block; max-width: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }
[data-go], [data-back], [data-action] { cursor: pointer; }

/* ---------- Stage + device ---------- */
#stage {
  position: fixed; inset: 0; z-index: 1;   /* phone sits above #desk-title (z 0) */
  pointer-events: none;                     /* …but only the phone itself catches clicks */
  display: flex; align-items: center; justify-content: center;
}
#device {
  position: relative; pointer-events: auto;
  width: var(--device-w);
  height: var(--device-h);
  border-radius: 48px;
  background: var(--bg);
  overflow: hidden;
  /* bezel */
  box-shadow: 0 0 0 10px #1c1c1c, 0 0 0 11px #3a3a3a, 0 30px 80px rgba(0,0,0,.35);
  transform-origin: center center;
  flex-shrink: 0;
  isolation: isolate;
}
html.is-mobile #stage { display: block; }
html.is-mobile #device {
  width: 100%; height: 100%;
  border-radius: 0; box-shadow: none; transform: none !important;
}
#app { position: absolute; inset: 0; overflow: hidden; }

/* Desktop status bar overlay (hidden on real phones). */
#statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: 54px;
  z-index: 900; pointer-events: none;
  color: #fff; transition: color .2s;
}
#statusbar.dark { color: var(--caviar); }
#statusbar .sb-time {
  position: absolute; left: 0; width: 35.11%; top: 18px; text-align: center;
  font: 600 17px/22px -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  letter-spacing: -0.4px;
}
#statusbar .sb-levels {
  position: absolute; right: 0; width: 36.39%; top: 23px; height: 13px;
  display: flex; align-items: center; justify-content: center; gap: 7px; padding-left: 8px;
}
#statusbar .sb-levels img { height: 12px; }
#statusbar.dark .sb-levels img { filter: invert(1) brightness(.17); }
#statusbar .sb-battery {
  position: relative; width: 27px; height: 13px;
}
#statusbar .sb-battery::before { /* border */
  content: ""; position: absolute; left: 0; top: 0; width: 25px; height: 13px;
  border: 1px solid currentColor; border-radius: 4.3px; opacity: .35;
}
#statusbar .sb-battery::after { /* cap */
  content: ""; position: absolute; right: 0; top: 4.5px; width: 1.4px; height: 4px;
  background: currentColor; opacity: .4; border-radius: 0 1px 1px 0;
}
#statusbar .sb-battery i {
  position: absolute; left: 2px; top: 2px; width: 21px; height: 9px;
  background: currentColor; border-radius: 2.5px;
}
html.is-mobile #statusbar { display: none; }

#home-indicator {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 134px; height: 5px; border-radius: 100px; background: #000;
  z-index: 950; pointer-events: none; transition: background .2s;
}
#home-indicator.light { background: #fff; }
html.is-mobile #home-indicator { display: none; }

/* Desktop helper controls under/around the phone */
#desk-controls {
  position: fixed; left: 24px; bottom: 24px; display: flex; gap: 8px; z-index: 10;
}
#desk-controls button {
  background: #fff; border-radius: 80px; padding: 10px 16px;
  font: 600 13px/1 var(--font-sans); color: var(--caviar);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
#desk-controls button:hover { background: var(--neutral-light); }
#desk-title {
  position: fixed; left: 24px; top: 24px; z-index: 0;   /* behind the phone when the window is narrow */
  font: 700 18px/1.2 var(--font-serif); color: var(--caviar); pointer-events: none;
}
#desk-title #back-btn {
  display: flex; align-items: center; gap: 2px; width: max-content; margin-bottom: 12px; pointer-events: auto;
  font: 600 13px/1.4 var(--font-sans); color: var(--neutral-dark); text-decoration: none;
}
#desk-title #back-btn svg { margin-left: -4px; flex-shrink: 0; }   /* chevron lines up with the title's left edge */
#desk-title #back-btn:hover { color: var(--caviar); text-decoration: underline; }
#desk-title small { display: block; font: 400 13px/1.4 var(--font-sans); color: var(--neutral-dark); margin-top: 4px; }
html.is-mobile #desk-controls, html.is-mobile #desk-title { display: none; }

/* Mobile: tiny handle for exiting full screen / restarting. */
#fs-handle {
  display: none;
  position: fixed; z-index: 2000;
  top: max(env(safe-area-inset-top, 0px), 2px); left: 50%; transform: translateX(-50%);
  width: 64px; height: 22px; align-items: flex-start; justify-content: center; padding-top: 4px;
}
#fs-handle::before {
  content: ""; width: 36px; height: 5px; border-radius: 5px;
  background: rgba(128,128,128,.55); box-shadow: 0 0 0 1px rgba(255,255,255,.35);
}
html.is-mobile.started #fs-handle { display: flex; }

/* ---------- Screen stack ---------- */
.screen {
  position: absolute; inset: 0;
  background: var(--bg);
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  will-change: transform;
}
.screen::-webkit-scrollbar { display: none; }
.screen[hidden] { display: none; }
/* Screens that manage their own inner scroller set this. */
.screen.no-scroll { overflow: hidden; }

/* Horizontal carousels: full-bleed, 16px gutters, 16px gaps, snap. */
.hscroll {
  display: flex; gap: 16px;
  overflow-x: auto; overflow-y: hidden;
  margin: 0 -16px; padding: 0 16px;
  scroll-padding: 0 16px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex-shrink: 0; }
.hscroll.dragging { scroll-snap-type: none; cursor: grabbing; }
.hscroll.dragging * { pointer-events: none; }

/* ---------- Overlays: backdrop, sheets, toasts ---------- */
.overlay-root { position: absolute; inset: 0; z-index: 800; pointer-events: none; }
.backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
  opacity: 0; transition: opacity .3s ease; pointer-events: auto;
}
.backdrop.show { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: calc(100% - var(--safe-top) - 24px);
  background: var(--bg); border-radius: 24px 24px 0 0;
  transform: translateY(100%);
  transition: transform .4s var(--ease-sheet);
  pointer-events: auto;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sheet.show { transform: translateY(0); }
.sheet-body { overflow-y: auto; scrollbar-width: none; flex: 1 1 auto; overscroll-behavior: contain; }
.sheet-body::-webkit-scrollbar { display: none; }
.sheet-grabber {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 5px; border-radius: 5px; background: var(--neutral-light-shade);
}

.toast-root {
  position: absolute; left: 0; right: 0; top: calc(var(--safe-top) + 8px);
  z-index: 850; display: flex; justify-content: center; pointer-events: none;
}
.toast {
  transform: translateY(-140%); opacity: 0;
  transition: transform .45s var(--ease-sheet), opacity .3s;
  pointer-events: auto;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Prototype action sheet (exit full screen / restart) */
.proto-menu { padding: 24px 16px calc(var(--safe-bottom) + 8px); display: flex; flex-direction: column; gap: 8px; }
.proto-menu h3 { font: 700 16px/22.4px var(--font-sans); text-align: center; margin-bottom: 8px; }
.proto-menu p { font: 400 14px/19.6px var(--font-sans); color: var(--neutral-dark); text-align: center; margin: -4px 0 8px; }
.proto-menu button {
  height: 48px; border-radius: 80px; background: var(--neutral-light);
  font: 700 16px/1 var(--font-sans);
}
.proto-menu button.primary { background: var(--caviar); color: #fff; }

/* Splash / start screen (Figma: "Prototype v4 START") */
.splash {
  position: absolute; inset: 0; z-index: 1000;
  background: linear-gradient(180deg, #fff 15%, #f7f7f7 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: opacity .4s ease;
  padding-bottom: 24px;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash .sticker {
  background: var(--tomato); color: #fff; padding: 10px 8px;
  font: 700 12px/0 var(--font-sans); letter-spacing: 1.2px; text-transform: uppercase;
  height: 20px; display: flex; align-items: center;
}
.splash h1 { width: 340px; text-align: center; margin-top: 16px; color: var(--caviar); }
.splash p { width: 340px; text-align: center; margin-top: 28px; color: var(--caviar); }

/* Screens with fixed chrome: put bars as direct children and the scrolling
   content in .scroller (sticky elements inside .scroller still work). */
.screen.has-scroller { display: flex; flex-direction: column; overflow: hidden; }
.scroller {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain; scrollbar-width: none; position: relative;
}
.scroller::-webkit-scrollbar { display: none; }

/* ---------- Embed mode (?embed, ?frame=0) ---------- */
html.embed body { background: transparent; }
html.embed #desk-title, html.embed #desk-controls { display: none; }
html.no-frame:not(.is-mobile) #device { border-radius: 0; box-shadow: none; }
html.no-frame #home-indicator { display: none; }

/* One-time hint pointing at the phone's options handle (js/core.js handleHint) */
.fs-hint {
  position: fixed; z-index: 2001; left: 50%; top: calc(max(env(safe-area-inset-top, 0px), 2px) + 30px);
  transform: translate(-50%, -6px); opacity: 0; transition: opacity .3s, transform .3s var(--ease-out);
  background: var(--caviar); color: #fff; font: 600 14px/18px var(--font-sans);
  padding: 10px 14px; border-radius: 10px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.fs-hint::before {
  content: ""; position: absolute; left: 50%; top: -6px; margin-left: -6px;
  border: 6px solid transparent; border-top: 0; border-bottom-color: var(--caviar);
}
.fs-hint.show { opacity: 1; transform: translate(-50%, 0); }
