/* FamilyWall — Night/Day Glass.
   Sizes are in rem; the root size scales with the screen so a 1080×1920 wall
   gets 16px rem and everything reads from across the kitchen. */

:root {
  --day: 0; /* 0 = night sky, 1 = day sky; set from JS by sunrise/sunset */
  --radius: 2rem;
  --gap: 2rem;
  --pad: 4rem;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: 1.5s ease;
}

[data-theme="night"] {
  --text: #e8edf7;
  --muted: #9aa7bd;
  --faint: #6f7c93;
  --tile: rgba(255, 255, 255, 0.06);
  --tile-press: rgba(255, 255, 255, 0.12);
  --tile-border: rgba(255, 255, 255, 0.10);
  --shadow: none;
  --track: rgba(255, 255, 255, 0.10);
  --meals: #f2b880;  --meals-fill: #f2b880;  --meals-on: #1a1206;
  --garden: #8fd4a8; --garden-fill: #8fd4a8; --garden-on: #07160d;
  --money: #8fb8ff;  --money-fill: #8fb8ff;  --money-on: #0b1630;
  --cal: #c9a7ff;
  --alert: #ffb3a1;
  --good: #8fd4a8;
  --chip: rgba(255, 255, 255, 0.08);
}

[data-theme="day"] {
  --text: #142033;
  --muted: #55627a;
  --faint: #7d889b;
  --tile: rgba(255, 255, 255, 0.72);
  --tile-press: rgba(255, 255, 255, 0.95);
  --tile-border: rgba(255, 255, 255, 0.95);
  --shadow: 0 0.75rem 2rem rgba(40, 60, 100, 0.08);
  --track: rgba(20, 32, 51, 0.08);
  --meals: #a5561a;  --meals-fill: #e8954a;  --meals-on: #1a1206;
  --garden: #2f7d50; --garden-fill: #2f7d50; --garden-on: #ffffff;
  --money: #2f5fb3;  --money-fill: #4a7fd6;  --money-on: #ffffff;
  --cal: #6f4bb8;
  --alert: #b23a22;
  --good: #2f7d50;
  --chip: rgba(20, 32, 51, 0.06);
}

* { box-sizing: border-box; }

html {
  font-size: clamp(11px, min(100vw / 67.5, 100vh / 120), 30px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: #0a101d;
  overflow-x: hidden;
  transition: color var(--ease);
  -webkit-tap-highlight-color: transparent;
}

/* Two sky layers; the day layer fades in/out around sunrise and sunset. */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.sky-night {
  background-color: #0a101d;
  background-image:
    radial-gradient(60vmax 45vmax at 85% 0%, rgba(120, 140, 255, 0.22), transparent 70%),
    radial-gradient(55vmax 55vmax at 0% 100%, rgba(80, 200, 170, 0.12), transparent 70%);
}
.sky-day {
  opacity: var(--day);
  transition: opacity 3s ease;
  background-color: #e9eff7;
  background-image:
    radial-gradient(60vmax 45vmax at 85% 0%, rgba(255, 200, 130, 0.45), transparent 70%),
    radial-gradient(55vmax 55vmax at 0% 100%, rgba(130, 200, 230, 0.35), transparent 70%);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 0.2rem solid var(--money); outline-offset: 0.2rem; }

#app { transition: filter 2s ease, transform 2s ease; }
body.dim #app { filter: brightness(0.45); }

.screen[hidden] { display: none !important; }

/* ---------- Home ---------- */
#home {
  min-height: 100vh;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; }
.clock { display: flex; align-items: baseline; gap: 1rem; }
#clock-time { font-size: 15rem; font-weight: 200; line-height: 0.9; letter-spacing: -0.5rem; font-variant-numeric: tabular-nums; }
#clock-ampm { font-size: 3rem; font-weight: 300; color: var(--muted); }
.when { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; padding-bottom: 0.75rem; text-align: right; }
.when-day { font-size: 3.25rem; font-weight: 500; }
.when-date { font-size: 2.25rem; font-weight: 300; color: var(--muted); }
.weather { display: flex; align-items: baseline; gap: 0.75rem; margin-top: 0.75rem; }
.weather-temp { font-size: 2.5rem; }
.weather-desc { font-size: 1.75rem; color: var(--muted); }

.tile {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: left;
  padding: 2.25rem 2.5rem;
  border-radius: var(--radius);
  background: var(--tile);
  border: 1px solid var(--tile-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(1.5rem);
  -webkit-backdrop-filter: blur(1.5rem);
  transition: background 0.15s ease, transform 0.15s ease, border-color var(--ease);
  min-width: 0;
  overflow: hidden;
}
.tile:active { background: var(--tile-press); transform: scale(0.985); }

.tile-dinner { flex-direction: row; justify-content: space-between; align-items: center; gap: 2rem; padding: 2.5rem 2.75rem; }
.dinner-text { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.dinner-title { font-size: 4.5rem; line-height: 1.05; }
.dinner-meta { font-size: 1.9rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); flex: 1; }
.grid .tile { min-height: 26rem; }

.label { font-size: 1.5rem; letter-spacing: 0.2rem; text-transform: uppercase; font-weight: 500; }
.label-meals { color: var(--meals); }
.label-garden { color: var(--garden); }
.label-money { color: var(--money); }
.label-cal { color: var(--cal); }

.tile-body { display: flex; flex-direction: column; gap: 1.2rem; font-size: 2.1rem; min-width: 0; }
.row { display: flex; gap: 1.4rem; align-items: baseline; min-width: 0; }
.row .time { font-family: var(--mono); font-size: 1.75rem; color: var(--muted); width: 6.5rem; flex-shrink: 0; }
.row .time.now { color: var(--cal); }
.row.past, .row.past .time { color: var(--faint); text-decoration: line-through; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 1.65rem; color: var(--muted); }
.sub.alert { color: var(--alert); }
.empty { font-size: 1.9rem; color: var(--muted); }
.error { font-size: 1.7rem; color: var(--alert); }

.pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.9rem;
  min-height: 7.5rem; padding: 0 2.75rem; border-radius: 4rem; border: 0;
  font-size: 2.1rem; font-weight: 600;
}
.pill-meals { background: var(--meals-fill); color: var(--meals-on); }
.pill-garden { background: var(--garden-fill); color: var(--garden-on); }
.pill-money { background: var(--money-fill); color: var(--money-on); }
.pill-ghost { background: transparent; border: 1px solid var(--tile-border); color: var(--text); background: var(--chip); }
.pill-sm { min-height: 4.5rem; padding: 0 1.9rem; font-size: 1.65rem; }

.bar { height: 0.9rem; border-radius: 0.45rem; background: var(--track); overflow: hidden; }
.bar > div { height: 100%; border-radius: 0.45rem; background: var(--money-fill); transition: width 1s ease; }
.goal { display: flex; flex-direction: column; gap: 0.6rem; }
.goal-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.9rem; }
.goal-head > :last-child { white-space: nowrap; flex-shrink: 0; }
.state-good { color: var(--good); }
.state-bad { color: var(--alert); }
.state-muted { color: var(--muted); }

.bots { display: flex; gap: 1.25rem; }
.bot {
  flex: 1; min-height: 6.5rem; border-radius: 3.25rem; font-size: 1.9rem; font-weight: 500;
  border: 1px solid; backdrop-filter: blur(1rem); -webkit-backdrop-filter: blur(1rem);
}
.bot:active { transform: scale(0.98); }
.bot-meals { color: var(--meals); border-color: color-mix(in srgb, var(--meals) 40%, transparent); background: color-mix(in srgb, var(--meals-fill) 12%, transparent); }
.bot-garden { color: var(--garden); border-color: color-mix(in srgb, var(--garden) 40%, transparent); background: color-mix(in srgb, var(--garden-fill) 12%, transparent); }
.bot-money { color: var(--money); border-color: color-mix(in srgb, var(--money) 40%, transparent); background: color-mix(in srgb, var(--money-fill) 12%, transparent); }

/* ---------- Detail ---------- */
#detail { min-height: 100vh; padding: var(--pad); display: flex; flex-direction: column; gap: 2.5rem; }
.detail-head { display: flex; align-items: center; gap: 2rem; }
.home-btn {
  display: inline-flex; align-items: center; gap: 0.75rem;
  min-height: 6rem; padding: 0 2.25rem 0 1.5rem; border-radius: 3rem;
  background: var(--tile); border: 1px solid var(--tile-border); font-size: 2rem;
}
.home-btn svg { width: 2.4rem; height: 2.4rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.detail-title { margin: 0; font-size: 3.5rem; font-weight: 400; }
.detail-body { display: flex; flex-direction: column; gap: var(--gap); flex: 1; min-height: 0; }

.panel {
  padding: 2.25rem 2.5rem; border-radius: var(--radius);
  background: var(--tile); border: 1px solid var(--tile-border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1.4rem;
}
.panel h3 { margin: 0; }
.list { display: flex; flex-direction: column; gap: 0.25rem; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  padding: 1.25rem 0; border-bottom: 1px solid var(--track); font-size: 2.1rem;
}
.item:last-child { border-bottom: 0; }
.item-main { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.actions { display: flex; gap: 0.9rem; flex-wrap: wrap; justify-content: flex-end; }

.check {
  display: flex; align-items: center; gap: 1.5rem; width: 100%; text-align: left;
  padding: 1.4rem 0; border: 0; border-bottom: 1px solid var(--track); background: none; font-size: 2.3rem;
}
.check .box { width: 3.2rem; height: 3.2rem; border-radius: 1rem; border: 2px solid var(--muted); flex-shrink: 0; display: grid; place-items: center; }
.check.done { color: var(--faint); text-decoration: line-through; }
.check.done .box { background: var(--garden-fill); border-color: var(--garden-fill); }
.check.done .box::after { content: ""; width: 1.4rem; height: 0.7rem; border: solid var(--garden-on); border-width: 0 0 0.3rem 0.3rem; transform: translateY(-0.15rem) rotate(-45deg); }

.add-row { display: flex; gap: 1rem; }
.field {
  flex: 1; min-width: 0; min-height: 6rem; padding: 0 1.75rem; border-radius: 3rem;
  border: 1px solid var(--tile-border); background: var(--chip); color: var(--text);
  font: inherit; font-size: 2rem;
}
.field::placeholder { color: var(--faint); }

.day-head { font-size: 1.6rem; letter-spacing: 0.2rem; text-transform: uppercase; color: var(--cal); margin-top: 1rem; }

/* Cook mode */
.cook { flex: 1; display: flex; flex-direction: column; gap: var(--gap); }
.cook-step { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2rem; padding: 3rem; }
.cook-count { font-size: 1.8rem; letter-spacing: 0.2rem; text-transform: uppercase; color: var(--meals); }
.cook-text { font-size: 4rem; line-height: 1.25; }
.cook-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.cook-nav .pill { min-height: 10rem; font-size: 2.6rem; }
.timer { font-family: var(--mono); font-size: 5rem; }
.ingredients { columns: 2; column-gap: 3rem; font-size: 2rem; margin: 0; padding-left: 2.5rem; }
.ingredients li { margin-bottom: 0.8rem; break-inside: avoid; }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; gap: 1.5rem; min-height: 0; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 1.2rem; overflow-y: auto; }
.msg { max-width: 80%; padding: 1.4rem 1.9rem; border-radius: 2rem; font-size: 2rem; line-height: 1.35; }
.msg.me { align-self: flex-end; background: var(--money-fill); color: var(--money-on); border-bottom-right-radius: 0.5rem; }
.msg.bot { align-self: flex-start; background: var(--tile); border: 1px solid var(--tile-border); border-bottom-left-radius: 0.5rem; }
.msg .who { display: block; font-size: 1.4rem; letter-spacing: 0.15rem; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.chips { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.chip { min-height: 4.5rem; padding: 0 1.75rem; border-radius: 2.25rem; border: 1px solid var(--tile-border); background: var(--chip); font-size: 1.7rem; }

/* ---------- Sign-in ---------- */
#pin { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.pin-box { display: flex; flex-direction: column; align-items: center; gap: 2.5rem; }
.pin-title { margin: 0; font-size: 5rem; font-weight: 200; letter-spacing: -0.1rem; }
.pin-hint { margin: 0; font-size: 2.2rem; color: var(--muted); min-height: 3rem; }
.pin-hint.alert { color: var(--alert); }
.pin-dots { display: flex; gap: 2rem; }
.pin-dots span { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 2px solid var(--muted); transition: background 0.1s; }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pin-dots.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-1.5rem); } 75% { transform: translateX(1.5rem); } }
.keypad { display: grid; grid-template-columns: repeat(3, 9rem); gap: 1.75rem; }
.key {
  width: 9rem; height: 9rem; border-radius: 50%; font-size: 3.5rem; font-weight: 300;
  background: var(--tile); border: 1px solid var(--tile-border); backdrop-filter: blur(1rem);
}
.key:active { background: var(--tile-press); }
.key-text { font-size: 1.8rem; }
.key[disabled] { opacity: 0.4; }

/* ---------- Phones & small screens ---------- */
@media (max-width: 760px) {
  html { font-size: 16px; }
  :root { --pad: 1.25rem; --gap: 1rem; --radius: 1.25rem; }
  #clock-time { font-size: 4.5rem; letter-spacing: -0.15rem; }
  #clock-ampm { font-size: 1.25rem; }
  .when-day { font-size: 1.4rem; }
  .when-date { font-size: 1rem; }
  .weather { margin-top: 0.25rem; }
  .weather-temp { font-size: 1.2rem; }
  .weather-desc { font-size: 0.9rem; }
  .tile { padding: 1.25rem 1.4rem; gap: 0.9rem; }
  .tile-dinner { flex-direction: column; align-items: stretch; padding: 1.4rem; }
  .dinner-title { font-size: 2rem; }
  .dinner-meta { font-size: 1rem; }
  .grid { grid-template-columns: 1fr; }
  .grid .tile { min-height: 0; }
  .label { font-size: 0.8rem; letter-spacing: 0.12rem; }
  .tile-body { font-size: 1.15rem; gap: 0.6rem; }
  .row .time { font-size: 0.95rem; width: 3.5rem; }
  .sub, .empty, .error { font-size: 0.95rem; }
  .pill { min-height: 3.25rem; font-size: 1.1rem; padding: 0 1.4rem; }
  .pill-sm { min-height: 2.75rem; font-size: 0.95rem; padding: 0 1rem; }
  .goal-head { font-size: 1.05rem; }
  .bar { height: 0.55rem; }
  .bots { gap: 0.5rem; }
  .bot { min-height: 3.25rem; font-size: 0.95rem; }
  .home-btn { min-height: 3rem; font-size: 1rem; padding: 0 1.1rem 0 0.75rem; }
  .home-btn svg { width: 1.3rem; height: 1.3rem; }
  .detail-title { font-size: 1.6rem; }
  .panel { padding: 1.25rem; gap: 0.8rem; }
  .item, .check { font-size: 1.15rem; padding: 0.9rem 0; gap: 0.9rem; }
  .check .box { width: 1.75rem; height: 1.75rem; border-radius: 0.5rem; }
  .check.done .box::after { width: 0.8rem; height: 0.4rem; border-width: 0 0 0.18rem 0.18rem; }
  .field { min-height: 3rem; font-size: 1rem; }
  .day-head { font-size: 0.85rem; }
  .cook-step { padding: 1.25rem; gap: 1rem; }
  .cook-text { font-size: 1.6rem; }
  .cook-count { font-size: 0.9rem; }
  .cook-nav .pill { min-height: 4rem; font-size: 1.2rem; }
  .timer { font-size: 2.5rem; }
  .ingredients { columns: 1; font-size: 1.05rem; }
  .msg { font-size: 1.05rem; padding: 0.8rem 1.1rem; }
  .msg .who { font-size: 0.75rem; }
  .chip { min-height: 2.75rem; font-size: 0.95rem; padding: 0 1rem; }
  .pin-title { font-size: 2.5rem; }
  .pin-hint { font-size: 1.1rem; }
  .pin-dots span { width: 1.1rem; height: 1.1rem; }
  .keypad { grid-template-columns: repeat(3, 4.75rem); gap: 1rem; }
  .key { width: 4.75rem; height: 4.75rem; font-size: 1.9rem; }
  .key-text { font-size: 1rem; }
}

/* Kiosk niceties */
body.kiosk { user-select: none; -webkit-user-select: none; cursor: none; }
body.kiosk input { user-select: text; -webkit-user-select: text; }
body.kiosk #home { height: 100vh; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, .sky-day { transition: none !important; animation: none !important; }
}
