/*
 * Aftertaste
 * Copyright (c) 2026 Robert ten Hoor. All rights reserved.
 * This software is proprietary. Without the prior written permission of Robert ten Hoor you may not copy, reproduce,
 * distribute, use any part of, modify, or create derivative works from this code or its data files, and you may not
 * decompile, disassemble or otherwise reverse engineer it.
 */
:root {
  --base: #eef2ec;
  --surface: #ffffff;
  --ink: #12211b;
  --muted: #5f6f66;
  --line: #d3dcd5;
  --accent: #1f6f4a;
  --accent-ink: #ffffff;
  --accent-soft: #d9ebe0;
  --amber: #c98a1e;
  --amber-soft: #f6e9cf;
  --warn: #b4452e;
  --safe: #13a34a;   /* bright green: foods on the safe list */
  --radius: 12px;
  --nav-h: 62px;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--base);
}
@media (prefers-color-scheme: dark) {
  :root {
    --base: #141a17;
    --surface: #1f2723;
    --ink: #e9efeb;
    --muted: #97a59d;
    --line: #313c36;
    --accent: #6fbf93;
    --accent-ink: #0f2419;
    --accent-soft: #1f3529;
    --amber: #e0a93d;
    --amber-soft: #3a2f16;
    --warn: #e07a63;
    --safe: #4ade80;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--base); color: var(--ink); }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

/* ---------- splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; background: var(--accent); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 32px; transition: opacity .35s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash .mark { width: 88px; height: 88px; margin-bottom: 18px; }
.splash .wordmark { font-family: var(--serif); font-size: 40px; letter-spacing: -.5px; }
.splash .tagline { font-size: 17px; opacity: .85; margin-top: 8px; max-width: 26ch; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--base);
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--accent); font-family: var(--serif); font-size: 20px; }
.brand svg { width: 24px; height: 24px; }
.help {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--accent); border: 1.5px solid var(--accent); font-weight: 700;
}
.help.active { background: var(--accent); color: var(--accent-ink); }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }

h1 { font-family: var(--serif); font-size: 26px; font-weight: 500; margin: 6px 0 4px; letter-spacing: -.3px; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 24px 0 8px; }
.hint { font-size: 14px; color: var(--muted); margin: 4px 0 12px; max-width: 60ch; }
.empty { color: var(--muted); padding: 28px 12px; text-align: center; }
.prose p { margin: 0 0 12px; max-width: 62ch; }
.prose h2 { margin-top: 26px; font-size: 15px; color: var(--ink); }
.prose ul { padding-left: 20px; margin: 0 0 12px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.prose a.btn { color: var(--accent-ink); text-decoration: none; }

input[type=text], input[type=number], input[type=time], input[type=datetime-local] {
  width: 100%; font: inherit; color: inherit; -webkit-appearance: none;
  padding: 13px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
input[type=text]:focus { border-color: var(--accent); outline: none; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 600; min-height: 46px;
}
.btn.big { width: 100%; font-size: 17px; min-height: 54px; }
.btn.quiet { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); font-weight: 500; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.danger { background: none; color: var(--warn); }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- chip wall (the heart of the app) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.chip {
  padding: 12px 15px; min-height: 46px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line);
  font-size: 16px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s, background .12s;
}
.chip:active { transform: scale(.95); }
.chip.recent { border-color: var(--accent); }
.chip.new { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- lists ---------- */
.list { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-top: 1px solid var(--line); width: 100%; text-align: left; min-height: 48px;
}
.item:first-child { border-top: 0; }
.item .t { color: var(--muted); min-width: 48px; font-variant-numeric: tabular-nums; }
.item .grow { flex: 1; }
.item .meta { color: var(--muted); font-size: 14px; }

/* ---------- check-in ---------- */
label.hint input { margin-top: 4px; }
.sym { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line); }
.sym:first-child { border-top: 0; }
.sym .name { flex: 1; }
.sym.on { background: var(--amber-soft); }
.sev { display: flex; gap: 4px; }
.sev button {
  min-width: 44px; height: 38px; padding: 0 8px; border-radius: 8px; font-size: 13px;
  background: var(--base); border: 1.5px solid var(--line); color: var(--muted);
}
.sev button.on { background: var(--amber); border-color: var(--amber); color: #fff; font-weight: 600; }
.submit { position: sticky; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); margin-top: 14px; }

/* ---------- findings ---------- */
.chart { width: 100%; height: auto; display: block; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 6px 4px 2px; }
.progress { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 5px; transition: width .3s; }

.stats { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.finding { display: flex; gap: 12px; align-items: baseline; padding: 11px 14px; border-top: 1px solid var(--line); }
.finding:first-child { border-top: 0; }
.finding .delta { min-width: 58px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.finding .delta.up { color: var(--warn); }
.finding .delta.down { color: var(--accent); }
.finding .meta { font-size: 13px; color: var(--muted); }

/* ---------- welcome ---------- */
.welcome { padding-top: 12px; }
.welcome h1 { font-size: 32px; margin-bottom: 8px; }
.welcome .lead { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: 30ch; }
.steps { margin: 0 0 24px; padding: 0; list-style: none; }
.steps li { display: flex; gap: 14px; margin-bottom: 16px; }
.steps .n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: var(--serif);
}
.steps b { display: block; margin-bottom: 2px; }
.steps span { color: var(--muted); font-size: 15px; }

/* ---------- component picker ---------- */
.compgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 50vh; overflow: auto; }
.compopt { display: block; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--base); font-size: 13px; line-height: 1.3; }
.compopt.on { border-color: var(--accent); background: var(--accent-soft); }
.compopt input { display: none; }
.compopt b { display: block; }
.compopt span { color: var(--muted); font-size: 12px; }
.hint.warn { border-left: 3px solid var(--amber); padding-left: 10px; color: var(--ink); }

/* ---------- experiments ---------- */
.plan-day { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.plan-day:first-child { border-top: 0; }
.plan-day .d { min-width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-day.today { background: var(--accent-soft); }
.plan-day.break { background: var(--amber-soft); }
.plan-day .k { font-size: 12px; color: var(--muted); }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card h3 { margin: 0 0 4px; font-family: var(--serif); font-weight: 500; font-size: 19px; }
.card .why { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.today-box { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 16px; margin: 8px 0 14px; }
.today-box .k { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.today-box .t { font-size: 18px; font-family: var(--serif); margin-top: 4px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal { background: var(--surface); width: 100%; max-width: 560px; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0;
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal h3 { margin: 0 0 12px; font-size: 18px; font-family: var(--serif); font-weight: 500; }
.modal label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.modal .row.end { margin-top: 18px; }

/* ---------- nav ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1.5px solid var(--line); z-index: 10;
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 0 2px;
}
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--accent); font-weight: 700; }
.tabs a.active svg { stroke-width: 2.2; }
.tabs .dot { position: absolute; top: 8px; right: 22%; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); border: 2px solid var(--surface); }

.toast {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%); background: var(--ink); color: var(--base);
  padding: 11px 16px; border-radius: 999px; display: flex; gap: 16px; align-items: center; z-index: 30;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.25); cursor: pointer;
}
.toast[hidden] { display: none; }
.toast button { color: #a9dcc0; font-weight: 700; }

.toggle { display: flex; align-items: center; justify-content: space-between; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; }
.switch.on { background: var(--accent); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .12s; }
.switch.on::after { left: 21px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

a.btn { text-decoration: none; }

/* ---------- expandable component rows in Findings ---------- */
.cmp + .cmp { border-top: 1px solid var(--line); }
.cmp .finding { border-top: 0; }
.cmpbtn { width: 100%; text-align: left; align-items: flex-start; }
.cmpbtn .chev { color: var(--muted); font-size: 14px; margin-left: auto; padding-left: 8px; }
.pill { margin-left: auto; align-self: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1.5px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.cmpdetail { padding: 0 14px 12px; }
.cmpfood { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); }
.cmpfood:first-of-type { border-top: 0; }
.cmpfood .meta { font-size: 13px; color: var(--muted); text-align: right; }


/* ---------- PRO / visual polish ---------- */
.pro-nav { font-size: 8px; line-height: 1; padding: 2px 5px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-weight: 800; letter-spacing: .04em; }
.pro-hero { position: relative; overflow: hidden; background: linear-gradient(145deg, var(--accent-soft), var(--surface)); border: 1.5px solid var(--line); border-radius: 20px; padding: 24px 20px 20px; margin: 8px 0 16px; box-shadow: 0 8px 24px rgba(18,33,27,.07); }
.pro-hero::after { content: ''; position: absolute; width: 150px; height: 150px; border-radius: 50%; right: -48px; top: -52px; border: 22px solid rgba(31,111,74,.10); }
.pro-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.pro-hero h1 { font-size: 28px; max-width: 14ch; margin-top: 12px; position: relative; z-index: 1; }
.pro-hero .lead { font-size: 16px; color: var(--muted); max-width: 42ch; }
.pro-price { display: flex; align-items: baseline; gap: 8px; }
.pro-price span { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.pro-price small { color: var(--muted); font-size: 13px; }
.pro-cta { margin-top: 4px; position: relative; z-index: 1; }
.pro-features { display: grid; gap: 8px; }
.pro-features > div { display: grid; grid-template-columns: minmax(130px, .7fr) 1fr; gap: 10px; padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; }
.pro-features b { font-size: 14px; }
.pro-features span { color: var(--muted); font-size: 14px; }
@media (max-width: 420px) { .pro-features > div { grid-template-columns: 1fr; gap: 3px; } }
.list { box-shadow: 0 2px 10px rgba(18,33,27,.035); }
.btn { box-shadow: 0 2px 7px rgba(18,33,27,.08); }
.finding, .item { transition: background .12s; }
.finding:active, .item:active { background: var(--accent-soft); }
.tabs { box-shadow: 0 -4px 18px rgba(18,33,27,.06); }

/* ---------- translations: longer labels ---------- */
.tabs a { min-width: 0; }
.tabs a > span:not(.dot):not(.pro-nav) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
select { width: 100%; padding: 12px; margin-top: 4px; font: inherit; color: var(--text, inherit); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; }
select:focus { border-color: var(--accent); outline: none; }
.chip[disabled] { opacity: .6; }

/* chips logged since the Log screen was opened */
.chip.picked { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }   /* colour only: no change in text width, so chips never reflow */

/* ---------- food-target experiments ---------- */
/* banner above every page while an experiment runs */
.xp-banner { max-width: 560px; margin: 0 auto; padding: 0 16px 4px; }
.xp-banner a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); background: var(--accent-soft);
  border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 8px 12px; font-size: 14px; line-height: 1.3; }
.xp-banner b { display: block; color: var(--accent); }
.xp-banner span span { display: block; color: var(--muted); font-size: 13px; }
.xp-banner .grow { flex: 1; }
.xp-banner .chev { color: var(--accent); font-size: 18px; }
.xp-run { border-color: var(--accent); }
.xp-k { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; margin-bottom: 2px; }
.xp-state { margin-left: 0; display: inline-block; }
.xp-running, .xp-active { color: var(--accent); border-color: var(--accent); }
.xp-finished, .xp-done { color: var(--ink); }
.xp-v { text-align: right; max-width: 62%; }
.today-box .s { font-size: 14px; opacity: .85; margin-top: 4px; }
.chip.static { min-height: 0; padding: 6px 11px; font-size: 14px; cursor: default; }
.chip.static:active { transform: none; }
.cmpfood .xp-mini { min-height: 30px; padding: 3px 9px; font-size: 12px; box-shadow: none; flex: none; align-self: center; }
.plan-day .d { white-space: nowrap; }
a.item { color: inherit; text-decoration: none; }
a.item .chev { color: var(--muted); }
.prose ol.help-steps { padding-left: 22px; margin: 0 0 12px; }
.prose ol.help-steps li { margin-bottom: 6px; }

/* ---------- safe list on the Log screen ---------- */
/* foods on the safe list: slightly smaller, faintly green text. Nothing else is marked. */
.item.safe .grow, .chip.safe { color: var(--safe); font-weight: 600; }
.chip.safe.picked { color: var(--safe); }
/* the remark at the top after logging a food that is on the safe list */
.lognote { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; padding: 6px 2px; color: var(--accent); text-decoration: none; font-size: 14px; }
.lognote .grow { flex: 1; }

/* ---------- food page ---------- */
a.foodrow { color: inherit; text-decoration: none; }
a.foodlink { color: var(--accent); text-decoration: none; }
.linkbtn { color: var(--accent); font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.foodstatus { border-radius: var(--radius); padding: 12px 14px; margin: 10px 0 4px; font-size: 15px; border: 1.5px solid var(--line); background: var(--surface); }
.foodstatus.ok { background: var(--accent-soft); border-color: var(--accent); }
.foodstatus.bad { background: var(--amber-soft); border-color: var(--amber); }
.foodstatus.part { border-color: var(--accent); }
h3.sub { font-size: 15px; font-weight: 600; margin: 18px 0 6px; }
.modal h3.sub { font-family: var(--sans); }
h2.pro-h { display: flex; align-items: center; gap: 8px; }
h2.pro-h .pill { margin-left: 0; }
.pro-lock .why { margin-bottom: 12px; }
main .hint a:not(.btn) { color: var(--accent); }
.finding.period .delta { min-width: 46px; }
details.fold summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary h3::before { content: '▸ '; color: var(--muted); }
details.fold[open] summary h3::before { content: '▾ '; }
details.fold summary .meta { font-size: 13px; color: var(--muted); }

/* ---------- PRO: share summary, teasers ---------- */
.share-row { margin: 10px 0 0; }
.btn.locked { opacity: .55; }
.btn.locked .pill { margin-left: 8px; }
.share-actions { margin: 4px 0 8px; }
.teaser { margin: 0 0 8px; font-weight: 600; }
.pro-lead { border-color: var(--accent); }
.pro-lead p { margin: 4px 0 0; }
@media print {
  .top, .tabs, .toast, .xp-banner, .noprint, .splash { display: none !important; }
  html, body { padding: 0; background: #fff !important; color: #000; }
  main { max-width: none; padding: 0; }
  .list { box-shadow: none; border-color: #bbb; break-inside: auto; }
  .item { min-height: 0; padding: 5px 10px; break-inside: avoid; }
  h2 { color: #000; break-after: avoid; }
}
.finding .delta .warn-ic { display: block; }

/* free-trial start screen: a timeline (today, reminder, end) */
.trial-h { margin: 6px 0 20px; font-family: var(--serif); font-weight: 500; font-size: 27px; line-height: 1.2; color: var(--ink); }
.pro-hero #tryPro { width: 100%; }
.trial-tl { list-style: none; margin: 0 0 20px; padding: 0; }
.trial-tl li { position: relative; padding: 0 0 18px 30px; }
.trial-tl li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.trial-tl li::after { content: ""; position: absolute; left: 9px; top: 22px; bottom: 0; width: 3px; border-radius: 2px; background: var(--accent); }
.trial-tl li.last::after { background: var(--line); background: color-mix(in srgb, var(--muted) 45%, transparent); bottom: 10px; }
/* arrowhead at the end of the grey line, as in the timeline it was modelled on */
.trial-tl li.last { padding-bottom: 34px; }
.trial-tl li.last > b::before { content: none; }
.trial-tl::after { content: ""; display: block; width: 13px; height: 13px; margin: -30px 0 20px 4px;
  border-right: 3px solid var(--line); border-bottom: 3px solid var(--line); border-radius: 0 0 2px 0; transform: rotate(45deg);
  border-color: color-mix(in srgb, var(--muted) 45%, transparent); }
/* the timeline sheet: a soft wash of the accent colour from the left */
.modal:has(.trial-tl) { background: linear-gradient(100deg, var(--accent-soft) 0%, var(--surface) 62%);
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 20%, var(--surface)) 0%, var(--surface) 68%); }
.trial-tl b { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.trial-tl span { color: var(--muted); }
.trial-cta { width: 100%; }
.trial-note { text-align: center; margin: 10px 0 0; }
