/* Hyldehelten prototype — page layout, the home panel and the room drawings */

:root {
  /* brand colours, sampled from the mockups */
  --cream: #fefbeb;
  --cream-2: #fef8ed;
  --green: #e8f2dc;
  --green-2: #d6e5c6;
  --ink: #12243b;
  --ink-2: rgba(18, 36, 59, .68);
  --ink-3: rgba(18, 36, 59, .45);
  --line: rgba(18, 36, 59, .12);
  --coral: #fe7059;
  --coral-soft: #ffe2da;
  --coral-ink: #c0391f;
  --ok: #2c8a57;
  --ok-soft: #dbefdf;

  --display: 'Syne', 'Poppins', system-ui, sans-serif;
  --body: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: linear-gradient(165deg, #fefbeb 0%, #eef5e2 52%, #e2eed4 100%) fixed;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- split view ---------- */
.split {
  display: grid;
  /* --phone-w / --phone-h are set by main.js, so the phone's column can animate away in 2035 mode */
  grid-template-columns: minmax(0, 1fr) var(--phone-w, auto);
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(24px, 3.4vw, 60px);
  padding: clamp(18px, 2.8vw, 44px);
  height: 100dvh;
  min-height: 560px;
  overflow-x: clip;
}

/* ---------- left: the home ---------- */
.home {
  container-type: inline-size;      /* lets the top bar tighten up when the box gets narrow */
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, .62);
  border: 1.5px solid var(--line);
  border-radius: 34px;
  overflow: hidden;
  box-shadow: 0 30px 60px -42px rgba(18, 36, 59, .4);
}
.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 13px 16px;
}
/* the simulation clock: date, Reset and Next day */
.sim-ctl { display: flex; align-items: center; gap: 8px; flex: none; }
.sim-date { display: grid; margin: 0 6px 0 4px; line-height: 1.2; white-space: nowrap; }
.sim-date b { font-size: 13.5px; font-weight: 600; }
.sim-date small { font-size: 11.5px; color: var(--ink-2); }

.nav { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
/* the 2035 switch: phone today, smart glasses in 2035 */
.mode-btn {
  display: flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--ink); border-radius: 999px;
  padding: 0 15px 0 12px; min-height: 43px;
  background: transparent;
  font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: .05em;
  cursor: pointer;
  transition: background .2s, box-shadow .2s, transform .12s;
}
.mode-btn .ic { width: 20px; height: 20px; transform: rotate(-8deg); }
.mode-btn:hover { background: rgba(18, 36, 59, .07); }
.mode-btn:active { transform: scale(.97); }
.mode-btn[aria-pressed="true"] { background: var(--coral); box-shadow: 0 0 0 4px rgba(254, 112, 89, .24); }
.mode-btn[aria-pressed="true"]:hover { background: #ff8672; }
.mode-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.rooms { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(18, 36, 59, .07); }
.rooms button {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  border: 0; border-radius: 999px;
  padding: 8px 15px 8px 11px;
  background: transparent;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.rooms button .ic { width: 19px; height: 19px; transform: rotate(-8deg); }
.rooms button:hover { background: rgba(18, 36, 59, .07); }
.rooms button[aria-selected="true"] { background: #000; color: #fff; font-weight: 600; }
.rooms button .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 2px rgba(254, 112, 89, .25); }
.rooms button.ping { animation: ping .5s ease 3; }
@keyframes ping { 50% { background: var(--coral-soft); } }

.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; width: 24px; height: 24px; flex: none; }

.scene-wrap { position: relative; flex: 1; min-height: 0; display: flex; overflow: hidden; border-top: 1.5px solid var(--line); }
.ai-toggle {
  position: absolute; top: 12px; right: 12px; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 13px 6px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .88); border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 500; cursor: pointer; user-select: none;
}
.ai-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sw { position: relative; width: 38px; height: 22px; border-radius: 11px; background: rgba(18, 36, 59, .2); transition: background .18s; flex: none; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
input:checked + .sw { background: var(--ink); }
input:checked + .sw::after { transform: translateX(16px); }
input:focus-visible + .sw { outline: 2px solid var(--ink); outline-offset: 2px; }

.scene {
  position: relative;
  flex: 1; min-width: 0; min-height: 0;
  background: var(--cream);
  overflow: hidden;
}
.scene-svg { display: block; width: 100%; height: 100%; overflow: visible; }

.btn { border: 0; border-radius: 14px; padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform .12s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.dark { background: #000; color: #fff; }
.btn.dark:hover { background: var(--ink); }
.btn.ghost { background: rgba(18, 36, 59, .08); }
.btn.ghost:hover { background: rgba(18, 36, 59, .14); }
.btn:focus-visible, .rooms button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* narrow box (phone showing in a small window): keep the top bar on one line */
@container (max-width: 800px) {
  .home-head { gap: 8px 10px; padding: 12px; }
  .sim-ctl { gap: 6px; }
  .sim-date { margin: 0 4px 0 2px; }
  .btn { padding: 10px 12px; }
  .nav { gap: 6px; }
  .mode-btn { padding: 0 12px 0 10px; }
  .rooms { gap: 2px; }
  .rooms button { padding: 8px 12px; }
  .rooms button .ic { display: none; }
}

/* ---------- drawing styles (rooms + product packs) ---------- */
.s { stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.s2 { stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.sl { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.o { stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.ln { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.ln.thin { stroke-width: 1.5; stroke-opacity: .5; }
/* units that have been used up (eggs, rolls, bananas …) */
.gone { fill: rgba(255, 255, 255, .3); stroke-opacity: .3; stroke-dasharray: 3 3.500; }
.ln.gone { fill: none; }
.core.gone, .leaf.gone { display: none; }
/* the "empty" part of a pack: the same drawing, faded */
.pk-ghost * { fill: rgba(255, 255, 255, .36); stroke-opacity: .3; }
.pk-ghost .ln { fill: none; }

.bg, .front, .overlay, .deco { pointer-events: none; }
.led { fill: #4fdc86; animation: blink 2.2s infinite; }
.sensor-off .led { fill: #8a96a3; animation: none; }
@keyframes blink { 0%, 60%, 100% { opacity: 1; } 75% { opacity: .25; } }

/* products you can click */
.it { cursor: pointer; outline: none; }
.it .hit { fill: transparent; }
.it .pk { transition: transform .18s ease; transform-box: fill-box; transform-origin: 50% 100%; }
.it:hover .pk, .it:focus-visible .pk { transform: translateY(-3px); }
.it:focus-visible .hit { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 3; }
.it.used .pk { animation: tilt .42s ease; }
.it.nope .pk { animation: shake .36s ease; }
.it.fresh .pk { animation: pop .7s cubic-bezier(.3, 1.5, .5, 1) both; }
.cl { transition: y .5s cubic-bezier(.3, .8, .3, 1), width .5s cubic-bezier(.3, .8, .3, 1); }
@keyframes tilt { 30% { transform: rotate(-7deg) translateY(-4px); } 70% { transform: rotate(4deg); } }
@keyframes shake { 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }
@keyframes pop { from { transform: scale(.4) translateY(-30px); opacity: 0; } }

.flag { opacity: 0; transition: opacity .2s; pointer-events: none; }
.flag circle { fill: var(--coral); stroke: var(--ink); stroke-width: 1.6; }
.flag text { font: 700 11px var(--body); fill: var(--ink); }
.it.is-low .flag, .it.is-ordered .flag { opacity: 1; }
.it.is-low .flag { animation: bob 1.4s ease-in-out infinite; }
.it.is-ordered .flag circle { fill: #bfe8cb; }
.ai-on .flag { display: none; }
@keyframes bob { 50% { transform: translateY(-2.500px); } }
.flag { transform-box: fill-box; }

/* AI view + scan */
.det .br { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.det .chip rect { fill: var(--ink); }
.det .chip text { font: 600 11.5px var(--body); fill: #fff; }
.det.low .br { stroke: var(--coral); opacity: 1; }
.det.low .chip rect { fill: var(--coral); }
.det.low .chip text { fill: var(--ink); }
.det.scan { animation: detIn .25s ease both, detOut .3s ease 2.7s both; }
.det .sweep { fill: var(--coral); animation: sweep 1.05s ease-in-out 2 alternate both; }
@keyframes sweep { from { transform: translateY(0); } to { transform: translateY(var(--h)); } }
@keyframes detIn { from { opacity: 0; } }
@keyframes detOut { to { opacity: 0; } }

/* hover card */
.tip {
  position: absolute; z-index: 5;
  display: grid; gap: 5px;
  width: max-content; min-width: 180px; max-width: 250px;
  padding: 10px 12px 9px;
  border-radius: 14px;
  background: var(--ink); color: #fff;
  font-size: 12px; line-height: 1.35;
  transform: translate(-50%, -100%);
  pointer-events: none;
  box-shadow: 0 12px 26px -12px rgba(18, 36, 59, .7);
}
.tip.below { transform: translate(-50%, 0); }
.tip strong { font-weight: 600; font-size: 12.5px; }
.tip-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.tip-bar i { display: block; height: 100%; border-radius: 3px; background: #9fe6b6; }
.tip-bar.low i, .tip-bar.out i { background: var(--coral); }
.tip span { opacity: .92; }
.tip em { font-style: normal; font-size: 11px; opacity: .62; }

.scene-off {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 28px);
  padding: 8px 14px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 12.5px;
}
.scene-off .ic { width: 18px; height: 18px; }

/* ---------- right: the phone column ---------- */
.phone-col { display: flex; align-items: center; justify-content: flex-start; min-width: 0; min-height: 0; }
.phone-holder { position: relative; flex: none; }
.device { transform-origin: 0 0; }

/* ---------- 2035: the phone slides off to the right and the home takes the whole page ---------- */
.mode-anim .split { transition: grid-template-columns .8s cubic-bezier(.65, 0, .25, 1), gap .8s cubic-bezier(.65, 0, .25, 1); }
.mode-anim .phone-col { transition: transform .8s cubic-bezier(.65, 0, .25, 1), height .8s cubic-bezier(.65, 0, .25, 1), padding .8s, visibility 0s; }
.is-2035 .split { grid-template-columns: minmax(0, 1fr) 0px; gap: 0px; }
.is-2035 .phone-col { transform: translateX(calc(14vw + 60px)); visibility: hidden; pointer-events: none; }
.is-2035.mode-anim .phone-col { transition: transform .8s cubic-bezier(.65, 0, .25, 1), height .8s cubic-bezier(.65, 0, .25, 1), padding .8s, visibility 0s .8s; }
.ai-toggle { transition: opacity .3s, visibility 0s; }
.is-2035 .ai-toggle { opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }   /* the glasses are the AI view */

/* ---------- small screens: stack the two halves ---------- */
@media (max-width: 880px) {
  .split, .is-2035 .split { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .scene { aspect-ratio: 900 / 640; }
  .phone-col { justify-content: center; height: calc(var(--phone-h) + 24px); padding-bottom: 24px; }
  .is-2035 .phone-col { height: 0; padding-bottom: 0; transform: translateX(110vw); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
