/* The Atack Family Cookbook — one stylesheet for every page. */

:root {
  --paper: #ffffff;
  --card: #f7f7f7;
  --ink: #2a231e;
  --muted: #6c6158;
  --faint: #998d82;
  --line: #e4d9ca;
  --line-strong: #cdbfac;
  --accent: #557260;
  --accent-ink: #497a5c;
  --accent-soft: #dff0e0;
  --ok: #3d6b3a;
  --ok-soft: #e4efe0;
  --warn-soft: #fbefd5;
  --danger: #a1281c;
  --danger-soft: #f8e1dd;
  --add: #e3f0dc;
  --del: #f7dfdb;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 2px 8px rgba(60, 40, 20, 0.05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

h1, h2, h3 { font-weight: 600; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 2.1rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Layout ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.site-header .inner {
  max-width: 1000px; margin: 0 auto; padding: 0.85rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand {
  font-size: 1.3rem; font-weight: 600; color: var(--ink); text-decoration: none;
  letter-spacing: 0.01em; margin-right: auto;
}
.nav { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; font-family: var(--sans); font-size: 0.92rem; }
.nav a { padding: 0.4rem 0.6rem; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.nav a:hover { background: var(--accent-soft); }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav .btn { margin-left: 0.25rem; }

main { max-width: 1000px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
main.narrow { max-width: 760px; }
main.tiny { max-width: 440px; }

.site-footer { text-align: center; color: var(--faint); font-family: var(--sans); font-size: 0.8rem; padding: 0 1rem 2rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow);
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.sans { font-family: var(--sans); }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 1rem; }

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: 500 0.92rem/1.2 var(--sans);
  padding: 0.55rem 0.95rem; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.btn.link { border: none; background: none; padding: 0.2rem 0.3rem; color: var(--accent); }
.btn.link:hover { text-decoration: underline; }
.btn[disabled] { opacity: 0.55; cursor: default; }

label { display: block; font: 600 0.85rem/1.3 var(--sans); margin-bottom: 0.3rem; color: var(--ink); }
.hint { font: 400 0.8rem/1.4 var(--sans); color: var(--muted); margin-top: 0.25rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
  width: 100%; font: 400 1rem/1.4 var(--sans); color: var(--ink);
  padding: 0.55rem 0.7rem; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #fff;
}
textarea { resize: vertical; min-height: 2.6rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.field { margin-bottom: 1.1rem; }
.field-error { color: var(--danger); font: 500 0.82rem/1.3 var(--sans); margin-top: 0.3rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }

.notice {
  font: 400 0.92rem/1.45 var(--sans); padding: 0.75rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); margin-bottom: 1rem;
}
.notice.error { background: var(--danger-soft); border-color: #e9b9b1; color: #6d1a12; }
.notice.ok { background: var(--ok-soft); border-color: #bcd5b4; color: #2a4a28; }
.notice.warn { background: var(--warn-soft); border-color: #ead39d; color: #5c4510; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: #fff; font: 500 0.9rem var(--sans);
  padding: 0.65rem 1.1rem; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50;
}

/* ---------- Recipe icon (photo thumbnail or monogram) ---------- */

.ricon {
  flex: none; width: 52px; height: 52px; border-radius: 10px; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font: 600 1.35rem/1 var(--serif); color: #fff; background: var(--accent);
}
.ricon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ricon.large { width: 96px; height: 96px; border-radius: 16px; font-size: 2.4rem; }
.ricon.c0 { background: #963c22; } .ricon.c1 { background: #5b6b3a; } .ricon.c2 { background: #3e5f78; }
.ricon.c3 { background: #8a5a2b; } .ricon.c4 { background: #6d4a6b; } .ricon.c5 { background: #2f6a62; }

/* ---------- Home: search & lists ---------- */

.hero { margin-bottom: 1.5rem; }
.hero p { margin: 0; color: var(--muted); }
.search-form { display: flex; gap: 0.5rem; margin: 1.25rem 0 0.75rem; }
.search-form input { font-size: 1.05rem; padding: 0.7rem 0.9rem; }

.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list li { border-bottom: 1px solid var(--line); }
.recipe-list li:last-child { border-bottom: none; }
.recipe-row { display: flex; gap: 0.9rem; align-items: center; padding: 0.7rem 0.25rem; text-decoration: none; color: inherit; }
.recipe-row:hover .rtitle { color: var(--accent); text-decoration: underline; }
.rtitle { font-size: 1.08rem; font-weight: 600; }
.rmeta { font: 400 0.8rem/1.4 var(--sans); color: var(--muted); }
.snippet { font: 400 0.85rem/1.4 var(--sans); color: var(--muted); margin-top: 0.15rem; }
.snippet mark { background: #f6e2a9; color: inherit; border-radius: 2px; padding: 0 1px; }

/* Two columns: the sidebar (categories, tags, then latest comments) on the left,
   recipes on the right. The recipes span both rows, so "Latest comments" sits
   directly under the sidebar. */
.home-grid {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr;
  gap: 0 2.5rem; align-items: start;
}
.home-grid .sidebar { grid-column: 1; grid-row: 1; }
.home-grid .results { grid-column: 2; grid-row: 1 / span 2; }
.home-grid .latest { grid-column: 1; grid-row: 2; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.results > .category-block:first-child h2 { margin-top: 0; }

.sidebar h2, .latest h2 {
  font: 600 0.75rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 0.6rem;
}
.sidebar nav + nav { margin-top: 1.75rem; }
.browse > summary { display: none; }   /* wide screens: always open, no "Browse" button */
.side-list { list-style: none; margin: 0; padding: 0; font: 400 0.92rem/1.3 var(--sans); }
.side-list a {
  display: flex; justify-content: space-between; gap: 0.5rem;
  padding: 0.3rem 0.5rem 0.3rem 0.6rem; margin-left: -0.6rem; border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--ink); text-decoration: none;
}
.side-list a:hover { color: var(--accent); background: var(--accent-soft); }
.side-list a[aria-current="page"] { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.side-list .n { color: var(--faint); font-size: 0.8rem; font-weight: 400; }
.side-list .empty { color: var(--muted); font-size: 0.85rem; }
.side-more { font: inherit; font-size: 0.85rem; color: var(--accent); background: none; border: 0; padding: 0.35rem 0; cursor: pointer; }
.side-more:hover { text-decoration: underline; }

.category-block h2 { display: flex; align-items: baseline; gap: 0.5rem; border-bottom: 2px solid var(--line); padding-bottom: 0.35rem; }
.category-block h2 .n { font: 400 0.8rem var(--sans); color: var(--faint); }

.feed { list-style: none; margin: 0; padding: 0; font-family: var(--sans); font-size: 0.85rem; }
.feed li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: none; }
.feed .quote { color: var(--ink); display: block; margin-top: 0.15rem; overflow-wrap: anywhere; }

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

.recipe-head { display: flex; gap: 1.25rem; align-items: flex-start; }
.recipe-head .titles { flex: 1; min-width: 0; }
.kicker { font: 600 0.75rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.45rem; }
.kicker a { text-decoration: none; }
.byline { font: 400 0.85rem/1.5 var(--sans); color: var(--muted); }
.description { font-size: 1.1rem; margin: 1rem 0 0; white-space: pre-wrap; }

.facts { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 1.25rem 0 0; padding: 0.85rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { font-family: var(--sans); }
.facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.facts dd { margin: 0; font-size: 0.95rem; }

/* Edit · History · Print · Show all comments · Delete, as one quiet line of links.
   Some are <button>s (they do something on the page) but look like links. */
.recipe-links { list-style: none; display: flex; flex-wrap: wrap; margin: 0.4rem 0 0; padding: 0; font: 400 0.85rem/1.7 var(--sans); }
.recipe-links li { white-space: nowrap; }
/* The dot goes AFTER each link (not before), so when the line wraps on a phone,
   the new line starts with a link rather than a stray dot. */
.recipe-links li:not(:last-child)::after { content: "·"; color: var(--faint); margin: 0 0.5rem; }
.recipe-links a, .recipe-links button {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none;
}
.recipe-links a:hover, .recipe-links button:hover { text-decoration: underline; }
.recipe-links .danger { color: var(--muted); }
.recipe-links .danger:hover { color: var(--danger); }
.tags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.6rem; }
.tag { font: 500 0.75rem/1 var(--sans); padding: 0.3rem 0.55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }

.recipe-body { display: grid; grid-template-columns: minmax(240px, 2fr) 3fr; gap: 2.5rem; margin-top: 0.5rem; }
.recipe-body h2 { display: flex; align-items: baseline; gap: 0.75rem; }

.items { list-style: none; margin: 0; padding: 0; }
.items > li { position: relative; }
.items .item-line { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.3rem 0; }
.items .item-text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.items.ingredients .item-line { border-bottom: 1px dotted var(--line); }
.items .heading-item { font: 600 0.8rem/1.3 var(--sans); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 1rem 0 0.25rem; }
.items .heading-item:first-child { padding-top: 0.25rem; }
.items.steps { counter-reset: none; }
.items.steps .item-line { padding: 0.55rem 0; }
.step-num {
  flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font: 600 0.85rem/1 var(--sans); margin-top: 0.1rem;
}

.cbtn {
  flex: none; display: inline-flex; align-items: center; gap: 0.25rem;
  font: 500 0.78rem/1 var(--sans); color: var(--faint);
  background: none; border: 1px solid transparent; border-radius: 999px; padding: 0.3rem 0.45rem; cursor: pointer;
  opacity: 0.55; transition: opacity 0.12s;
}
.cbtn svg { width: 15px; height: 15px; }
.item-line:hover .cbtn, .cbtn:focus-visible, .cbtn.has, .cbtn[aria-expanded="true"] { opacity: 1; }
.cbtn:hover { color: var(--accent); border-color: var(--line-strong); background: var(--card); }
.cbtn.has { color: var(--accent); background: var(--accent-soft); }
.cbtn[aria-expanded="true"] { border-color: var(--accent); background: var(--card); color: var(--accent); }

.thread {
  margin: 0.25rem 0 0.75rem 0; padding: 0.75rem 0.9rem; background: var(--card);
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.steps .thread { margin-left: 2.4rem; }

.notes-block { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.source-line { font-style: italic; color: var(--muted); margin-top: 1rem; }

/* ---------- Comments ---------- */

.comments { list-style: none; margin: 0; padding: 0; font-family: var(--sans); font-size: 0.9rem; }
.comment { padding: 0.55rem 0; }
.comment + .comment { border-top: 1px solid var(--line); }
.comment .who { font-weight: 600; }
.comment .when { color: var(--faint); font-size: 0.78rem; margin-left: 0.35rem; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0.15rem 0 0.2rem; line-height: 1.45; }
.comment .actions { display: flex; gap: 0.25rem; margin-left: -0.3rem; }
.comment .actions .btn.link { font-size: 0.78rem; color: var(--muted); }
.comment .actions .btn.link:hover { color: var(--accent); }
.comment .replies { list-style: none; margin: 0.35rem 0 0 1.1rem; padding: 0 0 0 0.85rem; border-left: 2px solid var(--line); }
.comment.flash { animation: flash 2s ease-out; }
@keyframes flash { from { background: #f6e2a9; } to { background: transparent; } }
.about { font-size: 0.78rem; color: var(--muted); background: var(--paper); border-radius: 4px; padding: 0.3rem 0.5rem; margin: 0.1rem 0 0.3rem; }
.comment-form { margin-top: 0.6rem; }
.comment-form textarea { font-size: 0.9rem; min-height: 2.4rem; }
.comment-form .row { margin-top: 0.4rem; }
.empty { color: var(--faint); font-family: var(--sans); font-size: 0.85rem; font-style: italic; }

.discussion { margin-top: 2.5rem; }
.discussion .card { padding: 1rem 1.25rem; }

/* ---------- Editor ---------- */

.editor-list { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.editor-row { display: flex; gap: 0.4rem; align-items: flex-start; padding: 0.3rem 0; }
.editor-row .num { flex: none; width: 1.8rem; text-align: right; font: 600 0.85rem/2.4rem var(--sans); color: var(--muted); }
.editor-row .grow { flex: 1; min-width: 0; }
.editor-row.heading input { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.85rem; background: var(--paper); }
.editor-row .tools { flex: none; display: flex; gap: 0.15rem; }
.icon-btn {
  width: 2.2rem; height: 2.4rem; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: none; border-radius: var(--radius); color: var(--muted); cursor: pointer; font: 600 1rem var(--sans);
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--accent); background: var(--card); }
.icon-btn[disabled] { opacity: 0.25; cursor: default; }
.icon-btn.del:hover { color: var(--danger); }
.ccount svg { width: 12px; height: 12px; }
.ccount { display: inline-flex; align-items: center; gap: 0.15rem; font: 500 0.72rem/1 var(--sans); color: var(--accent); background: var(--accent-soft); padding: 0.25rem 0.4rem; border-radius: 999px; align-self: center; }
.bulk textarea { min-height: 7rem; font-family: var(--sans); }
details.bulk summary { cursor: pointer; font: 500 0.88rem var(--sans); color: var(--accent); padding: 0.3rem 0; }
.photo-edit { display: flex; gap: 1rem; align-items: center; }
.sticky-actions {
  position: sticky; bottom: 0; background: linear-gradient(to bottom, rgba(248,244,236,0), var(--paper) 30%);
  padding: 1.25rem 0 1rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
}

/* ---------- History ---------- */

.versions { list-style: none; margin: 0; padding: 0; }
.version { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 0.75rem; }
.version-head { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; padding: 0.75rem 1rem; font-family: var(--sans); font-size: 0.9rem; }
.version-head .badge { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.2rem 0.45rem; border-radius: 4px; background: var(--ok-soft); color: var(--ok); }
.version-body { border-top: 1px solid var(--line); padding: 0.75rem 1rem 1rem; }
.diff { font: 400 0.85rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.diff li { white-space: pre-wrap; padding: 0 0.5rem; border-radius: 3px; }
.diff .add { background: var(--add); }
.diff .add::before { content: "+ "; color: var(--ok); }
.diff .del { background: var(--del); text-decoration: line-through; text-decoration-color: rgba(161, 40, 28, 0.4); }
.diff .del::before { content: "− "; color: var(--danger); }
.diff .same { color: var(--faint); }
.diff .same::before { content: "  "; }
.diff .gap { color: var(--faint); font-style: italic; }

/* ---------- Tables (admin) ---------- */

table.simple { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.9rem; }
table.simple th, table.simple td { text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line); }
table.simple th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.code-box { font: 600 1.4rem/1 ui-monospace, Consolas, monospace; letter-spacing: 0.05em; background: var(--paper); border: 1px dashed var(--line-strong); padding: 0.7rem 1rem; border-radius: var(--radius); display: inline-block; }

/* ---------- Small screens ---------- */

@media (max-width: 800px) {
  body { font-size: 17px; }
  h1 { font-size: 1.7rem; }
  .recipe-body { grid-template-columns: 1fr; gap: 0.5rem; }
  /* Phones: one column. The sidebar becomes a tap-to-open "Browse" panel above
     the recipes, and "Latest comments" moves below them. */
  .home-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 0; }
  .home-grid .sidebar, .home-grid .results, .home-grid .latest { grid-column: auto; grid-row: auto; }
  .browse { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; }
  .browse > summary { display: list-item; padding: 0.7rem 1rem; font: 600 0.95rem/1.3 var(--sans); cursor: pointer; color: var(--accent-ink); }
  .browse[open] > summary { border-bottom: 1px solid var(--line); }
  .browse nav { padding: 0.9rem 1rem 0.4rem; }
  .browse nav + nav { margin-top: 0; padding-top: 0.4rem; }
  .browse .side-list { columns: 2; column-gap: 1.25rem; }
  .browse .side-list li { break-inside: avoid; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .cbtn { opacity: 1; }
  .ricon.large { width: 72px; height: 72px; font-size: 1.8rem; }
}
@media (max-width: 520px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .site-header .inner { padding: 0.7rem 1rem; }
  main { padding: 1.25rem 1rem 3rem; }
  .editor-row { gap: 0.25rem; }
  .editor-row .num { display: none; }
  .editor-row .tools { gap: 0; }
  .editor-row .tools .icon-btn { width: 1.7rem; }
  .ccount { padding: 0.2rem 0.3rem; }
  .sticky-actions { padding-bottom: 0.75rem; }
}

/* ---------- Printing a recipe ---------- */

@media print {
  body { background: #fff; font-size: 12pt; }
  .site-header, .site-footer, .recipe-links, .cbtn, .thread, .discussion, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .recipe-body { grid-template-columns: 1fr 1.6fr; gap: 1.5rem; }
  .ricon { display: none; }
  a { color: inherit; text-decoration: none; }
  .notes-block { border: none; padding: 0; }
}
