/* ============================================================
   The Chester / Vestal Cookbook — design system
   The page is a hand-typed photocopy. The wallpaper strip is the
   only ornament. Type does the rest of the work.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
  --paper:        #FAF6EC;
  --paper-edge:   #F0E9D6;
  --ochre:        #99743C;
  --ochre-deep:   #816D42;
  --forest:       #334837;
  --forest-soft:  #516655;
  --sage:         #7E8D75;
  --terracotta:   #8A5746;
  --thistle:      #B5466B;
  --ink:          #2A2620;
  --ink-soft:     #5C544A;
  --rule:         #D9CFB8;
  --type-display: 'Special Elite', 'Courier Prime', ui-monospace, Menlo, monospace;
  --type-body:    'Lora', Georgia, 'Iowan Old Style', serif;
  --measure: 38rem;
  --pad-x:   1.5rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--type-body);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wallpaper {
  height: 22px;
  background-image: url('/images/wallpaper-strip.jpg');
  background-repeat: repeat-x;
  background-size: auto 22px;
  background-position: center;
}

.page { max-width: var(--measure); margin: 0 auto; padding: 0 var(--pad-x); }
.page--wide { max-width: 52rem; }

.site-header { padding: 2.6rem 0 1.6rem; text-align: center; }
.site-header h1 { font-family: var(--type-display); font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 400; letter-spacing: 0.02em; margin: 0; color: var(--ink); }
.site-header h1 a { color: inherit; text-decoration: none; }
.site-header h1 a:hover { color: var(--ochre); }
.site-header .subtitle { font-family: var(--type-display); font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.4rem; letter-spacing: 0.04em; }

.top-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 1.5rem; padding: 0.6rem 0 1.4rem; border-bottom: 1px solid var(--rule); font-family: var(--type-display); font-size: 0.82rem; }
.top-nav a { color: var(--ink-soft); text-decoration: none; letter-spacing: 0.04em; }
.top-nav a:hover, .top-nav a.active { color: var(--ochre); }

h1, h2, h3, h4 { font-family: var(--type-display); color: var(--ink); font-weight: 400; letter-spacing: 0.01em; margin: 2.4rem 0 0.8rem; }
h1 { font-size: 1.8rem; line-height: 1.2; }
h2 { font-size: 1.25rem; color: var(--ochre-deep); }
h3 { font-size: 1.05rem; color: var(--forest); }

p { margin: 0.7rem 0; }
.lede { font-size: 1.1rem; color: var(--ink-soft); font-style: italic; }
a { color: var(--ochre); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--terracotta); }

.random-button { display: inline-block; margin: 0.4rem 0 1.4rem; padding: 0.7rem 1.4rem; font-family: var(--type-display); font-size: 0.95rem; letter-spacing: 0.03em; background: var(--paper); color: var(--thistle); border: 1.5px solid var(--thistle); border-radius: 0; text-decoration: none; cursor: pointer; transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease; }
.random-button:hover { background: var(--thistle); color: var(--paper); transform: rotate(-0.6deg); }
.random-button .arrow { display: inline-block; margin-left: 0.4rem; }

.toc { margin: 2rem 0 3rem; padding-top: 0.8rem; border-top: 1px solid var(--rule); }
.toc h2 { text-align: center; margin-top: 1.4rem; font-size: 1.1rem; letter-spacing: 0.1em; color: var(--ink); }
.toc-section { margin: 2rem 0; }
.toc-section-head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.4rem; border-bottom: 1px dashed var(--rule); padding-bottom: 0.3rem; }
.toc-section-head h3 { font-family: var(--type-display); margin: 0; font-size: 1rem; color: var(--forest); letter-spacing: 0.04em; text-transform: uppercase; }
.toc-section-head .count { font-family: var(--type-display); font-size: 0.78rem; color: var(--ink-soft); margin-left: auto; }
.toc-list { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 2rem; break-inside: avoid; }
.toc-list li { margin: 0.18rem 0; font-size: 0.96rem; break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid; }
.toc-list a { color: var(--ink); text-decoration: none; }
.toc-list a:hover { color: var(--ochre); text-decoration: underline; text-decoration-style: dotted; }
@media (max-width: 540px) { .toc-list { columns: 1; } }

.browse-bar { margin: 3rem 0 2rem; padding: 1.4rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.browse-bar h2 { text-align: center; margin: 0 0 1.2rem; font-size: 1rem; letter-spacing: 0.1em; color: var(--ink); text-transform: uppercase; }
.browse-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
@media (max-width: 640px) { .browse-grid { grid-template-columns: 1fr; } }
.browse-card { display: block; padding: 1rem; background: var(--paper-edge); border: 1px solid var(--rule); text-decoration: none; color: var(--ink); transition: background 0.18s ease, border-color 0.18s ease; }
.browse-card:hover { background: var(--paper); border-color: var(--ochre); }
.browse-card .label { font-family: var(--type-display); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ochre-deep); }
.browse-card .head { font-family: var(--type-display); font-size: 1.05rem; margin: 0.3rem 0 0.6rem; }
.browse-card .preview { font-size: 0.85rem; color: var(--ink-soft); font-style: italic; }

.recipe-page .breadcrumb { font-family: var(--type-display); font-size: 0.8rem; color: var(--ink-soft); letter-spacing: 0.04em; margin: 1.6rem 0 0.6rem; }
.recipe-page .breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.recipe-page .breadcrumb a:hover { color: var(--ochre); }
.recipe-page .breadcrumb .sep { margin: 0 0.4rem; opacity: 0.5; }

.recipe-title { font-family: var(--type-display); font-size: 2rem; line-height: 1.15; margin: 0.6rem 0 1.4rem; color: var(--ink); }

.recipe-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-family: var(--type-display); font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0.04em; margin-bottom: 1.6rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--rule); }
.recipe-meta .tag { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; color: var(--ochre-deep); }
.recipe-meta a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--rule); }
.recipe-meta a:hover { color: var(--ochre); border-bottom-color: var(--ochre); }

.recipe-story { font-family: var(--type-body); font-style: italic; color: var(--ink-soft); font-size: 1.05rem; white-space: pre-line; margin: 1.4rem 0 2rem; padding-left: 1rem; border-left: 2px solid var(--ochre); }

.recipe-section-head { font-family: var(--type-display); font-size: 0.88rem; letter-spacing: 0.12em; color: var(--forest); text-transform: uppercase; margin: 2rem 0 0.6rem; }

.recipe-ingredients, .recipe-instructions { white-space: pre-line; font-size: 1.02rem; line-height: 1.7; }
.recipe-ingredients { margin: 0.4rem 0 1.6rem; }
.recipe-instructions { margin: 0.4rem 0 2.4rem; }

.recipe-actions { display: flex; gap: 1.2rem; flex-wrap: wrap; margin: 2rem 0 1rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-family: var(--type-display); font-size: 0.82rem; }
.recipe-actions button, .recipe-actions a { background: none; border: none; padding: 0; font: inherit; color: var(--ink-soft); cursor: pointer; text-decoration: none; letter-spacing: 0.04em; }
.recipe-actions button:hover, .recipe-actions a:hover { color: var(--ochre); }
.recipe-actions .saved { color: var(--thistle); }

.provenance { margin: 2.4rem 0 4rem; padding: 1.2rem; background: var(--paper-edge); border-left: 3px solid var(--ochre); font-size: 0.86rem; color: var(--ink-soft); font-style: italic; }
.provenance .stamp { font-family: var(--type-display); font-style: normal; font-size: 0.74rem; letter-spacing: 0.1em; color: var(--ochre-deep); text-transform: uppercase; display: block; margin-bottom: 0.4rem; }

.site-footer { margin-top: 4rem; padding: 2rem 0 3rem; border-top: 1px solid var(--rule); text-align: center; font-family: var(--type-display); font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--ochre); }
.site-footer .stamp { display: inline-block; margin-top: 0.6rem; padding: 0.2rem 0.6rem; border: 1px solid var(--rule); font-size: 0.72rem; letter-spacing: 0.08em; color: var(--ochre-deep); }

.browse-section { margin: 2.4rem 0; }
.browse-section h2 { font-family: var(--type-display); font-size: 1.05rem; letter-spacing: 0.06em; color: var(--ochre-deep); text-transform: uppercase; margin: 0 0 0.4rem; padding-bottom: 0.4rem; border-bottom: 1px dashed var(--rule); display: flex; align-items: baseline; gap: 0.6rem; }
.browse-section h2 .count { margin-left: auto; font-size: 0.78rem; color: var(--ink-soft); }
.browse-section ul { list-style: none; padding: 0; margin: 0.6rem 0 0; columns: 2; column-gap: 2rem; }
.browse-section ul li { margin: 0.18rem 0; break-inside: avoid; }
.browse-section ul a { color: var(--ink); text-decoration: none; }
.browse-section ul a:hover { color: var(--ochre); text-decoration: underline; text-decoration-style: dotted; }
@media (max-width: 540px) { .browse-section ul { columns: 1; } }

.search-trigger { position: fixed; top: 1.2rem; right: 1.2rem; z-index: 10; background: var(--paper); border: 1px solid var(--rule); font-family: var(--type-display); font-size: 0.78rem; letter-spacing: 0.06em; padding: 0.4rem 0.7rem; cursor: pointer; color: var(--ink-soft); }
.search-trigger:hover { color: var(--ochre); border-color: var(--ochre); }
dialog.search { border: 1px solid var(--rule); background: var(--paper); padding: 1.6rem; width: min(38rem, 92vw); max-height: 80vh; overflow-y: auto; font-family: var(--type-body); color: var(--ink); }
dialog.search::backdrop { background: rgba(42,38,32,0.45); }
dialog.search input { font-family: var(--type-display); font-size: 1.1rem; width: 100%; border: none; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink); padding: 0.4rem 0; outline: none; }
dialog.search input:focus { border-bottom-color: var(--ochre); }
dialog.search .results { margin-top: 1rem; }
dialog.search .results .row { padding: 0.5rem 0; border-bottom: 1px dashed var(--rule); }
dialog.search .results .row a { color: var(--ink); text-decoration: none; display: block; }
dialog.search .results .row .title { font-family: var(--type-display); }
dialog.search .results .row .preview { font-size: 0.86rem; color: var(--ink-soft); font-style: italic; margin-top: 0.2rem; }
dialog.search .empty { color: var(--ink-soft); font-style: italic; text-align: center; padding: 1.4rem 0; }

.edition-card { padding: 1.4rem; border: 1px solid var(--rule); background: var(--paper-edge); margin: 1rem 0; }
.edition-card.canonical { border-color: var(--ochre); background: var(--paper); border-left: 4px solid var(--ochre); }
.edition-card .stamp { font-family: var(--type-display); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ochre-deep); }
.edition-card h3 { font-family: var(--type-display); margin: 0.4rem 0 0.6rem; font-size: 1.3rem; color: var(--ink); }
.edition-card .meta { font-family: var(--type-display); font-size: 0.8rem; color: var(--ink-soft); letter-spacing: 0.03em; }
.edition-card .desc { margin-top: 0.6rem; font-size: 0.96rem; }
.edition-card.empty { border-style: dashed; text-align: center; font-style: italic; color: var(--ink-soft); }

@media print {
  .top-nav, .recipe-actions, .site-footer .stamp, .browse-bar, .search-trigger, .random-button { display: none; }
  body { background: white; color: black; font-size: 11pt; }
  .page { max-width: 100%; }
  .recipe-page .recipe-title { font-size: 1.6rem; }
  .recipe-story { color: #333; border-left-color: #888; }
  .provenance { background: #f4f4f4; }
  .wallpaper { display: block; height: 14px; }
  a { color: black; text-decoration: none; }
  @page { margin: 0.6in; }
}

.saved-list { list-style: none; padding: 0; margin: 1.4rem 0; }
.saved-list li { padding: 0.6rem 0; border-bottom: 1px dashed var(--rule); }
.saved-list .empty { font-style: italic; color: var(--ink-soft); }

.marginalia {
  font-family: var(--type-display);
  font-size: 0.74rem;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
}

/* Empty-state hiding for collection-rendered fields.
   Plinth's template doesn't have {{#if}}; we hide elements
   whose content is empty after rendering. */
.recipe-meta .tag-people:has(:only-child),
.recipe-meta .tag-occasions:only-child,
.recipe-meta .tag-origins:only-child { display: none; }
.recipe-meta .tag:empty,
.recipe-meta .tag[data-empty="true"] { display: none; }
.recipe-story:empty { display: none; }
.provenance-change:empty { display: none; }
.provenance-modified { display: none; }
.provenance[data-origin="modified"] .provenance-modified,
.provenance[data-origin="new"] .provenance-modified { display: block; }

/* Tag-rendering: if tag_people/occasions/origins is empty,
   the rendered text becomes 'people: ' (just label + empty). JS hides those. */
