/* media.de-almeida.net */

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --border: #e4e3df;
  --text: #1c1c1a;
  --muted: #6f6e69;
  --accent: #e8590c;
  --accent-strong: #c94a06;
  --accent-soft: #fdebe0;
  --on-accent: #ffffff;
  --star: #e0a100;
  --pin: #d6336c;
  --ok: #2b8a3e;
  --ok-soft: #e6f4ea;
  --err: #c92a2a;
  --err-soft: #fdecec;
  --t-folder: #e8a317;
  --t-video: #7048e8;
  --t-audio: #0c8599;
  --t-image: #2f9e44;
  --t-archive: #a0652b;
  --t-doc: #e03131;
  --t-text: #5c7cfa;
  --t-file: #868e96;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #1b1b1a;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #ecebe7;
    --muted: #9b9a94;
    --accent: #ff7a2f;
    --accent-strong: #ff9152;
    --accent-soft: #3a2416;
    --on-accent: #1a0d04;
    --ok-soft: #16301d;
    --err-soft: #3a1717;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1b1b1a;
  --surface-2: #232321;
  --border: #2e2e2b;
  --text: #ecebe7;
  --muted: #9b9a94;
  --accent: #ff7a2f;
  --accent-strong: #ff9152;
  --accent-soft: #3a2416;
  --on-accent: #1a0d04;
  --ok-soft: #16301d;
  --err-soft: #3a1717;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

a { color: inherit; text-decoration: none; }
h1 { margin: 0; font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ic, .brand-mark svg, .ficon svg, .login-mark svg, .crumb-sep {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.break { overflow-wrap: anywhere; }

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #f59f00); color: #fff;
}
.brand-mark svg { width: 20px; height: 20px; }
.topnav { display: flex; align-items: center; gap: 6px; }
.topnav form { margin: 0; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 999px; font-size: .9rem;
}
.avatar {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: .8rem;
}
.badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
}

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-icon { width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn:focus-visible, .act:focus-visible, a:focus-visible, .sort:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- mise en page ---------- */
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 24px 16px 32px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { padding: 48px 24px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.stack { display: grid; gap: 14px; }
.inline { display: inline; margin: 0; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface); }
.alert-error { background: var(--err-soft); border-color: transparent; color: var(--err); }
.alert-success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* fil d'Ariane */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 14px; font-size: .9rem; color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 7px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.crumb:hover { background: var(--surface); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 550; }
.crumb .ic { width: 16px; height: 16px; }
.crumb-sep { width: 14px; height: 14px; opacity: .5; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-tools { display: flex; align-items: center; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.tag .ic { width: 14px; height: 14px; }
.tag-public { background: var(--ok-soft); color: var(--ok); }

.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search input {
  height: 38px; width: 230px; padding: 0 12px 0 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}

/* menu deroulant (ajout torrent) */
.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: 300px;
  padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 40px rgb(0 0 0 / .18);
}

.field { display: grid; gap: 6px; font-size: .88rem; font-weight: 550; }
.field input, .field select {
  height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-weight: 400;
}
.field input[type="file"] { padding: 8px; height: auto; }

/* ---------- liste des fichiers ---------- */
.list-card { overflow: hidden; }
.files { width: 100%; border-collapse: collapse; table-layout: fixed; }
.files th {
  text-align: left; font-size: .76rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.files td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.files tbody tr:last-child td { border-bottom: 0; }
.files tbody tr { transition: background .12s; }
.files tbody tr:hover { background: var(--surface-2); }
.c-icon { width: 56px; padding-right: 0 !important; }
.c-size { width: 110px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.files th.c-size { text-align: right; }
.c-date { width: 150px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-actions { width: 170px; }
.sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; }
.sort::after { content: ""; width: 0; height: 0; border: 4px solid transparent; opacity: 0; }
.sort[data-dir="asc"]::after { border-bottom-color: currentColor; margin-top: -4px; opacity: 1; }
.sort[data-dir="desc"]::after { border-top-color: currentColor; margin-top: 4px; opacity: 1; }

.ficon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  color: var(--tc); background: color-mix(in srgb, var(--tc) 13%, transparent);
}
.ficon svg { width: 19px; height: 19px; }
.ficon-lg { width: 72px; height: 72px; border-radius: 20px; }
.ficon-lg svg { width: 34px; height: 34px; }
.t-folder { --tc: var(--t-folder); }
.t-folder svg { fill: color-mix(in srgb, var(--tc) 30%, transparent); }
.t-video { --tc: var(--t-video); }
.t-audio { --tc: var(--t-audio); }
.t-image { --tc: var(--t-image); }
.t-archive { --tc: var(--t-archive); }
.t-doc { --tc: var(--t-doc); }
.t-text { --tc: var(--t-text); }
.t-file { --tc: var(--t-file); }

.fname { display: block; font-weight: 520; overflow-wrap: anywhere; }
.fname:hover { color: var(--accent); }
.fmeta { display: none; font-size: .8rem; color: var(--muted); }

.acts { display: flex; justify-content: flex-end; gap: 2px; }
.act {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; opacity: .55;
  transition: opacity .12s, background .12s, color .12s;
}
tr:hover .act, .act:focus-visible, .act.on { opacity: 1; }
.act:hover { background: var(--border); color: var(--text); }
.act-star.on { color: var(--star); }
.act-star.on svg { fill: currentColor; }
.act-pin.on { color: var(--pin); }
.act-pin.on svg { fill: currentColor; }
span.act { cursor: default; }
span.act:hover { background: transparent; color: inherit; }
.act-star.on:hover { color: var(--star); }
.act-pin.on:hover { color: var(--pin); }
.no-match { padding: 24px; text-align: center; }

/* ---------- connexion ---------- */
.login { display: grid; place-items: center; min-height: 62vh; }
.login-card { width: 100%; max-width: 380px; padding: 32px 28px; display: grid; gap: 8px; }
.login-card form { margin-top: 16px; }
.login-mark {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), #f59f00); color: #fff;
}
.login-mark svg { width: 28px; height: 28px; fill: currentColor; stroke: none; }

/* ---------- lecteur ---------- */
.player-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.player-card { overflow: hidden; background: #000; border-color: #000; }
.player-card video { display: block; width: 100%; max-height: 75vh; background: #000; }
.audio-box { display: grid; justify-items: center; gap: 20px; padding: 40px 24px; background: var(--surface); }
.audio-box audio { width: 100%; }
.unsupported { display: flex; gap: 14px; align-items: flex-start; padding: 24px; background: var(--surface); }
.unsupported .ic { width: 28px; height: 28px; color: var(--accent); }
.audio-warning { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-start; padding: 16px 20px; background: var(--surface); border-top: 1px solid var(--border); }
.audio-warning > .ic { width: 24px; height: 24px; color: var(--accent); flex: none; }
.audio-warning p { flex: 1; min-width: 220px; margin: 0; font-size: .9rem; }
.side { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 550; }
.linkbox { display: grid; gap: 6px; }
.linkbox label { font-size: .85rem; font-weight: 600; }
.linkbox-row { display: flex; gap: 6px; }
.linkbox input {
  flex: 1; min-width: 0; height: 38px; padding: 0 10px; font-size: .82rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted);
}
.hint { font-size: .8rem; color: var(--muted); }
.siblings { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; border-top: 1px solid var(--border); padding-top: 14px; }
.siblings a {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: .86rem; background: var(--surface-2);
}
.siblings a:hover { color: var(--accent); }
/* noms longs : deux lignes maximum, le nom complet reste dans l'infobulle */
.siblings a span {
  flex: 1; min-width: 0; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.siblings a .ic { flex: none; }
.siblings a.next { justify-content: space-between; }

/* ---------- diaporama ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgb(8 8 8 / .94); color: #fff; touch-action: pan-y;
}
.lightbox figure { margin: 0; display: grid; gap: 12px; justify-items: center; padding: 56px 72px 24px; max-width: 100%; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; border-radius: 6px; }
.lightbox figcaption { font-size: .88rem; opacity: .8; text-align: center; overflow-wrap: anywhere; }
.lb-btn {
  position: absolute; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgb(255 255 255 / .1); color: #fff; cursor: pointer;
}
.lb-btn:hover { background: rgb(255 255 255 / .2); }
.lb-btn .ic { width: 22px; height: 22px; }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }

/* ---------- notification ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-size: .9rem; font-weight: 550; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .player-layout { grid-template-columns: 1fr; }
  .c-date { display: none; }
}
@media (max-width: 640px) {
  .wrap { padding: 16px; }
  .topbar-inner { padding: 8px 16px; }
  .hide-sm { display: none; }
  .user-chip { padding: 3px; }
  h1 { font-size: 1.2rem; }
  .page-tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .files thead { display: none; }
  .c-size { display: none; }
  .c-icon { width: 48px; }
  .c-actions { width: auto; }
  .files td { padding: 10px 8px; }
  .files td.c-name { padding-left: 4px; }
  .fmeta { display: block; }
  .acts { flex-wrap: wrap; max-width: 76px; }
  .act { opacity: 1; width: 32px; height: 32px; }
  .lightbox figure { padding: 60px 8px 80px; }
  .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; }
  .lb-prev { left: calc(50% - 56px); }
  .lb-next { right: calc(50% - 56px); }
  .dropdown-panel { position: fixed; left: 16px; right: 16px; top: 120px; width: auto; }
}
