/* ==========================================================================
   thestorybehindit.com — public theme
   Self-contained: no framework, no webfonts. Mobile-first, WCAG-minded,
   Core-Web-Vitals-friendly (single file, ~15 KB).
   ========================================================================== */

:root {
  --paper: #faf7f2;
  --surface: #ffffff;
  --ink: #23201c;
  --ink-soft: #55504a;
  --muted: #7a736b;
  --line: #e8e1d6;
  --brand: #c24f20;
  --brand-strong: #a03d13;
  --brand-tint: #fbeee6;
  --focus: #1d4ed8;
  --ok-bg: #eaf6ec;   --ok-ink: #1e5c2e;
  --err-bg: #fdecec;  --err-ink: #9b2222;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(35 32 28 / .06), 0 8px 24px -12px rgb(35 32 28 / .18);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", Times, serif;
  --shell: 1160px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--brand); text-decoration-thickness: from-font; text-underline-offset: .18em; }
a:hover { color: var(--brand-strong); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -100%;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--ink); color: #fff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: top .15s ease;
}
.skip-link:focus { top: 0; color: #fff; }

.shell {
  width: min(100% - 2.5rem, var(--shell));
  margin-inline: auto;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.brand img { width: 34px; height: 34px; flex: none; }
.brand-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.22rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.primary-nav ul {
  display: flex;
  gap: .25rem;
  list-style: none;
  margin: 0; padding: 0;
}
.primary-nav a {
  display: block;
  padding: .45rem .85rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
}
.primary-nav a:hover { background: var(--brand-tint); color: var(--brand-strong); }
.primary-nav a[aria-current="page"] { background: var(--brand); color: #fff; }

.header-search {
  display: flex;
  align-items: center;
  gap: .25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .15rem .25rem .15rem .9rem;
}
.header-search input {
  border: 0;
  background: transparent;
  font: inherit;
  /* >=16px so iOS Safari never zooms the viewport on focus */
  font-size: 1rem;
  width: 13.5rem;
  padding: .3rem 0;
  color: var(--ink);
}
.header-search input:focus { outline: none; }
.header-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.header-search button {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.header-search button:hover { background: var(--brand-strong); }

.nav-toggle {
  display: none;
  place-items: center;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle .icon-close { display: none; }

@media (max-width: 56.24em) {
  .nav-toggle { display: grid; }
  .header-bar { flex-wrap: wrap; }
  /* search gets its own full-width row above the menu — comfortable tap + typing space */
  .header-search {
    order: 5;
    flex-basis: 100%;
    padding: .4rem .5rem .4rem .95rem;
    margin-bottom: .25rem;
  }
  .header-search input { width: auto; flex: 1; min-width: 0; }
  .primary-nav {
    order: 6;
    flex-basis: 100%;
    display: none;
    border-top: 1px solid var(--line);
  }
  .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; padding: .5rem 0; gap: 0; }
  .primary-nav a { padding: .7rem .5rem; border-radius: var(--radius-sm); font-size: 1.05rem; }
  .nav-toggle[aria-expanded="true"] .icon-open { display: none; }
  .nav-toggle[aria-expanded="true"] .icon-close { display: block; }
}
@media (max-width: 30em) {
  .brand-name { font-size: 1.08rem; }
}

/* iOS zoom guard for every text input site-wide */
input[type="search"],
input[type="text"],
input[type="email"],
input[type="url"] { font-size: 1rem; }

/* ==========================================================================
   Page scaffolding & sections
   ========================================================================== */

.page-head { padding: clamp(2rem, 5vw, 3.25rem) 0 1.25rem; }
.page-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4.5vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 .5rem;
}
.page-head .lede {
  color: var(--ink-soft);
  font-size: 1.08rem;
  max-width: 62ch;
  margin: 0;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  letter-spacing: -.01em;
  margin: 2.25rem 0 1.1rem;
}

/* "Why we write this" — editorial statement under the homepage hero */
.editorial-note {
  margin: 0 0 1rem;
  padding: 1.5rem 1.75rem 1.35rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.editorial-note h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  letter-spacing: -.01em;
  margin: 0 0 .6rem;
  color: var(--ink);
}
.editorial-note p {
  margin: 0 0 .75rem;
  color: var(--ink-soft);
  line-height: 1.65;
}
.editorial-note p:last-child { margin-bottom: 0; }
.editorial-note a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  list-style: none;
  margin: 0; padding: 0;
  font-size: .86rem;
  color: var(--muted);
}
.breadcrumbs li + li::before { content: "/"; margin-right: .35rem; color: var(--line); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand); text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: var(--ink-soft); }

/* ==========================================================================
   Cards
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 1.4rem;
  padding-bottom: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgb(35 32 28 / .06), 0 16px 32px -12px rgb(35 32 28 / .22); }

.card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.card-image {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  background: var(--line);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  padding: 1.1rem 1.2rem 1.25rem;
  flex: 1;
}

.card-kicker {
  margin: 0;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--brand);
}

.card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.22rem;
  line-height: 1.3;
  letter-spacing: -.01em;
}

.card-excerpt {
  margin: 0;
  color: var(--ink-soft);
  font-size: .95rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: auto 0 0;
  padding-top: .6rem;
  font-size: .83rem;
  color: var(--muted);
}

/* Hero (featured post on home) */
.hero-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: block;
  color: #fff;
  text-decoration: none;
  background: var(--ink);
}
.hero-card img {
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  opacity: .82;
}
.hero-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: clamp(1.1rem, 3vw, 2.2rem);
  background: linear-gradient(to top, rgb(12 10 8 / .88) 20%, rgb(12 10 8 / 0));
}
.hero-kicker {
  margin: 0 0 .4rem;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #ffb894;
}
.hero-title {
  margin: 0 0 .4rem;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3.6vw, 2.4rem);
  line-height: 1.18;
  letter-spacing: -.02em;
}
.hero-meta {
  margin: 0;
  font-size: .88rem;
  color: rgb(255 255 255 / .85);
}
.hero-card:hover .hero-title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.cta-row { text-align: center; padding: .5rem 0 3rem; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.5rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-outline { border-color: var(--brand); color: var(--brand); background: transparent; }
.btn-outline:hover { background: var(--brand-tint); color: var(--brand-strong); }
.btn-sm { padding: .4rem 1rem; font-size: .87rem; }

/* ==========================================================================
   Article page
   ========================================================================== */

.article-wrap { padding: 1.75rem 0 2.5rem; }
.article {
  max-width: 720px;
  margin-inline: auto;
}

.article-kicker {
  margin: 1.1rem 0 .6rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.article-kicker a { text-decoration: none; }
.article-kicker a:hover { text-decoration: underline; }

.article h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 4.5vw, 2.7rem);
  line-height: 1.16;
  letter-spacing: -.02em;
  margin: 0 0 .9rem;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .9rem;
  color: var(--muted);
  font-size: .92rem;
  margin: 0 0 1.4rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--line);
}
.article-meta time { color: var(--ink-soft); }

.article-figure { margin: 0 0 1.75rem; }
.article-figure img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.article-figure figcaption {
  margin-top: .55rem;
  font-size: .84rem;
  color: var(--muted);
  text-align: center;
}

/* Featured-snippet "Quick answer" callout */
.quick-answer {
  margin: 0 0 2rem;
  padding: 1.25rem 1.4rem 1.1rem;
  background: var(--brand-tint);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
}
.quick-answer__label {
  display: block;
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: .5rem;
}
.quick-answer__a p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--ink-soft);
}

/* Editorial-integrity / corrections note */
.article-accuracy {
  margin: 2rem 0 0;
  padding: 1rem 1.25rem;
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  line-height: 1.6;
  color: var(--muted);
}
.article-accuracy p { margin: 0; }
.article-accuracy a { color: var(--brand); text-decoration: underline; }

/* Per-article Sources block. Sits between the body and the editorial
   note so the citation trail is visible before any trust claim. */
.article-sources {
  margin: 2.5rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.article-sources__heading {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  letter-spacing: .01em;
  margin: 0 0 .5rem;
  color: var(--ink);
}
.article-sources__intro {
  margin: 0 0 .75rem;
  font-size: .9rem;
  color: var(--muted);
}
.article-sources__list {
  margin: 0;
  padding-left: 1.35rem;
  font-size: .92rem;
  line-height: 1.6;
}
.article-sources__list li { margin-bottom: .45rem; }
.article-sources__list a { color: var(--brand); }
.article-sources__list a:hover { text-decoration: underline; }

/* Rich text editor content (legacy .fr-view class kept for stored posts) */
.fr-view {
  font-family: var(--font-serif);
  font-size: 1.13rem;
  line-height: 1.78;
  color: var(--ink);
}
.fr-view p { margin: 0 0 1.15rem; }
.fr-view h2, .fr-view h3, .fr-view h4 {
  font-family: var(--font-ui);
  letter-spacing: -.01em;
  line-height: 1.3;
  margin: 2rem 0 .8rem;
}
.fr-view h2 { font-size: 1.5rem; }
.fr-view h3 { font-size: 1.25rem; }
.fr-view img { border-radius: var(--radius-sm); margin: 1.25rem auto; }
.fr-view ul, .fr-view ol { padding-left: 1.5rem; margin: 0 0 1.15rem; }
.fr-view li { margin-bottom: .4rem; }
.fr-view blockquote {
  margin: 1.5rem 0;
  padding: .35rem 0 .35rem 1.25rem;
  border-left: 3px solid var(--brand);
  color: var(--ink-soft);
  font-style: italic;
}
.fr-view a { color: var(--brand); }
.fr-view strong { color: inherit; }

.share-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 2.25rem 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.share-label {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: .2rem;
}
.share-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s ease;
}
.share-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.related { padding-bottom: 3rem; }

/* ==========================================================================
   Lists, search, pagination
   ========================================================================== */

.post-list { display: grid; gap: 1.1rem; max-width: 720px; margin-inline: auto; padding-bottom: 2rem; }
.post-list .card { display: block; }
.post-list .card-link { flex-direction: row; align-items: stretch; gap: 0; height: auto; }
.post-list .card-image { width: 168px; aspect-ratio: 4 / 3; flex: none; align-self: center; margin-left: 1rem; }
.post-list .card-body { padding: 1rem 1.1rem; }
@media (max-width: 34em) {
  .post-list .card-link { flex-direction: column; }
  .post-list .card-image { width: 100%; aspect-ratio: 16 / 7; margin: 0; }
}

.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  padding: 0 0 3rem;
  list-style: none;
  margin: 0;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px; height: 40px;
  padding: 0 .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .93rem;
  text-decoration: none;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .active span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pagination .disabled span { opacity: .45; }

.pagination-wrap { padding-bottom: 3rem; }
.pagination-wrap .pagination { padding-bottom: 0; }
.pagination-count {
  margin: 0 0 1rem;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}

/* Editorial team block on the About page */
.team {
  margin: 1.4rem 0 1.8rem;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.team__member + .team__member { margin-top: 1rem; }
.team__name { margin: 0; font-weight: 600; color: var(--ink); }
.team__role { margin: .15rem 0 .5rem; font-size: .9rem; color: var(--brand); }
.team__bio { margin: 0 0 .5rem; }
.team__links { margin: 0; font-size: .9rem; }
.team__links a { margin-right: .75rem; }
.team__note { margin: 1rem 0 0; font-size: .93rem; color: var(--muted); }

.empty-state {
  max-width: 60ch;
  margin-inline: auto;
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--ink-soft);
}
.empty-state h2 { font-family: var(--font-serif); color: var(--ink); }

.search-retry {
  display: flex;
  gap: .6rem;
  max-width: 720px;
  margin: 0 auto 3rem;
}
.search-retry input[type=search] {
  flex: 1;
  min-width: 0;
  padding: .55rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
}

/* ==========================================================================
   Static pages (about / contact / policies)
   ========================================================================== */

.static-page {
  max-width: 720px;
  margin-inline: auto;
  padding: 2.5rem 0 3.5rem;
}
.static-page h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  letter-spacing: -.02em;
  margin: 0 0 1.25rem;
}
.static-page .prose { font-size: 1.03rem; color: var(--ink-soft); }
.static-page .prose p { margin: 0 0 1rem; }
.static-page .prose h2 {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  color: var(--ink);
  margin: 1.75rem 0 .5rem;
}
.static-page .contact-card {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ==========================================================================
   Flash messages
   ========================================================================== */

.flash-stack {
  position: fixed;
  top: .9rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: .5rem;
  width: min(94%, 480px);
}
.flash {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .93rem;
  animation: flash-in .25s ease;
}
.flash-success { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid #bfe3c8; }
.flash-error { background: var(--err-bg); color: var(--err-ink); border: 1px solid #f2c4c4; }
.flash-close {
  border: 0; background: none;
  font-size: 1.2rem; line-height: 1;
  color: inherit; cursor: pointer;
  padding: 0 .1rem;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Cookie banner
   ========================================================================== */

.cookie-banner {
  position: fixed;
  inset: auto 1rem 1rem 1rem;
  z-index: 80;
  margin-inline: auto;
  max-width: 620px;
  padding: 1rem 1.25rem;
  /* always a dark toast, in both themes — never inherits --ink (flips cream in dark mode) */
  background: #211c16;
  color: #efeae3;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px -8px rgb(0 0 0 / .45);
}
.cookie-banner p { margin: 0 0 .8rem; font-size: .9rem; }
.cookie-banner a { color: #ffb894; }
.cookie-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.cookie-actions .btn-primary { background: var(--brand); }
.cookie-actions .btn-outline { border-color: rgb(255 255 255 / .4); color: #efeae3; }
.cookie-actions .btn-outline:hover { background: rgb(255 255 255 / .12); color: #fff; }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  margin-top: 2rem;
  background: #201d19;
  color: #b9b2a8;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  padding: 2.75rem 0 2.25rem;
}
@media (max-width: 62em) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.75rem; }
}
@media (max-width: 46em) {
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
}
.site-footer .brand { color: #f3efe8; margin-bottom: .6rem; }
.site-footer .brand-name { font-size: 1.1rem; }
.footer-brand p { margin: 0; font-size: .92rem; max-width: 44ch; }
.footer-col h2 {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8f8880;
  margin: .3rem 0 .75rem;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.footer-col a { color: #cdc6bc; text-decoration: none; font-size: .94rem; }
.footer-col a:hover { color: #fff; text-decoration: underline; }
.footer-bottom {
  border-top: 1px solid rgb(255 255 255 / .09);
  padding: 1.1rem 0;
  font-size: .85rem;
}
.footer-bottom p { margin: 0; }

/* ==========================================================================
   Curiosity hub (home) — sticker tiles, one per category
   ========================================================================== */

.curiosity-hub { margin-top: 2.4rem; }

.curio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: .9rem;
  padding-bottom: 2.2rem;
}

.curio-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: 1.15rem .8rem .95rem;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgb(35 32 28 / .08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.curio-tile:nth-child(4n+1) { transform: rotate(-1.4deg); }
.curio-tile:nth-child(4n+2) { transform: rotate(1deg); }
.curio-tile:nth-child(4n+3) { transform: rotate(-.6deg); }
.curio-tile:nth-child(4n)   { transform: rotate(1.5deg); }
.curio-tile:hover {
  transform: rotate(0deg) translateY(-5px) scale(1.03);
  box-shadow: 0 4px 10px rgb(35 32 28 / .08), 0 18px 34px -14px rgb(35 32 28 / .25);
  color: inherit;
}

/* one soft pastel per topic */
.curio-tile--human-body          { background: #fdeaea; }
.curio-tile--animals-and-plants  { background: #e9f6ec; }
.curio-tile--earth-and-space     { background: #e7effb; }
.curio-tile--history-and-origins { background: #fbf3da; }
.curio-tile--things-around-us    { background: #f1eafc; }
.curio-tile--music               { background: #fdebf4; }
.curio-tile--festivals           { background: #fff0e3; }
.curio-tile--general             { background: #edf3f3; }

.curio-emoji { font-size: 1.9rem; line-height: 1; }

.curio-name {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -.01em;
}

.curio-tag {
  font-size: .8rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.curio-count {
  margin-top: .35rem;
  padding: .16rem .6rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
}

@media (max-width: 480px) {
  .curio-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .curio-tile { padding: .95rem .6rem .85rem; }
}

/* ==========================================================================
   Ad containers (reserved space prevents layout shift — good for CLS)
   ========================================================================== */

.ad-slot {
  min-height: 110px;
  margin: 1.75rem auto;
  max-width: 728px;
  padding: 0 .25rem;
  text-align: center;
}

.ad-slot__label {
  display: block;
  margin-bottom: .35rem;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.ad-slot__unit { overflow: hidden; }

@media (max-width: 640px) {
  .ad-slot { margin: 1.4rem auto; }
}

/* ==========================================================================
   Reading progress (article pages)
   ========================================================================== */

.read-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 90;
  background: transparent;
  pointer-events: none;
}
.read-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ==========================================================================
   Sticky article header (title + reading progress)
   ========================================================================== */

.read-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .55rem .9rem;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transform: translateY(-110%);
  transition: transform .22s ease, visibility 0s linear .22s;
  visibility: hidden;
}
.read-bar.is-visible {
  transform: translateY(0);
  visibility: visible;
  transition: transform .22s ease;
}
.read-bar__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.read-bar .read-progress {
  position: static;
  flex: 0 0 90px;
  height: 3px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

/* ==========================================================================
   Previous / next story navigation
   ========================================================================== */

.pn-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
  margin: 2.2rem 0 2.6rem;
}
.pn {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .95rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.pn:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: var(--shadow);
}
.pn strong {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: .98rem;
  line-height: 1.35;
  letter-spacing: -.01em;
}
.pn-dir {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pn-next { text-align: right; }
@media (max-width: 560px) {
  .pn-nav { grid-template-columns: 1fr; }
  .pn-next { text-align: left; }
}

/* ==========================================================================
   Header actions — theme toggle
   ========================================================================== */

.header-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.theme-toggle:hover {
  background: var(--brand-tint);
  transform: rotate(-8deg) scale(1.06);
}
.theme-toggle svg { width: 18px; height: 18px; stroke: var(--ink-soft); }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ==========================================================================
   Search suggestions dropdown
   ========================================================================== */

.header-search { position: relative; }

.suggest-box {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 70;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px -10px rgb(35 32 28 / .35);
  overflow: hidden;
}
.suggest-box a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .8rem;
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  border-bottom: 1px solid var(--line);
}
.suggest-box a:last-child { border-bottom: 0; }
.suggest-box a:hover,
.suggest-box a.is-active { background: var(--brand-tint); color: var(--ink); }
.suggest-thumb {
  width: 58px; height: 34px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--line);
  flex-shrink: 0;
}
.suggest-box .suggest-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest-box .suggest-all {
  font-size: .8rem;
  font-weight: 700;
  color: var(--brand);
}

/* ==========================================================================
   Search page — focused search hero
   ========================================================================== */

.search-hero {
  max-width: 620px;
  margin: clamp(1.5rem, 4vw, 2.75rem) auto 0;
  text-align: center;
}
.search-hero h1 { margin-bottom: 1.1rem; }
.search-hero form {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .35rem .35rem 1.15rem;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 999px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search-hero form:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-tint);
}
.search-hero input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 1.08rem;
  padding: .55rem 0;
  color: var(--ink);
}
.search-hero input:focus { outline: none; }
.search-hero button {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.search-hero button:hover { background: var(--brand-strong); }
.search-hero .chip-row { justify-content: center; margin-top: 1.1rem; }
.results-count { color: var(--muted); font-size: .92rem; margin: 0 0 1.2rem; }

/* ==========================================================================
   Empty-search chips + 404
   ========================================================================== */

.empty-lede { margin: 0 0 .7rem; color: var(--ink-soft); }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 2rem; }
.chip {
  padding: .48rem 1.05rem; /* ~40px tall for comfortable touch targets */
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  transition: all .15s ease;
}
.chip:hover {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.error-hero .error-code {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(4.5rem, 14vw, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
  color: var(--line);
}

/* ==========================================================================
   Micro-delight
   ========================================================================== */

::selection { background: var(--brand); color: #fff; }

@keyframes curio-wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-9deg) scale(1.12); }
  65% { transform: rotate(7deg) scale(1.08); }
}
.curio-tile:hover .curio-emoji { animation: curio-wiggle .45s ease; }

@keyframes card-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-grid > .card { animation: card-rise .35s ease both; }
.card-grid > .card:nth-child(2) { animation-delay: .05s; }
.card-grid > .card:nth-child(3) { animation-delay: .1s; }
.card-grid > .card:nth-child(4) { animation-delay: .15s; }

/* ==========================================================================
   Dark mode — honours system preference + manual toggle (data-theme)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171310;
    --surface: #211c16;
    --ink: #ede7dc;
    --ink-soft: #c7bfb2;
    --muted: #978e81;
    --line: #372f27;
    --brand: #e8763f;
    --brand-strong: #f28b5a;
    --brand-tint: #33200f;
    --focus: #7aa7ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 28px -12px rgb(0 0 0 / .55);
  }
}
:root[data-theme="dark"] {
  --paper: #171310;
  --surface: #211c16;
  --ink: #ede7dc;
  --ink-soft: #c7bfb2;
  --muted: #978e81;
  --line: #372f27;
  --brand: #e8763f;
  --brand-strong: #f28b5a;
  --brand-tint: #33200f;
  --focus: #7aa7ff;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 28px -12px rgb(0 0 0 / .55);
}

/* deep-tinted curiosity tiles for dark surfaces.
   Two scopes: (1) system prefers dark AND user hasn't forced light,
   (2) user explicitly toggled dark. Never apply to plain light mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .curio-tile--human-body { background: #38221f; }
  :root:not([data-theme="light"]) .curio-tile--animals-and-plants { background: #1f3023; }
  :root:not([data-theme="light"]) .curio-tile--earth-and-space { background: #1e2735; }
  :root:not([data-theme="light"]) .curio-tile--history-and-origins { background: #342b18; }
  :root:not([data-theme="light"]) .curio-tile--things-around-us { background: #291f38; }
  :root:not([data-theme="light"]) .curio-tile--music { background: #351f2c; }
  :root:not([data-theme="light"]) .curio-tile--festivals { background: #362517; }
  :root:not([data-theme="light"]) .curio-tile--general { background: #212a2c; }
}
:root[data-theme="dark"] .curio-tile--human-body { background: #38221f; }
:root[data-theme="dark"] .curio-tile--animals-and-plants { background: #1f3023; }
:root[data-theme="dark"] .curio-tile--earth-and-space { background: #1e2735; }
:root[data-theme="dark"] .curio-tile--history-and-origins { background: #342b18; }
:root[data-theme="dark"] .curio-tile--things-around-us { background: #291f38; }
:root[data-theme="dark"] .curio-tile--music { background: #351f2c; }
:root[data-theme="dark"] .curio-tile--festivals { background: #362517; }
:root[data-theme="dark"] .curio-tile--general { background: #212a2c; }

/* hero card mat: light mode uses a dark vignette; dark mode needs a dark mat, not cream */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-card { background: #241e17; }
}
:root[data-theme="dark"] .hero-card { background: #241e17; }

/* elements painted "inverse" in light mode must stay legible when inverted */
.skip-link { color: var(--paper); }
.primary-nav a[aria-current="page"] { color: var(--paper); }
.curio-count { color: var(--paper); }

