/* Sunday — a calm, minimal meal-plan UI.
   Design language: SF system type, generous whitespace, hairline dividers, soft cards,
   one fresh-green accent, full light/dark support. Built mobile-first. */

:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --hairline: rgba(0, 0, 0, 0.08);
  --hairline-strong: rgba(0, 0, 0, 0.14);
  --accent: #1f9d55;
  --accent-soft: #e7f6ee;
  --accent-text: #157a41;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --radius: 20px;
  --radius-sm: 12px;
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --hairline: rgba(255, 255, 255, 0.1);
    --hairline-strong: rgba(255, 255, 255, 0.16);
    --accent: #30d158;
    --accent-soft: rgba(48, 209, 88, 0.14);
    --accent-text: #4ee07a;
    --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 8px 30px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* The [hidden] attribute must always win over author display rules below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 20px;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---- Layout ---- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---- Hero ---- */
.hero { margin: 12px 0 28px; }
.hero .eyebrow {
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 4px;
}
.hero h1 {
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin: 0 0 16px;
}
.hero .dates { color: var(--accent-text); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.badge::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}

/* ---- Sections ---- */
.section { margin: 34px 0 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 14px;
}
.section-head h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0;
}
.section-head .meta { color: var(--text-3); font-size: 14px; font-weight: 500; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---- Meals grid ---- */
.meals { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .meals { grid-template-columns: 1fr 1fr; } }
.meal-card { padding: 18px 18px 20px; }
.meal-card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 600;
}
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

/* ---- Grocery list ---- */
.grocery-progress {
  display: flex; align-items: center; gap: 12px;
  margin: 0 4px 14px;
}
.progress-track {
  flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; background: var(--accent);
  border-radius: 3px; transition: width .35s cubic-bezier(.4,0,.2,1);
}
.progress-label { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.cat-head {
  padding: 16px 18px 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 600;
}
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cat-head + .item { border-top: none; }
.check {
  flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.check svg { width: 14px; height: 14px; opacity: 0; transform: scale(.5); transition: opacity .15s, transform .15s; }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item.done .check svg { opacity: 1; transform: scale(1); }
.item:active .check { transform: scale(.9); }
.item-body { flex: 1; min-width: 0; }
.item-name { font-size: 16px; letter-spacing: -0.01em; transition: color .15s; }
.item-qty { font-size: 13px; color: var(--text-3); }
.item.done .item-name { color: var(--text-3); text-decoration: line-through; }
.item-price { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.grocery-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}
.grocery-foot .total-label { font-size: 15px; color: var(--text-2); }
.grocery-foot .total-value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.budget-note {
  margin: 12px 4px 0; font-size: 13px; color: var(--text-3); line-height: 1.45;
}

/* ---- Recipes ---- */
.recipe { border-top: 1px solid var(--hairline); }
.recipe:first-child { border-top: none; }
.recipe summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
}
.recipe summary::-webkit-details-marker { display: none; }
.recipe .chev {
  flex: none; color: var(--text-3);
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.recipe[open] .chev { transform: rotate(90deg); }
.recipe-body { padding: 0 18px 18px; }
.recipe-body h4 {
  margin: 6px 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3); font-weight: 600;
}
.recipe-body ul { margin: 0 0 14px; padding-left: 18px; }
.recipe-body li { margin: 3px 0; color: var(--text-2); font-size: 15px; }
.recipe-body p { margin: 0; color: var(--text); font-size: 15px; line-height: 1.55; }

/* ---- Buttons ---- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  padding: 14px 22px; border-radius: 14px;
  transition: transform .08s ease, opacity .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .92; }
.btn-secondary {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--hairline);
}
.actions { margin: 40px 0 0; text-align: center; }
.actions .hint { margin: 12px 0 0; font-size: 13px; color: var(--text-3); }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 48px 20px; }
.empty-emoji { font-size: 56px; margin-bottom: 12px; }
.empty-title { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 8px; }
.empty-sub { color: var(--text-2); max-width: 420px; margin: 0 auto 24px; font-size: 16px; }

/* ---- Skeleton (initial load) ---- */
.skeleton { border-radius: var(--radius); background: var(--surface-2); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
.sk-hero { height: 120px; margin-bottom: 28px; }
.sk-block { height: 180px; margin-bottom: 16px; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---- Overlay ---- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 24px;
}
.overlay-card {
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: 36px 28px; text-align: center; max-width: 360px; width: 100%;
}
.overlay-msg { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 20px 0 6px; }
.overlay-sub { font-size: 14px; color: var(--text-2); margin: 0; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--surface-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.error-banner {
  background: color-mix(in srgb, #ff3b30 12%, var(--surface));
  border: 1px solid color-mix(in srgb, #ff3b30 30%, transparent);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0 0 20px; font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
