/* =====================================================================
   Socle : mise en page, barre du haut, dock (fiche + curseur d'époque)
   Les couleurs et polices viennent de css/eras.css.
   ===================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  overflow: hidden;
  background: var(--ui-bg);
  color: var(--ui-fg);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}

/* ---------------------------------------------------------------- barre du haut */

.hud {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(12px, 2.4vw, 28px);
  background: var(--hud-bg, var(--ui-bg));
  border-bottom: var(--ui-border, 1px solid var(--ui-line));
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}
.brand b {
  font-family: var(--ui-display);
  font-weight: var(--brand-weight, 800);
  font-size: var(--brand-size, 22px);
  letter-spacing: var(--brand-tracking, 0);
  color: var(--ui-accent);
}
.brand span {
  color: var(--ui-muted);
  font-size: 14px;
}

.seg {
  display: inline-flex;
  padding: var(--seg-pad, 3px);
  gap: var(--seg-gap, 2px);
  background: var(--seg-bg, rgba(255, 255, 255, 0.06));
  border-radius: var(--ui-radius);
  border: var(--seg-border, 0);
}
.seg button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  border: var(--btn-border, 0);
  background: var(--btn-bg, transparent);
  color: var(--btn-fg, var(--ui-fg));
  padding: var(--btn-pad, 7px 12px);
  border-radius: calc(var(--ui-radius) - 2px);
  font-size: var(--btn-size, 14px);
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  text-transform: var(--btn-case, none);
  letter-spacing: var(--btn-tracking, 0);
  box-shadow: var(--btn-shadow, none);
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.08s;
}
.btn:active,
.seg button:active {
  transform: translateY(1px);
}
.seg button[aria-checked='true'],
.btn[aria-pressed='true'] {
  background: var(--btn-on-bg, var(--ui-accent));
  color: var(--btn-on-fg, var(--ui-accent-ink));
  box-shadow: var(--btn-on-shadow, none);
}
.seg button svg,
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.credits {
  font-family: var(--ui-mono);
  font-size: 13px;
  color: var(--ui-muted);
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.credits b {
  color: var(--ui-fg);
  font-weight: 700;
}
.snd.is-new {
  animation: nudge 2.4s ease-in-out 1.5s 4;
}
.snd .wave {
  transition: opacity 0.2s;
}
.snd[aria-pressed='false'] .wave {
  opacity: 0;
}
.snd[aria-pressed='true'] .mute {
  opacity: 0;
}

:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- scène */

.stage {
  position: relative;
  min-height: 0;
  overflow: clip;
  background: #000;
}
.stage > section {
  transition: opacity 0.35s;
}
.stage > section[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- dock */

.dock {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 500px);
  gap: clamp(16px, 3vw, 40px);
  align-items: center;
  padding: 12px clamp(12px, 2.4vw, 28px) max(12px, env(safe-area-inset-bottom));
  background: var(--dock-bg, var(--ui-bg));
  border-top: var(--ui-border, 1px solid var(--ui-line));
}

.caption {
  min-width: 0;
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 4px;
  align-items: center;
}
.cap-tag {
  grid-row: 1;
  justify-self: start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 7px 3px;
  border-radius: calc(var(--ui-radius) / 2);
  background: var(--ui-accent);
  color: var(--ui-accent-ink);
  white-space: nowrap;
}
.cap-tag.is-import {
  background: #ffd400;
  color: #111;
}
.cap-tag.is-off {
  background: var(--ui-line);
  color: var(--ui-fg);
}
.cap-head {
  grid-row: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.cap-title {
  font-family: var(--ui-display);
  font-size: var(--cap-size, 20px);
  font-weight: var(--cap-weight, 800);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cap-meta {
  color: var(--ui-muted);
  font-size: 13px;
  white-space: nowrap;
}
.cap-pitch {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ui-muted);
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cap-pitch kbd {
  font-family: var(--ui-mono);
  font-size: 0.86em;
  padding: 1px 5px;
  border: 1px solid var(--ui-line);
  border-radius: 3px;
  color: var(--ui-fg);
}
.caption.is-hint .cap-pitch {
  -webkit-line-clamp: 3;
}

/* curseur d'époque */
.era {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 16px;
  align-items: center;
}
.era-read {
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 96px;
}
.era-read label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ui-muted);
}
.odo {
  display: flex;
  font-family: var(--odo-font, var(--ui-mono));
  font-size: var(--odo-size, 30px);
  font-weight: 700;
  line-height: 1;
  color: var(--ui-fg);
  font-variant-numeric: tabular-nums;
}
.odo span {
  display: inline-block;
  min-width: 0.62em;
  text-align: center;
}
.odo span.roll {
  animation: odo-roll 0.22s ease-out;
}
.era-name {
  font-size: 12px;
  color: var(--ui-accent);
  white-space: nowrap;
}

.era input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.era input[type='range']::-webkit-slider-runnable-track {
  height: var(--track-h, 6px);
  background: var(--track-bg);
  border-radius: var(--track-radius, 3px);
  box-shadow: var(--track-shadow, none);
}
.era input[type='range']::-moz-range-track {
  height: var(--track-h, 6px);
  background: var(--track-bg);
  border-radius: var(--track-radius, 3px);
}
.era input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb-w, 18px);
  height: var(--thumb-h, 18px);
  margin-top: calc((var(--track-h, 6px) - var(--thumb-h, 18px)) / 2);
  border: var(--thumb-border, 0);
  border-radius: var(--thumb-radius, 50%);
  background: var(--thumb-bg, var(--ui-accent));
  box-shadow: var(--thumb-shadow, none);
}
.era input[type='range']::-moz-range-thumb {
  width: var(--thumb-w, 18px);
  height: var(--thumb-h, 18px);
  border: var(--thumb-border, 0);
  border-radius: var(--thumb-radius, 50%);
  background: var(--thumb-bg, var(--ui-accent));
  box-shadow: var(--thumb-shadow, none);
}
.era-ticks {
  position: relative;
  height: 14px;
  font-family: var(--ui-mono);
  font-size: 11px;
  color: var(--ui-muted);
}
.era-ticks button {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  border: 0;
  background: none;
  padding: 0 2px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.era-ticks button:hover,
.era-ticks button.is-current {
  color: var(--ui-fg);
}
.era-ticks button:first-child {
  transform: none;
}
.era-ticks button:last-child {
  transform: translateX(-100%);
}

/* ---------------------------------------------------------------- effets plein écran */

.fx-static {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.6 0 0 0 0 0.6 0 0 0 0 0.6 0 0 0 1.4 -0.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-color: #222;
}
.fx-static.is-on {
  animation:
    static-flash 0.34s ease-out,
    static-jitter 0.1s steps(3) 4;
}
.fx-static.is-digital.is-on {
  background-image: none;
  background-color: #000;
  animation: digital-cut 0.36s ease-in-out;
}

.fx-launch {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--l-bg, #000);
  transition:
    inset 0.55s cubic-bezier(0.7, 0, 0.2, 1),
    border-radius 0.55s;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.fx-launch::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  animation: launch-flash 0.7s ease-out forwards;
}
.fx-launch span {
  font-family: var(--ui-display);
  color: var(--l-ink, #fff);
  font-size: clamp(18px, 3vw, 34px);
  opacity: 0;
  animation: fade-in 0.3s 0.45s forwards;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  padding: 40px;
  background: #111;
  color: #eee;
  font: 16px/1.5 system-ui, sans-serif;
}
.noscript a {
  color: #ffd400;
}

@keyframes nudge {
  0%,
  60%,
  100% {
    box-shadow: var(--btn-shadow, 0 0 0 0 transparent);
  }
  30% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-accent) 45%, transparent);
  }
}
@keyframes odo-roll {
  from {
    transform: translateY(-45%);
    opacity: 0;
  }
}
@keyframes static-flash {
  0% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}
@keyframes static-jitter {
  0% {
    background-position: 0 0;
  }
  50% {
    background-position: -60px 40px;
  }
  100% {
    background-position: 30px -90px;
  }
}
@keyframes digital-cut {
  0% {
    opacity: 0;
  }
  35%,
  55% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes launch-flash {
  0% {
    opacity: 0;
  }
  55% {
    opacity: 0;
  }
  70% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}
@keyframes fade-in {
  to {
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- petits écrans */

@media (max-width: 860px) {
  .dock {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .caption {
    min-height: 0;
  }
  .cap-pitch {
    -webkit-line-clamp: 1;
  }
  .brand span,
  .credits {
    display: none;
  }
}
@media (max-width: 520px) {
  .hud {
    gap: 8px;
  }
  .era-ticks button[data-year='2020'] {
    display: none;
  }
  .seg button span,
  .snd span {
    display: none;
  }
  .odo {
    font-size: 24px;
  }
  .era-read {
    min-width: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
