/* ============================================================
   DESIGN TOKENS
   A modular publishing engine where posts AND ad placements are
   both first-class, swappable "blocks". The visual language makes
   that literal: every block on the page carries a bracketed
   slot-tag, the way the admin panel names placements internally
   (HERO-AD, CONTENT-MID-AD, POST-04...). Strict black / white /
   paper — no colour accent.
   ============================================================ */

:root {
  --ink: #0b0b0b;
  --paper: #faf9f6;
  --white: #ffffff;
  --line: #111111;
  --gray-600: #5a5a56;
  --gray-400: #8c8c87;
  --gray-200: #dedcd5;
  --gray-100: #efeee9;

  --font-display: 'Archivo Black', 'Arial Black', sans-serif;
  --font-body: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;

  --border-thick: 3px solid var(--ink);
  --border-thin: 1px solid var(--gray-200);
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, .ph-image { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* -------- slot tag: the recurring signature element -------- */
.slot-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-600);
}
.slot-tag::before { content: '['; }
.slot-tag::after { content: ']'; }

/* -------- placeholder image block (no real assets yet) -------- */
.ph-image {
  width: 100%;
  aspect-ratio: 16/10;
  background:
    repeating-linear-gradient(135deg, var(--ink) 0 2px, transparent 2px 14px),
    var(--gray-100);
  filter: grayscale(1);
  border: var(--border-thin);
}
.ph-image.square { aspect-ratio: 1/1; }
.ph-image.wide { aspect-ratio: 21/9; }

/* ================= HEADER ================= */
.site-header {
  border-bottom: var(--border-thick);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--gutter);
  max-width: 1240px;
  margin: 0 auto;
  gap: 24px;
}
.logo {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo span { color: var(--gray-400); }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 9px 12px;
  border: 1px solid transparent;
}
.main-nav a:hover, .main-nav a.active {
  border: 1px solid var(--ink);
}

.header-tools { display: flex; align-items: center; gap: 14px; }
.search-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--ink);
  padding: 8px 12px;
  background: var(--white);
  cursor: pointer;
}
.search-btn:hover { background: var(--ink); color: var(--white); }

/* mobile nav toggle */
.nav-toggle {
  display: none;
  font-family: var(--font-mono);
  border: 1px solid var(--ink);
  background: var(--white);
  padding: 8px 10px;
  cursor: pointer;
}

/* ================= HERO ================= */
.hero {
  border-bottom: var(--border-thick);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 0;
}
.hero-main {
  padding: 56px var(--gutter) 56px 0;
  margin-left: var(--gutter);
  border-right: var(--border-thin);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}
.hero-eyebrow { display: flex; gap: 10px; align-items: center; }
.hero-eyebrow .cat-pill { }
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 5.4vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  margin: 0;
}
.hero-excerpt {
  max-width: 46ch;
  color: var(--gray-600);
  font-size: 17px;
}
.hero-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray-600);
  display: flex;
  gap: 14px;
  align-items: center;
}
.hero-cta {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 18px;
  background: var(--ink);
  color: var(--white);
  width: fit-content;
}
.hero-cta:hover { background: var(--gray-600); }

.hero-ad {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  background: var(--gray-100);
}
.ad-box {
  border: 2px dashed var(--gray-400);
  background: var(--white);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}
.ad-box .ad-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ================= CATEGORY STRIP ================= */
.cat-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 20px var(--gutter);
  border-bottom: var(--border-thin);
}
.cat-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--ink);
  padding: 6px 12px;
}
.cat-pill:hover { background: var(--ink); color: var(--white); }

/* ================= SECTION LABELS ================= */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 40px var(--gutter) 18px;
  border-bottom: var(--border-thin);
}
.section-title {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0;
}

/* ================= POST GRID ================= */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.post-card {
  border-right: var(--border-thin);
  border-bottom: var(--border-thin);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.post-card.feature {
  grid-column: span 2;
  grid-row: span 2;
}
.post-card.feature .ph-image { aspect-ratio: 16/9; }
.post-card .slot-tag { position: absolute; top: 18px; right: 18px; }
.post-card h3 {
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.15;
  margin: 0;
}
.post-card.feature h3 { font-size: 30px; }
.post-card p { color: var(--gray-600); font-size: 14px; margin: 0; }
.post-card .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-400);
  text-transform: uppercase;
}
.post-card:hover h3 { text-decoration: underline; text-underline-offset: 4px; }

/* ================= FULL-WIDTH AD BANNER ================= */
.ad-banner {
  padding: var(--gutter);
  border-bottom: var(--border-thin);
}
.ad-banner .ad-box { min-height: 120px; }

/* ================= POPULAR ROW ================= */
.popular-list { display: flex; flex-direction: column; }
.popular-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 16px var(--gutter);
  border-bottom: var(--border-thin);
}
.popular-item .rank {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray-400);
}
.popular-item h4 { margin: 0; font-family: var(--font-display); font-size: 16px; }
.popular-item .views { font-family: var(--font-mono); font-size: 11px; color: var(--gray-400); }

/* ================= LAYOUT: content + sidebar ================= */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
}
.sidebar {
  border-left: var(--border-thin);
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar .ad-box { min-height: 400px; }

/* ================= FOOTER ================= */
.site-footer {
  background: var(--ink);
  color: var(--paper);
  border-top: var(--border-thick);
}
.footer-ad { padding: var(--gutter); border-bottom: 1px solid #2a2a28; }
.footer-ad .ad-box { border-color: #4a4a46; background: transparent; }
.footer-ad .ad-label { color: #7a7a76; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 24px;
  padding: 44px var(--gutter);
}
.footer-grid h5 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a8a86;
  margin: 0 0 14px;
}
.footer-grid a { display: block; padding: 5px 0; font-size: 14px; }
.footer-grid a:hover { text-decoration: underline; }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px var(--gutter);
  font-family: var(--font-mono);
  font-size: 11px;
  color: #7a7a76;
  border-top: 1px solid #2a2a28;
  flex-wrap: wrap;
  gap: 10px;
}

/* ================= POST PAGE ================= */
.breadcrumb {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray-400);
  padding: 16px var(--gutter);
  border-bottom: var(--border-thin);
}
.breadcrumb a:hover { text-decoration: underline; }

.post-header {
  padding: 40px var(--gutter);
  border-bottom: var(--border-thin);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.post-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.02;
  margin: 0;
  max-width: 22ch;
}
.byline {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray-600);
}
.avatar {
  width: 32px; height: 32px;
  background: var(--ink);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
}

.featured-media { border-bottom: var(--border-thin); }
.featured-media .ph-image { aspect-ratio: 21/9; border: none; }

.article-body {
  padding: 44px var(--gutter);
  font-size: 18px;
  line-height: 1.75;
  max-width: 760px;
}
.article-body h2 {
  font-family: var(--font-display);
  font-size: 26px;
  margin-top: 44px;
}
.article-body p { margin: 0 0 20px; color: #1c1c1a; }
.article-body blockquote {
  margin: 32px 0;
  padding-left: 20px;
  border-left: var(--border-thick);
  font-size: 20px;
  font-style: normal;
  color: var(--gray-600);
}

.custom-code-block {
  margin: 0 var(--gutter) 44px;
  border: 2px dashed var(--gray-400);
  padding: 22px;
  background: var(--gray-100);
}
.custom-code-block .slot-tag { margin-bottom: 12px; }
.custom-code-block .sandbox-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-400);
}

.related-heading {
  font-family: var(--font-display);
  font-size: 22px;
  padding: 0 var(--gutter);
  margin: 8px 0 0;
}

/* ================= AD OVERLAYS (popup / new session / exit intent) ================= */
.fn-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
}
.fn-overlay[hidden] { display: none; }
.fn-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 11, 0.72);
}
.fn-overlay-card {
  position: relative;
  background: var(--white);
  border: var(--border-thick);
  width: 100%;
  max-width: 440px;
  box-shadow: 12px 12px 0 rgba(11, 11, 11, 0.25);
}
.fn-overlay-close {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 42px;
  height: 42px;
  border: none;
  border-left: var(--border-thin);
  border-bottom: var(--border-thin);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}
.fn-overlay-close:hover { background: var(--ink); color: var(--white); }
.fn-overlay-body {
  padding: 40px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fn-overlay-body .slot-tag { align-self: flex-start; }

/* ================= POST FEATURED IMAGE ================= */
.post-image {
  border: var(--border-thin);
  background: var(--gray-100);
  overflow: hidden;
}
.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.featured-media .post-image { border: none; }

/* ================= SEARCH / ARCHIVE PAGE ================= */
.search-panel {
  padding: 40px var(--gutter);
  border-bottom: var(--border-thin);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.search-panel h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 4.5vw, 42px);
  margin: 0;
}
.search-bar {
  display: flex;
  gap: 10px;
  max-width: 560px;
}
.search-bar input {
  flex: 1;
  border: 1px solid var(--ink);
  background: var(--white);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.search-bar input:focus { outline: 2px solid var(--ink); outline-offset: 1px; }

/* active filter on admin links (bracket style) */
.active-filter { color: var(--ink); font-weight: 600; }

/* ================= RESPONSIVE ================= */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-main { margin-left: 0; padding: 40px var(--gutter); border-right: none; border-bottom: var(--border-thin); }
  .split-layout { grid-template-columns: 1fr; }
  .sidebar { border-left: none; border-top: var(--border-thick); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .main-nav { display: none; }
  .nav-toggle { display: inline-block; }
  .post-grid { grid-template-columns: 1fr 1fr; }
  .post-card.feature { grid-column: span 2; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .post-grid { grid-template-columns: 1fr; }
  .post-card.feature { grid-column: span 1; }
  .popular-item { grid-template-columns: 40px 1fr; }
  .popular-item .views { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* focus visibility */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
