/* ==========================================================================
   NekoFlix — mise en page : header, panneaux, navigation mobile, annonces,
   pages, rangées, grilles, footer
   ========================================================================== */

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header { position: fixed; inset: 0 0 auto 0; z-index: 70; height: var(--header-h); transition: background .35s ease, box-shadow .35s ease; }
/* Transparente sur l'image (accueil, fiche), pleine dès qu'on défile */
.site-header::before { content: ""; position: absolute; inset: 0 0 -30px; z-index: -1; pointer-events: none; background: linear-gradient(180deg, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .35) 60%, rgba(0, 0, 0, 0) 100%); transition: opacity .35s ease; }
.site-header.is-solid { background: rgba(var(--bg-rgb), .97); box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 8px 24px rgba(0, 0, 0, .35); }
.site-header.is-solid::before { opacity: 0; }
html[data-theme="light"] .site-header.is-solid { background: rgba(255, 255, 255, .97); }
.header-inner { height: 100%; display: flex; align-items: center; gap: 28px; padding: 0 var(--gutter); }
.brand { display: inline-flex; align-items: center; gap: 8px; flex: none; font-size: 21px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.brand img { width: 30px; height: 30px; object-fit: contain; }
.brand b { font-weight: 800; color: var(--accent-text); }
.main-nav { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav-link { position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 10px; font-size: 14.5px; font-weight: 500; color: rgba(255, 255, 255, .72); white-space: nowrap; transition: color .2s ease; }
html[data-theme="light"] .nav-link { color: var(--text-2); }
.nav-link:hover { color: var(--text); }
.nav-link[aria-current="page"] { color: var(--text); font-weight: 700; }
.nav-link[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.header-actions .icon-btn { color: var(--text); }

/* Recherche du header + suggestions */
.hsearch { position: relative; margin-right: 6px; }
.hsearch-box { display: flex; align-items: center; gap: 8px; width: 40px; height: 38px; padding: 0 10px; border-radius: 6px; border: 1px solid transparent; color: var(--text); cursor: pointer; overflow: hidden; transition: width .3s var(--ease), background .2s ease, border-color .2s ease; }
.hsearch-box svg { flex: none; }
.hsearch-box:hover { background: rgba(255, 255, 255, .08); }
.hsearch-box:focus-within { width: 290px; cursor: text; background: rgba(0, 0, 0, .75); border-color: rgba(255, 255, 255, .35); }
html[data-theme="light"] .hsearch-box:focus-within { background: #fff; border-color: var(--line-2); }
.hsearch-box input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font-size: 14px; }
.hsearch-box input::placeholder { color: rgba(255, 255, 255, .5); }
.hsearch-box input::-webkit-search-cancel-button { display: none; }
.hsearch-box kbd { display: none; }
.search-btn, .mobile-only { display: none; }

/* Panneaux déroulants (suggestions, notifications, compte) */
.panel {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 90; width: 400px; max-width: calc(100vw - 24px);
  border-radius: 10px; background: rgba(20, 20, 23, .98); border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 24px 60px rgba(0, 0, 0, .65);
  animation: pop-in .16s var(--ease) both; transform-origin: top right; overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.panel-head h2 { font-size: 16px; font-weight: 700; }
.panel-head .link-btn { color: var(--accent-text); font-size: 12.5px; }
.panel-body { max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; }
.panel-foot { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .08); text-align: center; }
.panel-label { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px; font-size: var(--fs-caption); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.sg-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border-radius: var(--r); text-align: left; transition: background var(--dur) var(--ease); }
.sg-item:hover, .sg-item.is-active, .sg-item:focus-visible { background: var(--surface-2); outline: none; }
.sg-thumb { width: 38px; flex: none; }
.sg-thumb .frame { border-radius: 6px; }
.sg-body { min-width: 0; flex: 1; }
.sg-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.sg-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.sg-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: var(--r); background: var(--surface-2); color: var(--text-3); }
.sg-all { color: var(--accent-text); font-weight: 600; font-size: 13.5px; }

.ping { position: absolute; top: 5px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 700; line-height: 1; box-shadow: 0 0 0 2px var(--bg); }
/* Notifications : vignette du titre, texte, heure ; point violet si non lue */
.notif-item { position: relative; display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 10px 28px 10px 10px; border-radius: 8px; text-align: left; transition: background .15s ease; }
.notif-item:hover { background: rgba(255, 255, 255, .06); }
.notif-thumb { width: 96px; flex: none; }
.notif-thumb .frame { border-radius: 6px; }
.notif-ico { width: 96px; aspect-ratio: 16 / 9; flex: none; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.notif-ico svg { width: 22px; height: 22px; }
.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.notif-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-text { font-size: 12.5px; color: var(--text-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-time { font-size: 11.5px; color: var(--text-3); }
.notif-item:not(.unread) .notif-title { font-weight: 500; color: var(--text-2); }
.notif-item.unread::after { content: ""; position: absolute; right: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .2); }

.avatar-btn { width: 34px; height: 34px; margin-left: 6px; border-radius: 8px; flex: none; transition: box-shadow var(--dur) var(--ease); }
.avatar-btn .avatar { border-radius: 8px; background: linear-gradient(135deg, var(--accent-hover), var(--accent-press)); color: #fff; }
.avatar-btn:hover, .avatar-btn[aria-expanded="true"] { box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.avatar { position: relative; display: grid; place-items: center; width: 100%; height: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: var(--surface-3); color: var(--text); font-weight: 800; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.menu-head { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); }
.menu-head .avatar { width: 42px; height: 42px; font-size: 16px; }
.menu-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.menu-sub { font-size: 12.5px; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 38px; padding: 0 12px; border-radius: 6px; font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, .86); text-align: left; transition: background .15s ease, color .15s ease; }
.menu-item svg { width: 17px; height: 17px; color: rgba(255, 255, 255, .5); flex: none; }
.menu-item:hover, .menu-item:focus-visible { background: rgba(255, 255, 255, .07); color: #fff; outline: none; }
html[data-theme="light"] .menu-item { color: var(--text); }
.menu-item.danger:hover { color: var(--error); } .menu-item.danger:hover svg { color: var(--error); }
.menu-sep { height: 1px; margin: 4px 0; background: var(--line); }

/* ── Navigation mobile (barre du bas) ──────────────────────────────────── */
.bottom-nav { display: none; }

/* ── Annonces ──────────────────────────────────────────────────────────── */
.announces { position: relative; z-index: 65; display: flex; flex-direction: column; gap: 10px; padding: calc(var(--header-h) + 12px) var(--gutter) 0; }
.announces:empty { display: none; }
body[data-view="home"] .announces, body[data-view="detail"] .announces { position: absolute; left: 0; right: 0; top: 0; }
.announce { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border-left: 3px solid var(--accent); animation: fade-up .3s var(--ease) both; }
.announce .ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: var(--r); background: var(--accent-soft); color: var(--accent-text); }
.announce.maintenance .ico { background: var(--warning-soft); color: var(--warning); }
.announce .txt { flex: 1; min-width: 0; }
.announce b { font-size: 14px; } .announce p { font-size: 13px; color: var(--text-2); }

/* ── Pages ─────────────────────────────────────────────────────────────── */
main { min-height: 70vh; }
.view { animation: fade-in .22s var(--ease) both; }
.page { padding: calc(var(--header-h) + 32px) var(--gutter) 0; }
.announces:not(:empty) ~ main .page { padding-top: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head .kicker { display: none; } /* pas de sur-titre redondant au-dessus des titres de page */
.page-sub { margin-top: 6px; color: var(--text-2); font-size: 14px; max-width: 640px; }
.section { margin-bottom: var(--s-8); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--s-4); }
.tabs-row { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--s-6); overflow-x: auto; scrollbar-width: none; }
.tabs-row::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; height: 48px; padding: 0 16px; font-size: 14.5px; font-weight: 700; color: var(--text-3); transition: color var(--dur) var(--ease); display: inline-flex; align-items: center; }
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--text); }
.tab[aria-selected="true"]::after, .tab[aria-current="page"]::after { content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px; height: 3px; border-radius: 3px; background: var(--accent); }
.tab .count { margin-left: 6px; color: var(--text-3); font-weight: 600; letter-spacing: 0; }

/* ── Rangées (carrousels) ──────────────────────────────────────────────── */
.rows { position: relative; z-index: 2; }
.row { position: relative; margin-bottom: var(--s-8); }
.row-head { display: flex; align-items: flex-end; gap: 12px; padding: 0 var(--gutter); margin-bottom: 14px; }
.row-title { display: flex; align-items: center; gap: 10px; font-size: clamp(19px, 1.6vw, 24px); font-weight: 700; line-height: 1.25; }
/* Petit trait dégradé sous le titre de section (signature NekoFlix) */
.row-title { padding-bottom: 8px; background: linear-gradient(90deg, var(--accent), rgba(var(--accent-rgb), 0)) left bottom / 56px 3px no-repeat; }
.row-title .ic { display: inline-flex; color: var(--gold); } .row-title .ic svg { width: 22px; height: 22px; }
.row-sub { display: none; } /* titres seuls, comme sur les plateformes : pas de phrase d'accroche */
.row-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.row-nav { display: flex; gap: 6px; margin-left: 6px; }
.row-nav button { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-2); color: var(--text-2); transition: background var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease); }
.row-nav button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.row-nav button:disabled { opacity: .3; cursor: default; }
.track {
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--card-w); gap: var(--row-gap);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  padding: 4px var(--gutter) 12px; scroll-padding-inline: var(--gutter); scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.track > * { scroll-snap-align: start; }
.track.wide { grid-auto-columns: clamp(220px, 20vw, 300px); }
.track.landscape { grid-auto-columns: clamp(250px, 22vw, 340px); }
.track:has(> .empty-inline) { display: block; }

/* ── Grilles ───────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr)); gap: 26px 16px; }
.grid > .empty-state, .grid > .hint, .grid > .full { grid-column: 1 / -1; }
.grid-landscape { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px 16px; }
.grid-landscape > .empty-state { grid-column: 1 / -1; }
.list { display: flex; flex-direction: column; gap: 8px; }
.load-more { display: flex; justify-content: center; margin-top: var(--s-7); }

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer { margin-top: var(--s-9); padding: 28px var(--gutter) calc(32px + var(--bottom-h) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; align-items: center; flex-wrap: wrap; gap: 14px 28px; color: var(--text-3); font-size: var(--fs-small); }
.site-footer .brand { font-size: 16px; } .site-footer .brand img { width: 24px; height: 24px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-left: auto; }
.footer-nav a { color: var(--text-2); transition: color var(--dur) var(--ease); }
.footer-nav a:hover { color: var(--text); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .hsearch-box:focus-within { width: 220px; }
  .nav-link { padding: 0 9px; }
}
@media (max-width: 1100px) {
  :root { --header-h: 58px; --bottom-h: 62px; }
  .main-nav, .hsearch, .header-actions .hide-md { display: none; }
  .search-btn, .mobile-only { display: inline-grid; }
  .header-inner { gap: 10px; }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: flex;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bn-item { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-3); font-size: 11px; font-weight: 600; -webkit-tap-highlight-color: transparent; }
  .bn-item svg { width: 22px; height: 22px; }
  .bn-item[aria-current="page"] { color: var(--text); }
  .bn-item[aria-current="page"] svg { color: var(--accent-text); }
  .bn-item[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--accent); }
  main { padding-bottom: calc(var(--bottom-h) + var(--s-4)); }
  .panel { position: fixed; top: calc(var(--header-h) + 6px); right: 12px; left: 12px; width: auto; max-width: none; }
}
@media (max-width: 768px) {
  :root { --row-gap: 10px; --card-w: calc((100vw - var(--gutter) - 3 * var(--row-gap)) / 3.25); }
  .row { margin-bottom: var(--s-7); }
  .row-nav, .row-sub { display: none; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 10px; }
  .grid-landscape { grid-template-columns: 1fr; }
  .page { padding-top: calc(var(--header-h) + 20px); }
  .track.wide { grid-auto-columns: 62vw; }
  .track.landscape { grid-auto-columns: 78vw; }
  .site-footer { flex-direction: column; align-items: flex-start; }
  .footer-nav { margin-left: 0; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root { --card-w: calc((100vw - var(--gutter) - 2 * var(--row-gap)) / 2.3); }
}
@media (min-width: 1920px) {
  :root { --card-w: 200px; --grid-min: 190px; }
}

/* Conteneurs des panneaux du header */
.hpop { position: relative; }
@media (max-width: 768px) {
  .announce { flex-wrap: wrap; }
  .announce .txt { flex: 1 1 200px; }
  .announce > .btn { margin-left: 46px; }
}
/* Une annonce visible : on décale les grands en-têtes (une, fiche, profil) */
.announce { padding: 9px 12px; }
.announce .ico { width: 30px; height: 30px; }
body.has-ann .hero, body.has-ann .detail-hero { padding-top: calc(var(--ann-h, 140px) + 18px); }

/* Performance : le navigateur ne calcule pas l'affichage des rangées, sections
   et épisodes hors écran tant qu'on ne s'en approche pas. */
.rows > .row:nth-child(n+3), .detail-section, .ep-list > .epcard:nth-child(n+13), .ep-rows > .eprow:nth-child(n+31) { content-visibility: auto; contain-intrinsic-size: auto 360px; }
.ep-list > .epcard:nth-child(n+13) { contain-intrinsic-size: auto 190px; }
.ep-rows > .eprow:nth-child(n+31) { contain-intrinsic-size: auto 66px; }
@media (max-width: 768px) {
  /* Sur mobile, l'annonce se pose sur l'image : la une garde sa hauteur */
  body.has-ann .hero { padding-top: calc(var(--ann-h, 140px) + 8px); }
}

/* Les éléments atteints au clavier ou par défilement ne finissent pas sous les barres fixes */
html { scroll-padding-top: calc(var(--header-h) + 12px); scroll-padding-bottom: calc(var(--bottom-h) + 16px); }
