/* Appli Maison : thème sombre. Variante A (1024 px et plus), variante C en dessous. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/polices/inter-latin.woff2") format("woff2");
}

:root {
  --fond: #101317;
  --carte: #1A1F26;
  --carte-2: #232A33;
  --bord: #2A313B;
  --texte: #F2F4F6;
  --texte-2: #9AA4B2;
  --texte-3: #C9D1DB;
  --accent: #F5A524;
  --accent-texte: #1A1205;
  --danger: #F0716A;
  --rayon: 20px;
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

[hidden] { display: none !important; }

h1 { font-size: 28px; font-weight: 600; margin: 0 0 8px; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 20px 0 8px; color: var(--texte-3); }
b { font-weight: 600; }
a { color: var(--accent); }

.secondaire { color: var(--texte-2); }
.petit { font-size: 14px; }
.erreur-texte { color: var(--danger); min-height: 1.4em; margin: 8px 0; }
.chargement { color: var(--texte-2); text-align: center; padding: 40vh 16px 0; margin: 0; }
.etiquette {
  font-size: 14px; color: var(--texte-2); text-transform: uppercase; letter-spacing: 1px;
  display: flex; align-items: center; gap: 6px;
}

/* ---------- icônes ---------- */
.icone { display: inline-flex; width: 24px; height: 24px; flex: none; }
.icone svg { width: 100%; height: 100%; }
.icone .gris { stroke: var(--texte-3); }
.icone-petite { width: 20px; height: 20px; }
.icone-meteo { width: 64px; height: 64px; color: var(--accent); }
.icone-geante { width: 96px; height: 96px; color: var(--accent); }

/* ---------- boutons et champs (cibles de 44 px au moins) ---------- */
.bouton {
  min-height: 48px; padding: 10px 18px; border-radius: 14px;
  border: 1px solid var(--bord); background: var(--carte-2); color: var(--texte);
  font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.bouton:disabled, button:disabled { opacity: .45; cursor: default; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); font-weight: 600; }
.bouton.danger { color: var(--danger); }
.bouton.grand { min-height: 56px; font-size: 18px; padding: 12px 24px; width: 100%; }
.bouton.carre { width: 52px; height: 52px; padding: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.champ {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--bord); background: var(--fond); color: var(--texte); font: inherit;
}
.formulaire { display: flex; flex-direction: column; gap: 8px; }
.formulaire label { color: var(--texte-2); font-size: 14px; margin-top: 6px; }
.rangee { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.lien { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- cartes ---------- */
.carte { background: var(--carte); border-radius: var(--rayon); padding: 20px; }

.vue { padding: 16px; }
body.avec-nav .vue { padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }

/* ---------- accueil : téléphone (variante C) ---------- */
.accueil { display: flex; flex-direction: column; gap: 14px; }
.col-gauche { display: flex; flex-direction: column; gap: 14px; }
.horloge { display: none; }
.zone-meteo, .zone-maison { display: contents; }

.meteo { display: flex; flex-direction: column; gap: 14px; }
.meteo-tete { display: flex; align-items: center; gap: 14px; }
.meteo-temp { font-size: 40px; font-weight: 600; line-height: 1; }
.meteo .icone-meteo { width: 48px; height: 48px; }
.meteo-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 14px; color: var(--texte-3); }
.meteo-details b { color: var(--texte); }
.meteo-heures, .meteo-jours {
  display: grid; gap: 4px; text-align: center; font-size: 13px; color: var(--texte-2);
  border-top: 1px solid var(--bord); padding-top: 12px;
}
.meteo-heures { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.meteo-jours { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.meteo-heures > div, .meteo-jours > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.meteo-heures b, .meteo-jours b { color: var(--texte); font-size: 16px; }
.meteo-jours small { color: var(--texte-2); font-weight: 400; font-size: 13px; }
.meteo-jours .pluie { color: #7FB8E6; }

.maison { display: flex; flex-direction: column; gap: 12px; }
.maison-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.maison-ligne p { margin: 0; }
.maison-temp { font-size: 34px; font-weight: 600; line-height: 1.1; }
.boutons-consigne { display: flex; gap: 8px; }
.pastilles { display: flex; gap: 8px; flex-wrap: wrap; }
.pastille { background: var(--carte-2); border-radius: 10px; padding: 8px 12px; font-size: 14px; color: var(--texte-3); }

.actions { display: flex; flex-direction: column; gap: 12px; }
.actions:empty { display: none; }
.bouton-portail {
  width: 100%; min-height: 64px; border-radius: var(--rayon); border: 1px solid var(--bord);
  background: var(--carte); color: var(--texte); font: inherit; font-size: 19px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 12px; cursor: pointer;
}
.bouton-portail .icone { color: var(--accent); width: 28px; height: 28px; }

.col-cameras { display: flex; flex-direction: column; gap: 10px; }
.titre-cameras { padding: 4px 4px 0; }
.grille-cameras { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.camera {
  position: relative; overflow: hidden; border-radius: 14px; border: 0; padding: 0;
  background: var(--carte-2); color: var(--texte); font: inherit; text-align: left;
  aspect-ratio: 4 / 3; cursor: pointer; display: block; width: 100%;
}
div.camera { cursor: default; }
.camera-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera:not(.injoignable)::after {
  content: ""; position: absolute; inset: 45% 0 0 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
}
.camera-nom, .camera-info { position: absolute; left: 10px; z-index: 1; text-shadow: 0 1px 2px #000; }
.camera-nom { bottom: 26px; font-weight: 600; font-size: 15px; }
.camera-info { bottom: 8px; font-size: 12px; color: var(--texte-3); }
.camera.injoignable .camera-image, .camera.sans-image .camera-image { display: none; }
.camera.injoignable .camera-info { color: var(--danger); }

/* enfants (tablette) */
.enfants { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.bouton-enfant {
  min-height: 120px; border-radius: var(--rayon); border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-texte); font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.enfant-nom { font-size: 30px; font-weight: 700; }
.enfant-action { font-size: 18px; font-weight: 600; }

/* invité */
.invite { display: flex; flex-direction: column; gap: 16px; max-width: 520px; margin: 0 auto; }
.piscine-lignes { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.piscine-ligne { display: flex; justify-content: space-between; font-size: 20px; }

/* ---------- navigation du bas (téléphone) ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: rgba(16, 19, 23, .96); border-top: 1px solid var(--bord);
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
}
.onglet {
  flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--texte-2); text-decoration: none; font: inherit; font-size: 13px;
  background: none; border: 0; cursor: pointer;
}
.onglet[aria-current="page"] { color: var(--accent); }

/* ---------- feuille du portail ---------- */
.feuille { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.feuille-fond { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.feuille-boite {
  position: relative; width: 100%; max-width: 520px; background: var(--carte);
  border-radius: 24px 24px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--bord);
}
.feuille-boite h2 { font-size: 24px; }
.feuille-etat { color: var(--texte-2); min-height: 1.4em; }
.feuille-boutons { display: flex; gap: 12px; margin-top: 16px; }

/* ---------- plein écran : caméra, « Je suis rentré » ---------- */
.plein-ecran {
  position: fixed; inset: 0; z-index: 30; background: var(--fond);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.plein-ecran-boite { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.camera-vue { align-items: stretch; text-align: left; }
.camera-vue-tete { display: flex; justify-content: space-between; align-items: center; }
.camera-vue-tete h2 { margin: 0; }
.camera-grande { width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; border-radius: 14px; background: var(--carte-2); min-height: 200px; }
.rentre h2 { font-size: 30px; }
.grand-texte { font-size: 22px; color: var(--texte-3); margin: 0; }
.apercu-cadre { position: relative; width: 100%; max-width: 720px; }
.apercu { width: 100%; border-radius: 20px; background: var(--carte-2); transform: scaleX(-1); aspect-ratio: 16 / 9; object-fit: cover; }
.decompte {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 140px; font-weight: 700; color: var(--accent); text-shadow: 0 2px 12px #000;
}
.rentre .bouton.grand { max-width: 360px; }

/* ---------- connexion ---------- */
.ecran-centre {
  max-width: 420px; margin: 0 auto; padding-top: 12vh;
  display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: stretch;
}
.ecran-centre .lien { align-self: center; }
.logo { align-self: center; width: 72px; height: 72px; border-radius: 20px; background: var(--carte); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.logo .icone { width: 40px; height: 40px; }
.ecran-centre .formulaire { text-align: left; }

/* ---------- réglages ---------- */
.reglages { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.reglage .bouton { margin-top: 8px; }
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.liste li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--bord); min-height: 56px; }
.liste li .bouton { margin-top: 0; }
.cases { display: flex; flex-wrap: wrap; gap: 8px; }
.case, .jour {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px;
  border-radius: 12px; background: var(--carte-2); cursor: pointer;
}
.case input, .jour input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.jour { padding: 6px 8px; gap: 4px; min-width: 44px; justify-content: center; }
.creneaux { display: flex; flex-direction: column; gap: 10px; }
.creneau { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--bord); border-radius: 14px; }
.creneau .jours { display: flex; flex-wrap: wrap; gap: 4px; }
.creneau .heures { display: flex; align-items: center; gap: 6px; color: var(--texte-2); }
.heure-champ { width: auto; }
.pied { display: flex; justify-content: flex-end; margin-top: 12px; }
.resultat { margin-top: 8px; }
.resultat .champ { font-size: 14px; }

/* ---------- bandeau et messages ---------- */
.bandeau {
  position: sticky; top: 0; z-index: 50; text-align: center; padding: 8px;
  background: #5A4310; color: var(--texte); font-weight: 600;
}
.message {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); z-index: 60; max-width: calc(100% - 32px);
  background: var(--carte-2); color: var(--texte); border: 1px solid var(--bord);
  border-radius: 14px; padding: 12px 18px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.message.visible { opacity: 1; transform: translate(-50%, 0); }
.message.erreur { border-color: var(--danger); }

/* ---------- tablette et grand écran (variante A) ---------- */
@media (min-width: 1024px) {
  .vue { padding: 28px; }
  .accueil {
    display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 24px;
    height: calc(100dvh - 56px);
  }
  .col-gauche { gap: 20px; overflow-y: auto; min-height: 0; }
  .horloge { display: flex; justify-content: space-between; align-items: baseline; }
  .horloge .heure { font-size: 56px; font-weight: 600; letter-spacing: -1px; line-height: 1; }
  .horloge .date { font-size: 18px; color: var(--texte-2); }
  .carte { padding: 24px; }
  .meteo-temp { font-size: 64px; }
  .meteo .icone-meteo { width: 64px; height: 64px; }
  .meteo-details { font-size: 15px; }
  .maison-temp { font-size: 44px; }
  .col-cameras { min-height: 0; }
  .titre-cameras { display: none; }
  .grille-cameras { flex: 1; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 16px; min-height: 0; }
  .camera { aspect-ratio: auto; border-radius: var(--rayon); height: 100%; }
  .camera-nom { left: 16px; bottom: 34px; font-size: 18px; }
  .camera-info { left: 16px; bottom: 12px; font-size: 14px; }
  .nav { left: auto; right: 24px; bottom: 16px; border: 1px solid var(--bord); border-radius: 18px; padding: 4px; gap: 4px; }
  .onglet { flex: none; width: 96px; }
  body.avec-nav .vue { padding-bottom: 28px; }
  body.avec-nav .accueil { height: calc(100dvh - 56px); }
  body.avec-nav .col-cameras { padding-bottom: calc(var(--nav-h) + 16px); }
  .message { bottom: 24px; }
  .feuille { align-items: center; }
  .feuille-boite { border-radius: 24px; border: 1px solid var(--bord); }
}

@media (prefers-reduced-motion: reduce) {
  .message { transition: none; }
}

/* tablette du mur : tout doit tenir sans défiler (boutons des enfants toujours visibles) */
@media (min-width: 1024px) {
  body.tablette .meteo-heures { display: none; }
  body.tablette .col-gauche { gap: 16px; }
  body.tablette .carte { padding: 20px; }
  body.tablette .bouton-portail { min-height: 60px; }
  body.tablette .bouton-enfant { min-height: 96px; }
}

/* avec la barre de navigation, le portail y est déjà : pas de second bouton */
body.avec-nav .zone-portail { display: none; }
