/* home.css — the front page (home.html): a YouTube-style grid of served clips.
   Own stylesheet: the viewer's style.css pins the body to a fixed, non-scrolling
   stage; the home page scrolls. Same self-hosted Raleway and the same neutral
   dark tones, tuned darker (YouTube's #0f0f0f ground) so posters carry the
   colour. Layout: 56px sticky top bar · 72px mini rail · fluid card grid. */
@font-face {
  font-family: "Raleway";
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  src: url("fonts/raleway-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --bg-2: #161616;
  --bg-3: #212121;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f1f1f1;
  --muted: #aaaaaa;
  --faint: #717171;
  --chip: rgba(255, 255, 255, 0.10);
  --chip-hover: rgba(255, 255, 255, 0.18);
  --accent: #8ab4ff;
  --danger: #ff6b6b;
  --radius: 12px;
  --top-h: 56px;
  --rail-w: 72px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  font-family: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--bg-3); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }

/* ---- Top bar ---------------------------------------------------------------- */
#top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: grid; grid-template-columns: 1fr minmax(240px, 640px) 1fr; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--bg);
}
.top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.brand { display: flex; align-items: baseline; gap: 0; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.logo { font-weight: 600; font-size: 21px; letter-spacing: -0.02em; }
.logo-er { font-weight: 300; font-size: 21px; letter-spacing: -0.02em; color: var(--muted); }
.brand-sub { margin-left: 10px; font-size: 12px; color: var(--faint); letter-spacing: 0.04em; text-transform: uppercase; }
.brand-sub:empty { display: none; }

.ib {                                   /* round icon button */
  appearance: none; border: 0; background: transparent; width: 40px; height: 40px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text);
  transition: background 0.15s var(--ease);
}
.ib:hover { background: var(--chip); }
.ib:active { background: var(--chip-hover); }

#search { display: flex; align-items: center; height: 40px; }
#search input {
  flex: 1; min-width: 0; height: 40px; padding: 0 16px; font: inherit; font-size: 15px; color: var(--text);
  background: #121212; border: 1px solid #303030; border-right: 0; border-radius: 40px 0 0 40px; outline: none;
}
#search input:focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(138, 180, 255, 0.35); }
#search input::-webkit-search-cancel-button { filter: invert(1); }
#search .search-go { width: 64px; height: 40px; border-radius: 0 40px 40px 0; background: var(--bg-3); border: 1px solid #303030; }
#search .search-go:hover { background: #2a2a2a; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 10px; border-radius: 18px;
  background: var(--chip); border: 0; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background 0.15s var(--ease);
}
.pill:hover { background: var(--chip-hover); }
.pill.primary { background: var(--text); color: var(--bg); }
.pill.primary:hover { background: #d9d9d9; }
.pill svg { width: 20px; height: 20px; }

/* ---- Rail ------------------------------------------------------------------- */
#rail {
  position: fixed; top: var(--top-h); left: 0; bottom: 0; width: var(--rail-w); z-index: 15;
  display: flex; flex-direction: column; align-items: stretch; padding: 4px 4px; gap: 2px; background: var(--bg);
}
.rail-item {
  appearance: none; border: 0; background: transparent; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0 12px; border-radius: 10px;
  font-size: 10px; letter-spacing: 0.01em; transition: background 0.15s var(--ease);
}
.rail-item:hover { background: var(--chip); }
.rail-item.active { font-weight: 600; }
.rail-item.active svg { stroke-width: 2.2; }
body.rail-hidden #rail { display: none; }
body.rail-hidden #main { margin-left: 0; }

/* ---- Main / chips ----------------------------------------------------------- */
#main { margin-left: var(--rail-w); padding: 0 24px 40px; min-height: calc(100vh - var(--top-h)); }
#chipbar {
  position: sticky; top: var(--top-h); z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 8px 0 12px; margin: 0 -24px; padding-left: 24px; padding-right: 24px;
  background: linear-gradient(to bottom, var(--bg) 78%, rgba(15, 15, 15, 0));
}
#chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; padding-bottom: 2px; }
#chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; border: 0; flex: none; height: 32px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  background: var(--chip); color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.chip:hover { background: var(--chip-hover); }
.chip.active { background: var(--text); color: var(--bg); }
.chip .n { margin-left: 6px; font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: none; }
.sort select {
  appearance: none; -webkit-appearance: none; font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  background: var(--chip); border: 0; border-radius: 8px; height: 32px; padding: 0 30px 0 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.sort select option { background: #1c1c1c; }

/* ---- Shelves + grid --------------------------------------------------------- */
.shelf { margin: 8px 0 28px; animation: rise 0.5s var(--ease) both; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; }
.shelf-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.shelf-head .count { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Card ------------------------------------------------------------------- */
.card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius);
  background: var(--bg-2); cursor: pointer; transition: border-radius 0.2s var(--ease), transform 0.25s var(--ease);
  -webkit-user-select: none; user-select: none;
}
.card:hover .thumb { border-radius: 4px; }        /* YouTube: corners square up on hover */
.card.soon .thumb { cursor: default; }
.thumb .art, .thumb .poster, .thumb .strip { position: absolute; inset: 0; width: 100%; height: 100%; }
.thumb .art { display: block; }
.thumb .poster { object-fit: cover; transition: transform 0.6s var(--ease); }
.thumb .poster[hidden], .thumb .strip[hidden], .thumb .ribbon[hidden], .thumb .hover-hint[hidden] { display: none; }
.card.has-poster:hover .poster { transform: scale(1.04); }
.thumb .strip { background-repeat: no-repeat; background-size: auto 100%; }
.card.soon .art { filter: saturate(0.25) brightness(0.55); }
.badge {
  position: absolute; z-index: 2; padding: 3px 5px; border-radius: 4px; font-size: 12px; font-weight: 600;
  line-height: 1.1; letter-spacing: 0.02em; background: rgba(0, 0, 0, 0.8); color: #fff;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.badge.dur { right: 8px; bottom: 8px; }
.badge.kind { left: 8px; top: 8px; font-size: 11px; letter-spacing: 0.08em; background: rgba(0, 0, 0, 0.6); color: #ddd; }
.badge.kind.k4d { background: rgba(138, 180, 255, 0.22); color: #cfe0ff; }
.badge:empty { display: none; }
.ribbon {
  position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 6px 12px; border-radius: 999px; border: 1px dashed rgba(255, 255, 255, 0.45);
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: #ddd;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px); pointer-events: none;
}
.hover-hint {
  position: absolute; inset: 0; z-index: 1; display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 10px; background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent 45%);
  opacity: 0; transition: opacity 0.2s var(--ease); pointer-events: none;
}
.hover-hint span { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; }
.card:not(.soon):hover .hover-hint:not([hidden]) { opacity: 1; }

.body { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: var(--bg-3);
}
.text { flex: 1; min-width: 0; }
.title {
  margin: 0 0 4px; font-size: 15px; font-weight: 600; line-height: 1.3; letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.channel, .meta { font-size: 13px; color: var(--muted); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel { font-weight: 500; }
.meta { color: var(--faint); }
.more { flex: none; width: 36px; height: 36px; margin: -6px -8px 0 0; opacity: 0; }
.card:hover .more, .more:focus-visible, .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .more { opacity: 1; } }

/* ---- Card menu -------------------------------------------------------------- */
.menu {
  position: fixed; z-index: 30; min-width: 220px; padding: 8px 0; border-radius: 12px;
  background: #282828; box-shadow: var(--shadow); animation: rise 0.18s var(--ease) both;
}
.menu[hidden] { display: none; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; border: 0; background: none;
  text-align: left; font-size: 14px; cursor: pointer; color: var(--text);
}
.menu button:hover, .menu a:hover { background: rgba(255, 255, 255, 0.1); }
.menu button:disabled { color: var(--faint); cursor: default; }
.menu button:disabled:hover { background: none; }
.menu svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.menu .sep { height: 1px; margin: 6px 0; background: var(--line); }
.menu .head { padding: 6px 16px 8px; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; }
.menu .sub { max-height: 260px; overflow-y: auto; }
.menu .sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Details modal ---------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-card { width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px 22px 18px; border-radius: 16px;
  background: #1f1f1f; box-shadow: var(--shadow); animation: rise 0.25s var(--ease) both; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.rows { margin-top: 10px; border-top: 1px solid var(--line); }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.rows span { color: var(--muted); flex: none; }
.rows b { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.pill[hidden] { display: none; }
.pill:disabled { opacity: 0.5; cursor: default; }

/* ---- Upload sheet ----------------------------------------------------------- */
.fields { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field em { font-style: normal; color: var(--faint); margin-left: 4px; }
.field input[type="text"], .field textarea {
  font: inherit; font-size: 14px; color: var(--text); background: #121212; border: 1px solid #303030;
  border-radius: 10px; padding: 9px 12px; outline: none; resize: vertical;
}
.field input[type="text"]:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="file"] { font: inherit; font-size: 13px; color: var(--text); }
.field input[type="file"]::file-selector-button {
  font: inherit; font-weight: 500; color: var(--text); background: var(--chip); border: 0; border-radius: 8px;
  padding: 7px 12px; margin-right: 10px; cursor: pointer;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thumb-pick {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9;
  border-radius: var(--radius); border: 1px dashed var(--line-2); background: var(--bg-2); overflow: hidden; cursor: pointer;
}
.thumb-pick:hover, .visually-hidden:focus-visible + .thumb-pick { border-color: var(--accent); }
.thumb-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb-pick img[hidden], .thumb-pick span[hidden] { display: none; }
.progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress[hidden] { display: none; }
.progress progress { flex: 1; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--bg-3); }
.progress progress::-webkit-progress-bar { background: var(--bg-3); }
.progress progress::-webkit-progress-value { background: var(--accent); }
.progress progress::-moz-progress-bar { background: var(--accent); }
.error { margin: 12px 0 0; font-size: 13px; color: var(--danger); }
.error[hidden] { display: none; }

/* ---- Empty state, footer, toasts ------------------------------------------- */
.empty { display: flex; justify-content: center; padding: 48px 0; }
.empty[hidden] { display: none; }   /* the attribute must win over display:flex: shown only when nothing is served */
.empty-card { max-width: 560px; text-align: center; padding: 32px 28px; border-radius: 20px; background: var(--bg-2); box-shadow: var(--shadow); }
.empty-logo { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 8px; }
.empty-logo span { font-weight: 300; color: var(--muted); }
.empty pre { text-align: left; padding: 12px 14px; border-radius: 10px; background: #0b0b0b; overflow-x: auto; font-size: 12.5px; }
.empty p { font-size: 15px; line-height: 1.5; }
#foot { padding: 24px 0 0; font-size: 12px; color: var(--faint); }
#foot:empty { display: none; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 999px; background: #f1f1f1; color: #0f0f0f; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); animation: rise 0.25s var(--ease) both; }

/* ---- Responsive ------------------------------------------------------------- */
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } }
@media (max-width: 800px) {
  #top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; padding: 0 8px; }
  .brand-sub { display: none; }
  .brand { padding: 4px 2px; }
  #search { min-width: 0; }
  .pill span { display: none; }
  .pill { padding: 0 8px; }
  #rail { display: none; }
  body.rail-open #rail { display: flex; box-shadow: var(--shadow); }
  #main { margin-left: 0; padding: 0 12px 32px; }
  #chipbar { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .sort span { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px 12px; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .thumb, .card:hover .thumb { border-radius: 10px; }
  #search .search-go { width: 48px; }
}
@media (prefers-reduced-motion: reduce) { .shelf, .menu, .modal-card, .toast { animation: none; } .thumb .poster { transition: none; } }
