/* Shared frame rhythm and responsive corrections. Artwork and content stay intact. */
:root {
  --page-gutter: clamp(12px, 2.1vw, 32px);
  --panel-inset: clamp(20px, 2.8vw, 40px);
  --section-gap: clamp(20px, 2.4vw, 32px);
  --night-frame-bleed: var(--panel-inset);
  --night-wide-frame: min(calc(1280px + 2 * var(--panel-inset)), calc(100% - 2 * var(--page-gutter)));
}

.container {
  width: min(1280px, calc(100% - 2 * (var(--page-gutter) + var(--panel-inset))));
}

#main { display: flow-root; }

/* Match the blue separation approved between the story worlds and reading demo. */
#main:has(> .hero) { --section-gap: 32px; }
@media (max-width: 800px) {
  #main:has(> .hero) { --section-gap: 20px; }
}

#main > :is(.worlds-section, .reading-section, .stages-section, .keepsake-section,
  .final-invite, .episodes-section, .cast-section, .world-discovery,
  .studio-shell, .editor-page, .parents-page, .pdf-page, .empty) {
  margin-block: var(--section-gap);
  padding-block: clamp(36px, 4.5vw, 64px);
}

#main > .worlds-section { padding-bottom: 16px; }
.section-heading { align-items: flex-end; gap: 24px; }
.section-heading > div { min-width: 0; }
.section-heading > p { flex-shrink: 0; }
.reading-demo { gap: clamp(28px, 4.5vw, 64px); }
.keepsake { gap: clamp(32px, 5vw, 72px); }
.simple-steps li > span { flex-shrink: 0; }
.world-discovery > .button { flex-shrink: 0; max-width: 260px; }

/* Contain sideways browsing inside the frame, including focus rings. */
.world-row, .episode-grid, .world-picker {
  margin-inline: 0;
  padding: 5px 5px 20px;
  scroll-padding-inline: 5px;
  scrollbar-width: thin;
  scrollbar-color: #bba5ca transparent;
}
.world-card { display: flex; flex-direction: column; }
.world-art { flex-shrink: 0; }
.world-card-copy { flex: 1; min-height: 178px; }
.world-card p { font-size: 11px; margin-bottom: 30px; }
.benefit-row { padding-inline: 0; }
.benefit-row > div { min-width: 0; }
.stage-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.editor-layout { grid-template-columns: 240px minmax(0, 1fr); }
.manuscript, .form-split > *, .ready-summary > * { min-width: 0; }
.editor-heading > .button { flex-shrink: 0; }
.parent-grid { gap: clamp(20px, 3vw, 36px); }
.parent-grid article { padding: clamp(22px, 3vw, 32px); }
.cast-grid > article { display: flow-root; }

@media (max-width: 1100px) {
  .world-row { display: flex; overflow-x: auto; gap: 16px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
  .world-card { flex: 0 0 216px; scroll-snap-align: start; }
  .world-art { aspect-ratio: 1; }
  .world-card h3 { font-size: 19px; }
  .world-card-copy { padding: 20px 18px 26px; }
  .benefit-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
  .episode-grid { display: flex; overflow-x: auto; gap: 20px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
  .episode-card { flex: 0 0 295px; scroll-snap-align: start; }
  .episode-card.available { flex-basis: 340px; }
  .world-picker { display: flex; gap: 12px; }
  .world-pick { flex: 0 0 150px; }
}

@media (max-width: 1000px) {
  /* Keep the existing destinations available, with their own row. */
  .site-header:not(.reader-header) .nav-inner {
    width: calc(100% - 2 * var(--page-gutter));
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'brand create' 'links draft';
    height: auto;
    padding-block: 14px 8px;
    gap: 8px 12px;
  }
  .site-header:not(.reader-header) .brand { grid-area: brand; justify-self: start; }
  .site-header:not(.reader-header) .nav-actions { display: contents; }
  .site-header:not(.reader-header) .nav-actions > .button { grid-area: create; justify-self: end; min-height: 44px; }
  .site-header:not(.reader-header) .draft-link { grid-area: draft; justify-self: end; min-height: 44px; max-width: none; font-size: 10px; }
  .site-header:not(.reader-header) nav { grid-area: links; display: flex; align-items: center; gap: 20px; font-size: 11px; }
  .site-header:not(.reader-header) nav a { display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; }
  .hero-content { max-width: 650px; }
  .hero-image { mask-image: linear-gradient(transparent, #000 18%); }
}

@media (min-width: 801px) and (max-width: 1000px) {
  /* The desktop image/text overlap becomes crowded before phone sizes. */
  .hero { min-height: 680px; }
  .hero-image { inset: auto 0 0; height: 58%; width: 100%; }
  .hero-image img { object-position: 70% 55%; }
  .hero::after { background: linear-gradient(#15234f 0%, #17265bec 17%, #1b2d6555 43%, #15285c00 65%); }
  .hero-content { padding-top: 38px; padding-bottom: 330px; text-align: center; }
  .hero h1 { font-size: 44px; }
  .hero p { margin: 18px auto 0; }
  .hero-actions { justify-content: center; margin-top: 24px; }
  .hero-footnote { display: none; }
}

@media (max-width: 900px) {
  .editor-layout { display: block; }
  .editor-sidebar { position: static; display: flow-root; padding: 24px; margin-bottom: 28px; }
  .editor-sidebar > img { width: 130px; height: 165px; float: right; margin: 0 0 18px 24px; }
  .editor-sidebar .check, .editor-sidebar .hint, .writing-note { clear: both; }
  .editor-sidebar .check { padding-top: 12px; }
  .editor-heading { align-items: flex-start; flex-direction: column; gap: 20px; }
  .editor-heading .button { margin-top: 0; }
}

@media (max-width: 700px) {
  .section-heading { display: block; }
  .section-heading > p { margin-top: 16px; max-width: none; }
  .section-heading > p br { display: initial; }
  .reading-demo { display: flex; flex-direction: column; gap: 30px; }
  .demo-picture { width: 100%; height: auto; aspect-ratio: 1.35; }
  .demo-picture img { border-radius: 90px 90px 20px 20px; }
  .reading-copy { width: 100%; }
  .reading-copy > p, .mini-book { max-width: none; }
  .keepsake { display: flex; flex-direction: column; gap: 44px; }
  .keepsake > div { width: 100%; }
  .stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stage-card, .studio-card .stage-card { padding: 18px 15px; min-height: 140px; }
  .stage-card.selected, .studio-card .stage-card.selected { padding: 17px 14px; }
  .stage-card strong, .studio-card .stage-card strong { font-size: 11px; }
  .stage-card > span:last-child { font-size: 10px; }
  .form-split { display: block; }
  .studio-art { margin-top: 26px; }
  .mode-options, .parent-grid { grid-template-columns: 1fr; }
  .studio-card { padding: 26px 20px; }
  .pdf-actions { margin-top: 24px; }
  .footer-inner { grid-template-columns: 1fr; gap: 18px; }
  .footer-beta { text-align: left; }
  .footer-inner > p { font-size: 10px; }
  .footer-inner > a:not(.brand) { width: fit-content; min-height: 44px; display: inline-flex; align-items: center; }
}

@media (max-width: 520px) {
  .site-header:not(.reader-header) .nav-inner { gap: 6px 8px; padding-top: 10px; }
  .site-header:not(.reader-header) nav { gap: 12px; font-size: 9px; }
  .site-header:not(.reader-header) .nav-actions > .button { padding: 10px 12px; font-size: 9px; gap: 7px; }
  .site-header:not(.reader-header) .draft-link { font-size: 9px; padding: 0; }
  .hero-content { width: calc(100% - 32px); }
  .hero-actions .button { min-height: 44px; }
  .world-card { flex-basis: 205px; }
  .world-card-copy { min-height: 180px; }
  .benefit-row { gap: 20px 14px; }
  .benefit-row > div { align-items: flex-start; gap: 8px; }
  .benefit-row svg { width: 21px; height: 21px; }
  .benefit-row small { font-size: 9px; }
  .episode-card, .episode-card.available { flex-basis: min(290px, calc(100% - 10px)); }
  .episode-card > img, .coming-cover { height: 215px; }
  .studio-card { padding: 24px 16px; border-radius: 16px; }
  .studio-card h1 { font-size: 26px; }
  .studio-top { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .stepper { gap: 8px; }
  .stepper li { min-width: 0; }
  .world-pick { flex-basis: 140px; }
  .form-actions { align-items: stretch; }
  .form-actions > .button { min-height: 46px; }
  .editor-sidebar { padding: 20px; }
  .editor-sidebar > img { width: 95px; height: 125px; margin-left: 16px; }
  .scene-editor { padding: 20px 16px; }
  .scene-heading { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .approval-card { padding: 22px 18px; }
  .approval-card .form-actions { gap: 16px; }
  .book-object { max-width: calc(100% - 30px); }
  .cast-initial { float: none; margin-bottom: 16px; }
  .cast-grid > article + article { margin-top: 28px; }
}
