/* Saffas Thanksgiving — site styles. Warm autumn palette with South African flag accents. */

:root {
  --bg: #fff8ef;
  --bg-2: #fbeedd;
  --surface: #ffffff;
  --ink: #2b1a10;
  --muted: #6b5444;
  --line: #ead8c3;
  --brand: #b9461a;
  --brand-2: #8f3312;
  --brand-ink: #ffffff;
  --gold: #e8a317;
  --sa-green: #007749;
  --sa-gold: #ffb81c;
  --sa-red: #e03c31;
  --sa-blue: #001489;
  --ok: #17663a;
  --ok-bg: #e5f4ea;
  --warn: #8a5300;
  --warn-bg: #fff1d6;
  --err: #a32117;
  --err-bg: #fde8e6;
  --info-bg: #eef3ff;
  --focus: #1849d6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(43, 26, 16, .06), 0 6px 20px rgba(43, 26, 16, .07);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a120c;
    --bg-2: #24180f;
    --surface: #2a1d14;
    --ink: #f8ecdd;
    --muted: #c9b29b;
    --line: #47331f;
    --brand: #ee8a4f;
    --brand-2: #f6a370;
    --brand-ink: #24120a;
    --ok: #7fd6a0;
    --ok-bg: #173323;
    --warn: #f5c56b;
    --warn-bg: #3a2a0d;
    --err: #ff9b92;
    --err-bg: #3d1714;
    --info-bg: #1d2438;
    --focus: #8fb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-2); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
main { padding: 28px 0 64px; min-height: 60vh; }

/* ---------- header / footer ---------- */
.flag-bar { display: flex; height: 6px; }
.flag-bar span { flex: 1; }
.flag-bar span:nth-child(1) { background: var(--sa-red); }
.flag-bar span:nth-child(2) { background: var(--sa-green); }
.flag-bar span:nth-child(3) { background: var(--sa-gold); }
.flag-bar span:nth-child(4) { background: var(--sa-blue); }
.flag-bar span:nth-child(5) { background: var(--brand); }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.nav-toggle { display: inline-flex; align-items: center; gap: 6px; }
.site-nav { display: none; }
.site-nav.open { display: block; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.site-nav ul { list-style: none; margin: 0; padding: 8px 16px 16px; display: grid; gap: 2px; }
.site-nav a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--bg-2); color: var(--brand-2); }
@media (min-width: 900px) {
  .site-header .nav-toggle { display: none; }
  .site-nav, .site-nav.open { display: block; position: static; box-shadow: none; border: 0; background: none; }
  .site-nav ul { display: flex; padding: 0; gap: 4px; }
  .site-nav a { padding: 8px 12px; }
}

.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); padding: 28px 0 36px; color: var(--muted); font-size: .92rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.site-footer a { color: var(--muted); }

/* ---------- buttons & forms ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid transparent;
  font: 600 .98rem/1.2 var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--brand); color: var(--brand-ink);
}
.btn:hover { background: var(--brand-2); color: var(--brand-ink); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--brand); color: var(--brand-2); }
.btn.ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn.ghost:hover { background: var(--bg-2); color: var(--brand-2); }
.btn.danger { background: var(--surface); color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.field { display: grid; gap: 6px; margin-bottom: 16px; align-content: start; justify-items: stretch; }
.field > .btn { justify-self: start; }
.field label, .field .label { font-weight: 600; }
.field .hint { color: var(--muted); font-size: .88rem; }
.field .error { color: var(--err); font-size: .9rem; font-weight: 500; }
input[type="text"], input[type="email"], input[type="search"], input[type="password"], input[type="file"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid transparent; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
[aria-invalid="true"] { border-color: var(--err) !important; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px; }
@media (min-width: 720px) { .card.pad { padding: 26px; } }
.notice { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--info-bg); border: 1px solid var(--line); }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.notice.err { background: var(--err-bg); color: var(--err); border-color: transparent; }
.notice p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); font-size: .82rem; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.stack > * + * { margin-top: 16px; }
.section { margin-top: 44px; }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }

/* ---------- hero ---------- */
.hero { padding: 36px 0 12px; display: grid; gap: 28px; align-items: center; }
@media (min-width: 900px) { .hero { grid-template-columns: 1.1fr .9fr; padding-top: 48px; } }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 40ch; }
.hero-art { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.feature-links { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); margin-top: 36px; }
.feature-links a { display: block; padding: 20px; text-decoration: none; color: var(--ink); }
.feature-links a:hover { border-color: var(--brand); }
.feature-links .icon { font-size: 1.8rem; }

/* ---------- dish & recipe cards ---------- */
.dish { display: flex; flex-direction: column; overflow: hidden; }
.dish-photo { position: relative; aspect-ratio: 4 / 3; background: var(--bg-2); overflow: hidden; }
.dish-photo img { width: 100%; height: 100%; object-fit: cover; }
.dish-photo .placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; background: repeating-linear-gradient(45deg, var(--bg-2), var(--bg-2) 14px, var(--bg) 14px, var(--bg) 28px); }
.dish-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.dish-body h3 { margin: 0; font-size: 1.1rem; }
.dish-body p { margin: 0; color: var(--muted); font-size: .93rem; }
.dish-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dish-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; }
.credit { font-size: .72rem; color: var(--muted); line-height: 1.35; }
.credit a { color: var(--muted); }

/* ---------- builder ---------- */
.builder { display: grid; gap: 24px; }
@media (min-width: 1000px) { .builder { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; } .menu-panel { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs [role="tab"], .chip {
  min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 .9rem var(--sans); cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"], .chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.replace-banner { position: sticky; top: 72px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.menu-panel h2 { font-size: 1.4rem; }
.course { margin-top: 18px; }
.course h3 { font-size: 1rem; font-family: var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--brand-2); margin-bottom: 8px; }
.course ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.menu-item { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.menu-item .thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--bg-2); display: grid; place-items: center; }
.menu-item .name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.menu-item .desc { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.menu-item .controls { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.menu-item .controls .btn { min-height: 34px; padding: 4px 10px; font-size: .82rem; }
.menu-item .controls select { width: auto; min-height: 34px; padding: 4px 8px; font-size: .82rem; border-radius: 999px; }
.course-empty { color: var(--muted); font-size: .9rem; font-style: italic; }
.card-preview { margin-top: 18px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.card-preview svg { display: block; width: 100%; height: auto; }
.mobile-menu-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .08); }
@media (min-width: 1000px) { .mobile-menu-bar { display: none; } }
body.has-menu-bar main { padding-bottom: 96px; }
.share-box { display: grid; gap: 12px; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; min-width: 0; font-size: .9rem; }

/* ---------- menu view ---------- */
.menu-view-head { display: grid; gap: 20px; }
@media (min-width: 900px) { .menu-view-head { grid-template-columns: 1fr 1fr; align-items: center; } }
.menu-card-img { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); width: 100%; height: auto; aspect-ratio: 1200 / 630; background: var(--bg-2); }
.course-list { display: grid; gap: 12px; }
.course-list .row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; padding: 10px; }
.course-list .row img, .course-list .row .ph { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--bg-2); display: grid; place-items: center; font-size: 1.6rem; }

/* ---------- votes ---------- */
.vote { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vote-btn[aria-pressed="true"] { background: var(--sa-green); color: #fff; border-color: var(--sa-green); }
.vote-btn[aria-pressed="true"]:hover { background: #005c38; color: #fff; }
.vote-count { font-size: .88rem; color: var(--muted); }
.vote-count strong { color: var(--ink); }

/* ---------- recipe page ---------- */
.recipe-layout { display: grid; gap: 28px; }
@media (min-width: 900px) { .recipe-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }
.recipe-hero { border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 10; background: var(--bg-2); }
.recipe-hero img { width: 100%; height: 100%; object-fit: cover; }
.ingredients { padding-left: 1.2em; }
.ingredients li { margin-bottom: 6px; }
.method p { white-space: pre-line; }
blockquote.story { margin: 0; padding: 14px 18px; border-left: 4px solid var(--gold); background: var(--bg-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-style: italic; }

/* ---------- rankings ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank-list li { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 14px; }
.rank-num { font-family: var(--serif); font-weight: 700; font-size: 1.5rem; color: var(--brand); text-align: center; }
.rank-title { font-weight: 600; overflow-wrap: anywhere; }
.rank-stats { color: var(--muted); font-size: .88rem; }
.rank-grid { display: grid; gap: 24px; }
@media (min-width: 900px) { .rank-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- dialogs & toasts ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(20, 12, 6, .55); }
dialog .dialog-body { padding: 22px; }
.toast-region { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
body.has-menu-bar .toast-region { bottom: 92px; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-weight: 500; }
.toast.err { background: var(--err); color: #fff; }

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 20px; }
.admin-item { padding: 16px; display: grid; gap: 10px; }
.admin-item header { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.admin-item h3 { margin: 0; }
.admin-photo { max-width: 360px; border-radius: 10px; border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { padding: 14px; }
.stat .n { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; }
table.simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.simple th, table.simple td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll { overflow-x: auto; }
pre.details { white-space: pre-wrap; font-size: .8rem; background: var(--bg-2); padding: 8px; border-radius: 8px; margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .tabs [role="tab"] { transition: background-color .15s, border-color .15s, color .15s; }
}
