/* Eetlog: calm, mobile-first. Light and dark follow the system. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e6e5e0;
  --accent: #2f6b4f;
  --accent-text: #ffffff;
  --accent-soft: #e6efe9;
  --warn: #b0432f;
  --warn-soft: #f7e7e3;
  --radius: 14px;
  --gap: 16px;
  --tap: 44px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1b1b1e;
    --surface-2: #242428;
    --text: #f2f2f3;
    --muted: #9a9aa1;
    --line: #2c2c31;
    --accent: #7cc29c;
    --accent-text: #0f1a14;
    --accent-soft: #1d2b23;
    --warn: #ff8f78;
    --warn-soft: #3a211c;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

a { color: var(--accent); text-decoration: none; }

.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Layout ----------------------------------------------------------------- */

.page {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--gap) calc(var(--gap) + env(safe-area-inset-right)) 32px calc(var(--gap) + env(safe-area-inset-left));
  display: grid;
  gap: 28px;
}

.block { display: grid; gap: 12px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 8px) calc(var(--gap) + env(safe-area-inset-right)) 10px calc(var(--gap) + env(safe-area-inset-left));
}

.daynav { max-width: 600px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daytitle { text-align: center; display: grid; line-height: 1.25; }
.daytitle h1 { font-size: 1.15rem; font-weight: 650; }
.daytitle .muted, .today-link { font-size: 0.85rem; }

.icon-btn {
  width: var(--tap); height: var(--tap);
  display: inline-grid; place-items: center;
  border-radius: 50%;
  color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.placeholder { visibility: hidden; }

.kop-totaal {
  max-width: 600px; margin: 4px auto 0;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.kop-totaal strong { color: var(--text); font-weight: 600; }
.kop-totaal .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }

.footer {
  max-width: 600px; margin: 0 auto;
  padding: 8px var(--gap) calc(env(safe-area-inset-bottom) + 32px);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.9rem;
}
.footer a, .footer .link { color: var(--muted); }

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

input, select, button { font: inherit; color: inherit; }

input, select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 17px; /* 16px+ prevents iOS zoom on focus */
}
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

button { cursor: pointer; border: 0; background: none; }
button.primary, button.quiet, button.danger {
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
}
button.primary { background: var(--accent); color: var(--accent-text); }
button.quiet { background: var(--surface-2); color: var(--text); font-weight: 500; }
button.danger { background: transparent; color: var(--warn); font-weight: 500; margin-left: auto; }
button.link { padding: 0; color: var(--accent); }
button:active { opacity: 0.75; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.button-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }

label { font-size: 0.8rem; color: var(--muted); }

/* --- Favorites ---------------------------------------------------------------- */

.factor { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.factor { position: relative; }
.factor input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; opacity: 0; pointer-events: none; }
.factor label {
  min-width: 46px; padding: 5px 10px;
  text-align: center; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500; color: var(--muted);
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.factor input:checked + label { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.factor input:focus-visible + label { outline: 2px solid var(--accent); }

.fav-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fav {
  min-height: 84px;
  padding: 14px;
  display: grid; align-content: space-between; gap: 6px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 80ms ease, background 120ms ease;
}
.fav:active { transform: scale(0.98); background: var(--accent-soft); opacity: 1; }
.fav-naam { font-weight: 600; line-height: 1.25; }
.fav-kcal { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.fav.htmx-request { background: var(--accent-soft); }

/* --- Quick entry ----------------------------------------------------------------- */

.quick { display: grid; gap: 10px; }
.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; }
.field-wide { grid-column: 1 / -1; }

/* --- Day overview ---------------------------------------------------------------- */

.notice-error {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.95rem;
}

.notice-open {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.95rem;
}
.tag-open { margin-left: 0; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent); }

/* Confirmation floats above the content, so nothing shifts under your finger. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  z-index: 20;
  width: max-content;
  max-width: min(calc(100vw - 32px), 520px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.95rem;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
  pointer-events: none;
  transform: translateX(-50%);
  animation: toast 3.2s ease forwards;
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  8%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) { .toast { animation-duration: 0.01s; animation-delay: 3s; } }
#dag { display: grid; gap: 28px; }

.summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  gap: 10px;
}
.summary-main { display: flex; justify-content: space-between; align-items: flex-end; }
.summary-side { text-align: right; }
.big { font-size: 2.6rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.medium { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .muted { font-size: 0.9rem; }
.summary-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding-top: 12px; margin-top: 2px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.summary-row strong { font-weight: 600; white-space: nowrap; }
.summary-row.over strong, .summary-row.over .label { color: var(--warn); }
.hint { font-size: 0.85rem; color: var(--muted); }

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.72rem; font-weight: 500;
  color: var(--muted);
  vertical-align: 2px;
}

.moment .block-head .muted { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.entries {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.entries > li + li { border-top: 1px solid var(--line); }
.entry {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 12px;
  text-align: left;
}
.entry:active { background: var(--surface-2); opacity: 1; }
.entry-time { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-what { line-height: 1.3; }
.entry-kcal { font-variant-numeric: tabular-nums; font-weight: 500; }
.entry-edit { padding: 14px; background: var(--surface); }
.entry-edit .quick-row { grid-template-columns: 1fr 1fr 1fr; }
.entry-edit .field-wide { grid-column: 1 / -1; }

.empty { text-align: center; padding: 24px 0; }

/* --- Login ---------------------------------------------------------------------- */

.login-panel {
  max-width: 360px;
  margin: 18vh auto 0;
  display: grid; gap: 20px;
}
.brand-title { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
.error { color: var(--warn); font-size: 0.95rem; }

/* --- Larger screens ---------------------------------------------------------------- */

@media (min-width: 720px) {
  .page { padding-top: 28px; }
  .fav-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-row { grid-template-columns: 1fr 1fr 1.4fr; }
  .quick-row .field-wide { grid-column: auto; }
  .entry:hover { background: var(--surface-2); }
  .fav:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
}

/* --- Statistics ------------------------------------------------------------------------ */
/* Chart colors: the dataviz reference palette, validated against these surfaces
   (light #ffffff, dark #1b1b1e) with validate_palette.js. Moments use slots 1-5 in order;
   certainty uses an ordinal blue ramp. Text never wears these colors. */

:root {
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #eda100; --viz-5: #e87ba4;
  --viz-muted: #c9c8c1;
  --viz-grid: #ebeae5;
  --viz-ink: #52514e;
  --viz-hoog: #104281; --viz-midden: #2a78d6; --viz-laag: #86b6ef;
}
@media (prefers-color-scheme: dark) {
  :root {
    --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500; --viz-5: #d55181;
    --viz-muted: #4b4b48;
    --viz-grid: #2c2c31;
    --viz-ink: #c3c2b7;
    --viz-hoog: #86b6ef; --viz-midden: #3987e5; --viz-laag: #184f95;
  }
}

.periodes {
  max-width: 600px; margin: 8px auto 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 3px; border-radius: 999px; background: var(--surface-2);
}
.periodes a {
  padding: 6px 0; border-radius: 999px; text-align: center;
  font-size: 0.85rem; font-weight: 500; color: var(--muted);
}
.periodes a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

.hero { display: grid; gap: 2px; }
.hero-value { font-size: 3.2rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; }
.hero-label { color: var(--muted); }
.hero .hint { margin-top: 6px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  padding: 14px; display: grid; gap: 4px; align-content: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile-label { font-size: 0.8rem; color: var(--muted); }
.tile-value { font-size: 1.45rem; font-weight: 600; line-height: 1.15; }
.tile-unit { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.tile-sub { font-size: 0.8rem; color: var(--muted); line-height: 1.3; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 0.95rem; }
.list li + li { border-top: 1px solid var(--line); }
.list .muted { text-align: right; font-size: 0.85rem; }

.chart-card { margin: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chart-box { position: relative; height: 260px; }
.chart-box-small { height: 200px; }
.table-view summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.table-view table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 4px 6px 4px 0; text-align: right; border-top: 1px solid var(--line); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { font-weight: 500; color: var(--muted); }
.table-view details[open] table, .table-view { overflow-x: auto; }

.shares { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.9rem; }
.shares li { display: flex; align-items: center; gap: 8px; }
.shares strong { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.key { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.key-1 { background: var(--viz-1); } .key-2 { background: var(--viz-2); } .key-3 { background: var(--viz-3); }
.key-4 { background: var(--viz-4); } .key-5 { background: var(--viz-5); }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.bar-head strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { margin-top: 4px; height: 8px; border-radius: 4px; background: var(--surface-2); }
.bar-fill { height: 100%; border-radius: 4px; background: var(--viz-1); }

.compare { display: grid; gap: 10px; }
.compare-row { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 8px; }
.compare-name { font-size: 0.8rem; color: var(--muted); }
.compare-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare-pair > div { display: grid; }
.compare-value { font-size: 1.3rem; font-weight: 600; }
.compare-pair .muted { font-size: 0.8rem; line-height: 1.3; }

.stack-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.stack-bar .seg { height: 100%; }
.seg-hoog { background: var(--viz-hoog); } .seg-midden { background: var(--viz-midden); } .seg-laag { background: var(--viz-laag); }

.inline-form { margin-top: 4px; }
.footer { gap: 16px; }
.footer > :last-child { margin-left: auto; }

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-box { height: 300px; }
}

/* --- Guide ------------------------------------------------------------------------------ */

.guide { gap: 36px; }
.guide h3 { font-size: 1rem; font-weight: 600; margin: 0 0 6px; }
.guide p { margin: 0; }
.guide q { quotes: "\201C" "\201D"; font-style: italic; }
.lead { font-size: 1.1rem; line-height: 1.5; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.toc a { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; color: var(--text); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 56px 1fr; gap: 14px; }
.timeline .when { padding-top: 12px; text-align: right; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline li > div { position: relative; padding: 10px 0 10px 18px; border-left: 1px solid var(--line); line-height: 1.45; }
.timeline li > div::before {
  content: ""; position: absolute; left: -5px; top: 17px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--bg);
}

.cards { display: grid; gap: 10px; }
.card-item { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-item ul, .plain { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.plain li { line-height: 1.45; }

.faq { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.faq + .faq { margin-top: -18px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin-top: 8px; line-height: 1.45; }

@media (min-width: 720px) {
  .cards { grid-template-columns: 1fr 1fr; }
}
.guide section[id] { scroll-margin-top: 90px; }
