/* Celiac Chat — hand-rolled stylesheet, no frameworks, no JS. */

:root {
  --ink: #2b2b2b;
  --muted: #6b6b6b;
  --accent: #7a4a2b;      /* warm brown */
  --accent-hover: #5c3720;
  --paper: #fffdf9;
  --card: #ffffff;
  --line: #e7dfd4;
  --shadow: rgba(0, 0, 0, 0.12);
  --maxw: 46rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e4de;
    --muted: #a49d92;
    --accent: #d89c68;
    --accent-hover: #e8b586;
    --paper: #1c1a17;
    --card: #262320;
    --line: #3a352e;
    --shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
  .post-body img, .card img { filter: brightness(0.92); }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 1.05rem/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
}

h1, h2, h3, .site-title { font-family: Georgia, "Times New Roman", serif; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

/* Header / nav */
.site-header {
  text-align: center;
  padding: 1.6rem 1rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.site-title { font-size: 2.2rem; margin: 0; }
.site-title a { color: var(--ink); text-decoration: none; }
.site-tagline { color: var(--muted); margin: 0.2rem 0 0.9rem; font-style: italic; }

.site-nav {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.4rem;
  flex-wrap: wrap;
}
.site-nav > a, .nav-dropdown summary {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.site-nav > a:hover { color: var(--accent); }

.nav-dropdown { position: relative; }
.nav-dropdown summary { cursor: pointer; list-style: none; }
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: " \25BE"; font-size: 0.8em; }
.nav-dropdown[open] > ul {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  margin: 0.4rem 0 0;
  padding: 0.5rem 0;
  list-style: none;
  min-width: 14rem;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 18px var(--shadow);
  text-align: left;
}
.nav-dropdown ul a {
  display: block;
  padding: 0.3rem 1rem;
  text-decoration: none;
  color: var(--ink);
}
.nav-dropdown ul a:hover { background: var(--paper); color: var(--accent); }
.nav-subhead {
  padding: 0.5rem 1rem 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-top: 1px solid var(--line);
  margin-top: 0.4rem;
}

/* Main column */
main { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* Post */
.draft-banner {
  background: #b3261e;
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
}
.post h1 { font-size: 1.9rem; line-height: 1.25; margin-bottom: 0.3rem; }
.post-meta { color: var(--muted); font-size: 0.92rem; margin-top: 0; }
.post-meta a { color: var(--muted); }
.post-body figcaption { color: var(--muted); font-size: 0.9rem; text-align: center; }
/* Markdown photo captions: an italic line right under an image
   (matches both "same paragraph" and "own paragraph" renderings) */
.post-body p:has(> img) > em,
.post-body p:has(> img:only-child) + p:has(> em:only-child) {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* List / cards */
.list-heading { font-size: 1.6rem; }
.card-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1.4rem;
}
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  display: flex;
  flex-direction: column;
}
.card > a { text-decoration: none; color: inherit; }
.card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.card h2, .card h3 { font-size: 1.12rem; line-height: 1.3; margin: 0.7rem 0.9rem 0.2rem; font-weight: 600; }
.card > a:hover h2, .card > a:hover h3 { color: var(--accent); }
.card-date { color: var(--muted); font-size: 0.85rem; margin: 0 0.9rem 0.9rem; }

/* Instagram icon in nav */
.ig-link { display: inline-flex; align-self: center; color: var(--ink); }
.ig-link:hover { color: var(--accent); }
.ig-link svg { vertical-align: -0.2em; }

/* Nav search */
.nav-search { position: relative; margin: 0; }
.nav-search input {
  font: inherit;
  /* never below 16px: iOS Safari auto-zooms the page when focusing a
     smaller input, which hides the results dropdown */
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  width: 9rem;
  transition: width 0.15s ease;
}
.nav-search input:focus { width: 14rem; outline: 2px solid var(--accent); }
#search-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 20;
  width: 22rem;
  max-width: 88vw;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px var(--shadow);
  text-align: left;
}
@media (max-width: 640px) {
  /* On phones the wrapped nav can put the search box far left; anchoring
     the panel to it runs off-screen. Span the viewport width instead
     (top: auto keeps it vertically just below the box). */
  #search-dropdown {
    position: fixed;
    top: auto;
    left: 0.8rem;
    right: 0.8rem;
    width: auto;
    max-width: none;
  }
}
.search-hits { list-style: none; margin: 0; padding: 0.4rem 0; }
.search-hits li { padding: 0.35rem 1rem; }
.search-hits a { text-decoration: none; color: var(--ink); display: block; }
.search-hits li:hover { background: var(--paper); }
.search-hits li:hover a { color: var(--accent); }
.search-date { color: var(--muted); font-size: 0.8rem; }
.search-empty { color: var(--muted); padding: 0.6rem 1rem; margin: 0; }
.search-hint { color: var(--muted); }
#search-page-results .search-hits li { padding: 0.45rem 0; }
#search-page-results .search-hits a { display: inline; margin-right: 0.6rem; }

/* Wider grid pages get a wider column (direct children only, so the
   related-posts grid inside a post doesn't widen the reading column) */
main:has(> .card-grid), main:has(> .archive-year) { max-width: 62rem; }

/* Related posts under an article */
.related {
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
}
.related h2 { font-size: 1.3rem; }
.related-grid { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
.related-grid .card h3 { font-size: 0.98rem; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin-top: 2rem;
  color: var(--muted);
}
.pagination a { text-decoration: none; font-weight: 600; }

/* Archive */
.archive-year h2 {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.2rem;
}
.archive-list { list-style: none; padding: 0; }
.archive-list li { margin: 0.35rem 0; }
.archive-list time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.8rem;
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1.2rem 1rem 2rem;
}
.site-footer a { color: var(--muted); }
