/* site/assets/css/hero.css — the homepage hero (loaded by site/index.html only).
   One composition, two aligned columns:
   - left: the headline as a split-flap departures board (built by
     hero-board.js from the real <h1>, which stays in the page for search
     engines and screen readers), then the lede, the buttons and the stats;
   - right: the departures panel — the live flip row, the route chart
     (hero-atlas.js) and the eight trips, read from the trip cards below.
   Below 960px the two stack, both full width. The grid mirrors in Arabic,
   where the headline stays as type (Arabic letters must join, so no tiles). */

section.home-hero { align-items: center; }
.home-hero .home-hero__inner {
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  align-items: center;
  gap: var(--s7) clamp(32px, 4.5vw, 80px);
  padding-top: calc(var(--nav-h) + clamp(24px, 5svh, 56px));
  padding-bottom: clamp(28px, 5svh, 56px);
}
.home-hero .home-hero__content { gap: 0; min-width: 0; container: copy / inline-size; }

/* eyebrow: a hairline and spaced caps */
.home-hero .hero__eyebrow {
  align-self: flex-start;
  gap: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .16em;
}
.home-hero .hero__eyebrow svg { display: none; }
.home-hero .hero__eyebrow::before { content: ''; width: 32px; height: 1px; background: currentColor; flex: none; }
:root[lang="ar"] .home-hero .hero__eyebrow { letter-spacing: 0; font-size: 13px; }

/* the headline as type: no-JS, Arabic, and the frame before the tiles are built */
.home-hero .hero__title {
  margin: 18px 0 0;
  font-size: clamp(2.6rem, 1.2rem + 3.6vw, 5.2rem);
  line-height: .96;
  letter-spacing: -.04em;
  text-wrap: balance;
}
.home-hero .hero__title em { font-size: 1em; letter-spacing: inherit; color: var(--accent); }
:root[lang="ar"] .home-hero .hero__title,
:root[lang="ar"] .home-hero .hero__title em { letter-spacing: 0; line-height: 1.3; font-size: clamp(2.3rem, 1.2rem + 3vw, 4.4rem); }
/* once the board is built the <h1> text is kept for assistive tech only */
.home-hero .hero__title.is-boarded {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── the split-flap headline ── */
.flapboard {
  /* tile size = column width / (cols + gaps); hero-board.js refines it after measuring */
  --cols: 9;
  --cell: min(74px, calc(100cqw / (var(--cols) * 1.07 - 0.07)));
  --flap-bg: #161c24;
  --flap-hinge: rgba(0, 0, 0, .55);
  --flap-blank: rgba(255, 255, 255, .035);
  display: grid;
  gap: calc(var(--cell) * .1);
  margin-top: 18px;
  direction: ltr;
  user-select: none;
}
:root[data-theme="light"] .flapboard { --flap-bg: #0f2a40; --flap-hinge: rgba(0, 0, 0, .35); --flap-blank: rgba(0, 44, 81, .07); }
.flaprow { display: flex; gap: calc(var(--cell) * .07); }
.flapcell {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: var(--cell);
  height: calc(var(--cell) * 1.28);
  border-radius: calc(var(--cell) * .09);
  background: var(--flap-bg);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .06), 0 1px 0 rgba(0, 0, 0, .35);
  color: #f3ede2;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: calc(var(--cell) * .84);
  line-height: 1;
  overflow: hidden;
}
.flapcell::after {                                /* the hinge */
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: var(--flap-hinge);
}
.flapcell.is-blank { background: var(--flap-blank); box-shadow: none; }
.flapcell.is-blank::after { opacity: .4; }
.flaprow--em .flapcell { color: var(--mint, #9ce8b2); }
:root[data-theme="light"] .flaprow--em .flapcell { color: #9ce8b2; }
.flapcell.is-flip { animation: flap-turn .13s cubic-bezier(.3, 0, .4, 1); }
@keyframes flap-turn {
  from { transform: perspective(calc(var(--cell) * 4)) rotateX(-78deg); filter: brightness(.6); }
  to   { transform: none; filter: none; }
}

.home-hero .hero__lede { margin-top: 24px; max-width: 46ch; font-size: 17px; line-height: 1.6; color: var(--txt-2); }
.home-hero .home-hero__content > .u-cluster { margin-top: 28px; }

/* stats: one compact row of four */
.home-hero .hero-stats {
  grid-column: auto;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  gap: 0;
  margin-top: 30px;
  padding-top: 18px;
}
.home-hero .hero-stats > div { padding-inline-end: 24px; }
.home-hero .hero-stats > div + div { padding-inline-start: 24px; }
.home-hero .hero-stats .fs-h3 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.home-hero .hero-stats .fs-body-sm { font-size: 12px; margin-top: 3px; }

/* ── the departures panel ── */
.departures {
  container: deps / inline-size;
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--txt-1) 3%, transparent);
}

/* live flip row */
.atlas__board {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 12px 6px 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border: 1px solid var(--border);
  direction: ltr;
  overflow: hidden;
}
.atlas__board-from {
  font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .08em;
  padding: 4px 7px; border-radius: 6px; color: var(--bg); background: var(--accent);
}
.atlas__board-plane { color: var(--accent); flex: none; transform: rotate(90deg); }
.atlas__board-to { display: inline-flex; gap: 2px; flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--txt-1); }
.atlas__board-to .flap {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 1.05em; height: 1.45em; border-radius: 3px; overflow: hidden;
  background: color-mix(in srgb, var(--txt-1) 9%, transparent);
}
.atlas__board-to .flap::after {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.atlas__board-to .flap.is-blank { background: transparent; width: .45em; }
.atlas__board-to .flap.is-flip { animation: atlas-flap .14s ease-out; }
.atlas__board-price { font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.atlas__board-to.is-swap, .atlas__board-price.is-swap { animation: atlas-swap .4s ease-out; }
:root[lang="ar"] .atlas__board-to { direction: rtl; }
@keyframes atlas-flap { from { transform: perspective(80px) rotateX(-80deg); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes atlas-swap { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* the route chart */
.atlas {
  position: relative;
  aspect-ratio: 16 / 8.4;
  border-radius: 14px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity .9s ease;
}
.atlas.is-ready { opacity: 1; }
.atlas__layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.atlas__frame { position: absolute; inset: 10px 10px 22px; pointer-events: none; }
.atlas__marks { position: absolute; inset: 0; direction: ltr; }
.atlas__mark { position: absolute; left: var(--x); top: var(--y); width: 0; height: 0; }
.atlas__mark::before { content: ''; position: absolute; width: 26px; height: 26px; left: -13px; top: -13px; border-radius: 50%; }
.atlas__mark-label {
  position: absolute; white-space: nowrap;
  font-family: var(--font-display); font-weight: 600; font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--txt-2); transition: color .25s ease;
}
.atlas__mark[data-side="ne"] .atlas__mark-label { left: 9px;  bottom: 5px; }
.atlas__mark[data-side="nw"] .atlas__mark-label { right: 9px; bottom: 5px; }
.atlas__mark[data-side="se"] .atlas__mark-label { left: 9px;  top: 5px; }
.atlas__mark[data-side="sw"] .atlas__mark-label { right: 9px; top: 5px; }
.atlas__mark.is-active .atlas__mark-label { color: var(--accent); }
.atlas__mark.is-hidden .atlas__mark-label { visibility: hidden; }
:root[lang="ar"] .atlas__mark-label { letter-spacing: 0; font-size: 11px; }

/* the eight trips: two columns of single-line rows */
.departures__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px;
}
.departures__row {
  position: relative;
  display: grid;
  grid-template-columns: 1.9em minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--txt-1);
  text-decoration: none;
}
.departures__row::before {
  content: ''; position: absolute; inset-inline-start: -8px; top: 9px; bottom: 9px; width: 2px;
  background: var(--accent); transform: scaleY(0); transition: transform .3s ease;
}
.departures__no { font-family: var(--font-display); font-weight: 600; font-size: 10.5px; letter-spacing: .08em; color: var(--txt-3); font-variant-numeric: tabular-nums; }
.departures__name { font-family: var(--font-display); font-weight: 600; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .25s ease; }
.departures__dur { display: none; }
.departures__price { font-family: var(--font-display); font-weight: 600; font-size: 12px; color: var(--txt-2); font-variant-numeric: tabular-nums; white-space: nowrap; transition: color .25s ease; }
.departures__row.is-active::before, .departures__row:hover::before, .departures__row:focus-visible::before { transform: scaleY(1); }
.departures__row.is-active .departures__name, .departures__row:hover .departures__name,
.departures__row.is-active .departures__price, .departures__row:hover .departures__price { color: var(--accent); }
.departures__row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
:root[lang="ar"] .departures__name { letter-spacing: 0; font-size: 13.5px; }
/* "129 000 DA" inside Arabic text must not reorder to "DA 000 129" */
.departures__price, .atlas__board-price, .atlas__board-to { unicode-bidi: plaintext; }

/* a narrow copy column: stats as 2 x 2 */
@container copy (max-width: 540px) {
  .home-hero .hero-stats { grid-template-columns: repeat(2, auto); row-gap: 14px; }
  .home-hero .hero-stats > div:nth-child(3) { padding-inline-start: 0; border-inline-start: 0; }
}
/* a narrow panel: each trip row puts its price under the name */
@container deps (max-width: 600px) {
  .departures__row { grid-template-columns: 1.7em minmax(0, 1fr); grid-template-areas: "no name" "no price"; row-gap: 1px; padding: 7px 4px; }
  .departures__no { grid-area: no; align-self: center; }
  .departures__name { grid-area: name; }
  .departures__price { grid-area: price; font-size: 11.5px; }
}

/* stacked: both columns full width */
@media (max-width: 959px) {
  .home-hero .home-hero__inner { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .home-hero .home-hero__inner { padding-top: calc(var(--nav-h) + var(--s5)) !important; gap: var(--s6); }
  .home-hero .hero__lede { font-size: 16px; }
  .home-hero .hero-stats { grid-template-columns: repeat(2, auto); row-gap: 14px; }
  .home-hero .hero-stats > div:nth-child(3) { padding-inline-start: 0; border-inline-start: 0; }
  .departures { padding: 10px; border-radius: 18px; }
  .atlas { aspect-ratio: 16 / 10; }
  .atlas__marks { display: none; }
  .departures__list {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  }
  .departures__list > li { flex: none; scroll-snap-align: start; }
  .departures__row {
    grid-template-columns: auto; row-gap: 2px;
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px; min-width: 128px;
  }
  .departures__no { display: none; }
  .departures__row::before { display: none; }
  .departures__row.is-active { border-color: var(--accent); }
}
@media (prefers-reduced-motion: reduce) {
  .atlas { transition: none; }
  .flapcell.is-flip, .atlas__board-to .flap.is-flip, .atlas__board-to.is-swap, .atlas__board-price.is-swap { animation: none; }
}
@media print { .atlas, .flapboard { display: none; } .home-hero .hero__title.is-boarded { position: static; width: auto; height: auto; clip: auto; clip-path: none; } }
