/* ============================================================================
   Open TV Streams — Blog design language
   Same-origin stylesheet (served at /blog.css). CSP-safe:
   default-src 'self' allows the <link>; style-src 'self' covers this file;
   font-src 'self' data: => NO web-font CDN, we ride the site font stack
   ('VT323', monospace) that /styles.css already declares on <body>.

   Tokens lifted verbatim from the homepage (styles.css + the canonical
   brand blog pattern in public/blog.html):
     --bg            #0a0a0a   page background (body)
     --surface       #000      panels / cards / header / footer
     --surface-2     #111      inset fields
     --border        #222      hairline card border
     --border-2      #333      secondary border / dividers
     --accent        #ff0000   brand red (links, hover, rules)
     --text          #fff      primary text
     --text-dim      #aaa      body copy
     --text-mute     #666      meta / captions
     font: 'VT323', monospace  (declared by /styles.css; we only inherit)
     uppercase + wide letter-spacing, hard edges (no border-radius),
     brutalist hover: red fill sweep + translate + 0-blur #000 shadow.
   ============================================================================ */

:root {
  --otv-bg: #0a0a0a;
  --otv-surface: #000;
  --otv-surface-2: #111;
  --otv-border: #222;
  --otv-border-2: #333;
  --otv-accent: #ff0000;
  --otv-text: #fff;
  --otv-text-dim: #aaa;
  --otv-text-mute: #666;
  --otv-maxw: 1200px;
  --otv-maxw-article: 900px;
}

/* Inherit the site font/colour from /styles.css <body>; only normalise the
   blog wrappers so a missing inline block can't fall back to a serif. */
.blog-container,
.article-container {
  font-family: 'VT323', monospace;
  color: var(--otv-text);
}

/* Site title in the header (matches homepage <h1>) ------------------------- */
header .site-title {
  font-size: 3.5rem;
  font-weight: normal;
  color: var(--otv-text);
  text-transform: uppercase;
  letter-spacing: 0.5rem;
  position: relative;
  display: inline-block;
  animation: glitch 2s infinite; /* keyframes provided by /styles.css */
  margin: 0;
}

/* ---------------------------------------------------------------- listing - */
.blog-container {
  max-width: var(--otv-maxw);
  margin: 2rem auto;
  padding: 0 2rem;
}

.blog-header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem 0;
  border-bottom: 2px solid var(--otv-accent);
}

.blog-header h1 {
  font-size: 3rem;
  color: var(--otv-text);
  text-transform: uppercase;
  letter-spacing: 0.3rem;
  margin-bottom: 1rem;
  animation: glitch 2s infinite;
}

.blog-header p {
  font-size: 1.3rem;
  color: var(--otv-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15rem;
}

/* Category filter buttons — brutalist button language ---------------------- */
.blog-categories {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

.category-filter {
  padding: 0.8rem 1.6rem;
  background: var(--otv-surface);
  border: 2px solid var(--otv-accent);
  color: var(--otv-accent);
  cursor: pointer;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  transition: all 0.2s ease;
}

.category-filter:hover,
.category-filter:focus-visible,
.category-filter.active {
  background: var(--otv-accent);
  border-color: var(--otv-accent);
  color: var(--otv-surface);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--otv-surface);
  outline: none;
}

/* Card grid --------------------------------------------------------------- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

/* The server (api/blog-list.js) wraps each card in
   <article class="blog-card"><a class="blog-card-link"> ... </a></article>.
   Style the anchor so it never renders as a default underlined blue link. */
.blog-card {
  background: var(--otv-surface);
  border: 2px solid var(--otv-border);
  padding: 0;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;
}

.blog-card-link,
.blog-card > a {
  display: block;
  color: inherit;
  text-decoration: none;
  position: relative;
  z-index: 1;
}

/* Signature brand hover: red sweep behind the card content. */
.blog-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--otv-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 0;
}

[dir="rtl"] .blog-card::before {
  transform-origin: right;
}

.blog-card:hover,
.blog-card:focus-within {
  border-color: var(--otv-accent);
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(255, 0, 0, 0.3);
}

.blog-card:hover::before,
.blog-card:focus-within::before {
  transform: scaleX(1);
}

.blog-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--otv-surface);
  display: block;
  border-bottom: 1px solid var(--otv-border);
}

.blog-card-content {
  padding: 2rem;
}

.blog-card-category {
  display: inline-block;
  background: var(--otv-accent);
  color: var(--otv-text);
  padding: 0.3rem 0.9rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin-bottom: 1rem;
}

.blog-card h2 {
  font-size: 1.8rem;
  color: var(--otv-text);
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.blog-card-excerpt {
  color: var(--otv-text-dim);
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.blog-card-meta {
  display: flex;
  justify-content: space-between;
  color: var(--otv-text-mute);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--otv-border);
}

/* On hover the red panel sweeps in — flip text to black for contrast. */
.blog-card:hover h2,
.blog-card:focus-within h2,
.blog-card:hover .blog-card-excerpt,
.blog-card:focus-within .blog-card-excerpt,
.blog-card:hover .blog-card-meta,
.blog-card:focus-within .blog-card-meta {
  color: var(--otv-surface);
}

.blog-card:hover .blog-card-meta,
.blog-card:focus-within .blog-card-meta {
  border-top-color: rgba(0, 0, 0, 0.35);
}

.blog-card:hover .blog-card-category,
.blog-card:focus-within .blog-card-category {
  background: var(--otv-surface);
  color: var(--otv-accent);
}

.loading,
.no-posts {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  font-size: 1.3rem;
  color: var(--otv-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15rem;
}

/* ---------------------------------------------------------------- article - */
.article-container {
  max-width: var(--otv-maxw-article);
  margin: 2rem auto;
  padding: 0 2rem;
}

.article-header {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--otv-accent);
}

.article-category {
  display: inline-block;
  background: var(--otv-accent);
  color: var(--otv-text);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
}

.article-title {
  font-size: 2.5rem;
  color: var(--otv-text);
  text-transform: uppercase;
  letter-spacing: 0.15rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.article-meta {
  color: var(--otv-text-mute);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
}

.article-content {
  color: #ccc;
  font-size: 1.15rem;
  line-height: 1.8;
  margin-bottom: 3rem;
}

.article-content h2 {
  color: var(--otv-text);
  font-size: 2rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin: 2.5rem 0 1rem;
}

.article-content h3 {
  color: var(--otv-text);
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
  margin: 1.75rem 0 1rem;
}

.article-content p {
  margin-bottom: 1.5rem;
}

.article-content a {
  color: var(--otv-accent);
  text-decoration: underline;
}

.article-content a:hover {
  color: var(--otv-text);
}

.article-content ul,
.article-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

[dir="rtl"] .article-content ul,
[dir="rtl"] .article-content ol {
  padding-left: 0;
  padding-right: 2rem;
}

.article-content li {
  margin-bottom: 0.8rem;
}

.article-content strong {
  color: var(--otv-accent);
}

.article-content blockquote {
  border-left: 3px solid var(--otv-accent);
  margin: 1.5rem 0;
  padding-left: 1rem;
  color: var(--otv-text-dim);
}

[dir="rtl"] .article-content blockquote {
  border-left: none;
  border-right: 3px solid var(--otv-accent);
  padding-left: 0;
  padding-right: 1rem;
}

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

.article-hero-image img {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  margin-bottom: 2rem;
  border: 2px solid var(--otv-border);
}

/* Language switcher (real <a href> links — restyled, not restructured) ----- */
.language-switcher {
  margin: 1.5rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--otv-border-2);
  font-size: 1.05rem;
}

.language-switcher .lang-switch-label {
  color: var(--otv-text-mute);
  margin-right: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
}

[dir="rtl"] .language-switcher .lang-switch-label {
  margin-right: 0;
  margin-left: 0.5rem;
}

.language-switcher .lang-link {
  color: var(--otv-accent);
  margin: 0 0.5rem;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

.language-switcher .lang-link:hover {
  color: var(--otv-text);
  text-decoration: underline;
}

/* Sources / References ---------------------------------------------------- */
.article-sources {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--otv-border-2);
}

.article-sources h2 {
  color: var(--otv-text);
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin-bottom: 1rem;
}

.article-sources ol {
  color: var(--otv-text-dim);
  padding-left: 1.5rem;
}

[dir="rtl"] .article-sources ol {
  padding-left: 0;
  padding-right: 1.5rem;
}

.article-sources li {
  margin-bottom: 0.6rem;
}

.article-sources a {
  color: var(--otv-accent);
}

.article-sources a:hover {
  color: var(--otv-text);
}

.article-sources .src-domain {
  color: var(--otv-text-mute);
  font-size: 0.85rem;
}

/* In-text superscript citation markers ([n] -> <sup class="fn-ref">) ------- */
.fn-ref {
  font-size: 0.7em;
  line-height: 0;
  vertical-align: super;
  margin-left: 0.1em;
}

.fn-ref a {
  color: var(--otv-accent);
  text-decoration: none;
  padding: 0 0.1em;
}

.fn-ref a:hover,
.fn-ref a:focus {
  color: var(--otv-text);
  text-decoration: underline;
}

/* Highlight the source <li> jumped to from an in-text [n] marker. */
.article-sources li:target {
  background: var(--otv-surface-2);
  outline: 2px solid var(--otv-accent);
  outline-offset: 2px;
}

/* Related posts ----------------------------------------------------------- */
.related-posts {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--otv-border-2);
}

.related-posts h3 {
  color: var(--otv-text);
  font-size: 2rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin-bottom: 1.5rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.related-card {
  background: var(--otv-surface);
  border: 2px solid var(--otv-border);
  padding: 1.5rem;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.related-card:hover,
.related-card:focus-visible {
  border-color: var(--otv-accent);
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(255, 0, 0, 0.25);
  outline: none;
}

.related-card h4 {
  color: var(--otv-text);
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  margin-bottom: 0.8rem;
}

.related-card p {
  color: var(--otv-text-dim);
  font-size: 0.95rem;
}

/* Footer home link + generic back-to-home button -------------------------- */
footer .home-link {
  color: var(--otv-accent);
  font-weight: bold;
  text-decoration: none;
}

footer .home-link:hover {
  text-decoration: underline;
}

.back-home {
  text-align: center;
  margin: 3rem 0;
}

.back-home a {
  display: inline-block;
  padding: 1rem 2rem;
  background: var(--otv-surface);
  color: var(--otv-accent);
  border: 2px solid var(--otv-accent);
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  text-decoration: none;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

.back-home a:hover {
  background: var(--otv-accent);
  color: var(--otv-surface);
  transform: translate(-4px, -4px);
  box-shadow: 4px 4px 0 var(--otv-surface);
}

/* Responsive — matches homepage 768px breakpoint -------------------------- */
@media (max-width: 768px) {
  .blog-container,
  .article-container {
    padding: 0 1rem;
  }

  .blog-header h1 {
    font-size: 2rem;
    letter-spacing: 0.15rem;
  }

  .blog-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .article-title {
    font-size: 1.8rem;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  header .site-title {
    font-size: 2rem;
    letter-spacing: 0.25rem;
  }
}

/* ============================================================================
   Engine-emitted asides (engine v20260523).
   ----------------------------------------------------------------------------
   The shared content engine (lib/shared/) now appends two asides INSIDE the
   article body (article.content):
     <aside class="article-sources"><h3>...<ul>...</aside>
     <aside class="related-posts"><h3>...<ul>...</aside>
   The h2-and-ol blocks above are still emitted server-side by api/blog-page.js
   for posts whose row predates engine v20260523. Both shapes coexist; the
   selectors below target the engine's <ul>/<h3> shape without disturbing the
   legacy <ol>/<h2> shape. Brutalist red-and-black VT323 idiom preserved.
   ============================================================================ */

.article-content aside.article-sources,
.article-content aside.related-posts {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--otv-border-2);
}

.article-content aside.article-sources h3,
.article-content aside.related-posts h3 {
  color: var(--otv-text);
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin-bottom: 1rem;
}

.article-content aside.article-sources ul,
.article-content aside.related-posts ul {
  list-style: square;
  color: var(--otv-text-dim);
  padding-left: 1.5rem;
}

[dir="rtl"] .article-content aside.article-sources ul,
[dir="rtl"] .article-content aside.related-posts ul {
  padding-left: 0;
  padding-right: 1.5rem;
}

.article-content aside.article-sources li,
.article-content aside.related-posts li {
  margin-bottom: 0.6rem;
}

.article-content aside.article-sources a,
.article-content aside.related-posts a {
  color: var(--otv-accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--otv-accent);
}

.article-content aside.article-sources a:hover,
.article-content aside.related-posts a:hover {
  color: var(--otv-text);
  border-bottom-style: solid;
}

/* ============================================================================
   Conversion config blocks (engine v20260523).
   Primary CTA and email-capture form rendered at post-page placement
   markers from basePost.conversion_config. Idiom: hard edges, red accent,
   uppercase VT323. Matches the homepage CTA buttons.
   ============================================================================ */

.blog-cta {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--otv-surface);
  border: 2px solid var(--otv-accent);
  text-align: center;
}

.blog-cta--end { margin-top: 3rem; }
.blog-cta--top { margin-bottom: 2.5rem; }
.blog-cta--mid { margin: 2rem auto; }
.blog-cta--sticky {
  position: sticky;
  bottom: 1rem;
  z-index: 5;
}

.blog-cta a.blog-cta-primary,
.blog-cta a.blog-cta-secondary {
  display: inline-block;
  padding: 0.8rem 1.6rem;
  background: var(--otv-accent);
  color: var(--otv-bg);
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  text-decoration: none;
  border: 2px solid var(--otv-accent);
  transition: all 0.2s ease;
}

.blog-cta a.blog-cta-primary:hover,
.blog-cta a.blog-cta-secondary:hover,
.blog-cta a.blog-cta-primary:focus-visible,
.blog-cta a.blog-cta-secondary:focus-visible {
  background: var(--otv-bg);
  color: var(--otv-accent);
  outline: none;
  box-shadow: 4px 4px 0 0 var(--otv-accent);
  transform: translate(-2px, -2px);
}

.blog-cta a.blog-cta-secondary {
  background: transparent;
  color: var(--otv-accent);
  margin-left: 0.5rem;
}

/* Inline email-capture form. AJAX submit to /api/capture-email. */
.blog-email-capture {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--otv-surface);
  border: 2px solid var(--otv-border);
}

.blog-email-capture h3 {
  color: var(--otv-text);
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  margin: 0 0 0.5rem 0;
}

.blog-email-capture p {
  color: var(--otv-text-dim);
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

.blog-email-capture form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.blog-email-capture input[type="email"] {
  flex: 1 1 240px;
  padding: 0.7rem 1rem;
  background: var(--otv-surface-2);
  color: var(--otv-text);
  border: 2px solid var(--otv-border);
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
}

.blog-email-capture input[type="email"]:focus {
  outline: none;
  border-color: var(--otv-accent);
}

.blog-email-capture button[type="submit"] {
  padding: 0.7rem 1.4rem;
  background: var(--otv-accent);
  color: var(--otv-bg);
  border: 2px solid var(--otv-accent);
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.blog-email-capture button[type="submit"]:hover,
.blog-email-capture button[type="submit"]:focus-visible {
  background: var(--otv-bg);
  color: var(--otv-accent);
  outline: none;
}

.blog-email-capture button[type="submit"][disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.blog-email-capture .blog-email-status {
  margin-top: 0.8rem;
  font-size: 1rem;
  min-height: 1.4em;
}

.blog-email-capture .blog-email-status.success { color: #4caf50; }
.blog-email-capture .blog-email-status.error   { color: var(--otv-accent); }

/* === Newspaper hero (shared blog-generator HERO_CSS) ===================== */
.blog-body{overflow-wrap:break-word}
.blog-body::after{content:"";display:block;clear:both}
.blog-hero{margin:0 0 1.25rem 0}
.blog-hero__img{display:block;width:100%;height:auto;border-radius:10px;
  aspect-ratio:var(--hero-ar,1.7778);object-fit:cover}
.blog-hero__credit{font-size:.78rem;line-height:1.3;opacity:.65;margin-top:.4rem}
@media (min-width:768px){
  .blog-hero--landscape,.blog-hero--square,.blog-hero--portrait,.blog-hero--tall{
    float:var(--hero-float,right);max-width:55%;margin-top:.25rem;margin-bottom:1rem}
  .blog-hero[style*="--hero-float:right"]{margin-left:1.75rem}
  .blog-hero[style*="--hero-float:left"]{margin-right:1.75rem}
  .blog-hero--landscape{width:55%}
  .blog-hero--square{width:45%}
  .blog-hero--portrait{width:40%}
  .blog-hero--tall{width:34%}
  .blog-hero--panorama,.blog-hero--banner{float:none;width:100%;max-width:100%;
    margin-left:0;margin-right:0;margin-bottom:1.5rem}
}
