/* ==========================================================================
   Andaza Kitchen — a household archive of Pakistani cooking
   Design tokens, layout and components. One stylesheet, no framework.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */
:root {
  /* Warm archival palette. Terracotta + cream + coriander green. */
  --bg:            #FDFAF3;
  --bg-raised:     #FFFFFF;
  --bg-sunken:     #F6EFE3;
  --ink:           #1C1A17;
  --ink-soft:      #554D42;
  --ink-faint:     #857A6C;
  --primary:       #9A3412;   /* terracotta */
  --primary-deep:  #7C2D12;
  --accent:        #4D7C0F;   /* coriander */
  --border:        #E6DAC7;
  --border-strong: #D2C1A6;
  --warn-bg:       #FBF1E4;
  --warn-border:   #D9A05B;

  --font-display: "EB Garamond", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;          /* ~68 characters, the reading column */
  --measure-wide: 52rem;

  --s-1: .25rem; --s-2: .5rem;  --s-3: .75rem; --s-4: 1rem;
  --s-5: 1.5rem; --s-6: 2rem;   --s-7: 3rem;   --s-8: 4rem; --s-9: 6rem;

  --radius: 3px;
  --shadow: 0 1px 2px rgb(28 26 23 / .04), 0 8px 24px -12px rgb(28 26 23 / .10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #17140F;
    --bg-raised:     #201C16;
    --bg-sunken:     #12100C;
    --ink:           #F2EADC;
    --ink-soft:      #C3B7A4;
    --ink-faint:     #948877;
    --primary:       #E8845C;
    --primary-deep:  #F0A183;
    --accent:        #A3BE6A;
    --border:        #362F26;
    --border-strong: #4A4136;
    --warn-bg:       #241C12;
    --warn-border:   #8A6435;
  }
}
/* Explicit overrides win in both directions for a manual theme toggle. */
:root[data-theme="light"] {
  --bg:#FDFAF3; --bg-raised:#FFFFFF; --bg-sunken:#F6EFE3; --ink:#1C1A17;
  --ink-soft:#554D42; --ink-faint:#857A6C; --primary:#9A3412; --primary-deep:#7C2D12;
  --accent:#4D7C0F; --border:#E6DAC7; --border-strong:#D2C1A6;
  --warn-bg:#FBF1E4; --warn-border:#D9A05B;
}
:root[data-theme="dark"] {
  --bg:#17140F; --bg-raised:#201C16; --bg-sunken:#12100C; --ink:#F2EADC;
  --ink-soft:#C3B7A4; --ink-faint:#948877; --primary:#E8845C; --primary-deep:#F0A183;
  --accent:#A3BE6A; --border:#362F26; --border-strong:#4A4136;
  --warn-bg:#241C12; --warn-border:#8A6435;
}

/* --- Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 var(--s-4);
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 6vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.6vw, 2.1rem); margin-top: var(--s-8); }
h3 { font-size: 1.3rem; margin-top: var(--s-6); }
p  { margin: 0 0 var(--s-4); }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-deep); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 2px; }

img { max-width: 100%; height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-7) 0; }

/* --- Layout --------------------------------------------------------------- */
.wrap  { width: min(100% - 2.5rem, var(--measure-wide)); margin-inline: auto; }
.col   { width: min(100% - 2.5rem, var(--measure));      margin-inline: auto; }
.skip  {
  position: absolute; left: -9999px; top: 0; background: var(--primary);
  color: #fff; padding: var(--s-3) var(--s-4); z-index: 100;
}
.skip:focus { left: var(--s-4); top: var(--s-4); }

/* --- Small-caps label ----------------------------------------------------- */
.label {
  font-family: var(--font-body);
  font-size: .6875rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* --- Header --------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(140%) blur(8px);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); padding: var(--s-4) 0;
}
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1.05; }
.brand__name {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 600;
  color: var(--ink); letter-spacing: -0.015em;
}
.brand__sub { font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-top: 2px; }

.nav { display: flex; align-items: center; gap: var(--s-2); }
.nav a {
  color: var(--ink-soft); text-decoration: none; font-size: .9375rem;
  padding: var(--s-3); border-radius: var(--radius);
  min-height: 44px; display: inline-flex; align-items: center;
  transition: color .2s ease, background-color .2s ease;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--primary); background: var(--bg-sunken); }

.theme-toggle {
  min-width: 44px; min-height: 44px; display: inline-grid; place-items: center;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--ink-soft); cursor: pointer; transition: all .2s ease;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .icon-sun, .icon-moon { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: none; }
  :root:not([data-theme]) .icon-moon { display: block; }
}

/* --- Hero ----------------------------------------------------------------- */
.hero { padding: var(--s-9) 0 var(--s-8); text-align: center; }
.hero h1 { margin-bottom: var(--s-5); }
.hero__lede {
  font-family: var(--font-display); font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.5; color: var(--ink-soft); max-width: 32rem; margin: 0 auto var(--s-6);
}
.hero__rule { width: 3rem; height: 2px; background: var(--primary); margin: 0 auto var(--s-6); border: 0; }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: var(--s-3) var(--s-5);
  font-family: var(--font-body); font-size: .9375rem; font-weight: 500;
  border-radius: var(--radius); text-decoration: none; cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.btn--primary { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.btn--primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); color: #fff; }
.btn--ghost { background: none; color: var(--ink-soft); border: 1px solid var(--border-strong); }
.btn--ghost:hover { color: var(--primary); border-color: var(--primary); }

/* --- Status pill (the archive's signature element) ------------------------ */
.pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: .6875rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  padding: var(--s-1) var(--s-3); border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--ink-faint); background: var(--bg-raised);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--living { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill--fading { color: var(--warn-border); border-color: color-mix(in srgb, var(--warn-border) 45%, transparent); }
.pill--first  { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }

/* --- Recipe cards / index ------------------------------------------------- */
.grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }

.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-raised); padding: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-3);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card h3 { margin: 0; font-size: 1.25rem; }
.card h3 a { text-decoration: none; color: var(--ink); }
.card:hover h3 a { color: var(--primary); }
.card p { margin: 0; font-size: .9375rem; color: var(--ink-soft); }
.card__meta { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: auto; padding-top: var(--s-2); }

/* --- Recipe page ---------------------------------------------------------- */
.standfirst {
  font-family: var(--font-display); font-size: 1.3rem; line-height: 1.5;
  color: var(--ink-soft); margin-bottom: var(--s-6);
}
.byline { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; margin-bottom: var(--s-6); }

.glance {
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: var(--s-5) 0; margin: var(--s-6) 0;
  display: grid; gap: var(--s-4) var(--s-6);
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
}
.glance div { display: flex; flex-direction: column; gap: var(--s-1); }
.glance dd, .glance p { margin: 0; font-size: .9375rem; }

/* Ingredients — mono numerals so weights scan as data */
.ingredients { list-style: none; padding: 0; margin: 0 0 var(--s-5); }
.ingredients li {
  display: grid; grid-template-columns: 5.5rem 1fr; gap: var(--s-4);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
  font-size: .9375rem; align-items: baseline;
}
.ingredients .qty {
  font-family: var(--font-mono); font-size: .875rem; font-variant-numeric: tabular-nums;
  color: var(--primary); text-align: right; white-space: nowrap;
}

/* Method */
.method { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.method > li {
  counter-increment: step; position: relative;
  padding: 0 0 var(--s-5) var(--s-7); margin-bottom: var(--s-2);
}
.method > li::before {
  content: counter(step); position: absolute; left: 0; top: -2px;
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 600;
  color: var(--primary); line-height: 1;
}
.method strong { font-weight: 600; }

/* Pull note — the "this is the step" callout */
.note {
  border-left: 3px solid var(--primary); background: var(--bg-sunken);
  padding: var(--s-4) var(--s-5); margin: var(--s-5) 0; border-radius: 0 var(--radius) var(--radius) 0;
}
.note p:last-child { margin-bottom: 0; }
.note--warn { border-left-color: var(--warn-border); background: var(--warn-bg); }

/* Failure states — signature block */
.failures { display: grid; gap: var(--s-4); margin: var(--s-5) 0; }
.failure {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s-4) var(--s-5); background: var(--bg-raised);
}
.failure dt { font-weight: 600; color: var(--ink); margin-bottom: var(--s-2); font-size: .9375rem; }
.failure dd { margin: 0; color: var(--ink-soft); font-size: .9375rem; }

/* Tables */
.table-scroll { overflow-x: auto; margin: var(--s-5) 0; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 30rem; font-size: .9375rem; }
th, td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }

/* Figures */
figure { margin: var(--s-6) 0; }
figure img { border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-sunken); }
figcaption { font-size: .875rem; color: var(--ink-faint); margin-top: var(--s-3); font-style: italic; }

.placeholder {
  aspect-ratio: 3 / 2; display: grid; place-items: center;
  background: var(--bg-sunken); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); color: var(--ink-faint);
  font-size: .8125rem; text-align: center; padding: var(--s-5);
}

/* --- Footer --------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border); margin-top: var(--s-9);
  padding: var(--s-7) 0; background: var(--bg-sunken);
}
.site-footer .wrap { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.site-footer h4 { font-family: var(--font-body); font-size: .6875rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: var(--s-3); font-weight: 600; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: var(--s-2); }
.site-footer a { color: var(--ink-soft); text-decoration: none; font-size: .9375rem; }
.site-footer a:hover { color: var(--primary); text-decoration: underline; }
.colophon { border-top: 1px solid var(--border); margin-top: var(--s-6); padding-top: var(--s-5);
  font-size: .8125rem; color: var(--ink-faint); }

/* --- Breadcrumbs ---------------------------------------------------------- */
.crumbs { font-size: .8125rem; color: var(--ink-faint); margin: var(--s-5) 0 var(--s-4); }
.crumbs a { color: var(--ink-faint); text-decoration: none; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.crumbs span { margin: 0 var(--s-2); }

/* --- Subtle scroll reveal (respects reduced motion via the block above) ---- */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .35s ease-out, transform .35s ease-out; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* --- Browse: search, chips, filters ---------------------------------------- */
.browse { margin: var(--s-6) 0 var(--s-7); display: grid; gap: var(--s-5); }

.browse__search { display: grid; gap: var(--s-2); max-width: 28rem; }
.search-field {
  display: flex; align-items: center; gap: var(--s-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg-raised); padding: 0 var(--s-4);
  transition: border-color .2s ease;
}
.search-field:focus-within { border-color: var(--primary); }
.search-field svg { width: 18px; height: 18px; color: var(--ink-faint); flex: none; }
.search-field input {
  flex: 1; min-height: 44px; border: 0; background: none; outline: none;
  font-family: var(--font-body); font-size: 1rem; color: var(--ink);
}
.search-field input::placeholder { color: var(--ink-faint); }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; min-height: 38px;
  padding: var(--s-2) var(--s-4); border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-raised);
  color: var(--ink-soft); text-decoration: none; font-size: .875rem;
  transition: all .2s ease; cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.browse__filters { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.browse__filters select {
  min-height: 44px; padding: 0 var(--s-4); cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg-raised); color: var(--ink);
  font-family: var(--font-body); font-size: .9375rem;
}
.browse__filters select:focus-visible { border-color: var(--primary); }
.browse__count { font-size: .875rem; color: var(--ink-faint); margin: 0; }
.browse__empty {
  text-align: center; color: var(--ink-faint); padding: var(--s-8) var(--s-4);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}

/* --- Recipe cards with thumbnails ------------------------------------------ */
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }

.card--recipe { padding: 0; overflow: hidden; gap: 0; }
.card--recipe[hidden] { display: none; }
.card__thumb {
  aspect-ratio: 4 / 3; display: grid; place-items: center; padding: var(--s-4);
  text-align: center; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-size: 1.4rem; color: var(--ink-soft);
  background: var(--bg-sunken);
}
/* Until photography exists, each course gets its own tint so the grid still
   reads as a designed system rather than a wall of grey. */
.card__thumb[data-cat="main-dishes"] { background: linear-gradient(150deg, #F3E2D3, #E8CDB6); color: #6B3A1C; }
.card__thumb[data-cat="rice"]        { background: linear-gradient(150deg, #F5EEDC, #E9DDBE); color: #6A5A2A; }
.card__thumb[data-cat="breads"]      { background: linear-gradient(150deg, #F2E7D6, #DFCCAE); color: #6A4C28; }
.card__thumb[data-cat="breakfast"]   { background: linear-gradient(150deg, #FAEBD3, #F0D6A8); color: #79521B; }
.card__thumb[data-cat="snacks"]      { background: linear-gradient(150deg, #F4DFD1, #E3C0A6); color: #713518; }
.card__thumb[data-cat="desserts"]    { background: linear-gradient(150deg, #F6E3E6, #E8C6CD); color: #74303F; }
.card__thumb[data-cat="ice-cream"]   { background: linear-gradient(150deg, #E7EEF2, #CBDDE6); color: #2E4E5C; }
.card__thumb[data-cat="drinks"]      { background: linear-gradient(150deg, #E9F0E2, #CFE0C2); color: #3C5227; }
.card__thumb[data-cat="pickles"]     { background: linear-gradient(150deg, #F7EBCD, #EED9A0); color: #74551A; }

/* Darken for dark mode but push saturation up, so the hues still tell the
   categories apart instead of collapsing into grey. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card__thumb { filter: brightness(.42) saturate(1.6); }
}
:root[data-theme="dark"] .card__thumb { filter: brightness(.42) saturate(1.6); }
:root[data-theme="light"] .card__thumb { filter: none; }

.card__body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); flex: 1; }
.card--recipe.is-pending .card__thumb { opacity: .6; }
.card--recipe.is-pending h3 { color: var(--ink-soft); }

/* --- Read aloud ------------------------------------------------------------ */
.ra-s { transition: background-color .2s ease; border-radius: 2px; }
.ra-s.is-speaking {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.ra-w.is-word {
  background: var(--primary); color: #fff; border-radius: 2px;
  padding: 0 1px; margin: 0 -1px;
}
/* In dark mode the highlight is a light terracotta, so the word needs dark ink. */
:root[data-theme="dark"] .ra-w.is-word { color: #17140F; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ra-w.is-word { color: #17140F; }
}

.ra-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: var(--s-4); z-index: 60;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: 999px; box-shadow: 0 4px 24px -6px rgb(28 26 23 / .28);
  max-width: calc(100vw - 2rem);
}
.ra-bar.is-active { border-color: var(--primary); }

.ra-btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-4); cursor: pointer;
  border: 0; border-radius: 999px; background: var(--primary); color: #fff;
  font-family: var(--font-body); font-size: .9375rem; font-weight: 500;
  transition: background-color .2s ease;
}
.ra-btn:hover { background: var(--primary-deep); }
.ra-btn svg { width: 16px; height: 16px; flex: none; }
.ra-btn--stop {
  background: none; color: var(--ink-soft); min-width: 44px; padding: 0 var(--s-3);
}
.ra-btn--stop:hover { background: var(--bg-sunken); color: var(--primary); }

.ra-rate, .ra-voice { display: flex; align-items: center; gap: var(--s-2); }
.ra-voice select { max-width: 9rem; }
.ra-rate select, .ra-voice select {
  min-height: 36px; padding: 0 var(--s-2); cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: .875rem;
}
.ra-progress {
  font-family: var(--font-mono); font-size: .75rem; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

@media (max-width: 46rem) { .ra-voice .label, .ra-rate .label { display: none; } }
@media (max-width: 34rem) {
  .ra-voice { display: none; }          /* voice choice is remembered; speed matters more here */
  .ra-progress { display: none; }
}

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 34rem) {
  .site-header .wrap { flex-wrap: wrap; }
  .nav { width: 100%; justify-content: space-between; }
  .nav a { padding: var(--s-3) var(--s-2); font-size: .875rem; }
  .ingredients li { grid-template-columns: 4.5rem 1fr; gap: var(--s-3); }
  .hero { padding: var(--s-7) 0 var(--s-6); }
}
