/* ==========================================================================
   NekoFlix — design system : tokens, thèmes, reset, typographie, boutons,
   champs, badges, états de chargement
   --------------------------------------------------------------------------
   Breakpoints (référence, utilisés dans les media queries) :
     xs 480 · sm 768 · md 1024 · lg 1280 · xl 1440 · 2xl 1920
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Fonds & surfaces — thème « Sombre » (par défaut) */
  /* Noir franc + gris neutres (style plateforme de streaming, sans teinte bleutée) */
  /* Fond très sombre et neutre, façon PopcornVF */
  --bg: #0f0f11;           --bg-rgb: 15, 15, 17;
  --bg-2: #0a0a0b;
  --surface: #18181b;
  --surface-2: #232327;
  --surface-3: #2e2e33;
  --elevated: #1e1e22;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .16);
  --overlay: rgba(0, 0, 0, .8);

  /* Texte */
  --text: #ffffff;
  --text-2: #b8b8be;
  --text-3: #8a8a92;
  --text-off: #55555c;
  --on-accent: #ffffff;

  /* Accent NekoFlix : orange (celui du logo), personnalisable dans le profil */
  --accent: #ff6b1a;       --accent-rgb: 255, 107, 26;
  --accent-hover: #ff8233;
  --accent-press: #e85a0c;
  --accent-text: #ffa15c;
  --accent-soft: rgba(var(--accent-rgb), .14);
  --focus: rgba(var(--accent-rgb), .75);

  /* États */
  --success: #34d399;  --success-soft: rgba(52, 211, 153, .14);
  --warning: #fbbf24;  --warning-soft: rgba(251, 191, 36, .14);
  --error: #f87171;    --error-soft: rgba(248, 113, 113, .14);
  --gold: #f5c451;
  --k-anime: #6ee7b7; --k-film: #fca5a5; --k-serie: #93c5fd;

  /* Espacements */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px; --s-10: 72px;
  --gutter: clamp(16px, 4vw, 56px);

  /* Rayons */
  /* Coins presque droits : look « plateforme », pas « appli générée » */
  /* Coins arrondis généreux (cartes, une, boutons en pilule) */
  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  /* Ombres (très légères) */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 6px 16px rgba(0, 0, 0, .6);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .7);

  /* Typographie */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-display: clamp(28px, 3vw, 44px);
  --fs-h1: clamp(24px, 2.2vw, 32px);
  --fs-h2: clamp(18px, 1.45vw, 22px);
  --fs-h3: 17px;
  --fs-body: 15px;
  --fs-small: 13.5px;
  --fs-caption: 12px;

  /* Mouvement */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 160ms;
  --dur-2: 280ms;

  /* Mise en page */
  --header-h: 68px;
  --bottom-h: 0px;
  --card-w: clamp(132px, 11.4vw, 186px);
  --grid-min: clamp(128px, 11vw, 178px);
  --row-gap: 14px;
}

/* Thème « Nuit chaude » (clé historique « violet ») : fonds légèrement ambrés */
html[data-theme="violet"] {
  --bg: #120d0a;  --bg-rgb: 18, 13, 10;
  --bg-2: #18110d;
  --surface: #1f1712;
  --surface-2: #2a1f18;
  --surface-3: #3a2b21;
  --elevated: #2a1f18;
  --line: rgba(255, 200, 160, .09);
  --line-2: rgba(255, 200, 160, .16);
  --text-2: #c8b5a6;
  --text-3: #95806f;
  --text-off: #6b584a;
}
/* Thème clair */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6fa;  --bg-rgb: 246, 246, 250;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #eeeef4;
  --surface-3: #e2e2eb;
  --elevated: #ffffff;
  --line: rgba(16, 16, 32, .08);
  --line-2: rgba(16, 16, 32, .15);
  --overlay: rgba(20, 20, 30, .55);
  --text: #15151d;
  --text-2: #55556a;
  --text-3: #85859a;
  --text-off: #b2b2c2;
  --accent-text: #c2410c;
  --shadow-2: 0 10px 30px rgba(20, 20, 40, .1);
  --shadow-3: 0 28px 70px rgba(20, 20, 40, .18);
}

/* Couleurs d'accent (profil) */
html[data-accent="mauve"] { --accent: #8b5cf6; --accent-rgb: 139, 92, 246; --accent-hover: #9d76f8; --accent-press: #7845e8; --accent-text: #bba3ff; }
html[data-accent="indigo"] { --accent: #6366f1; --accent-rgb: 99, 102, 241; --accent-hover: #7c7ff4; --accent-press: #4f46e5; --accent-text: #a5b4fc; }
html[data-accent="rose"] { --accent: #ec4899; --accent-rgb: 236, 72, 153; --accent-hover: #f06bab; --accent-press: #db2777; --accent-text: #f9a8d4; }
html[data-accent="bleu"] { --accent: #3b82f6; --accent-rgb: 59, 130, 246; --accent-hover: #5b97f7; --accent-press: #2563eb; --accent-text: #93c5fd; }
html[data-accent="emeraude"] { --accent: #10b981; --accent-rgb: 16, 185, 129; --accent-hover: #2fc896; --accent-press: #059669; --accent-text: #6ee7b7; }
html[data-accent="ambre"] { --accent: #f59e0b; --accent-rgb: 245, 158, 11; --accent-hover: #f7b03a; --accent-press: #d97706; --accent-text: #fcd34d; --on-accent: #1c1305; }
html[data-theme="light"][data-accent] { --accent-text: var(--accent-press); }

/* Densité compacte */
html[data-density="compacte"] {
  --card-w: clamp(118px, 9.6vw, 156px);
  --grid-min: clamp(112px, 9.4vw, 150px);
  --row-gap: 10px;
}
/* Animations désactivées par l'utilisateur */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden;
  background: var(--bg); color: var(--text);
  font: 400 var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
body.no-scroll { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
[hidden] { display: none !important; }
::selection { background: rgba(var(--accent-rgb), .35); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid var(--bg); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 900; padding: 10px 14px; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); font-weight: 600; transform: translateY(-180%); transition: transform var(--dur) var(--ease); }
.skip-link:focus { transform: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Typographie ───────────────────────────────────────────────────────── */
.t-display, .t-h1, .t-h2, .t-h3, .row-title, .hero-title, .brand, .pf-id h1, .detail-title, .ftile-name, .card-rank { font-family: var(--font-display); }
.t-display { font-size: var(--fs-display); font-weight: 800; line-height: 1.08; letter-spacing: -.025em; }
.t-h1 { font-size: var(--fs-h1); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.t-h2 { font-size: var(--fs-h2); font-weight: 700; line-height: 1.25; }
.t-h3 { font-size: var(--fs-h3); font-weight: 600; line-height: 1.3; }
.t-small { font-size: var(--fs-small); }
.t-caption { font-size: var(--fs-caption); color: var(--text-3); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.kicker { font-size: 13px; font-weight: 600; color: var(--text-3); }
.clamp-1, .clamp-2, .clamp-3, .clamp-4 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; } .clamp-2 { -webkit-line-clamp: 2; } .clamp-3 { -webkit-line-clamp: 3; } .clamp-4 { -webkit-line-clamp: 4; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link { color: var(--accent-text); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Boutons ───────────────────────────────────────────────────────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: 8px; border: 0;
  font-size: 15px; font-weight: 700; line-height: 1; letter-spacing: -.005em; white-space: nowrap; user-select: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { flex: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-press); }
.btn-secondary { background: rgba(120, 120, 128, .38); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: rgba(120, 120, 128, .55); }
html[data-theme="light"] .btn-secondary { background: rgba(0, 0, 0, .08); color: var(--text); }
/* Bouton « Lecture » blanc (une, fiche) : le repère visuel des plateformes de streaming */
.btn-play { background: #fff; color: #0b0b0d; }
.btn-play:hover:not(:disabled) { background: rgba(255, 255, 255, .82); }
html[data-theme="light"] .btn-secondary { background: rgba(255, 255, 255, .8); }
html[data-theme="light"] .btn-secondary:hover:not(:disabled) { background: #fff; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.btn-danger { background: var(--error-soft); color: var(--error); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, .22); }
.btn-lg { height: 48px; padding: 0 26px; font-size: 15px; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 11px; font-size: 12px; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-lg { width: 48px; } .btn-icon.btn-sm { width: 34px; }
.btn[aria-pressed="true"].btn-secondary { color: var(--accent-text); border-color: rgba(var(--accent-rgb), .55); background: var(--accent-soft); }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text-2) var(--text-2) var(--text-2) transparent; animation: spin .7s linear infinite; }
.btn-primary.is-loading::after { border-color: #fff #fff #fff transparent; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--r-pill); color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
html[data-theme="light"] .icon-btn:hover { background: rgba(0, 0, 0, .05); }
.icon-btn.is-active { color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.sm { width: 32px; height: 32px; } .icon-btn.sm svg { width: 16px; height: 16px; }

.link-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: var(--fs-small); font-weight: 600; transition: color var(--dur) var(--ease); }
.link-btn:hover { color: var(--text); }
.link-btn svg { transition: transform var(--dur) var(--ease); }
.link-btn:hover svg { transform: translateX(2px); }

/* ── Badges, chips, segmenté ───────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .1); color: var(--text); font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; }
html[data-theme="light"] .badge { background: var(--surface-2); }
.badge-accent { background: var(--accent); color: var(--on-accent); }
.badge-outline { background: transparent; border: 1px solid var(--line-2); color: var(--text-2); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-error { background: var(--error-soft); color: var(--error); }
a.badge:hover, button.badge:hover { border-color: var(--text-3); color: var(--text); }
.kdot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--text-3); }
.kdot.anime { background: var(--k-anime); } .kdot.film { background: var(--k-film); } .kdot.serie { background: var(--k-serie); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid transparent; background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-small); font-weight: 600; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip:hover { color: var(--text); background: var(--surface-3); }
.chip[aria-pressed="true"], .chip[aria-current="page"], .chip.is-active { background: var(--accent); color: var(--on-accent); }
.chip .count { opacity: .6; font-weight: 500; }
.chip.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }

.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface); }
.segmented button { height: 32px; padding: 0 16px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; color: var(--text-2); white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
html[data-theme="light"] .segmented button[aria-pressed="true"] { background: #fff; }

/* ── Champs ────────────────────────────────────────────────────────────── */
.field, .select, textarea.field {
  width: 100%; height: 42px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.field { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.field::placeholder { color: var(--text-3); }
.field:focus, .select:focus, textarea.field:focus { outline: none; border-color: rgba(var(--accent-rgb), .7); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
.select {
  width: auto; min-width: 160px; padding-right: 36px; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3a3b3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.select.sm { height: 34px; min-width: 120px; font-size: 13px; }
.select:disabled { opacity: .5; cursor: not-allowed; }
.select option { background: var(--surface); color: var(--text); }
.label { display: block; margin-bottom: 6px; font-size: var(--fs-small); font-weight: 600; color: var(--text-2); }
.help { margin-top: 6px; font-size: var(--fs-caption); color: var(--text-3); }
.form-row { margin-bottom: var(--s-5); }

/* Interrupteur */
.switch { position: relative; display: inline-flex; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background var(--dur) var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: .4; }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--line-2); font: 600 11.5px/1 var(--font); color: var(--text-3); }

/* ── Chargement ────────────────────────────────────────────────────────── */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent); transform: translateX(-100%); animation: shimmer 1.3s ease-in-out infinite; }
html[data-theme="light"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); }
.skel-line { height: 12px; margin-top: 10px; border-radius: 4px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.appear { animation: fade-up .35s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
.field-group { margin-bottom: 18px; }
.field-group:last-child { margin-bottom: 0; }
