/**
 * Poems Page Styles — v1.0
 * Sticky Frame Slider + Scroll-Hijack + Larger Typography
 * + Navigation Dots + Glowing Margins + Layout Fixes
 */

/* ============================================
   VARIABLE BRIDGE — map short tokens to global.css
   ============================================ */
:root {
  --text-primary: var(--color-text-primary);
  --text-secondary: var(--color-text-secondary);
  --text-muted: var(--color-text-muted);
  --accent: var(--color-accent);
  --accent-glow: var(--color-accent-glow);
  --bg-primary: var(--color-bg-base);
  --bg-secondary: var(--color-bg-elevated);
  --bg-card: var(--color-bg-card);
  --border: var(--color-border-subtle);
  --border-accent: var(--color-border-strong);
  --font-poetry: var(--font-body);
  --font-mono: 'Space Mono', monospace;
}

/* ============================================
   POEMS HERO
   ============================================ */
.poems-hero {
  position: relative;
  min-height: 50vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8rem var(--padding-desktop) 4rem;
  background: transparent;
  overflow: hidden;
}

.poems-hero-content {
  text-align: center;
  z-index: 2;
  max-width: 700px;
}

.poems-hero-title {
  font-family: var(--font-poetry);
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  font-weight: 400;
  font-style: italic;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  margin: 1rem 0;
}

.poems-hero-subtitle {
  font-family: var(--font-poetry);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: var(--text-secondary);
  line-height: 1.6;
}

.hero-flourish {
  width: 150px;
  margin: 2rem auto 0;
}

.flourish-path {
  stroke: var(--accent);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: drawFlourish 2s ease forwards;
}

.flourish-path:nth-child(2) { animation-delay: 0.3s; }
.flourish-path:nth-child(3) { animation-delay: 0.6s; }

@keyframes drawFlourish {
  to { stroke-dashoffset: 0; }
}

/* Background Particles */

/* ============================================
   POEMS READER — Sticky Scroll-Hijack Slider
   ============================================
   Architecture:
   1. .poems-reader is tall (100vh × number-of-poems) to create
      scroll space — the user scrolls "through" the poems
   2. .reader-wrapper is position:sticky — it pins just below
      the nav bar and stays rock-still
   3. Inside: only one .poem-slide is visible at a time via
      absolute positioning (all overlap, only active shows)
   4. Scroll/wheel events in the pinned zone change poems
   5. Arrow buttons also change poems with crisp transitions
*/
.poems-reader {
  position: relative;
  padding: 0 var(--padding-desktop, 4rem);
  background: transparent;
  /* Height = viewport height × number of poems — creates scroll runway */
  /* JS will set this dynamically based on poem count */
}

.reader-wrapper {
  position: sticky;
  top: 70px; /* just below sticky nav */
  max-width: 800px;
  margin: 0 auto;
  padding: 0.35rem 0 0;
  z-index: 10;
}

/* Progress Indicator */
.poem-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.progress-bar {
  width: 240px;
  height: 2px;
  background-color: var(--border);
  position: relative;
  border-radius: 1px;
}

.progress-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background-color: var(--accent);
  border-radius: 1px;
  transition: width 0.4s ease;
}

.progress-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  min-width: 55px;
  text-align: right;
}

/* ============================================
   POEM FRAME CONTAINER
   ============================================ */
.poem-frame-container {
  position: relative;
  background: linear-gradient(135deg, rgba(212, 168, 83, 0.03) 0%, transparent 50%);
  border: 1px solid var(--border);
  padding: 3rem 3rem 1rem 3rem;
  max-width: 720px;
  margin: 0 auto;
  /* Fill available viewport height: nav(70) + wrapper-padding(6) + progress(20) + progress-margin(8) = ~104px */
  height: calc(100vh - 108px);  /* fallback: Safari < 15.4 */
  height: calc(100svh - 108px);
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

/* Frame Decorations */
.frame-decoration {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 30px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.frame-decoration.top    { top: 1rem; }
.frame-decoration.bottom {
  position: relative;
  bottom: auto;
  margin-top: auto;
  padding-top: 0.15rem;
}

.frame-decoration svg {
  width: 100%;
  height: 100%;
  color: var(--accent);
}

/* ============================================
   POEM SLIDES — Absolute overlap, crisp switch
   ============================================ */
.poems-scroll-container {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden; /* clip slides during transition */
}

.poem-slide {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 1.5rem 2rem 2rem;
  opacity: 0;
  visibility: hidden;
  transform: translateX(40px);
  transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s ease;
  text-align: center;
  /* Custom scrollbar for poem overflow */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.poem-slide::-webkit-scrollbar {
  width: 4px;
}
.poem-slide::-webkit-scrollbar-track {
  background: transparent;
}
.poem-slide::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Direction classes for slide animation */
.poem-slide.slide-left {
  transform: translateX(-40px);
}

.poem-slide.active {
  position: absolute;
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Poem Content — BIGGER typography */
.poem-title {
  font-family: var(--font-poetry);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2rem;
  letter-spacing: 0.05em;
}

.poem-text {
  font-family: var(--font-poetry);
  font-size: clamp(1.3rem, 1.24rem + 0.3vw, 1.5rem);  /* smooth scaling (was bare 2vw) */
  line-height: 2;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
  white-space: pre-wrap;
  text-align: left;
}

.poem-text p { margin: 0; }

.poem-citation {
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.7;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   NAVIGATION ARROWS
   ============================================ */
.poem-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: var(--bg-primary);
  border: 1px solid var(--text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.3s, color 0.3s, background-color 0.3s, transform 0.3s;
  z-index: 10;
}

.poem-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--accent-glow);
}

.poem-nav:active {
  transform: translateY(-50%) scale(0.92);
}

.poem-nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* KB-07: visible keyboard-focus ring for footnote reference numbers and the
   "↩" back-links (previously only the faint browser-default outline showed).
   Purely visual — does not affect the footnote jump behaviour. */
.poem-slide sup a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.poem-nav svg {
  width: 20px;
  height: 20px;
}

.poem-nav.prev { left: -28px; }
.poem-nav.next { right: -28px; }

/* Ensure arrows are always visible on all browsers */
.poem-nav svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.poem-nav:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}
.poem-nav:disabled:hover {
  border-color: var(--border);
  color: var(--text-secondary);
  background-color: transparent;
}

/* ============================================
   NAVIGATION DOTS — bottom of frame
   ============================================ */
.poem-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  /* Real gap between enlarged hit areas — Safari was bunching dots when ::before overlapped flex gap */
  gap: 0.6rem 1.1rem;
  column-gap: max(1.15rem, 18px);
  row-gap: 0.55rem;
  padding: 0.35rem min(1.25rem, 4vw) 0.2rem;
  position: relative;
  z-index: 2;
}

.poem-dot {
  /* Padding = Apple-friendly tap target; visible circle = content box only */
  box-sizing: content-box;
  width: 13px;
  height: 13px;
  padding: max(13px, calc((44px - 13px) / 2));
  border-radius: 50%;
  background-color: var(--border);
  background-clip: content-box;
  border: none;
  margin: 0;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  position: relative;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  transform-origin: center center;
}

.poem-dot:hover,
.poem-dot.active {
  background-color: var(--accent);
  transform: scale(1.35);
}

.poem-dot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================
   GLOWING MARGINS — vertical edge glow + progress line
   The glow is a soft ambient light on both sides.
   The line is a thin gold stroke that grows downward
   synchronised with poem-scroll progress.
   ============================================ */
.glow-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.glow-edge.left {
  left: -40px;
  background: linear-gradient(to right,
    transparent 0%,
    var(--accent-glow, rgba(240,215,140,0.15)) 60%,
    transparent 100%);
}

.glow-edge.right {
  right: -40px;
  background: linear-gradient(to left,
    transparent 0%,
    var(--accent-glow, rgba(240,215,140,0.15)) 60%,
    transparent 100%);
}

.glow-edge.visible {
  opacity: 1;
}

/* Thin gold progress line inside each glow edge */
.glow-line {
  position: absolute;
  top: 0;
  width: 1.5px;
  /* SCROLL-028: full height + scaleY(0..1) set by JS (was height:0%→N% —
     a per-scroll-frame LAYOUT animation with two glow shadows). transform
     runs on the compositor; same 0.35s easing, same visual at rest. */
  height: 100%;
  transform: scaleY(0);
  transform-origin: top center;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--accent, #f0d78c) 0%,
    var(--accent, #f0d78c) 85%,
    transparent 100%
  );
  box-shadow:
    0 0 6px var(--accent-glow, rgba(240,215,140,0.4)),
    0 0 14px var(--accent-glow, rgba(240,215,140,0.2));
  transition: transform 0.35s ease-out;
}

.glow-edge.left .glow-line {
  right: 12px; /* centred within the 40px glow band */
}

.glow-edge.right .glow-line {
  left: 12px;
}

/* ============================================
   POEMS INDEX SECTION — "Poems in this selection"
   ============================================ */
.poems-index-section {
  position: relative;
  padding: 6rem var(--padding-desktop);
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--bg-secondary) 12%,
    var(--bg-secondary) 88%,
    transparent 100%
  );
  overflow: hidden;
}

/* Last index section: generous star-visible zone at top, fade out at bottom */
.poems-index-section:last-of-type {
  padding-top: 12rem;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--bg-secondary) 30%,
    var(--bg-secondary) 88%,
    transparent 100%
  );
}

/* Decorative corner SVGs on section */
.section-corner-decor {
  position: absolute;
  width: 120px;
  height: 120px;
  pointer-events: none;
  opacity: 0.12;
  color: var(--accent);
}
.section-corner-decor.top-left     { top: 2rem;    left: 2rem; }
.section-corner-decor.bottom-right { bottom: 2rem; right: 2rem; transform: rotate(180deg); }

.index-header {
  text-align: center;
  margin-bottom: 4rem;
}

.index-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 0.8rem;
}

/* ============================================
   POEM CARDS — Bigger, more stylish
   Using section-id selectors for stronger specificity
   to prevent cascade / caching issues.
   ============================================ */
.poems-index-section .poems-cards,
.poems-cards {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.8rem;
}

.poems-index-section .poem-card,
.poem-card {
  position: relative;
  background-color: var(--bg-card, rgba(26, 26, 30, 0.8));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 2px;
  padding: 2.2rem 2rem;
  transition: border-color 0.4s ease, transform 0.4s ease, box-shadow 0.4s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.poems-index-section .poem-card:hover,
.poem-card:hover {
  border-color: var(--border-accent, rgba(255,255,255,0.2));
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Floating decorative element in each card */
.card-float-decor {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 80px;
  height: 80px;
  pointer-events: none;
  opacity: 0.06;
  color: var(--accent);
  animation: floatDecor 8s ease-in-out infinite;
}

.poem-card:nth-child(even) .card-float-decor {
  animation-delay: -4s;
  top: auto;
  bottom: -15px;
  right: auto;
  left: -15px;
  transform: rotate(90deg);
}

@keyframes floatDecor {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50%      { transform: rotate(8deg) scale(1.05); }
}

.poem-card:nth-child(even) .card-float-decor {
  animation-name: floatDecorAlt;
}

@keyframes floatDecorAlt {
  0%, 100% { transform: rotate(90deg) scale(1); }
  50%      { transform: rotate(98deg) scale(1.05); }
}

/* Card corner squiggle (bottom-left of each card) */
.card-corner-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 60px;
  pointer-events: none;
  opacity: 0.08;
  color: var(--accent);
}

.card-number {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
}

.card-title {
  font-family: var(--font-poetry);
  font-size: clamp(1.4rem, 2vw, 1.7rem);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.card-preview {
  font-family: var(--font-poetry);
  font-size: clamp(1.2rem, 1.7vw, 1.3rem);
  color: var(--text-secondary);
  line-height: 1.75;
  flex: 1;
}

.card-date {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin: 1.2rem 0;
}

.card-read {
  padding: 0.9rem 1.6rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, background-color 0.3s;
  align-self: flex-start;
  text-decoration: none;
  display: inline-block;
}

.card-read:hover {
  color: var(--bg-primary);
  background-color: var(--accent);
  border-color: var(--accent);
}

/* ============================================
   TRANSLATION CARDS — figure, badge, layout
   ============================================ */
.translation-card {
  position: relative;
}

/* Card figure — cover image with copyright */
.card-figure {
  width: 100%;
  aspect-ratio: 3 / 4;
  margin: 0 0 1.2rem 0;
  padding: 0;
  overflow: hidden;
  border-radius: 2px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  position: relative;
  background: var(--bg-primary, #0d0d0f);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Empty image placeholder — show a subtle icon */
.card-figure img[src=""] {
  visibility: hidden;
}
/* :has() fallback — JS adds .no-image class for browsers without :has() support */
.card-figure:has(img[src=""]),
.card-figure.no-image {
  background: linear-gradient(
    135deg,
    var(--bg-primary, #0d0d0f) 0%,
    rgba(240,215,140,0.04) 50%,
    var(--bg-primary, #0d0d0f) 100%
  );
}
.card-figure:has(img[src=""])::after,
.card-figure.no-image::after {
  content: "IMAGE";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono, 'Space Mono', monospace);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-muted, rgba(255,255,255,0.25));
  opacity: 0.5;
}

.card-figure figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono, 'Space Mono', monospace);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.7);
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  text-align: right;
}

/* Wide image variant — add data-figure="wide" to .translation-card
   to switch from portrait (3:4) to landscape (16:9).
   Uses object-fit: contain so the full image is visible. */
[data-figure="wide"] .card-figure {
  aspect-ratio: 16 / 9;
}

[data-figure="wide"] .card-figure img {
  object-fit: contain;
  background: var(--bg-primary, #0d0d0f);
}

/* Publication language badge — simple, clean, no glow */
.card-lang-badge {
  display: inline-block;
  font-family: var(--font-mono, 'Space Mono', monospace);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary, rgba(255,255,255,0.6));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  padding: 0.25rem 0.6rem;
  border-radius: 2px;
  margin-bottom: 1rem;
  background: transparent;
}

/* ============================================
   SECTION GLOW EDGES — reusable on card sections
   Same visual style as the poems reader glow margins
   ============================================ */
.has-section-glow {
  position: relative;
}

.section-glow-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.section-glow-edge.left {
  left: 0;
  background: linear-gradient(to right,
    var(--accent-glow, rgba(240,215,140,0.15)) 0%,
    transparent 100%);
}

.section-glow-edge.right {
  right: 0;
  background: linear-gradient(to left,
    var(--accent-glow, rgba(240,215,140,0.15)) 0%,
    transparent 100%);
}

.section-glow-edge.visible {
  opacity: 1;
}

/* Progressive gold line inside section glow */
.section-glow-line {
  position: absolute;
  top: 0;
  width: 1.5px;
  /* SCROLL-028: scaleY instead of height — see .glow-line note above. */
  height: 100%;
  transform: scaleY(0);
  transform-origin: top center;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--accent, #f0d78c) 0%,
    var(--accent, #f0d78c) 85%,
    transparent 100%
  );
  box-shadow:
    0 0 6px var(--accent-glow, rgba(240,215,140,0.4)),
    0 0 14px var(--accent-glow, rgba(240,215,140,0.2));
  transition: transform 0.35s ease-out;
}

.section-glow-edge.left .section-glow-line {
  right: 0;
}

.section-glow-edge.right .section-glow-line {
  left: 0;
}

/* ============================================
   SCROLL INDICATOR — inside poem frame, bottom zone
   Sits in the frame's padding-bottom area.
   height = frame padding-bottom − 4px so it
   fills from just under the dots to 2px above
   the card's bottom border.
   Line (flex:1) grows downward → SCROLL label
   flush at the bottom.
   Keyframe namespaced vs home.css scrollLine.
   ============================================ */
.poems-scroll-indicator {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  z-index: 10;
  pointer-events: none;
}

.poems-scroll-indicator .scroll-line {
  /* Fixed dimensions — SVG flex children collapse in Firefox without explicit height */
  display: block;
  width: 1px;
  height: 40px;
}
.poems-scroll-indicator .scroll-line-base {
  stroke: var(--border);
  stroke-width: 2;
}
.poems-scroll-indicator .scroll-line-dash {
  /* stroke-dasharray: 8 unit bright segment, 100 unit gap (period 108 >> viewBox 40).
     stroke-dashoffset 10  → segment at y [-10, -2]  = above line, invisible.
     stroke-dashoffset -42 → segment at y [ 42,  50] = below line, invisible.
     Animating 10 → -42 sweeps the segment cleanly top → bottom.
     GPU-composited on SVG — reliable in Chrome, Firefox, Safari. */
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 15 100;
  stroke-dashoffset: 10;
  animation: poemsScrollLine 2s ease-in-out infinite;
}

.poems-scroll-indicator .scroll-text {
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-transform: uppercase;
  line-height: 1;
}

@keyframes poemsScrollLine {
  0%   { stroke-dashoffset:  10; }  /* segment above line */
  100% { stroke-dashoffset: -42; }  /* segment below line */
}

/* Mobile: frame is natural height (not sticky) — hide indicator */
@media (max-width: 768px) {
  .poems-scroll-indicator { display: none; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .poem-frame-container {
    padding: 3rem 2rem 1rem 2rem;
  }

  .poem-nav.prev { left: -12px; }
  .poem-nav.next { right: -12px; }

  .poems-index-section .poems-cards,
  .poems-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* <= 768px: linearise the reader — no scroll-hijack, natural flow */
@media (max-width: 768px) {
  .poems-reader {
    height: auto !important; /* override JS-set height */
  }

  .reader-wrapper {
    position: relative; /* disable sticky */
    top: auto;
    padding: 1rem 0;
  }

  .poem-frame-container {
    height: auto;
    min-height: 0;
    max-width: 100%;
    padding: 2rem 1.5rem 1.5rem 1.5rem;
  }

  .poems-scroll-container {
    position: relative;
    overflow: visible;
  }

  /* Show only active slide, let it flow naturally */
  .poem-slide {
    position: relative;
    top: auto; left: auto; right: auto; bottom: auto;
    padding: 1rem 0;
  }

  .poem-slide:not(.active) {
    display: none;
  }

  .poem-slide.active {
    position: relative;
    display: block;
  }

  /* Fixed arrows on mobile — visible only when poem reader is in viewport */
  .poem-nav {
    display: none;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    opacity: 0.85;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  .poem-nav.reader-visible {
    display: flex;
  }
  .poem-nav.prev { left: 8px; }
  .poem-nav.next { right: 8px; }

  .poems-index-section .poems-cards,
  .poems-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .poems-hero {
    padding: 4.5rem var(--padding-mobile) 3rem;
    min-height: 40vh;
  }

  .poems-index-section {
    padding: 2rem 0.5rem;
  }

  .poems-index-section .poems-cards,
  .poems-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .poems-index-section .poem-card,
  .poem-card {
    padding: 1rem 0.6rem;
  }

  /* 2-col: use portrait aspect so 2 rows fit on screen */
  .card-figure {
    aspect-ratio: 3 / 4;
  }

  .poem-text {
    font-size: 1.05rem;
    line-height: 1.85;
  }

  /* Scale citation down to stay visually smaller than the poem text.
     Space Mono's large x-height makes it appear bigger than Cormorant
     Garamond at similar px values, so the gap must be generous. */
  .poem-citation {
    font-size: 0.7rem;        /* 11.2px — clear hierarchy below 1.05rem poem text */
  }

  .card-title {
    font-size: 1.35rem;
  }

  .section-corner-decor {
    width: 80px;
    height: 80px;
  }

  /* Glow edges narrower on mobile */
  .section-glow-edge {
    width: 20px;
  }
}

@media (max-width: 480px) {
  .poem-progress {
    flex-direction: column;
    gap: 0.5rem;
  }

  .progress-bar {
    width: 150px;
  }

  .poem-frame-container {
    padding: 2.5rem 1rem 1rem 1rem;
  }

  .poem-title {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
  }
}

/* ============================================
   TRANSLATION CARD IMAGE HOVER + FULLSCREEN
   Cross-platform: no Fullscreen API, uses
   position: fixed overlay modal instead.
   ============================================ */

/* Hover effect on translation card images */
.translation-card .card-figure {
  cursor: pointer;
  overflow: hidden;
}

.translation-card .card-figure img {
  transition: transform 0.45s ease, filter 0.45s ease;
}

.translation-card .card-figure:hover img {
  transform: scale(1.04);
  filter: brightness(1.08);
}

/* Subtle border glow on hover */
.translation-card .card-figure::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  border: 2px solid transparent;
  border-radius: 2px;
  transition: border-color 0.35s ease;
  z-index: 2;
  pointer-events: none;
}

.translation-card .card-figure:hover::before {
  border-color: var(--accent, #f0d78c);
}


/* ============================================
   DESKTOP MOUSE: reduce dot tap-target
   44px touch targets are not needed when the
   pointer is a precise mouse/trackpad.
   @media(pointer:fine) = mouse; coarse = touch.
   ============================================ */
@media (pointer: fine) {
  .poem-dot {
    /* Visible dot stays 13px; click zone shrinks from 44px to 29px */
    padding: 8px;
  }
  .poem-dots {
    padding: 0.25rem 1rem 0.15rem; /* was: 1rem / 0.5rem */
    gap: 0.4rem 0.75rem;
    column-gap: max(0.75rem, 12px);
    row-gap: 0.4rem;
  }
}


/* ============================================
   SHORT DESKTOP SCREENS — small laptops
   (MacBook Air 900px, 1280×800, etc.)

   Reclaims vertical space by compacting the
   progress bar gap, wrapper padding, frame
   padding, and frame decorations — giving the
   poem text ~80-100px more height.
   ============================================ */
@media (max-height: 820px) and (min-width: 769px) {

  /* Shorten frame decorations so reduced padding stays safe */
  .frame-decoration {
    height: 20px;
  }
  .frame-decoration.top {
    top: 0.65rem;
  }
  .frame-decoration.bottom {
    padding-top: 0.1rem;
  }

  /* Compact frame padding at medium-short screens */
  .poem-frame-container {
    padding: 2.5rem 2.5rem 1rem 2.5rem;
    height: calc(100vh  - 108px);
    height: calc(100svh - 108px);
  }

  /* Compact gap at medium-short screens */
  .poems-scroll-indicator {
    gap: 0.4rem;
  }

  /* Tighter dots at short screens */
  .poem-dots {
    padding: 0.25rem 1rem 0.15rem;
  }
}

/* Very short screens (1024×640 chromebooks, zoomed laptops) */
@media (max-height: 700px) and (min-width: 769px) {

  .poem-frame-container {
    padding: 1.8rem 2rem 0.75rem 2rem;
    height: calc(100vh  - 108px);
    height: calc(100svh - 108px);
    min-height: 300px;
  }

  /* At this size decorations take up too much; collapse them */
  .frame-decoration {
    height: 12px;
    opacity: 0.5;
  }
  .frame-decoration.top {
    top: 0.4rem;
  }

  /* Keep indicator visible but compact — just the animated line, no text */
  .poems-scroll-indicator {
    gap: 0;
  }
  .poems-scroll-indicator .scroll-line {
    height: 28px;
  }
  .poems-scroll-indicator .scroll-text {
    display: none;
  }
}

/* ============================================================
   SCROLL-008 — render cost containment (audit P1-3, 2026-06-13)
   Translation cards only. DELIBERATELY NOT applied to the slide
   reader's .poem-card[data-poem] — poems.js measures those
   (scrollHeight/rects) and skipped rendering would break it.
   Older browsers ignore both properties (progressive perf only).
   ============================================================ */
.poem-card.translation-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 460px;
}

