/* emberlane.app Home (R12b): one night, five scenes. Loads after styles.css.
   Parts: 1 scenes (layout, no motion), 2 the type of each scene, 3 phone, 4 motion (CSS only: scroll-driven, inside @supports and
   prefers-reduced-motion). Painted pages never move inside themselves: each painting fades and drifts whole. */

/* ---------- 1. scenes ---------- */
.night{position:relative;isolation:isolate;background:var(--night)}
.night{--f:60svh}   /* the crossfade: a scene is already pinned at the top, invisible, when it starts to show */
.beat{position:relative;height:calc(100svh + var(--d) + var(--f));--d:100svh}
.beat+.beat{margin-top:calc(-100svh - var(--f))}
.b4{height:calc(100svh + var(--d))}
.b0{--d:140svh}.b1{--d:190svh}.b2{--d:300svh}.b3{--d:200svh}.b4{--d:90svh}
.pin{position:sticky;top:0;height:100svh;overflow:hidden}
.b0 .pin{background:var(--night)}
.pn{position:absolute;inset:0;overflow:hidden}
.art{--ar:1.7778;position:absolute;left:50%;top:50%;width:calc(max(100%,100svh*var(--ar))*1.08);aspect-ratio:var(--ar);translate:-50% -50%}
.art picture{position:absolute;inset:0}
.art img{display:block;width:100%;height:100%;object-fit:cover}
.scr{position:absolute;inset:0;pointer-events:none}
.txt{position:absolute;inset:0;--px:clamp(1.25rem,5vw,5rem)}
.txt>*{position:absolute}
.disp{font-weight:300;font-variation-settings:"opsz" 144;letter-spacing:-.035em;line-height:.93;text-wrap:balance}
.txt p,.txt h2,.txt h1{margin:0}
.sh,.txt{text-shadow:0 2px 20px rgba(10,4,20,.5)}

/* a glint on the one found thing (dusk): light on the painting, placed on the daisy, never near type */
.glint{position:absolute;left:calc(var(--gx)*100%);top:calc(var(--gy)*100%);width:7.5%;aspect-ratio:1;translate:-50% -50%;pointer-events:none;mix-blend-mode:screen;background:radial-gradient(circle,rgba(255,246,208,.95) 0 3%,rgba(255,222,120,.5) 14%,transparent 56%)}
.glint::before,.glint::after{content:"";position:absolute;left:0;right:0;top:50%;height:2px;background:linear-gradient(90deg,transparent,#fff7d8,transparent);translate:0 -50%}
.glint::after{rotate:90deg}

/* ---------- 2. the type of each scene ---------- */
/* sunset */
.b0 .scr{background:linear-gradient(0deg,rgba(40,8,0,.66),transparent 40%),radial-gradient(ellipse 75% 60% at 24% 24%,rgba(90,14,8,.52),transparent 74%)}
.b0 h1{left:var(--px);top:calc(var(--head) + 1svh);font-size:clamp(3.4rem,min(12.4vw,20svh),13rem);font-weight:300;font-variation-settings:"opsz" 144}
.b0 h1{text-wrap:nowrap}.b0 h1 span{white-space:nowrap}.b0 h1 .l1{display:block}
.b0 .low{left:var(--px);bottom:clamp(1.5rem,6svh,4rem);width:min(32rem,calc(100% - 2*var(--px)))}
.b0 .low>*{position:static}
.sub{font:400 clamp(1.25rem,min(2vw,3.2svh),1.9rem)/1.38 var(--serif);font-variation-settings:"opsz" 30;text-shadow:0 2px 16px rgba(40,6,0,.75)}
.act{display:flex;align-items:center;gap:1.4rem;margin-top:1.4rem}
.note,.trust{margin:0;font:600 .95rem/1.4 var(--sans)}
.act .btn{text-shadow:none}
/* dusk */
.b1 .scr{background:linear-gradient(90deg,rgba(18,10,40,.7),rgba(18,10,40,.32) 42%,transparent 64%)}
.b1 .txt{--fs:clamp(2.7rem,min(8.4vw,13.5svh),8.6rem)}
.b1 h2{left:var(--px);top:calc(var(--head) + 2svh);width:min(5.4em,60vw);font-size:var(--fs)}
.b1 .hint{top:calc(var(--head) + 2svh + 3*.93*var(--fs) + clamp(1rem,4svh,2.6rem))}
.hint{left:var(--px);top:55svh;font:italic 300 clamp(1.1rem,min(2.2vw,3.6svh),2rem)/1.3 var(--serif);text-shadow:0 2px 16px rgba(10,6,30,.85)}
.b1 .hint{width:min(30rem,calc(100% - 2*var(--px)))}
/* moonlight */
.b2 .scr{background:linear-gradient(180deg,#04081e 11%,rgba(4,8,30,.55) 17%,transparent 24%),linear-gradient(0deg,rgba(4,8,30,.82),rgba(4,8,30,.55) 34%,transparent 62%)}
.mina{font-family:var(--serif);left:var(--px);top:58svh;width:min(90vw,86rem);text-wrap:wrap;font-weight:500;font-size:clamp(2.3rem,min(5.5vw,8.6svh),5.6rem);line-height:1.02;letter-spacing:-.025em;text-shadow:0 3px 28px rgba(4,8,30,.8)}
.mina .pb{display:none}
.mina small{font:italic 300 .46em/1 var(--serif);letter-spacing:0;vertical-align:.25em}
.mina::before,.b0 .low::before,.b1 .hint::before{content:"";position:absolute;z-index:-1;pointer-events:none;inset:-.3em -.5em;background:rgba(4,8,30,.62);filter:blur(26px);border-radius:2em}
.b0 .low::before{inset:-1rem -1.4rem;background:rgba(40,8,0,.42)}
.b1 .hint::before{background:rgba(18,10,40,.5)}
.along{left:var(--px);top:84svh;font:italic 300 clamp(1.05rem,min(1.7vw,2.9svh),1.55rem)/1.3 var(--serif);text-shadow:0 2px 16px rgba(4,8,30,.9)}
/* Ma and Rowan */
.b3 .scr{background:linear-gradient(0deg,rgba(40,22,6,.34),transparent 40%)}
.cap{left:55vw;top:calc(var(--head) + 4svh);width:min(29vw,27rem);font:400 clamp(1.3rem,min(2.3vw,4svh),2.5rem)/1.26 var(--serif);font-variation-settings:"opsz" 36;letter-spacing:-.01em;text-wrap:pretty;text-shadow:0 2px 18px rgba(40,20,4,.7)}
.ways{left:55vw;top:calc(var(--head) + 4svh + 5.5*clamp(1.3rem,min(2.3vw,4svh),2.5rem)*1.26 + 1.2rem);width:min(29vw,26rem);font:italic 400 clamp(1.05rem,min(1.6vw,2.8svh),1.5rem)/1.35 var(--serif);text-shadow:0 2px 14px rgba(40,20,4,.85)}
/* on the lit wall the caption is set in dark ink, like a printed page; on the phone it keeps the light type over its scrims */
@media (min-width:701px){.cap,.ways{color:#2a1608;text-shadow:0 0 22px rgba(255,238,200,.6),0 0 3px rgba(255,238,200,.5)}}
/* asleep */
.b4 .scr{background:linear-gradient(180deg,#03051a 12%,rgba(3,5,26,.5) 20%,transparent 28%),radial-gradient(ellipse 50% 40% at 22% 19%,#03051a 45%,transparent 100%),radial-gradient(ellipse 34% 38% at 80% 19%,#03051a 50%,transparent 100%),linear-gradient(180deg,rgba(3,5,26,.7),rgba(3,5,26,.25) 24%,transparent 36%),linear-gradient(0deg,rgba(3,5,22,.74),transparent 34%)}
.b4 h2{left:var(--px);top:calc(var(--head) + 1svh);width:min(7.4em,62vw);font-size:clamp(2.6rem,min(6.9vw,11svh),7rem);line-height:.96}
.free{right:clamp(1.25rem,4.2vw,4.5rem);top:calc(var(--head) + 2svh);width:min(24rem,30vw)}
.free h3{font:400 clamp(1.4rem,2.2vw,2.1rem)/1.15 var(--serif);font-variation-settings:"opsz" 48}
.free p{margin:.55rem 0 0;font:400 clamp(1.05rem,1.45vw,1.35rem)/1.4 var(--serif)}
.free em{font-style:italic;color:var(--amber)}
.free .btn{margin-top:1.3rem}
.free .trust{margin-top:.9rem;font-family:var(--sans)}
.lib{left:var(--px);bottom:clamp(1rem,3.5svh,2.5rem);display:grid;grid-template-columns:auto auto;align-items:end;gap:.7rem 1.6rem;position:absolute}
.lib>*{position:static}
.lib .lead,.more{font:italic 300 clamp(1.1rem,1.9vw,1.7rem)/1 var(--serif);text-shadow:0 2px 14px rgba(3,5,22,.9)}
.lib .lead{grid-column:1/-1}
/* the covers sit below the lion's paws at any window shape: --ph is the height left under the paws (the painting is 108% of the cover-fit; its paws end about .28 of its height below the centre, with the drift) */
.shelf{--artH:calc(max(100vw/1.7778,100svh)*1.08);--ph:calc(50svh - .28*var(--artH) - clamp(1rem,3.5svh,2.5rem) - 1.7rem);--cw:clamp(6rem,min(15vw,var(--ph)*1.3333),15rem);display:flex;text-decoration:none;padding-block:.5rem}
.shelf img{width:var(--cw);aspect-ratio:4/3;object-fit:cover;border-radius:.45rem;margin-right:calc(var(--cw)*-.24);box-shadow:0 14px 26px rgba(0,0,0,.6),inset 0 0 0 1px rgba(255,255,255,.12);transition:translate .35s var(--ease)}
.shelf img:last-child{margin-right:0}
.shelf img:nth-child(odd){rotate:-.8deg;translate:0 -4px}.shelf img:nth-child(even){rotate:.7deg}
.shelf:hover img,.shelf:focus-visible img{translate:0 -8px}
.shelf:focus-visible{outline-offset:6px}
.more{padding-bottom:.5rem;margin-left:0}

/* ---------- 3a. a tablet held upright: the desktop composition, the type sized to the width (min(vw, svh) would make it small) ---------- */
@media (min-width:701px) and (max-aspect-ratio:4/5){
  .sub{font-size:clamp(1.25rem,3.3vw,2.3rem)}
  .note,.trust{font-size:clamp(.95rem,1.9vw,1.25rem)}
  .hint{font-size:clamp(1.1rem,3.6vw,2.4rem)}
  .b1 h2{width:min(7em,80vw)}
  .b1 .txt{--fs:clamp(2.7rem,9.5vw,8.6rem)}
  .mina{font-size:clamp(2.3rem,7.6vw,6rem)}
  .along{font-size:clamp(1.05rem,3vw,1.9rem)}
  /* Ma and Rowan: the painting centred on the two of them (its x .36), the caption low over the quilt in light type, on a warm scrim */
  .b3 .art{translate:-36% -50%}
  .b3 .scr{background:linear-gradient(0deg,rgba(40,22,6,.9),rgba(40,22,6,.62) 26%,transparent 46%)}
  .cap,.ways{color:var(--cream);text-shadow:0 2px 18px rgba(40,20,4,.8)}
  .ways{left:var(--px);right:var(--px);width:auto;top:auto;bottom:4svh;font-size:clamp(1.05rem,2.7vw,1.9rem)}
  .cap{left:var(--px);right:var(--px);width:auto;top:auto;bottom:calc(4svh + 2*1.35*clamp(1.05rem,2.7vw,1.9rem) + 1.6rem);font-size:clamp(1.3rem,3.9vw,2.9rem)}
  .b4 h2{width:min(7.4em,52vw);font-size:clamp(2.6rem,8.4vw,7rem)}
  .free{width:min(28rem,40vw)}
  .free h3{font-size:clamp(1.4rem,3.6vw,2.6rem)}.free p{font-size:clamp(1.05rem,2.6vw,1.7rem)}
  .lib .lead,.more{font-size:clamp(1.1rem,3vw,2rem)}
}

@media (min-width:701px) and (max-height:500px){
  .b0 .scr{background:linear-gradient(90deg,rgba(40,8,0,.62),rgba(40,8,0,.3) 45%,transparent 70%),linear-gradient(0deg,rgba(40,8,0,.66),transparent 40%)}
  .b3 .scr{background:linear-gradient(270deg,rgba(34,18,4,.9),rgba(34,18,4,.8) 46%,transparent 62%)}   /* the far side of the room in evening shadow */
  .cap,.ways{left:55vw;width:38vw;color:var(--cream);text-shadow:0 2px 16px rgba(30,14,2,.9)}
}

/* ---------- 3. phone: composed for a tall, narrow screen ---------- */
@media (max-width:700px){
  /* a tall phone gets the portrait crops (index.html <source>); a wider phone-shaped window (600-700 px) the whole painting, framed like a tablet */
  @media (max-aspect-ratio:3/5){
    .art{--ar:.4621}
    .glint{left:calc(var(--mx)*100%);width:15%}   /* --mx: the daisy's x in the portrait crop (export_night.py crops p23 from x .47, .26 of the width) */
  }
  @media (min-aspect-ratio:601/1000){   /* (just past the portrait crops' 3/5, so the two never both match) as on a tablet: Ma and Rowan centred, the caption low on the quilt */
    .b3 .art{translate:-36% -50%}
    .b3 .pin .scr{background:linear-gradient(0deg,rgba(40,22,6,.9),rgba(40,22,6,.62) 26%,transparent 46%)}   /* (outranks the phone scrim below) */
    .b3 .txt .cap{top:auto;bottom:calc(4svh + 1.35*1.15rem + 1.2rem);font-size:min(5vw,3.1svh)}   /* three lines, so it stays under Rowan's chin   /* the line under it is one line at this width */
  }
  .txt{--px:1.4rem}
  .b0 h1{font-size:min(23vw,12svh);line-height:.92;letter-spacing:-.04em}
  .b0 h1 span,.b0 h1 .l1>span{display:block}
  .b0 .low{width:calc(100% - 2*var(--px))}
  .b0 .act{flex-direction:column;align-items:flex-start;gap:.8rem}
  .b0 .sub{font-size:1.3rem}
  .b0 .scr{background:linear-gradient(0deg,rgba(40,8,0,.82),rgba(40,8,0,.55) 30%,transparent 50%),radial-gradient(ellipse 75% 60% at 24% 24%,rgba(90,14,8,.52),transparent 74%)}   /* the line under the headline sits on the lit path on a small phone */
  .b1 h2{font-size:min(15vw,9.5svh);width:auto}
  .b1 .hint{top:calc(var(--head) + 2svh + 3*9.5svh + 4.2rem);font-size:1.2rem;max-width:18rem}
  .mina .pb{display:inline}
  .mina small{display:block;margin:.35em 0 .2em;vertical-align:0}   /* the second sentence breaks after "and", so "helping" stays clear of the fish at the right edge */
  .mina{top:59.2svh;width:calc(100% - 2*var(--px));font-size:min(9.8vw,6.4svh)}
  /* Mina's line: a scrim shaped to each line of text (not a full band), so the fish at the right keeps its own light */
  .b2 .scr{background:linear-gradient(180deg,#04081e 11%,rgba(4,8,30,.55) 17%,transparent 24%),linear-gradient(0deg,rgba(4,8,30,.85),rgba(4,8,30,.4) 9%,transparent 16%)}
  .along{top:auto;bottom:4.5svh;font-size:1.1rem}
  .b3 .scr{background:linear-gradient(180deg,rgba(48,30,12,.8),rgba(48,30,12,.52) 34%,transparent 48%),linear-gradient(0deg,rgba(40,22,6,.78),transparent 36%)}
  .cap{left:var(--px);width:calc(100% - 2*var(--px));top:calc(var(--head) + 1.2svh);font-size:min(6.1vw,3.6svh)}
  .ways{left:var(--px);width:calc(100% - 2*var(--px));top:auto;bottom:4svh;font-size:1.15rem}
  /* the last scene: the painting and its line fill the first screen; the free book, the covers and the action follow below on the night */
  .beat.b4{height:auto}
  .beat.b4::after{content:"";display:block;height:var(--f)}   /* room to pin for the crossfade (a sticky box never sticks into padding) */
  .b4 .pin{height:auto;overflow:visible;padding-top:calc(100svh - 5rem);background:linear-gradient(transparent 100svh,var(--night) 100svh)}
  .b4 .pn{inset:0 0 auto 0;height:100svh}
  .b4 .scr{inset:0 0 auto 0;height:100svh;background:linear-gradient(180deg,#03051a 24%,rgba(3,5,26,.6) 33%,transparent 44%),linear-gradient(0deg,var(--night),rgba(6,8,26,.3) 6rem,transparent 8rem)}
  .b4 .txt{position:static;display:flex;flex-direction:column;padding:0 var(--px) 3.5rem}
  .b4 .txt>*{position:static}
  .b4 .txt>.free,.b4 .txt>.lib{position:relative;z-index:2;inset:auto}
  .b4 .txt>h2{position:absolute;left:var(--px);right:var(--px);top:calc(var(--head) + 1.5svh);width:auto;font-size:min(14vw,8.5svh)}
  .free{order:1;width:auto}
  .free h3{font-size:1.7rem}.free p{font-size:1.2rem}
  .lib{order:2;position:relative;inset:auto;display:block;margin-top:2.4rem}
  .lib .lead{margin:0 0 .9rem;font-size:1.3rem}
  .shelf{padding-left:0}
  .shelf img{width:min(36vw,10.5rem);margin-right:-11vw}
  .shelf img:nth-child(n+4){display:none}
  .more{margin:.4rem 0 0;font-size:1.3rem}
  .b4 .pin::after{content:none}
}

/* ---------- 4. motion ---------- */
@keyframes tw{0%,100%{scale:.45;opacity:.55}50%{scale:1;opacity:1}}
@keyframes rise{from{opacity:0;transform:translateY(34px)}to{opacity:1;transform:none}}
@keyframes fin{from{opacity:0}}
@keyframes fout{to{opacity:0}}
@keyframes lift{from{opacity:0;transform:translateY(7svh)}}
@keyframes drift{from{transform:translateY(2.2%)}to{transform:translateY(-2.2%)}}
@keyframes litS{0%{opacity:.85}45%{opacity:1;color:#fff4c8}100%{opacity:1}}
@keyframes lit{0%{opacity:.62}45%{opacity:1;color:#fff4c8;text-shadow:0 0 26px rgba(255,214,120,.95),0 0 4px rgba(255,236,170,.9)}100%{opacity:1}}
@media (prefers-reduced-motion:no-preference){
  .glint{animation:tw 2.5s ease-in-out infinite}
  .r1{animation:rise 1.6s var(--ease) .2s both}.r2{animation:rise 1.6s var(--ease) .7s both}.r3{animation:rise 1.6s var(--ease) 1.1s both}
}
/* the night as one camera: a scene rises while invisible, is already pinned at the top when it starts to show, and fades in whole over
   the last one (nothing moves against the scroll, so nothing can lag a frame behind it); the last scene's type leaves as the next fades in */
@supports (animation-timeline:view()) and (timeline-scope:--a){
  .night{timeline-scope:--t0,--t1,--t2,--t3,--t4}
  .b0{view-timeline:--t0 block}.b1{view-timeline:--t1 block}.b2{view-timeline:--t2 block}.b3{view-timeline:--t3 block}.b4{view-timeline:--t4 block}
  .b1 .pin{animation:fin linear both;animation-timeline:--t1;animation-range:contain 0% contain var(--f)}
  .b2 .pin{animation:fin linear both;animation-timeline:--t2;animation-range:contain 0% contain var(--f)}
  .b3 .pin{animation:fin linear both;animation-timeline:--t3;animation-range:contain 0% contain var(--f)}
  .b4 .pin{animation:fin linear both;animation-timeline:--t4;animation-range:contain 0% contain var(--f)}
  .b0 .txt{animation:fout linear both;animation-timeline:--t1;animation-range:contain 0% contain 25svh}
  .b1 .txt{animation:fin linear both,fout linear both;animation-timeline:--t1,--t2;animation-range:contain 30svh contain 75svh,contain 0% contain 25svh}
  .b2 .txt{animation:fin linear both,fout linear both;animation-timeline:--t2,--t3;animation-range:contain 30svh contain 75svh,contain 0% contain 25svh}
  .b3 .txt{animation:fin linear both,fout linear both;animation-timeline:--t3,--t4;animation-range:contain 30svh contain 75svh,contain 0% contain 25svh}
  .b4 .txt{animation:fin linear both;animation-timeline:--t4;animation-range:contain 30svh contain 75svh}
  @media (prefers-reduced-motion:no-preference){
    .b0 .art{animation:drift linear both;animation-timeline:--t0;animation-range:contain 0% contain 100%}
    .b1 .txt,.b2 .txt,.b3 .txt{animation-name:lift,fout}
    .b4 .txt{animation-name:lift}
    .b1 .art{animation:drift linear both;animation-timeline:--t1;animation-range:contain 0% contain 100%}
    .b2 .art{animation:drift linear both;animation-timeline:--t2;animation-range:contain 0% contain 100%}
    .b3 .art{animation:drift linear both;animation-timeline:--t3;animation-range:contain 0% contain 100%}
    .b4 .art{animation:drift linear both;animation-timeline:--t4;animation-range:contain 0% contain 100%}
    /* the words light one by one as the dwell is scrolled, after the scene has faded in: dim until read, a glow on the word being read, then lit */
    .mina small.w{animation-name:litS}
    .w{animation:lit linear both;animation-timeline:--t2;animation-range:contain calc(22% + var(--i)*4.4%) contain calc(22% + var(--i)*4.4% + 6%)}
  }
}
/* phone: the last scene is taller than the screen (the free book and the covers follow the painting). It pins for the crossfade, then
   scrolls on; below its painting it is the night, so the scene behind never shows. Only its headline fades (a running transform on .txt
   would make it the containing block of the headline). After the motion rules, which would win otherwise. */
@media (max-width:700px){@supports (animation-timeline:view()){.b4 .txt{animation:none}.b4 .txt>h2{animation:fin linear both;animation-timeline:--t4;animation-range:contain 30svh contain 75svh}}}
