/* ─────────────────────────────────────────────────────
 * Article-page layout — for prose-wrapped concept pages.
 * Loaded after styles/common.css. The canvas demo lives
 * in an iframe to /embed/<slug>.html so this stylesheet
 * does not need to fight the demo's full-screen positioning.
 * ─────────────────────────────────────────────────────── */

html, body { height: auto; overflow: visible; }
body.article-page { background: var(--bg); color: var(--ink); line-height: 1.7; padding-bottom: 60px; }

/* Background grid (matches subject pages) */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(30,38,64,.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30,38,64,.25) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ── Site nav ─────────────────────────────────────────── */
.site-nav {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; max-width: 920px; margin: 0 auto;
}
.nav-logo { text-decoration: none; }
.nav-wordmark { font-family: 'Fraunces', serif; font-size: 22px; font-style: italic; color: var(--ink); letter-spacing: -0.02em; }
.nav-wordmark em { color: var(--accent); font-style: italic; }
.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links a {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--dim); text-decoration: none; transition: color .15s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links .nav-videos {
  color: var(--accent); border: 1px solid rgba(255,77,109,.3);
  padding: 6px 14px;
}

/* ── Article container ────────────────────────────────── */
main { position: relative; z-index: 1; }
.concept-article {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
  font-size: 16px;
}

/* ── Breadcrumb ───────────────────────────────────────── */
.breadcrumb {
  font-size: 11px; color: var(--dim); letter-spacing: 0.1em;
  text-transform: uppercase; margin: 12px 0 32px;
}
.breadcrumb a { color: var(--cyan); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { margin: 0 8px; color: #2a3148; }

/* ── Hero (title, lede, facts, share) ─────────────────── */
.article-hero { margin-bottom: 48px; }
.article-hero .eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.25em;
  color: var(--accent); margin-bottom: 12px;
}
.article-hero h1 {
  font-family: 'Fraunces', serif; font-weight: 300; font-size: 56px;
  line-height: 1.05; letter-spacing: -0.02em; color: var(--ink);
  margin-bottom: 8px;
}
.article-hero .subtitle {
  font-family: 'Fraunces', serif; font-style: italic; font-weight: 300;
  font-size: 22px; color: var(--accent); margin-bottom: 24px; line-height: 1.3;
}
.article-hero .lede {
  font-size: 19px; line-height: 1.55; color: var(--dim);
  margin-bottom: 28px; max-width: 640px;
}

.facts-pills {
  display: flex; flex-wrap: wrap; gap: 8px; list-style: none;
  margin: 0 0 24px; padding: 0;
}
.facts-pills li {
  display: inline-flex; align-items: baseline; gap: 8px;
  border: 1px solid #1e2640; padding: 8px 14px; background: rgba(17,23,42,.55);
  font-size: 12px; letter-spacing: 0.05em;
}
.fact-label { color: var(--dim); text-transform: uppercase; font-size: 10px; letter-spacing: 0.15em; }
.fact-value { color: var(--cyan); font-weight: 700; }

.share-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.share-btn {
  font-family: inherit; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.15em;
  background: transparent; color: var(--ink);
  border: 1px solid #2a3148; padding: 9px 16px;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Demo section (iframe) ────────────────────────────── */
.demo-section, .video-section, .faq-section, .related-section {
  margin: 56px 0;
}
.demo-section h2, .video-section h2, .faq-section h2, .related-section h2,
.prose h2 {
  font-family: 'Fraunces', serif; font-weight: 300; font-size: 32px;
  letter-spacing: -0.01em; color: var(--ink); margin: 0 0 12px; line-height: 1.2;
}
.section-intro {
  font-size: 14px; color: var(--dim); margin-bottom: 20px; max-width: 580px;
}
/* The embedded canvas demos are designed at a desktop viewport (cells at
 * 72px, full HUD with title/legend/controls). Squeezing them into a 760px
 * article column clips the rightmost cells. We render the iframe at a fixed
 * 1280×720 "design viewport," then CSS-scale the wrapper so it visually fills
 * the article column at any width. Click coordinates and pointer events
 * pass through transform: scale correctly. */
.demo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #1e2640;
  background: var(--bg-2);
  overflow: hidden;
}
.demo-scale {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 720px;
  transform-origin: 0 0;
  /* JS sets transform: scale(N) on resize. CSS fallback for first paint
   * before JS runs — assume mobile-ish width so first frame doesn't flash a
   * giant iframe sticking out the right side of the screen. */
  transform: scale(0.3);
}
.demo-scale iframe {
  width: 1280px; height: 720px;
  border: 0; display: block;
}
.demo-tip {
  font-size: 11px; color: var(--dim); margin-top: 12px;
  text-transform: uppercase; letter-spacing: 0.15em;
}
.demo-tip a { color: var(--cyan); text-decoration: none; }
.demo-tip a:hover { color: var(--ink); }

/* ── Prose body ───────────────────────────────────────── */
.prose { font-size: 16px; line-height: 1.75; color: var(--ink); }
.prose h2 { margin-top: 56px; color: var(--ink); }
.prose h3 {
  font-family: 'Fraunces', serif; font-weight: 300; font-size: 22px;
  margin: 32px 0 10px; color: var(--ink); letter-spacing: -0.01em;
}
.prose p { margin: 0 0 18px; color: var(--dim); }
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 22px; color: var(--dim); }
.prose li { margin-bottom: 6px; }
.prose code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.92em;
  background: var(--bg-2); color: var(--dim);
  padding: 2px 6px; border: 1px solid #1e2640;
}
.prose pre {
  background: var(--bg-2); border: 1px solid #1e2640;
  padding: 18px 20px; margin: 20px 0; overflow-x: auto;
  font-size: 13px; line-height: 1.65;
  position: relative;
}
.prose pre .copy-btn {
  position: absolute; top: 8px; right: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid #2a3148; color: var(--dim);
  padding: 5px 10px; cursor: pointer;
  opacity: 0; transition: opacity .15s, color .15s, border-color .15s;
}
.prose pre:hover .copy-btn,
.prose pre:focus-within .copy-btn { opacity: 1; }
.prose pre .copy-btn:hover { color: var(--ink); border-color: var(--accent); }
.prose pre .copy-btn.copied { color: var(--green); border-color: var(--green); opacity: 1; }
@media (max-width: 600px) {
  .prose pre .copy-btn { opacity: 1; }
}
.prose pre code {
  background: transparent; border: 0; padding: 0;
  color: var(--dim); font-size: inherit;
}
.prose strong { color: #d8deee; font-weight: 700; }
.prose em { color: var(--gold); font-style: italic; }
.prose a { color: var(--cyan); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(77,212,255,.35); }
.prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.prose table {
  border-collapse: collapse; width: 100%;
  margin: 20px 0; font-size: 14px;
}
.prose th, .prose td {
  border: 1px solid #1e2640; padding: 10px 14px;
  text-align: left;
}
.prose th {
  background: rgba(17,23,42,.7); color: var(--cyan);
  font-weight: 700; text-transform: uppercase;
  font-size: 11px; letter-spacing: 0.1em;
}
.prose td { color: var(--dim); }

/* ── Video embed ──────────────────────────────────────── */
.video-frame {
  display: flex; justify-content: center;
  background: var(--bg-2); border: 1px solid #1e2640;
}
.video-frame video {
  max-width: 100%; max-height: 80vh;
  display: block;
}
.video-link { font-size: 12px; color: var(--dim); margin-top: 12px; text-align: center; }
.video-link a { color: var(--cyan); text-decoration: none; }

/* ── FAQ ──────────────────────────────────────────────── */
.faq-item {
  border-top: 1px solid #1e2640;
  padding: 16px 0;
}
.faq-item:last-child { border-bottom: 1px solid #1e2640; }
.faq-item summary {
  cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'Fraunces', serif; font-weight: 300; font-size: 19px;
  color: #d8deee; padding-right: 24px; position: relative;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; position: absolute; right: 0; top: 50%;
  transform: translateY(-50%); color: var(--accent); font-size: 24px;
  font-family: 'JetBrains Mono', monospace; line-height: 1;
}
.faq-item[open] summary::after { content: '−'; }
.faq-item p {
  margin-top: 12px; color: var(--dim); font-size: 15px;
  line-height: 1.7; padding-right: 32px;
}

/* ── Related concepts ─────────────────────────────────── */
.related-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.related-list a {
  display: block; padding: 16px 18px; text-decoration: none;
  border: 1px solid #1e2640; background: rgba(17,23,42,.5);
  transition: all .15s; height: 100%;
}
.related-list a:hover { border-color: var(--accent); background: rgba(17,23,42,.8); }
.related-list strong {
  display: block; color: var(--ink); font-weight: 700;
  font-size: 14px; margin-bottom: 6px;
}
.related-list span {
  display: block; color: var(--dim); font-size: 12px; line-height: 1.5;
}

/* ── Keep exploring (next concept + same-subject grid) ── */
.keep-exploring .next-concept {
  position: relative; display: block; text-decoration: none;
  border: 1px solid var(--accent); padding: 20px 56px 20px 22px; margin: 0 0 30px;
  background: linear-gradient(135deg, rgba(180,125,255,.10), rgba(17,23,42,.55));
  transition: all .15s;
}
.keep-exploring .next-concept:hover {
  background: linear-gradient(135deg, rgba(180,125,255,.18), rgba(17,23,42,.85));
  transform: translateY(-1px);
}
.keep-exploring .next-kicker {
  display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 7px;
}
.keep-exploring .next-concept strong {
  display: block; font-family: 'Fraunces', serif; font-weight: 400;
  font-size: 23px; color: var(--ink); line-height: 1.2; margin-bottom: 6px;
}
.keep-exploring .next-teaser { display: block; color: var(--dim); font-size: 13px; line-height: 1.5; }
.keep-exploring .next-arrow {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  font-size: 26px; color: var(--accent); transition: transform .15s;
}
.keep-exploring .next-concept:hover .next-arrow { transform: translateY(-50%) translateX(5px); }
.keep-exploring .more-heading {
  font-size: 12px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim); font-weight: 600; margin: 0 0 14px;
}

/* ── Ad slots (inert until ads.js marks [data-ready]; reserved height = no CLS) ── */
.ad-slot { display: none; }
.ad-slot[data-ready] {
  display: block; margin: 44px auto; min-height: 280px; max-width: 100%;
  text-align: center; position: relative; overflow: hidden;
}
.ad-slot[data-ready]::before {
  content: 'Advertisement'; display: block;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim); opacity: .55; margin-bottom: 8px;
}
.ad-slot[data-ready] .adsbygoogle { display: block; min-height: 250px; }
@media (max-width: 640px) {
  .ad-slot[data-ready] { min-height: 250px; margin: 30px auto; }
}

/* ── Article footer ───────────────────────────────────── */
.article-footer {
  margin: 56px 0 32px; padding: 24px 0;
  border-top: 1px solid #1e2640;
  font-size: 12px; color: var(--dim); line-height: 1.6;
}
.article-footer a { color: var(--cyan); text-decoration: none; }
.article-footer a:hover { color: var(--ink); }
.article-footer-meta { margin-top: 10px; font-size: 10px; opacity: 0.7; letter-spacing: 0.05em; }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-nav { padding: 14px 18px; }
  .concept-article { padding: 0 18px; }
  .article-hero h1 { font-size: 38px; }
  .article-hero .lede { font-size: 17px; }
  .demo-section h2, .video-section h2, .faq-section h2, .related-section h2,
  .prose h2 { font-size: 26px; }
  .demo-frame { aspect-ratio: 9 / 16; }
  .facts-pills li { padding: 6px 10px; font-size: 11px; }
  .share-btn { padding: 7px 12px; font-size: 10px; }
  .keep-exploring .next-concept { padding: 16px 44px 16px 16px; }
  .keep-exploring .next-concept strong { font-size: 20px; }
  .keep-exploring .next-arrow { right: 16px; font-size: 22px; }
}
