/* يومًا ما · one day — the hour before sunrise
   Tokens are law (brand/brand-guideline.md). One accent. No gold, no pure black, no pure white. */

@font-face {
  font-family: 'Amiri';
  src: url('../assets/amiri.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Cormorant';
  src: url('../assets/cormorant.woff2') format('woff2');
  font-weight: 300 700;
  font-display: block;
}

:root {
  --ink: #1A202B;
  --ink-warm: #232634;
  --sand: #EAE3D6;
  --bone: #F3EEE5;
  --first-light: #C08552;
  --dawn-1: #161B26;
  --dawn-2: #2E3040;
  --dawn-3: #6A5262;
  --dawn-4: #B8815F;
  --ease-dawn: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-veil: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 240ms;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: 'Amiri', 'Geeza Pro', serif;
  font-size: 24px;
  line-height: 1.9;
  overflow-x: hidden;
}

[lang="en"], .hero-en, .s-en, .m-en, .spec-en, .cta-en, .close-en, .foot-en, .price-en, .card-copy-en {
  font-family: 'Cormorant', 'Didot', Georgia, serif;
  font-weight: 400;
  line-height: 1.7;
}

/* ---------- fixed layers ---------- */
#dawn { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: var(--ink); }
/* will-change stays here deliberately: the sky is the page's one long-running animated layer */
#dawn .sky {
  height: 600vh;
  will-change: transform;
  background: linear-gradient(
    180deg,
    var(--ink)     0%,
    var(--ink)     25%,
    var(--ink-warm) 33%,
    var(--dawn-3)  50%,
    var(--dawn-4)  66%,
    #E7D8BF        71%,
    var(--sand)    75%,
    var(--sand)    100%
  );
}

.grain {
  position: fixed; inset: -50%; z-index: 30; pointer-events: none;
  opacity: .025; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- skip link ---------- */
.skip {
  position: fixed; top: -80px; right: 16px; z-index: 40;
  background: var(--ink); color: var(--bone);
  padding: 10px 20px; font-size: 17px; text-decoration: none;
  border: 1px solid var(--first-light);
  transition: top var(--t-fast) var(--ease-dawn);
}
.skip:focus-visible { top: 16px; outline: none; }

/* ---------- acts, shared ---------- */
.act {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 96px 28px;
  position: relative;
}

.blank {
  display: inline-block; height: .06em; vertical-align: baseline;
  border-bottom: 3px solid var(--first-light);
}
.blank-static {
  display: inline-block; width: 90px; height: .06em; vertical-align: baseline;
  border-bottom: 2px solid var(--first-light);
}

a:focus-visible, .cta:focus-visible { outline: 2px solid var(--first-light); outline-offset: 4px; }

/* ---------- act I · hero ---------- */
.act--hero { min-height: 100svh; }
.hero { display: flex; flex-direction: column; align-items: center; font-weight: 400; }
.hero-ar { font-size: clamp(56px, 9vw, 108px); line-height: 1.5; }
.blank--hero { width: clamp(120px, 22vw, 260px); transform-origin: 100% 50%; }
.hero-en {
  font-size: clamp(26px, 3.6vw, 44px);
  letter-spacing: .16em; margin-top: 10px; opacity: .85;
}
/* the English echo's line is bone, not first-light — the blank device appears exactly three times */
.blank--hero-en { width: clamp(70px, 12vw, 150px); border-bottom-width: 2px; border-bottom-color: rgba(243, 238, 229, .55); }

.scroll-hint {
  position: absolute; bottom: 44px; left: 50%;
  width: 1px; height: 56px; background: var(--bone);
  opacity: .35;
  animation: breathe 2.4s var(--ease-veil) infinite;
}
@keyframes breathe { 0%, 100% { opacity: .3; } 50% { opacity: .6; } }

/* ---------- act II · sentences ---------- */
.act--sentences .stage { position: relative; width: 100%; max-width: 980px; height: 60vh; display: flex; align-items: center; justify-content: center; }
body.js .act--sentences .sentence { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.sentence .s-ar { font-size: clamp(40px, 7.5vw, 88px); line-height: 1.6; text-wrap: balance; }
.sentence .s-en { font-size: clamp(18px, 2.2vw, 27px); letter-spacing: .14em; opacity: .6; margin-top: 14px; }
.s-ar--big { font-size: clamp(64px, 10vw, 128px); }
.s-ar--blank { font-size: clamp(34px, 5.5vw, 68px); margin-top: 8px; }
.blank--you { width: clamp(110px, 18vw, 220px); transform-origin: 100% 50%; }

/* ---------- act III · manifesto ---------- */
/* clip: the oversized veil must never widen the document — in RTL that shifts the whole page */
.act--manifesto { overflow: clip; }
.act--manifesto .stage { position: relative; width: 100%; max-width: 860px; display: flex; align-items: center; justify-content: center; }
.act--manifesto .veil {
  position: absolute; inset: -20% -40%;
  background: radial-gradient(closest-side, rgba(26, 32, 43, .42), rgba(26, 32, 43, 0) 72%);
  opacity: 0;
}
/* two identical layers stacked in one grid cell; JS crossfades bone → ink as the sky lightens */
.m-stack { position: relative; display: grid; }
.m-stack .manifesto { grid-area: 1 / 1; }
.manifesto { position: relative; display: flex; flex-direction: column; gap: clamp(28px, 5vh, 52px); }
.layer-bone { color: var(--bone); }
.layer-ink { color: var(--ink); }
.m-line { display: flex; flex-direction: column; align-items: center; }
.m-ar { font-size: clamp(30px, 4.6vw, 54px); line-height: 1.8; text-wrap: balance; }
.m-en { font-size: clamp(17px, 2vw, 24px); letter-spacing: .12em; opacity: .8; margin-top: 6px; text-wrap: balance; }

/* ---------- act IV · the object ----------
   all tints derived from brand tokens via color-mix — no off-palette hex */
/* the sand half breathes but never yawns: content-sized acts, deliberate padding */
.act--object, .act--card, .act--close { min-height: auto; padding: 140px 28px; }
.act--object { color: var(--ink); background: var(--sand); }
.object-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 100%; }
.bottle-veil { position: relative; display: flex; flex-direction: column; align-items: center; }
.bottle-cap {
  width: 54px; height: 46px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(175deg, color-mix(in srgb, var(--sand) 88%, var(--ink)), color-mix(in srgb, var(--sand) 76%, var(--ink)));
}
.bottle-body {
  position: relative; overflow: hidden;
  width: 188px; height: 300px; margin-top: 4px;
  border-radius: 10px 10px 7px 7px;
  background: linear-gradient(165deg,
    color-mix(in srgb, var(--sand) 95%, var(--ink)) 8%,
    color-mix(in srgb, var(--sand) 86%, var(--ink)) 60%,
    color-mix(in srgb, var(--sand) 79%, var(--ink)) 100%);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 44px;
}
/* matte grain on the veiled object itself */
.bottle-body::after {
  content: ""; position: absolute; inset: 0; opacity: .06; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.bottle-mark { font-size: 26px; color: var(--ink); opacity: .16; }
/* low warm light: the shadow falls long, to one side */
.bottle-shadow {
  width: 320px; height: 26px; margin-top: 12px;
  transform: translateX(-14%) scaleY(.8);
  background: radial-gradient(ellipse closest-side, rgba(26, 32, 43, .26), rgba(26, 32, 43, 0));
}
body[data-phase="B"] img.bottle-photo { display: block; max-width: min(440px, 84%); height: auto; }
.object-caption { margin-top: 34px; font-size: clamp(21px, 2.4vw, 27px); max-width: 100%; }
.object-caption .ocap-ar, .object-caption .ocap-en { display: block; }
.object-caption .ocap-en { font-size: .78em; letter-spacing: .12em; opacity: .72; margin-top: 2px; }
.specimen { margin-top: 60px; font-size: clamp(19px, 2.1vw, 24px); display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.specimen span { text-wrap: balance; }
.spec-en { font-size: .8em; letter-spacing: .14em; opacity: .72; }

/* ---------- act V · the card ---------- */
.act--card { color: var(--ink); gap: 48px; background: var(--sand); }
.card-scene { position: relative; width: 300px; height: 340px; }
.envelope {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 300px; height: 170px; border-radius: 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--sand) 92%, var(--ink)), color-mix(in srgb, var(--sand) 84%, var(--ink)));
  box-shadow: 0 14px 20px -14px rgba(26, 32, 43, .25);
}
/* open flap behind the card — the card visibly emerges from something */
.envelope::before {
  content: ""; position: absolute; top: -52px; left: 0; right: 0; height: 54px;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  background: color-mix(in srgb, var(--sand) 87%, var(--ink));
}
/* the envelope mouth */
.envelope::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(180deg, rgba(26, 32, 43, .22), rgba(26, 32, 43, 0));
}
.card {
  position: absolute; bottom: 26px; left: 50%;
  width: 250px; height: 160px;
  transform: translateX(-50%);
}
.card-face {
  position: absolute; inset: 0; border-radius: 3px;
  background: linear-gradient(178deg, color-mix(in srgb, var(--bone) 72%, var(--sand)), color-mix(in srgb, var(--bone) 38%, var(--sand)));
  box-shadow: 0 10px 28px rgba(26, 32, 43, .16);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.card-ar { font-size: 25px; line-height: 1.8; color: var(--ink); text-wrap: balance; }
/* the card's printed line is ink — the site's first-light device stays scarce */
.blank-static { border-bottom-color: rgba(26, 32, 43, .35); }
.card-back { opacity: 0; }
.card-copy { max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.card-copy p { text-wrap: pretty; }
.card-copy p:first-child { font-size: clamp(22px, 2.6vw, 28px); }
.card-copy-en { font-size: clamp(17px, 2vw, 22px); letter-spacing: .1em; opacity: .72; }
.card-copy-note { font-size: clamp(17px, 1.9vw, 21px); margin-top: 8px; }
/* bidi discipline: mixed-direction sentences never share a line */
.card-copy-note .note-ar, .card-copy-note .note-en,
.card-copy-close .close2-ar, .card-copy-close .close2-en { display: block; }
.card-copy-note .note-ar { opacity: .85; }
.card-copy-note .note-en { font-size: .82em; letter-spacing: .08em; opacity: .72; margin-top: 4px; }
.card-copy-close { font-size: clamp(19px, 2.2vw, 24px); margin-top: 10px; }
.card-copy-close .close2-en { font-size: .78em; letter-spacing: .1em; opacity: .72; margin-top: 4px; }

/* ---------- act VI · close ---------- */
.act--close { color: var(--ink); gap: 56px; background: var(--sand); }
.close-line { display: flex; flex-direction: column; align-items: center; }
.close-line [lang="ar"] { font-size: clamp(38px, 6vw, 72px); line-height: 1.6; text-wrap: balance; }
.close-en { font-size: clamp(19px, 2.4vw, 28px); letter-spacing: .14em; opacity: .72; margin-top: 8px; }
.commerce { display: flex; flex-direction: column; align-items: center; gap: 40px; }
.commerce:focus { outline: none; }
.price { font-size: clamp(21px, 2.4vw, 26px); text-wrap: balance; }
.price-en { display: block; font-size: .8em; letter-spacing: .1em; opacity: .72; margin-top: 2px; }
.cta {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 240px; min-height: 44px;
  padding: 18px 56px;
  border: 1px solid var(--ink); border-radius: 1px;
  color: var(--ink); text-decoration: none;
  font-size: 24px; line-height: 1.5;
  transition: background-color var(--t-fast) var(--ease-dawn), color var(--t-fast) var(--ease-dawn);
}
.cta .cta-en { font-size: 16px; letter-spacing: .22em; opacity: .7; }
.cta:hover { background: var(--ink); color: var(--sand); }

/* phase switching — body[data-phase] governs */
.phase-a, .phase-b { display: none; }
body[data-phase="A"] .phase-a { display: inline-flex; }
body[data-phase="A"] p.phase-a { display: block; }
body[data-phase="B"] .phase-b { display: inline-flex; }
body[data-phase="B"] p.phase-b { display: block; }

/* ---------- footer — the pen changes hands ---------- */
.act--footer {
  min-height: 85vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 36px;
  text-align: center; color: var(--ink); padding: 80px 28px;
  background: var(--sand);
}
.foot-line [lang="ar"] { font-size: clamp(34px, 5vw, 56px); }
.foot-en { display: block; font-size: clamp(17px, 2vw, 23px); letter-spacing: .14em; opacity: .72; margin-top: 6px; }
.foot-blank .blank--foot {
  min-width: 170px; max-width: min(560px, 84vw);
  position: relative; display: inline-block;
  transform-origin: 100% 50%;
}
/* the visitor writes here — for real */
.foot-write {
  display: inline-block; min-width: 140px; max-width: 100%;
  font-family: 'Amiri', 'Geeza Pro', serif; font-size: clamp(26px, 3.4vw, 34px);
  line-height: 1.6; color: var(--ink); text-align: center;
  outline: none; caret-color: var(--first-light);
  padding: 0 6px 2px; white-space: nowrap; overflow: hidden;
}
.foot-hint { font-size: clamp(15px, 1.8vw, 18px); opacity: .6; margin-top: 14px; }
.foot-hint .hint-ar, .foot-hint .hint-en { display: block; }
.foot-hint .hint-en { font-size: .85em; letter-spacing: .12em; margin-top: 2px; }
/* the caret waits where Arabic writing begins — the right end of the line — and breathes, softly */
.caret {
  position: absolute; right: -1px; bottom: 4px;
  width: 2px; height: 30px; background: var(--first-light);
  animation: softblink 1.6s ease-in-out infinite;
}
@keyframes softblink { 0%, 100% { opacity: 1; } 50% { opacity: .12; } }
/* once the visitor takes the pen, the stand-in caret steps aside */
.foot-blank.writing .caret { display: none; }
.foot-affirm {
  font-size: clamp(18px, 2.1vw, 23px);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .9s var(--ease-dawn), transform .9s var(--ease-dawn), visibility 0s .9s;
}
.foot-affirm.shown { opacity: 1; visibility: visible; transform: none; transition: opacity .9s var(--ease-dawn), transform .9s var(--ease-dawn); }
.foot-affirm .affirm-en { display: block; font-size: .8em; letter-spacing: .12em; opacity: .72; margin-top: 4px; }
.legal { font-size: 13px; opacity: .72; }
.legal .legal-ar, .legal .legal-en { display: block; }
.legal .legal-en { letter-spacing: .1em; margin-top: 2px; }

/* ---------- selection ---------- */
::selection { background: rgba(192, 133, 82, .25); }
.act--hero ::selection, .act--sentences ::selection, .act--manifesto ::selection {
  background: rgba(243, 238, 229, .25);
}

/* ---------- reduced motion: pure CSS, independent of JS ---------- */
@media (prefers-reduced-motion: reduce) {
  .scroll-hint { animation: none; opacity: .4; }
  .caret { animation: none; opacity: 1; }
}

/* ---------- static fallbacks: no JS, or reduced motion ---------- */
body.no-js #dawn, body.reduced #dawn { display: none; }
body.no-js .scroll-hint, body.reduced .scroll-hint { animation: none; opacity: .4; }
body.reduced .caret { animation: none; opacity: 1; }

body.no-js .act--hero, body.reduced .act--hero,
body.no-js .act--sentences, body.reduced .act--sentences { background: var(--ink); }
body.no-js .act--manifesto, body.reduced .act--manifesto {
  background: linear-gradient(180deg, var(--ink) 0%, var(--dawn-3) 46%, var(--dawn-4) 72%, var(--sand) 100%);
}
body.no-js .act--object, body.reduced .act--object,
body.no-js .act--card, body.reduced .act--card,
body.no-js .act--close, body.reduced .act--close,
body.no-js .act--footer, body.reduced .act--footer { background: var(--sand); }

body.no-js .act--sentences .sentence { position: static; padding: 24px 0; }
body.no-js .act--sentences .stage { height: auto; flex-direction: column; }
body.reduced .act--sentences .sentence { position: static; padding: 24px 0; }
body.reduced .act--sentences .stage { height: auto; flex-direction: column; }
body.no-js .act--manifesto .veil, body.reduced .act--manifesto .veil { display: none; }
/* static pages show the bone layer only — centered content sits on the gradient's dark half */
body.no-js .layer-ink, body.reduced .layer-ink { display: none; }
body.no-js .card-back, body.reduced .card-back { position: static; opacity: 1; margin-top: 12px; box-shadow: none; }
body.no-js .card, body.reduced .card { position: static; transform: none; width: 250px; margin: 0 auto; height: auto; display: flex; flex-direction: column; gap: 10px; }
body.no-js .card-face, body.reduced .card-face { position: static; }
body.no-js .card-scene, body.reduced .card-scene { height: auto; display: flex; flex-direction: column; align-items: center; }
body.no-js .envelope, body.reduced .envelope { display: none; }

/* mobile spacing */
@media (max-width: 640px) {
  .act { padding: 72px 22px; }
  .act--object, .act--card, .act--close { padding: 84px 22px; }
  .act--card { gap: 40px; }
  .act--close { gap: 44px; }
  .act--footer { min-height: 80vh; padding: 64px 22px; }
}
