/* ---------- Thèmes ---------- */
:root {
  --bg: #F5F2EB;
  --surface: #FFFFFF;
  --surface-2: #EDE9E0;
  --border: #E2DDD2;
  --text: #17151A;
  --text-2: #3D3A42;
  --muted: #5E5A63;
  --accent: #C8231E;
  --accent-hover: #A81B17;
  --on-accent: #FFFFFF;
  --signal: #F2B705;
  --topbar: rgb(245 242 235 / .78);
  --shadow: 0 18px 40px -18px rgb(23 21 26 / .35);

  --font: 'Archivo', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --radius: 18px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121115;
  --surface: #1C1B20;
  --surface-2: #26242B;
  --border: #2E2C33;
  --text: #F3F0EA;
  --text-2: #CFCAD3;
  --muted: #A39FA8;
  --accent: #FF5A4E;
  --accent-hover: #FF7A70;
  --on-accent: #17151A;
  --signal: #FFC933;
  --topbar: rgb(18 17 21 / .72);
  --shadow: 0 18px 40px -18px rgb(0 0 0 / .8);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none;
}
.skip:focus { top: 16px; }
kbd {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
}

/* ---------- Barre du haut (verre dépoli) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1360px; margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.brand__mark { width: 40px; height: 40px; }
.brand__ring {
  fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 95; stroke-dashoffset: 95;
  transform: rotate(-90deg); transform-origin: center;
  animation: draw 1s .1s var(--ease) forwards;
}
.brand__dot { fill: var(--accent); transform: scale(0); transform-origin: center; animation: pop .5s .7s var(--spring) forwards; }
.brand__text { display: flex; flex-direction: column; line-height: 1; }
.brand__name { font-weight: 850; font-stretch: 75%; font-size: 22px; text-transform: uppercase; letter-spacing: .01em; }
.brand__kana { font-family: 'Noto Sans JP', sans-serif; font-weight: 700; font-size: 10px; color: var(--accent); letter-spacing: .12em; margin-top: 4px; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { transform: scale(1); } }

.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search__icon {
  position: absolute; left: 14px; top: 50%; translate: 0 -50%;
  width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%; height: 44px;
  padding: 0 44px 0 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search__kbd { position: absolute; right: 14px; top: 50%; translate: 0 -50%; color: var(--muted); transition: opacity .15s; }
.search input:focus ~ .search__kbd, .search input:not(:placeholder-shown) ~ .search__kbd { opacity: 0; }

/* ---------- Toggle thème ---------- */
.theme-toggle { all: unset; cursor: pointer; border-radius: 999px; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-toggle__track {
  display: block; width: 64px; height: 36px; padding: 4px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  transition: background .4s;
}
.theme-toggle__thumb {
  position: relative; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); color: #D99A00;
  box-shadow: 0 2px 6px rgb(0 0 0 / .2);
  transition: transform .5s var(--spring), color .4s;
}
.theme-toggle:hover .theme-toggle__thumb { box-shadow: 0 2px 10px rgb(0 0 0 / .28); }
.theme-toggle:active .theme-toggle__thumb { width: 30px; }
.theme-toggle svg {
  position: absolute; width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  transition: transform .5s var(--spring), opacity .3s;
}
.icon-moon { opacity: 0; transform: rotate(-90deg) scale(.4); fill: currentColor; }
[data-theme="dark"] .theme-toggle__thumb { transform: translateX(28px); color: var(--signal); }
[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: none; }

::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-switching ::view-transition-old(root) { z-index: 1; }
.theme-switching ::view-transition-new(root) { z-index: 2; }

/* ---------- Une (bento) ---------- */
main { max-width: 1360px; margin: 0 auto; padding: 28px var(--gutter) 0; }
.hero {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(220px, auto) minmax(180px, auto);
}
.tile {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  padding: 24px; text-decoration: none; text-align: left;
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
a.tile:hover, button.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
a.tile:active, button.tile:active { transform: translateY(-1px) scale(.99); }

.tile--feature { grid-column: span 2; grid-row: span 2; padding: 0; min-height: 420px; background: #17151A; border: 0; color: #F7F4EE; }
.tile__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.tile--feature:hover .tile__img { transform: scale(1.04); }
.tile__scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / 0) 30%, rgb(0 0 0 / .82) 100%); }
.tile__content { position: relative; margin-top: auto; padding: 28px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.tile__title {
  font-size: clamp(30px, 3.6vw, 52px); font-weight: 850; font-stretch: 72%;
  line-height: .95; text-transform: uppercase; text-wrap: balance;
}

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
}
.tag--accent { background: var(--accent); color: var(--on-accent); }
.tile--feature .tag--accent { background: #C8231E; color: #FFFFFF; }

.cta { display: inline-flex; align-items: center; gap: 12px; font-weight: 700; }
.cta__icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: #FFFFFF; color: #17151A;
  transition: transform .35s var(--spring);
}
.cta__icon svg { width: 20px; height: 20px; fill: currentColor; margin-left: 2px; }
.tile--feature:hover .cta__icon { transform: scale(1.12); }

.tile--intro { grid-column: span 2; justify-content: space-between; gap: 18px; background: var(--text); color: var(--bg); border: 0; }
.tile--intro h1 { margin: 0; font-size: clamp(30px, 3.2vw, 46px); font-weight: 850; font-stretch: 75%; text-transform: uppercase; line-height: .95; text-wrap: balance; }
.tile--intro p { margin: 0; max-width: 46ch; color: color-mix(in srgb, var(--bg) 78%, var(--text)); }
.stats { margin: 0; display: flex; gap: 28px; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.stats dd { margin: 0; font-family: var(--mono); font-weight: 600; font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats div:first-child dd { color: #FF5A4E; }
[data-theme="dark"] .stats div:first-child dd { color: #C8231E; }

.tile--random { cursor: pointer; background: var(--signal); color: #17151A; border: 0; justify-content: flex-end; gap: 2px; font: inherit; }
.dice { position: absolute; top: 20px; right: 20px; width: 52px; height: 52px; fill: none; stroke: currentColor; stroke-width: 1.6; transition: transform .6s var(--spring); }
.dice .pip { fill: currentColor; stroke: none; }
.tile--random:hover .dice { transform: rotate(180deg); }
.tile--random.is-rolling .dice { animation: roll .6s var(--ease); }
@keyframes roll { 50% { transform: rotate(200deg) scale(.85); } 100% { transform: rotate(360deg); } }
.tile__label { font-size: 30px; font-weight: 850; font-stretch: 75%; text-transform: uppercase; line-height: 1; }
.tile__hint { font-size: 14px; font-weight: 600; opacity: .8; }

.tile--bonus { gap: 10px; }
.tile__small-title { font-size: 20px; font-weight: 800; font-stretch: 85%; text-transform: uppercase; line-height: 1.05; text-wrap: balance; }
.arrow-link { margin-top: auto; font-weight: 700; color: var(--accent); }
.arrow-link span { display: inline-block; transition: transform .25s var(--ease); }
.tile--bonus:hover .arrow-link span { transform: translateX(5px); }

/* ---------- Bibliothèque ---------- */
.library { padding: 64px 0 24px; }
.library__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.library__head h2 { margin: 0; font-size: clamp(32px, 4vw, 52px); font-weight: 850; font-stretch: 72%; text-transform: uppercase; line-height: 1; }
.library__count { margin: 0; font-family: var(--mono); font-size: 14px; color: var(--muted); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0 24px; }
.chips {
  position: relative; display: flex; gap: 4px; padding: 4px;
  border-radius: 999px; background: var(--surface-2);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips__indicator {
  position: absolute; top: 4px; left: 0; height: calc(100% - 8px); width: 0;
  border-radius: 999px; background: var(--text);
  transition: transform .45s var(--spring), width .45s var(--spring);
}
.chip {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-2);
  font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: color .3s;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { color: var(--bg); }
.chip__n { font-family: var(--mono); font-size: 12px; opacity: .7; }

.sort select {
  appearance: none; height: 44px; padding: 0 40px 0 16px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235E5A63' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
}

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* Carte vidéo */
.card {
  display: flex; flex-direction: column; height: 100%;
  text-decoration: none; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: transparent; }
.card:active { transform: translateY(-2px) scale(.985); }
.card__media { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease), opacity .4s; opacity: 0; }
.card__media img.is-loaded { opacity: 1; }
.card:hover .card__media img { transform: scale(1.06); }
.card__media::after { content: ""; position: absolute; inset: 0; background: rgb(0 0 0 / 0); transition: background .3s; }
.card:hover .card__media::after { background: rgb(0 0 0 / .32); }
.card__play {
  position: absolute; z-index: 1; left: 50%; top: 50%;
  width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  display: grid; place-items: center;
  background: #FFFFFF; color: #17151A;
  opacity: 0; transform: scale(.6);
  transition: transform .35s var(--spring), opacity .2s;
}
.card__play svg { width: 22px; height: 22px; fill: currentColor; margin-left: 3px; }
.card:hover .card__play, .card:focus-visible .card__play { opacity: 1; transform: scale(1); }
.card__badge {
  position: absolute; z-index: 1; left: 10px; top: 10px;
  font-family: var(--mono); font-weight: 600; font-size: 13px;
  padding: 4px 9px; border-radius: 999px;
  background: #C8231E; color: #FFFFFF;
}
.card__badge--retro { background: #17151A; color: #FFC933; }
.card__badge--patreon, .card__badge--special { background: #FFC933; color: #17151A; }
.card__watched {
  position: absolute; z-index: 1; right: 10px; top: 10px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: rgb(23 21 26 / .78); color: #F3F0EA;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.card__watched svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; }
.card__body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__series { margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.card__title {
  margin: 0; font-size: 19px; font-weight: 800; font-stretch: 80%;
  line-height: 1.08; text-transform: uppercase; text-wrap: balance;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card__title mark { background: color-mix(in srgb, var(--signal) 55%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.card--seen .card__title { color: var(--text-2); }

/* Apparition au scroll */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity .5s var(--ease), transform .6s var(--ease); transition-delay: var(--d, 0ms); }

.empty { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty__title { margin: 0 0 4px; font-size: 26px; font-weight: 850; font-stretch: 75%; text-transform: uppercase; color: var(--text); }
.empty p { margin: 0 0 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  transition: background .2s, transform .2s var(--spring);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.96); }
.btn--ghost { background: transparent; color: inherit; border: 1px solid rgb(255 255 255 / .25); }
.btn--ghost:hover { background: rgb(255 255 255 / .1); }

/* ---------- Pied de page ---------- */
.footer {
  max-width: 1360px; margin: 48px auto 0; padding: 28px var(--gutter) 48px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 12px 32px; flex-wrap: wrap;
  font-size: 14px; color: var(--muted);
}
.footer p { margin: 0; }
.footer a { color: var(--text); font-weight: 700; }
.footer a:hover { color: var(--accent); }
.footer__keys kbd { margin: 0 2px; }

/* ---------- Lecteur ---------- */
.player {
  width: min(1100px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 20px; overflow: hidden;
  background: #0D0C0F; color: #F3F0EA;
  box-shadow: 0 40px 120px rgb(0 0 0 / .6);
}
.player::backdrop { background: rgb(10 9 12 / .78); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.player[open] { animation: player-in .4s var(--ease); }
.player[open]::backdrop { animation: fade .3s ease; }
@keyframes player-in { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@keyframes fade { from { opacity: 0; } }
.player__frame { aspect-ratio: 16 / 9; background: #000; }
.player__frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.player__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; flex-wrap: wrap; }
.player__meta { min-width: 0; flex: 1 1 320px; }
.player__series { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #FF5A4E; }
.player__title { margin: 2px 0 0; font-size: 22px; font-weight: 850; font-stretch: 78%; text-transform: uppercase; line-height: 1.05; }
.player__actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgb(255 255 255 / .2); background: transparent; color: inherit; cursor: pointer;
  transition: background .2s, transform .2s var(--spring);
}
.icon-btn:hover { background: rgb(255 255 255 / .12); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.player .btn--ghost { min-height: 44px; }

.noscript { max-width: 600px; margin: 40px auto; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .hero { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
  .tile--feature { grid-column: span 2; grid-row: auto; min-height: 380px; }
  .tile--intro { grid-column: span 2; }
}
@media (max-width: 640px) {
  .topbar__inner { flex-wrap: wrap; gap: 12px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .theme-toggle { margin-left: auto; }
  .search__kbd { display: none; }
  .brand__name { font-size: 20px; }
  main { padding-top: 16px; }
  .hero { gap: 12px; }
  .tile { padding: 20px; }
  .tile--feature { min-height: 340px; }
  .tile__content { padding: 20px; }
  .stats { gap: 20px; }
  .stats dd { font-size: 28px; }
  .tile--random, .tile--bonus { min-height: 170px; }
  .tile__label { font-size: 24px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .sort select { width: 100%; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .footer__keys { display: none; }
  .player { width: 100vw; max-height: 100dvh; border-radius: 0; }
}
@media (hover: none) {
  .card__play { opacity: .92; transform: scale(.85); }
}

/* ---------- Animations réduites ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .reveal { opacity: 1; transform: none; }
  .card:hover, a.tile:hover, button.tile:hover { transform: none; }
}
