/* Web face — the admin design system (clients/admin/styles.css, from the
   owner's Figma mockup): five colours, Jersey 25, 5px borders, no radii, no
   shadows, uppercase controls. Tokens keep the admin's names; the accent is
   PRODUCT blue (--c) — the player-facing domain of the admin header.
   Differences from the admin are layout-only: this page must also work on a
   phone, so the frame is a single centred column, not a sidebar shell. */

@font-face {
  font-family: "Jersey 25";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/jersey25-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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Jersey 25";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/jersey25-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, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;

  /* palette — the whole of it */
  --black: #000000;
  --white: #ffffff;
  --red: #ff0000;
  --green: #00ff00;
  --blue: #0000ff;

  /* layout (admin tokens) */
  --header-h: 122px;
  --header-pad-x: 40px;
  --control-h: 46px;
  --border-w: 5px;
  --pad: 10px;
  --gap: 10px;
  --logo-w: 150px;
  --logo-h: 92px;
  --form-w: 464px; /* admin --search-w: the one column width of the login form */

  /* type */
  --font: "Jersey 25", system-ui, sans-serif;
  --fs-control: 24px;
  --fs-nav: 36px;
  --fs-body: 20px;

  /* the accent of this client */
  --c: var(--blue);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--white);
  color: var(--black);
  font: 400 var(--fs-body) / 1.2 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--black); }
a:hover { background: var(--black); color: var(--white); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8em; }

/* ------------------------------------------------------------ header --- */

.top {
  height: var(--header-h);
  padding: 0 var(--header-pad-x);
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--black);
  color: var(--white);
}

.logo { display: block; flex: none; }
.logo:hover { background: transparent; }
.logo img { display: block; width: var(--logo-w); height: var(--logo-h); object-fit: contain; }

.top-spacer { flex: 1; }

.top-note {
  font-size: 16px;
  color: var(--white);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.link {
  margin: 0;
  height: auto;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--white);
  background: transparent;
  color: var(--white);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
}
button.link:hover { background: var(--white); color: var(--black); }
button.link:focus-visible { outline: 3px dashed var(--white); outline-offset: 2px; }

/* --------------------------------------------------------- r/g/b tabs --- */

/* The three sections of the signed-in shell — the iOS MainTabsView band
   (CATALOG red / LIBRARY green / SETTINGS blue) on the web face: inactive =
   the tab's colour as ink on black, active = the colour as fill. */
.tabs { display: flex; background: var(--black); }
.tabs[hidden] { display: none; }

.tab {
  flex: 1;
  margin: 0;
  height: 52px;
  padding: 0;
  justify-content: center;
  border: 0;
  background: var(--black);
  font-size: var(--fs-control);
}
.tab.is-catalog { color: var(--red); }
.tab.is-library { color: var(--green); }
.tab.is-settings { color: var(--blue); }
.tab.is-catalog:hover, .tab.is-catalog.is-active { background: var(--red); color: var(--white); }
/* black on green — white on pure green is unreadable (the .tag.is-ok pairing) */
.tab.is-library:hover, .tab.is-library.is-active { background: var(--green); color: var(--black); }
.tab.is-settings:hover, .tab.is-settings.is-active { background: var(--blue); color: var(--white); }
.tab:focus-visible { outline: 3px dashed var(--white); outline-offset: -6px; }

/* -------------------------------------------------------------- main --- */

main { max-width: 1080px; margin: 0 auto; padding: 24px var(--header-pad-x) 64px; }

h1 {
  margin: 0 0 16px;
  font-size: var(--fs-nav);
  line-height: 1;
  font-weight: 400;
  text-transform: uppercase;
}

/* secondary text is smaller INK, not gray — the palette has five colours */
.muted { font-size: 16px; }
.hint { font-size: 16px; }
.error { color: var(--red); }
.error-title { color: var(--red); margin: 0 0 4px; text-transform: uppercase; }

/* ------------------------------------------------------------- forms --- */

label {
  display: block;
  margin: 16px 0 4px;
  font-size: var(--fs-body);
  text-transform: uppercase;
}

input[type="text"], input[type="password"], input[type="email"], .field {
  width: 100%;
  height: var(--control-h);
  padding: var(--pad);
  border: var(--border-w) solid var(--black);
  background: var(--white);
  color: var(--black);
  font: inherit;
  font-size: var(--fs-control);
  line-height: 1;
  min-width: 0;
}

input::placeholder { color: var(--black); opacity: 0.5; }

/* checkbox / radio rows (remember me, aspect settings) */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-size: var(--fs-body);
}
.check input { width: auto; height: auto; margin: 0; accent-color: var(--c); }

#screen-auth form, #screen-auth .panel { max-width: var(--form-w); }

details.operator {
  max-width: var(--form-w);
  margin-top: 40px;
  border-top: var(--border-w) solid var(--black);
  padding-top: 16px;
}
details.operator summary {
  font-size: var(--fs-body);
  text-transform: uppercase;
  cursor: pointer;
}

/* ----------------------------------------------------------- buttons --- */

button, .btn {
  margin: 12px 8px 0 0;
  height: var(--control-h);
  padding: var(--pad);
  display: inline-flex;
  align-items: center;
  gap: var(--gap);
  border: var(--border-w) solid var(--black);
  background: var(--white);
  color: var(--black);
  font: inherit;
  font-size: var(--fs-control);
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.btn { margin: 0; }

button:disabled { opacity: 0.5; cursor: default; }
button.primary, .btn.is-primary { background: var(--black); color: var(--white); }
button.danger, .btn.is-danger { border-color: var(--red); color: var(--red); }

button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px dashed var(--c);
  outline-offset: 2px;
}

/* ------------------------------------------------- panels and notices --- */

.panel, .card {
  margin-top: 20px;
  padding: var(--pad);
  border: var(--border-w) solid var(--black);
  background: var(--white);
}

.panel-title {
  font-weight: 400;
  margin: 0 0 4px;
  font-size: var(--fs-control);
  text-transform: uppercase;
}

.error-panel { border-color: var(--red); }

.notice {
  margin: 0 0 20px;
  padding: var(--pad);
  border: var(--border-w) solid var(--c);
  font-size: var(--fs-control);
  line-height: 1.1;
}
.notice.is-error { border-color: var(--red); color: var(--red); }
.notice.is-ok { border-color: var(--green); }

.tag {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--black);
  font-size: 15px;
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag.is-ok { background: var(--green); }
.tag.is-bad { background: var(--red); }
.tag.is-warn { background: var(--blue); color: var(--white); }

.scroll { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: var(--fs-body); line-height: 1.2; }
.grid th, .grid td { border: 1px solid var(--black); padding: 8px 10px; text-align: left; vertical-align: top; }
.grid th { background: var(--black); color: var(--white); font-weight: 400; text-transform: uppercase; white-space: nowrap; }

/* ---------------------------------------------------- waiting screen --- */

.track {
  height: 16px;
  margin: 16px 0;
  max-width: var(--form-w);
  border: 2px solid var(--black);
  background: var(--white);
  overflow: hidden;
}

.fill { height: 100%; width: 0; background: var(--c); transition: width 0.4s linear; }

.fill.indeterminate { width: 30%; animation: slide 1.6s ease-in-out infinite; }

/* Overdue (describeWait: past twice the 41 s yardstick): the wait itself is
   the news, so bar, title and clock go red together — the iOS loader does
   the same (SessionWaitNarration.Tone). */
.fill.is-overdue { background: var(--red); }
#wait-title.is-overdue, #wait-detail.is-overdue { color: var(--red); }

/* The outcome screen's closing line (a just-ended session still flushing its
   save in the background): the same track at half scale — a footnote under
   "Session over", not the main event. */
.track-slim { height: 8px; margin: 8px 0; max-width: 232px; border-width: 2px; }

@keyframes slide {
  0% { margin-left: -30%; }
  100% { margin-left: 100%; }
}

/* ----------------------------------------------------------- catalog --- */

.games {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.game-card {
  display: block;
  width: 100%;
  margin: 0;
  height: auto;
  padding: 0;
  border: var(--border-w) solid var(--black);
  background: var(--white);
  color: var(--black);
  font: inherit;
  text-align: left;
  text-transform: none;
  white-space: normal;
  cursor: pointer;
}
.game-card:hover { border-color: var(--c); }
.game-card:hover .g-title { color: var(--c); }
/* a library card whose game left the catalog: history, not a link */
.game-card:disabled { cursor: default; opacity: 1; }
.game-card:disabled:hover { border-color: var(--black); }
.game-card:disabled:hover .g-title { color: var(--black); }

.cover {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--black);
  overflow: hidden;
}
.cover img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cover.is-empty::after {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 96px;
  line-height: 1;
}

.g-meta { display: block; padding: var(--pad); }
.g-title { display: block; font-size: var(--fs-control); line-height: 1; text-transform: uppercase; }
.g-sub { display: block; margin-top: 6px; font-size: 15px; }

/* --------------------------------------------------------- game page --- */

.back-link {
  margin: 0 0 16px;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-body);
}
.back-link:hover { background: var(--black); color: var(--white); }

.game-hero { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; margin: 0 0 20px; }
.game-hero .cover { flex: 1 1 380px; max-width: 560px; border: var(--border-w) solid var(--black); }
.game-info { flex: 1 1 300px; min-width: 260px; }
.game-title { margin: 0 0 10px; }

.tags { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }

.lead { margin: 0 0 12px; font-size: var(--fs-control); line-height: 1.15; }

.btn-play {
  margin: 8px 0 0;
  height: auto;
  padding: 12px 40px;
  border-color: var(--c);
  color: var(--c);
  font-size: var(--fs-nav);
}
.btn-play:hover { background: var(--c); color: var(--white); }

.game-desc { max-width: 75ch; white-space: pre-line; margin: 0 0 20px; }

.shots {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  margin: 0 0 16px;
  padding-bottom: 6px;
}
.shots img { display: block; height: 200px; border: 1px solid var(--black); background: var(--black); }

/* a screenshot is a button into the fullscreen viewer, chromeless on purpose */
.shot {
  margin: 0;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  flex: none;
  cursor: zoom-in;
}
.shot:hover img { border-color: var(--c); }

/* ------------------------------------------- fullscreen shot viewer --- */

#shot-viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
}
/* author display:flex would beat the UA [hidden] rule — restate it */
#shot-viewer[hidden] { display: none; }

#shot-image {
  display: block;
  max-width: calc(100vw - 130px);
  max-height: calc(100vh - 56px);
  border: var(--border-w) solid var(--white);
  background: var(--black);
}

#shot-viewer button {
  margin: 0;
  border-color: var(--white);
  background: var(--black);
  color: var(--white);
}
#shot-viewer button:hover { background: var(--white); color: var(--black); }
#shot-viewer button:focus-visible { outline-color: var(--white); }
#shot-prev, #shot-next { position: absolute; top: 50%; transform: translateY(-50%); }
#shot-prev { left: 10px; }
#shot-next { right: 10px; }
#shot-close { position: absolute; top: 10px; right: 10px; }
#shot-counter {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  color: var(--white);
  font-size: 16px;
}

/* ------------------------------------------------------ player #/play --- */

#screen-play { position: fixed; inset: 0; z-index: 50; background: var(--black); }

.play-stage { position: absolute; inset: 0; background: var(--black); }

.play-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--black);
}

/* author display:flex would beat the UA [hidden] rule — restate it
   (the same trap the admin's .chart-tip documents) */
.play-overlay[hidden], .play-panel[hidden] { display: none; }

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
  color: var(--white);
}

.play-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px;
  border: var(--border-w) solid var(--white);
  background: var(--black);
  text-align: center;
  max-width: 90vw;
}

.play-title { margin: 0; font-size: var(--fs-nav); line-height: 1; text-transform: uppercase; }
.play-note { margin: 0; font-size: 16px; }

.play-cta, .play-danger { margin: 0; background: var(--black); }
.play-cta { border-color: var(--white); color: var(--white); font-size: var(--fs-nav); height: auto; padding: 14px 36px; }
.play-cta:hover { background: var(--white); color: var(--black); }
.play-danger { border-color: var(--red); color: var(--red); }
.play-danger:hover { background: var(--red); color: var(--black); }
.play-cta:focus-visible, .play-danger:focus-visible { outline-color: var(--white); }

/* start state: the stream stays VISIBLE — the overlay is a transparent
   click-catcher (any click goes fullscreen) with a dimmed hint box, not a
   curtain. The paused dialog keeps the solid black default: it covers a
   game that captured the pointer a moment ago. Журнал (217). */
.play-overlay.is-start { background: transparent; cursor: pointer; }
.play-overlay.is-start .play-panel { background: rgba(0, 0, 0, 0.65); }

/* ------------------------------------------------------------- phone --- */

@media (max-width: 720px) {
  :root {
    --header-h: 72px;
    --header-pad-x: 16px;
    --logo-w: 98px;
    --logo-h: 60px;
    --fs-nav: 28px;
    --fs-control: 20px;
  }
  main { padding: 16px 16px 48px; }
  .games { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cover.is-empty::after { font-size: 64px; }
  .shots img { height: 140px; }
  /* the arrows ride over the image on a phone — width is the scarce side */
  #shot-image { max-width: 100vw; max-height: calc(100vh - 56px); border-left: 0; border-right: 0; }
  /* the play overlays: finger-sized, and inside the safe area of a notched
     phone in landscape (the stage itself stays edge-to-edge) */
  .play-panel {
    padding: 22px 18px;
    gap: 12px;
    max-width: min(90vw, 480px);
    margin-left: env(safe-area-inset-left, 0px);
    margin-right: env(safe-area-inset-right, 0px);
  }
  .play-cta { font-size: 22px; padding: 12px 26px; }
  .play-note { font-size: 14px; }
}
