/* We Are Portuguese — carte céleste des lusophones. */

:root {
  --bg: #04050a;
  --panel: rgba(12, 14, 22, 0.82);
  --panel-solid: #0c0e16;
  --line: rgba(240, 192, 74, 0.16);
  --line-soft: rgba(255, 255, 255, 0.08);
  --gold: #f0c04a;
  --gold-soft: rgba(240, 192, 74, 0.14);
  --text: #f4f1e9;
  --muted: #9aa0b0;
  --muted-dim: #7d8496;
  --danger: #ff8a7a;
  --ok: #7ad19b;
  --radius: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.is-map { overflow: hidden; }

/* ---------- Carte ---------- */
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#map.dragging { cursor: grabbing; }

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 35%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(4, 5, 10, 0.75) 0%, transparent 22%, transparent 70%, rgba(4, 5, 10, 0.85) 100%);
}

/* ---------- Barre supérieure ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand svg { width: 27px; height: 32px; flex: none; }
.brand-name { font-weight: 700; letter-spacing: 0.14em; font-size: 13px; }
.brand-sub { font-size: 10.5px; color: var(--muted-dim); letter-spacing: 0.18em; text-transform: uppercase; }

.topnav { display: flex; align-items: center; gap: 6px; }
.lang { display: flex; gap: 2px; background: rgba(255,255,255,0.05); border-radius: 999px; padding: 3px; }
.lang button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px;
  font-weight: 600; letter-spacing: 0.08em; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--gold); color: #10120c; }

/* ---------- Panneau latéral ---------- */
.panel {
  position: fixed;
  top: 84px; left: 24px;
  width: min(380px, calc(100vw - 48px));
  max-height: calc(100dvh - 140px);
  overflow-y: auto;
  padding: 26px;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  z-index: 15;
  scrollbar-width: thin;
}
.panel h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.15;
  margin: 0 0 12px;
}
.panel h1 em { font-style: italic; color: var(--gold); }
.panel p.lead { color: var(--muted); font-size: 14px; line-height: 1.65; margin: 0 0 20px; }

.counter { display: flex; align-items: baseline; gap: 10px; margin-bottom: 20px; }
.counter b {
  font-size: 34px; font-weight: 700; color: var(--gold);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.counter span { font-size: 12px; color: var(--muted-dim); text-transform: uppercase; letter-spacing: 0.12em; }

/* ---------- Formulaire ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted-dim); margin-bottom: 6px; font-weight: 600;
}
.field .req { color: var(--gold); }
/* `:where` garde la spécificité au minimum : les classes comme .code-input
   peuvent encore ajuster ces champs. Les cases à cocher gardent leur aspect natif. */
input:where(:not([type="checkbox"]):not([type="radio"])), select, textarea {
  width: 100%;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
input:where(:not([type="checkbox"]):not([type="radio"])):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(240, 192, 74, 0.06);
}
input::placeholder { color: #6b7183; }
select option { background: var(--panel-solid); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 11.5px; color: var(--muted-dim); margin-top: 5px; line-height: 1.5; }
.hint a { color: var(--gold); }
.err { font-size: 11.5px; color: var(--danger); margin-top: 5px; display: none; }
.field.invalid .err { display: block; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }

.honey { position: absolute; left: -9999px; opacity: 0; height: 0; }

.optional-toggle {
  width: 100%; text-align: left; background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer; padding: 10px 0;
  border-top: 1px solid var(--line-soft); margin-top: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.optional-toggle:hover { color: var(--gold); }
.optional-toggle .chev { transition: transform 0.2s; }
.optional-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.optional { display: none; padding-top: 6px; }
.optional.open { display: block; }

.consent { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; }
.consent input { margin-top: 2px; accent-color: var(--gold); width: 16px; height: 16px; flex: none; }
.consent label { font-size: 12px; color: var(--muted); line-height: 1.55; }
.consent a { color: var(--gold); }

button.primary {
  width: 100%; padding: 13px 18px; border: 0; border-radius: 9px;
  background: var(--gold); color: #10120c; font: inherit; font-weight: 700;
  font-size: 14px; cursor: pointer; transition: transform 0.12s, box-shadow 0.2s;
  box-shadow: 0 0 0 rgba(240, 192, 74, 0);
}
button.primary:hover:not(:disabled) { box-shadow: 0 6px 28px rgba(240, 192, 74, 0.3); }
button.primary:active:not(:disabled) { transform: translateY(1px); }
button.primary:disabled { opacity: 0.5; cursor: progress; }
button.ghost {
  background: none; border: 1px solid rgba(255,255,255,0.14); color: var(--muted);
  padding: 10px 16px; border-radius: 9px; font: inherit; font-size: 13px; cursor: pointer; width: 100%;
}
button.ghost:hover { border-color: var(--gold); color: var(--gold); }
.linkish { background: none; border: 0; color: var(--muted-dim); font: inherit; font-size: 11.5px; cursor: pointer; text-decoration: underline; padding: 0; }
.linkish:hover { color: var(--gold); }

/* ---------- Étape code ---------- */
.code-input {
  width: 100%; text-align: center; font-size: 28px; letter-spacing: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding: 14px 0 14px 14px;
}
.step { display: none; }
.step.active { display: block; }

.success-mark {
  width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 50%;
  background: radial-gradient(circle, rgba(240,192,74,0.9), rgba(240,192,74,0.05) 70%);
  box-shadow: 0 0 40px rgba(240, 192, 74, 0.55);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1 } 50% { transform: scale(1.12); opacity: 0.75 } }

.notice { padding: 11px 13px; border-radius: 9px; font-size: 12.5px; line-height: 1.5; margin-bottom: 14px; display: none; }
.notice.show { display: block; }
.notice.error { background: rgba(255, 138, 122, 0.12); color: var(--danger); border: 1px solid rgba(255,138,122,0.25); }
.notice.ok { background: rgba(122, 209, 155, 0.1); color: var(--ok); border: 1px solid rgba(122,209,155,0.22); }

/* ---------- Bas de carte ---------- */
.factbar {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  text-align: center; z-index: 12; pointer-events: none; max-width: 90vw;
}
.factbar .kicker { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--text); }
.factbar .fact { font-size: 12.5px; color: var(--muted-dim); margin-top: 4px; min-height: 18px; }

.zoomctl {
  position: fixed; right: 24px; bottom: 24px; z-index: 14;
  display: flex; flex-direction: column; gap: 6px;
}
.zoomctl button {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text);
  font-size: 17px; line-height: 1; backdrop-filter: blur(10px);
}
.zoomctl button:hover { border-color: var(--gold); color: var(--gold); }

.tooltip {
  position: fixed; z-index: 18; pointer-events: none; opacity: 0;
  transition: opacity 0.12s; background: var(--panel-solid);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px;
  font-size: 12px; white-space: nowrap; transform: translate(-50%, -140%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.tooltip.show { opacity: 1; }
.tooltip b { color: var(--gold); }

.footlinks {
  position: fixed; bottom: 18px; left: 24px; z-index: 12;
  display: flex; gap: 16px; font-size: 11px;
}
.footlinks a { color: var(--muted-dim); text-decoration: none; }
.footlinks a:hover { color: var(--gold); }
.version { color: #3f434f; font-variant-numeric: tabular-nums; }

/* ---------- Pages de contenu ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 100px 24px 80px; }
.page h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 0 0 8px; }
.page h2 { font-size: 17px; margin: 34px 0 10px; color: var(--gold); }
.page p, .page li { color: var(--muted); line-height: 1.75; font-size: 14.5px; }
.page a { color: var(--gold); }
.page .card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 24px; margin-top: 24px; }

/* ---------- Volet escamotable (mobile) ---------- */
.sheet-handle { display: none; }
.sheet-cta { display: none; }

/* ---------- Mobile ---------- */
/* Sur mobile, un champ dont le texte fait moins de 16 px déclenche le zoom
   automatique de Safari — et comme la page est en plein écran fixe, ce zoom
   décale toute la mise en page. 16 px l'empêche, sans rien changer ailleurs. */
@media (max-width: 860px) {
  input:where(:not([type="checkbox"]):not([type="radio"])), select, textarea {
    font-size: 16px;
  }
  .code-input { font-size: 26px; }
  .panel, .page { touch-action: manipulation; }
}

@media (max-width: 760px) {
  .panel {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%;
    max-height: 74dvh; border-radius: 18px 18px 0 0; padding: 20px 20px 28px;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  /* Le panneau est un volet : replié, il laisse la carte entière visible ;
     déplié, il montre le formulaire. La poignée bascule entre les deux. */
  .sheet-handle {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; background: none; border: 0; cursor: pointer;
    padding: 2px 0 14px; margin: -6px 0 0; color: var(--muted-dim);
    font: inherit; font-size: 11.5px; letter-spacing: .06em;
  }
  .sheet-grip {
    display: block; width: 40px; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,0.22);
  }
  .sheet-label { display: inline; }
  .panel.collapsed .sheet-label { display: none; }

  .panel { transition: max-height .28s ease; }
  /* Pas d'animation tant que la page n'a pas fini de se mettre en place. */
  .panel:not(.ready) { transition: none; }
  .panel.collapsed { max-height: 42dvh; }
  .panel.collapsed #signup,
  .panel.collapsed .lead { display: none; }
  .panel.collapsed .sheet-cta { display: block; margin-top: 4px; }
  .panel.collapsed h1 { font-size: 21px; margin-bottom: 10px; }
  .panel h1 { font-size: 24px; }
  .brand-sub { display: none; }
  .topnav .linkish { white-space: nowrap; }
  .factbar, .footlinks { display: none; }
  .zoomctl { bottom: auto; top: 76px; right: 16px; gap: 5px; }
  .zoomctl button { width: 34px; height: 34px; font-size: 15px; }
  .topbar { padding: 14px 16px; }
}

/* ---------- Centres d'intérêt ---------- */
.tag {
  font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-dim);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 2px 7px; margin-left: 6px;
}
.int-group { margin-bottom: 16px; }
.int-group h4 {
  margin: 0 0 8px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}
.int-list { display: flex; flex-wrap: wrap; gap: 7px; }
.int-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.int-item span {
  display: inline-block; padding: 7px 12px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--line-soft); color: var(--muted); cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.int-item span:hover { border-color: rgba(240,192,74,.45); color: var(--text); }
.int-item input:checked + span { border-color: var(--gold); color: var(--gold); background: rgba(240,192,74,.1); }
.int-item input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Carte de partage ---------- */
.card-preview {
  margin: 18px 0 12px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line-soft); background: #04050a;
  display: flex; justify-content: center;
}
.card-preview img { display: block; width: 100%; max-width: 208px; height: auto; }
.format-switch { display: flex; gap: 6px; margin-bottom: 14px; }
.format-switch button {
  flex: 1; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 12px; cursor: pointer;
  background: none; border: 1px solid var(--line-soft); color: var(--muted);
}
.format-switch button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: rgba(240,192,74,.08); }
