/* Pagelight, the landing page.

   Glass over colour, a real textbook in 3D, and one scroll story that shows
   what the product does: you ask, the book opens, the line lights up, the
   answer lifts off the page.

   Glass is done properly or not at all: a frosted fill, a hairline edge, a
   bright top highlight, a shadow tinted to the scene, and a sheen that
   follows the pointer. Blur alone is what makes glass look cheap.

   Dark is the first design; light is the same page in daylight. The book's
   pages are paper in both. */

:root {
  --bg: #06070C;
  --text: #F2F3F7;
  --text-2: rgba(242, 243, 247, .72);
  --text-3: rgba(242, 243, 247, .5);
  --glass: rgba(255, 255, 255, .07);
  --glass-2: rgba(255, 255, 255, .03);
  --edge: rgba(255, 255, 255, .14);
  --edge-top: rgba(255, 255, 255, .28);
  --shadow: 0 30px 80px -30px rgba(2, 4, 14, .75);
  --hl: #FFD34D;
  --hl-ink: #1D1500;
  --teal: #1FB5A9;
  --coral: #FF7A59;
  --blob-a: rgba(31, 181, 169, .42);
  --blob-b: rgba(255, 211, 77, .28);
  --blob-c: rgba(255, 122, 89, .26);
  --solid-bg: #F2F3F7;
  --solid-text: #06070C;
  /* glass that sits over the white book page must stay readable */
  --glass-strong: rgba(12, 14, 22, .66);
  --display: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", "Readex Pro", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --r: 22px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #EEF1F6; --text: #0B0D14; --text-2: rgba(11, 13, 20, .7); --text-3: rgba(11, 13, 20, .5);
    --glass: rgba(255, 255, 255, .55); --glass-2: rgba(255, 255, 255, .32); --edge: rgba(255, 255, 255, .75); --edge-top: rgba(255, 255, 255, .95);
    --shadow: 0 30px 70px -34px rgba(40, 56, 90, .35);
    --blob-a: rgba(31, 181, 169, .30); --blob-b: rgba(255, 196, 40, .30); --blob-c: rgba(255, 122, 89, .24);
    --solid-bg: #0B0D14; --solid-text: #F2F3F7;
    --glass-strong: rgba(255, 255, 255, .78);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #EEF1F6; --text: #0B0D14; --text-2: rgba(11, 13, 20, .7); --text-3: rgba(11, 13, 20, .5);
  --glass: rgba(255, 255, 255, .55); --glass-2: rgba(255, 255, 255, .32); --edge: rgba(255, 255, 255, .75); --edge-top: rgba(255, 255, 255, .95);
  --shadow: 0 30px 70px -34px rgba(40, 56, 90, .35);
  --blob-a: rgba(31, 181, 169, .30); --blob-b: rgba(255, 196, 40, .30); --blob-c: rgba(255, 122, 89, .24);
  --solid-bg: #0B0D14; --solid-text: #F2F3F7;
  --glass-strong: rgba(255, 255, 255, .78);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* No scroll-behavior: smooth here. The scroll library jumps to the top to
   measure, and a smooth jump is still gliding when it measures, which put
   every trigger off by the scroll position. Links glide via next.js. */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.75 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--hl); outline-offset: 3px; border-radius: 8px; }

/* ---------- the opening ---------- */

/* The mark builds itself (.mk, in boot.css). Then the highlighted line
   becomes a seam of light across the whole screen, the dark splits along it
   like a book opening, and the 3D book flies in (next.js). Only while html
   has .intro-on; .intro-out is added when the pages have loaded. */
.intro { display: none; }
.intro-on .intro { display: block; position: fixed; inset: 0; z-index: 100; cursor: pointer; }
/* taps go through to the page the moment it starts opening, not 1.3s later */
.intro-on.intro-out .intro { visibility: hidden; pointer-events: none; transition: visibility 0s 1.3s; }
/* --seam: the height of the mark's highlighted line, set by next.js as the
   curtain opens, so the screen splits exactly along it */
.intro-half { position: absolute; inset-inline: 0; background: var(--bg); transition: transform .95s cubic-bezier(.75, 0, .15, 1) .32s; }
/* the edges that part are lit by the seam, like pages caught in light */
/* only once they part: before that the lit edge was a faint line across the boot */
.intro-top { top: 0; height: calc(var(--seam, 50%) + 1px); }
.intro-bot { top: var(--seam, 50%); bottom: 0; }
.intro-on.intro-out .intro-top { box-shadow: inset 0 -1px 0 rgba(255, 211, 77, .45), 0 18px 40px -10px rgba(255, 211, 77, .16); }
.intro-on.intro-out .intro-bot { box-shadow: inset 0 1px 0 rgba(255, 211, 77, .45), 0 -18px 40px -10px rgba(255, 211, 77, .16); }
.intro-on.intro-out .intro-top { transform: translateY(-101%); }
.intro-on.intro-out .intro-bot { transform: translateY(101%); }
/* the seam: the highlighter's line, drawn across the screen */
.intro-seam { position: absolute; top: var(--seam, 50%); inset-inline: 0; height: 3px; margin-top: -1.5px; z-index: 2; background: var(--hl);
  box-shadow: 0 0 22px 3px rgba(255, 211, 77, .75), 0 0 80px 10px rgba(255, 211, 77, .3);
  transform: scaleX(0); transform-origin: center; opacity: 0; }
.intro-on.intro-out .intro-seam { animation: seam 1.25s cubic-bezier(.65, 0, .35, 1) forwards; }
@keyframes seam {
  0% { transform: scaleX(0); opacity: 1; }
  30% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1) scaleY(.4); opacity: 0; }
}
.intro-core { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; }
.intro-on.intro-out .intro-core { opacity: 0; transform: scale(1.08); filter: blur(6px); transition: opacity .35s ease-in, transform .45s ease-in, filter .35s; }

/* the hero's lines wait for the curtain, then rise one after another */
.intro-on .hero-copy > * { opacity: 0; transform: translateY(18px); }
.intro-on.intro-out .hero-copy > * { opacity: 1; transform: none; transition: opacity .8s var(--ease) .55s, transform .8s var(--ease) .55s; }
.intro-on.intro-out .hero-copy > :nth-child(2) { transition-delay: .63s; }
.intro-on.intro-out .hero-copy > :nth-child(3) { transition-delay: .71s; }
.intro-on.intro-out .hero-copy > :nth-child(4) { transition-delay: .79s; }

/* ---------- the colour the glass frosts over ---------- */

.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; opacity: 1; will-change: transform; animation: drift 26s var(--ease) infinite alternate; }
.aurora i:nth-child(1) { background: radial-gradient(circle, var(--blob-a), transparent 65%); top: -20vmax; inset-inline-start: -10vmax; }
.aurora i:nth-child(2) { background: radial-gradient(circle, var(--blob-b), transparent 65%); top: 30vh; inset-inline-end: -22vmax; animation-duration: 32s; }
.aurora i:nth-child(3) { background: radial-gradient(circle, var(--blob-c), transparent 65%); bottom: -30vmax; inset-inline-start: 20vw; animation-duration: 38s; }
@keyframes drift { to { transform: translate3d(6vw, 4vh, 0) scale(1.12); } }
/* a little grain, so the gradients read as light and not as banding */
body::after { content: ""; position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; pointer-events: none; display: block; }

/* ---------- glass ---------- */

.glass {
  position: relative;
  background: linear-gradient(180deg, var(--glass), var(--glass-2));
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  box-shadow: inset 0 1px 0 var(--edge-top), inset 0 -1px 0 rgba(255, 255, 255, .03), var(--shadow);
  isolation: isolate;
}
/* the sheen that follows the pointer */
.glass::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, .16), transparent 45%); }
.glass:hover::before { opacity: 1; }

/* ---------- buttons ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 12px; font: 600 15px var(--body); text-decoration: none; white-space: nowrap; transition: transform .2s var(--ease), background-color .2s; }
.btn:active { transform: scale(.97); }
.btn-solid { background: var(--solid-bg); color: var(--solid-text); }
.btn-solid:hover { transform: translateY(-1px); }
.btn-glass { background: var(--glass); color: var(--text); border: 1px solid var(--edge); box-shadow: inset 0 1px 0 var(--edge-top); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 14px; }

/* ---------- nav: a floating glass bar ---------- */

.nav { position: fixed; z-index: 20; top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 28px));
  display: flex; align-items: center; gap: 20px; padding: 8px 8px 8px 8px; padding-inline-start: 18px; border-radius: 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 600 18px var(--display); text-decoration: none; }
/* the mark: tools/brand.py draws it */
.logo { width: 26px; height: 26px; border-radius: 7px; background: url("/static/logo.svg") center / contain no-repeat; flex: none; }
.logo.sm { width: 18px; height: 18px; border-radius: 5px; }
.nav-links { display: flex; gap: 22px; margin-inline-start: auto; font-size: 15px; color: var(--text-2); }
.nav-links a { text-decoration: none; } .nav-links a:hover { color: var(--text); }
@media (max-width: 640px) { .nav-links { display: none; } .nav .btn { margin-inline-start: auto; } }

/* ---------- hero ---------- */

.hero { min-height: 100svh; display: grid; align-items: center; padding: calc(110px + env(safe-area-inset-top, 0px)) max(16px, 5vw) 80px; position: relative; }
.hero-copy { width: min(720px, 100%); display: grid; gap: 22px; }
/* Arabic labels use the Arabic face, never letter-spaced: spacing breaks the joins */
.eyebrow { font: 500 14px var(--body); color: var(--text-3); }
.hero h1 { font-size: clamp(34px, 3.9vw, 54px); line-height: 1.18; font-weight: 600; }
.hero h1 .ink { background: linear-gradient(var(--hl), var(--hl)) no-repeat 100% 86% / 0% 30%; padding-inline: .05em; animation: ink 1s .6s var(--ease) forwards; }
@keyframes ink { to { background-size: 100% 30%; } }
.sub { font-size: 19px; color: var(--text-2); max-width: 36ch; }
.ctas { display: flex; flex-wrap: wrap; gap: 10px; }
.scroll-hint { position: absolute; bottom: 26px; inset-inline-start: 50%; transform: translateX(50%); display: grid; justify-items: center; gap: 8px; font-size: 13px; color: var(--text-3); text-decoration: none; }
.scroll-hint i { width: 22px; height: 34px; border-radius: 12px; border: 1.5px solid var(--text-3); position: relative; }
.scroll-hint i::after { content: ""; position: absolute; top: 6px; left: 50%; width: 3px; height: 7px; border-radius: 2px; background: var(--text-2); transform: translateX(-50%); animation: wheel 1.8s var(--ease) infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translate(-50%, -3px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 10px); } }
/* phones, and tablets held upright: the text above, the book below */
@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) {
  .hero { align-items: start; padding-top: calc(100px + env(safe-area-inset-top, 0px)); }
  .hero h1 { font-size: clamp(34px, 9vw, 46px); }
  .sub { font-size: 17px; }
  .scroll-hint { display: none; }
}

/* ---------- the story ---------- */

.story .glass { background: var(--glass-strong); }

.story { height: 440vh; position: relative; }
/* held on screen while the story plays out underneath the scroll */
.pin { position: sticky; top: 0; height: 100vh; height: 100svh; width: 100%; overflow: hidden; }
.steps { position: absolute; inset-inline-start: max(16px, 5vw); top: 50%; transform: translateY(-50%); width: min(380px, calc(100% - 32px)); padding: 26px 28px 22px; min-height: 196px; }
/* the old step leaves before the new one arrives, so they never overlap */
.step { position: absolute; inset: 26px 28px auto; opacity: 0; transform: translateY(10px); transition: opacity .2s var(--ease), transform .2s var(--ease); display: grid; gap: 8px; }
.step.is-on { opacity: 1; transform: none; transition-duration: .45s; transition-delay: .2s; }
.step-n { font: 500 13px var(--body); color: var(--text-3); }
.step h2 { font-size: 30px; font-weight: 600; line-height: 1.2; }
.step p { color: var(--text-2); }
.dots { position: absolute; bottom: 18px; inset-inline-start: 28px; display: flex; gap: 6px; }
.dots i { width: 18px; height: 3px; border-radius: 2px; background: var(--edge); transition: background-color .3s, width .3s; }
.dots i.on { background: var(--hl); width: 30px; }

.ask { position: absolute; inset-inline-end: max(16px, 7vw); top: 18vh; padding: 12px 18px; border-radius: 18px 18px 18px 6px; opacity: 0; display: grid; gap: 2px; }
.ask-label { font: 500 12px var(--body); color: var(--text-3); }
.ask p { font: 600 20px var(--display); }

.answer { position: absolute; inset-inline-end: max(16px, 6vw); bottom: 12vh; width: min(460px, calc(100% - 32px)); padding: 20px 22px; opacity: 0; display: grid; gap: 10px; }
.answer-head { display: flex; align-items: center; gap: 8px; font: 600 14px var(--display); }
.cite { margin-inline-start: auto; font: 500 12.5px var(--body); color: var(--hl); border: 1px solid color-mix(in srgb, var(--hl) 55%, transparent); border-radius: 8px; padding: 1px 8px; }
.answer p { font-size: 17px; line-height: 1.85; }
.answer mark { background: color-mix(in srgb, var(--hl) 35%, transparent); color: inherit; border-radius: 4px; padding: 0 .15em; }
.answer-more { color: var(--text-2); font-size: 15px !important; }

/* phones, and tablets held upright: the text above, the book below */
@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) {
  .steps { top: auto; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: none; min-height: 168px; padding: 20px 20px 18px; }
  .step { inset: 20px 20px auto; }
  .step h2 { font-size: 24px; }
  .dots { inset-inline-start: 20px; bottom: 14px; }
  .ask { top: calc(86px + env(safe-area-inset-top, 0px)); inset-inline-end: 16px; }
  .ask p { font-size: 17px; }
  .answer { top: calc(178px + env(safe-area-inset-top, 0px)); bottom: auto; inset-inline-end: 16px; padding: 16px 18px; }
  .answer p { font-size: 15px; }
}

/* ---------- features ---------- */

.features { padding: 120px max(16px, 5vw) 60px; display: grid; gap: 40px; }
.sec-head { display: grid; gap: 10px; max-width: 640px; }
.sec-head h2 { font-size: clamp(30px, 4vw, 46px); line-height: 1.15; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; perspective: 1400px; }
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid { grid-template-columns: minmax(0, 1fr); } }
/* the tilt is set from script, so it can share the transform with the entrance */
.card { padding: 18px 18px 22px; display: grid; gap: 8px; align-content: start; transform-style: preserve-3d; min-width: 0; }
.card h3 { font-size: 20px; font-weight: 600; margin-top: 8px; }
.card p { color: var(--text-2); font-size: 15.5px; }

/* the small working previews inside each card; book bits are paper */
.viz { position: relative; height: 150px; border-radius: 14px; overflow: hidden; background: rgba(0, 0, 0, .18); border: 1px solid var(--edge); transform: translateZ(20px); }
.paper { position: absolute; inset: 14px 22% 14px 22%; background: #F7F4EC; border-radius: 4px; padding: 14px 12px; display: grid; gap: 7px; align-content: start; box-shadow: 0 12px 24px -12px rgba(0, 0, 0, .5); }
.paper i { display: block; height: 6px; border-radius: 3px; background: #D9D4C7; }
.paper i:nth-child(2n) { width: 80%; margin-inline-start: auto; }
.viz-snap .paper i.hit { background: rgba(255, 211, 77, .9); }
.viz-snap .vf { position: absolute; inset: 22px 16%; z-index: 2; }
.viz-snap .vf b { position: absolute; width: 18px; height: 18px; border-color: var(--hl); border-style: solid; border-width: 0; }
.viz-snap .vf b:nth-child(1) { top: 0; right: 0; border-top-width: 2.5px; border-right-width: 2.5px; } .viz-snap .vf b:nth-child(2) { top: 0; left: 0; border-top-width: 2.5px; border-left-width: 2.5px; }
.viz-snap .vf b:nth-child(3) { bottom: 0; right: 0; border-bottom-width: 2.5px; border-right-width: 2.5px; } .viz-snap .vf b:nth-child(4) { bottom: 0; left: 0; border-bottom-width: 2.5px; border-left-width: 2.5px; }
.viz-snap .scan { position: absolute; inset-inline: 16%; height: 2px; background: var(--hl); box-shadow: 0 0 12px var(--hl); z-index: 3; animation: scan 2.6s var(--ease) infinite; }
@keyframes scan { 0% { top: 24px; } 50% { top: calc(100% - 26px); } 100% { top: 24px; } }
.viz-select .box { position: absolute; inset: 44px 20% 58px 20%; border: 1.5px solid #0B0D14; border-radius: 3px; background: rgba(255, 211, 77, .25); }
.viz-select .box b { position: absolute; width: 8px; height: 8px; background: #fff; border: 1.5px solid #0B0D14; border-radius: 2px; }
.viz-select .box b:nth-child(1) { top: -5px; right: -5px; } .viz-select .box b:nth-child(2) { top: -5px; left: -5px; } .viz-select .box b:nth-child(3) { bottom: -5px; right: -5px; } .viz-select .box b:nth-child(4) { bottom: -5px; left: -5px; }
.pill-row { position: absolute; bottom: 12px; inset-inline: 20%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pill-row em { font: 600 11px var(--body); font-style: normal; text-align: center; padding: 5px 0; border-radius: 8px; background: var(--hl); color: var(--hl-ink); }
.pill-row em.ghost { background: rgba(255, 255, 255, .85); color: #0B0D14; }
.viz-black .paper i.bar { height: 9px; background: #0D0F14; }
.viz-black .paper i.bar.open { background: rgba(255, 211, 77, .85); animation: reveal 3.2s var(--ease) infinite; }
@keyframes reveal { 0%, 30% { background: #0D0F14; } 45%, 100% { background: rgba(255, 211, 77, .85); } }
.viz-map { display: grid; place-items: center; color: var(--text); }
.viz-map svg { width: 82%; height: auto; }
.viz-map rect { fill: var(--glass); stroke: var(--edge-top); stroke-width: 1; }
.viz-map rect.lit { fill: rgba(255, 211, 77, .85); stroke: none; }
.viz-share { display: grid; place-items: center; }
.viz-share .msg { width: 70%; background: rgba(255, 255, 255, .92); border-radius: 12px 12px 12px 4px; padding: 6px; display: grid; gap: 6px; box-shadow: 0 12px 24px -12px rgba(0, 0, 0, .5); }
.viz-share .crop { background: #F7F4EC; border-radius: 8px; padding: 10px; display: grid; gap: 6px; }
.viz-share .crop i { height: 6px; border-radius: 3px; background: #D9D4C7; } .viz-share .crop i.hl { background: rgba(255, 211, 77, .9); }
.viz-share .msg-t { font-size: 11px; color: #1F2430; padding: 0 4px 2px; }
.viz-removed { padding: 16px 22px; display: grid; gap: 8px; align-content: center; }
.viz-removed .row { display: flex; align-items: center; gap: 10px; font-size: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--edge); }
.viz-removed .tick { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--text-3); flex: none; }
.viz-removed .tick.on { background: var(--coral); border-color: var(--coral); }
.viz-removed .gone { text-decoration: line-through; text-decoration-color: var(--coral); text-decoration-thickness: 2px; color: var(--text-3); }
.viz-removed .stamp { position: absolute; inset-inline-start: 18px; top: 46%; transform: rotate(-10deg); border: 2px solid var(--coral); color: var(--coral); font: 700 15px var(--display); padding: 2px 10px; border-radius: 6px; }

/* ---------- the end ---------- */

.final { padding: 80px max(16px, 5vw) 60px; }
.final-card { max-width: 900px; margin: 0 auto; padding: clamp(36px, 6vw, 64px); text-align: center; display: grid; justify-items: center; gap: 16px; }
.final-card h2 { font-size: clamp(32px, 5vw, 54px); font-weight: 600; line-height: 1.15; }
.final-card p { color: var(--text-2); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; padding: 28px max(16px, 5vw) calc(36px + env(safe-area-inset-bottom, 0px)); color: var(--text-3); font-size: 14px; }

/* when there is no 3D (no WebGL, or reduced motion), the story is a list */
.no3d .story { height: auto; padding: 40px max(16px, 5vw); }
.no3d .pin { height: auto; display: grid; gap: 16px; overflow: visible; }
.no3d .steps, .no3d .ask, .no3d .answer { position: relative; inset: auto; transform: none; opacity: 1; width: auto; max-width: 560px; }
/* the scroll animation may already have hidden them with inline styles
   (the 3D started, then lost its GPU): the cards still show */
.no3d .ask, .no3d .answer { opacity: 1 !important; transform: none !important; }
.no3d .step { position: relative; inset: auto; opacity: 1; transform: none; padding-block: 8px; }
.no3d .dots { display: none; }

@media (prefers-reduced-motion: reduce) {
  .aurora i, .viz-snap .scan, .viz-black .paper i.bar.open, .scroll-hint i::after { animation: none; }
  .hero h1 .ink { animation: none; background-size: 100% 30%; }
}
