/* Scroll Repair V1 — scoped composition and mobile cinematic presentation only. */

:is(#story-engine-section, #khatan-experience-section, #experience-medical-transition) {
    height: calc(100vh - var(--cinema-header-height, var(--khatan-chrome-height)));
}
#story-engine-section .story-scene { gap: clamp(1rem, 2vh, 1.7rem); }
#story-engine-section .story-scene h2 { max-width: 48rem; text-wrap: balance; }
#story-engine-section .story-scene--motherhood h2 { font-size: clamp(2rem, 2.6vw, 2.7rem) !important; }
#story-engine-section .story-scene--father p { max-width: 38rem; }
#story-engine-section .story-scene--lasting h2:first-child { font-size: var(--story-copy-size) !important; font-weight: 400 !important; }
.cinema-sequence--swap { display: grid; align-items: center; width: 100%; }
.cinema-sequence--swap > * { grid-area: 1 / 1; margin: 0 !important; }
#story-engine-section .cinema-sequence { min-height: 4.5rem; }

/* One presentation frame; source aspect ratios remain independent. */
@media (max-width: 767px) {
    :is(#story-engine-section, #khatan-experience-section, #experience-medical-transition, #medical-assurance-section) {
        --cinema-safe-top: var(--cinema-header-height, calc(var(--khatan-chrome-height) + 32px));
        height: calc(100svh - var(--cinema-safe-top)); min-height: 0;
    }
    #story-engine-section #scene-container { height: 100%; }
    #story-engine-section .story-scene h2 { font-size: clamp(1.8rem, 7vw, 2.2rem) !important; line-height: 1.3 !important; }
    #story-engine-section .story-scene--motherhood h2 { font-size: clamp(1.8rem, 6vw, 2rem) !important; }
    #story-engine-section .story-scene p { font-size: clamp(1.05rem, 4vw, 1.3rem) !important; }

    /* Stable Experience frame, independent of each illustration's proportions. */
}
@media (max-width: 767px) and (max-height: 700px) {
    /* Clinical copy needs a separate short-height fit, not the illustration frame. */
}
/* Task 1B: mobile composition acceptance repairs; desktop rules/pacing untouched. */
@media (max-width: 767px) {/* Tailwind space-y margins otherwise add to the new grid gap. */

    /* Explicit clinical frames guarantee a gap, rather than approximate touching edges. */
}
@media (max-width: 767px) and (max-height: 720px) {
}

/* Empat Detik: isolated storytelling composition, S3–S7 only. */
:is(#s3-cinematic-section,#s4-cinematic-section,#s5-cinematic-section,#s6-cinematic-section,#s7-closing-section).ed-section { position:relative; height:calc(100svh - var(--cinema-header-height,var(--khatan-chrome-height))); min-height:0; overflow:hidden; padding:0; background:#F7F3EC; color:#2D1B14; --ed-anchor:clamp(2.3rem,3vw,3.25rem); --ed-support:clamp(1.25rem,1.5vw,1.55rem); --ed-whisper:clamp(1.05rem,1.2vw,1.2rem); }
.ed-section :is(p,h2,figure) { margin:0; }
.ed-section * { box-sizing:border-box; }
.ed-section .ed-layout { display:grid; grid-template-columns:minmax(0,56fr) minmax(0,44fr); gap:clamp(1.5rem,3vw,3rem); height:100%; padding:2rem clamp(1.5rem,4vw,4.5rem); }
.ed-section .ed-visual { min-height:0; min-width:0; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.ed-section .ed-visual img { display:block; width:100%; height:100%; object-fit:contain; object-position:center; }
.ed-section .ed-story { position:relative; min-height:0; min-width:0; }
.ed-section .ed-scene { position:absolute; inset:0; display:flex; align-items:center; opacity:0; visibility:hidden; }
.ed-section .ed-copy { display:flex; flex-direction:column; justify-content:center; gap:1.25rem; width:100%; }
.ed-section :is(.ed-anchor,.ed-support,.ed-whisper) { font-family:'Playfair Display',serif; color:#2D1B14; text-wrap:pretty; }
.ed-section .ed-anchor { font-size:var(--ed-anchor); font-weight:500; line-height:1.25; text-wrap:balance; }
.ed-section .ed-support { font-size:var(--ed-support); font-weight:400; line-height:1.5; color:rgba(45,27,20,.78); }
.ed-section .ed-whisper { font-size:var(--ed-whisper); font-weight:400; font-style:italic; line-height:1.45; color:rgba(45,27,20,.72); }
.ed-section .ed-swaps { display:grid; align-items:center; }
.ed-section .ed-swaps > * { grid-area:1 / 1; }
.ed-section .ed-index { position:absolute; top:.8rem; left:clamp(1.5rem,4vw,4.5rem); z-index:2; font-family:'Montserrat',sans-serif; font-size:.65rem; font-weight:500; line-height:1.5; letter-spacing:.16em; color:#C8AA81; }
:is(#s4-cinematic-section,#s5-cinematic-section).ed-section .ed-layout { grid-template-columns:minmax(0,44fr) minmax(0,56fr); }
:is(#s4-cinematic-section,#s5-cinematic-section) .ed-visual { grid-column:2; grid-row:1; }
:is(#s4-cinematic-section,#s5-cinematic-section) .ed-story { grid-column:1; grid-row:1; }
.ed-section .ed-gate { position:absolute; inset:0; z-index:3; background:#2D1B14; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:1.5rem; text-align:center; }
.ed-section .ed-gate .ed-anchor { color:#F7F3EC; }
.ed-section .ed-hairline { height:1px; width:50px; margin-top:1.5rem; background:#C8AA81; }
#s7-closing-section.ed-section .ed-layout { display:block; padding:2rem; }
#s7-closing-section .ed-story { height:100%; max-width:58rem; margin:auto; }
#s7-closing-section .ed-copy { text-align:center; gap:1.5rem; }
@media(max-width:767px) {
 #s7-closing-section.ed-section { --ed-anchor:clamp(1.9rem,7.2vw,2.5rem); --ed-support:clamp(1.05rem,4.4vw,1.2rem); --ed-whisper:clamp(.95rem,4vw,1.05rem); }
 :is(#s3-cinematic-section,#s4-cinematic-section,#s5-cinematic-section,#s6-cinematic-section).ed-section { --ed-anchor:clamp(1.65rem,6.2vw,2rem); --ed-support:clamp(.95rem,4vw,1.05rem); --ed-whisper:clamp(.875rem,3.6vw,.95rem); }
 .ed-section .ed-layout, :is(#s4-cinematic-section,#s5-cinematic-section).ed-section .ed-layout { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,50fr) minmax(0,50fr); gap:1rem; padding:1.35rem 1.25rem .75rem; }
 .ed-section .ed-visual, :is(#s4-cinematic-section,#s5-cinematic-section) .ed-visual { grid-column:1; grid-row:1; }
 .ed-section .ed-story, :is(#s4-cinematic-section,#s5-cinematic-section) .ed-story { grid-column:1; grid-row:2; }
 .ed-section .ed-copy { gap:.75rem; text-align:center; }
 .ed-section .ed-anchor { line-height:1.22; }
 .ed-section .ed-support { line-height:1.4; }
 .ed-section .ed-index { top:.25rem; left:1.25rem; font-size:.6rem; }
 .ed-section .ed-visual img { width:100%; max-width:none; }
 #s3-cinematic-section .ed-visual img { height:115%; }
 #s4-cinematic-section .ed-visual img { height:108%; }
 #s5-cinematic-section .ed-visual img { height:108%; }
 #s6-cinematic-section .ed-visual img { height:104%; }
 #s7-closing-section.ed-section .ed-layout { padding:1.25rem; }
}
@media(max-width:767px) and (max-height:700px) {
 .ed-section .ed-layout, :is(#s4-cinematic-section,#s5-cinematic-section).ed-section .ed-layout { grid-template-rows:minmax(0,44fr) minmax(0,56fr); gap:.75rem; padding-top:1.1rem; padding-bottom:.5rem; }
 .ed-section .ed-copy { gap:.5rem; }
}

@media(max-width:767px) and (max-height:700px) {
 #s3-cinematic-section.ed-section .ed-layout { grid-template-rows:minmax(0,48fr) minmax(0,52fr); }
 #s5-cinematic-section.ed-section .ed-layout { grid-template-rows:minmax(0,46fr) minmax(0,54fr); }
 #s6-cinematic-section.ed-section .ed-layout { grid-template-rows:minmax(0,48fr) minmax(0,52fr); }
}

#s4-cinematic-section .ed-visual img { filter:url('#s4-background-match'); mask-image:linear-gradient(to bottom,transparent 0%,#000 5%,#000 89%,transparent 100%); }

#s5-cinematic-section .ed-visual img { filter:url('#s5-background-match'); mask-image:linear-gradient(to bottom,transparent 0%,#000 5%,#000 89%,transparent 100%); }

#s6-cinematic-section .ed-visual img { filter:url('#s6-background-match'); mask-image:linear-gradient(to bottom,transparent 0%,#000 5%,#000 89%,transparent 100%); }

/* Related supporting thoughts share one reading composition. */
.ed-section .ed-support-group { display:grid; gap:.35rem; }

/* Desktop 01–04: align the rendered subjects towards their copy, not the centre of a wide image box. */
@media (min-width: 1024px) {
    :is(#s3-cinematic-section,#s4-cinematic-section,#s5-cinematic-section,#s6-cinematic-section) .ed-layout { gap: clamp(24px, 2vw, 32px); }
    :is(#s3-cinematic-section,#s4-cinematic-section,#s5-cinematic-section,#s6-cinematic-section) .ed-visual { overflow: visible; }
    :is(#s3-cinematic-section,#s6-cinematic-section) .ed-visual img { object-position: right center; transform: scale(1.12); transform-origin: right center; }
    #s4-cinematic-section .ed-visual img { object-position: left center; transform: scale(1.12); transform-origin: left center; }
    #s5-cinematic-section .ed-visual img { object-position: left center; transform: translate(calc(-1 * clamp(24px, 2vw, 36px)), 12px) scale(1.225); transform-origin: left center; }
}

/* Mobile 02/04: give the precious-moment headline a quieter scale. */
@media (max-width: 767px) {
    #s4-cinematic-section [data-beat="precious-moment"] .ed-anchor { font-size: clamp(1.45rem, 5.5vw, 1.75rem); }
    #s4-cinematic-section .ed-support { font-size: clamp(.875rem, 3.6vw, .95rem); line-height: 1.5; }
    #s4-cinematic-section .ed-support-group { gap: 0; }
    #s4-cinematic-section.ed-section .ed-layout { grid-template-rows: minmax(0,52fr) minmax(0,48fr); }
    #s4-cinematic-section .ed-visual img { height: 118%; }
}

@media (max-width: 767px) and (max-height: 700px) {
    #s4-cinematic-section.ed-section .ed-layout { grid-template-rows: minmax(0,46fr) minmax(0,54fr); }
}

/* Upper narrative governance: text roles only; composition and pacing stay in their existing rules. */
#story-engine-section .story-scene h2 { font-weight:500 !important; line-height:1.25 !important; color:#2D1B14 !important; max-width:48rem; }
#story-engine-section .story-scene p { max-width:38rem; line-height:1.5 !important; color:rgba(45,27,20,.78) !important; text-wrap:pretty; }
#story-engine-section .story-scene--lasting h2:first-child { color:rgba(45,27,20,.78) !important; line-height:1.5 !important; }
#story-engine-section .story-memory-line { color:rgba(45,27,20,.72) !important; }
#story-engine-section .story-scene :is(h2,p) { margin-block:0; }
@media(max-width:767px) {
 #story-engine-section .story-scene h2 { font-size:clamp(1.8rem,6.6vw,2.2rem) !important; }
 #story-engine-section .story-scene--motherhood h2 { font-size:clamp(1.8rem,6vw,2rem) !important; }
 #story-engine-section .story-scene--lasting h2:first-child { font-size:clamp(1.05rem,4vw,1.3rem) !important; }
}

:is(#s3-cinematic-section,#s4-cinematic-section,#s5-cinematic-section,#s6-cinematic-section) .ed-copy { max-width:36rem; }

/* S2 motherhood: each swapping memory shares the heading centre. */
#story-engine-section .story-scene--motherhood .cinema-sequence--swap { justify-items:center; }
#story-engine-section .story-scene--motherhood .story-memory-line { width:100%; text-align:center; }

/* Final optical polish: static composition only; existing narrative/timelines unchanged. */
@media (min-width:1024px) {
    #s5-cinematic-section .ed-layout { width:100%; max-width:84rem; margin-inline:auto; grid-template-columns:minmax(0,44fr) minmax(0,56fr); }
    #s5-cinematic-section .ed-visual img { transform:translate(calc(-1 * clamp(48px,5vw,72px)),10px) scale(1.18); }
}
@media (min-width:1600px) {
    #s5-cinematic-section .ed-visual img { transform:translate(-40px,10px) scale(1.18); }
}
@media (max-width:767px) {
    #s3-cinematic-section .ed-visual img { height:118%; }
    #s5-cinematic-section .ed-visual img { height:112%; }
    #s6-cinematic-section .ed-visual img { height:108%; }
    #s5-cinematic-section .ed-scene[data-beat="time-does-not-wait"] { padding-bottom:2rem; }
}
/* Per-artwork adjustments preserve peripheral guards, procession gestures and clinical detail. */
#khatan-experience-section .kx-visual-layer[data-number="06"] .kx-visual-image { transform:translateY(-.35rem) scale(1.035); transform-origin:50% 58%; }
@media (max-width:767px) {
    #khatan-experience-section .kx-visual-layer[data-number="04"] .kx-visual-image { transform:scale(1.035); transform-origin:50% 56%; }
    #khatan-experience-section .kx-visual-layer[data-number="05"] .kx-visual-image { transform:scale(1.035); transform-origin:50% 56%; }
    #khatan-experience-section .kx-visual-layer[data-number="06"] .kx-visual-image { transform:translateY(-.15rem) scale(1.06); transform-origin:50% 58%; }
    #khatan-experience-section .kx-visual-layer[data-number="09"] .kx-visual-image { transform:scale(1.035); transform-origin:50% 60%; }
}
