/* SkyView — feuille de style principale */

@font-face {
  font-family: 'Outfit';
  src: url('../fonts/outfit-var-latin.woff2') format('woff2');
  font-weight: 300 600;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('../fonts/space-mono-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('../fonts/space-mono-700-latin.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #050a1a;
  --surface: rgba(14, 22, 44, 0.86);
  --surface-solid: #0e162c;
  --surface-raised: #16213f;
  --border: rgba(130, 160, 230, 0.22);
  --text: #e3e9f7;
  --text-muted: #93a0bd;
  --accent: #7cc4ff;
  --accent-strong: #4aa8f5;
  --accent-text: #04121f;
  --danger: #ff7a7a;
  --radius: 14px;
  --tap: 52px; /* cible tactile minimale (gants l'hiver) */
  --font-ui: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-data: 'Space Mono', ui-monospace, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

/* Palette nuit rouge (activée en Phase 5 via body.night) */
body.night {
  --bg: #000;
  --surface: rgba(20, 0, 0, 0.9);
  --surface-solid: #140000;
  --surface-raised: #200404;
  --border: rgba(200, 40, 40, 0.3);
  --text: #e04848;
  --text-muted: #9a2a2a;
  --accent: #ff4040;
  --accent-strong: #d22;
  --accent-text: #000;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body { overflow: hidden; overscroll-behavior: none; }

button, input, select { font: inherit; color: inherit; }

.mono { font-family: var(--font-data); font-size: 0.82rem; }
.muted { color: var(--text-muted); }

.app {
  position: fixed;
  inset: 0;
  height: 100dvh;
}

.sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* les gestes sont gérés en JS (pas de zoom navigateur) */
  cursor: grab;
  outline: none;
}
.sky:active { cursor: grabbing; }
.sky:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* --- Barres --- */
.topbar, .bottombar {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  pointer-events: none;
}
.topbar > *, .bottombar > * { pointer-events: auto; }
.topbar { top: 0; padding-top: calc(12px + var(--safe-top)); justify-content: space-between; }
.bottombar {
  bottom: 0;
  padding-bottom: calc(14px + var(--safe-bottom));
  justify-content: space-between;
  align-items: flex-end;
}

.info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 0;
}
.info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.actions { display: flex; gap: 10px; flex: none; }

/* Visibilité selon le mode */
body:not(.mode-ar) .only-ar { display: none; }
body.mode-ar .only-map { display: none; }
body:not(.ar-capable) .ar-only { display: none; }

/* --- Caméra (mode AR) --- */
.camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.camera[hidden] { display: none; }
body.mode-ar .sky { cursor: default; }

/* --- Boutons --- */
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#location-button .icon { fill: currentColor; stroke: none; }

.icon-button, .pill {
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.icon-button { width: var(--tap); padding: 0; }
.icon-button.big { width: 60px; min-height: 60px; }
.pill { gap: 8px; padding: 0 18px 0 14px; max-width: calc(100vw - 32px - var(--tap) - 12px); }
.pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.primary-button {
  width: 100%;
  min-height: var(--tap);
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}
.primary-button:disabled, .secondary-button:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-button {
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  font-weight: 500;
  cursor: pointer;
}
.secondary-button.wide { width: 100%; margin-top: 12px; }
.text-button {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.icon-button:active, .pill:active { background: var(--surface-raised); }
@media (hover: hover) {
  .icon-button:hover, .pill:hover { background: var(--surface-raised); }
  .primary-button:hover { background: var(--accent-strong); }
  .list-button:hover, .secondary-button:hover { background: var(--surface-raised); filter: brightness(1.15); }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Dialogues (panneaux) --- */
dialog.sheet {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  margin: auto;
  padding: 16px 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.sheet-head .icon-button { background: transparent; }
dialog.sheet p { margin: 8px 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 4px; }
.field input[type='search'], .field select {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
}
.field input[type='range'] { width: 100%; accent-color: var(--accent); min-height: 32px; }

.group { border: 0; padding: 0; margin: 12px 0 0; }
.group legend { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 4px; padding: 0; }
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.switch input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }

.list { list-style: none; margin: 4px 0 0; padding: 0; }
.list-button {
  width: 100%;
  min-height: var(--tap);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

/* --- Panneaux non modaux (le ciel reste visible) --- */
.panel {
  position: absolute;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(480px, calc(100vw - 32px));
  padding: 14px 16px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.panel[hidden] { display: none; }
.panel h2 { margin: 0 0 6px; font-size: 1.1rem; font-weight: 600; }
.panel p { margin: 0 0 10px; }
.panel-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 8px; }
.panel-actions .primary-button, .panel-actions .secondary-button { flex: 1; }

.banner, .toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  line-height: 1.35;
}
.banner { top: calc(78px + var(--safe-top)); }
.toast { bottom: calc(100px + var(--safe-bottom)); }
.banner[hidden], .toast[hidden] { display: none; }

/* --- États --- */
.loading, .boot-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 16px;
  text-align: center;
  pointer-events: none;
}
.loading { display: none; color: var(--text-muted); }
body.is-loading .loading { display: grid; }
body.is-loading .topbar, body.is-loading .bottombar { visibility: hidden; }
.boot-error { color: var(--danger); background: var(--bg); }
.boot-error[hidden] { display: none; }

@media (max-width: 420px) {
  .info { max-width: calc(100vw - 32px - 134px); }
  .info span { white-space: normal; }
  .icon-button.big { width: 56px; min-height: 56px; }
}

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