/* Palette : un ciel de fond peint (haikei) et les papiers de correction de l'animation. */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-standard.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --nuit: #123540;
  --creux: #0c2730;
  --relief: #194652;
  --trait: #3d6f78;
  --papier: #eef4e8;
  --brume: #a9c6c1;
  --jaune: #ffd65c;
  --menthe: #8ee0b0;
  --azur: #8fcbff;
  --sable: #d8cfa8;
  --rose: #ffa3b5;
  --marge: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--nuit);
  color: var(--papier);
  font:
    400 1rem/1.45 "Archivo",
    system-ui,
    sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: anywhere;
}

body:has(dialog[open]) {
  overflow: hidden;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

h1,
h2,
h3,
strong {
  font-stretch: 68%;
  font-weight: 750;
}

h2 {
  font-size: 1.3rem;
  line-height: 1.15;
}

h3 {
  font-size: 1.15rem;
  margin-top: 28px;
}

a {
  color: var(--azur);
}

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

.cache {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Ciel --- */

.ciel {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  height: calc(168px + env(safe-area-inset-top));
  padding: calc(18px + env(safe-area-inset-top)) var(--marge) 0;
  background: #1b5361 url("/img/ciel.svg") center bottom / cover no-repeat;
}

.ciel-texte {
  text-shadow: 0 1px 10px #0c2730cc;
}

.ciel h1 {
  font-stretch: 62%;
  font-weight: 850;
  font-size: clamp(2.4rem, 12.5vw, 3rem);
  line-height: 0.95;
}

#resume {
  margin-top: 6px;
  max-width: 15rem;
  font-size: 0.9rem;
}

.bouton-ciel {
  flex: none;
  white-space: nowrap;
  min-height: 40px;
  padding: 0 14px;
  border: 1.5px solid var(--papier);
  border-radius: 20px;
  background: #0c2730b3;
  color: var(--papier);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

/* --- Champs et boutons --- */

label,
legend {
  display: block;
  font-size: 0.9rem;
  color: var(--brume);
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1.5px solid var(--trait);
  border-radius: 6px;
  background: var(--creux);
  color: var(--papier);
  font: inherit;
  font-size: 1rem;
}

label > input,
label > select,
label > textarea {
  margin-top: 5px;
}

textarea {
  resize: vertical;
}

::placeholder {
  color: #7fa3a2;
}

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 18px;
  border: 1.5px solid var(--papier);
  border-radius: 6px;
  background: transparent;
  color: var(--papier);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.bouton.principal {
  border-color: var(--jaune);
  background: var(--jaune);
  color: var(--creux);
}

.bouton.clair {
  background: var(--papier);
  color: var(--creux);
}

.bouton.danger {
  border-color: var(--rose);
  color: var(--rose);
}

.bouton.discret {
  min-height: 40px;
  border-color: var(--trait);
  font-weight: 400;
  font-size: 0.9rem;
}

.bouton.large {
  width: 100%;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.erreur {
  color: var(--rose);
}

.erreur:empty,
.alerte:empty,
.etat:empty {
  display: none;
}

/* --- Installation et connexion --- */

.porte {
  max-width: 420px;
  margin: 0 auto;
  padding: 28px var(--marge) 48px;
}

.porte h2 {
  margin-bottom: 16px;
  font-size: 1.8rem;
}

form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

/* --- Outils de la liste --- */

#ecran-liste {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px var(--marge) calc(104px + env(safe-area-inset-bottom));
}

.outils {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  max-width: 640px;
}

.statuts {
  display: flex;
  gap: 6px;
  margin: 0 calc(-1 * var(--marge));
  padding: 3px var(--marge);
  overflow-x: auto;
  scrollbar-width: none;
}

.statuts button {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 3px solid var(--accent, var(--papier));
  border-radius: 4px 4px 0 0;
  background: var(--creux);
  color: var(--papier);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.statuts button span {
  font-stretch: 70%;
  font-weight: 700;
  color: var(--brume);
}

.statuts button[aria-pressed="true"] {
  background: var(--accent, var(--papier));
  color: var(--creux);
  font-weight: 650;
}

.statuts button[aria-pressed="true"] span {
  color: inherit;
}

.reglage-liste,
.duo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.reglage-liste select {
  min-height: 40px;
  padding: 6px 10px;
  margin: 0;
  font-size: 0.9rem;
}

[data-statut="en_cours"] {
  --accent: var(--jaune);
}

[data-statut="termine"] {
  --accent: var(--menthe);
}

[data-statut="a_voir"] {
  --accent: var(--azur);
}

[data-statut="en_pause"] {
  --accent: var(--sable);
}

[data-statut="abandonne"] {
  --accent: var(--rose);
}

/* --- La liste --- */

.liste {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
  column-gap: 32px;
  margin-top: 6px;
}

.anime {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 66px;
  grid-template-rows: 1fr auto;
  column-gap: 12px;
  padding-top: 18px;
}

.affiche {
  align-self: start;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.affiche-image {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 108px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--teinte, var(--relief));
}

.affiche-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.initiale {
  padding: 0 6px;
  border-radius: 3px;
  background: var(--creux);
  color: var(--papier);
  font-stretch: 62%;
  font-weight: 850;
  font-size: 2.2rem;
  line-height: 1.25;
}

.infos {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.titre {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: var(--papier);
  font: inherit;
  line-height: 1.12;
  text-align: left;
  cursor: pointer;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  font-size: 0.85rem;
  color: var(--brume);
}

.statut {
  color: var(--accent);
  font-weight: 650;
}

.avis {
  font-size: 0.85rem;
  color: var(--brume);
}

.commentaire {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  font-style: italic;
}

.compteur {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--brume);
  font-variant-numeric: tabular-nums;
}

.compteur strong {
  color: var(--papier);
  font-size: 1.7rem;
  line-height: 1;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.plus,
.note-grande {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 66px;
  padding: 0;
  border-radius: 50%;
  font: inherit;
  cursor: pointer;
}

.plus {
  border: 0;
  background: var(--jaune);
  color: var(--creux);
  font-stretch: 66%;
  font-weight: 850;
  font-size: 1.85rem;
  box-shadow: 0 4px 0 #a98a2b;
}

.plus:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a98a2b;
}

.note-grande {
  border: 2px solid var(--menthe);
  background: none;
  color: var(--menthe);
  line-height: 1;
}

.note-grande strong {
  font-size: 1.7rem;
}

.note-grande small {
  font-size: 0.65rem;
}

.note-grande.a-noter {
  border-style: dashed;
  font-size: 0.9rem;
}

.moins {
  width: 66px;
  min-height: 36px;
  border: 1.5px solid var(--trait);
  border-radius: 18px;
  background: none;
  color: var(--brume);
  font: inherit;
  cursor: pointer;
}

/* La bande : une case par épisode, comme une pellicule. Elle sépare aussi les titres. */

.bande {
  grid-column: 1 / -1;
  display: flex;
  gap: 2px;
  height: 9px;
  margin-top: 14px;
}

.bande-cases span {
  flex: 1;
  min-width: 0;
  background: var(--relief);
}

.bande-cases .vue,
.bande-barre span {
  background: var(--accent);
}

.bande-barre {
  position: relative;
  background: var(--relief);
}

.bande-barre::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 7px, var(--nuit) 7px 9px);
}

.bande-inconnu {
  background: repeating-linear-gradient(
    90deg,
    var(--relief) 0 14px,
    transparent 14px 18px
  );
}

.avance .derniere {
  animation: impression 0.45s ease-out;
}

@keyframes impression {
  from {
    background: var(--papier);
    transform: scaleY(2.4);
  }
}

.vide {
  display: grid;
  justify-items: start;
  gap: 14px;
  max-width: 30rem;
  padding: 36px 0;
  color: var(--brume);
}

/* --- Barre du bas --- */

.barre {
  position: fixed;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px var(--marge) calc(12px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--trait);
  background: var(--creux);
}

.barre .bouton {
  padding-inline: 12px;
}

@media (min-width: 640px) {
  .barre {
    padding-inline: calc(50% - 280px);
  }
}

.toast {
  position: fixed;
  z-index: 5;
  left: var(--marge);
  right: var(--marge);
  bottom: calc(86px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 10px 10px 16px;
  border-radius: 8px;
  background: var(--papier);
  color: var(--creux);
  box-shadow: 0 8px 24px #04141a80;
}

.toast button {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--creux);
  color: var(--jaune);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* --- Feuilles (dialogues) --- */

dialog {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0 var(--marge) calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-top: 5px solid var(--jaune);
  border-radius: 14px 14px 0 0;
  background: var(--nuit);
  color: var(--papier);
}

@media (min-width: 640px) {
  dialog {
    margin: auto;
    border-radius: 14px;
  }
}

dialog::backdrop {
  background: #04141ac7;
}

.feuille-tete {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px 0 8px;
  background: var(--nuit);
}

.feuille-tete h2 {
  font-size: 1.6rem;
}

.fermer {
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--brume);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

dialog h3 {
  margin-bottom: 8px;
}

dialog p {
  margin-bottom: 10px;
}

dialog form p {
  margin-bottom: 0;
}

.trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  margin-bottom: 6px;
  padding: 0;
}

.notes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.notes label {
  position: relative;
}

.notes input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.notes span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1.5px solid var(--trait);
  border-radius: 6px;
  background: var(--creux);
  color: var(--papier);
  font-stretch: 75%;
  font-weight: 700;
  pointer-events: none;
}

.notes input:checked + span {
  border-color: var(--jaune);
  background: var(--jaune);
  color: var(--creux);
}

.notes input:focus-visible + span {
  outline: 3px solid var(--jaune);
  outline-offset: 2px;
}

.coche {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--papier);
}

.coche input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--jaune);
}

.source {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--brume);
}

.ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.etat {
  margin-top: 10px;
  color: var(--brume);
}

.choix {
  margin: 8px 0 16px;
}

.choix button {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 1.5px solid var(--relief);
  background: none;
  color: var(--papier);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.choix .affiche-image {
  flex: none;
  width: 52px;
  height: 74px;
}

.choix-texte {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--brume);
}

.choix-texte strong {
  color: var(--papier);
  font-size: 1.1rem;
}

progress {
  width: 100%;
  margin: 8px 0 20px;
  accent-color: var(--jaune);
}

.correspondances li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1.5px solid var(--relief);
}

.correspondances .affiche-image {
  width: 46px;
  height: 66px;
}

.correspondances .initiale {
  font-size: 1.4rem;
}

.correspondances select {
  min-height: 40px;
  margin-top: 4px;
  padding: 6px 8px;
  font-size: 0.9rem;
}

.alerte {
  font-size: 0.85rem;
  color: var(--jaune);
}

.collant {
  position: sticky;
  bottom: 0;
  box-shadow:
    0 0 0 16px var(--nuit),
    0 32px 0 16px var(--nuit);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
