/*
 * La vitrine, en HTML statique servi tel quel.
 *
 * Ce qui habille le chassis lui-même vit dans `examples/src/demo.css` : il tourne dans son
 * iframe et n'a rien à voir avec la page qui l'encadre. La palette commune aux deux est
 * dans `tokens.css`.
 */

/*
 * The showcase.
 *
 * Its palette is the library's own inversion, kept honest: the page is the CHASSIS colour and
 * every block laid on it is DARKER, which is the one visual idea the product is built on. The
 * accent is brass rather than the library's default blue — the page is itself a demonstration
 * that the accent comes from the host.
 */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 32px;
}

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

body {
  margin: 0;
  background: var(--chassis);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--brass);
  color: var(--brass-ink);
}

a {
  color: inherit;
}

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

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 96px var(--rail);
}

@media (max-width: 900px) {
  .page {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* ---------- the rail, which is the page's navigation ---------- */

.railnav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: var(--rail);
  height: 100vh;
  padding-top: 26px;
  border-right: 1px solid var(--line);
  background: var(--chassis);
}

.railnav__mark {
  width: 18px;
  height: 18px;
  margin-bottom: 22px;
  border-radius: 4px;
  /* The product in one glyph: a darker surface laid on the chassis, with a rail down its side. */
  background: linear-gradient(to right, var(--brass) 0 4px, transparent 4px), var(--sunk);
}

.railnav__dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition:
    color 140ms ease,
    background-color 140ms ease;
}

.railnav__dot:hover {
  background: var(--raised);
  color: var(--ink);
}

.railnav__dot--on {
  color: var(--brass);
}

.railnav__glyph {
  display: grid;
  place-items: center;
}

.railnav__glyph svg {
  width: 20px;
  height: 20px;
}

/* The label rides out of the rail on hover — the rail stays a rail. */

.railnav__label {
  position: absolute;
  left: calc(100% + 8px);
  padding: 4px 9px;
  border-radius: 5px;
  background: var(--sunk);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  pointer-events: none;
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.railnav__dot:hover .railnav__label,
.railnav__dot:focus-visible .railnav__label {
  opacity: 1;
  transform: none;
}

@media (max-width: 900px) {
  .railnav {
    flex-direction: row;
    width: 100%;
    height: auto;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .railnav__mark {
    margin: 0 12px 0 0;
  }
  .railnav__label {
    display: none;
  }
}

/* ---------- hero ---------- */

.hero {
  padding: 92px 0 48px;
}

@media (max-width: 900px) {
  .hero {
    padding-top: 40px;
  }
}

.hero__eyebrow {
  margin: 0 0 20px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.hero__title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.hero__title em {
  font-style: normal;
  color: var(--brass);
}

.hero__lead {
  margin: 22px 0 0;
  max-width: 52ch;
  font-size: 1.06rem;
  color: var(--muted);
}

.hero__actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 30px 0 44px;
}

.install {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.install:hover {
  border-color: var(--brass);
}

.install code {
  font-family: var(--mono);
  font-size: 13px;
}

.install__state {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brass);
}

.link {
  color: var(--brass);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  font-weight: 500;
}

.link:hover {
  border-bottom-color: currentColor;
}

/* ---------- the live chassis ---------- */

.stage {
  margin: 0;
}

.stage__frame {
  height: min(62vh, 540px);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  /* The one shadow on the page: it lifts the demo off the chassis so it reads as a device. */
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.4);
}

/* 🛑 Sans ces deux lignes, le chassis se dessinait dans un rectangle de 300 × 150 px,
   coincé en haut à gauche du cadre : c'est la taille par défaut d'une `<iframe>`, qui
   ne s'étire pas toute seule vers son parent. La démo vivait dans le flux de la page
   tant qu'elle était un composant React — elle n'avait alors aucune boîte à remplir. */
.stage__frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.stage__caption {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- sections ---------- */

.section {
  padding-top: 88px;
}

.section__title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section__lead {
  margin: 10px 0 34px;
  max-width: var(--measure);
  color: var(--muted);
}

/* ---------- example cards ---------- */

.cards {
  display: grid;
  gap: 20px;
  /* 🛑 `min()` and not a bare 390px: a fixed minimum stays 390px wide on a 390px screen, and
     the card then overflows by its own padding — measured at 150px of horizontal scroll on a
     phone. `min(100%, …)` lets the track collapse to the space that actually exists. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 390px), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.card__head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card__title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.16rem;
  font-weight: 600;
}

.card__what {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card__tip {
  margin: 0;
  padding-left: 14px;
  border-left: 2px solid var(--brass);
  color: var(--muted);
  font-size: 13.5px;
}

.card__tip strong {
  color: var(--ink);
  font-weight: 500;
}

.card__open {
  margin-top: auto;
  align-self: flex-start;
  color: var(--brass);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.card__open:hover span {
  margin-left: 3px;
}

.card__open span {
  display: inline-block;
  transition: margin-left 140ms ease;
}

/* ---------- code ---------- */

.code {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  overflow: hidden;
}

.code__pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.4px;
  line-height: 1.65;
  tab-size: 2;
}

.code code {
  color: #cfc7b8;
}

.code .k {
  color: var(--brass);
}

.code .s {
  color: #9ec07a;
}

.code .c {
  color: #6f695e;
  font-style: italic;
}

.code .t {
  color: #7fb8d8;
}

.code__caption {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* ---------- api list ---------- */

.api {
  margin: 0;
  display: grid;
  gap: 2px;
}

.api__row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 28px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  .api__row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.api__name {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
}

.api__body {
  margin: 0;
  display: grid;
  gap: 12px;
}

.api__body p {
  margin: 0;
  max-width: var(--measure);
  color: var(--muted);
}

/* ---------- foot ---------- */

.foot {
  margin-top: 96px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.foot__links {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.foot__note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* The language pair, at the foot of the rail: a preference, not a step in the reading. */

.railnav__lang {
  border: none;
  border-radius: 5px;
  padding: 4px 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.railnav__lang:hover {
  background: var(--raised);
  color: var(--ink);
}

.railnav__lang--on {
  color: var(--brass);
}

@media (max-width: 900px) {
  /* The rail is a horizontal bar there: the switch sits at its end and opens downward. */
  .langs {
    margin: 0 0 0 auto;
  }
  .langs__menu {
    top: calc(100% + 8px);
    bottom: auto;
    inset-inline-start: auto;
    inset-inline-end: 0;
  }
}

/*
 * The language switch, at the foot of the rail.
 *
 * The button carries the code — all that fits in 68 px — and the menu opens BESIDE the rail,
 * where there is room for the native names. Same shape as map3D's, which had already solved it.
 */

.langs {
  position: relative;
  margin-top: auto;
  margin-bottom: 18px;
}

.langs__current {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--sunk);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  list-style: none;
}

.langs__current::-webkit-details-marker {
  display: none;
}

.langs__current::after {
  content: '▾';
  font-size: 9px;
}

.langs__current:hover,
details[open] > .langs__current {
  color: var(--ink);
  border-color: var(--brass);
}

/* Beside the rail and anchored to its foot: opening upward keeps the list on screen when the
   button is already at the bottom of the viewport. */

.langs__menu {
  position: absolute;
  bottom: 0;
  inset-inline-start: calc(100% + 8px);
  z-index: 12;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
}

.langs__item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 5px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
}

.langs__item:hover {
  background: var(--raised);
  color: var(--ink);
}

.langs__item[aria-current='true'] {
  color: var(--brass);
}

.langs__item b {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  opacity: 0.55;
}

.langs__item i {
  font-style: normal;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Right-to-left. The stylesheet uses logical properties throughout, so the only things left to
   turn are the two places that name a physical side. */

[dir='rtl'] .railnav {
  right: 0;
  left: auto;
  border-right: none;
  border-left: 1px solid var(--line);
}

[dir='rtl'] .page {
  padding-right: var(--rail);
  padding-left: 28px;
}

[dir='rtl'] .railnav__label {
  right: calc(100% + 8px);
  left: auto;
}

[dir='rtl'] .card__tip {
  padding-right: 14px;
  padding-left: 0;
  border-right: 2px solid var(--brass);
  border-left: none;
}

/* Code is read left to right whatever the page around it does. */

[dir='rtl'] .code,
[dir='rtl'] .install code {
  direction: ltr;
  text-align: left;
}

@media (max-width: 900px) {
  [dir='rtl'] .page {
    padding-right: 20px;
  }
  [dir='rtl'] .railnav {
    border-left: none;
  }
}

/* Le pavillon du sélecteur de langue. Taille fixée en `em` pour qu'il suive le texte, et
   `line-height: 1` parce que les emoji drapeaux ont une hauteur de ligne propre qui
   décalait la ligne de base des noms à côté d'eux. */
.langs__flag {
  flex: none;
  font-size: 1.05em;
  line-height: 1;
}

/* Avec le pavillon la ligne porte trois éléments, et `space-between` les aurait écartés
   un à un — drapeau à gauche, nom au milieu, code à droite. Le nom prend l'espace qui
   reste : le drapeau lui reste collé, le code à deux lettres tient la droite. */
.langs__item i {
  flex: 1;
}

/* Le filet qui sépare les sections de la page des liens qui en sortent : au-dessus on
   navigue dans la page, en dessous on la quitte. */
.railnav__rule {
  width: 20px;
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

@media (max-width: 900px) {
  .railnav__rule {
    width: 1px;
    height: 20px;
    margin: 0 6px;
  }
}
