/* Thème sombre, comme l'appli Android (Material 3 sombre, couleurs du boîtier). */
:root {
  --case: #101010;
  --surface: #121212;
  --surface-high: #2b2930;
  --on-surface: #e6e1e5;
  --on-surface-variant: #cac4d0;
  --outline: #938f99;
  --primary: #e2bd3a;
  --alert: #d68647;
  --selected: #2e3b4a;
  --font: Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--case);
  color: var(--on-surface);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  /* Pas de zoom au double toucher (iPhone) : deux appuis rapides sur un bouton zoomaient la
     page, qui ne répondait plus normalement. */
  touch-action: manipulation;
}

.page {
  position: fixed;
  inset: 0;
}

.page[hidden] { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------- Écran de chargement */

.splash {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--case);
  transition: opacity 0.35s ease-out;
}

.splash.done {
  opacity: 0;
  pointer-events: none;
}

.splash-icon {
  width: 120px;
  height: 120px;
}

/* Les trois tirets clignotent comme l'afficheur pendant un son. */
.splash-dash { animation: splash-blink 1.2s infinite; }
.splash-dash:nth-of-type(3) { animation-delay: 0.15s; }
.splash-dash:nth-of-type(4) { animation-delay: 0.3s; }

@keyframes splash-blink {
  0%, 60% { opacity: 1; }
  70%, 90% { opacity: 0.15; }
  100% { opacity: 1; }
}

.splash-name {
  color: #dcdcdc;
  font: 700 18px var(--font);
  letter-spacing: 0.3em;
  padding-left: 0.3em; /* compense l'espacement après la dernière lettre */
}

@media (prefers-reduced-motion: reduce) {
  .splash-dash { animation: none; }
}

/* ------------------------------------------------------------- Le boîtier */

.scanner {
  overflow: hidden;
  background: var(--case);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* Pas de zoom, de défilement, de sélection ni de loupe sur le boîtier (touche TIP maintenue). */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.scanner canvas,
.scanner button {
  position: absolute;
  display: block;
}

.scanner-key {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12%;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.scanner-key:focus-visible,
.scanner-gear:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -6px;
}

/* iPhone : interrupteur natif presque transparent sur chaque touche, pour la vibration
   (ui/haptics.js). Agrandi pour couvrir toute la touche. */
.scanner .haptic-switch {
  position: absolute;
  overflow: hidden;
  border-radius: 12%;
  opacity: 0.011;
  touch-action: none;
}

.scanner .haptic-switch[hidden] { display: none; }

.haptic-switch input {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  outline: none;
  transform: scale(8);
}

.scanner-gear {
  /* Taille nulle tant que l'appli ne l'a pas placé (sinon l'icône remplit tout l'écran). */
  width: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0; /* réglé par le placement (ui/scanner.js), à l'échelle du boîtier */
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #707070;
  cursor: pointer;
}

.scanner-gear:active { background: rgba(255, 255, 255, 0.2); }

.scanner-gear svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* ------------------------------------------------------------- Pages (réglages, journal) */

.sheet {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 0 4px;
  flex: none;
}

.toolbar-back {
  width: 48px;
  height: 48px;
  padding: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface);
  cursor: pointer;
  flex: none;
}

.toolbar-back:active { background: rgba(255, 255, 255, 0.12); }

.toolbar-back svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.toolbar-titles { min-width: 0; padding-left: 8px; }

.toolbar-title {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
}

.toolbar-subtitle {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--alert);
}

.page-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}

.page-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 24px;
}

.section {
  margin: 24px 0 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--primary);
}

.body {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.setting { margin-top: 12px; }

.setting-label {
  display: block;
  font-size: 16px;
}

input[type="range"] {
  width: 100%;
  height: 36px;
  margin: 4px 0 0;
  accent-color: var(--primary);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  margin-top: 8px;
  font-size: 16px;
  cursor: pointer;
}

.indented { margin-left: 16px; }

.disabled { opacity: 0.38; }

/* Interrupteur façon Material 3. */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border: 2px solid var(--outline);
  border-radius: 16px;
  background: #36343b;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.switch::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--outline);
  transition: all 0.15s;
}

.switch:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.switch:checked::before {
  top: 2px;
  left: 22px;
  width: 24px;
  height: 24px;
  background: #000;
}

.switch:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.outlined-button {
  min-height: 40px;
  margin-top: 16px;
  padding: 0 24px;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font: 500 14px var(--font);
  cursor: pointer;
}

.outlined-button:active { background: rgba(226, 189, 58, 0.12); }

.reset-done {
  display: inline-block;
  margin-left: 16px;
  font-size: 14px;
  color: var(--on-surface-variant);
  transition: opacity 0.3s;
}

.reset-done:empty { opacity: 0; }

.credits { margin-top: 12px; }

.credits-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 0.3em; /* l'espace après « Créé par » disparaît dans une boîte flex */
  white-space: normal;
}

.credits-image { display: block; }

.credits-email .credits-image { cursor: pointer; }

.credits-email { color: var(--primary); }

.quiet-link {
  display: block;
  min-height: 48px;
  margin-top: 16px;
  padding: 0 16px 0 0;
  border: 0;
  background: transparent;
  color: var(--on-surface-variant);
  font: 12px var(--font);
  cursor: pointer;
}

.app-version {
  margin: 0;
  font-size: 12px;
  color: var(--on-surface-variant);
}

/* ------------------------------------------------------------- Journal du voleur */

.log-map {
  position: relative;
  flex: none;
  margin: 0 8px;
}

.log-map canvas {
  display: block;
  touch-action: none;
}

.log-summary,
.log-hint {
  margin: 8px 20px 0;
  font-size: 14px;
  line-height: 1.45;
  flex: none;
}

.log-hint {
  margin-top: 0;
  margin-bottom: 4px;
  color: var(--on-surface-variant);
}

.log-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px calc(16px + env(safe-area-inset-bottom));
}

.log-row {
  display: flex;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.log-row:active { background: rgba(255, 255, 255, 0.08); }
.log-row.selected { background: var(--selected); }

.log-number {
  width: 40px;
  flex: none;
  font-size: 14px;
  color: var(--on-surface-variant);
}

.log-main { min-width: 0; }

.log-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.log-square {
  font: bold 16px ui-monospace, "Roboto Mono", "Cascadia Mono", Consolas, monospace;
}

.log-place {
  font-size: 14px;
  color: var(--on-surface-variant);
}

.log-event {
  display: block;
  font-size: 14px;
}

.event-start { color: var(--primary); }
.event-alert { color: var(--alert); }

/* ------------------------------------------------------------- Boîtes de dialogue */

.dialog {
  width: calc(100% - 48px);
  max-width: 560px;
  padding: 24px;
  border: 0;
  border-radius: 28px;
  background: var(--surface-high);
  color: var(--on-surface);
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

.dialog-title {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 400;
}

.dialog-message {
  font-size: 14px;
  line-height: 1.45;
  color: var(--on-surface-variant);
  white-space: pre-wrap;
}

.dialog-long .dialog-message {
  max-height: 60vh;
  overflow-y: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.text-button {
  padding: 10px 12px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font: 500 14px var(--font);
  cursor: pointer;
}

.text-button:active { background: rgba(226, 189, 58, 0.12); }
