/* We Got Ham: a menu card, not a dashboard. Mobile first; light and dark. */

:root {
  color-scheme: light dark;

  --paper: #faf6ef;
  --ink: #2a2019;
  --muted: #76675a;
  --faint: #a4968a;
  --line: rgba(42, 32, 25, .10);
  --line-strong: rgba(42, 32, 25, .28);
  --fill: rgba(42, 32, 25, .055);
  --fill-strong: rgba(42, 32, 25, .09);
  --accent: #b4461d;            /* the one accent: a roasted rust */
  --on-accent: #fffaf4;
  --accent-soft: rgba(180, 70, 29, .12);
  --focus: #1d5fbf;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .4  0 0 0 0 .28  0 0 0 0 .15  0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --col: 600px;
  --gutter: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171210;
    --ink: #efe5d8;
    --muted: #a69686;
    --faint: #7c6e62;
    --line: rgba(239, 229, 216, .10);
    --line-strong: rgba(239, 229, 216, .30);
    --fill: rgba(239, 229, 216, .06);
    --fill-strong: rgba(239, 229, 216, .10);
    --accent: #ea8a52;
    --on-accent: #1a120d;
    --accent-soft: rgba(234, 138, 82, .16);
    --focus: #8db8ff;
    --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .9  0 0 0 0 .8  0 0 0 .035 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: var(--grain);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
svg { display: block; }
[hidden] { display: none !important; }

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

:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
[tabindex="-1"]:focus { outline: none; }

/* ---------- Shared bits ---------- */
.view, .state {
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.course-name {
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.text-btn {
  display: inline-flex; align-items: center;
  min-height: 44px;
  padding: 0 2px;
  border: 0; background: none;
  color: var(--accent);
  font-size: inherit; font-weight: 500;
  cursor: pointer;
}
.text-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.pill-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s var(--ease), filter .15s;
}
.pill-btn:hover { filter: brightness(1.06); }
.pill-btn:active { transform: scale(.96); }
.pill-small { min-height: 44px; padding: 0 18px; font-size: .95rem; }

/* ---------- Loading / error ---------- */
.state {
  min-height: 70vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center;
}
.state-title { font-family: var(--serif); font-weight: 500; font-size: 1.6rem; }
.state-text { color: var(--muted); }
.dots span { animation: blink 1.4s infinite both; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Screen 1: the spread ---------- */
#spread { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }

.masthead { padding: calc(44px + env(safe-area-inset-top)) 0 0; }
.brand {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.005em;
}
.occasion { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.masthead::after {
  content: "";
  display: block;
  width: 28px; height: 2px;
  margin: 22px 0 40px;
  background: var(--accent);
  border-radius: 2px;
}

.course + .course { margin-top: 40px; }
#spread .course-name { margin-bottom: 14px; }
.course-list { display: grid; gap: 18px; }

.dish-link { display: block; color: inherit; text-decoration: none; border-radius: 6px; }
.dish-link:hover .dish-name { color: var(--accent); }

.line { display: block; }
.dish-name {
  display: block;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -.01em;
  transition: color .15s;
}
.leader { display: none; }
.dish-who { display: block; margin-top: 3px; color: var(--muted); font-size: .92rem; }
.dish-note {
  margin-top: 2px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
}
.dish-note-who { font-style: normal; font-family: var(--sans); font-size: .85rem; }

/* Wide screens: set it like a menu card, name … who */
@media (min-width: 600px) {
  .line { display: flex; align-items: baseline; gap: 12px; }
  .dish-name { flex: 0 1 auto; font-size: 1.65rem; }
  .leader {
    display: block; flex: 1 1 24px; min-width: 24px;
    border-bottom: 2px dotted var(--line-strong);
    transform: translateY(-6px);
  }
  .dish-who { flex: 0 1 auto; max-width: 45%; margin: 0; text-align: right; }
}

/* Dishes settle in when you come back from adding them */
.dish.is-new { animation: settle .6s var(--ease) both; }
@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Empty state */
.empty { padding-top: 2vh; }
.empty-art {
  width: 104px; height: 104px; margin: 0 0 26px -8px;
  fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.empty-title {
  font-family: var(--serif); font-size: 2rem; font-weight: 500;
  line-height: 1.15; letter-spacing: -.015em;
}
.empty-text { color: var(--muted); max-width: 25em; margin-top: 10px; line-height: 1.6; }
.mini-plus {
  display: inline-block; vertical-align: -5px;
  width: 22px; height: 22px; margin: 0 2px;
  border-radius: 50%;
  background:
    linear-gradient(var(--on-accent), var(--on-accent)) center / 10px 2px no-repeat,
    linear-gradient(var(--on-accent), var(--on-accent)) center / 2px 10px no-repeat,
    var(--accent);
}

/* The one primary action */
.fab {
  position: fixed;
  z-index: 20;
  right: max(calc(20px + env(safe-area-inset-right)), calc(50vw - var(--col) / 2 - 92px));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 62px; height: 62px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 8px 22px -6px rgba(120, 45, 15, .55);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: scale(.9); box-shadow: 0 3px 10px -4px rgba(120, 45, 15, .6); transition-duration: .08s; }
.fab:focus-visible { outline-offset: 4px; border-radius: 50%; }
.fab-plus, .fab-plus::after {
  display: block;
  width: 24px; height: 2.5px;
  border-radius: 2px;
  background: var(--on-accent);
}
.fab-plus::after { content: ""; transform: rotate(90deg); }
.fab:active .fab-plus { transform: rotate(90deg); transition: transform .2s var(--ease); }

/* ---------- Screen 2: bring something ---------- */
#add-view { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

.bar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(52px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  margin: 0 calc(-1 * max(var(--gutter), env(safe-area-inset-left))) 0;
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
  background-color: var(--paper);
  background-image: var(--grain);
  box-shadow: 0 1px 0 transparent;
  transition: box-shadow .2s;
}
.bar.is-scrolled { box-shadow: 0 1px 0 var(--line); }
.back-btn {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; padding: 0 10px 0 4px;
  border: 0; background: none;
  color: var(--accent); font-weight: 600; font-size: 1.02rem;
  white-space: nowrap; flex-shrink: 0;
  cursor: pointer;
}
.back-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bar-title {
  font-family: var(--serif); font-weight: 600; font-size: 1.02rem;
  opacity: 0; transform: translateY(4px);
  transition: opacity .2s, transform .2s var(--ease);
  white-space: nowrap;
}
.bar.show-title .bar-title { opacity: 1; transform: none; }

.add-inner { padding-top: 12px; }
.add-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -.015em;
}
.lede { color: var(--muted); margin: 8px 0 22px; max-width: 30em; }

/* Who are you? */
.who-list li + li .who-row { box-shadow: inset 0 1px 0 var(--line); }
.who-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 66px;
  padding: 10px 2px;
  border: 0; background: none;
  text-align: left;
  cursor: pointer;
}
.who-name { font-family: var(--serif); font-size: 1.4rem; font-weight: 500; transition: color .15s; }
.who-row:hover .who-name { color: var(--accent); }
.chev { width: 20px; height: 20px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Bringing as … · change */
.as-line { color: var(--muted); font-size: .95rem; margin-top: 2px; }
.as-name { color: var(--ink); }

/* Search */
.search { position: relative; margin: 14px 0 6px; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 19px; height: 19px;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
.search-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px 12px 42px;
  font-size: 16px; /* no iOS zoom */
  border: 0; border-radius: 14px;
  background: var(--fill);
  outline-offset: 0;
  -webkit-appearance: none; appearance: none;
  transition: background-color .15s;
}
.search-input:focus { background: var(--fill-strong); }
.search-input:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 0; border-radius: 14px; }
.search-input::placeholder { color: var(--muted); }

/* The list */
#pick-list .course { margin-top: 30px; }
#pick-list .course + .course { margin-top: 30px; }
#pick-list .course-name { margin-bottom: 2px; }
.pick { position: relative; border-radius: 10px; }
.pick + .pick::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0;
  height: 1px; background: var(--line);
}
.pick-btn {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  min-height: 62px;
  padding: 10px 0;
  border: 0; background: none;
  text-align: left;
  cursor: pointer;
}
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-name { font-family: var(--serif); font-size: 1.28rem; font-weight: 500; line-height: 1.22; }
.pick-who { color: var(--muted); font-size: .88rem; margin-top: 1px; }
.pick-btn:hover .check:not(.is-on) { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* The check: a ring that fills, and a tick that draws itself */
.check {
  flex: none;
  position: relative;
  width: 30px; height: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition: background-color .2s, box-shadow .2s;
}
.check svg { width: 100%; height: 100%; }
.check path {
  fill: none; stroke: var(--on-accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 17; stroke-dashoffset: 17;
}
.check.is-on { background: var(--accent); box-shadow: none; }
.check.is-on path { stroke-dashoffset: 0; }
.check.is-drawing { animation: pop .42s var(--ease); }
.check.is-drawing path { animation: draw .34s .1s ease-out both; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes draw { from { stroke-dashoffset: 17; } to { stroke-dashoffset: 0; } }
.is-pending .check { opacity: .65; }

.check.is-plus { box-shadow: inset 0 0 0 1.5px var(--accent); transition: transform .25s var(--ease); }
[aria-expanded="true"] > .check.is-plus { transform: rotate(45deg); }
.check.is-plus::before, .check.is-plus::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 12px; height: 2px; margin: -1px 0 0 -6px;
  border-radius: 2px; background: var(--accent);
}
.check.is-plus::after { transform: rotate(90deg); }
.add-new { margin-top: 26px !important; }

/* Notes on your own dishes */
.note-btn {
  display: flex; align-items: center;
  min-height: 44px; margin-top: -10px;
  padding: 0 0 4px;
  border: 0; background: none;
  color: var(--muted); font-size: .9rem;
  text-align: left;
  cursor: pointer;
}
.note-btn:hover { color: var(--accent); }
.note-btn.has-note { color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 1rem; font-weight: 400; }
.note-btn.has-note:hover { color: var(--ink); }
.note-form { margin: -6px 0 12px; }
.note-input {
  width: 100%;
  min-height: 44px;
  padding: 8px 0;
  font-family: var(--serif); font-style: italic; font-size: 16px;
  border: 0; border-bottom: 1.5px solid var(--accent);
  border-radius: 0;
  background: transparent;
  outline: none;
}
.note-input::placeholder { color: var(--faint); }

/* "Bring one too?" — asked right on the row */
.confirm {
  margin: 0 0 14px;
  padding: 14px 16px 8px;
  border-radius: 14px;
  background: var(--fill);
  animation: unfold .25s var(--ease);
}
.confirm-text { font-size: .98rem; }
.confirm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 8px; }
.confirm-actions button { white-space: nowrap; }
.confirm-actions .text-btn { color: var(--muted); }
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* What kind of dish? */
.kinds { padding: 2px 0 12px; animation: unfold .25s var(--ease); }
.kinds-q { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.kind-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kind {
  min-height: 48px; padding: 6px 8px;
  border: 0; border-radius: 12px;
  background: var(--fill);
  font-family: var(--serif); font-size: 1.02rem;
  cursor: pointer;
  transition: background-color .15s, transform .12s var(--ease);
}
.kind:hover:not(:disabled) { background: var(--accent-soft); }
.kind:active:not(:disabled) { transform: scale(.96); }
.kind:disabled { opacity: .5; cursor: default; }
.kind-error { color: var(--accent); font-size: .92rem; font-weight: 500; margin-top: 10px; }

/* A row collapsing away, and the row you came to change */
.pick.is-leaving {
  overflow: hidden; opacity: 0;
  transition: height .3s var(--ease), opacity .2s;
}
.pick.is-highlight { animation: glow 1.8s ease-out; }
@keyframes glow {
  0%, 30% { background: var(--accent-soft); box-shadow: 0 0 0 10px var(--accent-soft); }
  100% { background: transparent; box-shadow: 0 0 0 10px transparent; }
}

/* ---------- Transitions between screens ---------- */
.enter-slide { animation: slide-in .32s var(--ease); }
.enter-fade { animation: fade-in .28s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Error message ---------- */
.toast {
  position: fixed; z-index: 30;
  left: 50%; top: calc(12px + env(safe-area-inset-top));
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink); color: var(--paper);
  font-size: .92rem;
  opacity: 0; transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Desktop ---------- */
@media (min-width: 720px) {
  .masthead { padding-top: 72px; }
  .masthead::after { margin-bottom: 52px; }
  .course + .course { margin-top: 48px; }
  .add-inner { padding-top: 28px; }
  .add-title { font-size: 2.4rem; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
