@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-MediumItalic.ttf") format("truetype");
  font-weight: 500;
  font-style: italic;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-SemiBoldItalic.ttf") format("truetype");
  font-weight: 600;
  font-style: italic;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
}

:root {
  --astuce-pink: #bd0062;
  --astuce-pink-dark: #a90058;
  --astuce-pink-light: #f3a8bf;
  --lime: #c9ff54;
  --ink: #111111;
  --muted: #666a70;
  --line-grey: #bcbfc3;
  --background: #676767;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;

  background: var(--background);
  color: var(--ink);
  font-family: "Poppins", Arial, sans-serif;

  overflow: auto;
}

.tft-screen {
  width: min(96vw, 1600px);
  aspect-ratio: 16 / 9;
  background: #fff;
  border: 1px solid #111;
  display: grid;
  grid-template-rows: 15.5% 84.5%;
  overflow: hidden;
}

.topbar {
  min-width: 0;
  background: var(--astuce-pink);
  color: #fff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.route-title {
  min-width: 0;
  height: 100%;
  position: relative;
}

.route-title .towards {
  position: absolute;
  left: 1.7rem;
  top: 50%;
  transform: translateY(-50%);

  width: 6.5rem;

  font-size: clamp(1.4rem, 2.1vw, 2.7rem);
  font-style: italic;
  font-weight: 400;

  white-space: nowrap;
}

#towards-text {
  display: block;
}

.route-title #destination {
  position: absolute;

  left: 9.5rem;
  right: 0.5rem;

  top: 0;
  bottom: 0;

  display: flex;
  flex-direction: column;
  justify-content: center;

  margin: 0;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  font-size: clamp(1.7rem, 2.8vw, 3.4rem);
  font-weight: 600;
  line-height: 1;
}

.clock {
  margin-right: 1.5rem;
  width: 12rem;
  height: 5rem;

  background: #666a70;
  color: #fff;
  border-radius: 0.45rem;

  display: grid;
  place-items: center;

  overflow: hidden;
  white-space: nowrap;
}

.clock span {
  display: block;

  font-size: clamp(2rem, 3.2vw, 3.8rem);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 1;

  transform: none;
}

.main-panel {
  width: 100%;
  min-height: 0;
  display: block;
}

.journey-panel {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 40% 38% 22%;
}

.next-stop-block {
  min-width: 0;
  padding: clamp(2rem, 4vw, 5rem) clamp(2rem, 5vw, 6rem) 1.5rem;
  position: relative;
}

.next-stop-block::before {
  content: "";
  position: absolute;
  left: 0;
  top: 41%;
  transform: translateY(-50%);
  border-top: 2.3rem solid transparent;
  border-bottom: 2.3rem solid transparent;
  border-left: 2.6rem solid var(--astuce-pink);
}

.next-stop-label {
  color: var(--muted);
  font-size: clamp(1.1rem, 1.6vw, 1.8rem);
  font-weight: 600;
}

.next-stop-name {
  margin-top: 0.5rem;
  color: var(--astuce-pink);

  font-size: clamp(2.5rem, 4.5vw, 5.2rem);
  font-weight: 700;
  line-height: 1.05;

  overflow-wrap: anywhere;
}

.next-stop-time {
  margin-top: 1rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.8rem);
  font-weight: 700;
}

.timeline {
  --line-y: 58%;
  --dot-size: clamp(2rem, 3vw, 3.4rem);
  --timeline-padding: clamp(2rem, 3vw, 4rem);

  width: 100%;
  min-width: 0;
  position: relative;

  padding: 0 var(--timeline-padding);

  display: grid;
  grid-template-columns:
    repeat(var(--stop-count, 6), minmax(0, 1fr));
}

.timeline::before {
  content: "";
  position: absolute;

  left: 0;

  /*
   * Padding droit
   * + moitié de la dernière colonne
   */
  right: calc(
    var(--timeline-padding)
    + (
      (100% - 2 * var(--timeline-padding))
      / var(--stop-count)
      / 2
    )
  );

  top: var(--line-y);
  transform: translateY(-50%);

  height: 0.48rem;
  background: var(--astuce-pink);
  z-index: 0;
}

.timeline-stop {
  min-width: 0;
  height: 100%;
  position: relative;
  text-align: center;

  /* Ne pas créer un niveau d’empilement par arrêt */
  z-index: auto;
}

.timeline-dot {
  position: absolute;
  left: 50%;
  top: var(--line-y);
  transform: translate(-50%, -50%);

  width: var(--dot-size);
  aspect-ratio: 1;

  border: 0.35rem solid #aaaeb2;
  border-radius: 50%;
  background: #fff;

  z-index: 3;
}

.timeline.at-departure-terminus::before {
  left: calc(
    var(--timeline-padding)
    + (
      (100% - 2 * var(--timeline-padding))
      / var(--stop-count)
      / 2
    )
  );
}

.timeline-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(42% + 2.2rem);

  padding: 0 0.3rem;

  font-size: clamp(0.75rem, 1vw, 1.05rem);
  line-height: 1.05;
  font-weight: 600;

  z-index: 3;
}

.timeline-time {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--line-y) + 2.2rem);

  padding: 0;

  font-size: clamp(0.75rem, 1vw, 1.05rem);
  text-align: center;
  font-weight: 600;

  z-index: 3;
}

.timeline-stop.current .timeline-name,
.timeline-stop.current .timeline-time {
  color: var(--astuce-pink);
}

.timeline-stop.current .timeline-dot {
  border-color: var(--astuce-pink);
  box-shadow: inset 0 0 0 0.45rem #fff;
  background: var(--astuce-pink);
}

.timeline-stop.reference .timeline-dot {
  border-color: var(--astuce-pink);
}

.timeline-stop.terminus .timeline-name,
.timeline-stop.terminus .timeline-time {
  color: var(--astuce-pink);
  font-weight: 700;
}

.timeline-stop.terminus .timeline-dot {
  border-color: var(--astuce-pink);
  background: var(--astuce-pink);
  box-shadow: inset 0 0 0 0.35rem #fff;
}

/* Pointillés uniquement entre les bords des deux cercles */
.timeline-stop.hidden-stops-before::before {
  content: "";
  position: absolute;

  left: calc(-50% + var(--dot-size) / 2);
  width: calc(100% - var(--dot-size));

  top: var(--line-y);
  transform: translateY(-50%);

  height: 0.48rem;

  background: repeating-linear-gradient(
    90deg,
    var(--astuce-pink) 0,
    var(--astuce-pink) 1rem,
    #fff 1rem,
    #fff 1.65rem
  );

  z-index: 1;
}

.timeline-stop.skipped .timeline-name,
.timeline-stop.skipped .timeline-time {
  color: #777;
}

.timeline-stop.skipped .timeline-dot {
  border-color: #777;
  background: #fff;
}

.timeline-stop.skipped .timeline-time {
  font-style: italic;
}

.bottom-message {
  margin: clamp(1rem, 2vw, 2rem);
  padding: 0 clamp(1rem, 2vw, 2rem);
  border-radius: 1.3rem;
  background: linear-gradient(90deg, #f0f0f0, #fafafa);
  color: var(--astuce-pink);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: clamp(1rem, 1.6vw, 1.7rem);
  font-weight: 600;

  transform: translateY(-3rem);
}

.error {
  color: #ffe66b;
}

@media (max-aspect-ratio: 4 / 3) {
  .tft-screen {
    width: 100vw;
    height: auto;
  }

  #vehicle-form {
    flex-wrap: wrap;
  }
}

.admin-bar {
  position: relative;
  z-index: 1000;

  width: 100%;
  padding: 12px 20px;

  background: #181818;
  color: #fff;

  font-family: "Poppins", Arial, sans-serif;
  font-size: 17px;
}

.admin-panel {
  width: min(100%, 1500px);
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-section-title {
  min-width: 90px;
  color: #f3a8bf;
  font-weight: 700;
  text-align: right;
}

.admin-row label {
  font-weight: 700;
}

.admin-row input {
  width: 220px;
  min-width: 180px;
  padding: 9px 12px;

  border: 1px solid #666;
  border-radius: 6px;

  background: #fff;
  color: #111;

  font: inherit;
}

#simulation-trip {
  width: 250px;
}

.admin-row select {
  padding: 9px 10px;

  border: 1px solid #666;
  border-radius: 6px;

  background: #fff;
  color: #111;

  font: inherit;
}

.admin-row button,
.admin-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 42px;
  padding: 9px 15px;

  border: 0;
  border-radius: 6px;

  background: var(--astuce-pink);
  color: #fff;

  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;

  cursor: pointer;
}

.admin-row button:hover,
.admin-row a:hover {
  background: var(--astuce-pink-dark);
}

#toggle-admin {
  margin-left: 14px;
  background: #444;
}

#toggle-admin:hover {
  background: #2f2f2f;
}

.admin-hidden .admin-bar {
  display: none;
}

.route-number {
  position: relative;
  height: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

#line-badge-fallback,
.line-badge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#line-badge-fallback {
  display: flex;
  align-items: center;
  justify-content: center;

  color: #fff;
  font-size: clamp(1.8rem, 3vw, 3.5rem);
  font-weight: 700;
}

.line-badge {
  display: none;
  object-fit: contain;
}

.line-badge {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.admin-hidden .admin-bar {
    display: none;
}

.admin-hidden {
    padding-top: 0;
}

.admin-hidden .tft-screen {
    height: 100vh;
    width: calc(100vh * 16 / 9);
    max-width: 100vw;
}

#vehicle-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#vehicle-form a,
#toggle-admin {
  margin-left: 8px;
}

.menu-separator {
  width: 1px;
  height: 32px;
  margin: 0 8px;
  background: #666;
}

#simulation-trip {
  width: 190px;
}

#simulation-speed {
  padding: 9px 10px;
  border: 1px solid #666;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font: inherit;
}

/* Véhicule réellement à l'arrêt :
   clignotement sec / radical */
.vehicle-stopped .timeline-stop.current .timeline-dot {
  animation: stop-flash 0.7s steps(1, end) infinite;
}

@keyframes stop-flash {
  0%,
  49% {
    background: var(--astuce-pink);
    border-color: var(--astuce-pink);
    box-shadow: inset 0 0 0 0.45rem #fff;
  }

  50%,
  100% {
    background: #fff;
    border-color: var(--astuce-pink);
    box-shadow: none;
  }
}

.vehicle-approaching .timeline-stop.current .timeline-dot {
  animation-name: approach-pulse;
  animation-duration: 2.2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-delay: var(--pulse-offset, 0ms);
}

@keyframes approach-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow:
      inset 0 0 0 0.45rem #fff,
      0 0 0 0 rgba(189, 0, 98, 0);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow:
      inset 0 0 0 0.45rem #fff,
      0 0 0 0.8rem rgba(189, 0, 98, 0.18);
  }
}

.route-title em {
  font-style: italic;
  font-weight: 400;
}

.admin-hint {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 1rem);

  z-index: 9999;

  padding: 1rem 1.6rem;
  border-radius: 0.7rem;

  background: rgba(20, 20, 20, 0.92);
  color: #fff;

  font-family: "Poppins", Arial, sans-serif;
  font-size: clamp(1rem, 1.3vw, 1.4rem);
  font-weight: 700;
  text-align: center;

  opacity: 0;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;

  pointer-events: none;
}

.admin-hint.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-warning {
  position: fixed;
  inset: 0;
  z-index: 20000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 2rem;

  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.mobile-warning-box {
  width: min(90vw, 520px);
  padding: 2rem;

  background: #fff;
  color: #111;

  border-radius: 1rem;

  font-family: "Poppins", Arial, sans-serif;
  text-align: center;

  box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.35);
}

.mobile-warning-box h2 {
  margin: 0 0 1rem;

  color: var(--astuce-pink);

  font-size: 2rem;
}

.mobile-warning-box p {
  margin: 0.8rem 0;

  font-size: 1.15rem;
  line-height: 1.35;
}

.mobile-warning-box button {
  margin-top: 1.3rem;

  padding: 0.8rem 1.5rem;

  border: 0;
  border-radius: 0.5rem;

  background: var(--astuce-pink);
  color: #fff;

  font: inherit;
  font-weight: 700;

  cursor: pointer;
}

.mobile-warning-box button:hover {
  background: var(--astuce-pink-dark);
}

.mobile-warning.hidden {
  display: none;
}

.timeline.at-departure-terminus
.timeline-stop.current
.timeline-time {
  visibility: hidden;
}

.destination-note {
  display: block;
  font-size: 0.5em;
  font-style: italic;
  font-weight: 400;
  line-height: 1;
  margin-top: 0.10em;
}

.next-stop-pmr {
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.25em;
  vertical-align: -0.05em;
  object-fit: contain;
}

.terminus-view {
  width: 100%;
  height: 100%;

  grid-row: 1 / -1;

  display: grid;
  grid-template-rows: 48% 52%;

  align-items: stretch;
}

.terminus-view[hidden] {
  display: none;
}

.terminus-departure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;

  color: var(--astuce-pink);

  font-size: clamp(2.2rem, 3.8vw, 4.5rem);
  font-weight: 700;
}

#terminus-departure-time {
  font: inherit;
}

.terminus-timeline {
  width: 100%;
  height: 100%;
  transform: translateY(-7.5rem);
}

.terminus-timeline::before {
  left: calc(
    var(--timeline-padding)
    + (
      (100% - 2 * var(--timeline-padding))
      / var(--stop-count)
      / 2
    )
  );
}

body.departure-terminus-mode
.next-stop-block,

body.departure-terminus-mode
#timeline:not(#terminus-timeline),

body.departure-terminus-mode
.bottom-message {
  display: none;
}

.end-of-trip-view {
  width: 100%;
  height: 100%;

  grid-row: 1 / -1;

  background: #fff;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 2.5rem;
}

.end-of-trip-view[hidden] {
  display: none;
}

.end-of-trip-logo {
    width: 650px;
    max-width: 75%;
    height: auto;
    object-fit: contain;
}

.end-of-trip-datetime {
  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 0.6rem;

  color: #222;
  text-align: center;
}

.end-of-trip-date {
  font-size: clamp(1.5rem, 2.2vw, 2.6rem);
  font-weight: 400;
}

.end-of-trip-time {
  font-size: clamp(2.8rem, 4.5vw, 5.2rem);
  font-weight: 400;
  line-height: 1;

  font-variant-numeric: tabular-nums;
}

.end-of-trip-unavailable {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;

    font-size: clamp(1.5rem, 2.2vw, 2.5rem);
    font-weight: 700;
    color: #111;
}

body.end-of-trip-mode
.topbar,

body.end-of-trip-mode
.next-stop-block,

body.end-of-trip-mode
#timeline,

body.end-of-trip-mode
.bottom-message,

body.end-of-trip-mode
#terminus-view {
  display: none;
}

body.end-of-trip-mode .tft-screen {
  grid-template-rows: 100%;
}

body.end-of-trip-mode .main-panel {
  grid-row: 1;
  height: 100%;
}