/* ============================================================
   ASPHALT BLADING CLUB — thème rétro "terminal" (années 80-90)
   Fond noir, typo monospace, vert phosphore + rouge du club.
   Disposition : logo en haut, liste à gauche, carte à droite.
   Sur téléphone, la carte passe au-dessus de la liste.
   ============================================================ */
:root {
  --bg: #000000;
  --surface: #0a0b0a;
  --surface-2: #111311;
  --ink: #e8e5d8;        /* blanc cassé, comme un vieux moniteur */
  --muted: #7d837a;
  --line: #262a26;
  --line-hi: #3a403a;
  --phos: #ffffff;       /* blanc (anciennement vert phosphore) */
  --phos-dim: #8a8a8a;
  --amber: #ffb000;      /* ambre des terminaux */
  --accent: #ff2e3a;     /* rouge du club */
  --accent-ink: #000000;
  --on-bust: #000000;
  --b1: #3dff8b;
  --b2: #b6f23a;
  --b3: #ffd02e;
  --b4: #ff8a2e;
  --b5: #ff2e3a;
  --glow: 0 0 6px rgba(255, 255, 255, .3);
  --display: "VT323", "IBM Plex Mono", ui-monospace, monospace;
  --font: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Un élément masqué (attribut hidden) reste masqué, même si sa classe lui donne un display */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5;
  display: flex; flex-direction: column; padding: 0 16px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px dashed var(--phos); outline-offset: 2px; }
::selection { background: var(--phos); color: #000; }

/* Lignes de balayage + vignettage de l'écran cathodique */
.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 5000;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,.028) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,.45) 100%);
}

/* Barre de défilement façon terminal */
* { scrollbar-width: thin; scrollbar-color: var(--phos-dim) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--phos-dim); }
::-webkit-scrollbar-track { background: transparent; }

/* ====== EN-TÊTE ====== */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-bottom: 2px solid var(--line); flex: none; position: relative;
}
.top::after { /* fine ligne verte sous le trait gris */
  content: ""; position: absolute; left: 0; bottom: -2px; width: 120px; height: 2px; background: var(--phos); box-shadow: var(--glow);
}
.brand { display: block; line-height: 0; }
.logo { height: 50px; width: auto; display: block; filter: invert(1); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* ====== BOUTONS ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--accent);
  padding: 4px 14px 3px; border-radius: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  font-family: var(--display); font-size: 21px; line-height: 1.1; letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--line-hi);
  transition: transform .06s steps(1), box-shadow .06s steps(1);
}
.btn:hover { background: #ff4a54; border-color: #ff4a54; }
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
/* Bouton "Submit a spot" : style de la première version */
#addBtn {
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; font-weight: 700; line-height: 1.45;
  letter-spacing: normal; text-transform: none; padding: 9px 14px; border-radius: 2px; border: 1px solid #ff2d3a;
  background: #ff2d3a; color: #ffffff; box-shadow: none; transform: none;
}
#addBtn:hover { background: #ff2d3a; border-color: #ff2d3a; filter: brightness(1.08); }
#addBtn:active { transform: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-hi); box-shadow: none; }
.btn.ghost:hover { border-color: var(--phos); color: var(--phos); text-shadow: var(--glow); }
.btn.ghost.on { background: var(--phos); color: #000; border-color: var(--phos); text-shadow: none; }
.btn.danger { background: transparent; color: var(--accent); border-color: var(--accent); box-shadow: none; }
.btn.danger:hover { background: var(--accent); color: #000; }

/* ====== DISPOSITION ====== */
.main { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; padding: 16px 0 10px; }
.panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 4px; }
.filters { display: grid; gap: 8px; }
.filters .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .btn { width: 100%; }

/* ====== CHAMPS ====== */
input[type="search"], input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; background: #000; border: 1px solid var(--line-hi); border-radius: 0; padding: 9px 10px; min-width: 0;
  color: var(--phos); caret-color: var(--phos); font-family: var(--font); font-size: 14px;
}
input::placeholder, textarea::placeholder { color: var(--phos-dim); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--phos); box-shadow: 0 0 0 1px var(--phos), var(--glow); }
#q { padding-left: 30px; background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='14'%3E%3Ctext x='0' y='12' font-family='monospace' font-size='14' fill='%23ffffff'%3E%3E%3C/text%3E%3C/svg%3E") no-repeat 11px 50%; }
select { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23ffffff'/%3E%3C/svg%3E") no-repeat right 10px center; }
select option { background: #000; color: var(--ink); }
textarea { resize: vertical; min-height: 110px; }
input[type="file"] { font-size: 13px; color: var(--muted); }
input[type="file"]::file-selector-button {
  font-family: var(--display); font-size: 19px; text-transform: uppercase; letter-spacing: .04em;
  background: transparent; color: var(--phos); border: 1px solid var(--phos); padding: 2px 12px; margin-right: 10px; cursor: pointer;
}

/* Compteur façon invite de commande, avec curseur clignotant */
.count {
  font-family: var(--display); font-size: 20px; color: var(--phos); margin: 0; letter-spacing: .04em; text-transform: uppercase;
  text-shadow: var(--glow);
}
.count::before { content: "C:\\SPOTS> "; color: var(--phos-dim); text-shadow: none; }
.count::after { content: "█"; margin-left: 4px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ====== LISTE DES SPOTS ====== */
.list { display: grid; gap: 8px; align-content: start; }
.card {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 10px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 0; cursor: pointer;
  color: var(--ink);
}
.card:hover { border-color: var(--line-hi); border-left-color: var(--phos); background: var(--surface-2); }
.card.on { border-color: var(--phos); border-left-color: var(--phos); background: var(--surface-2); }
.thumb {
  width: 76px; height: 76px; object-fit: cover; background: #000; border: 1px solid var(--line);
  display: grid; place-items: center; font-family: var(--display); font-size: 40px; color: var(--phos); text-shadow: var(--glow);
  filter: saturate(.85) contrast(1.05);
}
.card h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1; letter-spacing: .02em; text-transform: uppercase; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { font-family: var(--display); font-size: 17px; line-height: 1.1; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--line-hi); padding: 0 6px; color: var(--ink); }
.bustchip { font-family: var(--display); font-size: 17px; line-height: 1.1; color: var(--on-bust); padding: 0 7px; letter-spacing: .05em; }
.bustchip.pend { background: var(--accent); color: var(--accent-ink); animation: blink 1.2s steps(1) infinite; }
.coords { font-size: 11px; color: var(--muted); margin: 6px 0 0; letter-spacing: .03em; }
.empty { border: 1px dashed var(--line-hi); padding: 20px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--amber); font-family: var(--display); font-weight: 400; font-size: 26px; text-transform: uppercase; margin-bottom: 4px; }

/* ====== CARTE ====== */
.mapbox { position: relative; border: 1px solid var(--line-hi); background: #000; overflow: hidden; min-height: 300px; min-width: 0; display: flex; flex-direction: column; }
.maphead {
  flex: none; display: flex; justify-content: space-between; gap: 10px; padding: 2px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--line-hi); font-family: var(--display); font-size: 17px; color: var(--muted); letter-spacing: .06em;
}
.maphead span:first-child { color: var(--phos); }
#map { position: relative; flex: 1; min-height: 0; z-index: 0; background: #dddbd5; }
#map.place { cursor: crosshair; }
/* Fond OpenStreetMap gardé en couleurs claires d'origine */
.leaflet-container { background: #dddbd5; font-family: var(--font); }
.leaflet-bar { border: 1px solid var(--line-hi) !important; border-radius: 0 !important; box-shadow: none !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: #000; color: var(--phos); border-bottom-color: var(--line-hi); border-radius: 0 !important;
  font-family: var(--display); font-size: 22px; line-height: 30px;
}
.leaflet-bar a:hover { background: var(--phos); color: #000; }
.leaflet-control-attribution { background: rgba(0,0,0,.75) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--phos); }

.banner {
  position: absolute; top: 40px; left: 56px; right: 10px; z-index: 1100; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--phos); color: #000; padding: 4px 10px; font-family: var(--display); font-size: 21px; text-transform: uppercase; letter-spacing: .04em;
  box-shadow: 4px 4px 0 #000;
}
.banner span::after { content: "_"; animation: blink 1s steps(1) infinite; }
.banner button { background: #000; border: 0; color: var(--phos); padding: 2px 10px; border-radius: 0; cursor: pointer; font-family: var(--display); font-size: 19px; text-transform: uppercase; }

/* Marqueurs : points noirs ronds avec bord blanc (la carte est claire) */
.pin { background: none; border: 0; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%; background: #000; border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.55); transition: transform .12s ease;
}
.pin:hover .pin-dot { transform: scale(1.25); }
.pin-dot.pending { background: var(--accent); }
.pin-dot.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.pin-new { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.45); }

/* Aperçu au survol d'un point */
.leaflet-tooltip.spot-tip {
  padding: 0; width: 220px; white-space: normal; background: #000; color: var(--ink);
  border: 1px solid var(--phos); border-radius: 0; box-shadow: 4px 4px 0 rgba(255,255,255,.25); font-family: var(--font);
}
.leaflet-tooltip-top.spot-tip::before { border-top-color: var(--phos); }
.tip img { width: 100%; height: 130px; object-fit: cover; display: block; border-bottom: 1px solid var(--line-hi); }
.tip-body { display: grid; gap: 2px; padding: 8px 10px; }
.tip-body strong { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1; text-transform: uppercase; overflow-wrap: anywhere; }
.tip-body span { font-size: 11px; color: var(--phos); }

/* ====== BARRE D'ÉTAT EN BAS ====== */
.status {
  flex: none; display: flex; gap: 18px; padding: 4px 0 8px; border-top: 1px solid var(--line);
  font-family: var(--display); font-size: 17px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
}
.status span:first-child { color: var(--phos); }
.status .blink { margin-left: auto; color: var(--phos); animation: blink 1.4s steps(1) infinite; }

/* ====== FENÊTRES (détail, formulaires) ====== */
.overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .78); display: flex; }
.overlay[hidden] { display: none; }
.overlay.side { justify-content: flex-end; }
.overlay.center { align-items: center; justify-content: center; padding: 12px; }

.sheet { background: var(--bg); width: min(480px, 100%); height: 100%; overflow-y: auto; border-left: 2px solid var(--phos); box-shadow: -8px 0 0 rgba(255,255,255,.08); }
.sheet .body { padding: 16px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 46px; line-height: .95; text-transform: uppercase; letter-spacing: .01em; color: var(--ink); text-wrap: balance; overflow-wrap: anywhere; }
.sheet p.desc { margin: 0; white-space: pre-line; overflow-wrap: anywhere; color: var(--ink); }
.sheet .bar { display: flex; justify-content: flex-end; padding: 10px 16px 0; }
.close {
  background: #000; color: var(--ink); border: 1px solid var(--line-hi); width: 36px; height: 36px; border-radius: 0; cursor: pointer;
  font-size: 16px; display: grid; place-items: center;
}
.close:hover { border-color: var(--accent); color: var(--accent); }

.carousel { position: relative; background: #000; aspect-ratio: 4 / 3; max-width: 100%; border: 1px solid var(--line-hi); }
.carousel img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carousel .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 1px solid var(--phos); border-radius: 0; background: rgba(0,0,0,.8); color: var(--phos); font-size: 22px; cursor: pointer; }
.carousel .nav:hover { background: var(--phos); color: #000; }
.carousel .prev { left: 8px; } .carousel .next { right: 8px; }
.carousel .pos { position: absolute; right: 8px; bottom: 8px; background: #000; color: var(--phos); font-family: var(--display); font-size: 17px; padding: 0 7px; border: 1px solid var(--phos-dim); }
.nophoto {
  aspect-ratio: 16 / 7; display: grid; place-items: center; color: var(--phos-dim); font-family: var(--display); font-size: 22px; text-transform: uppercase; letter-spacing: .08em;
  border: 1px dashed var(--line-hi);
  background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(255,255,255,.04) 8px 16px);
}

.bustbox { border: 1px solid var(--line-hi); background: var(--surface); padding: 12px; display: grid; gap: 10px; }
.bustbox strong { font-family: var(--display); font-weight: 400; font-size: 23px; text-transform: uppercase; letter-spacing: .03em; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.scale span { text-align: center; color: var(--on-bust); font-family: var(--display); font-size: 20px; padding: 2px 0; opacity: .22; }
.scale span.on { opacity: 1; outline: 2px solid var(--ink); outline-offset: 2px; }
.scale .s1 { background: var(--b1); } .scale .s2 { background: var(--b2); } .scale .s3 { background: var(--b3); } .scale .s4 { background: var(--b4); } .scale .s5 { background: var(--b5); }
.scalekey { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.6; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pos-line { font-size: 12px; color: var(--phos); margin: 0; overflow-wrap: anywhere; }
.pos-line::before { content: "LAT/LON  "; color: var(--muted); }

.dialog {
  background: var(--bg); border: 2px solid var(--phos); width: min(560px, 100%); max-height: 100%; overflow-y: auto;
  display: grid; gap: 14px; padding: 0 16px 16px; align-content: start; box-shadow: 8px 8px 0 rgba(255,255,255,.15);
}
.dialog.small { width: min(400px, 100%); }
/* Barre de titre de fenêtre, inversée comme sur un vieil OS */
.dialog header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 -16px; padding: 4px 6px 4px 12px; background: var(--phos); color: #000; position: sticky; top: 0; z-index: 2;
}
.dialog h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1; text-transform: uppercase; letter-spacing: .04em; }
.dialog h2::before { content: "■ "; }
.dialog header .close { background: #000; color: var(--phos); border-color: #000; width: 30px; height: 30px; }
.dialog header .close:hover { background: var(--accent); color: #000; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > legend, .lab { font-family: var(--display); font-size: 18px; text-transform: uppercase; letter-spacing: .08em; color: var(--amber); }
.field > span::before, .field > legend::before, .lab::before { content: "> "; color: var(--phos-dim); }
fieldset.field { border: 0; margin: 0; padding: 0; }
.two { display: grid; grid-template-columns: 1fr; gap: 14px; }
.bustpick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.bustpick button { border: 1px solid var(--line-hi); background: #000; padding: 4px 2px; cursor: pointer; display: grid; gap: 2px; justify-items: center; min-width: 0; border-radius: 0; }
.bustpick button:hover { border-color: var(--ink); }
.bustpick b { color: var(--on-bust); font-family: var(--display); font-weight: 400; font-size: 20px; width: 100%; text-align: center; line-height: 1.2; }
.bustpick .p1 { background: var(--b1); } .bustpick .p2 { background: var(--b2); } .bustpick .p3 { background: var(--b3); } .bustpick .p4 { background: var(--b4); } .bustpick .p5 { background: var(--b5); }
.bustpick small { font-size: 10px; color: var(--muted); line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.bustpick button[aria-checked="true"] { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.bustpick button[aria-checked="true"] small { color: var(--ink); }

.locbox { border: 1px dashed var(--line-hi); background: var(--surface); padding: 12px; display: grid; gap: 10px; }
.locout { font-family: var(--display); font-size: 24px; color: var(--phos); text-shadow: var(--glow); letter-spacing: .03em; }
.locrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.msg { margin: 0; font-size: 12px; color: var(--muted); }
.msg.err { color: var(--accent); }
.msg.err::before { content: "ERR! "; font-weight: 700; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; background: var(--surface); border: 1px solid var(--line-hi); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 1px solid var(--accent); border-radius: 0; background: #000; color: var(--accent); cursor: pointer; line-height: 1; }
.ph button:hover { background: var(--accent); color: #000; }
.filepick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.file-hidden:focus-visible + .btn { outline: 2px dashed var(--phos); outline-offset: 2px; }
.btn.is-off { opacity: .5; cursor: default; pointer-events: none; }
.filename { font-size: 13px; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3000; background: #000; color: var(--phos);
  border: 2px solid var(--phos); box-shadow: 4px 4px 0 rgba(255,255,255,.25); padding: 6px 14px;
  font-family: var(--display); font-size: 21px; letter-spacing: .03em; text-transform: uppercase; max-width: calc(100% - 32px);
}
.toast::before { content: "OK> "; color: var(--phos-dim); }
.toast[hidden] { display: none; }
.foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding-top: 4px; }

/* ====== TÉLÉPHONE ====== */
@media (max-width: 899px) {
  body { padding: 0 12px; }
  .main { display: flex; flex-direction: column; overflow-y: auto; }
  .mapbox { order: -1; flex: none; height: 46vh; min-height: 300px; }
  .panel { overflow: visible; flex: none; }
  .logo { height: 40px; }
  .btn { font-size: 19px; padding: 3px 10px 2px; }
  .maphead span:last-child, .status span:nth-child(2) { display: none; }
}
@media (min-width: 640px) { .two { grid-template-columns: 1fr 1fr; } }

/* Moins d'animations si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
  .count::after, .status .blink, .banner span::after, .bustchip.pend { animation: none; }
}
