/* Softbook design system v2 — "riso picture book".
   Bright print inks on clean paper. One loud device: the misregistered
   offset shadow (pink under blue), used on the book covers and the main
   button only. Everything else stays quiet.
   Logical properties throughout, so Arabic (dir="rtl") just works. */

/* ---------------------------------------------------------------- fonts */
@font-face { font-family: "Gluten"; src: url("fonts/gluten-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Gluten"; src: url("fonts/gluten-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Readex"; src: url("fonts/readex-pro-arabic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Readex"; src: url("fonts/readex-pro-arabic-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Readex"; src: url("fonts/readex-pro-arabic-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Lalezar"; src: url("fonts/lalezar-arabic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Lalezar"; src: url("fonts/lalezar-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* ---------------------------------------------------------------- tokens */
:root {
  /* inks */
  --paper: #fafbff;
  --paper-2: #f0f2fb;
  --sheet: #ffffff;
  --ink: #1c2459;
  --ink-2: #4a527f;
  --ink-3: #7a81a8;
  --line: #dde1f1;
  --blue: #2f55d4;
  --blue-deep: #2442ad;
  --pink: #ff4f9a;
  --yellow: #ffd23f;
  --teal: #0e9f8e;
  --red: #d93a4a;
  --on-blue: #ffffff;
  --tint-blue: #e8edff;
  --tint-pink: #ffe7f2;
  --tint-yellow: #fff6d1;
  --tint-teal: #dff6f2;
  --tint-red: #ffe6e9;

  /* type */
  --f-display: "Gluten", "Lalezar", "Atkinson", system-ui, sans-serif;
  --f-body: "Atkinson", "Readex", system-ui, -apple-system, "Segoe UI", sans-serif;
  --t-xs: .8125rem;
  --t-sm: .9375rem;
  --t-md: 1.0625rem;
  --t-lg: 1.25rem;
  --t-xl: 1.625rem;
  --t-2xl: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);
  --t-3xl: clamp(2.4rem, 1.6rem + 3.6vw, 4.1rem);

  /* shape */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;
  --ox: 5px;
  --oy: 5px;
  --shadow-print: var(--ox) var(--oy) 0 var(--pink);
  --shadow-lift: 0 1px 0 var(--line), 0 10px 30px -18px rgba(28, 36, 89, .45);

  --gap: clamp(16px, 2.4vw, 28px);
  --wrap: 1160px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

/* Bedtime mode: night sky instead of grey. */
:root[data-theme="dark"] {
  --paper: #11173a;
  --paper-2: #171e48;
  --sheet: #1b2353;
  --ink: #eef0ff;
  --ink-2: #b9bfe6;
  --ink-3: #8a91c2;
  --line: #2c356d;
  --blue: #6f8dff;
  --blue-deep: #8ea6ff;
  --on-blue: #0d1233;
  --tint-blue: #23306f;
  --tint-pink: #4a1f45;
  --tint-yellow: #43401f;
  --tint-teal: #143f47;
  --tint-red: #4b1f2b;
  --shadow-lift: 0 1px 0 var(--line), 0 14px 34px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

:root[lang="ar"], [dir="rtl"] {
  --f-display: "Lalezar", "Gluten", "Readex", system-ui, sans-serif;
  --f-body: "Readex", "Atkinson", system-ui, sans-serif;
  --ox: -5px;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-md)/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[dir="rtl"] body, body[dir="rtl"] { line-height: 1.75; }
img, svg, video { max-width: 100%; display: block; }
a { color: var(--blue); text-underline-offset: .18em; text-decoration-thickness: .08em; }
a:hover { color: var(--blue-deep); }
::selection { background: var(--yellow); color: #1c2459; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 6px; box-shadow: 0 0 0 5px var(--ink); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.12; font-weight: 700; letter-spacing: -.01em; }
h1, h2, .display { font-family: var(--f-display); }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] .display { font-weight: 400; letter-spacing: 0; line-height: 1.3; }
h1 { font-size: var(--t-3xl); }
h2 { font-size: var(--t-2xl); }
h3 { font-size: var(--t-lg); font-family: var(--f-body); }
p { margin: 0 0 1em; }
.lead { font-size: var(--t-lg); color: var(--ink-2); max-width: 34em; }
.muted { color: var(--ink-2); }
.small { font-size: var(--t-sm); }
.tiny { font-size: var(--t-xs); color: var(--ink-3); }

.wrap { width: min(100% - 2 * var(--gap), var(--wrap)); margin-inline: auto; }
.narrow { width: min(100% - 2 * var(--gap), 720px); margin-inline: auto; }
.stack > * + * { margin-block-start: var(--s, 1rem); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: var(--gap); }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.section { padding-block: clamp(48px, 8vw, 104px); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --bg: var(--sheet); --fg: var(--ink); --bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: .6em 1.15em;
  border: 2px solid var(--bd); border-radius: var(--r-pill);
  background: var(--bg); color: var(--fg);
  font: 600 var(--t-md)/1.1 var(--f-body);
  text-decoration: none; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s;
}
.btn:hover { color: var(--fg); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { --bg: var(--blue); --fg: var(--on-blue); --bd: var(--blue); box-shadow: var(--shadow-print); }
.btn-primary:hover { --bd: var(--blue-deep); --bg: var(--blue-deep); box-shadow: calc(var(--ox) * 1.4) calc(var(--oy) * 1.4) 0 var(--pink); }
.btn-primary:active { box-shadow: 1px 1px 0 var(--pink); }
.btn-quiet { --bd: transparent; --bg: transparent; }
.btn-quiet:hover { --bg: var(--paper-2); --bd: transparent; }
.btn-danger { --fg: var(--red); --bd: color-mix(in srgb, var(--red) 40%, transparent); }
.btn-sm { min-height: 36px; padding: .4em .9em; font-size: var(--t-sm); }
.btn-lg { min-height: 54px; padding: .8em 1.6em; font-size: var(--t-lg); }
.btn-block { width: 100%; }
.btn .spin { width: 1em; height: 1em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: .35rem; }
.field + .field { margin-block-start: 1.1rem; }
label, .label { font-weight: 600; font-size: var(--t-sm); }
.hint { font-size: var(--t-xs); color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: .7em .95em;
  border: 2px solid var(--line); border-radius: var(--r-md);
  background: var(--sheet); color: var(--ink);
  font: 400 var(--t-md)/1.4 var(--f-body);
  transition: border-color .15s;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--tint-blue); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red); }
.counter { font-size: var(--t-xs); color: var(--ink-3); text-align: end; }
.counter.over { color: var(--red); font-weight: 700; }
.check { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; font-size: var(--t-sm); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }

/* Choice tiles: big, tappable radio/checkbox cards. */
.choices { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(var(--min, 150px), 1fr)); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice > span {
  display: grid; gap: .35rem; height: 100%;
  padding: .9rem 1rem; border: 2px solid var(--line); border-radius: var(--r-md);
  background: var(--sheet); font-weight: 600; transition: border-color .15s, background .15s;
}
.choice small { font-weight: 400; color: var(--ink-2); font-size: var(--t-xs); }
.choice img { border-radius: var(--r-sm); aspect-ratio: 1; object-fit: cover; width: 100%; }
.choice input:checked + span { border-color: var(--blue); background: var(--tint-blue); }
.choice input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
.choice input:disabled + span { opacity: .5; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--r-pill); background: var(--paper-2); }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: .45em 1em; border-radius: var(--r-pill); font: 600 var(--t-sm) var(--f-body); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-lift); }

/* ---------------------------------------------------------------- surfaces */
.panel { background: var(--sheet); border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 3vw, 30px); }
.panel-tight { padding: 16px; border-radius: var(--r-md); }
.note, .callout { display: block; padding: .85rem 1rem; border-radius: var(--r-md); background: var(--tint-blue); color: var(--ink); font-size: var(--t-sm); margin: 1rem 0; }
.callout-warn { background: var(--tint-yellow); }
.callout-bad { background: var(--tint-red); }
.callout-good { background: var(--tint-teal); }
.chip { display: inline-flex; align-items: center; gap: .35em; padding: .2em .7em; border-radius: var(--r-pill); background: var(--paper-2); font-size: var(--t-xs); font-weight: 700; color: var(--ink-2); }
.chip-blue { background: var(--tint-blue); color: var(--blue-deep); }
.chip-pink { background: var(--tint-pink); color: #b0236a; }
.chip-yellow { background: var(--tint-yellow); color: #7a5a00; }
.chip-teal { background: var(--tint-teal); color: #08695e; }
.chip-red { background: var(--tint-red); color: var(--red); }
:root[data-theme="dark"] .chip-pink { color: #ffb0d3; }
:root[data-theme="dark"] .chip-yellow { color: #ffe27a; }
:root[data-theme="dark"] .chip-teal { color: #7fe3d3; }
.credits { display: inline-flex; align-items: center; gap: .4em; font-weight: 700; padding: .3em .8em; border-radius: var(--r-pill); background: var(--tint-yellow); color: var(--ink); text-decoration: none; }
.credits::before { content: ""; width: .8em; height: .8em; border-radius: 50%; background: var(--yellow); box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .15); }

/* ---------------------------------------------------------------- the book */
/* The one loud object: a picture book with a spine and an offset print. */
.book {
  --w: 100%;
  position: relative; display: block; width: var(--w); aspect-ratio: var(--ratio, 1 / 1);
  border-radius: 4px 14px 14px 4px; overflow: hidden;
  background: var(--tint-blue) center / cover no-repeat;
  box-shadow: var(--ox) var(--oy) 0 var(--pink), var(--shadow-lift);
  color: inherit; text-decoration: none;
  transition: transform .25s var(--ease);
}
[dir="rtl"] .book { border-radius: 14px 4px 4px 14px; }
.book::before { /* spine */
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 7%;
  background: linear-gradient(90deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .18) 55%, rgba(0, 0, 0, .06));
  z-index: 2; pointer-events: none;
}
[dir="rtl"] .book::before { background: linear-gradient(-90deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .18) 55%, rgba(0, 0, 0, .06)); }
.book img { width: 100%; height: 100%; object-fit: cover; }
a.book:hover { transform: translateY(-3px) rotate(-.6deg); }
.book-title {
  position: absolute; inset-inline: 10% 6%; inset-block-end: 7%; z-index: 3;
  padding: .45em .7em; border-radius: 10px; background: rgba(255, 255, 255, .92); color: #1c2459;
  font: 700 clamp(.95rem, .7rem + 1vw, 1.25rem)/1.15 var(--f-display);
}
[dir="rtl"] .book-title { font-weight: 400; }
.book-blank { display: grid; place-items: center; background: repeating-linear-gradient(45deg, var(--tint-blue) 0 14px, var(--paper-2) 14px 28px); color: var(--ink-2); font-weight: 700; }

.shelf { display: grid; gap: clamp(22px, 3vw, 36px); grid-template-columns: repeat(auto-fill, minmax(min(100% / 2 - 12px, 190px), 1fr)); }
.shelf-item { display: grid; gap: .7rem; }
.shelf-item h3 { font-size: var(--t-md); margin: 0; }

/* ---------------------------------------------------------------- header / footer */
.top { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 1rem; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font: 700 1.3rem/1 var(--f-display); }
[dir="rtl"] .brand { font-weight: 400; }
.brand-mark { width: 30px; height: 30px; }
.nav { display: flex; gap: .25rem; margin-inline-start: auto; align-items: center; }
.nav a:not(.btn) { color: var(--ink-2); text-decoration: none; font-weight: 600; padding: .5em .75em; border-radius: var(--r-pill); }
.nav a:not(.btn):hover, .nav a[aria-current="page"] { color: var(--ink); background: var(--paper-2); }
.nav-toggle { display: none; }
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; margin-inline-start: auto; }
  .nav { display: none; position: absolute; inset-inline: 0; top: 64px; flex-direction: column; align-items: stretch; padding: 12px var(--gap) 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
  .nav.open { display: flex; }
  .nav .btn { margin-top: .5rem; }
}
.foot { border-top: 1px solid var(--line); padding-block: 40px 56px; margin-top: 40px; color: var(--ink-2); font-size: var(--t-sm); }
.foot-grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.foot h4 { font-size: var(--t-sm); color: var(--ink); margin-bottom: .6rem; }
.foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.linkish { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------------------------------------------------------------- dialogs, toasts */
dialog.modal { width: min(560px, 100% - 32px); border: 0; padding: 0; border-radius: var(--r-lg); background: var(--sheet); color: var(--ink); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .55); }
dialog.modal::backdrop { background: rgba(17, 23, 58, .55); backdrop-filter: blur(3px); }
.modal-body { padding: 26px; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; padding: 0 26px 24px; flex-wrap: wrap; }
dialog.modal[open] { animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; inset-inline: 0; bottom: 18px; display: grid; justify-items: center; gap: 8px; z-index: 1000; pointer-events: none; }
.toast { pointer-events: auto; max-width: min(520px, 100% - 32px); padding: .75rem 1.1rem; border-radius: var(--r-md); background: var(--ink); color: var(--paper); font-weight: 600; box-shadow: var(--shadow-lift); animation: pop .2s var(--ease); }
.toast-bad { background: var(--red); color: #fff; }
.toast-good { background: var(--teal); color: #fff; }

/* ---------------------------------------------------------------- progress */
.progress { height: 10px; border-radius: var(--r-pill); background: var(--paper-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: var(--p, 0%); background: repeating-linear-gradient(-45deg, var(--blue) 0 10px, var(--blue-deep) 10px 20px); border-radius: inherit; transition: width .5s var(--ease); }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 22px; }
.steps li { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--line); }
.steps li.done { background: var(--blue); }
.steps li.now { background: var(--pink); }
.skeleton { background: linear-gradient(90deg, var(--paper-2), var(--line), var(--paper-2)); background-size: 300% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -100% 0; } }

/* ---------------------------------------------------------------- prose (legal, FAQ) */
.prose { max-width: 70ch; }
.prose h2 { font-family: var(--f-body); font-size: var(--t-xl); margin-top: 2.2em; }
.prose h3 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-inline-start: 1.3em; }
.prose li + li { margin-top: .35em; }
.table-wrap { overflow-x: auto; margin: 1rem 0 1.5rem; border: 1.5px solid var(--line); border-radius: var(--r-md); }
.prose table { border-collapse: collapse; width: 100%; font-size: var(--t-sm); }
.prose th, .prose td { text-align: start; vertical-align: top; padding: .65rem .8rem; border-bottom: 1px solid var(--line); }
.prose th { background: var(--paper-2); }
.prose tr:last-child td { border-bottom: 0; }
details.faq { border-bottom: 1.5px solid var(--line); padding-block: 1rem; }
details.faq summary { cursor: pointer; font-weight: 700; font-size: var(--t-lg); list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
details.faq summary::after { content: "+"; font-family: var(--f-display); color: var(--blue); font-size: 1.5rem; line-height: 1; }
details.faq[open] summary::after { content: "–"; }
details.faq p { margin-top: .75rem; color: var(--ink-2); }

/* ---------------------------------------------------------------- consent banner */
.consent { position: fixed; inset-inline: 16px; bottom: 16px; z-index: 900; max-width: 560px; margin-inline-start: auto; padding: 18px 20px; border-radius: var(--r-lg); background: var(--sheet); border: 1.5px solid var(--line); box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .6); }
.consent p { font-size: var(--t-sm); margin-bottom: .8rem; }

/* ---------------------------------------------------------------- audio player */
.voice { display: flex; align-items: center; gap: .8rem; }
.play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--blue); color: var(--on-blue); display: grid; place-items: center; cursor: pointer; flex: none; }
.play svg { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .top, .foot, .consent, .toasts, .no-print { display: none !important; }
  body { background: #fff; }
}
