/* Home 04 a day with Naalai: one school day, morning to night, told as three cut-paper scenes (Round 2: the 9:00 am
   attendance scene and its big bell are gone; the diary page and Nila's page carry those details).
   Desktop with motion: a full-bleed sticky stage holds three paper sheets; as you scroll (natively, nothing is hijacked)
   the next sheet slides up over the last one with its torn edge, while the step cards scroll past on the left.
   Phones, no-JS and reduced motion: the same scenes stacked, each above its card. Scene pieces stand up on twos and
   small things tick, light up or float once a scene arrives (04-day.js). The art is decoration (aria-hidden); the four
   cards are the real text. */

.day {
  --day-set-w: min(63vw, 980px, 117svh);
  position: relative;
  padding-top: var(--sec-pad);
  padding-bottom: clamp(56px, 7vw, 96px);
}
.day__lead { margin-top: clamp(12px, 1.4vw, 18px); max-width: 34em; font-size: var(--t-lead); line-height: 1.55; color: var(--ink-2); }
.day__small { margin-top: clamp(28px, 3vw, 40px); font: 700 15.5px/1.5 var(--font-body); color: var(--ink-2); text-align: center; }

/* ---------------------------------------------------------------- stacked (the default) */
.day__story { margin-top: clamp(48px, 5vw, 72px); display: grid; grid-template-columns: minmax(0, 1fr); }
.day__stage, .day__steps { display: contents; }
.day__sheet[data-scene="morning"] { order: 1; } .day__step:nth-child(1) { order: 2; }
.day__sheet[data-scene="evening"] { order: 3; } .day__step:nth-child(2) { order: 4; }
.day__sheet[data-scene="night"] { order: 5; } .day__step:nth-child(3) { order: 6; }

.day__sheet { --pk-tex: url(/assets/art/textures/grain-soft-tile.webp); --pk-tex-size: 256px 256px; --pk-blend: multiply; --pk-fg: var(--ink); --pk-rim: #FFFFFF;
  position: relative; overflow: clip visible; padding: clamp(28px, 6vw, 56px) 0 clamp(40px, 6vw, 56px); display: flex; justify-content: center; align-items: flex-end; }
.day__sheet--morning { --pk-c: #FFE5A3; --ground: #A6D38C; }
.day__sheet--evening { --pk-c: #F7C2A9; --ground: #79A676; }
.day__sheet--night { --pk-c: var(--night); --pk-tex: url(/assets/art/textures/night-paper-tile.webp); --pk-tex-size: 512px 512px; --pk-blend: normal; --ground: #22433A; --pk-rim: #4A5A96; }
.day__sheet .pk-edge { --pk-edge-h: clamp(26px, 3.2vw, 44px); }

.day__set { position: relative; width: min(100%, 720px); aspect-ratio: 800 / 660; container-type: inline-size; }
.day__p { position: absolute; display: block; max-width: none; height: auto; }
.day__p > img:first-child { display: block; width: 100%; max-width: none; height: auto; }
.day__ground { position: absolute; left: -100vw; right: -100vw; bottom: calc(-1 * clamp(40px, 6vw, 56px) - 1px); height: calc(16.5% + clamp(40px, 6vw, 56px)); z-index: 0;
  background: var(--ground); }
.day__ground::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 34px; background: var(--ground);
  -webkit-mask: url(/assets/art/textures/edge-cut.svg) 0 0 / auto 100% repeat-x; mask: url(/assets/art/textures/edge-cut.svg) 0 0 / auto 100% repeat-x; transform: scaleY(-1); }

.day__step { position: relative; z-index: 2; margin: -30px 0 64px; padding-inline: var(--gutter); }
.day-card { position: relative; isolation: isolate; width: min(100%, 560px); margin-inline: auto; padding: clamp(22px, 2.4vw, 32px);
  border-radius: var(--pk-cut); background: #FFFDF8; color: var(--ink); rotate: -.6deg;
  box-shadow: var(--pk-edge-light), 0 2px 3px rgba(90, 42, 0, .2), 0 26px 44px -22px rgba(90, 42, 0, .45); }
.day__step:nth-child(even) .day-card { rotate: .7deg; }
.day-card::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: url(/assets/art/textures/grain-tile.webp) 0 0 / 256px 256px; mix-blend-mode: multiply; opacity: .45; }
.day-card__when { display: flex; align-items: center; gap: 10px; }
.day-card__when img { width: 36px; height: 36px; }
.day-card__when time { font: 800 clamp(20px, 1.7vw, 24px)/1 var(--font-display); letter-spacing: -.01em; }
.day-card__when span { font: 800 15.5px/1 var(--font-body); color: var(--ink-2); }
.day-card__when span::before { content: "·"; margin-right: 8px; color: var(--ink-3); }
.day-card h3 { margin-top: 14px; font-size: clamp(26px, 2.5vw, 36px); line-height: 1.08; }
.day-card__text { margin-top: 12px; color: var(--ink); }
.day-card__chip { margin-top: 16px; display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 5px 13px 5px 8px;
  border-radius: .55em .7em .6em .5em / .62em .5em .7em .56em; font: 800 15px/1.25 var(--font-body);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 1px 0 rgba(90, 42, 0, .16), 0 .2em .4em -.25em rgba(90, 42, 0, .4); }
.day-card__chip::before { content: ""; width: 22px; height: 22px; flex: none; background: center / contain no-repeat; }
.day-card__chip--diary { background: var(--lemon); color: var(--ink); }
.day-card__chip--diary::before { background-image: url(/assets/art/icons/sun.webp); }
.day-card__aside { margin-top: 14px; padding-top: 12px; border-top: 1.5px dashed rgba(30, 42, 90, .16); font: 700 15.5px/1.45 var(--font-body); color: var(--ink-2); }
.day-card--night { background: var(--night) url(/assets/art/textures/night-paper-tile.webp) 0 0 / 512px 512px; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 2px 3px rgba(11, 26, 85, .3), 0 26px 44px -22px rgba(11, 26, 85, .55); }
.day-card--night::after { mix-blend-mode: soft-light; opacity: .55; }
.day-card--night h3 { color: #fff; }
.day-card--night .day-card__text { color: #E3E9FF; }
.day-card--night .day-card__when span { color: #D3DBF7; }
.day-card--night .day-card__when span::before { color: #9FAAD6; }

/* ---------------------------------------------------------------- the four sets (800 x 660 units, in %) */
/* morning: the house, Iniya at the door, everything for PT day lined up and ticked */
.dm-sun { left: 64%; top: 2%; width: 23%; }
.dm-cloud { left: 30%; top: 9%; width: 20%; }
.dm-tree { left: 70%; bottom: 12%; width: 31%; }
.dm-house { left: 14%; bottom: 13%; width: 39.5%; }
.dm-girl { left: 23.8%; bottom: 8%; width: 11.3%; }
.dm-bag { left: 42%; bottom: 4%; width: 13%; }
.dm-thing { bottom: 4%; }
.dm-tiffin { left: 56.5%; width: 8.4%; }
.dm-bottle { left: 66%; width: 5.6%; }
.dm-card { left: 73.5%; width: 6.2%; bottom: 6%; }
.dm-shoes { left: 81.5%; width: 12.5%; display: flex; align-items: flex-end; gap: 6%; }
.dm-thing > .pk-mark { position: absolute; left: 50%; bottom: 100%; margin-bottom: 1.2cqi; translate: -50% 0; --pk-mark-size: 3.2cqi; }
.dm-idcard { position: relative; display: block; aspect-ratio: 3 / 4.2; padding: 18% 14%; border-radius: 9%; background: #FFFDF8;
  box-shadow: inset 0 0 0 .25cqi rgba(30, 42, 90, .12), 0 .15cqi .2cqi rgba(90, 42, 0, .3), .3cqi .9cqi 1cqi -.4cqi rgba(90, 42, 0, .4); }
.dm-idcard::before { content: ""; position: absolute; left: 22%; right: 22%; bottom: 100%; height: 3.2cqi; border: .45cqi solid #D84A3E; border-bottom: 0; border-radius: 50% 50% 0 0; }
.dm-idcard b { display: block; aspect-ratio: 1; border-radius: 12%; background: var(--sky); box-shadow: inset 0 -1.2cqi 0 #8FA3E8; }
.dm-idcard i { display: block; height: .5cqi; margin-top: 12%; border-radius: 1cqi; background: rgba(30, 42, 90, .35); }
.dm-idcard i:last-child { width: 70%; }
.dm-shoe { position: relative; flex: 1; aspect-ratio: 1.55; border-radius: 40% 60% 18% 22% / 70% 80% 22% 22%; background: #FFFFFF;
  box-shadow: inset 0 -.9cqi 0 #C9CFDB, inset .3cqi .3cqi 0 rgba(255, 255, 255, .8), 0 .15cqi .2cqi rgba(90, 42, 0, .3), .2cqi .7cqi .9cqi -.4cqi rgba(90, 42, 0, .4); }
.dm-shoe::after { content: ""; position: absolute; left: 30%; top: 22%; width: 34%; height: 30%;
  background: repeating-linear-gradient(90deg, transparent 0 18%, rgba(30, 42, 90, .45) 18% 30%); border-radius: .5cqi; }

/* evening: the window lights up; Appa's paper phone shows tomorrow and every line gets its tick */
.de-cloud { left: 34%; top: 9%; width: 16%; }
.de-house { left: 3%; bottom: 13%; width: 45%; aspect-ratio: 316 / 291; }
.de-house > img:first-child { position: absolute; inset: 0 auto auto 0; width: 100%; }
.de-light { position: absolute; display: block; max-width: none; height: auto; left: 43.67%; top: 36.77%; width: 40.82%; }
.de-appa { left: 43.5%; bottom: 4%; width: 14.8%; }
.de-phone { left: 61%; bottom: 2.5%; width: 33%; aspect-ratio: 282 / 526; container-type: inline-size; rotate: -2deg; }
.de-phone > img { position: absolute; display: block; max-width: none; height: auto; }
.de-phone__back { left: 0; top: 0; width: 100%; }
.de-phone__screen { left: 8.865%; top: 5.513%; width: 82.27%; }
.de-phone__bezel { left: 4.61%; top: .57%; width: 90.78%; }
/* the phone's screen: one grid for every row (a fixed label column of paper pills, each in its own soft colour; the
   words in a flexible column, two short lines at most; the tick centred on the row), equal gaps, no top gap beyond the
   side gap (the speaker and camera are in the bezel, above the screen). Owner review, 3 Nov. */
.de-phone__ui { position: absolute; left: 9.93%; top: 6.08%; width: 80.14%; height: 84.41%; overflow: hidden; border-radius: 9.2cqi;
  display: flex; flex-direction: column; padding: 7.5cqi 5.4cqi 0; font-size: 5.4cqi; line-height: 1.3; color: var(--ink); }
.de-ui__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .5em; }
.de-ui__word { font: 800 1.5em/1 var(--font-display); color: var(--blue); letter-spacing: -.01em; white-space: nowrap; }
.de-ui__head .tag { height: auto; min-height: 1.6em; padding: .2em .6em; font-size: max(11px, .74em); }
.de-ui__day { grid-column: 1 / -1; margin-top: .2em; font: 800 .9em/1.2 var(--font-body); color: var(--ink-2); }
.de-ui__who { display: inline-block; margin-top: .6em; padding: .28em .75em; border-radius: 999px; background: var(--sky); color: var(--blue-deep);
  font: 800 .82em/1.2 var(--font-body); white-space: nowrap; }
.de-ui__list { margin-top: .8em; display: grid; gap: .55em; }
.de-ui__row { display: grid; grid-template-columns: 3.6em minmax(0, 1fr) auto; align-items: center; column-gap: .5em; padding: .5em .5em .5em .45em;
  border-radius: .6em .7em .65em .55em; background: #FFFDF8; box-shadow: inset 0 1px 0 #FFFFFF, 0 .1em .15em rgba(90, 42, 0, .2); }
.de-ui__k { --c: var(--sky); --cf: var(--blue-deep); display: flex; align-items: center; justify-content: center; min-height: 1.9em; padding: .1em .2em;
  border-radius: .5em .6em .55em .45em / .55em .45em .6em .5em; background: var(--c); color: var(--cf); font: 800 .76em/1 var(--font-body);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 1px 0 rgba(90, 42, 0, .14); }
.de-ui__k--maths { --c: var(--sun); --cf: var(--ink); }
.de-ui__k--bring { --c: var(--pink); --cf: #8A2440; }
.de-ui__k--sign { --c: var(--mint); --cf: #1F6B3A; }
.de-ui__k--notice { --c: var(--sky); --cf: var(--blue-deep); }
.de-ui__t { font: 700 .86em/1.25 var(--font-body); color: var(--ink); }
.de-ui__row .pk-mark { --pk-mark-size: 1.4em; grid-column: 3; }
/* the form row: the signature sits under its words, the tick stays centred on the whole row */
.de-ui__row--sign { grid-template-rows: auto auto; row-gap: .1em; }
.de-ui__row--sign .de-ui__k { grid-row: 1; }
.de-ui__row--sign .pk-mark { grid-row: 1 / span 2; }
.de-ui__sig { grid-column: 2; grid-row: 2; display: block; width: 5.2em; height: 1.4em; overflow: clip; }
.de-ui__sig svg { display: block; width: 5.2em; height: 1.4em; }
/* the app's tab bar sits on the screen's foot */
.de-ui__tabs { margin: auto -5.4cqi 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: .55em .4em .9em; background: #FFFDF8;
  box-shadow: 0 -1px 0 rgba(30, 42, 90, .1); }
.de-ui__tabs span { display: grid; justify-items: center; gap: .2em; font: 800 .68em/1 var(--font-body); color: var(--ink-2); }
.de-ui__tabs img { width: 1.9em; height: 1.9em; opacity: .55; }
.de-ui__tabs .is-on { color: var(--blue); }
.de-ui__tabs .is-on img { opacity: 1; }
/* a small phone in the scene (tablets and phones): the pills and ticks carry it, the card beside it has the words */
@container (max-width: 259.98px) {
  .de-phone__ui { padding: 8cqi 6cqi 0; font-size: 6.4cqi; }
  .de-ui__word { font-size: 1.3em; }
  .de-ui__head .tag { grid-column: 1 / -1; grid-row: 3; justify-self: start; margin-top: .45em; }
  .de-ui__who, .de-ui__t, .de-ui__sig { display: none; }
  .de-ui__row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .de-ui__row--sign { grid-template-rows: auto; }
  .de-ui__k { padding-inline: .6em; }
  .de-ui__row .pk-mark { grid-column: 3; grid-row: 1; }
  .de-ui__tabs { margin-inline: -6cqi; }
  .de-ui__tabs span { font-size: 0; gap: 0; }
  .de-ui__tabs img { width: 13cqi; height: 13cqi; }
  .de-ui__list { flex: 1; align-content: space-evenly; margin-top: .4em; }
}

/* night: the sun asleep in its nightcap, Nila up, the packed bag by the door */
.dn-stars { left: -22%; top: -6%; width: 144%; opacity: .5; }
.dn-twinkle { left: 52%; top: 15%; width: 5.5%; }
.dn-sun { left: 4%; bottom: 22%; width: 21%; aspect-ratio: 357 / 376; }
.dn-sun > img:first-child { position: absolute; left: 15.97%; top: 1.6%; width: 84.03%; }
.dn-z { position: absolute; display: block; max-width: none; height: auto; }
.dn-z1 { left: 16.25%; top: 30.05%; width: 8.4%; }
.dn-z2 { left: 9.24%; top: 16.49%; width: 9.52%; }
.dn-z3 { left: 0; top: 0; width: 12.32%; }
.dn-nila { left: 66%; top: 4%; width: 24%; }
.dn-house { left: 36%; bottom: 14%; width: 31%; }
.dn-bag { left: 42%; bottom: 7%; width: 8.5%; }

/* ---------------------------------------------------------------- pop-up and the little things, on twos */
@keyframes day-pop {
  0% { transform: scale(1, .06); opacity: 1; }
  20% { transform: scale(1, .62); }
  40% { transform: scale(1, 1.1); }
  60% { transform: scale(1, .95); }
  80%, 100% { transform: none; opacity: 1; }
}
@keyframes day-tick {
  0% { transform: scale(.2); opacity: 1; }
  33% { transform: scale(1.28); }
  66% { transform: scale(.92); }
  100% { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.rm) .day.is-live .day__sheet:not(.is-played) .day__pop { opacity: 0; }
  html.js:not(.rm) .day.is-live .day__sheet.is-played .day__pop { transform-origin: 50% 100%; animation: day-pop 415ms steps(1, end) both; animation-delay: var(--d, 0ms); }
  html.js:not(.rm) .day.is-live .dm-thing > .pk-mark:not(.is-ticked) { opacity: 0; }
  html.js:not(.rm) .day.is-live .dm-thing > .pk-mark.is-ticked { animation: day-tick 250ms steps(1, end) both; }
  html.js:not(.rm) .day.is-live .day__sheet:not(.is-lit) .de-light { opacity: 0; }
  html.js:not(.rm) .day.is-live .de-ui__sig svg { transform: translateX(-100%); }
  html.js:not(.rm) .day.is-live .dn-z { opacity: 0; }
  html.js:not(.rm) .day.is-live .day__sheet:not(.is-played) .dm-sun { opacity: 0; transform: translateY(42%); }
  html.js:not(.rm) .day.is-live [data-mark].is-on { animation: day-tick 250ms steps(1, end) both; }
}
.day__sheet--morning .dm-tree { --d: 0ms; } .day__sheet--morning .dm-house { --d: 83ms; } .day__sheet--morning .dm-girl { --d: 249ms; }
.day__sheet--morning .dm-bag { --d: 415ms; } .dm-tiffin { --d: 498ms; } .dm-bottle { --d: 581ms; } .dm-card { --d: 664ms; } .dm-shoes { --d: 747ms; }
.de-house { --d: 0ms; } .de-appa { --d: 166ms; } .de-phone { --d: 332ms; }
.dn-sun { --d: 0ms; } .dn-house { --d: 83ms; } .dn-bag { --d: 249ms; } .dn-nila { --d: 332ms; }

/* reduced motion and no-JS: every mark is simply on */
@media (prefers-reduced-motion: reduce) { .day [data-mark] { background: var(--pk-mark-c); } .day [data-mark]::after { background: var(--pk-mark-ink); } }
html:not(.js) .day [data-mark] { background: var(--pk-mark-c); }
html:not(.js) .day [data-mark]::after { background: var(--pk-mark-ink); }
html.rm .day [data-mark] { background: var(--pk-mark-c); }
html.rm .day [data-mark]::after { background: var(--pk-mark-ink); }

/* ---------------------------------------------------------------- desktop with motion: the sticky stage
   R2 performance (3 Nov): the stage is laid out this way from the very first layout (scripting and motion welcome, a
   wide screen), not when 04-day.js adds .is-live: switching a long section's layout at script time cost a second full
   layout of the page on a mid phone. If the script never runs, the later sheets slide into place after 4 s. */
@media (scripting: enabled) and (min-width: 861px) and (prefers-reduced-motion: no-preference) {
  html:not(.rm) .day .day__story { grid-template-columns: minmax(0, 1fr); }
  html:not(.rm) .day .day__stage { display: block; grid-area: 1 / 1; align-self: start; position: sticky; top: 0; z-index: 0;
    height: 100vh; height: 100svh; overflow: clip visible; clip-path: inset(-64px 0 -64px 0); }
  html:not(.rm) .day .day__steps { display: block; grid-area: 1 / 1; position: relative; z-index: 1; width: var(--wrap); margin-inline: auto; }
  html:not(.rm) .day .day__sheet { position: absolute; inset: 0; padding: 0; display: block; overflow: clip visible; will-change: transform; }
  html:not(.rm) .day .day__sheet:not([data-scene="morning"]) { transform: translateY(calc(100% + 140px)); }
  html:not(.rm) .day:not(.is-live) .day__sheet:not([data-scene="morning"]) { animation: day-failsafe 1ms 4s forwards; }
  html:not(.rm) .day .day__set { position: absolute; bottom: 0; right: max(12px, calc((100vw - 1200px) / 2 - 36px)); width: var(--day-set-w); }
  html:not(.rm) .day .day__ground { bottom: -1px; height: 16.5%; }
  html:not(.rm) .day .day__step { min-height: 100vh; min-height: 100svh; margin: 0; padding: 0; display: flex; align-items: center; }
  html:not(.rm) .day .day-card { width: min(440px, 36vw); margin: 0; }
}
@media (scripting: enabled) and (min-width: 861px) and (max-width: 1100px) and (prefers-reduced-motion: no-preference) {
  html:not(.rm) .day { --day-set-w: min(64vw, 112svh); }
  html:not(.rm) .day .day-card { width: min(380px, 40vw); }
}
@keyframes day-failsafe { to { transform: none; } }

/* ---------------------------------------------------------------- phones */
@media (max-width: 560px) {
  .day__step { margin: -24px 0 52px; }
  .day-card h3 { font-size: 26px; }
}

@media (forced-colors: active) {
  .day-card { border: 1px solid CanvasText; }
}

/* R6 (9 Nov): felt mascots in the day story; at night Suri sleeps low behind the hill */
.dm-sun { left: 62%; top: 0; width: 24%; }
.dn-sun { left: 3%; bottom: -5%; width: 22%; aspect-ratio: 480 / 527; z-index: 0; }
.dn-sun .toy3d__poster { filter: brightness(.78) saturate(.85) drop-shadow(0 10px 10px rgba(0, 0, 0, .3)); }
.dn-sun::after { content: "z z z"; position: absolute; left: 68%; top: -6%; font: 800 clamp(14px, 1.7vw, 24px)/1 var(--font-display); letter-spacing: .25em; color: #FFE9B5; rotate: -14deg; text-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.dn-nila { left: 66%; top: 0; width: 26%; }

.dn-sun { aspect-ratio: 480 / 481; }
.dn-sun .toy3d__poster { filter: brightness(.9) drop-shadow(0 10px 10px rgba(0, 0, 0, .3)); }

/* the sleeping Suri rests on the hill, seen (owner 9 Nov: it was buried) */
.day .day__sheet--night .dn-sun, html.js .day .day__sheet--night .day__pop.dn-sun { bottom: 21% !important; left: 4%; width: 21%; }

/* the star sheet: wider than the sheet and faded at both ends, so its canvas edge never shows as a line */
.day .day__sheet--night .dn-stars { left: -22%; top: -6%; width: 144%; max-width: none; opacity: .5;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent); }
