/* ============================================================
   RECIPE BOOK — "The Recipe Box" theme
   A kitchen-counter dark backdrop holding a warm index-card
   panel. Cards styled like catalog cards from a wooden recipe
   box: punched hole, stamped number, dashed tear line.
   ============================================================ */

:root {
  /* Outer room */
  --bg: #1E1A15;
  --bg-deep: #15120E;

  /* Paper / index card surface */
  --paper: #FBF3E1;
  --paper-line: #E4D3A8;
  --paper-shadow: rgba(20, 14, 4, 0.45);

  /* Ink */
  --ink: #2B2013;
  --ink-soft: #5B4A32;
  --muted: #8B7A5C;

  /* Spice rack accents */
  --turmeric: #E2A335;
  --turmeric-dark: #B97F1F;
  --chili: #B3402A;
  --chili-dark: #8F2F1E;
  --cardamom: #4B7A5C;
  --cardamom-dark: #345943;

  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Work Sans", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #2B2419 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; }

code {
  font-family: "IBM Plex Mono", monospace;
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ---------- Page shell ---------- */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 20px 70px;
}

header.site {
  text-align: center;
  margin-bottom: 22px;
}

.site-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #2A2116, #201A12);
  border: 1px solid rgba(226, 163, 53, 0.35);
  border-radius: 999px;
  padding: 10px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}

.site-badge svg { width: 26px; height: 26px; flex-shrink: 0; }

header.site h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #F3E6C8;
}

header.site p.tagline {
  margin: 14px 0 0;
  color: #B9A98A;
  font-size: 0.92rem;
  font-style: italic;
  font-family: "Fraunces", Georgia, serif;
}

/* ---------- The paper panel ---------- */

.panel {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px var(--paper-shadow), 0 2px 0 rgba(0,0,0,0.05);
  padding: 8px;
}

.panel::before {
  /* subtle paper grain */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.05;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.container {
  position: relative;
  padding: 30px clamp(18px, 4vw, 44px) 44px;
}

/* ---------- Toolbar & inputs ---------- */

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--paper-line);
}

input[type="text"], input[type="number"], textarea, select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border: 1.5px solid var(--paper-line);
  border-radius: var(--radius-sm);
  background: #FFFCF4;
  color: var(--ink);
}

input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--turmeric);
  box-shadow: 0 0 0 3px rgba(226, 163, 53, 0.25);
}

.search-box { flex: 1; min-width: 180px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--turmeric);
  color: #2A1D07;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-shadow: 0 2px 0 var(--turmeric-dark);
}

.btn:hover { background: #EDB44B; transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }

.btn.secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--paper-line);
  box-shadow: none;
}
.btn.secondary:hover { background: rgba(0,0,0,0.03); border-color: var(--ink-soft); }

.btn.danger { background: var(--chili); color: #FBEDE7; box-shadow: 0 2px 0 var(--chili-dark); }
.btn.danger:hover { background: #C24A32; }

/* ---------- Recipe grid & catalog cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  background: #FFFCF4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--paper-line);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card:hover {
  transform: translateY(-4px) rotate(-0.4deg);
  box-shadow: 0 14px 28px rgba(43, 32, 19, 0.22);
}

/* punched hole */
.card::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.5);
  z-index: 2;
}

.card-photo { position: relative; }

.card-photo img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--paper-line);
  display: block;
}

.card-num {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  background: rgba(20, 14, 4, 0.72);
  color: #F3E6C8;
  padding: 3px 8px;
  border-radius: 5px;
}

.card .body {
  padding: 14px 16px 16px;
  border-top: 1px dashed var(--paper-line);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
}

.card .meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-family: "IBM Plex Mono", monospace;
  display: flex;
  gap: 12px;
}

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.tag {
  background: rgba(75, 122, 92, 0.14);
  color: var(--cardamom-dark);
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  border: 1px solid rgba(75, 122, 92, 0.25);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 70px 20px;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
}

/* ---------- Recipe detail page ---------- */

.recipe-header { position: relative; }

.recipe-header img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--paper-line);
  border: 1px solid var(--paper-line);
}

.recipe-header h1 {
  margin: 20px 0 6px;
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
}

.recipe-header .desc { color: var(--ink-soft); font-size: 1rem; }

.stats {
  display: flex;
  gap: 28px;
  margin: 20px 0;
  flex-wrap: wrap;
  padding: 16px 0;
  border-top: 1px dashed var(--paper-line);
  border-bottom: 1px dashed var(--paper-line);
}

.stat { text-align: center; }
.stat .num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--chili-dark);
}
.stat .label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 24px;
  font-family: "IBM Plex Mono", monospace;
}

.servings-control button {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--paper-line);
  background: #FFFCF4;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s ease;
}
.servings-control button:hover { background: var(--turmeric); border-color: var(--turmeric-dark); }

.sections { display: grid; grid-template-columns: 1fr 1.4fr; gap: 36px; margin-top: 8px; }
@media (max-width: 700px) { .sections { grid-template-columns: 1fr; } }

.sections h2 {
  font-size: 1.05rem;
  font-weight: 600;
  border-bottom: 2px solid var(--turmeric);
  padding-bottom: 10px;
  display: inline-block;
}

ul.ingredient-list { list-style: none; padding: 0; margin: 0; }
ul.ingredient-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--paper-line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
ul.ingredient-list li strong {
  font-family: "IBM Plex Mono", monospace;
  color: var(--chili-dark);
  white-space: nowrap;
}

ol.steps-list { padding-left: 22px; margin: 0; }
ol.steps-list li { padding: 10px 0; }
ol.steps-list li::marker {
  font-family: "IBM Plex Mono", monospace;
  color: var(--turmeric-dark);
  font-weight: 700;
}

/* ---------- Forms (add / edit / import) ---------- */

.form-row { margin-bottom: 18px; }
.form-row label {
  display: block;
  font-weight: 700;
  margin-bottom: 7px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-row textarea, .form-row input[type=text], .form-row input[type=number] { width: 100%; }

.dynamic-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.dynamic-row input { flex: 1; }
.dynamic-row .remove-btn {
  background: none;
  border: none;
  color: var(--chili);
  cursor: pointer;
  font-size: 1.1rem;
  width: 28px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.top-nav a { color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: 0.9rem; }
.top-nav a:hover { color: var(--chili-dark); }

h2#formTitle, .container > h2 {
  font-weight: 600;
  color: var(--ink);
  margin-top: 0;
}

details {
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #FFFCF4;
}
details summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
