/* ================================================================
   Cookbook · Shared theme
   ================================================================ */

:root {
  --bg:           #0d0b09;
  --bg-2:         #16110d;
  --bg-3:         #1d1712;
  --ink:          #f2e8d5;
  --ink-soft:     #d4c8b0;
  --ink-dim:      #8a7e6a;
  --vermillion:   #e94b38;
  --jade:         #8fb897;
  --gold:         #e0b964;
  --line:         rgba(242, 232, 213, 0.10);
  --line-strong:  rgba(242, 232, 213, 0.18);
  --shadow-1:     0 1px 0 rgba(255,255,255,0.03) inset, 0 20px 40px -20px rgba(0,0,0,0.6);
  --shadow-card:  0 30px 60px -30px rgba(0,0,0,0.7);
  --stamp-text:   #fff8ec;
  --stamp-border: #f9e8c5;
  --bg-glow-1:    rgba(233, 75, 56, 0.10);
  --bg-glow-2:    rgba(143, 184, 151, 0.07);
}

:root[data-theme="light"] {
  --bg:           #f6f1e7;
  --bg-2:         #fffaf0;
  --bg-3:         #fdf5e3;
  --ink:          #1a1612;
  --ink-soft:     #3a3127;
  --ink-dim:      #7c6f5d;
  --vermillion:   #b4332a;
  --jade:         #4a7a55;
  --gold:         #8a6f2d;
  --line:         rgba(26, 22, 18, 0.12);
  --line-strong:  rgba(26, 22, 18, 0.22);
  --shadow-1:     0 1px 0 rgba(255,255,255,0.6) inset, 0 14px 30px -16px rgba(60,40,20,0.20);
  --shadow-card:  0 24px 50px -28px rgba(60,40,20,0.30);
  --stamp-text:   #fff8ec;
  --stamp-border: #fff;
  --bg-glow-1:    rgba(180, 51, 42, 0.06);
  --bg-glow-2:    rgba(74, 122, 85, 0.05);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:           #f6f1e7;
    --bg-2:         #fffaf0;
    --bg-3:         #fdf5e3;
    --ink:          #1a1612;
    --ink-soft:     #3a3127;
    --ink-dim:      #7c6f5d;
    --vermillion:   #b4332a;
    --jade:         #4a7a55;
    --gold:         #8a6f2d;
    --line:         rgba(26, 22, 18, 0.12);
    --line-strong:  rgba(26, 22, 18, 0.22);
    --shadow-1:     0 1px 0 rgba(255,255,255,0.6) inset, 0 14px 30px -16px rgba(60,40,20,0.20);
    --shadow-card:  0 24px 50px -28px rgba(60,40,20,0.30);
    --bg-glow-1:    rgba(180, 51, 42, 0.06);
    --bg-glow-2:    rgba(74, 122, 85, 0.05);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ---------- Body & typography stack ---------- */
body {
  font-family: 'Fraunces', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 17px;
  font-weight: 400;
  background-image:
    radial-gradient(ellipse 80% 50% at 15% 0%, var(--bg-glow-1), transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 60%, var(--bg-glow-2), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}
@media (max-width: 720px) {
  .container { padding: 32px 20px 60px; }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 56px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.topbar .brand-mark {
  width: 32px;
  height: 32px;
  background: var(--vermillion);
  color: var(--stamp-text);
  display: grid;
  place-items: center;
  font-family: 'Noto Serif TC', 'Songti SC', 'Source Han Serif TC', serif;
  font-weight: 900;
  font-size: 18px;
  border: 2px double var(--stamp-border);
  transform: rotate(-4deg);
  line-height: 1;
}

/* ---------- Hero (recipe pages + index) ---------- */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 36px;
  align-items: center;
  padding: 24px 0 48px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 56px;
}
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
}

.stamp {
  width: 120px;
  height: 120px;
  background: var(--vermillion);
  display: grid;
  place-items: center;
  font-family: 'Noto Serif TC', 'Songti SC', 'Source Han Serif TC', serif;
  font-weight: 900;
  color: var(--stamp-text);
  font-size: 64px;
  transform: rotate(-5deg);
  border: 4px double var(--stamp-border);
  box-shadow: 6px 6px 0 var(--bg-3), 6px 6px 0 1px var(--line-strong);
  line-height: 1;
}
@media (max-width: 720px) {
  .stamp { width: 84px; height: 84px; font-size: 44px; border-width: 3px; }
}

.hero-text { min-width: 0; }
.eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--jade);
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: '';
  width: 28px;
  height: 1px;
  background: var(--jade);
  display: inline-block;
}

h1.chinese {
  font-family: 'Noto Serif TC', 'Songti SC', 'Source Han Serif TC', serif;
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 900;
  line-height: 1.0;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}
h1.chinese span { color: var(--vermillion); }

h2.english {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(20px, 2.4vw, 30px);
  color: var(--gold);
  letter-spacing: 0.005em;
  margin-bottom: 22px;
}

.lede {
  max-width: 620px;
  font-size: 17px;
  color: var(--ink-soft);
  border-left: 2px solid var(--gold);
  padding-left: 18px;
  margin-top: 4px;
}

/* ---------- Meta strip ---------- */
.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 24px;
  padding: 24px 28px;
  margin-top: 36px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.meta div {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-top: 1px solid var(--vermillion);
  padding-top: 10px;
}
.meta strong {
  display: block;
  margin-top: 6px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

/* ---------- Section grid (recipe pages) ---------- */
.grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 48px;
  padding: 64px 0;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; gap: 24px; padding: 40px 0; }
}

.section-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--jade);
  text-transform: uppercase;
  position: sticky;
  top: 30px;
  align-self: start;
  height: fit-content;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-label::before {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--jade);
}
.section-label .cn {
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  letter-spacing: 0.3em;
  color: var(--gold);
  margin-right: 6px;
}
@media (max-width: 820px) {
  .section-label { position: static; }
}

h3 {
  font-family: 'Noto Serif TC', 'Songti SC', serif;
  font-size: clamp(28px, 3.5vw, 36px);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--ink);
}
h3 small {
  display: block;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  color: var(--vermillion);
  margin-top: 4px;
  margin-bottom: 24px;
}

/* ---------- Ingredient blocks ---------- */
.ing-box {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  padding: 28px 32px;
  position: relative;
  border-radius: 2px;
  box-shadow: var(--shadow-1);
}
.ing-box[data-badge]::before {
  content: attr(data-badge);
  position: absolute;
  top: -12px;
  left: 24px;
  background: var(--vermillion);
  color: var(--stamp-text);
  padding: 4px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  font-weight: 500;
}

ul.ing { list-style: none; }
ul.ing li {
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-bottom: 1px dashed var(--line);
  font-size: 16px;
  color: var(--ink-soft);
}
ul.ing li:last-child { border-bottom: none; }
ul.ing li > span:first-child::after {
  content: '';
  display: block;
}
ul.ing .amt {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
  font-weight: 400;
  text-transform: uppercase;
}

/* ---------- Steps ---------- */
ol.steps { list-style: none; counter-reset: step; }
ol.steps li {
  counter-increment: step;
  padding: 24px 0 24px 88px;
  position: relative;
  border-bottom: 1px solid var(--line);
  font-size: 16.5px;
  color: var(--ink-soft);
  line-height: 1.65;
}
ol.steps li:last-child { border-bottom: none; }
ol.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 24px;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: 56px;
  color: var(--vermillion);
  line-height: 1;
  width: 70px;
  text-align: right;
}
ol.steps li strong {
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- Tip ---------- */
.tip {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--vermillion);
  padding: 36px 40px;
  margin-top: 56px;
  position: relative;
  border-radius: 2px;
  box-shadow: var(--shadow-1);
}
.tip::before {
  content: '訣';
  position: absolute;
  top: -22px;
  left: 28px;
  background: var(--vermillion);
  color: var(--stamp-text);
  font-family: 'Noto Serif TC', serif;
  font-weight: 900;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 28px;
  transform: rotate(-4deg);
  border: 2px double var(--stamp-border);
  line-height: 1;
}
.tip h4 {
  font-family: 'Noto Serif TC', serif;
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0 14px;
  color: var(--gold);
}
.tip p {
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 720px;
}
.tip p + p { margin-top: 10px; }

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 60px 0 0;
  margin-top: 40px;
  border-top: 1px solid var(--line);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
footer::before {
  content: '※';
  display: block;
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  color: var(--gold);
  margin-bottom: 16px;
  letter-spacing: 0;
}

/* ---------- Back link ---------- */
.back {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--jade);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s, color 0.15s;
}
.back:hover { border-bottom-color: var(--jade); color: var(--ink); }

/* ---------- Index: cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 28px;
  padding: 0 0 40px;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  padding: 32px 28px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  border-radius: 2px;
  transition: transform 0.25s ease, border-color 0.2s, box-shadow 0.25s;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--vermillion);
  transform: scaleX(0.2);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--vermillion);
  box-shadow: var(--shadow-card);
}
.card:hover::before { transform: scaleX(1); }

.card-stamp {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  background: var(--vermillion);
  color: var(--stamp-text);
  font-family: 'Noto Serif TC', serif;
  font-weight: 900;
  font-size: 26px;
  display: grid;
  place-items: center;
  transform: rotate(-5deg);
  border: 2px double var(--stamp-border);
  box-shadow: 3px 3px 0 var(--bg-3);
  line-height: 1;
}

.card-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--jade);
  margin-bottom: 14px;
}

.card-chinese {
  font-family: 'Noto Serif TC', 'Songti SC', serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 6px;
  color: var(--ink);
  padding-right: 60px;
}

.card-english {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  color: var(--gold);
  margin-bottom: 14px;
  line-height: 1.25;
}

.card-lede {
  font-size: 14.5px;
  color: var(--ink-soft);
  margin-bottom: auto;
  padding-bottom: 18px;
  line-height: 1.55;
}

.card-meta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.card-meta span strong {
  color: var(--ink);
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-dim);
  font-style: italic;
  border: 1px dashed var(--line);
  border-radius: 2px;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  transition: border-color 0.15s, transform 0.2s, background 0.15s;
  box-shadow: var(--shadow-1);
}
.theme-toggle:hover {
  border-color: var(--vermillion);
  transform: rotate(20deg);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { line-height: 1; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  position: fixed;
  top: 20px;
  right: 68px;
  z-index: 100;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: 'Noto Serif TC', 'Songti SC', serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  transition: border-color 0.15s, transform 0.2s, background 0.15s;
  box-shadow: var(--shadow-1);
}
.lang-toggle:hover { border-color: var(--vermillion); transform: scale(1.08); }
.lang-toggle .lang-cn,
.lang-toggle .lang-en-label { line-height: 1; }
.lang-toggle .lang-en-label {
  display: none;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.lang-toggle .lang-cn { display: block; }
:root[data-lang="zh"] .lang-toggle .lang-cn { display: none; }
:root[data-lang="zh"] .lang-toggle .lang-en-label { display: block; }
