:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1b2230;
    --muted: #6b7486;
    --line: #e5e8ee;
    --hover: #f0f3f9;
    --accent: #e0a81c;
    --accent-ink: #1b2230;
    --link: #1f4fd8;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 8px 24px rgba(20, 30, 50, .06);
    --c-folder: #e0a81c;
    --c-video: #7c4dff;
    --c-audio: #e5484d;
    --c-image: #12a594;
    --c-archive: #f76b15;
    --c-app: #30a46c;
    --c-doc: #3e63dd;
    --c-other: #8b93a5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f131b;
        --surface: #171c27;
        --text: #e8ebf2;
        --muted: #8e97aa;
        --line: #252c3a;
        --hover: #1d2431;
        --link: #8aa8ff;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

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

/* ---------- En-tête ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-header .inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 18px;
    flex: none;
}

.site-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.site-header p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Contenu ---------- */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--muted);
    min-width: 0;
}

.breadcrumbs a { color: var(--link); font-weight: 500; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { opacity: .5; }
.breadcrumbs .current { color: var(--text); font-weight: 600; }

.search {
    position: relative;
    flex: 0 1 260px;
    width: 100%;
    max-width: 260px;
}

.search svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.search input::placeholder { color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

table.files {
    width: 100%;
    border-collapse: collapse;
}

.files thead th {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.files thead th a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.files thead th a:hover { color: var(--text); }
.files thead th.active { color: var(--text); }

.files tbody tr { border-bottom: 1px solid var(--line); }
.files tbody tr:last-child { border-bottom: 0; }
.files tbody tr:hover { background: var(--hover); }

.files td { padding: 10px 16px; vertical-align: middle; }

.files .col-size, .files .col-date {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.files .col-size { width: 110px; text-align: right; }
.files thead .col-size { text-align: right; }
.files .col-date { width: 170px; }

.entry {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.entry a {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.entry a:hover { color: var(--link); }

.ico {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    background: var(--c-other);
}

.ico.folder { background: color-mix(in srgb, var(--c-folder) 18%, transparent); color: var(--c-folder); }
.ico.video { background: var(--c-video); }
.ico.audio { background: var(--c-audio); }
.ico.image { background: var(--c-image); }
.ico.archive { background: var(--c-archive); }
.ico.app { background: var(--c-app); }
.ico.doc { background: var(--c-doc); }

.badge-new {
    flex: none;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
}

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--muted);
}

.footer {
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .site-header .inner { padding: 16px; }
    .container { padding: 16px 12px 36px; }
    .search { max-width: none; flex-basis: 100%; }
    .files .col-date { display: none; }
    .files .col-size { width: 84px; }
    .files td, .files thead th { padding-left: 12px; padding-right: 12px; }
}


/* =========================================================
   ANIMATIONS
   ========================================================= */
html { --d: 0s; }          /* délai de base (0 sans intro) */
html.intro { --d: 1.9s; }  /* délai quand l'intro est jouée */

/* ---------- Intro d'ouverture (1 fois par session) ---------- */
.splash {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #121826;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 22px;
    color: #fff;
}

html.intro .splash {
    display: flex;
    animation: splash-out .7s cubic-bezier(.76, 0, .24, 1) 1.45s forwards;
}

.splash-logo {
    position: relative;
    width: 92px;
    height: 92px;
    display: grid;
    place-items: center;
}

.splash-logo svg {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
}

.splash-logo circle {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 264;
    stroke-dashoffset: 264;
    animation: draw-ring 1s ease-out .15s forwards;
}

.splash-logo b {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    font-size: 30px;
    font-weight: 800;
    opacity: 0;
    transform: scale(.4) rotate(-20deg);
    animation: pop-in .6s cubic-bezier(.2, 1.4, .4, 1) .55s forwards;
}

.splash-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .02em;
    opacity: 0;
    animation: rise .6s ease-out .85s forwards;
}

.splash-bar {
    width: 140px;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}

.splash-bar::after {
    content: "";
    display: block;
    height: 100%;
    width: 100%;
    background: var(--accent);
    transform: translateX(-100%);
    animation: load 1.2s ease-in-out .2s forwards;
}

@keyframes draw-ring { to { stroke-dashoffset: 0; } }
@keyframes pop-in { to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes load { to { transform: translateX(0); } }
@keyframes splash-out {
    to { transform: translateY(-100%); visibility: hidden; }
}

/* ---------- Entrée de la page ---------- */
.site-header .inner > * {
    opacity: 0;
    animation: rise .6s ease-out calc(var(--d) + .05s) forwards;
}
.site-header .inner > div:last-child { animation-delay: calc(var(--d) + .15s); }

.toolbar {
    opacity: 0;
    animation: rise .6s ease-out calc(var(--d) + .25s) forwards;
}

.card {
    opacity: 0;
    animation: rise .7s ease-out calc(var(--d) + .35s) forwards;
}

/* lignes qui apparaissent l'une après l'autre */
.files tbody tr {
    opacity: 0;
    transform: translateX(-12px);
    animation: row-in .45s ease-out forwards;
    animation-delay: calc(var(--d) + .5s + var(--i, 0) * 45ms);
}

@keyframes row-in { to { opacity: 1; transform: none; } }

.footer {
    opacity: 0;
    animation: rise .6s ease-out calc(var(--d) + .9s) forwards;
}

/* ---------- Vagues animées dans l'en-tête ---------- */
.site-header { position: relative; overflow: hidden; }
.site-header .inner { position: relative; z-index: 1; padding-bottom: 34px; }

.waves {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 32px;
    pointer-events: none;
}

.waves use { animation: wave-move 14s cubic-bezier(.55, .5, .45, .5) infinite; }
.waves use:nth-child(1) { animation-delay: -2s; animation-duration: 8s; }
.waves use:nth-child(2) { animation-delay: -3s; animation-duration: 11s; }
.waves use:nth-child(3) { animation-delay: -4s; animation-duration: 15s; }

@keyframes wave-move {
    0%   { transform: translate3d(-90px, 0, 0); }
    100% { transform: translate3d(85px, 0, 0); }
}

/* ---------- Interactions ---------- */
.brand-mark { transition: transform .3s cubic-bezier(.2, 1.4, .4, 1); }
.site-header .inner:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }

.files tbody tr { position: relative; transition: background .2s; }
.files tbody tr td:first-child { box-shadow: inset 0 0 0 var(--accent); transition: box-shadow .2s; }
.files tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.ico { transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); }
.files tbody tr:hover .ico { transform: scale(1.12) rotate(-4deg); }

.entry a { transition: color .2s, transform .2s; }
.files tbody tr:hover .entry a { transform: translateX(3px); }

.files thead th svg { transition: transform .25s; }
.files thead th a:hover svg { transform: translateY(-2px); }

.badge-new { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(224, 168, 28, .5); }
    50%      { box-shadow: 0 0 0 6px rgba(224, 168, 28, 0); }
}

.search input { transition: border-color .2s, box-shadow .2s, background .2s; }
.search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(224, 168, 28, .2);
}

/* apparition douce quand on filtre */
.files tbody tr.filter-in { animation: row-in .3s ease-out forwards; animation-delay: 0s; }

/* ---------- Respect de « réduire les animations » ---------- */
@media (prefers-reduced-motion: reduce) {
    .splash { display: none !important; }
    .site-header .inner > *, .toolbar, .card, .footer, .files tbody tr {
        opacity: 1 !important; transform: none !important; animation: none !important;
    }
    .waves use, .badge-new { animation: none !important; }
}

/* =========================================================
   CODES DOWNLOADER
   ========================================================= */
.codes { margin-bottom: 20px; opacity: 0; animation: rise .6s ease-out calc(var(--d) + .3s) forwards; }

.codes-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 10px;
}

.codes-head h2 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.codes-logo { width: 36px; height: 36px; border-radius: 9px; display: block; }
.code-ico { grid-area: ico; width: 40px; height: 40px; border-radius: 10px; display: block; margin-right: 2px; }
.codes-head span { font-size: 13px; color: var(--muted); }

.codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.code {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "ico name copy" "ico value copy";
    align-items: center;
    column-gap: 10px;
    text-align: left;
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .2s, transform .2s, box-shadow .2s;
}

.code:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.code:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.code-name { grid-area: name; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.code-value { grid-area: value; font-size: 22px; font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

.code-copy {
    grid-area: copy;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--hover);
    color: var(--muted);
    transition: background .2s, color .2s;
}

.code:hover .code-copy { background: var(--accent); color: var(--accent-ink); }
.code.copied { border-color: var(--c-app); }
.code.copied .code-copy { background: var(--c-app); color: #fff; }

@media (max-width: 640px) {
    .codes-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .code { grid-template-columns: auto 1fr; grid-template-areas: "ico copy" "name name" "value value"; row-gap: 2px; }
    .code-ico { width: 32px; height: 32px; margin-bottom: 6px; }
    .code-copy { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
    .codes { opacity: 1 !important; animation: none !important; }
    .code { transition: none; }
}
