/* ==========================================================================
   Mellon — feuille de style
   Organisation calquée sur une structure Sass (abstracts / base / layout /
   components), en CSS pur pour rester sans build. Nommage BEM léger.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Abstracts — variables (thème sombre par défaut)
   -------------------------------------------------------------------------- */
:root {
  --bg: #14141b;
  --bg-glow: #2a2440;
  --surface: #1d1d27;
  --surface-2: #262633;
  --text: #f0f0f5;
  --text-muted: #9a9aa8;
  --accent: #a29bfe;
  --accent-2: #ff7edb;
  --border: #2c2c38;
  --shadow: 0 18px 36px -18px rgba(0, 0, 0, 0.6);

  --radius: 14px;
  --gap: 1.5rem;
  --font-title: "Poppins", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  color-scheme: dark;
}

/* Thème clair : suit le système, sauf si l'utilisateur a forcé le sombre avec le bouton */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f5f8;
    --bg-glow: #e6e1ff;
    --surface: #ffffff;
    --surface-2: #f0eff6;
    --text: #1a1a22;
    --text-muted: #5c5c6a;
    --accent: #6c5ce7;
    --accent-2: #d6336c;
    --border: #e2e1ea;
    --shadow: 0 18px 36px -20px rgba(40, 30, 90, 0.35);
    color-scheme: light;
  }
}

/* Thème clair forcé avec le bouton */
:root[data-theme="light"] {
  --bg: #f5f5f8;
  --bg-glow: #e6e1ff;
  --surface: #ffffff;
  --surface-2: #f0eff6;
  --text: #1a1a22;
  --text-muted: #5c5c6a;
  --accent: #6c5ce7;
  --accent-2: #d6336c;
  --border: #e2e1ea;
  --shadow: 0 18px 36px -20px rgba(40, 30, 90, 0.35);
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  /* Les ancres (#apps…) s'arrêtent sous la barre collante au lieu d'être cachées dessous */
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.5;
  color: var(--text);
  background: radial-gradient(circle at 15% -5%, var(--bg-glow) 0%, transparent 40%), var(--bg);
  background-attachment: fixed;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

svg {
  flex-shrink: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  z-index: 100;
}

.skip-link:focus {
  top: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* --------------------------------------------------------------------------
   Layout — hero, barre d'outils, contenu, footer
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  padding: 4.5rem 1.5rem 3rem;
}

/* La carte à gauche, le titre à droite. space-evenly met le même vide à gauche de la carte,
   entre les deux, et à droite du titre : chacun est centré dans l'espace qu'il occupe */
.hero__inner {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 2rem;
  max-width: calc(1200px - 3rem); /* aligné sur .content, marges intérieures déduites */
  margin: 0 auto;
}

/* Mêmes dimensions que .hero__photo dans cvOnline */
.hero__skills .card {
  width: 200px;
  aspect-ratio: 4 / 5;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(120deg, var(--accent), var(--accent-2)) border-box;
}

.hero__skills .card__thumb {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}

.hero__skills .card__body {
  flex: none;
  gap: 0.1rem;
  padding: 0.75rem 1rem 0.85rem;
}

.hero__skills .card__title {
  font-size: 1rem;
}

.hero__skills .card__links {
  font-size: 0.8rem;
}

.hero__content {
  min-width: 0;
  text-align: center;
}

.hero__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.hero__tengwar {
  width: min(100%, 340px);
  height: auto;
}

.hero__name {
  font-family: var(--font-title);
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.1;
  letter-spacing: 0.35em;
  margin-right: -0.35em; /* l'espacement ajouté après la dernière lettre décentrerait le mot */
}

.hero__tagline {
  margin: 0 auto;
  max-width: 40ch;
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .hero__inner {
    flex-direction: column;
  }

  .hero__skills .card {
    width: 160px;
    margin-inline: auto;
  }

  .hero__skills .card__body {
    padding: 0.5rem 0.75rem 0.65rem;
  }
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-block: 1px solid var(--border);
}

.toolbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar__nav {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar__nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
}

.toolbar__nav a:hover,
.toolbar__nav a.is-active {
  color: var(--text);
  background: var(--surface-2);
}

.count:not(:empty) {
  font-size: 0.75rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  display: grid;
  gap: 3.5rem;
}

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer p {
  margin: 0;
}

.footer__top {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Components — boutons, recherche, catégories, cartes
   -------------------------------------------------------------------------- */

/* Pastilles (liens des plateformes, onglets du lecteur) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}

.pill svg {
  width: 18px;
  height: 18px;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* Bouton de thème */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Sombre affiché → icône soleil (pour passer au clair), et inversement */
.theme-toggle__icon--moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle__icon--sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle__icon--moon {
  display: block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle__icon--sun {
    display: none;
  }

  :root:not([data-theme="dark"]) .theme-toggle__icon--moon {
    display: block;
  }
}

/* Recherche */
.search {
  position: relative;
  margin-left: auto;
  flex: 0 1 260px;
}

.search svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 0.5rem 0.9rem 0.5rem 2.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 640px) {
  /* La barre collante fait deux lignes sur mobile */
  html {
    scroll-padding-top: 8.5rem;
  }

  .search {
    flex-basis: 100%;
  }
}

/* Catégories */
.category[hidden] {
  display: none;
}

.category__title {
  margin: 0 0 1.5rem;
  font-family: var(--font-title);
  font-size: 1.45rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Petit trait dégradé à gauche plutôt qu'un soulignement pleine largeur */
.category__title::before {
  content: "";
  align-self: center;
  width: 6px;
  height: 1.2em;
  border-radius: 3px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

.category__title small {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

.no-result {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

/* Grilles de cartes
   flex-wrap + justify-content: center → une dernière ligne incomplète reste centrée.
   --card-w fixe la largeur de base de chaque carte selon la variante. */
.cards {
  --card-w: 340px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

.cards > .card {
  flex: 0 1 min(100%, var(--card-w));
}

.cards--compact {
  --card-w: 260px;
}

.cards--wide > .card {
  flex-basis: 100%;
}

.cards__status {
  color: var(--text-muted);
  font-style: italic;
}

/* Carte */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover,
.card:focus-within {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.card[hidden] {
  display: none;
}

/* Vignette : l'image se pose par-dessus un fond de secours (dégradé + initiales)
   → si la capture échoue, le fond reste visible et toutes les cartes gardent la même hauteur */
.card__thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, hsl(var(--hue, 250) 55% 35%), hsl(calc(var(--hue, 250) + 60) 60% 22%));
  overflow: hidden;
}

.card__initials {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 2.4rem;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em;
}

.card__thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  opacity: 0;
  transition: opacity 0.4s ease, scale 0.4s ease;
}

.card__thumb img.is-loaded {
  opacity: 1;
}

.card:hover .card__thumb img {
  scale: 1.04;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
  padding: 1.1rem 1.25rem 1.25rem;
}

.card__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.1rem;
}

/* Lien "étiré" : tout la carte est cliquable, sans imbriquer de <a> */
.card__title a {
  text-decoration: none;
}

.card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card__title a:focus-visible {
  outline: none;
}

.card__desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-grow: 1;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card__tags li {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

/* Liens secondaires (carte à plusieurs liens) : au-dessus du lien étiré */
.card__links a {
  position: relative;
  z-index: 1;
  text-decoration: none;
}

.card__links a:hover {
  text-decoration: underline;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Variante compacte (GitHub, archives) : vignette plus basse, texte plus serré */
.cards--compact .card__thumb {
  aspect-ratio: 16 / 8;
}

.cards--compact .card__initials {
  font-size: 1.8rem;
}

.cards--compact .card__body {
  padding: 0.9rem 1rem 1rem;
}

.cards--compact .card__title {
  font-size: 1rem;
}

.cards--compact .card__desc {
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Variante large (vitrine pro) : vignette à gauche, texte à droite */
@media (min-width: 760px) {
  .cards--wide .card {
    flex-direction: row;
  }

  .cards--wide .card__thumb {
    flex: 0 0 45%;
    aspect-ratio: auto;
    min-height: 260px;
  }

  .cards--wide .card__body {
    justify-content: center;
    padding: 2rem 2.25rem;
  }

  .cards--wide .card__title {
    font-size: 1.5rem;
  }

  .cards--wide .card__desc {
    flex-grow: 0;
    font-size: 1rem;
  }
}

/* Section Laindle : liens des plateformes */
.platforms {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: var(--gap) 0;
  padding: 0;
  list-style: none;
}

#laindle .card__thumb img {
  object-position: center;
}

/* Section Laindle : lecteur de playlists (liste à gauche, lecteur à droite) */
.playlists {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.playlists__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.playlists__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.1rem;
}

.playlists__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button.pill {
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

button.pill:hover,
button.pill[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.playlists__list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.playlist {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.4rem;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.playlist:hover,
.playlist[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.playlist:focus-visible {
  outline-offset: -2px;
}

.playlist__cover {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(135deg, hsl(var(--hue, 250) 55% 35%), hsl(calc(var(--hue, 250) + 60) 60% 22%));
}

.playlist__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.playlist__title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.playlists__more {
  padding: 0.5rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.playlists__more a {
  color: var(--accent);
  text-decoration: none;
}

.playlists__more a:hover {
  text-decoration: underline;
}

.playlists__player {
  display: grid;
  height: 400px;
}

/* YouTube est une vidéo : format 16/9 sur petit écran */
.playlists__player[data-service="youtube"] {
  height: auto;
  aspect-ratio: 16 / 9;
}

.playlists__player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color-scheme: normal;
}

.playlists__empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.25rem;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.playlists__empty > svg {
  width: 64px;
  height: 64px;
}

@media (min-width: 760px) {
  .playlists {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .playlists__head {
    grid-column: 1 / -1;
  }

  /* Hauteur fixe commune : la page ne saute pas en changeant d'onglet */
  .playlists__list {
    height: 440px;
    max-height: none;
  }

  .playlists__player,
  .playlists__player[data-service="youtube"] {
    height: 440px;
    aspect-ratio: auto;
  }
}
