/* =====================================================================
   REAPER+  —  design system
   Hommage monochrome à Canal+ : noir & blanc strict, design plat,
   sans-serif géométrique (Jost) pour la signature, Inter pour l'UI.
   La seule couleur de l'interface provient des visuels de contenu.
   ===================================================================== */

:root {
    color-scheme: dark;

    /* Surfaces */
    --noir:        #000000;
    --surface:     #0a0a0b;
    --surface-2:   #121214;
    --blanc:       #ffffff;

    /* Texte */
    --brume:       rgba(255, 255, 255, 0.60);
    --brume-faible:rgba(255, 255, 255, 0.40);

    /* Filets */
    --trait:       rgba(255, 255, 255, 0.12);
    --trait-fort:  rgba(255, 255, 255, 0.26);

    /* Sémantique (réservé, usage parcimonieux) */
    --danger:      #ff3b30;
    --succes:      #d9ffe2;
    --avert:       #ffe9b0;

    /* Type */
    --font-display: 'Jost', 'Century Gothic', system-ui, sans-serif;
    --font-ui:      'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --bar-h: 66px;
    --maxw: 1180px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--noir);
    color: var(--blanc);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }
a { color: inherit; }

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

::selection { background: var(--blanc); color: #000; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.d-none { display: none !important; }

/* ----------------------------------------------------------- Wordmark */
.wordmark {
    font-family: var(--font-display);
    font-weight: 800;
    font-style: italic;          /* le penché caractéristique */
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    line-height: 1;
    text-transform: uppercase;
    color: var(--blanc);
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    user-select: none;
}
.wordmark .plus {               /* le « + » droit, en pavé inversé : clin d'œil au bloc noir Canal+ */
    font-style: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.82em;
    height: 0.82em;
    margin-left: 0.14em;
    background: var(--blanc);
    color: #000;
    font-weight: 700;
    transform: translateY(-0.02em);
}
.wordmark--lg { font-size: 3rem; }
.wordmark--sm { font-size: 0.92rem; }

/* ------------------------------------------------------------- Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: var(--bar-h);
    background: rgba(0, 0, 0, 0.82);
    border-bottom: 1px solid var(--trait);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.topbar__inner {
    max-width: var(--maxw);
    margin: 0 auto;
    min-height: var(--bar-h);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand { text-decoration: none; display: inline-flex; }
.topbar__nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.topbar__divider {
    flex: 0 0 auto;
    width: 1px;
    height: 1.4rem;
    background: var(--trait);
    margin: 0 0.2rem;
}

/* -------------------------------------------------------------- Badge */
.badge {
    font-family: var(--font-ui);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brume);
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--trait);
}

/* ------------------------------------------------------------ Buttons */
.btn {
    --btn-bg: transparent;
    --btn-fg: var(--blanc);
    --btn-bd: var(--trait-fort);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.75rem 1.2rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    color: var(--btn-fg);
    background: var(--btn-bg);
    border: 1px solid var(--btn-bd);
    border-radius: 0;
    transition: background 0.18s var(--ease), color 0.18s var(--ease),
                border-color 0.18s var(--ease), transform 0.12s var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.btn:active { transform: translateY(1px); }

.btn--primary { --btn-bg: var(--blanc); --btn-fg: #000; --btn-bd: var(--blanc); }
.btn--primary:hover { --btn-bg: rgba(255, 255, 255, 0.84); }

.btn--ghost { --btn-bd: var(--trait); }
.btn--ghost:hover { --btn-bd: var(--blanc); background: rgba(255, 255, 255, 0.07); }

.btn--quiet { --btn-bd: transparent; --btn-fg: var(--brume); }
.btn--quiet:hover { --btn-fg: var(--blanc); background: rgba(255, 255, 255, 0.06); }

.btn--danger { --btn-fg: var(--brume); --btn-bd: var(--trait); }
.btn--danger:hover { --btn-fg: #fff; --btn-bd: var(--danger); background: rgba(255, 59, 48, 0.16); }

.btn--sm { padding: 0.55rem 0.85rem; font-size: 0.7rem; }
.btn--icon { padding: 0.55rem 0.7rem; font-size: 0.85rem; letter-spacing: 0; }
.btn--block { width: 100%; }

.btn[disabled], .btn.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* ------------------------------------------------------ Layout shell */
.container {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 3rem 1.25rem 4rem;
}

.page-head { margin-bottom: 2.5rem; }
.eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--brume-faible);
    margin: 0 0 0.6rem;
}
.page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.9rem, 4vw, 2.9rem);
    letter-spacing: -0.01em;
    line-height: 1.04;
    margin: 0;
}
.page-sub {
    color: var(--brume);
    max-width: 60ch;
    margin: 0.7rem 0 0;
}

.site-footer {
    width: 100%;
    max-width: var(--maxw);
    margin: auto auto 0;
    padding: 2rem 1.25rem 2.5rem;
    border-top: 1px solid var(--trait);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--brume-faible);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
}
.site-footer .wordmark { color: var(--brume); }

/* -------------------------------------------------------------- Alert */
.alert {
    border: 1px solid var(--trait-fort);
    border-left-width: 3px;
    background: var(--surface);
    color: var(--blanc);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.75rem;
    font-size: 0.92rem;
}
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert--success { border-left-color: var(--succes); }
.alert--warning { border-left-color: var(--avert); }
.alert--info    { border-left-color: var(--brume); }
.alert--danger  { border-left-color: var(--danger); }

/* --------------------------------------------------- Channel catalog */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
.channel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--trait);
    transition: border-color 0.2s var(--ease);
}
.channel:hover { border-color: var(--trait-fort); }

.channel__media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #18181a;
    text-decoration: none;
}
.channel__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s var(--ease), filter 0.3s var(--ease);
}
.channel__media:hover img,
.channel__media:focus-visible img { transform: scale(1.05); }

.channel__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.22s var(--ease);
}
.channel__media:hover .channel__overlay,
.channel__media:focus-visible .channel__overlay { opacity: 1; }
.channel__play {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #000;
    background: var(--blanc);
    padding: 0.65rem 1.2rem;
}

.channel__body { padding: 1.1rem 1.2rem 1.2rem; }
.channel__body .eyebrow { margin-bottom: 0.35rem; }
.channel__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.15rem;
    margin: 0;
    line-height: 1.2;
}
.channel__admin {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1.2rem 1.2rem;
    margin-top: auto;
}
.channel__admin .spacer { flex: 1; }

.empty-state {
    border: 1px dashed var(--trait-fort);
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--brume);
}

/* --------------------------------------------------------------- Forms */
.form-shell {
    max-width: 620px;
    margin: 0 auto;
}
.form-card {
    background: var(--surface);
    border: 1px solid var(--trait);
    padding: 2.25rem;
}
.field { margin-bottom: 1.5rem; }
.label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brume);
    margin-bottom: 0.55rem;
}
.input {
    width: 100%;
    font-family: var(--font-ui);
    font-size: 1rem;
    color: var(--blanc);
    background: var(--noir);
    border: 1px solid var(--trait-fort);
    border-radius: 0;
    padding: 0.8rem 0.9rem;
    transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder { color: var(--brume-faible); }
.input:focus {
    outline: none;
    border-color: var(--blanc);
    background: #050505;
}
.input[type="file"] { padding: 0.6rem 0.7rem; color: var(--brume); cursor: pointer; }
.input[type="file"]::file-selector-button {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #000;
    background: var(--blanc);
    border: 0;
    padding: 0.5rem 0.9rem;
    margin-right: 0.9rem;
    cursor: pointer;
}
.help { color: var(--brume-faible); font-size: 0.82rem; margin: 0.45rem 0 0; }

.source-row { display: flex; gap: 0.5rem; align-items: stretch; }
.source-row .input { flex: 1; }
.source-row .select { flex: 0 0 auto; }
.source-list { display: flex; flex-direction: column; gap: 0.6rem; }
.remove-source { flex: 0 0 auto; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.thumb-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #18181a;
    border: 1px solid var(--trait);
}

.select {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--blanc);
    background: var(--noir);
    border: 1px solid var(--trait-fort);
    border-radius: 0;
    padding: 0.65rem 0.8rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.select:focus { outline: none; border-color: var(--blanc); }

/* ---------------------------------------------------------- Login gate */
body.is-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.gate { width: 100%; max-width: 420px; }
.gate__card {
    border: 1px solid var(--trait);
    background: var(--surface);
    padding: 3rem 2.5rem;
}
.gate__brand { text-align: center; margin-bottom: 0.4rem; }
.gate__tagline {
    text-align: center;
    color: var(--brume);
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    margin: 0 0 2rem;
}
.gate__foot {
    text-align: center;
    color: var(--brume-faible);
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    margin: 1.5rem 0 0;
}

/* -------------------------------------------------------------- Panels */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--trait);
    padding: 1.5rem 1.6rem 1.7rem;
}
.panel__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.2rem;
    margin: 0.1rem 0 1.2rem;
}

/* -------------------------------------------------------- Data tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    text-align: left;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brume-faible);
    padding: 0 0.6rem 0.7rem;
    border-bottom: 1px solid var(--trait-fort);
    white-space: nowrap;
}
.data-table td {
    padding: 0.75rem 0.6rem;
    border-bottom: 1px solid var(--trait);
    color: var(--blanc);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}
.data-table .muted { color: var(--brume); }
.data-table .url {
    color: var(--brume);
    font-size: 0.8rem;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.data-table .empty {
    text-align: center;
    color: var(--brume-faible);
    padding: 2rem 0.6rem;
}
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------ Catalog sections */
.search-bar { margin-bottom: 2rem; }
.search-field { position: relative; }
.search-field__icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.05rem;
    height: 1.05rem;
    color: var(--brume-faible);
    pointer-events: none;
}
.search-field .input { padding-left: 2.7rem; }
.search-empty { margin: 1rem 0 0; color: var(--brume); }
.section-group { margin-bottom: 2.75rem; }
.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    margin: 0 0 1.1rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--trait);
}
.channel__badge {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 2;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.section-admin { display: flex; flex-direction: column; gap: 0.7rem; }
.section-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--trait);
    flex-wrap: wrap;
}
.section-row--hidden { opacity: 0.55; }
.section-row__order { display: flex; gap: 0.3rem; }
.section-row__name { display: flex; gap: 0.5rem; flex: 1 1 240px; }
.section-row__name .input { flex: 1; }
.section-row__actions { display: flex; gap: 0.5rem; margin-left: auto; }

/* ------------------------------------------------------------- Player */
.player-head { margin-bottom: 1.25rem; }
.player-head__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.6rem;
    margin: 0;
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.badge--4k {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--blanc);
    border: 1px solid var(--trait-fort);
    border-radius: 2px;
    padding: 0.16rem 0.4rem;
    line-height: 1;
}

.player-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.75rem 1.25rem;
}
.player-shell { width: 100%; max-width: 1100px; }
.player-frame {
    overflow: hidden;
    background: #050505;
    border: 1px solid var(--trait);
}
.player-stage { position: relative; width: 100%; }
.player-stage::before { content: ''; display: block; padding-bottom: 56.25%; }
.player-stage > * { position: absolute; inset: 0; }
.player-stage .plyr,
.player-stage .plyr__video-wrapper { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; }
.player-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.player-stage .plyr { display: flex; flex-direction: column; }
/* keep the video filling the frame in fullscreen (no leftover band below) */
.plyr--fullscreen-active .plyr__video-wrapper { position: absolute; inset: 0; padding: 0; }
.plyr--fullscreen-active video { width: 100%; height: 100%; object-fit: contain; }

.player-loading {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.24s var(--ease);
    pointer-events: none;
}
.player-loading.is-hidden { opacity: 0; }
.player-loading__msg {
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--brume);
}

.spinner {
    position: relative;
    width: 3rem;
    height: 3rem;
}
.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
    animation: spin 0.9s linear infinite;
}
.spinner::before {
    inset: 0;
    border-top-color: var(--blanc);
    border-right-color: rgba(255, 255, 255, 0.35);
}
.spinner::after {
    inset: 0.5rem;
    border-bottom-color: var(--blanc);
    border-left-color: rgba(255, 255, 255, 0.35);
    animation-duration: 0.7s;
    animation-direction: reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.player-sources {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}
.player-sources .select { margin-left: auto; }

.plyr {
    --plyr-color-main: #ffffff;
    --plyr-video-control-color: #fff;
    --plyr-video-control-background-hover: rgba(255, 255, 255, 0.22);
    --plyr-video-control-color-hover: #000;
}
.plyr--video .plyr__controls {
    margin-top: auto;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.78) 70%, rgba(0,0,0,0.95) 100%);
    padding: 0.85rem 1.25rem;
}

/* --------------------------------------------------------- Responsive */
@media (max-width: 640px) {
    .container { padding: 2rem 1.1rem 3rem; }
    .form-card { padding: 1.75rem 1.35rem; }
    .gate__card { padding: 2.25rem 1.5rem; }
    .player-sources .select { margin-left: 0; width: 100%; }
    .form-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* The loading spinner is functional feedback, so keep it spinning even when
   reduced motion is requested (overrides the blanket rule above). */
@media (prefers-reduced-motion: reduce) {
    .spinner::before { animation: spin 0.9s linear infinite !important; }
    .spinner::after { animation: spin 0.7s linear infinite reverse !important; }
}
