/* ===================================================================
   HOME PAGE — index.html only
   =================================================================== */

/* Typography utilities used only on homepage */
.tag {
  color: var(--muted);
  margin: 0 0 var(--space-3) 0;
  font-size: var(--font-size-lg);
}

.cta-center {
  text-align: center;
  margin-top: var(--space-4);
}


/* Hero
   ------------------------------------------------------------------- */

.hero-wrapper {
  width: 100%;
  background: var(--overlay-surface);
  border-bottom: 1px solid var(--border);
}

.hero-container {
  max-width: var(--content-width-wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  align-items: center;
  padding: clamp(var(--space-5), 8vw, var(--section-padding-max)) var(--space-3);
}

.hero-content {
  padding-right: var(--space-4);
}

.hero-eyebrow {
  display: block;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-tight);
  margin: 0 0 var(--space-2) 0;
  text-align: left;
}

.hero-content h1 {
  font-size: clamp(var(--font-size-2xl), 4.5vw, var(--font-size-3xl));
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-3) 0;
  text-align: left;
}

.hero-content .tag {
  font-size: clamp(var(--font-size-base), 1.8vw, var(--font-size-lg));
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  margin: 0 0 var(--space-4) 0;
  text-align: left;
}

.hero-ctas {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.hero-image {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}


/* Carousel
   ------------------------------------------------------------------- */

.carousel {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.carousel-slides {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.carousel-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
}

.carousel-slide.active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: rgba(0, 0, 0, 0.6);
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition-fast);
  z-index: 2;
}

.carousel-arrow:hover {
  color: rgba(0, 0, 0, 0.9);
}

.carousel-arrow svg {
  width: 24px;
  height: 48px;
}

.carousel-arrow-left {
  left: calc(-40px - var(--space-1));
}

.carousel-arrow-right {
  right: calc(-40px - var(--space-1));
}

.carousel-dots {
  display: flex;
  gap: var(--space-1);
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background var(--transition-fast);
  padding: 0;
}

.carousel-dot:hover {
  background: rgba(0, 0, 0, 0.6);
}

.carousel-dot.active {
  background: rgba(0, 0, 0, 0.8);
}

/* Dark mode carousel colors */
@media (prefers-color-scheme: dark) {
  .carousel-dot {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.3);
  }

  .carousel-dot:hover {
    background: rgba(255, 255, 255, 0.6);
  }

  .carousel-dot.active {
    background: white;
  }

  .carousel-arrow {
    color: rgba(255, 255, 255, 0.6);
  }

  .carousel-arrow:hover {
    color: rgba(255, 255, 255, 0.9);
  }
}

/* Manual theme overrides for carousel */
html.theme-dark .carousel-dot {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.3);
}

html.theme-dark .carousel-dot:hover {
  background: rgba(255, 255, 255, 0.6);
}

html.theme-dark .carousel-dot.active {
  background: white;
}

html.theme-dark .carousel-arrow {
  color: rgba(255, 255, 255, 0.6);
}

html.theme-dark .carousel-arrow:hover {
  color: rgba(255, 255, 255, 0.9);
}

html.theme-light .carousel-dot {
  border-color: rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.3);
}

html.theme-light .carousel-dot:hover {
  background: rgba(0, 0, 0, 0.6);
}

html.theme-light .carousel-dot.active {
  background: rgba(0, 0, 0, 0.8);
}

html.theme-light .carousel-arrow {
  color: rgba(0, 0, 0, 0.6);
}

html.theme-light .carousel-arrow:hover {
  color: rgba(0, 0, 0, 0.9);
}


/* Quick Start Section
   ------------------------------------------------------------------- */

.quickstart-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.quickstart-content h2 {
  font-size: var(--font-size-xl);
  margin: 0;
  text-align: center;
}

.quickstart-list {
  list-style: none;
  counter-reset: quickstart-counter;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.quickstart-list li {
  counter-increment: quickstart-counter;
  position: relative;
  padding-top: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-align: center;
}

.quickstart-list li::before {
  content: counter(quickstart-counter);
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: var(--icon-size-numbered);
  height: var(--icon-size-numbered);
  border-radius: 50%;
  background: var(--numbered-circle-bg);
  color: var(--numbered-circle-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
}

.quickstart-list li strong {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin: 0;
}

.quickstart-list li p {
  margin: 0;
  color: var(--muted);
  line-height: var(--line-height-normal);
  font-size: var(--font-size-sm);
}


/* Card
   ------------------------------------------------------------------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--overlay-surface);
  padding: var(--space-3);
  box-shadow: var(--shadow);
  backdrop-filter: var(--backdrop-blur-sm);
}


/* Trust Bar
   ------------------------------------------------------------------- */

.trust-bar {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-4) 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  text-align: center;
}
.trust-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
}
.trust-stat {
  font-size: var(--font-size-2xl, 1.5rem);
  font-weight: var(--font-weight-bold);
  color: var(--brand);
  line-height: 1.1;
}
.trust-label {
  font-size: var(--font-size-sm);
  color: var(--muted);
}
.trust-quote .trust-label {
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-semibold, 600);
  font-style: italic;
  color: var(--brand);
  line-height: 1.3;
}
.trust-source {
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--muted);
}


/* How It Works Section
   ------------------------------------------------------------------- */

.how-it-works {
  margin-top: var(--space-5);
}

.how-it-works h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-2);
}

/* How It Works Diagram (Asset 2) */
.how-it-works-diagram {
  display: block;
  margin: var(--space-5) auto;
  max-width: 960px;
  width: 100%;
}

.how-it-works-diagram img {
  width: 100%;
  height: auto;
  display: block;
}

/* Mobile: Vertical layout */
@media (max-width: 767px) {
  .how-it-works-diagram {
    max-width: 360px;
  }
}

.how-it-works-video {
  max-width: var(--content-width-narrow);
  margin: var(--space-5) auto 0 auto;
  text-align: center;
}

.how-it-works-video h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-3) 0;
  color: var(--text);
}

.how-it-works-video video {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  background: var(--bg);
}


/* Features Section
   ------------------------------------------------------------------- */

.features-section {
  margin-top: var(--space-5);
}

.features-section h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-4);
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--overlay-surface);
  padding: var(--space-3);
  box-shadow: var(--shadow);
  backdrop-filter: var(--backdrop-blur-sm);
  overflow: hidden;
}

.feature-card img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.feature-card h3,
.feature-card h2 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-1) 0;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  line-height: var(--line-height-normal);
}


/* Review Modes Section
   ------------------------------------------------------------------- */

.review-modes-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  align-items: center;
}

.review-modes-text h2 {
  font-size: var(--font-size-xl);
  margin: 0 0 var(--space-2) 0;
  text-align: left;
}

.review-modes-text .section-intro {
  text-align: left;
  margin: 0 0 var(--space-4) 0;
}

.review-modes-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0 0 var(--space-3) 0;
}

.review-mode-description h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-1) 0;
  color: var(--text);
}

.review-mode-description p {
  margin: 0;
  color: var(--muted);
  line-height: var(--line-height-normal);
}

.review-modes-footer {
  text-align: left;
  margin: var(--space-2) 0 0 0;
  color: var(--muted);
  font-size: var(--font-size-base);
  font-style: italic;
}

/* Review Modes Diagram */
.review-modes-visual {
  display: flex;
  align-items: center;
  justify-content: center;
}

.review-modes-diagram {
  width: 100%;
  max-width: 580px;
  height: auto;
  display: block;
}

/* Diagram theme switching */
.diagram-light {
  display: block;
}

.diagram-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .diagram-light {
    display: none;
  }

  .diagram-dark {
    display: block;
  }
}

/* Manual theme overrides for diagrams */
html.theme-dark .diagram-light {
  display: none;
}

html.theme-dark .diagram-dark {
  display: block;
}

html.theme-light .diagram-light {
  display: block;
}

html.theme-light .diagram-dark {
  display: none;
}

/* Mobile: Stack text and diagram vertically */
@media (max-width: 900px) {
  .review-modes-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .review-modes-text h2 {
    text-align: center;
  }

  .review-modes-text .section-intro {
    text-align: center;
  }

  .review-modes-footer {
    text-align: center;
  }

  .review-modes-visual {
    order: 2;
  }

  .review-modes-diagram {
    max-width: 100%;
  }
}


/* Email Signup & FAQ Sections
   ------------------------------------------------------------------- */

.email-signup {
  margin-top: var(--space-5);
}

.email-signup .card {
  text-align: center;
  padding: var(--space-4);
  max-width: 600px;
  margin: 0 auto;
}

.email-signup h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-3);
}

.faq-section {
  margin-top: 0;
}

.faq-section h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-4);
}

.faq-list {
  max-width: var(--content-width-narrow);
  margin: 0 auto;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--overlay-surface);
  backdrop-filter: var(--backdrop-blur-sm);
  margin-bottom: var(--space-2);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: var(--space-3);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  transition: background-color var(--transition-fast);
  font-family: inherit;
}

.faq-question:hover {
  background: var(--overlay-header);
}

.faq-question::after {
  content: '+';
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--brand);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.faq-item.active .faq-question::after {
  content: '−';
  transform: rotate(0deg);
}

.faq-answer {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.faq-item.active .faq-answer {
  grid-template-rows: 1fr;
}

.faq-answer > div {
  min-height: 0;
}

.faq-answer p {
  padding: 0 var(--space-3) var(--space-3) var(--space-3);
  margin: 0;
  color: var(--muted);
  line-height: var(--line-height-normal);
}


/* ===================================================================
   MEDIA QUERIES — Homepage
   =================================================================== */

@media (min-width: 640px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quickstart-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quickstart-list {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .hero-container {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-3);
  }

  .hero-content {
    padding-right: 0;
    text-align: center;
  }

  .hero-eyebrow {
    text-align: center;
  }

  .hero-content h1 {
    text-align: center;
  }

  .hero-content .tag {
    text-align: center;
  }

  .hero-ctas {
    justify-content: center;
  }

  .hero-image {
    order: -1; /* Move image above text on mobile */
  }

  .trust-bar {
    flex-wrap: wrap;
  }

  .trust-item {
    flex: 1 1 40%;
  }

  .quickstart-list {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .quickstart-list li {
    padding-top: 0;
    padding-left: var(--space-5);
    text-align: left;
  }

  .quickstart-list li::before {
    left: 0;
    transform: none;
  }
}

@media (max-width: 640px) {
  .trust-item {
    flex: 1 1 100%;
  }

  /* Hero mobile adjustments */
  .hero-container {
    padding: var(--space-4) var(--space-2);
  }

  /* Carousel mobile adjustments - hide arrows on mobile */
  .carousel-arrow {
    display: none;
  }
}

/* =================================================================
   PREVIEW CHUNK 1 (take 2) — hero depth, no window chrome
   Just the layered float + a touch more copy weight. Revert = delete.
   ================================================================= */

/* Desktop only — below 900px the live rule stacks the hero (image on top) */
@media (min-width: 901px) {
  .hero-container {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.15fr);
    gap: var(--space-4);
  }
  .hero-content { padding-right: var(--space-2); }
}

/* Shadow lives on the slides box (its overflow:hidden was clipping the
   image's own shadow before, which is why the live hero reads flat). */
.carousel-slides {
  border-radius: var(--radius);
  box-shadow:
    0 1px 1px rgba(18, 42, 43, 0.05),
    0 10px 28px rgba(18, 42, 43, 0.12),
    0 34px 64px -22px rgba(18, 42, 43, 0.26);
}

.hero-image img {
  border-radius: var(--radius);
  box-shadow: none;
}


/* =================================================================
   PREVIEW CHUNK 2 (take 2) — keep the cards, give them real depth
   Revert = delete this block.
   ================================================================= */

.feature-card {
  box-shadow:
    0 1px 1px rgba(18, 42, 43, 0.05),
    0 8px 22px rgba(18, 42, 43, 0.10),
    0 24px 48px -22px rgba(18, 42, 43, 0.20);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 1px 1px rgba(18, 42, 43, 0.06),
    0 12px 28px rgba(18, 42, 43, 0.13),
    0 36px 64px -22px rgba(18, 42, 43, 0.28);
}

/* The Anki logo isn't a screenshot — keep it a tidy centered emblem
   inside its card rather than a 280px slab. */
.feature-card:nth-of-type(4) img {
  width: auto;
  max-height: 150px;
  display: block;
  margin: var(--space-3) auto var(--space-4);
}

/* =================================================================
   PREVIEW CHUNK 3 — confident section-heading scale (sharper hierarchy)
   Revert = delete this block.
   ================================================================= */

.how-it-works h2,
.features-section h2,
.quickstart-content h2,
.review-modes-text h2,
.faq-section h2,
.email-signup h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.015em;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-3);
}

/* Give the supporting intro a touch more room under the bigger title */
.section-intro { margin-bottom: var(--space-4); }

/* =================================================================
   PREVIEW CHUNK 4 — let the demo video float (and breathe a bit bigger)
   Revert = delete this block.
   ================================================================= */

.how-it-works-video {
  max-width: 960px;            /* match the diagram width, up from 800 */
}

.how-it-works-video video {
  border: 1px solid var(--border);
  box-shadow:
    0 1px 1px rgba(18, 42, 43, 0.05),
    0 10px 28px rgba(18, 42, 43, 0.12),
    0 34px 64px -22px rgba(18, 42, 43, 0.26);
}


/* =================================================================
   Home section-heading scale. (The site-wide ~20% scale-down — spacing,
   display-type tokens, and the navbar/logo height — now lives in the
   shared theme.css / styles.css so every readpindu page matches.)
   ================================================================= */

/* Re-tune the home section headings to the smaller scale */
.how-it-works h2,
.features-section h2,
.quickstart-content h2,
.review-modes-text h2,
.faq-section h2,
.email-signup h2 {
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
}


/* =================================================================
   PREVIEW CHUNK 7 (take 2) — diagram is the centerpiece, video demoted
   Revert = delete this block.
   ================================================================= */

/* Featured diagram */
.how-it-works-diagram {
  max-width: 1000px;
  margin: var(--space-4) auto var(--space-5);
}

/* Demoted supporting clip — small, centered, keeps its float */
.how-it-works-video {
  max-width: 520px;
  margin: 0 auto;
}

.hiw-cap {
  margin: 0 0 var(--space-2);
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-tight);
  text-transform: uppercase;
  color: var(--text);
}

/* Unified secondary "read more" link — quiet right-aligned teal arrow.
   The filled pill is reserved for the primary install CTA only. */
/* Rule: a secondary link aligns to the right edge of the thing it owns. */
.section-more {
  margin: var(--space-3) 0 0;
  text-align: right;
  letter-spacing: 0.02em;
}
.section-more a {
  font-weight: 500;
  text-decoration: none;
  color: var(--link);
}
.section-more a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* How-it-works link hugs the video frame's edge (the video supplies the edge).
   The 4-step section has no figure edge, so manufacture one with a hairline. */
.quickstart-content .section-more {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* =================================================================
   PREVIEW CHUNK 10 — fix "Full Anki integration" card alignment
   Emblem centered in the free space; caption bottom-aligned with siblings.
   Revert = delete this block.
   ================================================================= */

.feature-card:nth-of-type(4) {
  display: flex;
  flex-direction: column;
}
/* auto margins absorb the vertical free space → emblem centers above,
   the h3 + p settle at the bottom of the card */
.feature-card:nth-of-type(4) img {
  margin: auto;
}


/* =================================================================
   PREVIEW CHUNK 12 — inline loop diagram (themes via CSS vars)
   Replaces the SVG files. Revert = delete this block + restore <picture>.
   ================================================================= */

.hiw-diagram {
  display: block;
  width: 100%;
  max-width: 680px;
  height: auto;
  margin: var(--space-4) auto var(--space-5);
  /* Anki rating colors aren't theme tokens — tuned per mode for contrast */
  --r-good: #2E7D32;
  --r-hard: #A9790C;
  --r-again: #C0392B;
}
@media (prefers-color-scheme: dark) {
  .hiw-diagram { --r-good: #5BBE6E; --r-hard: #D8B24A; --r-again: #FF6B6B; }
}
html.theme-dark .hiw-diagram { --r-good: #5BBE6E; --r-hard: #D8B24A; --r-again: #FF6B6B; }
html.theme-light .hiw-diagram { --r-good: #2E7D32; --r-hard: #A9790C; --r-again: #C0392B; }

/* Surfaces & strokes */
.hiw-diagram .d-surface { fill: var(--overlay-surface); }
.hiw-diagram .d-stroke { stroke: var(--border); stroke-width: 1; fill: none; }
.hiw-diagram .d-chip { fill: var(--overlay-surface); stroke: var(--border); stroke-width: 1; }

/* Type */
.hiw-diagram text { font-family: 'IBM Plex Sans', system-ui, sans-serif; }
.hiw-diagram .d-title { fill: var(--text); font-weight: 600; font-size: 16px; }
.hiw-diagram .d-cap { fill: var(--muted); font-weight: 400; font-size: 13px; }
.hiw-diagram .d-legend { fill: var(--muted); font-weight: 400; font-size: 12px; }
.hiw-diagram .d-hanzi { fill: var(--text); font-family: 'Noto Sans SC', sans-serif; font-weight: 500; font-size: 24px; }
.hiw-diagram .d-hanzi-sm { fill: var(--text); font-family: 'Noto Sans SC', sans-serif; font-weight: 500; font-size: 17px; }
.hiw-diagram .d-arc-label { fill: var(--muted); font-weight: 500; font-size: 13px; }
.hiw-diagram .d-arc-strong { fill: var(--text); font-weight: 600; font-size: 13px; }
.hiw-diagram .d-chip-num { font-weight: 600; font-size: 14px; }
.hiw-diagram .d-chip-lbl { fill: var(--muted); font-weight: 400; font-size: 12px; }

/* Accent fills */
.hiw-diagram .d-teal,  .hiw-diagram .d-dot-teal  { fill: var(--brand); }
.hiw-diagram .d-terra, .hiw-diagram .d-dot-terra { fill: var(--accent); }
.hiw-diagram .d-good  { fill: var(--r-good); }
.hiw-diagram .d-hard  { fill: var(--r-hard); }
.hiw-diagram .d-again { fill: var(--r-again); }

/* Arcs */
.hiw-diagram .d-arc { stroke: var(--muted); stroke-width: 2; fill: none; opacity: 0.85; }
.hiw-diagram .d-arc-return { stroke: var(--text); stroke-width: 2.5; fill: none; }
.hiw-diagram .d-ah { fill: var(--muted); }
.hiw-diagram .d-ah-bold { fill: var(--text); }

/* Rating underlines */
.hiw-diagram .u-good  { stroke: var(--r-good);  stroke-width: 3; stroke-linecap: round; }
.hiw-diagram .u-hard  { stroke: var(--r-hard);  stroke-width: 3; stroke-linecap: round; }
.hiw-diagram .u-again { stroke: var(--r-again); stroke-width: 3; stroke-linecap: round; }

/* CHUNK 12 fix — solid card backgrounds for diagram nodes */
.hiw-diagram { --d-card: #FCFBF8; }
@media (prefers-color-scheme: dark) { .hiw-diagram { --d-card: #243F41; } }
html.theme-dark  .hiw-diagram { --d-card: #243F41; }
html.theme-light .hiw-diagram { --d-card: #FCFBF8; }
.hiw-diagram .d-card-fill { fill: var(--d-card); }

/* =================================================================
   PREVIEW CHUNK 13 — staged reveal for the loop diagram
   Mirrors the .reveal-demo / .rv-N pattern from prose.css (fig-1),
   driven by /js/figure-reveal.js. Revert = delete this block + the
   reveal-demo class + figure-reveal.js script tag.
   ================================================================= */

@keyframes hiw-rv-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Default state is visible (no-JS safe); .playing replays the staggered
   fade-in via the keyframe's `both` backwards fill, like fig-1. */
.hiw-diagram.reveal-demo { cursor: pointer; }
.hiw-diagram.reveal-demo.playing .rv-1 { animation: hiw-rv-rise 0.5s ease-out 0.15s both; }
.hiw-diagram.reveal-demo.playing .rv-2 { animation: hiw-rv-rise 0.5s ease-out 0.55s both; }
.hiw-diagram.reveal-demo.playing .rv-3 { animation: hiw-rv-rise 0.5s ease-out 0.95s both; }
.hiw-diagram.reveal-demo.playing .rv-4 { animation: hiw-rv-rise 0.6s ease-out 1.40s both; }

@media (prefers-reduced-motion: reduce) {
  .hiw-diagram.reveal-demo .rv-1,
  .hiw-diagram.reveal-demo .rv-2,
  .hiw-diagram.reveal-demo .rv-3,
  .hiw-diagram.reveal-demo .rv-4 { opacity: 1; animation: none !important; }
}

.hiw-figure { margin: 0; }

/* =================================================================
   PREVIEW CHUNK 14 — diagram + video side-by-side; footer-rule link
   Revert = delete this block + unwrap .hiw-row + move link back.
   ================================================================= */

.hiw-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(var(--space-3), 4vw, var(--space-5));
  align-items: center;
  margin: var(--space-4) 0 var(--space-2);
}
.hiw-row .hiw-figure,
.hiw-row .hiw-diagram { width: 100%; max-width: 100%; margin: 0; }
.hiw-row .how-it-works-video { max-width: 100%; margin: 0; }

@media (max-width: 860px) {
  .hiw-row { grid-template-columns: 1fr; gap: var(--space-5); }
}

/* Full-walkthrough link: hairline-above + right-aligned, matching the
   "Get started in 4 steps" footer link. */
.how-it-works .section-more {
  border-top: 1px solid var(--border);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
}

/* =================================================================
   PREVIEW CHUNK 15 — full-width section, bigger diagram, video modal
   Revert = delete this block (+ restore wrap nesting & inline video).
   ================================================================= */

/* Section spans wide so its edges align with the section below */
.hiw-container {
  max-width: var(--content-width-wide);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* Diagram gets the bulk of the width (≈ its full size); video is a thumbnail */
.hiw-row { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: center; }

.hiw-video {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Thumbnail: poster + play badge, opens the modal */
.hiw-video-thumb {
  position: relative;
  display: block;
  width: 100%;
  max-width: 460px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--lightest);
  box-shadow:
    0 1px 1px rgba(18, 42, 43, 0.05),
    0 8px 22px rgba(18, 42, 43, 0.10),
    0 24px 48px -22px rgba(18, 42, 43, 0.22);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.hiw-video-thumb:hover { transform: translateY(-3px); }
.hiw-video-thumb img { display: block; width: 100%; height: auto; }

.hiw-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 58px; height: 58px;
  border-radius: var(--radius-pill);
  background: rgba(18, 42, 43, 0.62);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast);
}
.hiw-video-thumb:hover .hiw-play { background: var(--brand); }
.hiw-play svg { width: 26px; height: 26px; margin-left: 3px; }

/* Shaded full-screen modal */
.hiw-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
  background: rgba(10, 24, 25, 0.84);
  backdrop-filter: blur(3px);
}
.hiw-modal[hidden] { display: none; }
.hiw-modal-video {
  width: 80vw;
  max-width: 1280px;
  max-height: 80vh;
  height: auto;
  border-radius: var(--radius);
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.hiw-modal-close {
  position: absolute;
  top: 16px; right: 24px;
  width: 40px; height: 40px;
  background: none; border: none;
  color: #fff; font-size: 34px; line-height: 1;
  cursor: pointer; opacity: 0.85;
}
.hiw-modal-close:hover { opacity: 1; }

.hiw-diagram .d-center { fill: var(--text); font-style: italic; font-weight: 500; font-size: 21px; }

.hiw-diagram .d-ink { fill: var(--text); }

/* =================================================================
   PREVIEW CHUNK 16 — card 3 click-to-mark demo (cursor + tally count-up)
   Adapted from fig-5's .click-demo. Plays with the diagram reveal.
   Default / no-JS / reduced-motion = final state (4/1/1, both underlines).
   ================================================================= */

/* Default (resting) state */
.hiw-diagram .cd3-tally0,
.hiw-diagram .cd3-tally1 { opacity: 0; }
.hiw-diagram .cd3-tally2 { opacity: 1; }
.hiw-diagram .cd3-cursor { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .hiw-diagram.reveal-demo.playing .cd3-cursor { animation: cd3-cursor-path 3s ease-in-out 1.6s both; }
  .hiw-diagram.reveal-demo.playing .cd3-uhard  { animation: cd3-fade-in 0.3s ease-out 2.5s both; }
  .hiw-diagram.reveal-demo.playing .cd3-uagain { animation: cd3-fade-in 0.3s ease-out 3.7s both; }
  .hiw-diagram.reveal-demo.playing .cd3-tally0 { animation: cd3-hide 0.25s ease 2.5s both; }
  .hiw-diagram.reveal-demo.playing .cd3-tally1 { animation: cd3-blip 1.2s ease 2.5s both; }
  .hiw-diagram.reveal-demo.playing .cd3-tally2 { animation: cd3-show 0.25s ease 3.7s both; }
}

@keyframes cd3-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cd3-hide    { from { opacity: 1; } to { opacity: 0; } }
@keyframes cd3-show    { from { opacity: 0; } to { opacity: 1; } }
@keyframes cd3-blip    { 0% { opacity: 0; } 10% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; } }

@keyframes cd3-cursor-path {
  0%   { transform: translate(150px, 545px) scale(1);   opacity: 0; }
  5%   { transform: translate(150px, 545px) scale(1);   opacity: 1; }
  27%  { transform: translate(180px, 470px) scale(1);   opacity: 1; }
  31%  { transform: translate(180px, 470px) scale(0.8); opacity: 1; }
  35%  { transform: translate(180px, 470px) scale(1);   opacity: 1; }
  58%  { transform: translate(276px, 470px) scale(1);   opacity: 1; }
  62%  { transform: translate(276px, 470px) scale(0.8); opacity: 1; }
  66%  { transform: translate(276px, 470px) scale(1);   opacity: 1; }
  70%  { transform: translate(276px, 470px) scale(0.8); opacity: 1; }
  74%  { transform: translate(276px, 470px) scale(1);   opacity: 1; }
  90%  { transform: translate(276px, 470px) scale(1);   opacity: 1; }
  100% { transform: translate(304px, 500px) scale(1);   opacity: 0; }
}

/* =================================================================
   PREVIEW CHUNK 17 — card 1 flashcard stacks (false-front, heavier grey)
   Revert = delete this block + restore card-1 single stack.
   ================================================================= */

.hiw-diagram .d-fcard {
  fill: var(--d-card);
  stroke: var(--muted);
  stroke-width: 1.2;
}
.hiw-diagram .d-fc-hanzi {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 600;
  font-size: 16px;
}
.hiw-diagram .d-fc-py  { fill: var(--muted); font-size: 9px; }
.hiw-diagram .d-fc-def { fill: var(--muted); font-size: 9px; }
.hiw-diagram .d-fc-rule { stroke: var(--muted); stroke-width: 0.75; opacity: 0.5; }
.hiw-diagram .d-fc-cap { fill: var(--muted); font-size: 11px; }

.hiw-diagram .d-gloss { fill: var(--muted); font-style: italic; font-size: 11px; }

/* =================================================================
   PREVIEW CHUNK 18 — mobile How-it-works: stack row, vertical diagram
   Revert = delete this block.
   ================================================================= */

/* Vertical-chain diagram is desktop-hidden */
.hiw-diagram-m { display: none; }

@media (max-width: 860px) {
  /* Re-stack diagram over video (chunk 15's 2-col rule applies at all widths) */
  .hiw-row { grid-template-columns: 1fr; gap: var(--space-4); }
  /* Swap circular -> vertical chain */
  .hiw-diagram-d { display: none; }
  /* specificity must beat chunk-14's `.hiw-row .hiw-diagram { max-width:100% }` */
  .hiw-row .hiw-diagram-m { display: block; width: 100%; max-width: 300px; margin: 0 auto; }
}

/* =================================================================
   SECTION RHYTHM — consistent vertical spacing for top-level sections.
   Each region is a <section>; .home-section owns symmetric vertical
   padding, bands (.section-wrapper) carry only their bg/borders +
   internal padding, and the inner .wrap adds no vertical padding.
   ================================================================= */
.home-section { padding: clamp(var(--space-5), 6vw, var(--space-6)) 0; }
.home-section > .wrap { padding-top: 0; padding-bottom: 0; }

/* Replace the old ad-hoc per-section margins (now handled by .home-section) */
.how-it-works { margin-top: 0; }
.features-section { margin-top: 0; }
.email-signup { margin-top: 0; }

/* Bands sit flush; the adjacent .home-section padding sets the gap */
.section-wrapper { margin: 0; }

/* Trust bar: just the row + its divider; no extra outer margin */
.trust-bar { padding: 0 0 var(--space-4); margin-bottom: 0; }

/* Trust bar already has a divider, so it needs no bottom padding of its own —
   the gap to "How Pindu Works" is just that section's top padding (≈ half). */
#trust-bar { padding-bottom: 0; }

/* Float the diagram node cards like the other cards on the page.
   (SVG shapes take `filter`, not box-shadow; chained drop-shadows ≈ layered.) */
.hiw-diagram .d-card-fill {
  filter:
    drop-shadow(0 1px 1px rgba(18, 42, 43, 0.05))
    drop-shadow(0 6px 16px rgba(18, 42, 43, 0.13));
}
