/* Shared responsive refinements loaded after all scene styles. */

:root {
  --scene-max-width: 90rem;
  --scene-side-gap: clamp(1.25rem, 4vw, 5rem);
  --scene-nav-clearance: calc(var(--icon-left) + var(--icon-size) + 3.5rem);
  --caption-size: var(--text-caption-size);
  --caption-leading: var(--text-caption-leading);
}

/* Consistent captions and dates across data scenes. */
.scene8-date,
.scene9-date,
.scene10-date,
.scene11-date {
  font-family: var(--mono);
  font-size: var(--caption-size);
  line-height: var(--caption-leading);
  font-weight: 300;
  letter-spacing: 0.1em;
}

/* Keep full-screen content clear of the left navigation rail. */
.scene8-gallery,
.scene9-content,
.scene10-content,
.scene11-content,
.scene12-content,
.scene13-content {
  max-width: var(--scene-max-width);
}

@media (max-width: 81.25rem) {
  .scene8-title {
    margin-bottom: 2.5rem;
  }

  .scene8-gallery {
    gap: 1.5rem 1.25rem;
  }

  .scene8-photo {
    width: 8.25rem;
  }

  .scene9-content {
    inset: 6vh 5vw 5vh calc(5vw + 3rem);
  }

  .scene11-content {
    inset: 8vh 4vw 5vh calc(4vw + 3rem);
  }

  .scene12-content,
  .scene13-content {
    inset-inline: calc(4vw + 3rem) 4vw;
  }
}

@media (max-width: 56.25rem) {
  :root {
    --caption-size: 0.625rem;
    --caption-leading: 0.875rem;
    --scene-side-gap: 1.25rem;
    --scene-nav-clearance: 1.25rem;
  }

  .nav {
    height: 4.5rem;
  }

  .kolam-link {
    width: 2.25rem;
    height: 2.25rem;
  }

  .scroll-dots {
    display: none;
  }

  .small-text {
    max-width: calc(100vw - 2.5rem);
  }

  /* Gallery keeps two rows so all ten photos remain in one viewport. */
  .scene-8 {
    padding-inline: 1rem;
  }

  .scene8-title {
    width: min(32rem, 88vw);
    margin-bottom: 1.25rem;
  }

  .scene8-gallery {
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1rem 0.5rem;
  }

  .scene8-item {
    min-width: 0;
  }

  .scene8-photo {
    width: min(3.75rem, 16vw);
    margin-inline: auto;
  }

  .scene8-date {
    margin-block: 0 0.35rem;
    font-size: 0.5rem;
    letter-spacing: 0.05em;
    text-align: center;
    white-space: nowrap;
  }

  .scene8-item:nth-child(n+6) .scene8-date {
    margin-block: 0.35rem 0;
  }

  /* Length comparison table. */
  .scene9-content {
    inset: 5rem 1rem 2rem;
  }

  .scene9-list {
    row-gap: 0.5rem;
  }

  .scene9-row {
    grid-template-columns: 3.5rem minmax(0, 1fr);
    column-gap: 0.75rem;
  }

  .scene9-svg {
    width: 2.75rem;
    height: 2.75rem;
  }

  .scene9-date {
    font-size: 0.5rem;
    margin-top: 0.25rem;
  }

  .scene9-paths {
    gap: 0.3rem 0;
  }

  .scene9-segment + .scene9-segment {
    margin-left: 0.35rem;
  }

  .scene9-dots {
    gap: 0.3rem;
    margin-top: 0.35rem;
  }

  .scene9-dot {
    width: 0.1875rem;
    height: 0.1875rem;
  }

  .scene9-title {
    margin-top: 1rem;
  }

  /* Motif tally table. */
  .scene10-content {
    top: 4.75rem;
    right: 0.75rem;
    bottom: 2rem;
    left: 0.75rem;
  }

  .scene10-table {
    width: 100%;
    grid-template-columns: 2rem repeat(5, minmax(0, 1fr));
    grid-template-rows: 3.75rem repeat(4, minmax(0, 1fr));
  }

  .scene10-header-svg,
  .scene10-header img {
    width: 1.8rem;
    height: 1.8rem;
  }

  .scene10-date {
    font-size: 0.42rem;
    line-height: 0.6rem;
    letter-spacing: 0.03em;
  }

  .scene10-motif {
    padding-right: 0.2rem;
  }

  .scene10-motif-icon {
    width: 0.95rem;
    height: 0.95rem;
  }

  .scene10-tallies {
    padding: 0.4rem 0.3rem;
    column-gap: 0.25rem;
    row-gap: 0.25rem;
  }

  .scene10-tally-group {
    gap: 0.035rem;
  }

  .scene10-tally {
    font-size: 0.52rem;
  }

  .scene10-title {
    margin-top: 0.85rem;
  }

  /* Rounded/tapered split view. */
  .scene11-content {
    inset: 4.75rem 0.75rem 2rem;
  }

  .scene11-columns {
    column-gap: 0.75rem;
  }

  .scene11-category-icon {
    width: 1rem;
    height: 1rem;
    margin-bottom: 0.75rem;
  }

  .scene11-svg {
    width: 2.6rem;
    height: 2.6rem;
  }

  .scene11-date {
    font-size: 0.48rem;
    line-height: 0.65rem;
  }

  .scene11-title {
    margin-top: 1rem;
  }

  /* Ten-photo scene remains a compact 5 × 2 grid. */
  .scene12-content {
    inset: 4.75rem 0.75rem 2rem;
  }

  .scene12-photo-field {
    grid-template-columns: repeat(5, minmax(0, 3.6rem));
    grid-template-rows: repeat(2, minmax(0, 3.6rem));
    gap: 0.65rem;
  }

  .scene12-item {
    width: 100%;
    max-width: 3.6rem;
  }

  .scene12-title {
    margin-top: 1rem;
  }

  /* Family-photo scene. */
  .scene13-content {
    inset: 4.75rem 1rem 2rem;
  }

  .scene13-text {
    top: 25%;
    width: min(32rem, 88vw);
  }

  .scene13-carousel {
    width: 8rem;
    bottom: 12vh;
  }

  /* Rules and return scene. */
  .scene14-text {
    top: 27%;
    width: 88vw;
  }

  .scene14-kolam {
    bottom: 18vh;
    height: 4.5rem;
  }

  /* Final three-part composition. */
  .scene15-fixed {
    left: 1.25rem;
    right: 1.25rem;
    top: 37%;
    grid-template-columns: 0.7fr 0.7fr 1.5fr;
    column-gap: 1.25rem;
  }

  .scene15-serif {
    font-size: clamp(1.65rem, 7vw, 2.3rem);
  }

  .scene15-line-word {
    font-size: clamp(1.8rem, 7.5vw, 2.5rem);
  }

  .scene15-wander-line {
    gap: 0.25rem;
  }

  .scene15-changing {
    width: min(18rem, 48vw);
  }
}

@media (max-width: 40rem) {
  .name-link {
    right: 1rem;
    font-size: 0.6875rem;
  }

  .scene1 .grandmother,
  .scene1 .kolam-word,
  .scene2-simplest {
    font-size: clamp(2.5rem, 12vw, 3.4rem);
    line-height: 1.05;
  }

  .scene3-grid {
    gap: 1rem;
  }

  .scene15-fixed {
    top: 33%;
    grid-template-columns: 1fr 1fr;
    row-gap: 2.25rem;
  }

  .scene15-wander {
    grid-column: 1 / -1;
    align-items: center;
  }

  .scene15-changing {
    width: min(22rem, 88vw);
    align-items: center;
  }

  .type-text-scene15-changing {
    text-align: center;
  }

  .scene15-final-line {
    justify-content: center;
  }
}

@media (max-height: 43.75rem) and (orientation: landscape) {
  .scene8-title,
  .scene9-title,
  .scene10-title,
  .scene11-title,
  .scene12-title {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .scene13-text,
  .scene14-text {
    top: 20%;
  }

  .scene13-carousel {
    width: 6.5rem;
    bottom: 7vh;
  }

  .scene14-kolam {
    bottom: 9vh;
  }
}
