* {
  box-sizing: border-box;
}

:root {
  --bg: #fbf5ec;
  --surface: #fffdfa;
  --surface-soft: rgba(255, 253, 250, 0.85);
  --border: rgba(146, 109, 71, 0.22);
  --text: #6f5a44;
  --text-strong: #4a3826;
  --muted: #a5907a;
  --accent: #c46a2b;
  --accent-dark: #9e4f1c;
  --honey: #d9a441;
  --honey-soft: #f6e7c6;
  --shadow: 0 10px 30px rgba(146, 109, 71, 0.12);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 164, 65, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(196, 106, 43, 0.1), transparent 28%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--honey-soft);
  color: var(--text-strong);
}

/* --- topbar --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 20px;
  max-width: 1160px;
  margin: 0 auto;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: box-shadow 200ms ease;
}

.brand {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--accent-dark);
}

.navlinks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.navlinks a {
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.navlinks a:hover,
.navlinks a.active {
  transform: translateY(-1px);
  background: var(--honey-soft);
  border-color: rgba(217, 164, 65, 0.5);
  color: var(--accent-dark);
}

/* --- hero --- */

.hero {
  padding: 0 20px 12px;
  max-width: 1160px;
  margin: 0 auto;
}

.hero-card,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 30px;
}

.hero-card {
  position: relative;
  display: flex;
  gap: 24px;
  padding: 44px 34px 40px;
  overflow: hidden;
  justify-content: center;
}

.hero-copy {
  position: relative;
  z-index: 1;
  text-align: center;
}

.eyebrow,
.section-kicker,
.meta-label,
.hero-note span,
.subsection-title {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.hero-copy h1 {
  margin: 6px 0 14px;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(2.8rem, 7vw, 4.6rem);
  line-height: 1.1;
  color: var(--accent-dark);
}

.lead {
  font-size: 1.08rem;
  line-height: 1.7;
  max-width: 56ch;
  margin: 0 auto 22px;
  color: var(--text);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  justify-items: center;
}

.meta-item {
  width: 100%;
  padding: 18px 16px;
  border-radius: 22px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  text-align: center;
}

.meta-label {
  display: block;
  margin-bottom: 8px;
}

.meta-value {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text-strong);
}

/* --- recipe cards (index) --- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

a.recipe-card-link {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  color: inherit;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

a.recipe-card-link:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(146, 109, 71, 0.18);
}

a.recipe-card-link img,
.card-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--honey-soft);
}

.card-placeholder {
  display: grid;
  place-items: center;
  font-size: 3rem;
}

.card-body {
  padding: 16px 20px 20px;
}

.card-body h2 {
  margin: 0 0 6px;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.25;
  color: var(--accent-dark);
}

.card-body p {
  margin: 0 0 8px;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text);
}

.card-body .card-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0;
}

/* --- load error --- */

.load-error {
  background: #fdeceb;
  border: 1px solid rgba(181, 70, 47, 0.35);
  color: #8e3423;
  border-radius: 18px;
  padding: 16px 20px;
  line-height: 1.6;
}

.load-error code {
  background: rgba(181, 70, 47, 0.1);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.9em;
}

.load-error-detail {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* --- sections --- */

.content {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 20px 32px;
}

.section {
  padding: 34px 0 16px;
  scroll-margin-top: 84px;
}

.section-heading {
  margin-bottom: 18px;
  text-align: center;
}

.section-heading h2 {
  margin: 6px 0 0;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(2.1rem, 4.5vw, 3rem);
  line-height: 1.15;
  color: var(--accent-dark);
}

.section-kicker::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  margin: 10px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--honey));
}

.card {
  padding: 24px;
}

/* --- recipe card --- */

.recipe-top {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.recipe-copy {
  position: relative;
  z-index: 1;
  flex: 1 1 min(58ch, 100%);
}

.recipe-copy .lead {
  margin: 0 0 14px;
}

.recipe-meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 10px;
}

.base-note {
  display: inline-block;
  background: var(--honey-soft);
  border: 1px solid rgba(217, 164, 65, 0.4);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.9rem;
  color: var(--text-strong);
  margin: 0;
}

.recipe-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: min(320px, 100%);
}

.hero-note {
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdfa, #fbf1e1);
  border: 1px solid var(--border);
}

.hero-note span {
  color: var(--accent);
}

.hero-note strong {
  display: block;
  margin: 12px 0 14px;
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text-strong);
}

/* scaling controls */

.mode-tabs,
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-tabs button,
.preset-chips button {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.mode-tabs button:hover,
.preset-chips button:hover {
  transform: translateY(-1px);
  background: var(--honey-soft);
  border-color: rgba(217, 164, 65, 0.5);
}

.mode-tabs button[aria-selected="true"],
.preset-chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mode-tabs button[aria-selected="true"]:hover,
.preset-chips button.active:hover {
  background: var(--accent-dark);
  color: #fff;
}

.custom-amount,
.custom-size {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text);
}

input[type="number"] {
  width: 5.2rem;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text-strong);
}

input[type="number"]:focus {
  outline: 2px solid rgba(196, 106, 43, 0.35);
  border-color: var(--accent);
}

.custom-amount .unit {
  color: var(--muted);
  font-size: 0.9rem;
}

.scale-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 10px 0 0;
  line-height: 1.5;
}

/* --- sub-blocks inside recipe --- */

.sub-block {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(146, 109, 71, 0.16);
}

.subsection-title {
  display: block;
  margin: 0 0 12px;
  color: var(--accent);
}

.round-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  margin: 0 0 12px;
  user-select: none;
}

.round-toggle input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.round-toggle:hover {
  color: var(--text-strong);
}

/* --- ingredients --- */

.ingredient-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0 24px;
}

.ingredient-list li {
  padding: 9px 2px;
  border-bottom: 1px dashed rgba(146, 109, 71, 0.2);
  line-height: 1.5;
}

.ingredient-list .amount {
  font-weight: 650;
  color: var(--text-strong);
  margin-right: 4px;
  white-space: nowrap;
}

.ingredient-list .ingredient-group {
  grid-column: 1 / -1;
  list-style: none;
  margin-top: 14px;
  padding: 4px 2px;
  border-bottom: none;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.ingredient-list .ingredient-group:first-child {
  margin-top: 0;
}

/* --- steps --- */

.steps-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
  line-height: 1.7;
  color: var(--text);
}

.steps-list li::marker {
  color: var(--accent);
  font-weight: 700;
  font-family: "Fraunces", serif;
}

.step-title {
  color: var(--text-strong);
}

.steps-sub {
  margin: 6px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  line-height: 1.65;
}

.steps-sub li::marker {
  color: var(--muted);
  font-weight: 600;
}

.tips-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
  color: var(--text);
}

.tips-list li::marker {
  color: var(--honey);
}

.tips-list li + li {
  margin-top: 6px;
}

/* --- gallery --- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 0;
}

.gallery figure {
  margin: 0;
}

.image-card {
  padding: 0;
  overflow: hidden;
}

.gallery .image-card {
  padding: 8px;
}

.gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  background: #fff;
}

img.zoomable {
  cursor: zoom-in;
  transition: transform 160ms ease;
}

img.zoomable:hover {
  transform: scale(1.02);
}

.gallery figcaption {
  font-size: 0.83rem;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

/* --- lightbox --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(58, 40, 24, 0.9);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
  animation: lightbox-fade 200ms ease;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: min(92vw, 1400px);
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  cursor: default;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav[hidden] {
  display: none;
}

.lightbox-prev {
  left: max(16px, 4vw);
}

.lightbox-next {
  right: max(16px, 4vw);
}

.lightbox-counter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

@keyframes lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- footer --- */

.footer {
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px 20px clamp(60px, 12vw, 140px);
  color: var(--muted);
  text-align: center;
}

.footer p {
  margin: 0;
}

/* --- responsive --- */

@media (max-width: 900px) {
  .recipe-top {
    flex-direction: column;
  }

  .recipe-panel {
    min-width: 0;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero,
  .content,
  .footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero-card,
  .card {
    border-radius: 24px;
  }

  .hero-card {
    padding: 30px 20px;
  }

  .topbar {
    padding: 12px 14px;
    gap: 8px;
  }

  .navlinks a {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .ingredient-list {
    grid-template-columns: 1fr;
  }

  .gallery {
    grid-template-columns: 1fr 1fr;
  }

  .lightbox {
    padding: 10px;
  }

  .lightbox-nav {
    width: 42px;
    height: 42px;
    font-size: 1.6rem;
  }

  .lightbox-prev {
    left: 6px;
  }

  .lightbox-next {
    right: 6px;
  }
}

@media print {
  .topbar, .hero, .footer, .lightbox, .recipe-panel, .gallery { display: none !important; }
  body { background: #fff; }
  .card { border: none; box-shadow: none; padding: 0; }
}
