/* Sonne : page de commande. Mobile d'abord, sobre, clair et sombre. */

:root {
  --fond: #faf8f5;
  --surface: #ffffff;
  --encre: #1d1a16;
  --encre-douce: #6b645b;
  --trait: #e7e1d8;
  --accent: #d9480f;
  --accent-fonce: #b23a0b;
  --accent-texte: #ffffff;
  --accent-doux: #fde8dc;
  /* Contrastes AA (4,5:1) : vert 6,1:1 sur blanc et 5,4:1 sur vert-doux. */
  --vert: #237032;
  --vert-doux: #e3f5e6;
  --gris: #8a8178;
  --rouge: #b02525;
  --rouge-doux: #fde2e2;
  --rayon: 18px;
  --ombre: 0 1px 2px rgb(29 26 22 / 6%), 0 4px 16px rgb(29 26 22 / 5%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #16130f;
    --surface: #211d18;
    --encre: #f3eee7;
    --encre-douce: #a89f94;
    --trait: #352f28;
    --accent: #f76707;
    --accent-fonce: #e8590c;
    --accent-texte: #1a0d04;
    --accent-doux: #3a2316;
    --vert: #51cf66;
    --vert-doux: #1d3322;
    --gris: #8a8178;
    --rouge: #ff6b6b;
    --rouge-doux: #3b1d1d;
    --ombre: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

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

/* En-tête */

.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.marque {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.marque img {
  border-radius: 8px;
}

.choix select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--encre);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: 999px;
  padding: 6px 30px 6px 14px;
  min-height: 44px;
  max-width: 55vw;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--encre-douce) 50%),
    linear-gradient(135deg, var(--encre-douce) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 4px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 16px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

.discret {
  color: var(--encre-douce);
  font-size: 0.9rem;
  margin: 0;
}

/* Écran vide */

.vide h1 {
  font-size: 1.6rem;
  margin: 18px 0 8px;
}

.vide p {
  color: var(--encre-douce);
  margin: 0 0 16px;
}

/* État du téléphone */

.tableau {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.etat-haut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.etat-haut h1 {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.pastille {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  background: var(--fond);
  color: var(--encre-douce);
  white-space: nowrap;
}

.pastille .point {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gris);
}

.pastille[data-etat="en-ligne"] {
  background: var(--vert-doux);
  color: var(--vert);
}

.pastille[data-etat="en-ligne"] .point {
  background: var(--vert);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--vert) 22%, transparent);
}

.pastille[data-etat="relais"] {
  background: var(--rouge-doux);
  color: var(--rouge);
}

.pastille[data-etat="relais"] .point {
  background: var(--rouge);
}

.pastille[data-etat="connexion"] .point {
  animation: clignote 1s ease-in-out infinite;
}

.mesures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
}

.mesures div {
  min-width: 0;
}

.mesures dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--encre-douce);
}

.mesures dd {
  margin: 2px 0 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.batterie {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: 0.8;
  flex: none;
}

.batterie::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 2.5px;
  width: 2px;
  height: 4px;
  background: currentColor;
  border-radius: 0 1px 1px 0;
}

.batterie-niveau {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 0;
  max-width: calc(100% - 2px);
  background: currentColor;
  border-radius: 1px;
}

.batterie-faible {
  color: var(--rouge);
}

.modele {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--encre-douce);
}

.modele:empty {
  display: none;
}

.indice {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--encre-douce);
}

/* Actions */

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0 0;
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sonner {
  width: min(64vw, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-texte);
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 30px rgb(217 72 15 / 30%), inset 0 -6px 0 rgb(0 0 0 / 12%);
  transition: transform 0.12s ease, background 0.2s ease;
}

.sonner:not(:disabled):hover {
  background: var(--accent-fonce);
}

.sonner:not(:disabled):active {
  transform: scale(0.97);
}

.sonner .cloche {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sonner[data-sonne="oui"] {
  animation: onde 1.4s ease-out infinite;
}

.sonner[data-sonne="oui"] .cloche {
  animation: balance 0.5s ease-in-out infinite alternate;
  transform-origin: 50% 15%;
}

.accuse {
  min-height: 1.5em;
  margin: 0;
  text-align: center;
  font-weight: 600;
  color: var(--encre-douce);
}

.accuse[data-genre="ok"] {
  color: var(--vert);
}

.accuse[data-genre="alerte"] {
  color: var(--rouge);
}

.arreter {
  width: min(100%, 320px);
  padding: 14px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--trait);
  background: var(--surface);
  color: var(--encre);
  font-weight: 600;
}

.arreter:not(:disabled):hover {
  border-color: var(--encre-douce);
}

/* Journal */

.journal h2 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.journal-liste {
  list-style: none;
  margin: 0;
  padding: 0;
}

.journal-liste li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--trait);
  font-size: 0.92rem;
}

.journal-liste li:first-child {
  border-top: none;
}

.journal-liste time {
  color: var(--encre-douce);
  font-variant-numeric: tabular-nums;
}

.journal-liste li[data-genre="ok"] span {
  color: var(--vert);
}

.journal-liste li[data-genre="alerte"] span {
  color: var(--rouge);
}

/* Gestion des téléphones et ajout */

.gestion summary {
  cursor: pointer;
  font-weight: 600;
  list-style-position: inside;
}

.gestion h3 {
  font-size: 0.95rem;
  margin: 18px 0 10px;
}

.liste-telephones {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.liste-telephones li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.liste-telephones .id {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: var(--encre-douce);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: -4px;
}

.form-ajout {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-ajout label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--encre-douce);
}

textarea,
input[type="text"] {
  font: inherit;
  color: var(--encre);
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 12px;
  padding: 10px 12px;
  width: 100%;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primaire {
  margin-top: 4px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: var(--encre);
  color: var(--fond);
  font-weight: 600;
}

.supprimer {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--trait);
  background: transparent;
  color: var(--rouge);
  font-size: 0.9rem;
}

.erreur {
  color: var(--rouge);
  margin: 0;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.erreur:empty {
  display: none;
}

.pied {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 16px max(20px, env(safe-area-inset-bottom));
  color: var(--encre-douce);
  font-size: 0.8rem;
  text-align: center;
}

.pied p {
  margin: 0;
}

/* Animations */

@keyframes clignote {
  50% {
    opacity: 0.3;
  }
}

@keyframes onde {
  0% {
    box-shadow: 0 0 0 0 rgb(217 72 15 / 45%), inset 0 -6px 0 rgb(0 0 0 / 12%);
  }
  100% {
    box-shadow: 0 0 0 28px rgb(217 72 15 / 0%), inset 0 -6px 0 rgb(0 0 0 / 12%);
  }
}

@keyframes balance {
  from {
    transform: rotate(-12deg);
  }
  to {
    transform: rotate(12deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
