/* Video Archive: a light table. Films sit in black mounts on a daylight-white surface; playing one turns
   the lights down. Grease-pencil crimson is the only accent: focus, selection, progress, drop target. */
:root {
  --table: #EBEFED;          /* lightbox surface, daylight-balanced */
  --glow: #F8FAF9;           /* lit centre and raised panels */
  --ink: #1C2321;
  --ink-2: #5A6561;
  --rule: #CDD5D1;
  --mount: #000;
  --mount-edge: transparent;
  --pencil: #C41E3A;         /* china-marker crimson */
  --chip: #FFFFFF;
  --row-h: clamp(210px, 20vw, 320px);
  --pad: clamp(16px, 3vw, 40px);
  --font: "Archivo", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {  /* the table light switched off */
  :root {
    --table: #181C1B; --glow: #212625; --ink: #E7ECEA; --ink-2: #9AA4A0; --rule: #313836;
    --mount-edge: rgba(255, 255, 255, .1); --pencil: #FF5C70; --chip: #262C2A; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background-color: var(--table);
  background-image: radial-gradient(120% 55% at 50% -12%, var(--glow), transparent 72%); background-attachment: fixed;
  font: 450 15px/1.5 var(--font); font-synthesis: none;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--pencil); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header ---------------------------------------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 28px;
  padding: 14px var(--pad); border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--table) 90%, transparent); backdrop-filter: blur(12px);
}
.brand {
  font-size: 21px; font-weight: 800; font-stretch: 125%; letter-spacing: -.012em; line-height: 1;
  text-decoration: none; white-space: nowrap;
}
.crumbs {
  display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none;
  white-space: nowrap; font-weight: 600; font-size: 15px;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs a { color: var(--ink-2); text-decoration: none; padding: 4px 5px; border-radius: 5px; }
.crumbs a:hover { color: var(--ink); background: var(--glow); }
.crumbs a[aria-current] { color: var(--ink); }
.crumbs .sep { color: var(--rule); padding: 0 1px; }
.crumbs .refresh {
  margin-left: 8px; border: 0; background: none; color: var(--ink-2); font-size: 13px; font-weight: 500;
  padding: 4px 6px; border-radius: 5px; cursor: pointer;
}
.crumbs .refresh:hover { color: var(--ink); background: var(--glow); }

.tools { display: flex; align-items: center; gap: 8px; }
.filter input {
  width: 190px; padding: 7px 12px; font-size: 14px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--glow);
}
.filter input::placeholder { color: var(--ink-2); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--rule); border-radius: 9px; background: var(--glow); }
.seg button {
  padding: 5px 11px; border: 0; border-radius: 7px; background: none; color: var(--ink-2);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--table); }
.btn {
  padding: 7px 14px; border: 1px solid var(--ink); border-radius: 8px; background: none;
  font-size: 14px; font-weight: 650; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--glow); }
.btn.primary { background: var(--ink); color: var(--table); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--table)); }

.loading-line {
  position: fixed; inset: 0 0 auto; height: 2px; z-index: 30;
  background: linear-gradient(90deg, transparent, var(--pencil), transparent) no-repeat; background-size: 35% 100%;
  animation: sweep 1.1s linear infinite;
}
@keyframes sweep { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* ---- the table ---------------------------------------------------------------------------------------------- */
.table { max-width: 1720px; margin: 0 auto; padding: 30px var(--pad) 140px; outline: none; }
.table.stale { opacity: .35; pointer-events: none; transition: opacity .2s ease .15s; }
.section { margin: 0 0 48px; }
.section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 16px; }
.section-head h2 { margin: 0; font-size: 18px; font-weight: 750; font-stretch: 110%; letter-spacing: -.005em; }
.section-head .count { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.section-head .where { flex-basis: 100%; color: var(--ink-2); font-size: 13px; text-decoration: none; }
.section-head .where:hover { color: var(--ink); text-decoration: underline; }

.all-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  margin: 0 0 30px; color: var(--ink-2);
}
.all-head p { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); font-weight: 550; }
.toggle input { width: 16px; height: 16px; accent-color: var(--pencil); margin: 0; }

/* folders read like an index, not like more pictures */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0 28px; }
.folder {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  margin: 0 -10px; padding: 9px 10px; border-radius: 7px; text-decoration: none;
}
.folder:hover { background: var(--glow); }
.folder svg { width: 20px; height: 20px; color: var(--ink-2); }
.folder .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.folder time { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* films: mounts keep each film's real shape; rows justify like a contact sheet */
.reel { display: flex; flex-wrap: wrap; gap: 30px 22px; }
.reel::after { content: ""; flex: 1000 1 0; }
.film {
  --h: var(--row-h);
  flex: var(--ar) 1 calc(var(--h) * var(--ar)); max-width: calc(var(--h) * var(--ar) * 1.55); min-width: 0;
  display: flex; flex-direction: column; gap: 9px;
}
.reel.stills .film { --h: calc(var(--row-h) * .68); }
.mount {
  position: relative; display: block; aspect-ratio: var(--ar); padding: 5px; border-radius: 3px;
  background: var(--mount); box-shadow: 0 0 0 1px var(--mount-edge); cursor: pointer;
}
.mount img {
  display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 1.5px;
  opacity: 0; transition: opacity .3s ease;
}
.mount img.ready { opacity: 1; }
.mount.no-thumb::after {
  content: attr(data-kind); position: absolute; inset: 0; display: grid; place-items: center;
  color: #8A938F; font-size: 13px; font-weight: 600;
}
.film .mount:hover, .film .mount:focus-visible { outline: 2px solid var(--pencil); outline-offset: 4px; }
.film-title {
  margin: 0; font-size: 14px; font-weight: 620; line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.film-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0;
  color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.chip {
  display: inline-block; padding: 0 8px; border: 1px solid var(--rule); border-radius: 999px; background: var(--chip);
  color: var(--ink); font-size: 11.5px; font-weight: 650; line-height: 19px; text-decoration: none; white-space: nowrap;
}
a.chip:hover { border-color: var(--pencil); color: var(--pencil); }

/* projects on the home page: a black mount holds any poster shape, text sits beneath like a label */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 34px 26px; }
.project { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.project .mount { aspect-ratio: 16 / 9; }
.project .mount img { object-fit: contain; }
.project-text { display: flex; flex-direction: column; gap: 4px; }
.project-title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; }
.project-title a { text-decoration: none; }
.project-title a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.project-en { margin: 0; color: var(--ink-2); font-size: 13px; font-weight: 550; }
.project-summary {
  margin: 4px 0 2px; font-size: 14px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* a project's description: Chinese and English side by side, films right below */
.about { margin: 0 0 52px; padding-bottom: 34px; border-bottom: 1px solid var(--rule); }
.about-head { margin-bottom: 22px; }
.about-title { margin: 0; font-size: clamp(24px, 3.2vw, 34px); font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
.about-title-en { margin: 6px 0 10px; color: var(--ink-2); font-size: 16px; font-weight: 600; font-stretch: 108%; }
.about-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 56px; max-width: 1240px; }
.about-col { font-size: 15px; line-height: 1.75; }
.about-col[lang="en"] { line-height: 1.65; padding-left: 28px; border-left: 1px solid var(--rule); }
.about-col h3 { margin: 22px 0 6px; font-size: 14px; font-weight: 750; color: var(--ink); }
.about-col h3:first-child { margin-top: 0; }
.about-col p { margin: 0 0 10px; max-width: 68ch; }
.about-col ul { margin: 0 0 10px; padding-left: 1.1em; }
.about-col li { margin: 0 0 6px; max-width: 66ch; }
.about-col strong { font-weight: 700; }
.about-col code { font-size: .92em; padding: 0 3px; border-radius: 3px; background: var(--glow); }
.about-private { margin-top: 24px; max-width: 1240px; color: var(--ink-2); font-size: 14px; line-height: 1.65; }
.about-private summary { cursor: pointer; font-weight: 650; }
.about-private h3 { margin: 16px 0 4px; font-size: 13.5px; }
.sign-in { color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: none; padding: 7px 4px; }
.sign-in:hover { color: var(--ink); text-decoration: underline; }

.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files td { padding: 9px 14px 9px 0; border-top: 1px solid var(--rule); vertical-align: baseline; }
.files tr:last-child td { border-bottom: 1px solid var(--rule); }
.files .name a { text-decoration: none; overflow-wrap: anywhere; }
.files .name a:hover { text-decoration: underline; }
.files .size, .files .date { width: 1%; color: var(--ink-2); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.files .act { width: 1%; padding-right: 0; text-align: right; }
.dl { color: var(--pencil); font-weight: 650; text-decoration: none; white-space: nowrap; }
.dl:hover { text-decoration: underline; }

.empty { max-width: 560px; padding: 72px 0; color: var(--ink-2); }
.empty h2 { margin: 0 0 8px; color: var(--ink); font-size: 22px; font-weight: 750; font-stretch: 110%; }
.empty p { margin: 0 0 18px; }

/* ---- theatre: lights down -------------------------------------------------------------------------------------- */
.theatre {
  position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  background: rgba(0, 0, 0, .975); color: #E9EDEB;
}
.t-stage { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: center; min-height: 0; padding: 24px 0; }
.t-screen { display: grid; place-items: center; min-width: 0; height: 100%; }
.t-screen video {
  --ar: 1.7778;
  display: block; width: min(100%, calc((100dvh - 48px) * var(--ar))); height: auto; aspect-ratio: var(--ar);
  background: #000; outline: none;
}
.t-nav {
  height: 140px; border: 0; background: none; color: #fff; font-size: 44px; line-height: 1; opacity: .5; cursor: pointer;
}
.t-nav:hover { opacity: 1; }
.t-nav:disabled { visibility: hidden; }
.t-info { overflow-y: auto; padding: 22px 26px 40px; border-left: 1px solid rgba(255, 255, 255, .09); }
.t-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.t-folder { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #97A29E; font-size: 13px; text-decoration: none; }
.t-folder:hover { color: #fff; text-decoration: underline; }
.t-close {
  flex: none; padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 7px; background: none;
  color: #fff; font-size: 13px; font-weight: 650; cursor: pointer;
}
.t-close:hover { background: rgba(255, 255, 255, .08); }
.t-info h2 { margin: 18px 0 0; font-size: 21px; font-weight: 750; font-stretch: 108%; line-height: 1.3; overflow-wrap: anywhere; }
.t-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 0; color: #C3CBC8; font-size: 13px; font-variant-numeric: tabular-nums; }
.t-info h3 { margin: 28px 0 6px; color: #97A29E; font-size: 13px; font-weight: 650; }
.t-list { margin: 0; padding: 0; list-style: none; }
.t-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 9px 0; border-top: 1px solid rgba(255, 255, 255, .09); font-size: 14px;
}
.t-list .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-list li.current .label { color: #fff; font-weight: 700; }
.t-list li.current .label::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 8px 1px 0; border-radius: 50%; background: #FF5C70;
}
.t-list .size { color: #97A29E; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.t-list .acts { display: flex; gap: 6px; }
.t-list button, .t-list .acts a {
  padding: 3px 10px; border: 1px solid rgba(255, 255, 255, .26); border-radius: 6px; background: none;
  color: #fff; font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.t-list button:hover, .t-list .acts a:hover { background: rgba(255, 255, 255, .1); }
.t-links { margin: 26px 0 0; }
.t-links a { color: #fff; font-size: 14px; font-weight: 600; }
.ghost { position: fixed; z-index: 55; object-fit: cover; transform-origin: 0 0; pointer-events: none; background: #000; }

/* ---- uploads, drop target, dialog, toast ------------------------------------------------------------------ */
.uploads {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; width: min(390px, calc(100vw - 32px));
  max-height: 60vh; overflow-y: auto; padding: 14px 16px 6px; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--glow); box-shadow: 0 14px 40px rgba(16, 28, 24, .16);
}
.up-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.up-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.up-hide { border: 0; background: none; color: var(--ink-2); font-size: 13px; cursor: pointer; padding: 2px 4px; }
#up-list { margin: 0; padding: 0; list-style: none; }
#up-list li { padding: 10px 0; border-top: 1px solid var(--rule); }
.up-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: baseline; font-size: 13.5px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.up-cancel { border: 0; background: none; color: var(--ink-2); font-size: 12.5px; cursor: pointer; padding: 0; }
.up-cancel:hover { color: var(--pencil); }
.up-bar { height: 3px; margin: 7px 0 5px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--pencil); transition: width .2s linear; }
.up-status { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
li.failed .up-status { color: var(--pencil); }
li.done .up-bar i { background: var(--ink-2); }

.drop {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--table) 82%, transparent);
}
.drop-mark {
  padding: 46px 60px; border: 3px dashed var(--pencil); border-radius: 22px; background: var(--glow);
  font-size: 20px; font-weight: 650; text-align: center; overflow-wrap: anywhere;
}

dialog {
  width: min(430px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--rule); border-radius: 14px;
  background: var(--glow); color: var(--ink);
}
dialog::backdrop { background: rgba(12, 18, 16, .38); }
dialog h2 { margin: 0; font-size: 19px; font-weight: 750; font-stretch: 108%; }
.fd-where { margin: 4px 0 18px; color: var(--ink-2); font-size: 13.5px; overflow-wrap: anywhere; }
.fd-where strong { color: var(--ink); font-weight: 600; }
dialog label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 650; }
dialog input { width: 100%; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--table); }
.fd-error { min-height: 20px; margin: 6px 0 12px; color: var(--pencil); font-size: 13px; }
.fd-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 9px; background: var(--ink); color: var(--table); font-size: 14px; font-weight: 600;
}

/* ---- smaller screens -------------------------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .bar { grid-template-columns: auto minmax(0, 1fr); }
  .crumbs { grid-column: 1 / -1; grid-row: 2; }
  .tools { justify-self: end; }
}
@media (max-width: 900px) {
  .theatre { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  .t-stage { grid-template-columns: 36px minmax(0, 1fr) 36px; padding: 12px 0; }
  .t-screen video { width: min(100%, calc(62dvh * var(--ar))); }
  .t-nav { height: 90px; font-size: 34px; }
  .t-info { border-left: 0; border-top: 1px solid rgba(255, 255, 255, .09); }
}
@media (max-width: 700px) {
  :root { --row-h: 168px; }
  .bar { grid-template-columns: 1fr; }
  .brand { font-size: 19px; }
  .tools { grid-row: 3; justify-self: stretch; flex-wrap: wrap; }
  .filter { flex: 1 1 100%; }
  .filter input { width: 100%; }
  .tools .btn { flex: 1; }
  .reel { gap: 22px 14px; }
  .film { max-width: calc(var(--h) * var(--ar) * 1.25); }
  .files .date { display: none; }
  .about-cols { grid-template-columns: 1fr; }
  .about-col[lang="en"] { margin-top: 18px; padding: 18px 0 0; border-left: 0; border-top: 1px solid var(--rule); }
}
@media (prefers-reduced-motion: reduce) {
  .loading-line { animation: none; background: var(--pencil); opacity: .45; }
  .mount img, .up-bar i { transition: none; }
}
