/*
Theme Name: Zeitgeist
Theme URI: https://michaeldevault.com
Author: Michael DeVault
Author URI: https://michaeldevault.com
Description: Zeitgeist is the site; Dispatches (professional) and Marginalia (personal) are its two blogs. Cobalt/sans for Dispatches, signal red/serif for Marginalia, shared ink and grid module throughout. Header, footer, nav, and site identity are Customizer-editable; everything else (post content, featured images, alt text, dates, categories) is pulled dynamically from WordPress.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: zeitgeist
*/

/* =========================================================
   TYPOGRAPHY TOKENS — every value here has a matching Customizer
   control (Appearance → Customize → Zeitgeist: Fonts). Defaults below
   are the theme's original design; Customizer output overrides them
   via an inline <style> block injected after this stylesheet.
   ========================================================= */
:root {
  --zg-font-heading: 'Archivo', system-ui, sans-serif;
  --zg-font-body: 'Archivo', system-ui, sans-serif;
  --zg-font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --zg-font-serif: 'Newsreader', Georgia, serif;
  --zg-weight-heading: 700;
  --zg-weight-body: 400;
  --zg-weight-mono: 400;
  --zg-weight-serif: 400;
  --zg-scale-heading: 1;
  --zg-scale-body: 1;
  --zg-scale-mono: 1;
  --zg-scale-serif: 1;
}

/* =========================================================
   RESET / BASE
   ========================================================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f3f6fa;
  color: #14213a;
  font-family: var(--zg-font-body);
  font-weight: var(--zg-weight-body);
  -webkit-font-smoothing: antialiased;
}

body.section-marginalia { background: #f9f4ea; }

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

a { color: #14213a; text-decoration: none; }
a:hover { opacity: 0.66; }

h1, h2, h3, h4, h5, h6 { font-family: var(--zg-font-heading); }

.ital { font-family: var(--zg-font-serif); font-style: italic; font-weight: var(--zg-weight-serif); }
.serif { font-family: var(--zg-font-serif); font-weight: var(--zg-weight-serif); }
.mono { font-family: var(--zg-font-mono); font-weight: var(--zg-weight-mono); font-size: calc(16px * var(--zg-scale-mono)); letter-spacing: 0.12em; text-transform: uppercase; }
.tight { letter-spacing: -0.035em; font-weight: var(--zg-weight-heading); line-height: 0.9; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px,1px,1px,1px); white-space: nowrap; }

/* =========================================================
   SITE IDENTITY STRIP + NAV (shared across every template)
   ========================================================= */
.zg-identity {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 16px;
  padding: 9px 10px;
  border-bottom: 1px solid #d2dbe8;
  flex-wrap: wrap;
}
body.section-marginalia .zg-identity { border-bottom-color: #e0d6c2; }

.zg-identity-title { font-family: var(--zg-font-mono); font-size: calc(26px * var(--zg-scale-mono)); font-weight: 700; letter-spacing: 0.18em; color: #14213a; }
.zg-identity-title a { color: inherit; }
.zg-identity-tagline { font-size: calc(22px * var(--zg-scale-serif)); color: #6b7590; }
body.section-marginalia .zg-identity-tagline { color: #857b66; }

.substack-tab {
  z-index: 5;
  position: absolute;
  right: 10px;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6em 1.32em;
  background: linear-gradient(165deg, #e6383c 0%, #e31e25 42%, #d11d22 100%);
  color: #ffffff !important;
  font-weight: 500;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 2px 4px rgba(20,33,58,0.08);
}
.substack-tab:hover { opacity: 0.85; }

.zg-nav-wrap { position: relative; }
.site-header {
  position: relative;
  min-height: clamp(90px, 12vw, 138px);
  border-bottom: 1px solid #d2dbe8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 3vw, 40px);
  padding: 14px max(20px, 4%);
}
body.section-marginalia .site-header { border-bottom-color: #e0d6c2; }

.nav-group { display: flex; align-items: center; flex: 1 1 0; gap: clamp(16px, 4vw, 56px); }
.nav-group--left { justify-content: flex-start; }
.nav-group--right { justify-content: flex-end; }
.nav-logo-wrap { flex: 0 0 auto; text-align: center; max-width: clamp(140px, 20vw, 260px); }
.nav-logo-wrap a { display: block; }
.nav-logo-wrap img,
.nav-logo-wrap .custom-logo {
  height: clamp(70px, 9vw, 110px);
  width: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
}
.nav-logo-text { font-size: clamp(calc(22px * var(--zg-scale-mono)), 3vw, calc(32px * var(--zg-scale-mono))); font-weight: 700; letter-spacing: 0.18em; }
.nav-link { font-size: calc(18px * var(--zg-scale-mono)); }
.nav-item .ital { font-size: calc(18.4px * var(--zg-scale-serif)); color: #6b7590; margin-top: 3px; display: block; }
body.section-marginalia .nav-item .ital { color: #857b66; }
.nav-item--dispatches .nav-link { font-weight: 500; color: #334da1; }
.nav-item--marginalia .nav-link { font-weight: 500; color: #e31e25; }

/* Hover double-underline — same red and line weight as the small
   "pipe" bars in front of the breadcrumb trail (.hero-eyebrow-bars
   span: clamp(2px, 0.25vw, 3px) thick, #e31e25). Two stacked red
   rules fade/slide in under the item on hover. Purely decorative/CSS
   — no markup change needed on the nav items themselves. */
.nav-item {
  position: relative;
  padding-bottom: 12px;
}
.nav-item::before,
.nav-item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: clamp(2px, 0.25vw, 3px);
  background: #e31e25;
  opacity: 0;
  transform: scaleX(0.85);
  transform-origin: left center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.nav-item::before { bottom: 6px; }
.nav-item::after { bottom: 0; }
.nav-item:hover::before,
.nav-item:hover::after,
.nav-item:focus-within::before,
.nav-item:focus-within::after {
  opacity: 1;
  transform: scaleX(1);
}

/* =========================================================
   GRID / LAYOUT PRIMITIVES
   ========================================================= */
.hero-split { display: grid; grid-template-columns: 1.15fr 1fr; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 34px; }
.tile-grid { column-gap: 34px; row-gap: 24px; }
.marg-row { display: grid; grid-template-columns: 1.9fr 1fr 9.6fr 6.7fr; gap: 24px; align-items: start; }
.marg-thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: #e6ddc8; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 28px; }
.row-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 28px; }
.idx-row { display: grid; grid-template-columns: 1fr 130px; gap: 26px; align-items: start; padding: 24px 0; }
.arc-row { display: grid; grid-template-columns: 200px 1fr; gap: 40px; }

/* =========================================================
   HERO (front page)
   ========================================================= */
.hero-eyebrow { display: flex; gap: 16px; align-items: center; margin-bottom: 22px; }
.hero-eyebrow .zg-breadcrumbs { margin-bottom: 0; }
.hero-eyebrow-bars { display: flex; gap: 4px; }
.hero-eyebrow-bars span { display: block; width: clamp(2px, 0.25vw, 3px); height: clamp(10px, 1.2vw, 15px); background: #e31e25; }
.hero-headline { font-size: clamp(calc(34px * var(--zg-scale-heading)), 6vw, calc(64px * var(--zg-scale-heading))); line-height: 1.15; margin: 0 0 26px; }
.hero-dek { font-size: calc(16.5px * var(--zg-scale-body)); line-height: 1.6; color: #4e5872; margin: 0 0 40px; max-width: 34ch; }
.hero-ctas { display: flex; gap: 25px; flex-wrap: wrap; }
.btn-solid { background: #14213a; color: #f3f6fa; padding: 15px 22px; font-size: calc(16px * var(--zg-scale-body)); font-weight: 600; display: inline-block; }
.btn-solid:hover { color: #f3f6fa; }
.btn-outline { border: 1px solid #14213a; padding: 14px 22px; font-size: calc(16px * var(--zg-scale-body)); font-weight: 500; display: inline-block; }
.hero-media { position: relative; aspect-ratio: 4/3; overflow: hidden; background: #e6ecf4; }
.hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-media-tag { position: absolute; left: 0; top: 0; background: #334da1; color: #fff; }
.hero-media-tag span { padding: 7px 14px; display: inline-block; }
.hero-rule { position: absolute; left: 4%; right: 50.5116%; bottom: 0; height: clamp(2px, 0.2vw, 3px); background: #334da1; }

/* =========================================================
   DISPATCHES TILE GRID (front page + archive teaser)
   ========================================================= */
.tg-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #e6ecf4; }
.tg-cat { color: #334da1; }
.tg-head { font-size: calc(23px * var(--zg-scale-heading)); font-weight: 600; line-height: 1.24; letter-spacing: -0.018em; margin: 0 0 -14px; }
.tg-head a { color: inherit; }
.tg-date { color: #8790a6; }
.tg-preview { display: flex; flex-direction: column; height: 100%; }
.tg-preview p { font-size: calc(16px * var(--zg-scale-body)); line-height: 1.6; color: #5a6480; margin: 0 0 20px; }
.tg-preview a { color: #334da1; font-weight: 500; margin-top: auto; }

/* =========================================================
   MARGINALIA LIST (front page + archive)
   ========================================================= */
.marg-date { color: #a3987f; }
.marg-row h4 a { color: inherit; }
.marg-row p { font-size: calc(17px * var(--zg-scale-body)); line-height: 1.65; color: #6b6252; margin: 0; }

/* =========================================================
   CREDENTIALS / BIO (front page)
   ========================================================= */
.bio-portrait { aspect-ratio: 1/1; background: #e6ecf4; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bio-portrait img { width: 100%; height: 100%; object-fit: cover; }
.bio-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; margin-bottom: 18px; }
.bio-books img { aspect-ratio: 2/3; background: #e6ecf4; object-fit: cover; width: 100%; display: block; }
.bio-book-link { display: block; }
.bio-book-link:hover { opacity: 0.85; }

/* Homepage Blocks (Customizer-managed repeater) */
.zg-block { padding: 60px 8%; }
.zg-block-title { color: #8790a6; margin: 0 0 18px; }

/* =========================================================
   SUBSCRIBE BLOCK (dark)
   ========================================================= */
.zg-subscribe { background: #14213a; color: #ebe8df; padding: 90px 8%; }
.zg-subscribe .hero-eyebrow-bars span { background: #e31e25; width: clamp(3px, 0.3vw, 4px); height: clamp(18px, 2vw, 26px); }
.zg-subscribe h3 { font-size: clamp(calc(32px * var(--zg-scale-heading)), 4.5vw, calc(56px * var(--zg-scale-heading))); margin: 0 0 16px; }
.zg-subscribe p { font-size: calc(16px * var(--zg-scale-body)); line-height: 1.6; color: #9fabc4; margin: 0; max-width: 34ch; }
.zg-subscribe-form { display: flex; gap: 10px; }
.zg-subscribe-form input[type=email] { flex-grow: 1; border: 1px solid #3d4a68; background: transparent; color: #ebe8df; padding: 15px 18px; font-size: calc(16px * var(--zg-scale-body)); font-family: inherit; }
.zg-subscribe-form button { background: #e31e25; color: #fff; border: 0; padding: 15px 22px; font-size: calc(16px * var(--zg-scale-body)); font-weight: 600; white-space: nowrap; cursor: pointer; font-family: inherit; }

/* =========================================================
   FOOTER
   ========================================================= */
.zg-footer { background: #14213a; color: #7b86a0; padding: 40px 8% 44px; }
.zg-footer-rule { height: clamp(1px, 0.1vw, 2px); background: #26314f; margin-bottom: 34px; }
.zg-footer img.footer-logo { width: 55%; display: block; }
.zg-footer .widget-title { font-family: var(--zg-font-mono); font-size: calc(16px * var(--zg-scale-mono)); letter-spacing: 0.12em; text-transform: uppercase; color: #4a5675; margin: 0 0 12px; }
.zg-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.zg-footer a { color: #9fabc4; font-family: var(--zg-font-mono); font-size: calc(16px * var(--zg-scale-mono)); letter-spacing: 0.12em; text-transform: uppercase; }
.zg-footer-copy { color: #4a5675; padding-top: 34px; }

/* simple horizontal footer used on interior/archive templates */
.zg-footer-simple { background: #14213a; color: #7b86a0; padding: 40px 8%; margin-top: 70px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.zg-footer-simple img { width: 180px; display: block; }
.zg-footer-simple nav { display: flex; gap: 26px; flex-wrap: wrap; }
.zg-footer-simple a { color: #9fabc4; }

/* =========================================================
   ARCHIVE MASTHEADS (Dispatches / Marginalia)
   ========================================================= */
.masthead-rule { height: 4px; margin-bottom: 30px; }
.masthead-rule--dispatches { background: #334da1; }
.masthead-rule--marginalia { background: #e31e25; margin-bottom: 34px; }
.masthead-title--dispatches { font-size: clamp(calc(44px * var(--zg-scale-heading)), 8vw, calc(96px * var(--zg-scale-heading))); margin: 0 0 26px; color: #334da1; }
.masthead-title--marginalia { font-size: clamp(calc(52px * var(--zg-scale-serif)), 10vw, calc(118px * var(--zg-scale-serif))); line-height: 0.88; letter-spacing: -0.03em; margin: 0 0 24px; color: #e31e25; }
.masthead-filters { display: flex; justify-content: flex-end; gap: 24px; padding-bottom: 10px; flex-wrap: wrap; }
.masthead-filters a { padding-bottom: 6px; color: #8790a6; }
.masthead-filters a.is-active { font-weight: 500; color: inherit; border-bottom: 2px solid currentColor; }

.lead-post { padding: 36px 0 42px; }
.lead-post-img { aspect-ratio: 4/3; background: #e6ecf4; overflow: hidden; }
.lead-post-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lead-post h2 a, .lead-post h2 { color: inherit; }

.idx-row h3 a { color: inherit; }
.idx-row p { font-size: calc(16px * var(--zg-scale-body)); line-height: 1.6; color: #5a6480; margin: 0; }

.arc-row h3 a { color: inherit; }
.arc-row p { font-size: calc(17.5px * var(--zg-scale-serif)); line-height: 1.62; color: #5a6480; margin: 0 0 14px; }

.zg-pagination { display: flex; align-items: center; justify-content: space-between; padding: 22px 0 0; flex-wrap: wrap; gap: 12px; }
.zg-pagination a { color: #334da1; font-weight: 500; }
body.section-marginalia .zg-pagination a { color: #e31e25; }

/* rail (Dispatches sidebar) */
.zg-rail { display: flex; flex-direction: column; gap: 28px; }
.zg-rail-card { background: #334da1; color: #fff; padding: 28px; }
.zg-rail-card a.zg-rail-btn { display: block; background: #fff; color: #334da1; padding: 13px; font-size: calc(16px * var(--zg-scale-body)); font-weight: 600; text-align: center; }
.zg-rail-crosslink { background: #f9f4ea; padding: 24px; border-top: 3px solid #e31e25; }

/* foot matter (Marginalia archive) */
.zg-footmatter { padding: 66px 8% 0; }
.zg-footmatter .grid-3 { gap: 0; }
.zg-footmatter .col { padding: 0 40px; border-right: 1px solid #e0d6c2; }
.zg-footmatter .col:first-child { padding-left: 0; }
.zg-footmatter .col:last-child { padding-right: 0; border-right: none; }

/* =========================================================
   SINGLE POST
   ========================================================= */
.zg-single-header { padding: 56px 8% 30px; }
.zg-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 18px; }
.zg-breadcrumbs a { color: inherit; text-decoration: none; }
.zg-breadcrumbs a:hover { text-decoration: underline; }
.zg-breadcrumbs .zg-crumb-sep { opacity: 0.4; }
.zg-single-title { margin: 0 0 22px; }
.zg-single-title--dispatches { font-size: clamp(calc(32px * var(--zg-scale-heading)), 6vw, calc(58px * var(--zg-scale-heading))); color: #14213a; }
.zg-single-title--marginalia { font-size: clamp(calc(32px * var(--zg-scale-serif)), 6vw, calc(58px * var(--zg-scale-serif))); font-family: var(--zg-font-serif); font-weight: var(--zg-weight-serif); letter-spacing: -0.022em; color: #14213a; }
.zg-single-meta { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.zg-single-media { padding: 0 8%; margin-bottom: 40px; }
.zg-single-media img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.zg-single-content { padding: 0 8% 70px; max-width: 760px; margin: 0 auto; font-size: calc(18px * var(--zg-scale-body)); line-height: 1.7; color: #2a3450; }
.zg-single-content.serif-body { font-family: var(--zg-font-serif); font-size: calc(20px * var(--zg-scale-serif)); }
.zg-single-content p { margin: 0 0 26px; }
.zg-single-content h2, .zg-single-content h3 { letter-spacing: -0.02em; margin: 44px 0 20px; }
.zg-single-content img { display: block; margin: 34px auto; }
.zg-single-content blockquote { margin: 34px 0; padding-left: 26px; border-left: 3px solid #334da1; font-style: italic; color: #4e5872; }
body.section-marginalia .zg-single-content blockquote { border-left-color: #e31e25; }
.zg-single-footer { padding: 40px 8% 70px; max-width: 760px; margin: 0 auto; border-top: 1px solid #d2dbe8; }
body.section-marginalia .zg-single-footer { border-top-color: #e0d6c2; }
.zg-single-tags a { color: #8790a6; margin-right: 12px; }

/* =========================================================
   GENERIC INTERIOR PAGE
   ========================================================= */
.zg-page-header { padding: 56px 8% 20px; border-bottom: 2px solid #14213a; }
.zg-page-title { font-size: clamp(calc(38px * var(--zg-scale-heading)), 6vw, calc(64px * var(--zg-scale-heading))); margin: 0; }
.zg-page-content { padding: 50px 8% 90px; max-width: 760px; margin: 0 auto; font-size: calc(18px * var(--zg-scale-body)); line-height: 1.7; color: #2a3450; }
.zg-page-content p { margin: 0 0 26px; }

/* =========================================================
   404
   ========================================================= */
.zg-404 { padding: 110px 8%; text-align: center; }
.zg-404 h1 { font-size: clamp(calc(60px * var(--zg-scale-heading)), 12vw, calc(140px * var(--zg-scale-heading))); margin: 0 0 20px; color: #334da1; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 980px) {
  .site-header { flex-direction: column; align-items: center; row-gap: 16px; min-height: 0 !important; padding-top: 18px !important; padding-bottom: 18px !important; }
  .nav-group { flex-direction: column; row-gap: 14px; text-align: center; }
  .nav-logo-wrap { order: -1; }
  .hero-split { grid-template-columns: 1fr !important; }
  .hero-split > div:last-child, .hero-media { aspect-ratio: 16/10 !important; }
  .grid-3 { grid-template-columns: 1fr !important; row-gap: 40px; }
  .tile-grid > *:nth-child(1) { order: 1; }
  .tile-grid > *:nth-child(4) { order: 2; }
  .tile-grid > *:nth-child(7) { order: 3; }
  .tile-grid > *:nth-child(10) { order: 4; }
  .tile-grid > *:nth-child(13) { order: 5; margin-bottom: 40px; }
  .tile-grid > *:nth-child(2) { order: 6; }
  .tile-grid > *:nth-child(5) { order: 7; }
  .tile-grid > *:nth-child(8) { order: 8; }
  .tile-grid > *:nth-child(11) { order: 9; }
  .tile-grid > *:nth-child(14) { order: 10; margin-bottom: 40px; }
  .tile-grid > *:nth-child(3) { order: 11; }
  .tile-grid > *:nth-child(6) { order: 12; }
  .tile-grid > *:nth-child(9) { order: 13; }
  .tile-grid > *:nth-child(12) { order: 14; }
  .tile-grid > *:nth-child(15) { order: 15; }
  .marg-row, .arc-row { grid-template-columns: 1fr !important; row-gap: 6px; }
  .grid-12 > div, .row-12 > div { grid-column: 1 / -1 !important; }
  .grid-12, .row-12 { row-gap: 32px; }
  .idx-row { grid-template-columns: 1fr; }
  .substack-tab { position: static !important; margin: 14px auto 0; width: max-content !important; border-radius: 8px !important; }
  .zg-footmatter .col { padding: 0 !important; border: none !important; }
  .zg-footer-simple { flex-direction: column; text-align: center; }
  .masthead-filters { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .nav-item { text-align: center; }
}
