/* The night scene: the hero of Why Sehal? and of the landing page (NightScene.astro). One page of an old khata
   writing itself in, a calculator, two customers asking on WhatsApp. Static and complete with reduced motion. */
.story, .night {
  --night: #031711; --night-2: #0A2A21; --night-3: #123A2F; --night-4: #1F5546;
  --lamp: #F6CF6A; --paper: #F4EFE1; --rule: #9DB3C9; --margin: #C2554A; --ink-blue: #1F3B6B; --cover: #6E2B26;
  --hand: 'Marhey', var(--f-brand);
}

/* ── The night: the accounts begin ─────────────────────────────────────────── */
:is(.story .night, .night) { background: var(--night); color: #AAC4BE; padding-block: clamp(3rem, 8vw, 6rem) 0; overflow: hidden; }
.night-in { display: grid; justify-items: center; text-align: center; gap: clamp(1.5rem, 4vw, 3rem); }
.night h1 { color: #EFF4F2; font-size: clamp(2.75rem, 9vw, 7.5rem); line-height: .98; letter-spacing: -.045em; margin: 0; }
/* Three set lines (the user, 2026-11-16): "The accounts" muted sage, the verdict white over a hand-drawn green line. */
.night .h-line { display: block; }
.night .h-muted { color: #9DC3B8; }
.night .h-mark { position: relative; display: inline-block; }
.night .h-mark::after { content: ''; position: absolute; inset-inline: -.04em -.02em; bottom: -.1em; height: max(2px, .025em); border-radius: 2px; background: #5FD39A; rotate: -1.2deg; transform-origin: left center; }
html[dir='rtl'] .night .h-mark::after { transform-origin: right center; rotate: 1.2deg; }
html[lang='ur'] .night h1 { font-size: clamp(2.25rem, 7vw, 5.5rem); line-height: 1.55; letter-spacing: 0; }
html[lang='ur'] .night .h-mark::after { bottom: .05em; }
.scene-wrap { position: relative; width: min(100%, 60rem); }
.night .scene { width: 100%; overflow: visible; direction: ltr; }
/* Two customers asking on WhatsApp late at night: the bubbles pop in first (0.4s, 0.9s), then the register writes in. */
.chats { position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.chat { position: absolute; display: grid; grid-template-columns: auto auto; column-gap: .75em; align-items: end; margin: 0; padding: .45em .7em .35em; border-radius: 0 .75em .75em .75em; background: #FFFFFF; color: #111B21; font: 400 clamp(.75rem, 1.95vw, 1.25rem)/1.35 var(--f-ui); text-align: start; box-shadow: 0 .6em 1.4em -.5em rgb(0 0 0 / .6); }
.chat::before { content: ''; position: absolute; top: 0; left: -.5em; width: .6em; height: .7em; background: inherit; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.chat b { grid-column: 1 / -1; font-size: .82em; font-weight: 600; color: #00715A; }
.chat-1 b { color: #B5651D; }
.chat span { font-size: 1.05em; white-space: nowrap; }
.chat span:lang(ur) { font-size: 1.1em; line-height: 1.7; }
.chat time { font-size: .7em; color: #667781; white-space: nowrap; direction: ltr; }
/* Each bubble reaches 15% of its own width over the register's edge (the page runs 32.7%–69% of the scene). */
.chat-0 { right: 67.3%; top: 38%; translate: 15% 0; }
.chat-1 { left: 69%; top: 20%; translate: -15% 0; }
@media (max-width: 560px) {
  /* No room around the page on a phone: the two messages sit in a row above the scene. */
  .scene-wrap { display: flex; flex-direction: column; }
  .chats { order: -1; position: static; display: flex; flex-direction: column; direction: ltr; gap: .5rem; padding-inline-start: .5rem; margin-bottom: .25rem; }
  .chat { position: relative; inset: auto; translate: none; align-self: flex-start; font-size: .8125rem; }
  .chat-1 { align-self: flex-end; }
}
@media (prefers-reduced-motion: no-preference) {
  .chat { animation: chat-in .45s cubic-bezier(.3, 1.4, .5, 1) .4s both; transform-origin: top left; }
  .chat-1 { animation-delay: .9s; }
  @keyframes chat-in { from { opacity: 0; scale: .6; translate: 0 .5rem; } }
}

.scene { display: block; width: 100%; height: auto; }
.scene .wall { fill: var(--night); }
.scene .window rect { fill: var(--night); stroke: var(--night-4); stroke-width: 6; }
.scene .window path:not(.moon-c) { stroke: var(--night-4); stroke-width: 4; fill: none; }
.scene .window circle, .scene .moon-c { fill: #EFE6C8; }
.scene .wall-clock circle:first-child { fill: #DCE6E2; stroke: var(--night-4); stroke-width: 4; }
.scene .wall-clock path { stroke: var(--night); stroke-width: 2; stroke-linecap: round; }
.scene .wall-clock .hand { stroke-width: 3.5; }
.scene .pin { fill: var(--night); }
.scene .counter { fill: var(--night-3); }
.scene .counter-top { fill: var(--night-4); }
.scene .cup ellipse, .scene .cup path:not(.steam):not(.cup-handle) { fill: #DCE6E2; }
.scene .cup-handle { fill: none; stroke: #DCE6E2; stroke-width: 5; }
.scene .steam { fill: none; stroke: #DCE6E2; stroke-width: 2.5; stroke-linecap: round; opacity: .45; }
/* The khata (2D, replaced the three.js desk 2026-11-16): kraft cover, yellowed leaves, grain, foxing, curved rules. */
.scene .kraft { fill: #A9803F; }
.scene .stack { fill: #CDB98C; }
.scene .leaf-l { fill: url(#leaf-l); } .scene .leaf-r { fill: url(#leaf-r); }
.scene .age { fill: url(#age); }
.scene .grain { fill: #fff; opacity: .55; mix-blend-mode: multiply; }
.scene .lines { fill: none; stroke: #7F96A6; stroke-width: .55; opacity: .7; }
.scene .head { fill: none; stroke: #6FA58A; stroke-width: .7; stroke-dasharray: 2 1.4; }
.scene .pink { stroke: #D2557E; stroke-width: .9; opacity: .8; }
.scene .print text { font: 600 6px Georgia, serif; fill: #5C5446; }
.scene .spots ellipse { fill: #8B6A35; opacity: .14; filter: url(#soft); }
.scene .spots circle { fill: #7E5C2C; opacity: .35; }
.scene .ring { fill: none; stroke: #8B6A35; stroke-width: 2.4; stroke-dasharray: 60 6 18 4; opacity: .28; }
.scene .spine { fill: #5E4A2A; opacity: .28; filter: url(#soft); }
.scene .ear { fill: #CDB98C; } .scene .ear-back { fill: #EADFBE; }
.scene .ink text { font: 400 13px var(--hand); fill: #23407A; }
.scene .ink .amt { direction: ltr; }
.scene .strike { stroke: var(--margin); stroke-width: 1.3; stroke-linecap: round; }
.scene .circle-red { fill: none; stroke: var(--margin); stroke-width: 1.1; }
.scene .pen-body { stroke: #24468C; stroke-width: 4.2; stroke-linecap: round; }
.scene .pen-cap { stroke: #EFF4F2; stroke-width: 4.6; stroke-linecap: round; }
.scene .pen-tip { stroke: #2A2A2A; stroke-width: 2; stroke-linecap: round; }
/* The calculator: 4, 3, 7, 0 and = pressed in turn on a 7-second loop; without motion it shows 4,370. */
.scene .calc-body { fill: #1E2A26; stroke: #0E1613; stroke-width: 1.5; }
.scene .calc-lcd { fill: #B7CB9C; }
.scene .calc-digits text { font: 600 11px var(--f-ui); fill: #18261F; font-variant-numeric: tabular-nums; opacity: 0; }
.scene .calc-digits .d4 { opacity: 1; }
.scene .key rect { fill: #46524E; transform-box: fill-box; }
.scene .key.op rect { fill: #2F8F5B; }
.scene .key text { font: 600 6px var(--f-ui); fill: #EFF4F2; pointer-events: none; }

/* The one page-load moment: the lamp comes on, then the night's figures write themselves in, right to left. */
@media (prefers-reduced-motion: no-preference) {
  .night .h-mark::after { animation: underline .6s cubic-bezier(.5, 0, .2, 1) .2s both; }
  .scene .glow { animation: lamp-on 1.4s ease-out both; }
  .scene .ink > g { animation: write-in .55s ease-out both; animation-delay: calc(1.6s + var(--i, 0) * .2s); }
  .scene .ink > g:nth-child(2) { --i: 1; }
  .scene .ink > g:nth-child(3) { --i: 2; }
  .scene .ink > g:nth-child(4) { --i: 3; }
  .scene .ink > g:nth-child(5) { --i: 4; }
  .scene .ink > g:nth-child(6) { --i: 5; }
  .scene .ink > g:nth-child(7) { --i: 6; }
  .scene .ink > g:nth-child(8) { --i: 7; }
  .scene .ink > g:nth-child(9) { --i: 8; }
  .scene .ink > g:nth-child(10) { --i: 9; }
  .scene .calc-digits text { animation: 7s steps(1, end) infinite; }
  .scene .calc-digits .d0 { animation-name: d0; } .scene .calc-digits .d1 { animation-name: d1; } .scene .calc-digits .d2 { animation-name: d2; }
  .scene .calc-digits .d3 { animation-name: d3; } .scene .calc-digits .d4 { animation-name: d4; }
  .scene :is(.k-4, .k-3, .k-7, .k-0, .k-eq) rect { animation: key-press 7s ease-out infinite; }
  .scene .k-3 rect { animation-delay: 1s; } .scene .k-7 rect { animation-delay: 2s; } .scene .k-0 rect { animation-delay: 3s; } .scene .k-eq rect { animation-delay: 4s; }
  .scene .strike, .scene .circle-red { animation: fade-in .5s ease-out 3.4s both; }
  .scene .steam { animation: steam 3s ease-in-out 3; }
  .scene .steam + .steam { animation-delay: 1.2s; }
}
@keyframes lamp-on { 0% { opacity: 0; } 18% { opacity: .9; } 26% { opacity: .2; } 40% { opacity: 1; } 52% { opacity: .5; } 100% { opacity: 1; } }
@keyframes write-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes underline { from { scale: 0 1; } }
@keyframes d0 { 0% { opacity: 1; } 14.28%, 100% { opacity: 0; } }
@keyframes d1 { 0% { opacity: 0; } 14.28% { opacity: 1; } 28.57%, 100% { opacity: 0; } }
@keyframes d2 { 0% { opacity: 0; } 28.57% { opacity: 1; } 42.85%, 100% { opacity: 0; } }
@keyframes d3 { 0% { opacity: 0; } 42.85% { opacity: 1; } 57.14%, 100% { opacity: 0; } }
@keyframes d4 { 0% { opacity: 0; } 57.14%, 100% { opacity: 1; } }
@keyframes key-press { 0% { translate: 0 1px; fill: #A7CDC4; } 6%, 100% { translate: 0 0; } }
@keyframes steam { 0%, 100% { opacity: 0; translate: 0 6px; } 50% { opacity: .5; translate: 0 -4px; } }

/* The landing page's pitch, between the heading and the scene: always on the night ground, whatever the theme. */
.night .pitch { display: grid; justify-items: center; max-width: 40rem; }
.night .pitch .lede { margin: 0; color: #C9DBD6; font-size: clamp(1.125rem, 2vw, 1.375rem); text-wrap: balance; }
.night .pitch .ctas { margin-top: 1.5rem; }
.night .pitch .quiet { color: #8FE3C0; }
.night .pitch .cta-note { color: #89A8A0; margin-top: .75rem; }
/* A smaller heading than Why Sehal?'s, so the register starts to show above the fold. */
.night:has(.pitch) h1 { font-size: clamp(2.5rem, 7vw, 5.5rem); }
.night:has(.pitch) .night-in { gap: clamp(1.25rem, 3vw, 2rem); }
