/* ==========================================================================
   About — the story, told in chapters. Follows the current mode.
   ========================================================================== */

.story-head {
  max-width: 76rem;
  margin-inline: auto;
  padding: var(--space-section) var(--pad) 0;
}
.story-head__eyebrow {
  margin-bottom: 1rem;
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.story-head__title {
  font-family: var(--font-display);
  font-size: var(--fs-5xl);
  font-weight: 400;
  line-height: 0.88;
  letter-spacing: -0.02em;
}
.story-head__title em {
  color: var(--accent);
}
.story-head__lead {
  max-width: 34ch;
  margin-top: 2rem;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: 1.2;
}

html[data-mode="code"] .story-head__eyebrow {
  text-transform: lowercase;
  letter-spacing: 0;
}
html[data-mode="code"] .story-head__title {
  font-size: var(--fs-4xl);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.06em;
  text-transform: lowercase;
}
html[data-mode="code"] .story-head__title em {
  font-style: normal;
}
html[data-mode="code"] .story-head__lead {
  max-width: 52ch;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- Chapters ---------- */
.chapters {
  max-width: 76rem;
  margin: var(--space-section) auto 0;
  padding-inline: var(--pad);
  counter-reset: chapter;
}
.chapter {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 6rem);
  padding-block: var(--space-section);
  border-top: 1px solid var(--line);
  counter-increment: chapter;
}
:is(#ch-2, #ch-4) > :last-child {
  order: -1;
}
@media (max-width: 820px) {
  .chapter {
    grid-template-columns: 1fr;
  }
  .chapter > :last-child {
    order: -1;
  }
}
.chapter__meta {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.25rem;
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.chapter__meta::before {
  content: counter(chapter, decimal-leading-zero);
  color: var(--muted);
}
.chapter__title {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
}
.chapter__text {
  max-width: 46ch;
  margin-top: 1.5rem;
  font-size: var(--fs-base);
  line-height: 1.65;
  color: color-mix(in srgb, var(--ink) 82%, var(--bg));
}
.chapter__text + .chapter__text {
  margin-top: 1rem;
}
.chapter__media {
  position: relative;
  overflow: hidden;
  background: #111;
}
.chapter__media img {
  width: 100%;
  height: auto;
  transition: scale 1.4s var(--ease);
}
.chapter__media:hover img {
  scale: 1.03;
}
.chapter__media figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.5rem 1rem 0.75rem;
  background: linear-gradient(transparent, rgb(0 0 0 / 0.7));
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.chapter__code {
  margin: 0;
  padding: 1.5rem;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.02);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
}
.chapter__code b {
  font-weight: 500;
  color: var(--accent);
}
.chapter__code i {
  font-style: normal;
  color: var(--muted);
}

html[data-mode="code"] .chapter__meta {
  text-transform: lowercase;
  letter-spacing: 0;
}
html[data-mode="code"] .chapter__title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.05em;
  text-transform: lowercase;
}
html[data-mode="code"] .chapter__text {
  font-size: var(--fs-sm);
}

/* ---------- Closing statement and doors ---------- */
.closing {
  max-width: 76rem;
  margin-inline: auto;
  padding: var(--space-section) var(--pad) 0;
  border-top: 1px solid var(--line);
}
.closing__quote {
  max-width: 22ch;
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.closing__quote em {
  color: var(--muted);
}
html[data-mode="code"] .closing__quote {
  max-width: 28ch;
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.05em;
  text-transform: lowercase;
}
html[data-mode="code"] .closing__quote em {
  font-style: normal;
}
.facts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1px;
  margin-top: clamp(2.5rem, 6vw, 4.5rem);
  border: 1px solid var(--line);
  background: var(--line);
}
.facts-row div {
  padding: 1.1rem 1.2rem;
  background: var(--bg);
}
.facts-row dt {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts-row dd {
  margin: 0.25rem 0 0;
}
.doors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.door {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  transition: border-color var(--t-fast), background-color var(--t-fast), translate var(--t) var(--ease);
}
.door:hover,
.door:focus-visible {
  border-color: var(--accent);
  background: rgb(255 74 61 / 0.05);
  translate: 0 -3px;
}
.door small {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.door strong {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 400;
  line-height: 1.1;
}
.door strong::after {
  content: " →";
  color: var(--accent);
}
html[data-mode="code"] .door strong {
  font-size: var(--fs-lg);
  font-weight: 700;
  text-transform: lowercase;
}

/* ==========================================================================
   Richer story: tools under the title, the eye, chapter rail, route map,
   big years, image reveals, collage, pull quote, lessons
   ========================================================================== */

/* ---------- Under the title ---------- */
.story-head__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 2.5rem;
}
.story-head__label {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.story-head__scroll {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.story-head__scroll::after {
  content: "";
  width: 1px;
  height: 3rem;
  background: linear-gradient(var(--accent), transparent);
}
html[data-mode="code"] .story-head__label,
html[data-mode="code"] .story-head__scroll {
  text-transform: lowercase;
  letter-spacing: 0;
}

/* ---------- The eye ---------- */
.story-eye {
  position: relative;
  height: clamp(14rem, 46vw, 34rem);
  margin-top: clamp(2.5rem, 6vw, 5rem);
  overflow: hidden;
  background: #0c0c0c;
}
.story-eye img {
  position: absolute;
  inset: -12% 0 auto 0;
  width: 100%;
  height: 124%;
  object-fit: cover;
}
.story-eye::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--bg), transparent 22%, transparent 78%, var(--bg));
}

/* ---------- Chapter rail (wide screens) ---------- */
.rail {
  display: none;
}
@media (min-width: 1640px) {
  .rail {
    position: fixed;
    top: 50%;
    left: var(--pad);
    z-index: 4;
    display: grid;
    gap: 0.9rem;
    translate: 0 -50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t);
  }
  .rail.is-on {
    opacity: 1;
    pointer-events: auto;
  }
  .rail a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: var(--fs-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    transition: color var(--t-fast);
  }
  .rail a span {
    color: transparent;
    transition: color var(--t-fast);
  }
  .rail a::before {
    content: "";
    width: 1.25rem;
    height: 1px;
    background: currentColor;
    transition: width var(--t) var(--ease), background-color var(--t-fast);
  }
  .rail a:hover,
  .rail a.is-active {
    color: var(--ink);
  }
  .rail a.is-active::before {
    width: 2.75rem;
    background: var(--accent);
  }
  .rail a.is-active span {
    color: var(--accent);
  }
  html[data-mode="code"] .rail a {
    text-transform: lowercase;
    letter-spacing: 0;
  }
}

/* ---------- Chapters: more room, big years behind ---------- */
.chapter {
  position: relative;
  min-height: 78vh;
  isolation: isolate;
}
.chapter__year {
  position: absolute;
  top: 8%;
  right: -2%;
  z-index: -1;
  font-family: var(--font-display);
  font-size: clamp(7rem, 24vw, 21rem);
  font-style: italic;
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1px rgb(236 232 225 / 0.11);
  pointer-events: none;
  user-select: none;
}
:is(#ch-2, #ch-4) .chapter__year {
  right: auto;
  left: -2%;
}
html[data-mode="code"] .chapter__year {
  font-style: normal;
  font-weight: 700;
  font-size: clamp(5rem, 17vw, 15rem);
  -webkit-text-stroke: 1px rgb(255 74 61 / 0.16);
}
.chapter__title {
  font-size: var(--fs-3xl);
}

/* ---------- Route: Tunis -> Montréal ---------- */
.route {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 0 1.5rem;
  padding-block: var(--space-section);
  border-top: 1px solid var(--line);
}
.route__map {
  width: 100%;
  height: auto;
  overflow: visible;
}
.route__ghost,
.route__line {
  fill: none;
  stroke-linecap: round;
}
.route__ghost {
  stroke: rgb(236 232 225 / 0.16);
  stroke-width: 1.5;
  stroke-dasharray: 3 9;
}
.route__line {
  stroke: var(--accent);
  stroke-width: 2.5;
}
.route__end {
  fill: var(--bg);
  stroke: var(--ink);
  stroke-width: 1.5;
}
.route__dot {
  fill: var(--accent);
}
.route__place {
  padding-bottom: 0.25rem;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  line-height: 1;
}
.route__place small {
  display: block;
  margin-top: 0.5rem;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--muted);
}
.route__place--from {
  text-align: right;
}
.route__km {
  grid-column: 1 / -1;
  margin-top: 1.5rem;
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.route__km span {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
html[data-mode="code"] .route__place,
html[data-mode="code"] .route__km span {
  font-weight: 700;
  letter-spacing: -0.05em;
  text-transform: lowercase;
}
html[data-mode="code"] .route__place {
  font-size: var(--fs-xl);
}
@media (max-width: 640px) {
  .route {
    grid-template-columns: 1fr 1fr;
  }
  .route__map {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 1rem;
  }
}

/* ---------- Pull quote ---------- */
.pull {
  margin: 0;
  padding: var(--space-section) 0;
  border-top: 1px solid var(--line);
}
.pull p {
  max-width: 20ch;
  margin-inline: auto;
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
  text-wrap: balance;
}
.pull em {
  color: var(--muted);
}
html[data-mode="code"] .pull p {
  max-width: 26ch;
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.05em;
  text-transform: lowercase;
}
html[data-mode="code"] .pull em {
  font-style: normal;
}

/* ---------- Collage ---------- */
.collage {
  position: relative;
  aspect-ratio: 1 / 1.05;
}
.collage img {
  position: absolute;
  width: 52%;
  height: auto;
  box-shadow: 0 30px 60px rgb(0 0 0 / 0.6);
}
.collage__a {
  top: 0;
  left: 4%;
  rotate: -4deg;
}
.collage__b {
  top: 14%;
  right: 0;
  z-index: 1;
  rotate: 3deg;
}
.collage__c {
  bottom: 0;
  left: 22%;
  z-index: 2;
  width: 44% !important;
  rotate: -1.5deg;
}
/* ---------- Lessons ---------- */
.lessons {
  width: 100%;
  max-width: 34rem;
  margin-top: 2rem;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
.lessons th {
  padding: 0 1rem 0.75rem 0;
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
}
.lessons td {
  width: 50%;
  padding: 0.8rem 1rem 0.8rem 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
}
.lessons td:last-child {
  color: var(--muted);
}
html[data-mode="code"] .lessons th {
  text-transform: lowercase;
  letter-spacing: 0;
}
html[data-mode="code"] .lessons td {
  font-size: var(--fs-base);
}

/* The contact door is the page's main action */
.door--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.door--primary small,
.door--primary strong::after {
  color: inherit;
}
.door--primary:hover,
.door--primary:focus-visible {
  background: color-mix(in srgb, var(--accent) 88%, #fff);
}
