/* What to Cook. Enamelware palette: white with a blue rim, basil and a
   yolk accent on a cool tile background. Mobile first. */

/* Fonts are preloaded in index.html and cached by the service worker.
   font-display: optional means text never re-renders in a second font
   (no flicker on refresh): if a font isn't ready within ~100ms on a first
   visit, that page view keeps the system font. */

@font-face {
  font-family: 'Young Serif';
  src: url('/fonts/young-serif-400.woff2') format('woff2');
  font-weight: 400;
  font-display: optional;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-400.woff2') format('woff2');
  font-weight: 400;
  font-display: optional;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-700.woff2') format('woff2');
  font-weight: 700;
  font-display: optional;
}

:root {
  --enamel: #2c5f8a;
  --enamel-strong: #214a6d;
  --ink: #1d2b36;
  --basil: #3f7d4e;
  --yolk: #f2b632;
  --tile: #eef2f1;
  --card: #ffffff;
  --line: #d3dcda;
  --muted: #56666f;
  --danger: #a33a2c;
  --focus: #1d2b36;
  --toast-action: var(--yolk);
  --sheet-fill: #e6ecea;
  --serif: 'Young Serif', Georgia, serif;
  --sans: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabs-h: 4.25rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --enamel: #86b6dd;
    --enamel-strong: #a9cbe8;
    --ink: #e6edef;
    --basil: #85c595;
    --yolk: #f2b632;
    --tile: #13202a;
    --card: #1b2a36;
    --line: #2d3f4c;
    --muted: #9eafb9;
    --danger: #f08a7a;
    --focus: #f2b632;
    --toast-action: #214a6d;
    --sheet-fill: #2a3b48;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--tile);
  color: var(--ink);
  font: 1.0625rem/1.5 var(--sans);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 1rem);
}

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; }
p { margin: 0; }
a { color: var(--enamel); }
small { font-size: 0.85rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }

.skip-link { position: absolute; left: -999px; top: 0.5rem; background: var(--card); padding: 0.5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0.5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.pad { padding: 1rem; }

/* ---- Frame ---- */

.top {
  max-width: 36rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1.25rem 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
}

main { max-width: 36rem; margin: 0 auto; padding: 0 1.25rem; }

.page { padding-top: 1.25rem; }
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.75rem; }
.caption { color: var(--muted); margin-top: 0.25rem; }

.block { margin-top: 1.75rem; }
.block > * + * { margin-top: 0.75rem; }
.section-title { font-size: 1.05rem; }
.help { color: var(--muted); font-size: 0.95rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }

.tabs {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabs[hidden] { display: none; }
.tabs a {
  flex: 1;
  max-width: 9rem;
  height: var(--tabs-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
}
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current='page'] { color: var(--enamel); font-weight: 700; }
.tabs a[aria-current='page'] svg { stroke-width: 2.4; }

/* ---- Controls ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--enamel); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }
.btn.primary { background: var(--enamel); border-color: var(--enamel); color: #fff; }
.btn.primary:hover { background: var(--enamel-strong); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 2.75rem; padding: 0.35rem 0.9rem; font-size: 0.95rem; }
.btn.wide { width: 100%; margin: 2rem 0 1rem; }
@media (prefers-color-scheme: dark) {
  .btn.primary { color: #10202c; }
}

.link { background: none; border: 0; padding: 0; color: var(--enamel); font: inherit; text-decoration: underline; cursor: pointer; min-height: 2.75rem; }

.icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1.3rem;
  border-radius: 50%;
  cursor: pointer;
}
.icon-btn:hover { background: var(--tile); }
.icon-btn[disabled] { opacity: 0.3; cursor: default; }

.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.stack > .btn { width: 100%; }

label { display: block; font-weight: 700; font-size: 0.95rem; }
.input {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.input:focus { border-color: var(--enamel); }
textarea.input { resize: vertical; }

.segmented { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.segmented button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  justify-content: center;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.segmented button[aria-pressed='true'] { border-color: var(--enamel); background: var(--enamel); color: #fff; font-weight: 700; }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed='true'] { color: #10202c; } }
.segmented small { font-weight: 400; opacity: 0.85; }

.choices { display: flex; flex-direction: column; gap: 0.5rem; }
.choice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-weight: 400;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--enamel); box-shadow: inset 0 0 0 1px var(--enamel); }
.choice input { margin: 0.3rem 0 0; accent-color: var(--enamel); width: 1.1rem; height: 1.1rem; flex: none; }
.choice b { display: block; }
.choice small { color: var(--muted); font-size: 0.92rem; }

/* ---- Today ---- */

.today-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.today-head h1 { font-size: 1.35rem; }

.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { display: block; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 6; }
.ring-fill { fill: none; stroke: var(--basil); stroke-width: 6; stroke-linecap: round; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring-text b { font-size: 1.15rem; }
.ring-text small { font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }

.meals { display: flex; flex-direction: column; gap: 1rem; }

/* The enamel plate: white with a blue rim. The one bold element. */
.meal {
  background: var(--card);
  border: 3px solid var(--enamel);
  border-radius: 24px;
  padding: 1.4rem 1.4rem 1.3rem;
  box-shadow: inset 0 0 0 6px var(--card), inset 0 0 0 7px var(--line);
}
.meal-slot { color: var(--enamel); font-weight: 700; margin-bottom: 0.35rem; }
.meal-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 10vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.meal-name.is-empty { color: var(--muted); font-size: 1.6rem; }
.meal-note { color: var(--muted); margin-top: 0.6rem; max-width: 60ch; }
.meal .row { margin-top: 1.1rem; }
.meal.is-cooked { border-color: var(--basil); }
.meal.is-cooked .meal-name { color: var(--muted); }
.meal-done { color: var(--basil); font-weight: 700; margin-top: 0.4rem; }
.meal-done::before { content: '\2713\00a0'; }

.actions { margin-top: 1rem; }
.note-line { margin-top: 0.75rem; color: var(--muted); }

.empty {
  background: var(--card);
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  padding: 1.5rem;
}
.empty h2 { font-family: var(--serif); font-weight: 400; font-size: 1.7rem; }
.empty p { color: var(--muted); margin: 0.5rem 0 1rem; }

/* ---- Lists ---- */

.days, .pick-list, .dish-list, .pool, .order, .cycle, .weekdays, .plans {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.days > li + li, .pick-list > li + li, .dish-list > li + li, .pool > li + li,
.order > li + li, .cycle > li + li, .weekdays > li + li { border-top: 1px solid var(--line); }

.day, .pick, .dish-row {
  width: 100%;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  min-height: 3.25rem;
  padding: 0.7rem 1rem;
  background: none;
  border: 0;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.day:hover, .pick:hover, .dish-row:hover { background: var(--tile); }
.day-when { flex: 0 0 6.5rem; color: var(--muted); font-size: 0.95rem; }
.day.is-today .day-when { color: var(--enamel); font-weight: 700; }
.day-what { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.day-dish small { color: var(--muted); margin-right: 0.4rem; }
.tag { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--tile); color: var(--muted); align-self: center; }

.pick, .dish-row { flex-direction: column; gap: 0.1rem; align-items: flex-start; justify-content: center; }
.pick small, .dish-row small { color: var(--muted); }
.pick[aria-current='true'] { box-shadow: inset 4px 0 0 var(--enamel); }
.pick[aria-current='true'] > span { font-weight: 700; }

.cycle > li, .weekdays > li { display: flex; gap: 0.75rem; padding: 0.5rem 0.75rem 0.5rem 1rem; align-items: flex-start; }
.cycle > li.is-today { box-shadow: inset 4px 0 0 var(--basil); }
.cycle-day, .wd-name { flex: 0 0 5.75rem; padding-top: 0.65rem; font-weight: 700; font-size: 0.95rem; }
.cycle-day small { display: block; color: var(--basil); font-weight: 700; }
.cycle-cells { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; min-height: 2.75rem; }
.cell {
  min-height: 2.75rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cell small { display: block; color: var(--muted); font-size: 0.78rem; }
.cell.is-empty { color: var(--muted); border-style: dashed; }
.cell:hover { border-color: var(--enamel); }

.cell.add { border-style: dashed; color: var(--enamel); font-weight: 700; background: none; }
.empty-day { padding: 0.65rem 0 0; font-size: 0.95rem; }

.order > li { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.25rem 0.25rem 1rem; }
.order > li.is-today { box-shadow: inset 4px 0 0 var(--basil); }
.order-n { flex: 0 0 1.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.order-name { flex: 1; }
.order-name small { margin-left: 0.5rem; color: var(--basil); font-weight: 700; }
.order-tools { display: flex; }

.pool > li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.4rem 0.5rem 0.4rem 1rem; }
.pool small { display: block; color: var(--muted); }
.pool.done > li > span { color: var(--muted); }

.plans { background: none; border: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.plan-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.plan-card h3 { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; }
.plan-card p { color: var(--muted); margin: 0.25rem 0 0.5rem; }
.plan-card details { margin-bottom: 0.75rem; }
.plan-card summary { cursor: pointer; color: var(--enamel); min-height: 2.75rem; display: flex; align-items: center; }
.plan-dishes { columns: 2 12rem; margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.95rem; }

.add-form > label { margin-top: 0.9rem; }
.add-form > label + .input { margin-top: 0.35rem; }
.add-form .btn { margin-top: 1rem; }
.slot-names { display: grid; gap: 0.75rem; }
.slot-names label { margin-bottom: 0.35rem; }
#start-date { max-width: 14rem; }
.about p + p { margin-top: 0.5rem; }

/* ---- Sheet ---- */

.sheet {
  width: 100%;
  max-width: 36rem;
  max-height: 85dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--card);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgb(10 20 28 / 0.5); }
@media (min-width: 40rem) { .sheet { margin: auto; border-radius: 20px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0.5rem 0.25rem 1.25rem; }
.sheet-head h2 { font-size: 1.2rem; }
/* Round filled close button, like driver-education's SheetHeader:
   a 36px disc with a 20px Material close icon, inside a 44px tap area. */
.sheet-close {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.sheet-close-disc {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sheet-fill);
}
.sheet-close svg { fill: currentColor; }
.sheet-close:hover .sheet-close-disc { filter: brightness(0.95); }
@media (prefers-color-scheme: dark) { .sheet-close:hover .sheet-close-disc { filter: brightness(1.15); } }
.sheet-body { padding: 0.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet-body > * + * { margin-top: 0.75rem; }
.sheet-body .pick-list { border-radius: 10px; }
.sheet-lead { font-family: var(--serif); font-size: 1.3rem; }
.sheet-body label + .input { margin-top: 0.35rem; }
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: rise 0.18s ease-out; }
  @keyframes rise { from { transform: translateY(1.5rem); opacity: 0.6; } }
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 0.75rem);
  transform: translateX(-50%);
  width: min(34rem, calc(100% - 2rem));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.65rem 0.65rem 1rem;
  background: var(--ink);
  color: var(--card);
  border-radius: 12px;
  z-index: 20;
}
.toast[hidden] { display: none; }
.toast-btn { background: none; border: 0; color: var(--toast-action); font: inherit; font-weight: 700; min-height: 2.75rem; padding: 0 0.75rem; cursor: pointer; }

/* ---- 404 ---- */

.not-found { max-width: 30rem; margin: 0 auto; padding: 4rem 1.5rem; }
.not-found h1 { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; margin: 1rem 0 0.5rem; }
.not-found p + p { margin-top: 1.5rem; }
