/* Device Tracker - interface styles.
   Phone first: one main action per screen, large text, touch targets of at
   least 44px, high contrast. Visible text is Italian; everything else here
   is code and stays English. */

:root {
  --bg: #101418;
  --surface: #1a2027;
  --surface-high: #232c35;
  --border: #33414f;
  --text: #f2f5f8;
  --text-dim: #a9b6c3;
  --accent: #2f9e6b;
  --accent-dark: #247a53;
  --danger: #ff8a7a;
  --radius: 14px;
  --touch: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--text-dim); }
a:hover, a:focus { color: var(--text); }

.hidden { display: none !important; }

/* -- centred screens: sign in, invite, recovery ------------------------ */

.screen-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
}

h1 { font-size: 1.5rem; margin: 0 0 10px; }
.subtitle { color: var(--text-dim); margin: 0 0 22px; }
.help { color: var(--text-dim); font-size: 0.95rem; margin: 18px 0 0; text-align: center; }
.note { color: var(--text-dim); font-size: 0.85rem; margin: 10px 0 0; text-align: center; }

/* -- controls ---------------------------------------------------------- */

.btn-primary,
.btn-secondary {
  display: block;
  width: 100%;
  min-height: var(--touch);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #06120c; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); color: var(--text); }
.btn-primary:disabled { background: var(--surface-high); color: var(--text-dim); cursor: default; }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  margin-top: 12px;
  font-size: 1rem;
}
.btn-secondary:hover { background: var(--surface-high); }

:focus-visible { outline: 3px solid #7fd3ab; outline-offset: 2px; }

.field { display: block; margin-bottom: 18px; }
.field span { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 0.95rem; }
.field input, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-high);
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
}

.confirm {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 18px 0;
  color: var(--text-dim);
}
.confirm input { width: 22px; height: 22px; }

.phrase {
  background: var(--surface-high);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  word-spacing: 0.15em;
  text-align: center;
  overflow-wrap: anywhere;
}

.message { margin: 16px 0 0; min-height: 1.5em; text-align: center; }
.message.error { color: var(--danger); }

/* -- map screen -------------------------------------------------------- */

.screen-map { position: relative; overflow: hidden; }

#map { position: absolute; inset: 0; background: var(--bg); }

.bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}

.picker { display: block; margin-bottom: 12px; }
.picker span { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 0.9rem; }
.picker select {
  width: 100%;
  min-height: 48px;
  padding: 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface-high);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.status { margin: 0 0 12px; text-align: center; font-size: 1.05rem; }
.status.error { color: var(--danger); }

.progress {
  height: 6px;
  margin: 0 0 12px;
  background: var(--surface-high);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 1s linear;
}

.empty-panel {
  position: absolute;
  inset: 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: var(--bg);
}

.btn-signout {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  z-index: 1000;
  min-height: 44px;
  padding: 0 16px;
  font: inherit;
  color: var(--text);
  background: rgba(26, 32, 39, 0.92);
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
}

/* Leaflet on a dark background: keep the zoom and attribution boxes legible. */
.leaflet-container { background: #0b0e11; }
.leaflet-bar a, .leaflet-control-attribution {
  background: var(--surface);
  color: var(--text-dim);
  border-color: var(--border);
}
.leaflet-bar a { color: var(--text); }
.leaflet-control-attribution a { color: var(--text-dim); }

@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}
