/* =========================================================
   RIDER MONTRÉAL — COUCHE APPLICATION (2026)
   ---------------------------------------------------------
   Couche 100 % visuelle, chargée en dernier sur toutes les
   pages, après style.css, identite.css, /api/theme.css,
   racing.css, brand-2026.css et premium-2026.css.

   Elle ajoute la grammaire « application mobile » :
   - barre d’onglets flottante en verre (5 destinations) ;
   - tableau de bord d’accueil (niveau, prochaine sortie) ;
   - cartes en verre, cibles tactiles de 44 px ;
   - carte plein écran et repères-avatars ;
   - respect des zones sûres iPhone/Android.

   Aucune structure existante n’est supprimée : les blocs
   d’origine restent dans la page et sont simplement masqués
   ou recomposés sous 900 px. Aucun style en ligne (la CSP du
   site interdit les attributs style).
   ========================================================= */

:root {
  --app-bar-h: 64px;
  --app-tab-h: 64px;
  --app-gap: 12px;
  --app-glass: rgba(11, 13, 18, 0.82);
  --app-glass-2: rgba(18, 21, 27, 0.9);
  --app-glass-line: rgba(255, 255, 255, 0.09);
  --app-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.95);
  --app-safe: env(safe-area-inset-bottom, 0px);
}

/* ---------- Barre d’actions de l’entête ---------- */

.app-head-actions {
  display: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.app-icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--app-glass-line);
  background: var(--app-glass-2);
  color: var(--steel, #c9cfd9);
  position: relative;
  text-decoration: none;
  transition: border-color 0.2s var(--ease-out, ease), color 0.2s var(--ease-out, ease);
}

.app-icon-btn:hover,
.app-icon-btn:focus-visible {
  border-color: rgba(255, 32, 46, 0.55);
  color: #fff;
}

.app-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-icon-btn--dot::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #ff202e);
  box-shadow: 0 0 8px rgba(255, 32, 46, 0.8);
}

/* ---------- Barre d’onglets flottante ---------- */

.app-tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--app-safe));
  transform: translateX(-50%);
  width: min(540px, calc(100% - 20px));
  display: none;
  align-items: stretch;
  justify-content: space-between;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 22px;
  border: 1px solid var(--app-glass-line);
  background: var(--app-glass);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 22px 50px -20px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  z-index: 900;
}

.app-tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0 4px;
  border-radius: 14px;
  color: #767d8b;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  position: relative;
  transition: color 0.18s var(--ease-out, ease);
  -webkit-tap-highlight-color: transparent;
}

.app-tab svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-tab span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-tab[aria-current='page'] {
  color: #fff;
}

.app-tab[aria-current='page'] svg {
  stroke: var(--accent, #ff202e);
  filter: drop-shadow(0 0 7px rgba(255, 32, 46, 0.65));
}

.app-tab[aria-current='page']::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  border-radius: 99px;
  background: var(--accent, #ff202e);
  box-shadow: 0 0 10px rgba(255, 32, 46, 0.9);
}

.app-tab:active {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- Tableau de bord d’accueil ---------- */

.app-home {
  display: none;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px 6px;
}

.app-greet {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.app-kicker {
  margin: 0 0 4px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted, #858b96);
}

.app-title {
  margin: 0;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: clamp(30px, 9vw, 40px);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: #fff;
  text-transform: uppercase;
}

.app-title em {
  font-style: normal;
  color: var(--accent, #ff202e);
}

.app-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #08090b;
  background: linear-gradient(150deg, #ff5c72, #b30f26);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-decoration: none;
  box-shadow: 0 10px 22px -12px rgba(255, 32, 46, 0.9);
}

.app-avatar--invite {
  background: linear-gradient(150deg, #2b3038, #12151b);
  color: #cfd5df;
}

.app-xp {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 32, 46, 0.24);
  background:
    radial-gradient(120% 150% at 100% 0%, rgba(255, 32, 46, 0.2), transparent 58%),
    linear-gradient(180deg, rgba(24, 27, 34, 0.95), rgba(11, 13, 18, 0.95));
  margin-bottom: var(--app-gap);
}

.app-xp[hidden] {
  display: none;
}

.app-xp__badge {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 17px;
  font-weight: 700;
  color: #ff8d9d;
  background: rgba(255, 32, 46, 0.12);
  border: 1px solid rgba(255, 32, 46, 0.36);
}

.app-xp__body {
  flex: 1 1 auto;
  min-width: 0;
}

.app-xp__label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #858b96);
}

.app-xp__label b {
  color: #e9edf4;
  font-weight: 600;
}

.app-xp__bar {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  -webkit-appearance: none;
  appearance: none;
}

.app-xp__bar::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

.app-xp__bar::-webkit-progress-value {
  border-radius: 99px;
  background: linear-gradient(90deg, #ff202e, #ff7a4d);
}

.app-xp__bar::-moz-progress-bar {
  border-radius: 99px;
  background: linear-gradient(90deg, #ff202e, #ff7a4d);
}

.app-actions {
  display: flex;
  gap: 9px;
  margin-bottom: var(--app-gap);
}

.app-cta {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--app-glass-line);
  background: var(--app-glass-2);
  color: #e8ecf3;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}

.app-cta svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-cta--primary {
  background: linear-gradient(180deg, #ff2b46, #c8102c);
  border-color: rgba(255, 120, 140, 0.45);
  color: #fff;
  box-shadow: 0 14px 26px -16px rgba(255, 32, 46, 0.95);
}

.app-cta:active {
  transform: translateY(1px);
}

.app-block {
  padding: 15px;
  border-radius: 20px;
  border: 1px solid var(--app-glass-line);
  background: linear-gradient(180deg, rgba(22, 25, 32, 0.92), rgba(11, 13, 18, 0.94));
  margin-bottom: var(--app-gap);
  box-shadow: var(--app-shadow);
}

.app-block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.app-block__head h2 {
  margin: 0;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #cfd5df;
  font-weight: 600;
}

.app-block__head a,
.app-block__head span {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #858b96);
  text-decoration: none;
}

.app-next {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.app-next__date {
  flex: 0 0 auto;
  width: 52px;
  padding: 8px 0;
  border-radius: 13px;
  text-align: center;
  background: rgba(255, 32, 46, 0.1);
  border: 1px solid rgba(255, 32, 46, 0.3);
}

.app-next__date b {
  display: block;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 20px;
  line-height: 1;
  color: #ff8d9d;
}

.app-next__date span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b96b78;
}

.app-next__body {
  flex: 1 1 auto;
  min-width: 0;
}

.app-next__body strong {
  display: block;
  font-size: 14.5px;
  line-height: 1.25;
  color: #f4f7fb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-next__body span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted, #858b96);
}

.app-next__chev {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #6f7683;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-empty a {
  color: #ff8d9d;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-avatar svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-empty {
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  color: var(--muted, #858b96);
  font-size: 12.5px;
  line-height: 1.5;
}

.app-stats {
  display: flex;
  gap: 8px;
}

.app-stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 11px 6px;
  border-radius: 14px;
  border: 1px solid var(--app-glass-line);
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
}

.app-stat b {
  display: block;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 22px;
  line-height: 1;
  color: #fff;
}

.app-stat span {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #858b96);
}

.app-riders {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-riders__stack {
  display: flex;
  align-items: center;
}

.app-riders__stack .avatar {
  width: 36px;
  height: 36px;
  margin-right: -10px;
  border: 2px solid #0b0d12;
}

.app-riders__more {
  font-size: 11.5px;
  color: var(--muted, #858b96);
}

.app-note {
  margin: 2px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted, #858b96);
  text-align: center;
}

/* =========================================================
   MOBILE — l’expérience application
   ========================================================= */

@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body.has-appnav {
    padding-bottom: calc(var(--app-tab-h) + 26px + var(--app-safe));
  }

  body.has-appnav .app-tabbar {
    display: flex;
  }

  body.has-appnav .app-head-actions {
    display: flex;
  }

  /* Entête compacte et collante */
  body.has-appnav .site-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 800;
    padding-top: 4px;
    padding-bottom: 4px;
    background: rgba(6, 7, 10, 0.86);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  body.has-appnav .header-inner {
    min-height: 52px;
    gap: 8px;
    padding-left: 14px;
    padding-right: 14px;
  }

  body.has-appnav .brand-text {
    font-size: 15px;
  }

  body.has-appnav .brand-logo {
    width: 28px;
    height: 28px;
  }

  body.has-appnav .nav-toggle {
    min-height: 40px;
    padding: 0 12px;
    font-size: 10px;
  }

  /* Le menu complet reste disponible, en panneau sous l’entête */
  body.has-appnav .site-nav {
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Accueil : le tableau de bord remplace le hero marketing */
  body.has-apphome .hero {
    display: none;
  }

  body.has-apphome .app-home {
    display: block;
  }

  /* Titres de page façon application */
  .page-head {
    padding-top: 18px;
    padding-bottom: 6px;
  }

  .page-head h1 {
    font-size: clamp(28px, 9vw, 38px);
    line-height: 0.98;
    letter-spacing: 0.01em;
  }

  .page-head p {
    font-size: 14px;
    line-height: 1.55;
  }

  .section {
    padding-top: 26px;
    padding-bottom: 18px;
  }

  .section-head {
    gap: 8px;
    margin-bottom: 14px;
  }

  .section-head h2 {
    font-size: clamp(22px, 7vw, 28px);
  }

  .eyebrow {
    font-size: 9.5px;
    letter-spacing: 0.18em;
  }

  /* Cartes en verre */
  .ride-card,
  .step,
  .panel,
  .cta-band {
    border-radius: 20px;
    border: 1px solid var(--app-glass-line);
    background: linear-gradient(180deg, rgba(22, 25, 32, 0.92), rgba(11, 13, 18, 0.94));
    box-shadow: var(--app-shadow);
  }

  .ride-card {
    padding: 14px;
  }

  .ride-card h3 {
    font-size: 17px;
    line-height: 1.2;
  }

  /* Cibles tactiles confortables */
  .btn {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .btn-small {
    min-height: 40px;
  }

  input,
  select,
  textarea {
    font-size: 16px; /* évite le zoom automatique iOS */
  }

  /* Carte plein écran */
  .carte-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .carte-frame {
    border-radius: 22px;
    overflow: hidden;
    height: calc(100vh - 210px);
    height: calc(100dvh - 210px);
    min-height: 380px;
    max-height: 720px;
  }

  .carte-map {
    height: 100% !important;
    min-height: 0;
  }

  .carte-tools {
    bottom: 14px;
    right: 14px;
  }

  .carte-legende {
    display: none;
  }

  .carte-list {
    border-radius: 22px;
    border: 1px solid var(--app-glass-line);
    background: var(--app-glass-2);
    padding: 16px;
  }

  .carte-sorties-grid {
    gap: 10px;
  }

  /* Carte bord à bord, comme une application de navigation */
  body[data-page='carte'] .carte-shell {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
    max-width: none;
  }

  body[data-page='carte'] .carte-head,
  body[data-page='carte'] .carte-note,
  body[data-page='carte'] .carte-list,
  body[data-page='carte'] .carte-sorties {
    margin-left: 16px;
    margin-right: 16px;
  }

  body[data-page='carte'] .carte-frame {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    -webkit-clip-path: none;
    clip-path: none;
  }

  body[data-page='carte'] .carte-hud {
    top: 12px;
    left: 12px;
    right: 12px;
    padding: 8px 12px;
    border-radius: 14px;
  }

  /* Pied de page allégé : la barre d’onglets porte la navigation */
  body.has-appnav .site-footer {
    padding-bottom: 18px;
  }

  body.has-appnav .footer-links {
    font-size: 12px;
  }

  .toast {
    bottom: calc(var(--app-tab-h) + 28px + var(--app-safe));
    left: 14px;
    right: 14px;
    text-align: center;
  }
}

/* ---------- Très petits écrans ---------- */

@media (max-width: 400px) {
  .app-tab {
    font-size: 8.5px;
  }

  .app-tab svg {
    width: 19px;
    height: 19px;
  }

  .app-cta {
    font-size: 13px;
    min-height: 46px;
  }

  .app-title {
    font-size: 27px;
  }
}

/* ---------- Tablette : barre visible, contenu plus large ---------- */

@media (min-width: 641px) and (max-width: 900px) {
  .app-home {
    padding-top: 18px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .carte-frame {
    height: calc(100dvh - 230px);
  }
}

/* ---------- Bureau : la barre d’onglets disparaît ---------- */

@media (min-width: 901px) {
  .app-tabbar,
  .app-head-actions,
  .app-home {
    display: none !important;
  }
}

/* ---------- Repères-avatars sur la carte ---------- */

.carte-pin__label {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  font-family: var(--font-display, 'Barlow Condensed', sans-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #08090b;
  background: linear-gradient(150deg, #fff, #c9cfd9);
}

.carte-pin.carte-pin--avatar {
  width: 32px;
  height: 32px;
  padding: 2px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #0b0d12;
  -webkit-clip-path: none;
  clip-path: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(255, 32, 46, 0.18);
}

.carte-marker .carte-pin--avatar svg {
  display: none;
}

.carte-pin--avatar.carte-pin--actif {
  border-color: var(--accent, #ff202e);
  box-shadow: 0 0 0 6px rgba(255, 32, 46, 0.28), 0 8px 20px rgba(0, 0, 0, 0.7);
}

/* ---------- Accessibilité ---------- */

@media (prefers-reduced-motion: reduce) {
  .app-tab,
  .app-icon-btn,
  .app-cta {
    transition: none;
  }
}
