/* ==========================================================================
   Qusai's story: styles
   --------------------------------------------------------------------------
   Layout and visual style follow adilmania.com's "storybook":
   one full-screen leaf per chapter, scroll snapping from leaf to leaf,
   a painted picture above a short centred passage, and lines that fade in
   (from blurred to sharp) when a leaf comes into view.
   ========================================================================== */


/* ---------- 1. Fonts (free OFL fonts, stored in /fonts) -------------------
   Fraunces (English): a soft, warm storybook serif, the closest free match to
   the original's hand-made feel. Noto Naskh Arabic (Arabic): clean, modern naskh.
   Chosen by Qusai on 2026-11-09 from 6 pairs rendered on the real page.
   Thmanyah was NOT used: its licence forbids serving font files on a website. */

@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/fraunces-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/fraunces-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(../fonts/fraunces-normal-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(../fonts/fraunces-normal-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/noto-naskh-arabic-normal-arabic.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/noto-naskh-arabic-normal-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/noto-naskh-arabic-normal-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


/* ---------- 2. Design tokens: change colours and fonts here, once --------- */

:root {
  --paper: #f0eee6;        /* page background (warm cream) */
  --ink: #191919;          /* main text */
  --hint: #656158;         /* small helper text; Arabic closing lines */
  --dots: #9f9b92;         /* dotted underline under links */
  --selection: #d8d4c8;    /* colour behind selected text */
  --slot: #e8e4d9;         /* box shown where a picture is still missing */

  --font-latin: "Fraunces", Georgia, serif;
  --font-arabic: "Noto Naskh Arabic", "Geeza Pro", serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;

  /* The design centres every passage, in both languages.
     Centring never stretches letters, so Arabic joins stay intact.
     Never use "justify" here: it breaks Arabic letter joins in Chrome. */
  --passage-align: center;

  /* Space between two paragraphs inside one chapter. */
  --paragraph-gap: 0.8em;
}


/* ---------- 3. Base reset ------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

/* Anything with the "hidden" attribute stays hidden, whatever else says. */
[hidden] { display: none !important; }

html {
  background: var(--paper);
  /* Every scroll lands exactly on a chapter: this is the "turn the page" feel. */
  scroll-snap-type: y mandatory;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
}

h1, p, figure { margin: 0; }
img { display: block; max-width: 100%; height: auto; }


/* ---------- 4. The storybook ----------------------------------------------- */

.storybook {
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-latin);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
.storybook ::selection { background: var(--selection); }

/* One leaf = one chapter = one full screen. */
.story-leaf {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 100px 28px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* The block that holds the picture and the words. */
.passage {
  width: 100%;
  max-width: 20.65em;
  font-size: clamp(23px, 2.5vw, 32px);
  text-align: var(--passage-align);
}
.storybook .passage p,
.storybook .passage h1 {
  margin: 0;
  font: 400 1em/1.6 var(--font-latin);
  letter-spacing: -0.018em;
  text-wrap: pretty;
}
/* A chapter can have several paragraphs; each one fades in on its own beat. */
.storybook .passage p + p { margin-top: var(--paragraph-gap); }

/* Closing lines in italics, e.g. <em>what it taught him.</em> */
.storybook em { color: inherit; font-weight: 400; }

/* The picture above the words. */
.story-drawing {
  width: 420px;
  max-width: 90%;
  margin: 0 auto 36px;
}
.story-drawing img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* A chapter whose picture is not there yet (story.js adds "is-missing"):
   a tinted 3:2 box that names the file to add, e.g. images/chapter-10.png. */
.story-drawing.is-missing {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 2;
  border-radius: 14px;
  background: var(--slot);
}
.story-drawing.is-missing img { display: none; }
.story-drawing.is-missing::after {
  content: attr(data-slot);
  direction: ltr;
  color: var(--hint);
  font: italic 15px/1.4 var(--font-latin);
}

/* "scroll to turn the page", only on the first leaf. */
.opening { position: relative; }
.reading-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 38px;
  text-align: center;
  color: var(--hint);
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
}


/* ---------- 5. Highlighted words ------------------------------------------
   Written in the content files as <strong data-icon="🖥️">computer.</strong>
   or <a href="..." data-icon="🌐">internet</a>. story.js turns them into:
   [tilted emoji] + bold word (+ dotted underline when it is a link).        */

.storybook a {
  color: inherit;
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.2s;
}
.storybook a strong {
  text-decoration: underline dotted var(--dots);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.2s;
}
.storybook a:hover strong { text-decoration-color: var(--ink); }
.storybook a:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 7px;
}

.story-word { white-space: nowrap; }
.nobreak { white-space: nowrap; }   /* keeps hyphenated names like "Al-Natheef" on one line */
.story-word strong {
  font-weight: 600;
  font-synthesis: weight;
}

.word-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-inline-end: 0.12em;
  font-family: var(--font-emoji);
  font-size: 0.9em;
  line-height: 1;
  vertical-align: -0.08em;
  transform: rotate(-9deg);
  transition: transform 0.25s;
}
.story-word:hover .word-icon { transform: rotate(0); }

/* Small real photos in place of emojis (data-photo in the content files). */
.word-icon img {
  display: inline-block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
}
.word-icon img[src*="qusai"] { border-radius: 50%; }   /* his own face is round, like the original */

/* Contact links at the end of the last chapter. */
.storybook .passage .story-contact { margin-top: 1.5em; }


/* ---------- 6. Fade-in, line by line --------------------------------------
   story.js adds "reveal-ready" to the page and "is-revealed" to each passage
   when it scrolls into view. Each line waits 340 ms longer than the one before. */

[data-beat] {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}
.reveal-ready .passage:not(.is-revealed) [data-beat] {
  opacity: 0;
  filter: blur(10px);
  transform: translateY(18px);
}
.reveal-ready .passage.is-revealed [data-beat] {
  transition: opacity 0.8s, filter 0.8s, transform 0.8s;
  transition-delay: var(--beat-delay, 0s);
}
/* Keyboard users: anything focused shows at once. */
.reveal-ready .passage:focus-within [data-beat] {
  opacity: 1;
  filter: none;
  transform: none;
  transition-delay: 0s;
}


/* ---------- 7. Language switch (small, top corner, mirrors in Arabic) ------ */

.lang-switch {
  position: fixed;
  top: 30px;
  inset-inline-end: 32px;   /* right in English, left in Arabic */
  z-index: 10;
  color: var(--hint);
  font: italic 15px/1.4 var(--font-latin);
  text-decoration: underline dotted var(--dots);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: color 0.2s, text-decoration-color 0.2s;
}
.lang-switch:hover { color: var(--ink); text-decoration-color: var(--ink); }
.lang-switch:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 7px;
}
/* The label "العربية" is Arabic text: Arabic font, no italics. */
.lang-switch span:lang(ar) {
  font-family: var(--font-arabic);
  font-style: normal;
  font-size: 17px;
}


/* ---------- 8. Arabic (right to left) --------------------------------------
   html gets lang="ar" dir="rtl" from story.js. Rules that matter for Arabic:
   no letter-spacing (it pulls joined letters apart), no italics (Arabic has
   none; fake slanting looks broken), a real bold weight, and a little more
   line height for Naskh's tall letters. Numbers stay Western: 1234.          */

html[lang="ar"] .storybook { font-family: var(--font-arabic); }
html[lang="ar"] .storybook .passage p,
html[lang="ar"] .storybook .passage h1 {
  font-family: var(--font-arabic);
  letter-spacing: 0;
  line-height: 1.75;
}
html[lang="ar"] .story-word strong { font-weight: 700; }
html[lang="ar"] .storybook em {
  font-style: normal;
  color: var(--hint);
}
html[lang="ar"] .reading-hint {
  font-family: var(--font-arabic);
  font-style: normal;
  font-size: 17px;
}
/* The emoji tilts the other way, towards the reading direction. */
html[dir="rtl"] .word-icon { transform: rotate(9deg); }
html[dir="rtl"] .story-word:hover .word-icon { transform: rotate(0); }
/* English inside Arabic (an email address, "LinkedIn") keeps its own direction. */
.storybook bdi { unicode-bidi: isolate; }


/* ---------- 9. Phones ------------------------------------------------------- */

@media (max-width: 600px) {
  .passage { font-size: clamp(20px, 5.45vw, 27px); }
  .story-leaf { padding: 90px 20px; }
  .story-drawing { width: 280px; margin-bottom: 32px; }
  .lang-switch { top: 24px; inset-inline-end: 20px; }
}


/* ---------- 10. Reduced motion and printing -------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .storybook * { transition: none !important; animation: none !important; }
  .reveal-ready .passage:not(.is-revealed) [data-beat] {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

@media print {
  html { scroll-snap-type: none; }
  .story-leaf { min-height: 0; padding: 40px 0; break-inside: avoid; }
  .reading-hint, .lang-switch { display: none; }
  .reveal-ready .passage:not(.is-revealed) [data-beat] {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

/* Shown only when JavaScript is off. */
.no-script {
  max-width: 32em;
  margin: 40vh auto 0;
  padding: 0 20px;
  text-align: center;
  color: var(--hint);
  font: italic 17px/1.6 var(--font-latin);
}
