/*
 * GladEyes theme for Meta Ray-Ban Display.
 * - Unlit black canvas (additive display: black pixels add no light).
 * - Bounded dark surfaces so text separates from the real world behind it.
 * - Focus is shown by outline + thicker accent edge + heavier text, never colour alone.
 * - Everything sizes from the viewport (600x600 is a test target, not a fixed size).
 */
:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #141a1f;
  --surface-2: #1e272e;
  --line: rgba(255, 255, 255, .2);
  --text: #f5f5f5;
  --muted: #b8b8b8;
  --accent: #2fe0c0;          /* mint-teal */
  --accent-soft: #0a3a33;
  --accent-ink: #04211d;
  --eye: #ff8a73;             /* coral: the happy eyes in the logo */
  --r-lg: 20px;
  --r-md: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body, #app { inline-size: 100%; block-size: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }

/* ---------- shell ---------- */
.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: .6rem;
  padding: .9rem 1.1rem 1rem;
  overflow: hidden;
}

.topbar { display: flex; align-items: center; gap: .9rem; min-inline-size: 0; }
.topbar-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--muted);
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem 1rem .35rem .8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.back:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

/* One scroll owner for the content area. Padding leaves room for focus outlines. */
.screen {
  min-block-size: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px 10px;
  scroll-padding-block: 1rem;
}

/* ---------- lists ---------- */
/* content-visibility keeps huge libraries fast, but it clips to the row's box, so the row
   carries padding to leave room for the 3px focus outline + offset. */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 6px 8px; content-visibility: auto; contain-intrinsic-size: auto 5.6rem; }

.item {
  display: flex;
  align-items: center;
  gap: .8rem;
  inline-size: 100%;
  min-block-size: 4.3rem;
  padding: .7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: start;
  cursor: pointer;
}
.item-text { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; gap: .1rem; }
.item-label {
  font-size: 1.4rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-sub { font-size: .95rem; color: var(--muted); }
.chev { flex: none; font-size: 1.9rem; line-height: 1; color: var(--muted); }

.item:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 9px 0 0 var(--accent);  /* structural cue: fat edge on the selected row (no layout shift) */
}
.item:focus .item-label { font-weight: 800; }
.item:focus .chev { color: var(--accent); }

.note { margin: .9rem .3rem 0; color: var(--muted); font-size: .95rem; }
.note-ver { font-size: .8rem; opacity: .7; }

/* ---------- A-Z jump strip (big libraries) ---------- */
.screen:has(.letters) { scroll-padding-top: 5rem; padding-top: 0; }   /* strip sticks flush to the top */
.letters {
  position: sticky; top: 0; z-index: 3;
  display: flex; gap: .5rem;
  padding: 8px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  scroll-padding-inline: 2.5rem;
  background: var(--bg);
}
.letters::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-inline-size: 3.2rem; block-size: 3.2rem;
  padding: 0 .8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1.3rem; font-weight: 700;
  cursor: pointer;
}
/* the letter you're currently viewing: accent text + a bar under it (not colour alone) */
.chip[aria-current="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: inset 0 -5px 0 var(--accent);
}
.chip:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
  box-shadow: none;
}

/* ---------- movie splash ---------- */
.splash { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: .9rem; block-size: 100%; min-block-size: 0; }
.splash-top { display: flex; gap: 1rem; align-items: flex-start; }
.poster {
  flex: none;
  inline-size: 34%;
  max-inline-size: 11rem;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}
.poster-missing { visibility: hidden; }
.splash-info { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; gap: .7rem; }
.splash-title {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta { margin: 0; color: var(--muted); font-size: 1rem; }
.summary {
  min-block-size: 0;
  overflow-y: auto;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: 1.1rem;
  line-height: 1.45;
}
.summary:focus { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:focus { outline: 3px solid #fff; outline-offset: 3px; }
.btn-primary:focus { box-shadow: 0 0 0 6px var(--accent-soft); }
.ico { display: inline-flex; }

/* ---------- status / errors ---------- */
.status {
  min-block-size: 60%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 1.2rem;
  text-align: center;
}
.panel {
  margin: .5rem 0;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  display: grid;
  gap: .8rem;
  justify-items: start;
}
.panel h2 { margin: 0; font-size: 1.4rem; }
.panel p { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.panel .small { font-size: .95rem; color: var(--muted); }

.spinner {
  inline-size: 2.2rem; block-size: 2.2rem;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- player ---------- */
.player { position: fixed; inset: 0; background: #000; }
.player video { inline-size: 100%; block-size: 100%; object-fit: contain; background: #000; }
.surface {
  position: absolute; inset: 0;
  border: 0; padding: 0; background: transparent;
  outline: none;
}
.loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem;
  font-size: 1.2rem;
  pointer-events: none;
}
.perr {
  position: absolute; inset-inline: 1.1rem; inset-block-start: 9%;
  max-block-size: 52%; overflow-y: auto;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: rgba(20, 20, 20, .95);
}
.perr h2 { margin: 0 0 .5rem; font-size: 1.4rem; }
.perr p { margin: 0; line-height: 1.35; font-size: .95rem; overflow-wrap: anywhere; white-space: pre-line; }

.controls {
  position: absolute; inset-inline: 0; inset-block-end: 0;
  padding: 3rem 1.1rem 1.2rem;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, .88) 45%);
}
.ptitle {
  margin: 0 0 .6rem;
  font-size: 1.1rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar { block-size: 8px; border-radius: 99px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.fill { block-size: 100%; inline-size: 0; background: var(--accent); }
.ptime { margin: .4rem 0 .8rem; font-size: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.ctl {
  min-block-size: 4rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  font-size: 1.15rem; font-weight: 700;
  cursor: pointer;
}
.ctl-main { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ctl:focus {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--accent-soft);
  font-weight: 900;
}

/* In the player the Back button floats over the video, top-left, only while controls are open. */
body.mode-player .app-shell { padding: 0; }
body.mode-player .topbar {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 20;
  padding: .9rem 1.1rem 2rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .85), transparent);
}

/* ---------- brand mark (Libraries screen) ---------- */
.brand { flex: none; inline-size: 2rem; block-size: 2rem; fill: none; }
.brand .b-brow { stroke: var(--accent); stroke-width: 7; stroke-linejoin: miter; stroke-miterlimit: 6; }
.brand .b-eye { stroke: var(--eye); stroke-width: 6.5; stroke-linecap: round; }

/* ---------- Play button on the movie splash ---------- */
.btn-play {
  gap: .85rem;
  min-block-size: 4.2rem;
  padding: .55rem 1.8rem .55rem .65rem;
  border-radius: 999px;
  font-size: 1.45rem;
  letter-spacing: .01em;
}
.play-badge {
  display: grid; place-items: center;
  inline-size: 3rem; block-size: 3rem;
  border-radius: 50%;
  background: var(--accent-ink);
  color: var(--accent);
  font-size: 1.7rem;
}
.play-badge .ico { display: grid; place-items: center; transform: translateX(.07em); }  /* optical centring of the triangle */
.btn-play:focus { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 7px var(--accent-soft); }

/* ---------- player: quiet "Controls" pill + stats line ---------- */
/* Always present and focusable (the glasses need something visible to select), but faint: it shows its label for a
   few seconds, then shrinks to three dots. */
.hint {
  position: absolute; inset-inline: 0; inset-block-end: 1rem;
  margin-inline: auto; inline-size: max-content;
  padding: .35rem 1rem;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  color: rgba(255, 255, 255, .7);
  font-size: .9rem; font-weight: 500;
  opacity: .85;
  cursor: pointer;
  transition: opacity .5s, padding .3s;
}
.hint .hint-dots { display: none; letter-spacing: .3em; font-weight: 700; line-height: 1; }
.hint.quiet { opacity: .5; padding: .2rem .9rem; }
.hint.quiet .hint-text { display: none; }
.hint.quiet .hint-dots { display: inline; }
.hint:focus { outline: 2px solid rgba(255, 255, 255, .55); outline-offset: 2px; color: #fff; background: rgba(0, 0, 0, .5); }
.pstat { margin: -.5rem 0 .7rem; font-size: .85rem; color: var(--muted); opacity: .85; font-variant-numeric: tabular-nums; }

/* ---------- small quiet button + diagnostics ---------- */
.btn-quiet { margin-top: .6rem; padding: .45rem 1.1rem; font-size: 1rem; font-weight: 600; color: var(--muted); border-radius: 999px; }
.diag-h { margin: .9rem 0 .3rem; font-size: 1rem; color: var(--accent); }
.diag-pre { margin: 0; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); font: .8rem/1.35 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.diag .btn { margin-top: 1rem; }

/* ---------- sign in / settings ---------- */
.signin { display: grid; gap: .5rem; justify-items: center; text-align: center; padding-top: .2rem; }
.signin-h { margin: 0; font-size: 1.5rem; }
.signin-p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.signin-p.small { font-size: .9rem; }
.signin-url { margin: 0; font-size: 1.7rem; font-weight: 800; color: #fff; }
.code {
  margin: .3rem 0; padding: .35rem 1.2rem .35rem 1.4rem;
  border: 2px solid var(--accent); border-radius: var(--r-lg);
  background: var(--surface);
  font: 800 3.4rem/1.1 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .12em; color: var(--accent);
}
.signin-timer { margin: 0; color: var(--muted); font-size: .95rem; font-variant-numeric: tabular-nums; }
.info { margin: 0 .2rem .6rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); font-size: 1rem; }
.info p { margin: .15rem 0; overflow-wrap: anywhere; }
.field-l { display: grid; gap: .3rem; inline-size: 100%; font-size: .95rem; color: var(--muted); }
.field {
  inline-size: 100%; padding: .65rem .9rem;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: #0d1216; color: var(--text); font: inherit; font-size: 1.1rem;
}
.field:focus { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- toast (short messages such as "Restored from GitHub") ---------- */
.toast {
  position: fixed; inset-inline: 1rem; inset-block-end: 1rem; z-index: 50;
  padding: .7rem 1rem;
  border: 1px solid var(--accent); border-radius: var(--r-lg);
  background: rgba(10, 58, 51, .95); color: #fff;
  font-size: 1.05rem; text-align: center;
}

/* ---------- page up / page down rail (long lists) ---------- */
.rail {
  position: fixed; inset-inline-end: .45rem; inset-block-end: .9rem;
  inline-size: 2.3rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 6;
}
.rail[hidden] { display: none; }
.rail-btn {
  flex: 1; min-block-size: 3rem;
  display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(20, 26, 31, .92); color: var(--muted);
  cursor: pointer;
}
.rail-btn svg { inline-size: 1.4rem; block-size: 1.4rem; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:focus { outline: 3px solid var(--accent); outline-offset: 2px; background: var(--accent); color: var(--accent-ink); }
.screen.rail-room { padding-inline-end: 3.4rem; }

/* ---------- film / episode page: Resume + Start from beginning ---------- */
.btn-start { min-block-size: 3.2rem; padding: .5rem 1.3rem; font-size: 1.15rem; border-radius: 999px; }
.splash-info > .btn { align-self: flex-start; }
.pbar { block-size: 6px; border-radius: 99px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.pfill { block-size: 100%; background: var(--accent); }
.poster.wide { aspect-ratio: 16 / 9; inline-size: 44%; max-inline-size: 15rem; }

/* ---------- in-app dimming ---------- */
.dim { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 1000; }
.screen:focus { outline: none; }

/* ---------- player: brightness + battery (top right, with the controls) ---------- */
.hud {
  margin-inline-start: auto;          /* the right-hand end of the top bar */
  display: flex; align-items: center; gap: .6rem;
}
.hud[hidden] { display: none; }
.hud-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(20, 26, 31, .92); color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.hud-btn svg { inline-size: 1.25rem; block-size: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.hud-btn:focus { outline: 3px solid var(--accent); outline-offset: 2px; background: var(--accent); color: var(--accent-ink); }
.batt {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(20, 26, 31, .92); color: #e8e8e8; font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.batt[hidden] { display: none; }
.batt svg { inline-size: 1.7rem; block-size: .9rem; }
.batt-body { fill: none; stroke: currentColor; stroke-width: 1.6; }
.batt-nub, .batt-fill { fill: currentColor; }
.batt-bolt { fill: #04211d; display: none; }
.batt.charging { color: var(--accent); }
.batt.charging .batt-bolt { display: block; }
.batt.low { color: var(--eye); }
