/* Source Sans 3 and Source Serif 4, Adobe, SIL OFL 1.1. See fonts/OFL.txt.
   ponytail: latin subset omits ⅓ ⅔ ⅛; those glyphs fall through to the next face.
   Upgrade path is a number-forms subset if scaled amounts start looking mixed. */
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("./fonts/source-sans-3-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/source-serif-4-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-2: #e7dfd2;
  --paper: #fffaf3;
  --ink: #1e1914;
  --muted: #5e564e;
  --faint: #675e54;
  --line: #e3d8cb;
  --line-strong: #cfc1b0;
  --accent: #b8431f;
  --accent-hover: #9a3819;
  --accent-ink: #fff8f4;
  --accent-text: #8f3418;
  --accent-soft: #f8e6dc;
  --good: #1f6b3e;
  --good-ink: #f4fff7;
  --focus: #8f3418;
  --shadow: 0 12px 28px rgb(0 0 0 / 10%);
  --header: rgb(244 239 230 / 88%);
  --serif: "Source Serif 4", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Source Sans 3", "Avenir Next", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141210;
  --bg-2: #2a241e;
  --paper: #1e1a17;
  --ink: #f6f0e8;
  --muted: #c4b8ac;
  --faint: #b3a496;
  --line: #3a322b;
  --line-strong: #5a4d43;
  --accent: #e8884e;
  --accent-hover: #f0a06a;
  --accent-ink: #1a100c;
  --accent-text: #f0a06a;
  --accent-soft: #3a241c;
  --good: #3d9a62;
  --good-ink: #04140c;
  --focus: #f0a06a;
  --shadow: 0 16px 40px rgb(0 0 0 / 35%);
  --header: rgb(20 18 16 / 90%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141210;
    --bg-2: #2a241e;
    --paper: #1e1a17;
    --ink: #f6f0e8;
    --muted: #c4b8ac;
    --faint: #b3a496;
    --line: #3a322b;
    --line-strong: #5a4d43;
    --accent: #e8884e;
    --accent-hover: #f0a06a;
    --accent-ink: #1a100c;
    --accent-text: #f0a06a;
    --accent-soft: #3a241c;
    --good: #3d9a62;
    --good-ink: #04140c;
    --focus: #f0a06a;
    --shadow: 0 16px 40px rgb(0 0 0 / 35%);
    --header: rgb(20 18 16 / 90%);
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  font-synthesis: none;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: clip;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

input { caret-color: var(--accent); }

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

[hidden] { display: none !important; }

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

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 5;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  border-radius: 8px;
}
.skip:focus { top: 12px; }

.bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 20px;
  background: var(--header);
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  min-height: 44px;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 999px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.nav a:hover { color: var(--ink); }

.nav a[aria-current="page"] {
  color: var(--accent-text);
  background: var(--paper);
  box-shadow: 0 1px 2px rgb(30 25 20 / 8%);
}

.badge {
  font-size: 0.75rem;
  min-width: 1.4em;
  text-align: center;
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 1px 6px;
}

button, .btn, .file-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  min-height: 44px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.ghost, .file-btn, #theme {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

.search button[type="submit"],
#r-save,
.empty .btn,
#clear {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  border-color: transparent;
}

.search button[type="submit"]:hover,
#r-save:hover,
.empty .btn:hover,
#clear:hover { background: var(--accent-hover); }

button.ghost:hover,
.file-btn:hover,
#theme:hover,
.chips button:hover { background: var(--bg-2); }

button:not(:disabled):active { transform: translateY(1px); }

.theme-dark { display: none; }
:root[data-theme="dark"] .theme-light { display: none; }
:root[data-theme="dark"] .theme-dark { display: inline; }

.row:has(#import:focus-visible) .file-btn {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 8px;
}

.kicker {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--accent-text);
}

h1, h2, h3, .brand { font-weight: 600; }

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-wrap: balance;
}

.lede {
  max-width: 38rem;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  text-wrap: pretty;
}

.hero { margin-bottom: 20px; }

@media (min-width: 960px) {
  #discover {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    column-gap: 48px;
    align-items: center;
  }
  .hero { margin: 0; }
  .finder { display: flex; flex-direction: column; gap: 14px; }
  #missing, #grid, #empty { grid-column: 1 / -1; }
}
.hero.is-compact { margin-bottom: 14px; }
.hero.is-compact .lede { display: none; }
.hero.is-compact h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}

.search:focus-within {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 10px 0;
  appearance: none;
}

.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
  width: 0;
  height: 0;
}

.search input:focus-visible { outline: none; }
.search input::placeholder { color: var(--faint); }

.search button[type="submit"] { border: 0; }

.kbd {
  flex: none;
  min-width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.search input:not(:placeholder-shown) ~ .kbd,
.search:focus-within .kbd { display: none; }

.browse {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  min-height: 44px;
}

.chips button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.chips button[aria-pressed="true"]:hover { background: var(--accent-hover); }

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.alert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--paper);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgb(30 25 20 / 4%);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), border-color 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.band {
  position: relative;
  height: 96px;
  color: white;
  background:
    linear-gradient(180deg, rgb(0 0 0 / 10%), rgb(0 0 0 / 52%)),
    linear-gradient(145deg, var(--c1), var(--c2));
}

.band-cuisine {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.band-cuisine { z-index: 1; }

.band-letter {
  position: absolute;
  right: 4px;
  top: -20px;
  font-family: var(--serif);
  font-size: 96px;
  line-height: 1;
  opacity: 0.28;
  pointer-events: none;
}

.body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  padding: 16px 16px 18px;
}

.card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

.card p { margin: 0; color: var(--muted); }

.card .body > p:nth-child(2) {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-meta .time {
  color: var(--accent-text);
  font-weight: 700;
}

.card.feature .time {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
}

.saved-pill {
  color: var(--good);
  font-weight: 700;
}

#q-clear {
  background: transparent;
  color: var(--muted);
  border: 0;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

@media (min-width: 960px) {
  .card.feature {
    grid-column: span 2;
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    min-height: 230px;
  }
  .card.feature .band { height: auto; min-height: 100%; }
  .card.feature h2 { font-size: 1.8rem; }
  .card.feature .body > p:nth-child(2) { -webkit-line-clamp: 3; }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 36rem;
  margin-top: 18px;
  padding: 28px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.empty h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.8rem;
}

.empty p { margin: 0 0 8px; color: var(--muted); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 8px;
}

.section-head h1 { font-size: clamp(2rem, 4vw, 3rem); }

.row { display: flex; flex-wrap: wrap; gap: 8px; }

footer {
  width: min(1120px, calc(100% - 32px));
  margin: 8px auto 0;
  padding: 28px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

footer p { margin: 0; max-width: 42rem; }

dialog {
  width: min(880px, calc(100% - 2rem));
  max-width: min(880px, calc(100vw - 2rem));
  max-height: min(92vh, 920px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 48px rgb(0 0 0 / 28%);
  overflow: hidden;
}

dialog[open] {
  animation: sheet-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

dialog[open]::backdrop {
  animation: dim-in 200ms ease-out;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(12px); }
}

@keyframes dim-in {
  from { opacity: 0; }
}

dialog::backdrop {
  background: rgb(20 14 10 / 55%);
}

.sheet {
  max-height: min(92vh, 920px);
  overflow: auto;
  scroll-padding-bottom: 5rem;
}

.sheet-band {
  position: relative;
  min-height: 180px;
  padding: 22px 22px 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: white;
  background:
    linear-gradient(160deg, rgb(0 0 0 / 12%), rgb(0 0 0 / 42%)),
    linear-gradient(145deg, var(--c1, #b8431f), var(--c2, #e07a3d));
}

.sheet-band .kicker { color: rgb(255 255 255 / 82%); }

.sheet-band h2 {
  margin: 0;
  max-width: 16ch;
  padding-right: 88px;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: white;
}

#r-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgb(0 0 0 / 35%);
  color: white;
  border: 0;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 22px 36px;
}

#r-desc { margin: 0; font-size: 1.05rem; }

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pills li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.servings {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.servings p {
  margin: 0;
  min-width: 12rem;
  text-align: center;
  font-size: 0.95rem;
}

.servings button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  border: 0;
  font-size: 1.2rem;
}

.cols {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 32px;
}

h3 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.35rem;
}

.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 22px calc(16px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.sheet-foot .status { min-height: 0; }

.ings {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ings label {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  margin: 0 -8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.ings label:hover { background: var(--bg); }

.ings input { width: 18px; height: 18px; accent-color: var(--accent); }

.amt {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.ings .is-done .item {
  color: var(--faint);
  text-decoration: line-through;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}

.steps p { margin: 4px 0 0; }

.steps .n {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.85rem;
}

.note {
  margin: 18px 0 0;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: 14px;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

#r-save[aria-pressed="true"],
#r-save[aria-pressed="true"]:hover { background: var(--good); color: var(--good-ink); }

.skel {
  height: 228px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) 0 0 / 100% 96px no-repeat,
    linear-gradient(var(--line), var(--line)) 16px 116px / 70% 14px no-repeat,
    linear-gradient(var(--line), var(--line)) 16px 140px / 92% 10px no-repeat,
    linear-gradient(var(--line), var(--line)) 16px 158px / 40% 10px no-repeat,
    var(--paper);
}

@media (max-width: 720px) {
  .bar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { font-size: 1.25rem; }
  .nav { order: 3; width: 100%; margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  #theme { margin-left: auto; }
  .nav a { justify-content: center; padding: 8px 10px; }
  main, footer { width: min(1120px, calc(100% - 24px)); }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    width: 100%;
    padding-bottom: 4px;
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: none; }
  .status { width: 100%; }
  .kbd { display: none; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .cols { grid-template-columns: 1fr; gap: 8px; }
  .servings { width: 100%; }
  .servings p { flex: 1; min-width: 0; }
  .actions button, .actions .ghost { flex: 1 1 30%; }
  dialog {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
  .sheet { max-height: 100dvh; }
  .sheet-band h2 { padding-right: 0; max-width: 20ch; }
  #r-close { position: static; align-self: flex-end; margin-bottom: 12px; }
  .sheet-band { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, dialog[open], dialog[open]::backdrop { animation: none; transition: none; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-light { display: none; }
  :root:not([data-theme="light"]) .theme-dark { display: inline; }
}

@media print {
  .bar, footer, .search, .chips, .status, .actions, .sheet-foot, #theme, .nav { display: none !important; }
  dialog, .sheet { position: static; max-height: none; width: 100%; overflow: visible; box-shadow: none; }
  .sheet-band, .sheet-band h2, .sheet-band .kicker { color: black; background: none; }
  body { background: white; color: black; }
}
