/* Strax
 *
 * A wall of photographs, so the photographs are the design and everything else
 * gets out of their way. The old version put each frame in a bordered card with
 * a caption bar under it, which meant a screen of boxes with pictures in them
 * rather than a screen of pictures.
 *
 * Near-black rather than dark grey: a photograph shown against #1c1f25 has its
 * shadows lifted by the surround, and a press box wall at night is bright
 * enough already.
 */

:root {
  --bg:      #08090b;
  --surface: #101216;
  --line:    #1e222a;
  --text:    #f2f4f7;
  --muted:   #8b94a3;
  --accent:  #fdb713;
  --live:    #3ddc84;
  --danger:  #ff6b70;

  --radius: 12px;
  --gap: 12px;

  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85em; }

/* ------------------------------------------------------------------- bar */

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1.1rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.bar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -.01em;
}

.bar p { margin: .1rem 0 0; font-size: .8rem; }
.bar__right { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }

/* The live indicator breathes, so a glance tells you the page is still
   listening rather than frozen on the last frame it received. */
.live { display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; color: var(--muted); }
.live__dot {
  width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 70%, transparent);
  animation: pulse 2.4s ease-out infinite;
}
.live.is-down .live__dot { background: var(--danger); animation: none; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  70%  { box-shadow: 0 0 0 .5rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ------------------------------------------------------------------ grid */

/* Uniform 3:2 cells, cropped to fill. Frames arrive in a mix of orientations
   and a ragged grid of true aspect ratios reads as clutter on a wall; the
   viewer shows the whole frame uncropped, which is where it matters.
   A fixed ratio also means the layout never jumps as lazy images arrive. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--gap);
  padding: var(--gap);
}

.tile {
  position: relative;
  margin: 0;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
  transition: transform .18s ease, box-shadow .18s ease;
}

.tile img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  /* Fades in rather than snapping, so a wall filling up during a match does
     not flicker at whoever is watching it. */
  opacity: 0;
  transition: opacity .3s ease;
}
.tile img.is-loaded { opacity: 1; }

@media (hover: hover) {
  .tile:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgb(0 0 0 / .55); }
  .tile:hover figcaption { opacity: 1; }
}

.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Over the photograph, not under it. Only on hover, because a caption that is
   always there is a caption you stop reading. */
.tile figcaption {
  position: absolute; inset: auto 0 0 0;
  padding: 2.2rem .7rem .6rem;
  display: grid; gap: .1rem;
  background: linear-gradient(to top, rgb(0 0 0 / .82), transparent);
  font-size: .8rem;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
.tile figcaption strong { font-weight: 600; }

/* No hover on a phone, so the caption would never be reachable. */
@media (hover: none) {
  .tile figcaption { opacity: 1; }
}

.tile--new { animation: arrive .45s cubic-bezier(.2, .8, .3, 1); }
@keyframes arrive {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .tile img, .tile figcaption { transition: none; }
  .tile--new { animation: none; }
  .live__dot { animation: none; }
}

/* ---------------------------------------------------------------- viewer */

.viewer {
  border: 0; padding: 0;
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
  background: #000; color: var(--text);
  overflow: hidden;
}
.viewer::backdrop { background: rgb(0 0 0 / .92); }

.viewer img {
  width: 100%;
  height: calc(100% - 3.5rem);
  object-fit: contain;
  display: block;
  background: #000;
}

.viewer__bar {
  height: 3.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 .9rem;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
}
.viewer__actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.viewer__count { font-variant-numeric: tabular-nums; }

/* Big enough to hit on a phone, quiet enough to ignore on a desktop. */
.viewer__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 3rem; height: 5rem;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius);
  background: rgb(0 0 0 / .35);
  color: #fff; font-size: 1.6rem; line-height: 1;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s ease, background .15s ease;
}
.viewer__nav:hover { opacity: 1; background: rgb(0 0 0 / .6); }
.viewer__nav--prev { left: .5rem; }
.viewer__nav--next { right: .5rem; }
.viewer__nav[disabled] { opacity: .15; cursor: default; }

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

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .85rem;
  border: 1px solid transparent; border-radius: 9px;
  background: var(--accent); color: #0d0e11;
  font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; white-space: nowrap;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface); filter: none; }
.btn--danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .4; cursor: not-allowed; filter: none; }

/* ----------------------------------------------------------------- cards */

.centered { display: grid; place-items: center; min-height: 100vh; padding: 1.2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem;
  display: grid; gap: .85rem;
  width: min(100%, 24rem);
}
.card h1 { margin: 0; font-size: 1.15rem; letter-spacing: -.01em; }

.card input,
.stack input {
  padding: .65rem .75rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
  font: inherit;
}
.card input:focus, .stack input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}

/* A code is read off a card and typed in — spaced and monospaced so a Z is not
   mistaken for a 2 halfway through. */
.card input[name="code"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: center;
  font-size: 1.05rem;
}

/* ------------------------------------------------------------ index list */

.galleries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--gap);
  padding: var(--gap);
}

.gcard {
  position: relative;
  display: block;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.gcard:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgb(0 0 0 / .55); }
.gcard img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .75; transition: opacity .18s ease; }
.gcard:hover img { opacity: .95; }

.gcard__body {
  position: absolute; inset: auto 0 0 0;
  padding: 2.5rem .9rem .85rem;
  background: linear-gradient(to top, rgb(0 0 0 / .88), transparent);
  display: grid; gap: .15rem;
}
.gcard__body strong { font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }

/* No photographs yet, so there is nothing to show behind the title. */
.gcard--bare { display: grid; place-items: center; aspect-ratio: 3 / 1; }
.gcard--bare .gcard__body { position: static; padding: 1rem; background: none; text-align: center; }

/* ----------------------------------------------------------------- misc */

.stack { display: grid; gap: .85rem; padding: 1.2rem; max-width: 44rem; margin: 0 auto; }
.stack--wide { max-width: 62rem; }

.error  { color: var(--danger); margin: 0; }
.notice { color: var(--live);   margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 4rem 1.5rem; }
.foot  { text-align: center; color: var(--muted); font-size: .78rem; padding: 2.5rem 1rem 3rem; }

/* ----------------------------------------------------------------- admin */

/* A panel is not a card. They shared a class, and .card is the narrow centred
   thing a guest types a code into — 24rem wide by design. Every admin section
   inherited that width inside a 62rem page, which is why a six-column table
   spilled out of its own box: the box was 384px no matter what was in it. */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  display: grid;
  gap: .9rem;
}

.panel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.panel__title { display: grid; gap: .1rem; min-width: 0; }
.panel__title strong { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; }
.panel h2 { margin: 0; font-size: .95rem; font-weight: 650; }

/* Facts as separate chips rather than one long sentence strung together with
   middots — at a glance you want to find one number, not read a paragraph. */
.facts { display: flex; flex-wrap: wrap; gap: .4rem; }
.fact {
  display: inline-flex; align-items: baseline; gap: .35rem;
  padding: .28rem .6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: .8rem; color: var(--muted);
  white-space: nowrap;
}
.fact b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.fact--warn b { color: var(--danger); }
.fact--open b { color: var(--live); }

/* The share code is the one thing on this page somebody reads out loud. */
.code-box {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .75rem .9rem;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.code-box__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.15rem; font-weight: 600; letter-spacing: .1em;
  color: var(--accent);
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row--actions { flex-wrap: wrap; justify-content: flex-start; gap: .5rem; }
.row--actions form { margin: 0; display: flex; gap: .4rem; align-items: center; }

/* Destructive things sit apart, after a rule, so the button you press by habit
   is never next to the one that deletes a job. */
.actions-danger {
  display: flex; flex-wrap: wrap; gap: .5rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}
.actions-danger form { margin: 0; }

/* Tables scroll inside themselves. A six-column log on a phone otherwise makes
   the whole page scroll sideways, which breaks every other panel with it. */
.table-wrap { overflow-x: auto; margin: 0 -.4rem; padding: 0 .4rem; }

.data { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: .84rem; }
.data th, .data td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.data tr:last-child td { border-bottom: 0; }
.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .35em;
}
