/* ============================================================
   放映室 · SCREENING ROOM
   ------------------------------------------------------------------
   两种版式，由 assets/room.js 按「屏幕比例 vs 片子比例」自动选：

     body.fill  宽屏（桌面 / 平板横屏 / 手机横屏）
                画面铺满整块屏幕，只裁掉最少的一圈，影院感。

     body.fit   竖屏（手机竖屏 / 平板竖屏 / 窄屏）
                2.24:1 的片子铺满竖屏要裁掉八成，那不叫看电影。
                所以改成整幅画面都在，上下空出来的地方用「环境光」
                （当前片子的封面放大糊掉）垫上，不是一块死黑。

   另外：刘海安全区、手指粗细的控件、进度线加大触摸区，
   都是冲着手机和平板去的。
   ============================================================ */

@font-face{
  font-family:'Archivo';
  font-style:normal;
  font-weight:400 800;
  font-display:swap;
  src:url('room/archivo-latin.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face{
  font-family:'Archivo';
  font-style:normal;
  font-weight:400 800;
  font-display:swap;
  src:url('room/archivo-latin-ext.woff2') format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020-20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

*,*::before,*::after{box-sizing:border-box}
html,body{height:100%}
html{-webkit-text-size-adjust:100%}

/* 视口尺寸交给 JS 写进来，手机上比 100vh 准（地址栏会伸缩） */
:root{--vw:100vw;--vh:100vh;--ar:1.7778}

body{
  margin:0;
  background:#000;
  color:#fff;
  font-family:'Archivo','PingFang SC','Hiragino Sans GB','Microsoft YaHei',system-ui,sans-serif;
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-tap-highlight-color:transparent;
}

/* ---------- 舞台 ---------- */
.stage{position:fixed;inset:0;background:#000;overflow:hidden}

/* 银幕后面那层环境光。只在 fit 版式下亮起来： */
.ambient{
  position:absolute;
  inset:-10%;
  background-position:center;
  background-size:cover;
  background-repeat:no-repeat;
  filter:blur(26px) saturate(1.35) brightness(.52) contrast(1.05);
  opacity:0;
  transition:opacity .7s cubic-bezier(.22,.61,.36,1);
  pointer-events:none;
}
body.fit .ambient{opacity:1}

/* 竖屏手机上「横过来看更满」的提示。只在一台设备上出现一次，几秒后自己退场。 */
.rot{
  position:fixed;
  left:50%;
  top:19%;
  z-index:6;
  transform:translate(-50%,-6px);
  display:none;
  align-items:center;
  gap:7px;
  padding:7px 13px;
  border-radius:999px;
  background:rgba(0,0,0,.52);
  border:1px solid rgba(255,255,255,.16);
  color:rgba(255,255,255,.86);
  font-size:12.5px;
  letter-spacing:.02em;
  white-space:nowrap;
  cursor:pointer;
  opacity:0;
  transition:opacity .5s cubic-bezier(.22,.61,.36,1), transform .5s cubic-bezier(.22,.61,.36,1);
}
.rot.on{display:flex;opacity:1;transform:translate(-50%,0)}
.rot i{font-style:normal;font-size:14px;color:#e3ad62}
@media (orientation:landscape){.rot{display:none!important}}

/* 银幕本身。
   两种版式都让这块盒子的比例**就等于片子的比例**，
   所以画面在盒子里不需要再裁 —— 裁多少只由屏幕和片子的比例差决定。 */
.stage-box{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
}

/* 铺满：盒子放大到盖住屏幕，长边溢出多少就裁多少 */
body.fill .stage-box{
  width:max(var(--vw), calc(var(--ar) * var(--vh)));
  height:max(var(--vh), calc(var(--vw) / var(--ar)));
}

/* 完整：盒子缩到屏幕里面，两边（或上下）留出环境光 */
body.fit .stage-box{
  width:min(var(--vw), calc(var(--ar) * var(--vh)));
  height:min(var(--vh), calc(var(--vw) / var(--ar)));
}

.player,.reel{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  border:0;
  display:block;
  background:#000;
}
/* 盒子比例已经等于片子比例，contain 和 fill 结果一样；contain 更稳 */
.player{object-fit:contain}
.player::-webkit-media-controls{display:none!important}
.reel[hidden],.player[hidden]{display:none}

/* B 站播放器回落到这一层时：把播放器放大，它自己的标题栏和底栏就被推到画面外。 */
.reel{inset:auto;left:-23%;top:-19%;width:146%;height:146%}

/* ---------- 压暗 + 暗角 ---------- */
.scrim{
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(180deg, rgba(0,0,0,.5), transparent 18%),
    linear-gradient(0deg, rgba(0,0,0,.62), transparent 26%);
}
/* fit 版式下画面不是满的，四周加一圈暗角，让中间的银幕浮出来 */
body.fit .scrim{
  background:
    radial-gradient(135% 105% at 50% 46%, rgba(0,0,0,0) 34%, rgba(0,0,0,.5) 78%, rgba(0,0,0,.86) 100%),
    linear-gradient(180deg, rgba(0,0,0,.42), transparent 20%),
    linear-gradient(0deg, rgba(0,0,0,.5), transparent 26%);
}

/* ---------- 点击区：整块画面都是播放/暂停 ---------- */
.tap{
  position:fixed;
  inset:0;
  z-index:3;
  width:100%;
  height:100%;
  border:0;
  padding:0;
  background:transparent;
  cursor:pointer;
  touch-action:manipulation;
}

/* ---------- 浮层 ---------- */
.hud{
  position:fixed;
  left:0;
  right:0;
  z-index:4;
  display:flex;
  gap:clamp(10px,2vw,26px);
  padding:clamp(14px,2.4vh,28px) clamp(16px,2.6vw,42px);
  pointer-events:none;
  transition:opacity .45s cubic-bezier(.22,.61,.36,1), transform .45s cubic-bezier(.22,.61,.36,1);
}
.hud a,.hud button,.hud .strip,.hud .ctl,.hud .progress{pointer-events:auto}
.hud button{touch-action:manipulation}

.hud-top{
  top:0;
  align-items:baseline;
  justify-content:space-between;
  gap:14px;
  padding-top:max(clamp(14px,2.4vh,28px), env(safe-area-inset-top));
  padding-left:max(clamp(16px,2.6vw,42px), env(safe-area-inset-left));
  padding-right:max(clamp(16px,2.6vw,42px), env(safe-area-inset-right));
  padding-bottom:clamp(30px,7vh,80px);
}
.hud-bot{
  bottom:0;
  flex-direction:column;
  gap:clamp(9px,1.5vh,16px);
  padding-left:max(clamp(16px,2.6vw,42px), env(safe-area-inset-left));
  padding-right:max(clamp(16px,2.6vw,42px), env(safe-area-inset-right));
  padding-bottom:max(clamp(14px,2.4vh,28px), env(safe-area-inset-bottom));
  padding-top:clamp(34px,9vh,96px);
}

body.idle .hud-top{transform:translateY(-8px)}
body.idle .hud-bot{transform:translateY(10px)}
body.idle .hud{opacity:0}
body.idle .hud:focus-within{opacity:1}
body.idle .progress i{opacity:.45}

/* 名字 + 返回 */
.mark{
  margin:0;
  display:flex;
  align-items:baseline;
  gap:clamp(8px,.9vw,14px);
  font-weight:600;
  min-width:0;
}
.m-zh{font-size:clamp(15px,1.5vw,20px);letter-spacing:.02em;white-space:nowrap}
.m-en{
  font-size:clamp(8.5px,.72vw,10.5px);
  font-weight:500;
  letter-spacing:.24em;
  text-transform:uppercase;
  opacity:.62;
  white-space:nowrap;
}
.back{
  font-size:clamp(11px,.85vw,12.5px);
  letter-spacing:.06em;
  color:rgba(255,255,255,.72);
  text-decoration:none;
  border-bottom:1px solid rgba(255,255,255,.28);
  padding-bottom:2px;
  white-space:nowrap;
}
.back:hover{color:#fff;border-color:#e3ad62}

/* ---------- 整卷 ---------- */
.strip{
  display:flex;
  gap:clamp(4px,.5vw,8px);
  max-width:100%;
}
.frame{
  position:relative;
  flex:0 0 auto;
  width:clamp(58px,7.4vw,120px);
  padding:0;
  border:0;
  background:none;
  cursor:pointer;
  border-radius:1px;
  overflow:hidden;
  touch-action:manipulation;
  scroll-snap-align:start;
}
.frame img{
  display:block;
  width:100%;
  height:auto;
  aspect-ratio:16/9;
  object-fit:cover;
  filter:saturate(.5) brightness(.66);
  transition:filter .32s cubic-bezier(.22,.61,.36,1), transform .32s cubic-bezier(.22,.61,.36,1);
}
.frame::after{
  content:attr(data-no);
  position:absolute;
  left:5px;
  bottom:3px;
  font-family:ui-monospace,'SF Mono','Cascadia Mono',Menlo,Consolas,monospace;
  font-size:11px;
  letter-spacing:.1em;
  color:rgba(255,255,255,.82);
  text-shadow:0 1px 3px rgba(0,0,0,.9);
}
.frame:hover img,.frame:focus-visible img{filter:none;transform:scale(1.04)}
.frame[aria-pressed="true"] img{filter:none}
.frame[aria-pressed="true"]{outline:2px solid #e3ad62;outline-offset:0}

/* ---------- 片名 + 控件 ---------- */
.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:clamp(12px,2.5vw,32px);
  flex-wrap:wrap;
}
.now{
  display:flex;
  align-items:baseline;
  gap:clamp(8px,.9vw,14px);
  min-width:0;
}
.n-no{
  font-family:ui-monospace,'SF Mono','Cascadia Mono',Menlo,Consolas,monospace;
  font-size:12px;
  font-weight:700;
  letter-spacing:.1em;
  color:#e3ad62;
}
.n-title{
  font-size:clamp(13px,1.35vw,18px);
  font-weight:600;
  text-shadow:0 1px 12px rgba(0,0,0,.7);
}
.n-len{
  font-family:ui-monospace,'SF Mono','Cascadia Mono',Menlo,Consolas,monospace;
  font-size:12px;
  letter-spacing:.06em;
  opacity:.6;
}

.ctl{
  display:flex;
  align-items:center;
  gap:clamp(4px,.6vw,10px);
}
.cb{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  padding:0;
  border:0;
  border-radius:2px;
  background:rgba(255,255,255,.08);
  color:#fff;
  cursor:pointer;
  transition:background .2s ease;
}
.cb:hover{background:rgba(255,255,255,.18)}
.cb:focus-visible{outline:2px solid #e3ad62;outline-offset:2px}
.cb svg{width:16px;height:16px;fill:currentColor}
.cb .ico-pause,.cb .ico-wave,.cb .ico-mute{display:none}
body.playing #playBtn .ico-play{display:none}
body.playing #playBtn .ico-pause{display:block}
body.muted #muteBtn .ico-wave{display:none}
body.muted #muteBtn .ico-mute{display:block}
body:not(.muted) #muteBtn .ico-wave{display:block}
body:not(.muted) #muteBtn .ico-mute{display:none}

/* 画质开关：显示当前实际在放哪一档，点一下循环 自动 → 4K → 1080P。
   宽度必须显式写成 .cb.qb —— 光写 .qb 会被后面 @media 里的 .cb{width:44px} 盖掉，
   文字就会溢出按钮、压在时间上。 */
.cb.qb{
  width:auto;
  min-width:38px;
  padding:0 10px;
}
.q-label{
  font-family:ui-monospace,'SF Mono','Cascadia Mono',Menlo,Consolas,monospace;
  font-size:11px;
  letter-spacing:.06em;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}
.qb[data-tier="1080"] .q-label{color:#ffc46b}
.qb[data-tier="2160"] .q-label{color:#7ee0a8}
body.embed .qb{display:none}

.time{
  font-family:ui-monospace,'SF Mono','Cascadia Mono',Menlo,Consolas,monospace;
  font-size:12px;
  letter-spacing:.04em;
  opacity:.72;
  flex:0 0 auto;
  min-width:9.5em;
  text-align:center;
  font-variant-numeric:tabular-nums;
}

.credit{
  margin:0;
  font-size:clamp(10.5px,.82vw,12px);
  line-height:1.6;
  color:rgba(255,255,255,.62);
  max-width:74ch;
}
.credit a{color:rgba(255,255,255,.9);text-decoration:underline;text-underline-offset:2.5px}
.credit a:hover{color:#e3ad62}

/* ---------- 进度线 ---------- */
.progress{
  position:fixed;
  left:0;
  right:0;
  bottom:env(safe-area-inset-bottom, 0);
  z-index:5;
  height:3px;
  background:rgba(255,255,255,.16);
  cursor:pointer;
  touch-action:none;
}
/* 3px 的线手指按不准，往上撑出一块透明的大触摸区 */
.progress::before{
  content:'';
  position:absolute;
  left:0;
  right:0;
  top:-26px;
  bottom:0;
}
.progress i{
  display:block;
  height:100%;
  width:0;
  background:#e3ad62;
  transition:width .18s linear, opacity .3s ease;
}
.progress:focus-visible{outline:2px solid #e3ad62;outline-offset:-2px}
.progress.drag{height:5px}
.progress .bubble{
  position:absolute;
  bottom:14px;
  transform:translateX(-50%);
  padding:3px 7px;
  border-radius:6px;
  background:rgba(0,0,0,.78);
  color:#fff;
  font-family:ui-monospace,'SF Mono','Cascadia Mono',Menlo,Consolas,monospace;
  font-size:11px;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
  opacity:0;
  transition:opacity .15s ease;
  pointer-events:none;
}
.progress.drag .bubble{opacity:1}

/* 回落到内嵌播放器时，自定义控件不适用 */
body.embed .ctl,body.embed .progress{display:none}

/* ============================================================
   窄屏 / 触屏
   ============================================================ */

/* 手指比鼠标粗：控件一律撑到 44px（苹果和谷歌都认的触摸下限） */
@media (pointer:coarse){
  .cb{width:44px;height:44px}
  .cb svg{width:18px;height:18px}
  .cb.qb{width:auto;min-width:44px;padding:0 12px}
  .frame{width:clamp(72px,17vw,104px)}
  .strip{
    overflow-x:auto;
    scrollbar-width:none;
    scroll-snap-type:x proximity;
    -webkit-overflow-scrolling:touch;
  }
  .strip::-webkit-scrollbar{display:none}
  .credit{font-size:11.5px}
}

@media (max-width:820px){
  .hud-top{padding-bottom:clamp(20px,5vh,48px)}
  .hud-bot{padding-top:clamp(22px,6vh,56px)}
  .m-en{display:none}
  .time{min-width:0;font-size:11.5px}
  .row{gap:8px}
  .credit{font-size:11px}
  /* B 站的小尺寸界面 chrome 占比大得多 */
  .reel{left:-42.5%;top:-42%;width:185%;height:185%}
}

/* 手机竖屏：底部这块要能放得下，片名单独一行，出处最多两行 */
@media (max-width:560px){
  .hud-top{padding-bottom:14px}
  .hud-bot{gap:8px;padding-top:16px}
  .row{flex-direction:column;align-items:flex-start;gap:9px}
  .ctl{width:100%;justify-content:space-between;gap:7px}
  .time{flex:0 0 auto;min-width:0;font-size:11px;letter-spacing:0}
  .q-label{font-size:10.5px;letter-spacing:0}
  .n-title{font-size:13.5px;line-height:1.35}
  .credit{
    font-size:10.5px;
    line-height:1.5;
    max-width:100%;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
  }
  .frame::after{font-size:10px}
}

/* 竖屏的平板和手机：画面在中间，字号再收一点 */
@media (orientation:portrait) and (max-width:1024px){
  .hud-top{padding-bottom:16px}
  .hud-bot{padding-top:20px}
}

/* 横屏手机：高度很浅，底部别堆太高 */
@media (orientation:landscape) and (max-height:460px){
  .hud-top{padding-top:8px;padding-bottom:10px}
  .hud-bot{padding-top:10px;gap:6px}
  .m-zh{font-size:14px}
  .credit{display:none}
  .frame{width:64px}
  .cb{width:38px;height:38px}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{transition-duration:.01ms!important}
}
