/**
 * Version mobile — téléphone & tablette
 */

:root {
  --mobile-nav-h: 4.25rem;
  --header-h: 3.5rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overflow-x: hidden;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

.legal-page {
  padding: max(1rem, var(--safe-top)) 0 max(2rem, var(--safe-bottom));
}

.legal-page .card {
  padding: 1.25rem;
}

@media (max-width: 768px) {
  .legal-page h1 {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  .legal-page .card {
    padding: 1rem;
  }

  .legal-page .card h2 {
    font-size: 1.05rem;
  }

  .legal-page ul {
    padding-left: 1.15rem;
  }
}

body.app-logged-in {
  padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 0.5rem);
}

/* Container plus étroit sur mobile */
@media (max-width: 768px) {
  :root {
    --container: min(100% - 1.25rem, 100vw);
  }

  .top-bar__locale {
    font-size: 0.72rem;
  }

  .top-bar__internal {
    font-size: 0.72rem;
  }

  /* Header compact + menu */
  .site-header__inner {
    padding: 0.5rem 0;
    gap: 0.5rem;
  }

  .site-header__logo {
    height: 32px;
  }

  .site-header__title {
    font-size: 0.8rem;
    padding-left: 0.65rem;
    border-left-width: 2px;
  }

  .site-header__brand .site-header__title br {
    display: none;
  }

  .site-header__brand .site-header__title::after {
    content: " CDM 2026";
    font-weight: 500;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--c-background);
    border-bottom: 1px solid var(--c-highlight-high);
    padding: 0.75rem 1rem 1rem;
    box-shadow: var(--shadow);
    gap: 0;
  }

  .site-nav--open {
    display: flex;
  }

  .site-nav a {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--c-muted);
    font-size: 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--c-highlight-high);
    border-radius: var(--radius);
    background: var(--c-muted);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--c-primary);
    flex-shrink: 0;
  }

  .header-user {
    width: 100%;
    order: 10;
    justify-content: space-between;
    padding-top: 0.5rem;
    border-top: 1px solid var(--c-muted);
  }

  .header-user #header-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55vw;
  }

  .site-header__inner {
    flex-wrap: wrap;
    position: relative;
  }

  .site-header__brand {
    flex: 1;
    min-width: 0;
  }

  /* Hero mobile */
  .hero {
    padding: 1.5rem 0 2rem;
  }

  .hero__visual {
    display: none;
  }

  .hero__grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 1.45rem;
    max-width: none;
  }

  .hero__tagline {
    font-size: 0.95rem;
  }

  .hero__hosts {
    font-size: 0.9rem;
  }

  .hero__cta {
    flex-direction: column;
  }

  .hero__cta .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .hero__ball,
  .hero__ball--1,
  .hero__ball--2 {
    display: none;
  }

  /* Sections */
  .section {
    padding: 1.5rem 0;
  }

  .section h2,
  .section-title {
    font-size: 1.25rem;
  }

  .section__intro {
    font-size: 0.9rem;
  }

  /* Auth plein écran */
  .auth-screen__inner {
    padding: 1rem 0 2rem;
    max-width: none;
  }

  .auth-card {
    padding: 1.25rem;
  }

  .auth-tab {
    min-height: 44px;
    font-size: 0.9rem;
  }

  input,
  select,
  .btn,
  .pool-tab,
  .match-card,
  .winner-pick__btn,
  .stepper__btn {
    min-height: 44px;
    font-size: 16px; /* évite zoom iOS sur focus */
  }

  .stepper__input {
    font-size: 1.25rem;
  }

  /* Étapes — scroll horizontal */
  .steps {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 0.35rem;
    padding: 0.5rem;
  }

  .steps__item {
    flex: 0 0 auto;
    min-width: auto;
    scroll-snap-align: start;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .steps__item .steps__num {
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.7rem;
  }

  /* Layout pronostic = une colonne */
  .pronostic-layout,
  .pronostic-layout--bet-open {
    grid-template-columns: 1fr !important;
  }

  .panel {
    padding: 1rem;
  }

  .panel--bet {
    position: fixed;
    left: var(--safe-left);
    right: var(--safe-right);
    bottom: calc(var(--mobile-nav-h) + var(--safe-bottom));
    max-height: 72vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 40;
    margin: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.2);
  }

  .panel--bet::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    background: var(--c-highlight);
    border-radius: 2px;
    margin: 0 auto 0.75rem;
  }

  /* Poules : styles détaillés dans pronos-app.css (mobile) */

  .match-grid {
    max-height: none;
    gap: 0.5rem;
  }

  .match-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.5rem;
    padding: 1rem;
    text-align: center;
  }

  .match-card__team {
    flex-direction: row;
    justify-content: center;
    gap: 0.5rem;
  }

  .match-card__team .team-row {
    flex-direction: row;
    font-size: 0.9rem;
  }

  .match-card__meta {
    order: -1;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed var(--c-highlight-high);
    font-size: 0.75rem;
  }

  .match-card__meta .match-card__vs {
    display: inline;
    margin: 0 0.35rem;
  }

  /* Face-à-face */
  .match-faceoff__teams {
    gap: 0.5rem;
  }

  .match-faceoff__team .team-row__name {
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.2;
  }

  .flag-img--lg {
    width: 48px;
    height: 36px;
  }

  .winner-pick__options {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .winner-pick__btn {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
    min-height: 52px;
  }

  .winner-pick__btn--draw {
    grid-column: 1;
    justify-content: center;
  }

  .stepper {
    max-width: 100%;
  }

  .stepper__btn {
    width: 3.25rem;
    min-height: 48px;
  }

  .btn--submit.btn--football {
    min-height: 52px;
    font-size: 1.05rem;
  }

  /* Scores 2 colonnes */
  .scores-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .scores-card {
    padding: 0.75rem 0.5rem;
  }

  .scores-card__value {
    font-size: 1.4rem;
  }

  .bet-card__predictions {
    grid-template-columns: 1fr;
  }

  .bet-card__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .bet-card__header time {
    margin-left: 0;
  }

  /* Toast au-dessus de la barre mobile */
  .toast {
    bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 1rem);
    max-width: calc(100vw - 2rem);
  }

  .site-footer {
    padding-bottom: calc(1.5rem + var(--safe-bottom));
  }

  body.app-logged-in .site-footer {
    padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 1rem);
  }

  body.mode-app #app-screen .section,
  body.mode-app main.section {
    padding-top: 1.25rem;
  }

  /* Barre du haut : une ligne sur petit écran */
  .top-bar__inner {
    justify-content: center;
    text-align: center;
    padding: 0.35rem 0;
  }

  .top-bar__internal {
    width: 100%;
    justify-content: center;
    font-size: 0.68rem;
  }

  /* Sous-navigation des pages app */
  .app-subnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
  }

  .app-subnav::-webkit-scrollbar {
    display: none;
  }

  .app-subnav__link {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    white-space: nowrap;
  }

  /* Choix du site (Moulin / Loraine / Atton) */
  .site-picker {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.85rem;
  }

  .site-picker__tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .site-picker__tab {
    min-height: 44px;
    padding: 0.5rem 0.35rem;
    font-size: 0.78rem;
    text-align: center;
    border-radius: var(--radius);
  }

  /* Classement */
  .classement-podium {
    grid-template-columns: 1fr;
    max-width: 18rem;
    gap: 0.65rem;
  }

  .podium-place--1 {
    order: 1;
    transform: none;
    padding-bottom: 1rem;
  }

  .podium-place--2,
  .podium-place--3 {
    order: unset;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.5rem 0.45rem;
    font-size: 0.8rem;
  }

  .leaderboard-table th:nth-child(5),
  .leaderboard-table th:nth-child(6),
  .leaderboard-table th:nth-child(7),
  .leaderboard-table td:nth-child(5),
  .leaderboard-table td:nth-child(6),
  .leaderboard-table td:nth-child(7) {
    display: none;
  }

  .leaderboard-table .prize-chip {
    max-width: 4.5rem;
    font-size: 0.65rem;
  }

  .classement-prizes-cta .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  /* Lots / cadeaux */
  .prizes-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .prize-card__visual img {
    max-height: 140px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }

  .prizes-hero {
    padding: 0 0.25rem;
  }

  /* Inscription / mot de passe affiché */
  .auth-success__password {
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    word-break: break-all;
  }

  .auth-success__actions .btn {
    width: 100%;
    min-height: 48px;
  }

  .auth-card .btn--primary,
  .auth-card .btn--secondary {
    width: 100%;
    min-height: 48px;
  }

  /* Compte / RGPD */
  .rgpd-actions .btn {
    width: 100%;
    min-height: 48px;
  }

  .account-readonly {
    font-size: 0.9rem;
  }

  /* Pied de page */
  .site-footer__inner {
    text-align: center;
    font-size: 0.85rem;
  }

  .section-title {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  /* Section pronostic : éviter débordement horizontal */
  #pronostic.section--pitch {
    overflow-x: hidden;
  }

  #pronostic .section__intro {
    font-size: 0.88rem;
    padding-inline: 0.15rem;
  }
}

@media (max-width: 380px) {
  .site-picker__tabs {
    grid-template-columns: 1fr;
  }

  .site-picker__tab {
    font-size: 0.85rem;
  }
}

/* Barre navigation basse (app) */
.menu-toggle {
  display: none;
}

.mobile-nav {
  display: none;
  position: fixed;
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: 0;
  z-index: 60;
  height: calc(var(--mobile-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--c-background);
  border-top: 1px solid var(--c-highlight-high);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
}

.mobile-nav--visible {
  display: grid;
}

.mobile-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.25rem;
  text-decoration: none;
  color: var(--c-accent);
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
}

.mobile-nav__item:active {
  background: var(--c-muted);
}

.mobile-nav__icon {
  font-size: 1.35rem;
  line-height: 1;
}

.mobile-nav__item--active {
  color: var(--c-primary);
  background: var(--c-pitch-pale);
}

/* Overlay quand panneau pronostic ouvert */
.bet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 35;
}

.bet-overlay--visible {
  display: block;
}

@media (min-width: 769px) {
  .mobile-nav,
  .bet-overlay {
    display: none !important;
  }

  body.app-logged-in {
    padding-bottom: 0;
  }

  .menu-toggle {
    display: none !important;
  }

  .site-nav {
    display: flex !important;
    position: static;
    flex-direction: row;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .panel--bet {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .panel--bet::before {
    display: none;
  }
}

/* Tablette */
@media (min-width: 769px) and (max-width: 959px) {
  .pronostic-layout--bet-open {
    grid-template-columns: 1fr 1fr !important;
  }

  .panel--profile {
    grid-column: 1 / -1;
  }
}
