/* ==========================================================================
   Charte Anautiqua — Variables, typographie et composants communs
   ========================================================================== */

:root {
  --encre: #231f20;
  --papier: #fbfbfa;
  --gris: #6b6667;
  --trait: #e4e1e1;
  --rubrique: #a3221a;
  --rubrique-nuit: #e2675c;
  --nuit: #1b191c;
  --nuit-2: #2a272b;
  --nuit-texte: #f3f1f1;
  --nuit-gris: #a9a3a5;
  --nuit-survol: #353137;
  --nuit-choisi: #382c30;
  --ombre: rgba(35, 31, 32, 0.08);
  --rubrique-pale: color-mix(in srgb, var(--rubrique) 7%, var(--papier));
  --serif: "Merriweather", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--papier);
  color: var(--encre);
  font-family: var(--serif);
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Surfaces the browser draws itself, themed from the charter */
::selection {
  background-color: color-mix(in srgb, var(--rubrique) 22%, transparent);
  color: var(--encre);
}
body.page-test ::selection {
  background-color: color-mix(in srgb, var(--rubrique-nuit) 35%, transparent);
  color: var(--nuit-texte);
}
input, textarea {
  caret-color: var(--rubrique);
}
.form-check-input:checked {
  background-color: var(--encre);
  border-color: var(--encre);
}
.form-check-input:focus,
.form-control:focus {
  border-color: var(--encre);
  box-shadow: none;
}

:focus-visible {
  outline: 2px solid var(--rubrique);
  outline-offset: 2px;
}

a {
  color: var(--encre);
  text-decoration: underline;
  text-decoration-color: var(--trait);
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--rubrique);
  text-decoration-color: var(--rubrique);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  color: var(--encre);
  font-weight: 700;
  line-height: 1.3;
}

p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

/* --------------------------------------------------------------------------
   En-tête & Navigation
   -------------------------------------------------------------------------- */
.site-nav {
  background-color: var(--papier);
  border-bottom: 1px solid var(--trait);
  padding: 1rem 0;
  position: relative;
}

.site-nav .container-fluid {
  position: relative;
  max-width: 1200px;
}

.navbar-brand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.navbar-brand img {
  height: 44px;
  width: auto;
}

/* Desktop: the logo is absolutely centred, so each link list must stay inside its own half
   (logo is ~242px wide at 44px high: half of it plus 24px of breathing room) */
@media (min-width: 1200px) {
  .site-nav .navbar-collapse > .navbar-nav {
    flex: 0 0 calc(50% - 145px);
    flex-wrap: nowrap;
    column-gap: clamp(0.9rem, 2.2vw, 2rem);
  }
  .site-nav .navbar-collapse > .navbar-nav.ms-auto {
    justify-content: flex-end;
  }
  .site-nav .navbar-nav .nav-item {
    margin-inline: 0 !important; /* spacing comes from column-gap, overriding .mx-xl-3 */
    white-space: nowrap;
  }
}

.navbar-toggler {
  border: 1px solid var(--trait);
  background-color: var(--papier);
  color: var(--encre);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

.navbar-toggler:focus-visible {
  outline: 2px solid var(--rubrique);
  outline-offset: 2px;
}

.navbar-nav .nav-link {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--encre);
  text-decoration: none;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.navbar-nav .nav-link:hover {
  color: var(--rubrique);
}

.navbar-nav .nav-link.active,
.navbar-nav .nav-link[aria-current="page"] {
  border-bottom-color: var(--rubrique);
  color: var(--encre);
  font-weight: 400;
}

.dropdown-menu {
  background-color: var(--papier);
  border: 1px solid var(--trait);
  border-radius: 4px;
  font-family: var(--ui);
  box-shadow: 0 4px 12px var(--ombre);
}

.dropdown-item {
  color: var(--encre);
  font-family: var(--ui);
  padding: 0.5rem 1rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--trait);
  color: var(--encre);
}

/* below 1200px the menu is collapsed: three admin links + centred logo do not fit */
@media (max-width: 1199.98px) {
  .navbar-brand img {
    height: 34px;
  }
  /* centre the logo on the toggler row, not on the whole header (which grows when the menu opens) */
  .navbar-brand {
    top: 0;
    height: 48px;
    transform: translateX(-50%);
  }
  .navbar-collapse {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--trait);
  }
  .navbar-nav .nav-link {
    padding: 0.6rem 0;
  }
}

/* --------------------------------------------------------------------------
   Pied de page
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--trait);
  padding: 1.5rem 1rem;
  font-family: var(--ui);
  font-size: 0.875rem;
  color: var(--gris);
  background-color: var(--papier);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer .credits {
  color: var(--gris);
  font-size: 0.875rem;
}

.site-footer .footer-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-footer .footer-logo img {
  height: 28px;
  width: auto;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .site-footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   Accueil (index.php)
   -------------------------------------------------------------------------- */
.accueil-conteneur {
  max-width: 68ch;
  margin: 3rem auto;
  /* padding, not margin: Bootstrap's .my-auto overrides vertical margins */
  padding: 2.5rem 1rem;
  width: 100%;
}

.accueil-lore {
  text-align: left;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--encre);
}

.accueil-lore p {
  margin-bottom: 1.5rem;
}

.accueil-lore strong,
.accueil-lore b {
  font-weight: 700;
}

.accueil-action {
  margin-top: 2.5rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------------- */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--encre);
  color: var(--papier);
  border: 1px solid var(--encre);
  border-radius: 4px;
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bouton:hover {
  background-color: var(--nuit-2);
  border-color: var(--nuit-2);
  color: var(--papier);
}

.bouton-rubrique {
  background-color: var(--rubrique);
  border-color: var(--rubrique);
  color: var(--papier);
}

.bouton-rubrique:hover {
  background-color: var(--encre);
  border-color: var(--encre);
  color: var(--papier);
}

.bouton-secondaire {
  background-color: transparent;
  color: var(--encre);
  border: 1px solid var(--trait);
}

.bouton-secondaire:hover {
  background-color: var(--trait);
  color: var(--encre);
}

/* --------------------------------------------------------------------------
   Formulaires communs
   -------------------------------------------------------------------------- */
.form-page-conteneur {
  max-width: 480px;
  margin: 2rem auto;
  /* padding, not margin: Bootstrap's .my-auto overrides vertical margins */
  padding: 2.5rem 1rem;
  width: 100%;
}

.champ {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
}

.champ label {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--encre);
  margin-bottom: 0.35rem;
}

.champ input[type="text"],
.champ input[type="email"],
.champ input[type="password"],
.champ textarea,
.champ select {
  padding: 0.65rem 0.85rem;
  font-family: var(--ui);
  font-size: 1rem;
  color: var(--encre);
  background-color: var(--papier);
  border: 1px solid var(--trait);
  border-radius: 4px;
  transition: border-color 0.15s ease;
  width: 100%;
}

.champ input:focus,
.champ textarea:focus,
.champ select:focus {
  border-color: var(--rubrique);
  outline: 2px solid var(--rubrique);
  outline-offset: 1px;
}

.champ-erreur {
  margin-top: 0.35rem;
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--rubrique);
}

.demo-form {
  margin-bottom: 0.5rem;
}

.separateur {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--gris);
}
.separateur::before,
.separateur::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--trait);
}

.champ-aide {
  margin: 0.35rem 0 0;
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--gris);
}

fieldset.champ legend {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--encre);
  margin-bottom: 0.5rem;
}

/* Mon compte */
.compte-verrou {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.compte-verrou:disabled {
  opacity: 0.6;
}
.compte-conteneur {
  max-width: 900px;
  margin: 0 auto;
  /* padding, not margin: Bootstrap's .my-auto overrides vertical margins */
  padding: 2.5rem 1rem;
  width: 100%;
}

.compte-titre {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.compte-avatar {
  position: relative;
  width: 150px;
  margin: 0 auto 1.5rem;
}

.compte-avatar-drapeau {
  position: absolute;
  right: 0;
  bottom: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 2px var(--papier);
}

.compte-pays {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--trait);
  font-family: var(--serif);
}

.zone-message {
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  font-family: var(--ui);
  font-size: 0.95rem;
}

.zone-message[role="alert"] {
  background-color: var(--rubrique-pale);
  border: 1px solid var(--rubrique);
  color: var(--encre);
}
.zone-message[role="alert"] .bi {
  color: var(--rubrique);
}

.zone-message[role="status"] {
  background-color: var(--papier);
  border: 1px solid var(--trait);
  color: var(--encre);
}

.round-image {
  object-fit: cover;
  width: 150px;
  height: 150px;
  border-radius: 50%;
}

.nodisplay {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Page de Test (plein écran, fond nuit)
   -------------------------------------------------------------------------- */
body.page-test {
  background-color: var(--nuit);
  color: var(--nuit-texte);
  font-family: var(--serif);
  /* the test is one screen: header, question and progress always visible */
  height: 100vh;
  height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

body.page-test :focus-visible {
  outline: 2px solid var(--rubrique-nuit);
  outline-offset: 3px;
}

.test-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 0;
  padding: 1.5rem 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.test-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 48px;
}

.test-btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--nuit-gris);
  font-family: var(--ui);
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.test-btn-nav:hover {
  color: var(--nuit-texte);
  border-color: var(--nuit-2);
}

.test-body {
  flex: 1;
  min-height: 0;
  /* last resort (very large text): scroll the answers, never the page, never clip */
  overflow-y: auto;
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: 2rem 0;
}

.test-form {
  width: 100%;
}

.test-step {
  border: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* En mode JS, seule la question active est affichée */
.js-test .test-step {
  display: none;
}

.js-test .test-step.active {
  display: block;
  animation: testFadeIn 0.3s ease-in-out;
}

@keyframes testFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .js-test .test-step.active {
    animation: none;
  }
}

.test-question-titre {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.5vw, 1.85rem);
  font-weight: 400;
  font-style: italic;
  text-align: center;
  color: var(--nuit-texte);
  margin-bottom: 2.5rem;
  padding: 0 1rem;
  width: 100%;
  text-wrap: balance;
}

.test-reponses-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .test-reponses-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

.test-carte {
  display: flex;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background-color: var(--nuit-2);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--nuit-texte);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
  user-select: none;
}

.test-carte:hover {
  background-color: var(--nuit-survol);
  border-color: var(--nuit-gris);
}

.test-carte input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.test-carte:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--rubrique-nuit);
  outline-offset: 2px;
}

.test-carte.selected,
.test-carte:has(input[type="radio"]:checked) {
  border-color: var(--rubrique-nuit);
  background-color: var(--nuit-choisi);
}

.test-carte-texte {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1.5;
}

.test-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  padding-top: 1rem;
}

.test-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.test-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex: 1;
}

.test-progress-bar-container {
  flex: 1;
  height: 4px;
  background-color: var(--nuit-2);
  border-radius: 2px;
  overflow: hidden;
}

.test-progress-bar {
  height: 100%;
  background-color: var(--rubrique-nuit);
  transition: width 0.25s ease;
}

.test-progress-text {
  font-family: var(--ui);
  font-size: 0.95rem;
  color: var(--nuit-gris);
  min-width: 60px;
  text-align: right;
}

.test-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* --------------------------------------------------------------------------
   Page Résultats (resultats.php)
   -------------------------------------------------------------------------- */
.resultats-conteneur {
  max-width: 900px;
  margin: 2rem auto 4rem auto;
  padding-block: 2.5rem;
  width: 100%;
}

.resultats-nom-pays {
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin-bottom: 1.5rem;
}

.resultats-drapeau {
  max-width: 360px;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 16px var(--ombre);
  margin-bottom: 2rem;
}

.resultats-desc {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--encre);
  max-width: 65ch;
  margin: 0 auto 3rem auto;
  text-align: left;
}

.resultats-desc p {
  margin: 0 0 1.1em;
}

.resultats-top3 {
  max-width: 600px;
  margin: 0 auto 3rem auto;
  text-align: left;
}

.resultats-top3-titre {
  font-family: var(--ui);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--encre);
}

.resultat-ligne {
  margin-bottom: 1.25rem;
}

.resultat-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
  font-family: var(--ui);
}

.resultat-pays {
  font-weight: 600;
  color: var(--encre);
}

.resultat-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--gris);
}

.resultat-bar-container {
  height: 12px;
  background-color: var(--trait);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar.bar-rubrique {
  background-color: var(--rubrique);
}

.progress-bar.bar-encre {
  background-color: var(--encre);
}

.resultats-actions {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.resultats-vide {
  max-width: 60ch;
  margin: 3rem auto;
}

/* kept last so it wins over the base .test-* rules above */
/* Small or short screens: every question must fit in one screen, so spacing and type follow the height */
@media (max-width: 640px), (max-height: 700px) {
  .test-container {
    padding: 0.75rem 1rem;
  }
  .test-header {
    min-height: 40px;
  }
  .test-body {
    padding: 0.5rem 0;
  }
  .test-question-titre {
    font-size: clamp(1rem, 0.55rem + 1.9vh, 1.5rem);
    margin-bottom: clamp(0.75rem, 2.5vh, 2rem);
    padding: 0;
  }
  .test-reponses-grid {
    gap: clamp(0.4rem, 1.2vh, 0.85rem);
  }
  .test-carte {
    padding: clamp(0.5rem, 1.6vh, 1.1rem) 1rem;
  }
  .test-carte-texte {
    font-size: clamp(0.875rem, 0.55rem + 1.2vh, 1.05rem);
    line-height: 1.35;
  }
  .test-footer {
    padding-top: 0.5rem;
  }
}

/* Very short phones (e.g. 320×568): the longest questions need a tighter set */
@media (max-height: 600px) and (max-width: 640px) {
  .test-container {
    padding: 0.5rem 0.75rem;
  }
  .test-header {
    min-height: 36px;
  }
  .test-body {
    padding: 0.25rem 0;
  }
  .test-question-titre {
    font-size: 1rem;
    margin-bottom: 0.6rem;
  }
  .test-reponses-grid {
    gap: 0.35rem;
  }
  .test-carte {
    padding: 0.45rem 0.85rem;
  }
  .test-carte-texte {
    font-size: 0.8125rem;
    line-height: 1.3;
  }
}
