/* =====================================================================
   Aai's Kitchen — a homey, hand-written-feeling recipe book
   Palette: warm cream, terracotta, sage, mustard, dusty rose.
   Default theme is LIGHT. Dark is a cozy candle-lit brown.
   Mobile-first; scales up gracefully.
   ===================================================================== */

/* ── Theme tokens ─────────────────────────────────────────── */
:root {
  --bg: #fdf3e7;
  --bg-warm: #f8e8d2;
  --card: #fffaf2;
  --ink: #43301f;
  --ink-soft: #7a6551;
  --line: #e7d3ba;

  --terracotta: #c9683f;
  --terracotta-soft: #f2d3c2;
  --sage: #7f9068;
  --sage-soft: #dbe3cd;
  --mustard: #d99a2b;
  --mustard-soft: #f5e0b4;
  --rose: #c2748a;
  --rose-soft: #f0d6de;

  --shadow: 22px 22px 44px rgba(120, 84, 52, 0.14);
  --shadow-sm: 0 8px 22px rgba(120, 84, 52, 0.12);
  --radius: 26px;
  --font-display: "Fraunces", Georgia, serif;
  --font-hand: "Caveat", cursive;
  --font-body: "Karla", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #241a13;
  --bg-warm: #2e2118;
  --card: #2f231a;
  --ink: #f5e7d5;
  --ink-soft: #c3a889;
  --line: #4a3626;

  --terracotta: #e08a5f;
  --terracotta-soft: #4a2e21;
  --sage: #a3b585;
  --sage-soft: #33402a;
  --mustard: #ecb653;
  --mustard-soft: #423318;
  --rose: #e0a0b3;
  --rose-soft: #45262f;

  --shadow: 22px 22px 48px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.35);
}

/* ── Base ─────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--bg-warm), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, var(--bg-warm), transparent 55%),
    var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.5s ease, color 0.5s ease;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; line-height: 1.1; }

em { font-style: italic; }

/* ── Floating background spices ───────────────────────────── */
.spice-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.spice {
  position: absolute;
  top: 110%;
  left: var(--x);
  font-size: 1.6rem;
  opacity: 0.16;
  filter: saturate(0.8);
  animation: drift var(--s, 26s) linear var(--d, 0s) infinite;
}
@keyframes drift {
  0%   { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-125vh) rotate(320deg); }
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.1rem;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  font-size: 1.7rem;
  animation: sway 4s ease-in-out infinite;
  transform-origin: 50% 80%;
}
@keyframes sway { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-hand); font-size: 1.7rem; font-weight: 700; }
.brand-sub { font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft); }

/* Header actions (GitHub link + theme toggle) */
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.gh-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1.2), color 0.3s, border-color 0.3s, background 0.3s;
}
.gh-link:hover {
  transform: translateY(-2px) rotate(-8deg);
  color: var(--terracotta);
  border-color: var(--terracotta);
  background: var(--terracotta-soft);
}
.gh-link:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }

/* Theme toggle */
.theme-toggle { border: 0; background: none; cursor: pointer; padding: 4px; }
.toggle-track {
  display: block;
  width: 60px;
  height: 30px;
  border-radius: 999px;
  background: var(--mustard-soft);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.4s ease;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--mustard);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform 0.45s cubic-bezier(0.68, -0.4, 0.27, 1.4), background 0.4s;
}
.toggle-thumb .icon-moon { display: none; }
[data-theme="dark"] .toggle-track { background: var(--sage-soft); }
[data-theme="dark"] .toggle-thumb { transform: translateX(30px); background: #4b5d78; }
[data-theme="dark"] .toggle-thumb .icon-sun { display: none; }
[data-theme="dark"] .toggle-thumb .icon-moon { display: block; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 3.4rem 1.4rem 2rem;
  text-align: center;
}
.hero-kicker {
  font-family: var(--font-hand);
  font-size: 1.5rem;
  color: var(--terracotta);
  margin: 0;
  transform: rotate(-2deg);
}
.hero-title {
  font-size: clamp(3rem, 12vw, 5.6rem);
  margin: 0.2rem 0 1rem;
  letter-spacing: -0.02em;
}
.hero-title em { color: var(--terracotta); position: relative; }
.hero-title em::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0.08em;
  height: 0.14em;
  background: var(--mustard);
  border-radius: 999px;
  transform: scaleX(0);
  transform-origin: left;
  animation: underline 1s ease 0.4s forwards;
}
@keyframes underline { to { transform: scaleX(1); } }
.hero-note {
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 34rem;
  margin: 0 auto 1.6rem;
}
.hearty { color: var(--rose); font-family: var(--font-hand); font-size: 1.4rem; }
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--terracotta);
  color: #fff;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.hero-cta:hover { transform: translateY(-3px); box-shadow: 0 14px 26px rgba(201,104,63,0.35); }
.hero-cta svg { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* Steamy plate */
.hero-plate { margin-top: 2.4rem; position: relative; display: inline-block; }
.plate { font-size: 4.4rem; animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.steam {
  position: absolute;
  top: -18px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px;
}
.steam span {
  width: 6px; height: 26px;
  background: linear-gradient(var(--ink-soft), transparent);
  border-radius: 999px;
  opacity: 0;
  animation: steam 3s ease-in-out infinite;
}
.steam span:nth-child(2) { animation-delay: 0.6s; }
.steam span:nth-child(3) { animation-delay: 1.2s; }
@keyframes steam {
  0%   { opacity: 0; transform: translateY(6px) scaleY(0.6); }
  40%  { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(-22px) scaleY(1.2); }
}

/* ── Recipes section ──────────────────────────────────────── */
.recipes {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.2rem 4rem;
}
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(2rem, 7vw, 3rem); margin: 0 0 0.3rem; }
.section-head p { color: var(--ink-soft); margin: 0; }

.recipe-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 620px) { .recipe-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 940px) { .recipe-grid { grid-template-columns: 1fr 1fr; gap: 2rem; } }

/* Recipe card */
.recipe-card {
  --a: var(--terracotta);
  --a-soft: var(--terracotta-soft);
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s, border-color 0.35s;
  position: relative;
}
.recipe-card.accent-terracotta { --a: var(--terracotta); --a-soft: var(--terracotta-soft); }
.recipe-card.accent-sage { --a: var(--sage); --a-soft: var(--sage-soft); }
.recipe-card.accent-mustard { --a: var(--mustard); --a-soft: var(--mustard-soft); }
.recipe-card.accent-rose { --a: var(--rose); --a-soft: var(--rose-soft); }

.recipe-card:hover {
  transform: translateY(-8px) rotate(-0.6deg);
  box-shadow: var(--shadow);
  border-color: var(--a);
}
.recipe-card:focus-visible { outline: 3px solid var(--a); outline-offset: 3px; }

.card-photo {
  height: 190px;
  background-size: cover;
  background-position: center;
}
.card-badge {
  height: 150px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 25%, var(--a-soft), transparent 70%),
    var(--a-soft);
}
.card-badge span { font-size: 3.6rem; animation: floaty 6s ease-in-out infinite; }

.card-body { padding: 1.1rem 1.2rem 0.4rem; flex: 1; }
.card-title { font-size: 1.45rem; margin: 0 0 0.35rem; }
.card-blurb { color: var(--ink-soft); margin: 0 0 0.9rem; font-size: 0.96rem; }

.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.meta-pill {
  font-size: 0.78rem;
  background: var(--a-soft);
  color: var(--ink);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.spice-meter { display: inline-flex; }
.chilli { filter: grayscale(1) opacity(0.35); font-size: 0.85rem; }
.chilli.on { filter: none; }

.card-open {
  padding: 0.9rem 1.2rem 1.2rem;
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--a);
  transition: transform 0.3s ease;
}
.recipe-card:hover .card-open { transform: translateX(6px); }

.grid-footer {
  text-align: center;
  margin-top: 2.4rem;
  font-family: var(--font-hand);
  font-size: 1.5rem;
  color: var(--ink-soft);
}

/* ── Reveal animation ─────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.reveal.in { opacity: 1; transform: none; }

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(50, 32, 18, 0.55);
  backdrop-filter: blur(4px);
  animation: fade 0.3s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  margin: 2.5rem 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1.1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-close {
  position: absolute;
  top: 0.8rem; right: 0.8rem;
  z-index: 3;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.85);
  color: #43301f;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease;
}
.modal-close:hover { transform: rotate(90deg); }

.modal-hero {
  --a: var(--terracotta); --a-soft: var(--terracotta-soft);
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.3rem 1.4rem;
  background:
    radial-gradient(circle at 20% 0%, var(--a-soft), transparent 70%),
    var(--bg-warm);
}
.modal-hero.accent-terracotta { --a: var(--terracotta); --a-soft: var(--terracotta-soft); }
.modal-hero.accent-sage { --a: var(--sage); --a-soft: var(--sage-soft); }
.modal-hero.accent-mustard { --a: var(--mustard); --a-soft: var(--mustard-soft); }
.modal-hero.accent-rose { --a: var(--rose); --a-soft: var(--rose-soft); }

.card-photo.big { width: 130px; height: 130px; flex: none; border-radius: 20px; box-shadow: var(--shadow-sm); }
.card-badge.big { width: 110px; height: 110px; flex: none; border-radius: 24px; }
.card-badge.big span { font-size: 3rem; }
.modal-kicker { font-family: var(--font-hand); font-size: 1.3rem; color: var(--a); margin: 0; }
.modal-hero-text h2 { font-size: clamp(1.6rem, 6vw, 2.4rem); margin: 0.1rem 0 0.6rem; }

.modal-note {
  margin: 0;
  padding: 1.1rem 1.4rem;
  font-size: 1rem;
  color: var(--ink-soft);
  font-style: italic;
  border-bottom: 1px dashed var(--line);
}

.modal-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 1.2rem 1.4rem 1.8rem;
}
@media (min-width: 680px) {
  .modal-columns { grid-template-columns: 0.85fr 1.15fr; gap: 1.8rem; }
}
.modal-columns h3 {
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0 0.9rem;
}
.sec-emoji { font-size: 1.2rem; }

/* Ingredients */
.ingredient-list { list-style: none; margin: 0; padding: 0; }
.ingredient {
  opacity: 0;
  transform: translateX(-10px);
  animation: slideIn 0.5s ease forwards;
  animation-delay: calc(var(--i) * 60ms + 0.2s);
}
@keyframes slideIn { to { opacity: 1; transform: none; } }
.ingredient label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.ingredient input { position: absolute; opacity: 0; width: 0; height: 0; }
.tick {
  width: 20px; height: 20px;
  border: 2px solid var(--line);
  border-radius: 7px;
  flex: none;
  display: grid;
  place-items: center;
  transition: background 0.25s, border-color 0.25s;
}
.tick::after {
  content: "✓";
  font-size: 0.75rem;
  color: #fff;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.2s;
}
.ingredient input:checked + .tick { background: var(--sage); border-color: var(--sage); }
.ingredient input:checked + .tick::after { opacity: 1; transform: scale(1); }
.ingredient input:checked ~ .ing-name { text-decoration: line-through; color: var(--ink-soft); }
.ing-name { flex: 1; font-weight: 500; }
.ing-qty { color: var(--ink-soft); font-size: 0.9rem; text-align: right; }

/* Steps */
.step-list { list-style: none; margin: 0; padding: 0; position: relative; }
.step-list::before {
  content: "";
  position: absolute;
  left: 15px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(var(--line), transparent);
}
.step {
  display: flex;
  gap: 0.9rem;
  padding: 0.35rem 0 0.9rem;
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  animation: slideIn 0.5s ease forwards;
  animation-delay: calc(var(--i) * 80ms + 0.25s);
}
.step-num {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--terracotta);
  color: #fff;
  font-family: var(--font-display);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  z-index: 1;
}
.step p { margin: 0.3rem 0 0; }

/* Tips */
.tips {
  margin-top: 1rem;
  background: var(--mustard-soft);
  border-radius: 18px;
  padding: 0.9rem 1.1rem;
}
.tips h4 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.tips ul { margin: 0; padding-left: 1.1rem; }
.tips li { margin-bottom: 0.3rem; color: var(--ink); }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 1.4rem 3.5rem;
  border-top: 1px solid var(--line);
  background: var(--bg-warm);
}
.footer-heart { font-size: 2rem; color: var(--rose); animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } }
.site-footer p { margin: 0.4rem 0; font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); }
.footer-small { font-family: var(--font-body) !important; font-size: 0.85rem !important; color: var(--ink-soft); }

/* ── Motion-sensitive folks ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
