/* Duckdex - feuille de style unique (pas de build, pas de framework CSS). */

:root {
  --ink-900: #12141d;
  --ink-700: #232838;
  --ink-400: #5b6478;
  --ink-100: #e4e6eb;
  --ink-50: #f4f5f7;

  --gold-700: #966615;
  --gold-600: #c2871c;
  --gold-500: #e3a72e;
  --gold-300: #f2ce6d;
  --gold-100: #faedc6;
  --gold-50: #fdf8ec;

  --paper: #fbf7ee;
  --white: #ffffff;
  --red-600: #dc2626;
  --emerald-50: #ecfdf5;
  --emerald-200: #a7f3d0;
  --emerald-600: #059669;
  --emerald-700: #047857;

  --navbar-bg: rgba(251, 247, 238, 0.85);
  --cover-liseret: rgba(150, 102, 21, 0.18);

  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --shadow-card: 0 1px 2px rgba(18, 20, 29, 0.04), 0 8px 24px -12px rgba(18, 20, 29, 0.18);
}

/*
 * Mode sombre.
 *
 * Rien d'autre que la palette n'est redefini : toutes les regles du fichier
 * passent par ces variables, donc inverser les valeurs suffit. Les noms
 * gardent leur sens de role et non de couleur -- « ink-900 » reste la teinte
 * du texte principal, meme lorsqu'elle devient claire.
 *
 * Le theme est pose par theme.js sur <html> avant l'affichage : sans cela la
 * page apparaitrait blanche une fraction de seconde avant de basculer.
 */
:root[data-theme="dark"] {
  --ink-900: #f1f3f7;
  --ink-700: #ccd2de;
  --ink-400: #939bad;
  --ink-100: #333a49;
  --ink-50: #262c38;

  /* L'or garde sa place, mais un ton chaud lisible sur fond sombre. */
  --gold-700: #efc267;
  --gold-600: #d8a132;
  --gold-500: #e3a72e;
  --gold-300: #8b6c26;
  --gold-100: #3b3018;
  --gold-50: #272015;

  --paper: #14161d;
  --white: #1c1f28;
  --red-600: #f87171;
  --emerald-50: #10291f;
  --emerald-200: #1f5c42;
  --emerald-600: #22c55e;
  --emerald-700: #5eead4;

  --navbar-bg: rgba(20, 22, 29, 0.85);
  --cover-liseret: rgba(239, 194, 103, 0.22);

  /* Une ombre portee ne se voit pas sur du sombre : on marque le relief par
     un liseré clair plutot que par une ombre qui passerait inapercue. */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink-900);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

.container {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/*
 * Sur telephone, le texte se retrouvait colle au bord. Ce n'etait pas le
 * rembourrage du conteneur, correct, mais un debordement horizontal : un
 * element plus large que l'ecran fait defiler toute la page, et le
 * rembourrage part hors champ. Les regles ci-dessous s'attaquent aux causes.
 */

/* Un mot trop long ne doit pas elargir la page a lui seul. */
body {
  overflow-wrap: break-word;
}

/* Un enfant de flex refuse de retrecir sous sa taille de contenu sans ceci. */
.card,
.list-item,
.album-card-lien,
.stack {
  min-width: 0;
}

@media (max-width: 640px) {
  .container {
    padding: 0 1rem;
  }

  /* Sept liens en ligne depassaient largement : ils passent a la ligne. */
  .navbar-inner {
    height: auto;
    min-height: 3.5rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  .nav-links {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8125rem;
  }

  .page {
    padding: 2rem 0;
  }

  .hero {
    padding: 2.5rem 0;
  }

  /* Les titres portent une taille en style en ligne, qu'il faut surpasser. */
  .hero h1 {
    font-size: 1.75rem !important;
    line-height: 1.2 !important;
  }

  .card-lg {
    padding: 1.25rem;
  }

  /* Une ligne de liste tient rarement sur un ecran etroit. */
  .list-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Un tableau large doit defiler dans son coin, pas emporter la page. */
  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
}

/* Navbar */

.navbar {
  border-bottom: 1px solid var(--ink-100);
  background: var(--navbar-bg);
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
  z-index: 10;
}

.navbar-inner {
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
}

.brand-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--gold-500);
  /* En dur : la pastille reste doree dans les deux themes, donc son texte doit
     rester sombre. Herite de la couleur du corps, il passerait clair sur clair
     en mode sombre. */
  color: #12141d;
  font-size: 0.875rem;
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-700);
}

.nav-links a:hover {
  color: var(--ink-900);
}

/* Bloc connexion de la nav, rempli par nav-auth.js. */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-auth .nav-user {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--gold-700);
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--ink-100);
}

.footer-inner {
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--ink-400);
}

.footer-inner a {
  font-weight: 500;
  color: var(--ink-700);
}

.footer-inner a:hover {
  color: var(--gold-700);
}

/* Layout helpers */

.page {
  padding: 3rem 0;
}

.hero {
  padding: 5rem 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Typography */

.eyebrow {
  display: inline-block;
  background: var(--gold-100);
  color: var(--gold-700);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.text-muted {
  color: var(--ink-400);
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.65rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--ink-900);
  color: var(--paper);
}

.btn-primary:hover:not(:disabled) {
  background: var(--ink-700);
}

.btn-outline {
  border-color: var(--ink-100);
  background: var(--white);
  color: var(--ink-900);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--ink-400);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--gold-700);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
}

.btn-danger {
  color: var(--red-600);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Cards */

.card {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: 1rem;
  box-shadow: var(--shadow-card);
  padding: 1rem;
}

.card-lg {
  padding: 2rem;
}

.album-card {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  position: relative;
}

.album-card-lien {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  flex: 1;
  min-width: 0;
}

/*
 * Ajouter un numero a sa collection sans ouvrir sa fiche : avec plus de mille
 * numeros, l'aller-retour serait vite penible.
 */
.album-card-collection {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border: 1px solid var(--ink-100);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink-400);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.album-card-collection:hover {
  border-color: var(--gold-500);
  color: var(--gold-700);
}

/* Vert, et non or : sur une grille de vignettes toutes dorees, la coche
   possede doit se reperer d'un coup d'oeil sans etre lue. */
.album-card-collection.est-possede {
  background: var(--emerald-600);
  border-color: var(--emerald-600);
  color: #ffffff;
}

.album-card-collection.est-possede:hover {
  border-color: var(--emerald-700);
  color: #ffffff;
}

.album-card-collection:disabled {
  opacity: 0.5;
  cursor: default;
}

.album-cover {
  flex-shrink: 0;
  width: 4rem;
  height: 6rem;
  border-radius: 0.5rem;
  background: var(--gold-100);
  color: var(--gold-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  object-fit: cover;
}

/*
 * Onglets de filtrage (collection par serie). Ils defilent horizontalement
 * plutot que de passer a la ligne : sur telephone, une collection etalee sur
 * dix series pousserait sinon la liste tres bas.
 */
.onglets {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding-bottom: 0.375rem;
  scrollbar-width: thin;
}

.onglet {
  flex: none;
  border: 1px solid var(--gold-300);
  border-radius: 999px;
  background: var(--white);
  padding: 0.375rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-700);
  cursor: pointer;
  white-space: nowrap;
}

.onglet:hover {
  background: var(--gold-50);
}

.onglet.est-actif {
  background: var(--gold-600);
  border-color: var(--gold-600);
  color: var(--white);
}

/* Barre de progression : avancement d'une serie, palier d'un succes. */

.jauge {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--ink-50);
  overflow: hidden;
}

.jauge-remplie {
  height: 100%;
  border-radius: 999px;
  background: var(--gold-500);
  transition: width 0.3s;
}

/* Un succes obtenu se distingue au liseré, pas a la couleur de fond : une
   grille de cartes dorees serait illisible. */
.succes-acquis {
  border-color: var(--gold-500);
}

/* Initiales, a defaut d'avatar : Duckdex n'en stocke pas. */
.pastille {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: var(--gold-100);
  color: var(--gold-700);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
}

/* Inversion du sens de tri : la fleche indique l'ordre en cours. */
.btn-sens {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--ink-100);
  border-radius: 0.5rem;
  background: var(--white);
  color: var(--ink-700);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.btn-sens:hover {
  border-color: var(--gold-500);
  color: var(--gold-700);
}

/* Format reduit, pour les listes en ligne (collection). */
.album-cover--vignette {
  width: 3.25rem;
  height: 4.5rem;
  font-size: 0.85rem;
}

/*
 * Cartouche affiche a defaut de couverture. Les scans de couvertures sont
 * sous droits et aucune source ne les distribue librement (voir la page
 * « A propos ») : plutot qu'un vide, on compose serie / numero / annee.
 * Tout est en em pour qu'un font-size inline suffise a changer d'echelle.
 */
.album-cover--empty {
  position: relative;
  flex-direction: column;
  gap: 0.15em;
  padding: 0.5em 0.35em;
  overflow: hidden;
  line-height: 1.1;
  text-align: center;
  background: var(--gold-50);
  box-shadow: inset 0 0 0 1px var(--cover-liseret);
}

/* Une tranche sur le bord gauche : le cartouche evoque un fascicule. */
.album-cover--empty::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0.3em;
  background: var(--gold-300);
}

.album-cover-series {
  font-family: var(--font-body, inherit);
  font-size: 0.42em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-600);
}

.album-cover-number {
  font-size: 1.35em;
  font-weight: 700;
  color: var(--gold-700);
}

.album-cover-year {
  font-family: var(--font-body, inherit);
  font-size: 0.4em;
  font-weight: 500;
  color: var(--ink-400);
}

/* Cinq teintes alternees pour qu'une grille de numeros ne soit pas uniforme. */
.album-cover--empty[data-shade="1"] { background: var(--gold-100); }
.album-cover--empty[data-shade="1"]::before { background: var(--gold-500); }
.album-cover--empty[data-shade="2"] { background: var(--ink-50); }
.album-cover--empty[data-shade="2"]::before { background: var(--gold-600); }
.album-cover--empty[data-shade="3"] { background: var(--white); }
.album-cover--empty[data-shade="3"]::before { background: var(--gold-300); }
.album-cover--empty[data-shade="4"] { background: var(--gold-50); }
.album-cover--empty[data-shade="4"]::before { background: var(--gold-600); }

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.badge-high {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border-color: var(--emerald-200);
}

.badge-mid {
  background: var(--gold-50);
  color: var(--gold-700);
  border-color: var(--gold-300);
}

.badge-low {
  background: var(--ink-50);
  color: var(--ink-400);
  border-color: var(--ink-100);
}

/* Forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--ink-700);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--ink-100);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--white);
  color: var(--ink-900);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold-500);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.checkbox-list {
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid var(--ink-100);
  border-radius: 0.5rem;
  padding: 0.5rem;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.875rem;
}

/* Lists */

.list {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: 1rem;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-top: 1px solid var(--ink-100);
}

.list-item:first-child {
  border-top: none;
}

/* Etats */

.error-box {
  background: var(--gold-50);
  border: 1px solid var(--gold-300);
  color: var(--gold-700);
  padding: 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
}

.error-text {
  color: var(--red-600);
  font-size: 0.875rem;
}

/* QR scanner */

#qr-reader {
  width: 100%;
  max-width: 24rem;
  aspect-ratio: 1;
  background: var(--ink-900);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
