/* FilmDock – public page. Colours / sizes come from CSS variables printed by settings_css_vars(). */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-w: 1280px; --card-min: 250px; --gap: 22px; --radius: 14px; --btn-radius: 10px;
  --poster-ratio: 4/3; --title-lines: 1; --lift: -4px; --header-pos: sticky; --logo-h: 34px;
  --d-bg: #14161a; --d-surface: #1c1f25; --d-surface2: #252932; --d-text: #e8eaed; --d-muted: #9aa1ab; --d-border: #2b303a; --d-accent: #5b8cff;
  --l-bg: #f3f4f7; --l-surface: #ffffff; --l-surface2: #eceef3; --l-text: #16181d; --l-muted: #5d6572; --l-border: #dde0e7; --l-accent: #2f6bff;
  --btn-yt-bg: #c4002f; --btn-yt-fg: #fff; --btn-dcp-bg: #0b7fa6; --btn-dcp-fg: #fff;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--d-bg); --surface: var(--d-surface); --surface-2: var(--d-surface2);
  --text: var(--d-text); --muted: var(--d-muted); --border: var(--d-border); --accent: var(--d-accent);
  --shadow: 0 14px 34px rgba(0, 0, 0, .42);
  --glass: color-mix(in srgb, var(--d-bg) 78%, transparent);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: var(--l-bg); --surface: var(--l-surface); --surface-2: var(--l-surface2);
  --text: var(--l-text); --muted: var(--l-muted); --border: var(--l-border); --accent: var(--l-accent);
  --shadow: 0 14px 34px rgba(24, 34, 70, .14);
  --glass: color-mix(in srgb, var(--l-bg) 80%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  transition: background-color .25s ease, color .25s ease;
}
html.modal-open { overflow: hidden; }
a { color: inherit; }
.ic { flex: none; display: block; }

/* ---------- header ---------- */
.topbar {
  position: var(--header-pos); top: 0; z-index: 20;
  background: var(--glass); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: var(--max-w); margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { height: var(--logo-h); width: auto; display: block; }
.site-title { margin: 0; font-size: 1.25rem; font-weight: 750; letter-spacing: -.01em; line-height: 1.2; }
.site-sub { margin: 2px 0 0; font-size: .85rem; color: var(--muted); }
.tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; min-width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .92rem;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); cursor: pointer; }

.langs { display: flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.langs a {
  text-decoration: none; font-size: .74rem; font-weight: 700; letter-spacing: .04em; color: var(--muted);
  padding: 6px 11px; border-radius: 999px; transition: background .15s, color .15s;
}
.langs a:hover { color: var(--text); }
.langs a[aria-current] { background: var(--accent); color: #fff; }

.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  transition: background .15s, transform .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible, .btn:focus-visible, .langs a:focus-visible, .copy-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
[data-theme="dark"] .ico-sun, [data-theme="light"] .ico-moon { display: none; }

/* ---------- grid + cards ---------- */
.wrap { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 28px 24px 40px; flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr)); gap: var(--gap); }

.card {
  display: flex; flex-direction: column; gap: 14px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card:hover { transform: translateY(var(--lift)); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card[hidden] { display: none; }

.poster {
  aspect-ratio: var(--poster-ratio); overflow: hidden; background: var(--surface-2);
  border-radius: calc(var(--radius) - 5px);
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.card:hover .poster img { transform: scale(1.045); }
.poster-ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); opacity: .6;
  background: linear-gradient(135deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 60%, var(--bg))); }

.card-title {
  margin: 0; font-size: 1.04rem; font-weight: 700; line-height: 1.3; letter-spacing: -.005em;
  display: -webkit-box; -webkit-line-clamp: var(--title-lines); -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.row { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.row-label { font-size: .8rem; color: var(--muted); }

.btn {
  --b: var(--surface-2); --c: var(--text);
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px;
  background: var(--b); color: var(--c); border: 0; border-radius: var(--btn-radius);
  font: inherit; font-size: .86rem; font-weight: 650; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: filter .15s, transform .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.12); box-shadow: 0 6px 16px color-mix(in srgb, var(--b) 40%, transparent); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn-yt { --b: var(--btn-yt-bg); --c: var(--btn-yt-fg); }
.btn-dcp { --b: var(--btn-dcp-bg); --c: var(--btn-dcp-fg); }
.btn .count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: .74rem; font-weight: 700; text-align: center;
  background: rgba(255, 255, 255, .22);
}
.btn-ghost { --b: var(--surface-2); --c: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { box-shadow: none; filter: none; background: color-mix(in srgb, var(--surface-2) 70%, var(--accent)); }

.notice { text-align: center; color: var(--muted); padding: 60px 0; margin: 0; }

.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 22px 24px 30px; border-top: 1px solid var(--border); }

/* ---------- DCP dialog ---------- */
dialog {
  padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(680px, calc(100vw - 28px)); max-height: min(82vh, 760px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
dialog[open] { display: flex; animation: pop .18s ease-out; }
dialog::backdrop { background: rgba(6, 8, 12, .62); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.dlg { display: flex; flex-direction: column; width: 100%; min-height: 0; max-height: inherit; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px 12px; }
.dlg-heading { min-width: 0; }
.dlg-title { margin: 0; font-size: 1.15rem; font-weight: 750; overflow-wrap: anywhere; }
.dlg-sub { margin: 3px 0 0; font-size: .82rem; color: var(--muted); }
.dlg-search { padding: 0 20px 12px; }
.dlg-search .search { width: 100%; min-width: 0; border-radius: 12px; background: var(--surface-2); }

.dcp-list {
  list-style: none; margin: 0; padding: 0 12px; overflow-y: auto; flex: 1 1 auto; min-height: 0;
  border-top: 1px solid var(--border); counter-reset: n; scrollbar-width: thin;
}
.dcp-list li {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 8px;
}
.dcp-list li:last-child { border-bottom: 0; }
.dcp-list li:hover { background: var(--surface-2); }
.dcp-list .num { flex: none; min-width: 28px; text-align: right; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dcp-list .fname {
  flex: 1; min-width: 0; overflow-wrap: anywhere; user-select: all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem;
}
.copy-btn {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted); border: 0; border-radius: 8px; transition: color .15s, background .15s;
}
.copy-btn:hover { color: var(--text); background: var(--surface-2); }
.copy-btn.done { color: #3ccf8e; }
.dcp-empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: .9rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .topbar-in { padding: 12px 16px; }
  .wrap { padding: 20px 16px 32px; }
  .search { min-width: 0; flex: 1; }
  .tools { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
