/* ==========================================================================
   Kamel El-Refaie — profile page
   Palette: true black, paper white, stone grey, one limestone-gold accent.
   ========================================================================== */

:root {
  --black: #000000;
  --paper: #EFEBE3;
  --stone: #8C877E;
  --rule: #26241F;
  --gold: #D9B77A;
  --raised: #141311;

  --display: "Big Shoulders", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;

  --wrap: 1240px;
  --gutter: clamp(20px, 5vw, 64px);
  --nav-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--paper);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.98rem + 0.3vw, 1.1875rem);
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }

::selection { background: var(--gold); color: var(--black); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  border-radius: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--paper);
  color: var(--black);
  text-decoration: none;
}
.skip:focus { top: 16px; }

/* ---------- Navigation ---------- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter)));
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease;
}
.nav.is-scrolled { border-bottom-color: var(--rule); }

.nav__mark {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.625rem;
  letter-spacing: .02em;
  text-decoration: none;
  line-height: 1;
}

.nav__links { display: flex; gap: clamp(16px, 3vw, 36px); }
.nav__links a {
  font-size: 1rem;
  text-decoration: none;
  color: var(--stone);
  transition: color .2s ease;
}
.nav__links a:hover { color: var(--paper); }
.nav__links .nav__lang {
  color: var(--paper);
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.nav__links .nav__lang:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Hero ---------- */

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: calc(var(--nav-h) + 40px);
  padding-bottom: clamp(32px, 6vh, 64px);
}

.hero__name {
  font-family: var(--display);
  font-weight: 850;
  font-variation-settings: "opsz" 72;
  text-transform: uppercase;
  font-size: clamp(4.5rem, 24vw, 18.5rem);
  line-height: .84;
  letter-spacing: -.01em;
  margin-inline-start: -.04em;
}
.hero__name .line {
  display: block;
  overflow: hidden;
  padding-top: .06em;
}
.hero__name .char { display: inline-block; }

.hero__foot {
  margin-top: clamp(28px, 5vh, 48px);
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px 48px;
}

.hero__lede {
  max-width: 34ch;
  font-size: clamp(1.25rem, 1.05rem + .8vw, 1.625rem);
  line-height: 1.4;
}

.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid var(--paper);
  border-radius: 999px;
  text-decoration: none;
  font-size: 1.0625rem;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.btn:hover { background: var(--paper); color: var(--black); }
.btn--solid { background: var(--paper); color: var(--black); }
.btn--solid:hover { background: var(--gold); border-color: var(--gold); }

/* Page-load sequence (only when JS is running) */
.js .hero__name .char {
  transform: translateY(105%);
  animation: rise .95s var(--ease) forwards;
  animation-delay: calc(var(--i) * 42ms + 120ms);
}
.js .hero__foot {
  opacity: 0;
  animation: fade .9s ease forwards 1s;
}

@keyframes rise { to { transform: translateY(0); } }
@keyframes fade { to { opacity: 1; } }

/* ---------- Sections ---------- */

.section {
  padding-top: clamp(96px, 14vw, 180px);
}

.section__title {
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "opsz" 72;
  text-transform: uppercase;
  font-size: clamp(3.5rem, 9vw, 7.5rem);
  line-height: .9;
  letter-spacing: -.005em;
}

.section__intro {
  max-width: 44ch;
  color: var(--stone);
  font-style: italic;
  font-size: 1.1875rem;
  line-height: 1.5;
}

/* ---------- About ---------- */

.about {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 32px;
}
.about .section__title { grid-column: 1 / span 4; }
.about__body { grid-column: 5 / span 8; max-width: 66ch; }

.about__lead {
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.875rem);
  line-height: 1.35;
  margin-bottom: 28px;
}
.about__body > p + p { color: #C9C4BA; }

.facts { margin-top: 48px; border-top: 1px solid var(--rule); }
.facts__row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}
.facts dt { color: var(--stone); font-style: italic; }

/* ---------- Story / timeline ---------- */

.story__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 48px;
  margin-bottom: clamp(48px, 7vw, 88px);
}

.story__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 0 clamp(24px, 5vw, 72px);
  align-items: start;
}

/* The rolling year counter */
.odometer {
  position: sticky;
  top: calc(var(--nav-h) + 12vh);
  display: flex;
  font-family: var(--display);
  font-weight: 850;
  font-variation-settings: "opsz" 72;
  font-size: clamp(6rem, 15vw, 14.5rem);
  line-height: 1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  direction: ltr; /* keep digits in order on the Arabic page too */
}
.digit {
  display: block;
  height: 1em;
  overflow: hidden;
}
.digit__strip {
  display: flex;
  flex-direction: column;
  transition: transform .9s var(--ease);
}
.digit__strip span { display: block; height: 1em; text-align: center; }

.timeline {
  position: relative;
  border-inline-start: 1px solid var(--rule);
  --progress: 0;
}
.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: -1px;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--gold);
  transform-origin: top;
  transform: scaleY(var(--progress));
}

.entry {
  position: relative;
  padding-block-end: clamp(64px, 9vw, 112px);
  padding-inline-start: clamp(24px, 4vw, 48px);
}
.entry:last-child { padding-block-end: 0; }

.entry::before {
  content: "";
  position: absolute;
  inset-inline-start: -6px;
  top: .55em;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--black);
  border: 1px solid var(--stone);
  transition: background-color .4s ease, border-color .4s ease;
}

.entry__head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-weight: 400;
}
.entry__year {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: .04em;
  color: var(--stone);
  line-height: 1;
}
.entry__title {
  font-size: clamp(1.625rem, 1.3rem + 1.2vw, 2.25rem);
  line-height: 1.15;
  font-weight: 500;
}
.entry p { max-width: 58ch; color: #C9C4BA; }

.entry__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
.entry__tags li {
  font-size: .875rem;
  line-height: 1;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--stone);
}

/* Dim entries until they're reached — only with JS */
.js .entry { opacity: .38; transition: opacity .6s ease; }
.js .entry.is-active,
.js .entry.is-past { opacity: 1; }
.entry.is-active::before,
.entry.is-past::before { background: var(--gold); border-color: var(--gold); }
.entry.is-active .entry__year { color: var(--gold); }

/* ---------- Books ---------- */

.books__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 48px;
  margin-bottom: clamp(40px, 6vw, 72px);
}

.shelf {
  --shelf-h: clamp(340px, 42vw, 440px);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: calc(var(--shelf-h) + 18px);
  padding-bottom: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  position: relative;
  border-bottom: 6px solid var(--raised);
  box-shadow: 0 1px 0 var(--rule);
}

.book {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  height: var(--shelf-h);
  scroll-snap-align: start;
}

.book__spine {
  position: relative;
  width: clamp(58px, 6vw, 72px);
  height: var(--h, 90%);
  padding: 18px 0;
  border: 0;
  border-radius: 2px 2px 0 0;
  background: var(--spine);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset -6px 0 0 rgba(0, 0, 0, .18), inset 1px 0 0 rgba(255, 255, 255, .12);
  transition: transform .35s var(--ease);
}
.book__spine::before,
.book__spine::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 1px;
  background: currentColor;
  opacity: .45;
}
.book__spine::before { top: 14px; }
.book__spine::after { bottom: 14px; }
.book__spine:hover { transform: translateY(-10px); }

.book__spine-title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 100%;
}

.book__note {
  height: var(--h, 90%);
  background: var(--spine);
  color: var(--ink);
  overflow: hidden;
  border-start-end-radius: 3px;
  box-shadow: inset 10px 0 18px -10px rgba(0, 0, 0, .5);
}
.book__note-inner {
  width: min(320px, 72vw);
  height: 100%;
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
}
.book__title {
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 2.25rem;
  line-height: .95;
}
.book__author { margin-top: 10px; font-style: italic; }
.book__text { margin-top: 20px; font-size: 1rem; line-height: 1.55; opacity: .9; }
.book__meta { margin-top: auto; padding-top: 16px; font-size: .9375rem; opacity: .7; }

/* Closed/opened behaviour (JS only; without JS every book shows its note) */
.js .book__note {
  width: 0;
  visibility: hidden;
  transition: width .6s var(--ease), visibility 0s linear .6s;
}
.js .book.is-open .book__note {
  width: min(320px, 72vw);
  visibility: visible;
  transition: width .6s var(--ease), visibility 0s linear 0s;
}
.book.is-open .book__spine { transform: none; border-start-end-radius: 0; }

/* ---------- Connect ---------- */

.connect .section__title { margin-bottom: clamp(32px, 5vw, 56px); }

.links { border-top: 1px solid var(--rule); }
.links__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  padding: clamp(18px, 2.4vw, 28px) 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  transition: padding-inline-start .35s var(--ease), color .25s ease;
}
.links__name {
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  line-height: .95;
}
.links__handle { color: var(--stone); font-size: 1.0625rem; transition: color .25s ease; overflow-wrap: anywhere; }
.links__item:hover { padding-inline-start: clamp(8px, 2vw, 24px); color: var(--gold); }
.links__item:hover .links__handle { color: var(--paper); }

/* ---------- Footer ---------- */

.footer {
  margin-top: clamp(96px, 12vw, 160px);
  padding-top: 28px;
  padding-bottom: 40px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 32px;
  color: var(--stone);
  font-size: .9375rem;
}
.footer a { text-decoration: none; }
.footer a:hover { color: var(--paper); }


/* ---------- Arabic (RTL) version ----------
   Arabic letters join together, so no letter-spacing, no uppercase,
   and taller line-heights so dots and marks are never clipped. */

html[lang="ar"] {
  --display: "Alexandria", "Noto Kufi Arabic", Tahoma, sans-serif;
  --serif: "Noto Naskh Arabic", "Amiri", Tahoma, serif;
}
html[lang="ar"] body { line-height: 1.95; }

html[lang="ar"] .hero__name,
html[lang="ar"] .section__title,
html[lang="ar"] .entry__year,
html[lang="ar"] .book__spine-title,
html[lang="ar"] .book__title,
html[lang="ar"] .links__name {
  letter-spacing: 0;
  text-transform: none;
  font-variation-settings: normal;
}
html[lang="ar"] .hero__name {
  font-weight: 800;
  font-size: clamp(4rem, 17vw, 13.5rem);
  line-height: 1.12;
  margin-inline-start: 0;
}
html[lang="ar"] .hero__name .line { padding-block: .04em .36em; margin-block-end: -.3em; }
html[lang="ar"] .hero__name .line:last-child { margin-block-end: 0; } /* room for letters that dip below the line, like the dots of ي */
html[lang="ar"] .hero__lede { line-height: 1.7; }
html[lang="ar"] .section__title { font-weight: 800; font-size: clamp(3rem, 7.5vw, 6.25rem); line-height: 1.2; }
html[lang="ar"] .section__intro,
html[lang="ar"] .facts dt,
html[lang="ar"] .book__author { font-style: normal; }
html[lang="ar"] .entry__title { font-weight: 700; line-height: 1.45; }
html[lang="ar"] .book__title { font-weight: 800; font-size: 1.875rem; line-height: 1.3; }
html[lang="ar"] .book__spine-title { font-weight: 700; font-size: 1rem; }
html[lang="ar"] .links__name { font-weight: 800; line-height: 1.25; }
html[lang="ar"] .odometer,
html[lang="ar"] .nav__mark { font-family: "Big Shoulders", "Arial Narrow", Impact, sans-serif; }
html[lang="ar"] .odometer { justify-content: flex-end; }
html[lang="ar"] .entry__year { font-family: "Big Shoulders", "Arial Narrow", Impact, sans-serif; }
html[lang="ar"] .nav__links .nav__lang { font-family: "Newsreader", Georgia, serif; }
html[lang="ar"] .book__spine { box-shadow: inset 6px 0 0 rgba(0, 0, 0, .18), inset -1px 0 0 rgba(255, 255, 255, .12); }
html[lang="ar"] .book__note { box-shadow: inset -10px 0 18px -10px rgba(0, 0, 0, .5); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .about .section__title,
  .about__body { grid-column: 1 / -1; }

  .story__grid { grid-template-columns: minmax(0, 1fr); }

  /* Year counter becomes a slim sticky bar */
  .odometer {
    top: var(--nav-h);
    z-index: 5;
    font-size: 4.5rem;
    margin-inline: calc(-1 * var(--gutter));
    padding: 6px var(--gutter) 10px;
    margin-bottom: 32px;
    background: var(--black);
    border-bottom: 1px solid var(--rule);
  }
}

@media (max-width: 520px) {
  .nav__links { gap: 12px; align-items: center; }
  .nav__links li:first-child { display: none; } /* hide "About" to make room for the language switch */
  .nav__links .nav__lang { padding: 2px 10px; }
  .nav__links a { font-size: .9375rem; }
  .hero__actions { width: 100%; }
  .hero__actions .btn { flex: 1; justify-content: center; }
  .facts__row { grid-template-columns: 1fr; gap: 2px; }
  .entry { padding-inline-start: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}
