/* Hamesh — the site. Tokens are the app's (lib/core/theme/hamesh_colors.dart):
   library green on cool paper by day, the night palette by night. */

@font-face { font-family: "Readex Pro"; src: url("assets/fonts/ReadexPro-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Readex Pro"; src: url("assets/fonts/ReadexPro-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Readex Pro"; src: url("assets/fonts/ReadexPro-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Readex Pro"; src: url("assets/fonts/ReadexPro-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Literata"; src: url("assets/fonts/Literata-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Literata"; src: url("assets/fonts/Literata-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Literata"; src: url("assets/fonts/Literata-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --paper: #F3F5F2;
  --surface: #FFFFFF;
  --sunk: #E8ECE9;
  --rule: #DAE1DC;
  --ink: #0F1F1A;
  --ink2: #47564F;
  --ink3: #56635D;
  --primary: #1F5A47;
  --primary-press: #164336;
  --primary-soft: #DCEBE3;
  --primary-ink: #17473A;
  --on-primary: #FFFFFF;
  --accent: #AF2D5A;
  --accent-soft: #FBE4EC;
  --marker: rgba(255, 221, 51, .62);
  --marker-solid: #FFDD33;
  --mark-strength: .75;
  --page: #FCFBF7;
  --page-ink: #26231E;
  --page-marker: rgba(255, 221, 51, .62);
  --pencil: #1F5A47;
  --pencil-alpha: .7;
  --shadow: 0 1px 2px rgba(15, 31, 26, .05), 0 6px 20px rgba(15, 31, 26, .06);
  --shadow-lift: 0 18px 48px rgba(15, 31, 26, .14);
  --radius: 24px;
  --side: 20px;
  --ui: "Readex Pro", system-ui, sans-serif;
  --book: "Literata", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0B1411; --surface: #141F1B; --sunk: #070D0B; --rule: #24322C;
    --ink: #E8F0EC; --ink2: #A8B7B0; --ink3: #8A9A92;
    --primary: #7CCBA8; --primary-press: #62B792; --primary-soft: #163A2E; --primary-ink: #9EDDC0; --on-primary: #0B1411;
    --accent: #FF7FA8; --accent-soft: #3A1725;
    --marker: rgba(255, 221, 51, .34); --mark-strength: .3;
    --page: #CFCBC0; --page-ink: #1E1B17;
    --page-marker: rgba(255, 214, 10, .72); --pencil: #4FA582; --pencil-alpha: 1;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-lift: 0 18px 48px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0B1411; --surface: #141F1B; --sunk: #070D0B; --rule: #24322C;
  --ink: #E8F0EC; --ink2: #A8B7B0; --ink3: #8A9A92;
  --primary: #7CCBA8; --primary-press: #62B792; --primary-soft: #163A2E; --primary-ink: #9EDDC0; --on-primary: #0B1411;
  --accent: #FF7FA8; --accent-soft: #3A1725;
  --marker: rgba(255, 221, 51, .34); --mark-strength: .3;
  --page: #CFCBC0; --page-ink: #1E1B17;
  --page-marker: rgba(255, 214, 10, .72); --pencil: #4FA582; --pencil-alpha: 1;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-lift: 0 18px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; scroll-behavior: smooth;
  /* Jumps to #ar, #how… stop below the sticky header, not under it. */
  scroll-padding-top: 84px;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.7 var(--ui);
  overflow-x: hidden;
}
a { color: var(--primary-ink); }
img { max-width: 100%; }
.book { font-family: var(--book); }
[lang="en"] { font-family: var(--book); }
.ui-en { font-family: var(--ui); }

.wrap { width: min(1120px, 100% - 2 * var(--side)); margin-inline: auto; }
.skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { width: auto; height: auto; clip-path: none; inset-inline-start: 12px; top: 12px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 10px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 6px; }

/* ── Header ─────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.top.scrolled { border-bottom-color: var(--rule); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 20px; }
.brand svg { width: 34px; height: 34px; border-radius: 9px; }
.nav { display: flex; gap: 22px; margin-inline-start: auto; align-items: center; }
.nav a { color: var(--ink2); text-decoration: none; font-size: 15px; }
.nav a:hover { color: var(--ink); }
.lang {
  border: 1.5px solid var(--rule); background: none; color: var(--ink);
  font: 500 14px var(--ui); border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
@media (max-width: 720px) { .nav a.hide-sm { display: none; } .nav { gap: 14px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 26px; border-radius: 999px;
  font: 600 16px/1 var(--ui); text-decoration: none; cursor: pointer; border: 0;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn.primary:hover { background: var(--primary-press); }
.btn.quiet { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.btn.soon { background: var(--sunk); color: var(--ink3); cursor: default; }
.btn svg { width: 20px; height: 20px; }

/* ── Hero: a page, and what goes in its margin ──────────── */
.hero { padding: 56px 0 72px; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr); gap: 48px; align-items: center; }
@media (max-width: 920px) { .hero .wrap { grid-template-columns: minmax(0, 1fr); gap: 36px; } .hero { padding-top: 32px; } }
.hero h1 {
  font-size: clamp(34px, 5vw, 58px); line-height: 1.25; margin: 0 0 18px; font-weight: 700; letter-spacing: -.5px;
}
/* The marker is the text's own background, so it follows each line when
   the phrase wraps (English runs longer), and sweeps in from the start. */
.hero h1 .mark {
  background-image: linear-gradient(color-mix(in srgb, var(--marker-solid) calc(var(--mark-strength) * 100%), transparent), color-mix(in srgb, var(--marker-solid) calc(var(--mark-strength) * 100%), transparent));
  background-repeat: no-repeat;
  background-size: 0% 46%;
  background-position: right 0 bottom 6%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 0 6px;
  border-radius: 6px;
  animation: sweep .9s .5s cubic-bezier(.2, .8, .2, 1) forwards;
}
[dir="ltr"] .hero h1 .mark { background-position: left 0 bottom 6%; }
.hero p.lede { font-size: 19px; color: var(--ink2); margin: 0 0 30px; max-width: 34em; }
.hero .ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .note { margin-top: 16px; font-size: 14px; color: var(--ink3); }

@keyframes sweep { to { background-size: 100% 46%; } }

.stage { position: relative; }
.page {
  position: relative; direction: ltr;
  background: var(--page); color: var(--page-ink);
  border-radius: 6px 18px 18px 6px;
  padding: 44px 40px 40px 56px;
  box-shadow: var(--shadow-lift);
  margin-inline-end: 30%;
  transform: rotate(-1.2deg);
}
[dir="rtl"] .page { margin-inline-end: 0; margin-inline-start: 30%; }
.page::before { /* the spine */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 18px; border-radius: 6px 0 0 6px;
  background: linear-gradient(90deg, rgba(0,0,0,.12), rgba(0,0,0,0));
}
.page .chapter { font: 600 12px/1 var(--ui); letter-spacing: .14em; color: color-mix(in srgb, var(--page-ink) 55%, transparent); margin-bottom: 18px; text-align: center; }
.page p { font: 400 clamp(15px, 1.6vw, 18px)/1.75 var(--book); margin: 0; text-wrap: pretty; }
.page .w { position: relative; z-index: 0; }
.page .w::before {
  content: ""; position: absolute; inset: 12% -3px 6% -3px; z-index: -1;
  background: var(--page-marker); border-radius: 4px;
  transform: scaleX(0); transform-origin: left;
  transition: transform .55s cubic-bezier(.2, .8, .2, 1);
}
.page .w.on::before { transform: scaleX(1) rotate(-.8deg); }
.page .folio { margin-top: 18px; text-align: center; font: 400 13px var(--book); color: color-mix(in srgb, var(--page-ink) 50%, transparent); }

/* Margin notes: the Arabic meaning, where a reader would pencil it. */
.notes { position: absolute; inset: 0; pointer-events: none; }
.notes svg.links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.notes svg.links path {
  fill: none; stroke: var(--pencil); stroke-width: 1.6; stroke-linecap: round;
  stroke-dasharray: 2 6; opacity: var(--pencil-alpha);
  stroke-dashoffset: 0;
}
.gloss {
  position: absolute; width: max-content; max-width: 30%;
  direction: rtl; text-align: start;
  background: var(--surface); border-radius: 16px 16px 16px 4px; box-shadow: var(--shadow);
  padding: 10px 14px 9px; font-size: 15px; line-height: 1.5;
  opacity: 0; transform: translateY(8px) scale(.96);
  transition: opacity .45s ease, transform .55s cubic-bezier(.2, .8, .2, 1);
}
.gloss.on { opacity: 1; transform: none; }
.gloss b { display: block; font-weight: 600; color: var(--ink); }
.gloss span { display: block; font: 400 13px var(--book); color: var(--ink3); direction: ltr; text-align: end; }
@media (max-width: 560px) {
  .page { margin-inline: 0 !important; padding: 30px 22px 26px 34px; transform: none; }
  .notes { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
  .notes svg.links { display: none; }
  .gloss { position: static; max-width: none !important; width: auto; left: auto !important; top: auto !important; }
  /* An odd last note spans the row rather than sitting alone in half. */
  .gloss:last-child:nth-child(even) { grid-column: 1 / -1; }
}

/* ── Sections ───────────────────────────────────────────── */
section { padding: 72px 0; }
/* Phones: sections closer together; the hero's own bottom space is enough. */
@media (max-width: 560px) {
  section { padding: 44px 0; }
  .hero { padding-bottom: 8px; }
  section .sub { margin-bottom: 26px; }
}
.eyebrowless h2, section h2 { font-size: clamp(28px, 4vw, 40px); line-height: 1.3; margin: 0 0 14px; font-weight: 700; }
section .sub { color: var(--ink2); max-width: 36em; margin: 0 0 40px; font-size: 18px; }

.steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px;
  /* A real list for screen readers; its own number is the badge, so no marker or indent. */
  list-style: none; margin: 0; padding: 0;
}
@media (max-width: 860px) { .steps { grid-template-columns: minmax(0, 1fr); } }
.step {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 24px 28px; position: relative; overflow: hidden;
}
.step .num {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; margin-bottom: 16px;
}
.step h3 { margin: 0 0 8px; font-size: 21px; }
.step p { margin: 0; color: var(--ink2); font-size: 16px; }
.vignette { height: 150px; margin: 4px 0 18px; border-radius: 16px; background: var(--sunk); position: relative; overflow: hidden; }

/* 1 · scan: a page and corners that find it */
.v-scan .sheet { position: absolute; inset: 22px 30%; background: var(--page); border-radius: 4px; box-shadow: var(--shadow); }
.v-scan .sheet i { display: block; height: 5px; margin: 10px 12px 0; border-radius: 3px; background: color-mix(in srgb, var(--page-ink) 22%, transparent); }
.v-scan .sheet i.hl { background: var(--marker-solid); opacity: .8; width: 45%; }
.v-scan .corner { position: absolute; width: 22px; height: 22px; border: 3px solid var(--primary); animation: find 3.2s ease-in-out infinite; }
.v-scan .c1 { top: 12px; left: 22%; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.v-scan .c2 { top: 12px; right: 22%; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.v-scan .c3 { bottom: 12px; left: 22%; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.v-scan .c4 { bottom: 12px; right: 22%; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
@keyframes find {
  0%, 15% { transform: translate(var(--dx, 0), var(--dy, 0)); opacity: .5; }
  45%, 85% { transform: none; opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)); opacity: .5; }
}
.v-scan .c1 { --dx: -14px; --dy: -8px; } .v-scan .c2 { --dx: 14px; --dy: -8px; }
.v-scan .c3 { --dx: -14px; --dy: 8px; } .v-scan .c4 { --dx: 14px; --dy: 8px; }

/* 2 · understand: a word and its meaning in this sentence */
.v-mean { display: grid; place-items: center; text-align: center; }
.v-mean .en { font: 600 30px var(--book); direction: ltr; }
.v-mean .ar { font: 600 20px var(--ui); color: var(--primary-ink); }
.v-mean .ctx { font: italic 400 14px var(--book); color: var(--ink3); direction: ltr; }

/* 3 · remember: a card that turns */
.v-card { perspective: 700px; display: grid; place-items: center; }
.v-card .card { width: 62%; height: 96px; position: relative; transform-style: preserve-3d; animation: turn 5s ease-in-out infinite; }
.v-card .face {
  position: absolute; inset: 0; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.v-card .face.en { font: 600 24px var(--book); direction: ltr; }
.v-card .face.ar { font: 600 20px var(--ui); color: var(--primary-ink); transform: rotateY(180deg); }
@keyframes turn { 0%, 35% { transform: none; } 50%, 85% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }

/* Play */
.play { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; }
@media (max-width: 860px) { .play { grid-template-columns: minmax(0, 1fr); } }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
@media (max-width: 560px) { .tile { padding: 20px; } .games { gap: 8px; } .game { padding: 14px 6px; } }
.games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.game { background: var(--sunk); border-radius: 16px; padding: 16px 10px; text-align: center; font-size: 14px; }
.game svg { width: 28px; height: 28px; display: block; margin: 0 auto 8px; color: var(--primary); }
.code {
  direction: ltr; display: flex; gap: 8px; justify-content: center; margin: 18px 0 10px;
}
/* Six boxes that share the row: full size on wide screens, smaller on a phone. */
.code span {
  flex: 0 1 46px; min-width: 0; aspect-ratio: 46 / 58; border-radius: 12px; background: var(--sunk);
  display: grid; place-items: center; font: 700 clamp(20px, 6vw, 26px) var(--ui); color: var(--ink);
}
.code span.flip { animation: flip .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: none; } }
.tile .small { color: var(--ink2); font-size: 15px; margin: 0; }
.score { margin-top: 14px; font-size: 15px; background: var(--primary-soft); color: var(--primary-ink); border-radius: 12px; padding: 10px 14px; }

/* Quotes: one at a time, typed */
.quotes { background: var(--primary); color: var(--on-primary); overflow: hidden; position: relative; }
.quotes::after { /* one large, faint quotation mark */
  content: "\201C"; position: absolute; inset-inline-end: 4%; top: 50%; transform: translateY(-46%);
  font: 400 clamp(220px, 34vw, 420px)/1 var(--book); opacity: .08; pointer-events: none;
}
.quote { min-height: 230px; display: grid; align-content: center; max-width: 820px; position: relative; z-index: 1; }
.quote .en { font: 400 clamp(22px, 3.2vw, 34px)/1.5 var(--book); direction: ltr; text-align: left; min-height: 1.5em; }
.quote .en .caret { display: inline-block; width: 2px; height: 1em; background: currentColor; vertical-align: -.12em; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.quote .ar { font-size: clamp(17px, 2vw, 20px); opacity: 0; transition: opacity .6s; margin-top: 14px; }
.quote .by { font: italic 400 16px var(--book); opacity: 0; transition: opacity .6s .15s; margin-top: 6px; direction: ltr; text-align: left; }
.quote.done .ar, .quote.done .by { opacity: .8; }
.quotes h2 { position: relative; z-index: 1; font-size: 15px; font-weight: 500; opacity: .75; margin: 0 0 10px; }

/* Download */
.get { text-align: center; }
.get .ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.get .icon { width: 96px; height: 96px; border-radius: 24px; box-shadow: var(--shadow-lift); }

footer { padding: 40px 0 56px; color: var(--ink3); font-size: 14px; border-top: 1px solid var(--rule); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
footer a { color: var(--ink2); text-decoration: none; }
footer a:hover { color: var(--ink); }
footer .copy { margin-inline-start: auto; }

/* Reveal as it comes into view, once */
/* Hidden only once the script runs, so a page without it still shows everything. */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .8s cubic-bezier(.2, .8, .2, 1); }
.reveal.in { opacity: 1; transform: none; }

/* Long reading pages: privacy, terms, support */
.doc { padding: 48px 0 80px; }
.doc .wrap { max-width: 760px; }
.doc h1 { font-size: clamp(30px, 4.4vw, 42px); line-height: 1.3; margin: 0 0 8px; }
.doc .meta { color: var(--ink3); font-size: 14px; margin: 0 0 36px; }
.doc h2 { font-size: 22px; margin: 36px 0 10px; }
.doc p, .doc li { color: var(--ink2); }
.doc ul { padding-inline-start: 22px; }
.doc .card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin: 18px 0; }
.doc hr { border: 0; border-top: 1px solid var(--rule); margin: 56px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .hero h1 .mark { background-size: 100% 46%; }
  .gloss { opacity: 1; transform: none; }
  .page .w::before { transform: scaleX(1); }
  .quote .ar, .quote .by { opacity: .8; }
}
