/* ==========================================================================
   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: rgb(255 255 255 / .92);
  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;
  font-size: .92rem;
  width: 11ch;
  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; }
  .primary-nav {
    order: 5;
    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) {
  .header-search input { width: 8ch; }
  .brand-name { font-size: 1.08rem; }
}

/* ==========================================================================
   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;
}

.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;
}

/* 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; }

.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;
  background: var(--ink);
  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;
  gap: 2rem;
  padding: 2.75rem 0 2.25rem;
}
@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; }

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

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