/* ============================================================
   1. CSS Custom Properties
   ============================================================ */
:root {
  --color-bg:         #fafaf8;
  --color-surface:    #ffffff;
  --color-border:     #e8e5df;
  --color-text:       #1a1a1a;
  --color-text-muted: #6b6560;
  --color-accent:     #c0392b;
  --color-accent-hover: #a93226;
  --color-tag-bg:     #f0ede8;
  --color-tag-text:   #4a4540;

  --font-serif:  Georgia, 'Times New Roman', serif;
  --font-sans:   system-ui, -apple-system, sans-serif;
  --font-mono:   'Courier New', monospace;

  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;

  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.12);

  --max-w: 1100px;
  --max-w-text: 700px;
}

/* ============================================================
   2. Reset + Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: normal;
  line-height: 1.3;
  color: var(--color-text);
}

h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: var(--space-md); }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); margin-bottom: var(--space-sm); }
h3 { font-size: 1.1rem; margin-bottom: var(--space-sm); }

p { margin-bottom: var(--space-md); }
ul, ol { padding-left: 1.5rem; margin-bottom: var(--space-md); }
li { margin-bottom: var(--space-xs); }

code { font-family: var(--font-mono); font-size: .88em; background: var(--color-tag-bg); padding: .1em .3em; border-radius: 3px; }

hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-xl) 0; }

/* ============================================================
   3. Layout
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

.main-content {
  flex: 1;
  padding-block: var(--space-2xl);
}

/* ============================================================
   4. Components
   ============================================================ */

/* --- Nav / Header --- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding-block: var(--space-md);
}

/* --- Disclaimer banner --- */
.disclaimer {
  background: #fef9e7;
  border-bottom: 1px solid #f0d080;
  color: #7a6000;
  font-size: .85rem;
  padding-block: var(--space-sm);
  text-align: center;
}

.site-logo {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-text);
  white-space: nowrap;
}
.site-logo:hover { color: var(--color-accent); text-decoration: none; }

.site-nav { display: flex; gap: var(--space-md); }
.site-nav a {
  color: var(--color-text-muted);
  font-size: .9rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}
.site-nav a:hover {
  background: var(--color-tag-bg);
  color: var(--color-text);
  text-decoration: none;
}

/* --- Search --- */
.search-wrap {
  flex: 1;
  max-width: 400px;
  margin-left: auto;
  position: relative;
}

#search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: .9rem;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(192,57,43,.1);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}

.search-dropdown a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  font-size: .9rem;
  transition: background .1s;
}
.search-dropdown a:last-child { border-bottom: none; }
.search-dropdown a:hover { background: var(--color-tag-bg); text-decoration: none; }
.search-result-title { font-weight: 600; }
.search-result-desc { color: var(--color-text-muted); font-size: .82rem; }
.search-all-link { color: var(--color-accent); font-size: .85rem; text-align: center; }

/* --- Recipe Grid --- */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
}

/* --- Recipe Card --- */
.recipe-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
  position: relative; /* anchor for stretched link */
}
.recipe-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-image-wrap { display: block; aspect-ratio: 16/9; overflow: hidden; }
.card-image-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.recipe-card:hover .card-image-wrap img { transform: scale(1.03); }

.card-body { padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-xs); flex: 1; }
.card-title { font-size: 1rem; font-family: var(--font-serif); }

/* Stretched link — covers the whole card */
.card-link {
  color: var(--color-text);
  text-decoration: none;
}
.card-link::after {
  content: '';
  position: absolute;
  inset: 0;
}
.recipe-card:hover .card-link { color: var(--color-accent); }

.card-desc { font-size: .85rem; color: var(--color-text-muted); line-height: 1.5; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; margin-top: var(--space-xs); }
.meta-item { font-size: .78rem; color: var(--color-text-muted); }

/* --- Tags --- */
.tag, .meta-tag {
  display: inline-block;
  font-size: .75rem;
  padding: 2px 8px;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  border-radius: 20px;
  transition: background .15s, color .15s;
  position: relative; /* sit above the stretched link */
  z-index: 1;
}
.tag:hover, .meta-tag:hover {
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
}

/* --- Home Sections --- */
.home-section { margin-bottom: var(--space-2xl); }
.section-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text);
}

/* --- Recipe Page --- */
.recipe-page { max-width: var(--max-w-text); margin-inline: auto; }

.recipe-hero {
  margin-bottom: var(--space-xl);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/7;
}
.recipe-hero img { width: 100%; height: 100%; object-fit: cover; }

.recipe-header { margin-bottom: var(--space-xl); }
.recipe-title { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: var(--space-sm); }
.recipe-description { font-size: 1.1rem; color: var(--color-text-muted); margin-bottom: var(--space-md); }

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
}
.recipe-meta .meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
.meta-value { font-size: .95rem; font-weight: 600; }
.meta-link { color: var(--color-accent); }

.recipe-tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

/* Recipe Body typography */
.recipe-body { line-height: 1.75; }
.recipe-body h2 {
  font-size: 1.3rem;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
}
.recipe-body h3 { font-size: 1.05rem; margin-top: var(--space-lg); margin-bottom: var(--space-sm); color: var(--color-text-muted); }
.recipe-body ul { list-style: none; padding-left: 0; }
.recipe-body ul li {
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border);
}
.recipe-body ul li::before { content: '·'; margin-right: var(--space-sm); color: var(--color-accent); }
.recipe-body ol { counter-reset: steps; list-style: none; padding-left: 0; }
.recipe-body ol li {
  counter-increment: steps;
  padding: var(--space-md) 0;
  padding-left: 2.5rem;
  position: relative;
  border-bottom: 1px solid var(--color-border);
}
.recipe-body ol li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: var(--space-md);
  width: 1.75rem;
  height: 1.75rem;
  background: var(--color-accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: bold;
}

/* --- List page --- */
.page-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin-bottom: var(--space-xl);
}

.list-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-2xl);
  align-items: start;
}

.sidebar-title {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  margin-top: var(--space-lg);
}
.sidebar-title:first-child { margin-top: 0; }

.sidebar-list { list-style: none; padding: 0; }
.sidebar-list li { border-bottom: 1px solid var(--color-border); }
.sidebar-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-text);
  font-size: .9rem;
  transition: background .1s, color .1s;
  border-radius: var(--radius);
}
.sidebar-link:hover { background: var(--color-tag-bg); color: var(--color-accent); text-decoration: none; }
.sidebar-count { color: var(--color-text-muted); font-size: .8rem; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

/* --- Feedback --- */
.feedback-section { margin-top: var(--space-2xl); padding-top: var(--space-xl); border-top: 1px solid var(--color-border); }

.feedback-details { }
.feedback-summary {
  cursor: pointer;
  font-size: .9rem;
  color: var(--color-text-muted);
  user-select: none;
  padding: var(--space-sm) 0;
}
.feedback-summary:hover { color: var(--color-accent); }

.feedback-form { display: flex; flex-direction: column; gap: var(--space-sm); padding-top: var(--space-md); }

/* Star rating — reverse-order radio trick */
.stars-fieldset { border: none; padding: 0; margin-bottom: var(--space-sm); }
.stars-legend { font-size: .85rem; color: var(--color-text-muted); margin-bottom: var(--space-xs); display: block; }
.stars {
  display: flex;
  flex-direction: row-reverse; /* inputs are 5→1 in DOM; reverse makes 1 appear left */
  justify-content: flex-end;
  gap: 2px;
}
.star-input { display: none; }
.star-label {
  font-size: 1.8rem;
  color: var(--color-border);
  cursor: pointer;
  line-height: 1;
  transition: color .1s, transform .1s;
  -webkit-user-select: none;
  user-select: none;
}
/* Highlight hovered star and all stars to its left (= higher indices in reversed flex) */
.star-label:hover,
.star-label:hover ~ .star-label,
.star-input:checked ~ .star-label {
  color: #f0a500;
}
.star-label:hover { transform: scale(1.15); }

.feedback-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: .9rem;
  resize: vertical;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color .15s;
}
.feedback-textarea:focus { outline: none; border-color: var(--color-accent); }

.btn-submit {
  align-self: flex-start;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-submit:hover { background: var(--color-accent-hover); }
.feedback-thanks { color: var(--color-accent); font-weight: 600; }

/* --- Footer --- */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-lg);
  text-align: center;
  color: var(--color-text-muted);
  font-size: .85rem;
}

/* --- Misc --- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.empty-state { color: var(--color-text-muted); font-style: italic; }
.loading-msg { color: var(--color-text-muted); font-style: italic; }

/* ============================================================
   5. Responsive
   ============================================================ */
@media (max-width: 768px) {
  .container { padding-inline: var(--space-md); }

  .site-header .container {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }
  .search-wrap { order: 3; max-width: 100%; flex: 1 1 100%; margin-left: 0; }

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

  .list-layout { grid-template-columns: 1fr; }
  .list-sidebar { order: 2; }
  .list-main { order: 1; }

  .recipe-meta { gap: var(--space-md); }
}

@media (max-width: 480px) {
  .recipe-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   6. Print
   ============================================================ */
@media print {
  @page {
    size: A4;
    margin: 2cm 2.5cm;
  }

  /* Hide non-essential elements */
  .site-header,
  .site-footer,
  #search-input,
  .search-wrap,
  .site-nav,
  .feedback-section,
  .no-print {
    display: none !important;
  }

  body {
    font-family: var(--font-serif);
    font-size: 11pt;
    line-height: 1.6;
    color: #000;
    background: #fff;
  }

  .main-content { padding: 0; }
  .container { padding: 0; max-width: 100%; }

  .recipe-page { max-width: 100%; }

  .recipe-title { font-size: 22pt; margin-bottom: 6pt; }
  .recipe-description { font-size: 11pt; margin-bottom: 12pt; }

  .recipe-meta {
    border: 1px solid #999;
    padding: 8pt;
    margin-bottom: 12pt;
    display: flex;
    flex-wrap: wrap;
    gap: 24pt;
    page-break-inside: avoid;
  }

  .recipe-tags { display: none; }

  .recipe-hero { max-height: 10cm; page-break-inside: avoid; margin-bottom: 12pt; }
  .recipe-hero img { max-height: 10cm; object-fit: cover; width: 100%; }

  .recipe-body h2 { font-size: 14pt; page-break-after: avoid; border-bottom: 1px solid #ccc; }
  .recipe-body h3 { font-size: 12pt; page-break-after: avoid; }

  .recipe-body ul li { page-break-inside: avoid; }
  .recipe-body ol li { page-break-inside: avoid; }
  .recipe-body ol li::before {
    background: #000;
    color: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  a { color: #000; text-decoration: none; }
  a[href]::after { content: none; }
}
