/* ==========================================================================
   Vespiary — Shared Theme
   vespiary.css

   Source of truth for tokens and chrome: vespiary-front/front-v2.html
   (cream / sage palette, Georgia serif headings, system sans body).

   Usage:
     <link rel="stylesheet" href="/theme/vespiary.css">
   Or copy / symlink this file into an app and link to its local copy.
   Apps should NOT redefine these tokens locally — override only
   app-specific layout inside their own additional stylesheet, loaded after
   this one.

   Contents:
     1. Design tokens (light + dark)
     2. Base / reset / typography
     3. Layout wrapper
     4. Header / wordmark / main navigation / account area
     5. Hero
     6. Section headings
     7. Cards grid + card
     8. Panel
     9. Buttons
    10. Icons, hero / panel images
    11. Essay / article (long-form) typography
    12. Footer
    13. Utilities
    14. Responsive rules
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   Extracted verbatim from front-v2.html :root, plus two derived tokens
   that were hard-coded there (.icon background, focus colour).
   -------------------------------------------------------------------------- */
:root {
  --bg:         #f7f4ee;  /* warm cream page background */
  --ink:        #2a2620;  /* primary text */
  --muted:      #6e675c;  /* secondary text */
  --line:       #ddd5c7;  /* borders / dividers */
  --card:       #fffdf9;  /* card & panel surface */
  --accent:     #3f6b3a;  /* sage green — links, buttons */
  --accent-ink: #fff;     /* text on --accent */
  --icon-bg:    #e9efe2;  /* pale sage disc behind card icons (was hard-coded) */

  /* Derived / structural tokens (not in front-v2, kept consistent with it) */
  --radius:     18px;     /* card / panel radius in front-v2 */
  --radius-sm:  12px;     /* button radius in front-v2 */
  --wrap-max:   1020px;   /* .wrap max-width in front-v2 */
  --article-max: 40rem;   /* long-form reading measure */
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans:  system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Dark mode follows the OS setting, exactly as front-v2 did.
   No class toggle, no JavaScript. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #1b1a17;
    --ink:        #ece6da;
    --muted:      #a49c8e;
    --line:       #3a362f;
    --card:       #24221e;
    --accent:     #5c8f55;
    --accent-ink: #fff;
    --icon-bg:    #2e332a;
  }
}

/* --------------------------------------------------------------------------
   2. Base / reset / typography
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--font-sans);
}

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   3. Layout wrapper
   -------------------------------------------------------------------------- */
.wrap {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 0 16px 56px;
}

/* --------------------------------------------------------------------------
   4. Header / wordmark / main navigation / account area
   Markup contract (see header.php / header.html):
     <header class="top">
       <a class="wordmark" href="/">Vespiary</a>
       <nav class="main" aria-label="Main">…</nav>
       <div class="account">…</div>
     </header>
   -------------------------------------------------------------------------- */
header.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 18px;
  padding: 20px 0 6px;
}

.wordmark {
  font: 700 26px var(--font-serif);
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
}

nav.main {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 15.5px;
}
nav.main a {
  color: var(--ink);
  text-decoration: none;
}
nav.main a:hover {
  color: var(--accent);
  text-decoration: underline;
}
nav.main a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

.account {
  font-size: 15.5px;
  white-space: nowrap;
}
.account a {
  color: var(--ink);
  text-decoration: none;
}
.account a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.account .username { font-weight: 600; }

/* --------------------------------------------------------------------------
   5. Hero
   -------------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 44px 8px 10px;
}
.hero h1 {
  font: 700 40px/1.18 var(--font-serif);
  margin: 0 0 14px;
  letter-spacing: -.01em;
}
.hero p {
  max-width: 680px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 18.5px;
}
.heroimg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-top: 28px;
}

/* --------------------------------------------------------------------------
   6. Section headings
   -------------------------------------------------------------------------- */
h2.sec {
  font: 700 25px var(--font-serif);
  margin: 44px 0 6px;
}
.secsub {
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 720px;
}

/* --------------------------------------------------------------------------
   7. Cards grid + card
   -------------------------------------------------------------------------- */
.cards {
  display: grid;
  gap: 14px;
}
@media (min-width: 700px) {
  .cards { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.card h3 {
  font: 700 20px var(--font-serif);
  margin: 0 0 6px;
}
.card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15.5px;
}
.card p:last-child { margin-bottom: 0; }

/* Two-up "taken / doing" split used on the front page; generic grid utility */
.taken {
  display: grid;
  gap: 14px;
}
@media (min-width: 700px) {
  .taken { grid-template-columns: 1fr 1fr; }
}
.taken h3 {
  font: 700 18px var(--font-serif);
  margin: 0 0 6px;
}
.taken ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}
.taken ul li { margin-bottom: 4px; }

/* --------------------------------------------------------------------------
   8. Panel
   -------------------------------------------------------------------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-top: 14px;
}
.panel h3 {
  font: 700 20px var(--font-serif);
  margin: 0 0 6px;
}
.panel p { margin: 0 0 12px; }
.panel p:last-child { margin-bottom: 0; }
.panelimg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  font-size: 15.5px;
  cursor: pointer;
}
.btn:hover { text-decoration: underline; }

/* Secondary / outline variant — same geometry, no fill */
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* --------------------------------------------------------------------------
  10. Icons
   -------------------------------------------------------------------------- */
.icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--icon-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
  11. Essay / article typography — long-form reading
  Markup contract:
    <article class="article">
      <header class="article-head">
        <h1>…</h1>
        <p class="standfirst">…</p>
        <p class="byline">…</p>            <!-- optional -->
      </header>
      <p>…</p>
      <figure>
        <img src="…" alt="…">
        <figcaption>…</figcaption>
      </figure>
      <section class="endnotes">          <!-- optional -->
        <h2>Notes</h2>
        <ol><li id="note-1">…</li></ol>
      </section>
    </article>
  In-text note references: <sup class="note-ref"><a href="#note-1">1</a></sup>
   -------------------------------------------------------------------------- */
.article {
  max-width: var(--article-max);
  margin: 0 auto;
  font-size: 18px;
  line-height: 1.75;
}
.article-head { margin: 36px 0 28px; }
.article-head h1 {
  font: 700 36px/1.22 var(--font-serif);
  letter-spacing: -.01em;
  margin: 0 0 12px;
}
.article .standfirst {
  font-size: 20px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 12px;
}
.article .byline {
  font-size: 14.5px;
  color: var(--muted);
  margin: 0;
}
.article h2 {
  font: 700 25px/1.3 var(--font-serif);
  margin: 40px 0 10px;
}
.article h3 {
  font: 700 20px/1.35 var(--font-serif);
  margin: 32px 0 8px;
}
.article p { margin: 0 0 18px; }
.article ul,
.article ol { margin: 0 0 18px; padding-left: 26px; }
.article li { margin-bottom: 6px; }
.article blockquote {
  margin: 0 0 18px;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.article blockquote p:last-child { margin-bottom: 0; }
.article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 36px 0;
}
.article a { text-decoration: underline; }

/* Figures inside (and outside) articles */
.article figure,
figure.figure {
  margin: 28px 0;
}
.article figure img,
figure.figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.article figcaption,
figure.figure figcaption {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

/* Endnotes / footnotes */
.article .note-ref { font-size: .72em; line-height: 0; }
.article .note-ref a { text-decoration: none; }
.endnotes {
  margin-top: 44px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
}
.endnotes h2 {
  font: 700 19px var(--font-serif);
  color: var(--ink);
  margin: 0 0 10px;
}
.endnotes ol { margin: 0; padding-left: 22px; }
.endnotes li { margin-bottom: 8px; }
.endnotes li:target { color: var(--ink); }

/* Listen-along audio player in an essay header / panel */
.article audio { width: 100%; margin: 8px 0 18px; }

/* --------------------------------------------------------------------------
  12. Footer
  Markup contract (see footer.php / footer.html):
    <footer>
      <span>Vespiary — a village, rebuilt piece by piece.</span>
      <span class="foot-nav">…same links as nav.main…</span>
    </footer>
   -------------------------------------------------------------------------- */
footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: space-between;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }
footer .foot-nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* --------------------------------------------------------------------------
  13. Utilities
   -------------------------------------------------------------------------- */
.note {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin-top: 26px;
}
.muted { color: var(--muted); }

/* --------------------------------------------------------------------------
  14. Responsive rules
   -------------------------------------------------------------------------- */
@media (max-width: 620px) {
  .hero { padding-top: 32px; }
  .hero h1 { font-size: 31px; }
  .article-head h1 { font-size: 29px; }
  .article { font-size: 17px; }
  header.top { padding-top: 16px; }
  .panel { padding: 18px; }
  .card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
