/* Dallas' Recipe Vault — shared styles
 * Dark theme. Mobile-first. Print-friendly (reverts to light for paper).
 */

:root {
  --bg: #0f1115;
  --surface: #1a1d23;
  --surface-2: #22262e;
  --ink: #e8eaed;
  --ink-soft: #9aa0a6;
  --rule: #2a2e36;
  --accent: #e8896a;          /* warm terracotta — readable on dark */
  --accent-strong: #ff9d7a;   /* hover/focus emphasis */
  --accent-soft: rgba(232, 137, 106, 0.14);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.55), 0 10px 28px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --maxw: 1100px;
  --maxw-reading: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

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

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px;
}

/* Recipe detail pages want a narrower reading width */
.recipe-page .container,
.container.reading {
  max-width: var(--maxw-reading);
}

/* ---------- Site header ---------- */
.site-header {
  padding: 28px 16px 12px;
  text-align: center;
}
.site-header h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.site-header .tagline {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Index controls (search + filters) ---------- */
.controls-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 21, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
  padding: 12px 16px;
  margin: 0 -16px 14px;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0;
}
.search-box {
  flex: 1 1 280px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box input::placeholder { color: var(--ink-soft); }
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}
.count {
  color: var(--ink-soft);
  font-size: 0.9em;
  white-space: nowrap;
}
.clear-btn {
  padding: 7px 12px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85em;
  transition: color 0.15s, border-color 0.15s;
}
.clear-btn:hover { color: var(--ink); border-color: var(--accent); }

.sort-select {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
}
.sort-select:hover { border-color: var(--accent); }
.sort-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}
.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
}
.quick-filters .filter-tag.time { background: transparent; border-color: var(--rule); }
.quick-filters .filter-tag.time.active { background: var(--accent); color: #0f1115; border-color: var(--accent); }
.filter-tag {
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.82em;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-tag:hover { color: var(--ink); }
.filter-tag.active {
  background: var(--accent);
  color: #0f1115;
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- Recipe grid (index page cards) ---------- */
.recipe-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Categorized layout: a stack of category sections, each with its own grid */
.recipe-categories {
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.recipe-category[hidden] { display: none; }
.recipe-category .category-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  scroll-margin-top: 90px; /* so jump-links land below the sticky controls bar */
}
.recipe-category .category-heading .cat-count {
  font-size: 0.78em;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-soft);
}

/* Jump-link nav above the category sections */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
}
.category-nav a {
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.82em;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.category-nav a:hover {
  color: var(--ink);
  border-color: var(--accent);
  text-decoration: none;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.recipe-card .thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}
.recipe-card .body { padding: 16px 18px 14px; display: flex; flex-direction: column; flex: 1; }
.recipe-card:hover {
  transform: translateY(-2px);
  text-decoration: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
.recipe-card h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.recipe-card .subtitle {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 0.92em;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.recipe-card .card-tag {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72em;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.recipe-card .meta {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.85em;
  color: var(--ink-soft);
}
.recipe-card .meta .mi { display: inline-flex; align-items: center; gap: 5px; }
.recipe-card .meta .mi svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.8; }
.recipe-card .meta b { color: var(--ink); font-weight: 600; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-soft);
  padding: 60px 20px;
  font-size: 1.05em;
}

/* ---------- Recipe detail page ---------- */
.recipe-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  font-size: 14px;
}
.recipe-nav a { color: var(--ink-soft); }
.recipe-nav a:hover { color: var(--accent); }
.print-btn {
  background: var(--accent);
  color: #0f1115;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background 0.15s;
}
.print-btn:hover { background: var(--accent-strong); }

.recipe-hero {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.recipe-hero h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.recipe-hero .summary {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 15px;
}
.recipe-hero .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}
.recipe-hero .tag {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  font-weight: 500;
}
.recipe-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.recipe-meta .stat { text-align: center; }
.recipe-meta .stat .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.recipe-meta .stat .value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.recipe-section {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.recipe-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.ingredients ul { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  display: flex; gap: 10px; align-items: baseline;
}
.ingredients li:last-child { border-bottom: none; }
.ingredients .qty { font-weight: 600; min-width: 80px; flex-shrink: 0; color: var(--ink); }
.ingredients .item { flex: 1; }
.ingredients .group-label {
  display: block;
  margin-top: 8px; margin-bottom: 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.ingredients .group-label:first-child { margin-top: 0; }

.equipment ul { margin: 0; padding-left: 20px; }
.equipment li { padding: 3px 0; }

.steps ol { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  padding: 12px 0 12px 44px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 10px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.notes p { margin: 0 0 8px; }
.notes p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.footer-note {
  color: var(--ink-soft);
  font-size: 0.85em;
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .site-header h1 { font-size: 26px; }
  .recipe-grid { gap: 12px; grid-template-columns: 1fr; }
  .recipe-card { padding: 16px 18px 14px; }
  .recipe-hero { padding: 20px 18px; }
  .recipe-hero h1 { font-size: 24px; }
  .recipe-section { padding: 18px 16px; }
}

/* ---------- Hero image on recipe page ---------- */
.recipe-hero .hero-img {
  display: block;
  width: calc(100% + 40px);
  margin: -24px -20px 18px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid var(--rule);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ---------- Servings scaler ---------- */
.recipe-section .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.recipe-section .section-header h2 { margin: 0; }
.scaler {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
}
.scaler-label {
  font-size: 0.78em;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 6px 0 8px;
}
.scaler button {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  font: inherit;
  font-size: 0.85em;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.scaler button:hover { color: var(--ink); }
.scaler button.active {
  background: var(--accent);
  color: #0f1115;
}

/* Visually flag when quantities are scaled away from 1× */
.ingredients .qty { transition: color 0.15s; }
body.scaled .ingredients .qty { color: var(--accent); }

/* ---------- Cook mode ---------- */
.cook-btn {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 6px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.cook-btn:hover { color: var(--ink); border-color: var(--accent); }
.cook-btn.active {
  background: var(--accent);
  color: #0f1115;
  border-color: var(--accent);
  font-weight: 600;
}

body.cook-mode {
  font-size: 19px;
}
body.cook-mode .recipe-hero .summary,
body.cook-mode .recipe-hero .tags,
body.cook-mode .recipe-section.notes,
body.cook-mode .recipe-section.equipment {
  display: none;
}
body.cook-mode .steps li { padding-top: 18px; padding-bottom: 18px; }
body.cook-mode .ingredients li { padding-top: 12px; padding-bottom: 12px; }

/* ---------- Filters dropdown (index page) ---------- */
.filters-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 7px 12px 7px 10px;
  font: inherit;
  font-size: 0.88em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.filters-btn:hover { border-color: var(--accent); color: var(--ink); }
.filters-btn .chev { transition: transform 0.18s ease; opacity: 0.7; }
.filters-btn.open { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filters-btn.open .chev { transform: rotate(180deg); }

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #0f1115;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.filters-panel {
  margin-top: 12px;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: filtersFadeIn 0.15s ease;
}
@keyframes filtersFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.filters-section + .filters-section { margin-top: 14px; }
.filters-label {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.filters-panel .quick-filters,
.filters-panel .tag-filters {
  margin: 0;
}
.filters-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: flex-end;
}

/* ---------- Unit toggle (recipe pages) ---------- */
.unit-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  margin-right: 6px;
}
.unit-toggle button {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  font: inherit;
  font-size: 0.78em;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  letter-spacing: 0.02em;
}
.unit-toggle button:hover { color: var(--ink); }
.unit-toggle button.active {
  background: var(--accent);
  color: #0f1115;
}

.recipe-nav .nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Print: always light, no chrome ---------- */
@media print {
  :root {
    --bg: white; --surface: white; --surface-2: white;
    --ink: black; --ink-soft: #555; --rule: #ccc;
    --shadow: none; --shadow-hover: none;
    --accent: #b9472a; --accent-soft: #f4e6df;
  }
  body { background: white; color: black; font-size: 11pt; line-height: 1.4; }
  .container { max-width: none; padding: 0; }
  .site-header, .recipe-nav, .print-btn, .cook-btn, .unit-toggle, .controls, .controls-bar, .filters-btn, .filters-panel, .tag-filters, .quick-filters, .scaler, .footer-note, .category-nav { display: none !important; }
  .recipe-section .section-header { display: block; }
  .recipe-hero .hero-img { display: none; }
  .recipe-hero, .recipe-section {
    border: none; box-shadow: none;
    padding: 0; margin-bottom: 14pt;
    page-break-inside: avoid;
  }
  .recipe-hero h1 { font-size: 20pt; }
  .recipe-section h2 { font-size: 12pt; color: black; border-bottom: 1px solid #999; padding-bottom: 2pt; }
  .recipe-hero .tags { display: none; }
  .ingredients li, .steps li { border-bottom: 1px solid #eee; }
  .steps li::before { background: white; color: black; border: 1px solid #999; }
  a { color: black; text-decoration: none; }
  .ingredients, .steps { page-break-inside: avoid; }
}
