/* SiloCut — the public gallery at /gallery.
 *
 * ⚠️ IT DOES NOT LINK styles.css, AND THAT IS DELIBERATE. The app's stylesheet puts
 * `height: 100%; overflow: hidden` on html and body and lays the body out as the editor's
 * four-row grid — correct for an application that owns the viewport, wrong for a page that
 * scrolls. Linking it here would give the gallery a body it cannot scroll.
 *
 * So the TOKENS are copied across instead, verbatim, from styles.css's `:root`. Same greys, same
 * single muted accent, same radius, same font stack. No new palette: this is one product and the
 * gallery is not the place it starts looking like a different one. (styles.css belongs to another
 * agent in this wave and is not edited from here — copying the values is the whole reason this
 * duplication exists, and it is a small, stable set.)
 *
 * ⚠️ EVERY CLASS THAT CARRIES A `display` AND IS HIDDEN WITH THE ATTRIBUTE HAS ITS OWN
 * `[hidden] { display: none; }`. A `display` on a class outranks the UA sheet's
 * `[hidden] { display: none }`, and this codebase has hit that bug four times — most recently
 * where a hidden grid drew an empty box underneath the "nothing here yet" line while every test
 * still passed, because no test can see a stylesheet. The guards are asserted by
 * test/publicgallery.test.mjs.
 *
 * Class prefix is `pgal-` throughout. The editor's own export-history panel uses `gal-`, in
 * styles.css, and the two must never be confused for one another.
 */

:root {
  /* ── copied verbatim from styles.css ──────────────────────────────────── */
  --bg: #131315;
  --bg-2: #191a1d;
  --bg-3: #1f2024;
  --line: #2c2e33;
  --line-2: #3a3d44;
  --fg: #e8e8ea;
  --fg-2: #a5a7ad;
  --fg-3: #74777e;
  --accent: #6f8fd0;
  --danger: #d08a8a;
  --ok: #7fb08a;
  --warn: #d0b184;
  --radius: 4px;
  --stage-bg: #0d0d0f;
  --check-a: #232327;
  --check-b: #2a2a2e;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* ── this page only ───────────────────────────────────────────────────── */
  --page-w: 1180px;
  --tile-w: 216px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  /* NOT `overflow: hidden`. See the header — this page scrolls. */
  min-height: 100%;
  background: var(--bg);
}

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); }

/* ── the bar ──────────────────────────────────────────────────────────── */

.pgal-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 40px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}
.pgal-top[hidden] { display: none; }

.pgal-wordmark {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-decoration: none;
}

.pgal-where {
  color: var(--fg-3);
  font-size: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.pgal-spacer { flex: 1; }

/* One button shape for the whole page: the bar's link, the empty state's call to action, and the
   error state's retry are the same control wearing three labels. */
.pgal-btn {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  text-decoration: none;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.pgal-btn:hover { background: #26272c; }
.pgal-btn:active { transform: translateY(1px); }
.pgal-btn[hidden] { display: none; }

.pgal-btn.primary {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2));
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-3));
}
.pgal-btn.primary:hover { background: color-mix(in srgb, var(--accent) 28%, var(--bg-3)); }

/* ── the page ─────────────────────────────────────────────────────────── */

.pgal-page {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 26px 16px 64px;
}

/* The heading block. In four of the five states it IS the screen, so it centres itself and takes
   the height; with a grid under it, it is a quiet strip above the tiles. */
.pgal-state {
  display: block;
  padding: 0 0 20px;
}
.pgal-state[hidden] { display: none; }

.pgal-state.is-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  min-height: 52vh;
  padding: 0 0 24px;
}

.pgal-heading {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.pgal-state.is-full .pgal-heading { font-size: 20px; }

.pgal-note {
  margin: 6px 0 0;
  color: var(--fg-2);
  max-width: 58ch;
}
.pgal-state.is-full .pgal-note { margin: 0; }

/* The error state's note is the one somebody reads while worried, so it gets the warning colour —
   not the danger red, which reads as "your thing is broken" rather than "we could not look". */
.pgal-state[data-state="error"] .pgal-heading { color: var(--warn); }
.pgal-state[data-state="off"] .pgal-heading { color: var(--fg-2); }

.pgal-action {
  display: block;
  margin-top: 14px;
}
.pgal-action[hidden] { display: none; }

/* ── the grid ─────────────────────────────────────────────────────────── */

.pgal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr));
  gap: 14px;
}
.pgal-grid[hidden] { display: none; }

.pgal-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.pgal-tile:hover { border-color: var(--line-2); }
.pgal-tile[hidden] { display: none; }

/* The work itself. Square, and on the same checkerboard the editor's stage uses — most of what
   gets published here is cut out, so the transparency has to read as transparency rather than as
   a white box somebody forgot to crop. */
.pgal-shot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background-color: var(--stage-bg);
  background-image:
    linear-gradient(45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--check-a) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.pgal-shot[hidden] { display: none; }

.pgal-still,
.pgal-live {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.pgal-still[hidden] { display: none; }
.pgal-live[hidden] { display: none; }

/* What an animated item shows when the server has no still for it. Inert on purpose — the only
   other candidate for a "poster" is the animation itself, and an <img> pointed at a GIF plays the
   moment it loads. */
.pgal-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--fg-3);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.pgal-plate[hidden] { display: none; }

.pgal-play {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font: inherit;
  font-size: 11px;
  color: var(--fg);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.pgal-play:hover { background: var(--bg-3); }
.pgal-play[hidden] { display: none; }

.pgal-body {
  display: grid;
  gap: 6px;
  padding: 9px 10px 10px;
  min-width: 0;
}
.pgal-body[hidden] { display: none; }

.pgal-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pgal-by {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--fg-2);
  font-size: 11px;
}
.pgal-by[hidden] { display: none; }

.pgal-avatar {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  object-fit: cover;
}

/* The monogram, which is the NORMAL state — see avatarSource in src/ui/publicgallery.js for why a
   real Discord CDN avatar is refused until the server serves one from this origin. */
.pgal-mono {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-3);
}
.pgal-mono[hidden] { display: none; }

.pgal-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pgal-when {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--fg-3);
  font-size: 11px;
}
.pgal-when[hidden] { display: none; }

/* THE DOOR OUT — layer tiles only. Louder than the report control and quieter than the bar's
   primary button, because it is the point of this page but not the point of this tile: the work
   is. Tinted with the one accent the product already has rather than a new colour.

   ⚠️ THREE PROPERTIES NO TEST CAN SEE, ALL THREE LOAD-BEARING. `.pgal-body` is a GRID, so without
   `justify-self: start` this stretches the full width of the tile and reads as a banner. `a` is
   `color: var(--accent)` with the UA underline further up this file, so without
   `text-decoration: none` it arrives underlined and blue inside a chip. And the `[hidden]` rule is
   the fifth-time bug the header warns about — a `display` on a class outranks the UA sheet's
   `[hidden] { display: none }`. test/galleryuse.test.mjs pins all three as text. */
.pgal-use {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  font-size: 11px;
  color: var(--fg);
  text-decoration: none;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line-2));
  border-radius: var(--radius);
}
.pgal-use:hover { background: color-mix(in srgb, var(--accent) 26%, var(--bg-3)); }
.pgal-use:active { transform: translateY(1px); }
.pgal-use[hidden] { display: none; }

/* Quiet until you go looking for it. A report control shouted at from every tile turns the grid
   into a moderation queue; one that is not there at all is the liability. */
.pgal-report {
  justify-self: start;
  padding: 1px 6px;
  font: inherit;
  font-size: 11px;
  color: var(--fg-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.pgal-report:hover { color: var(--fg-2); border-color: var(--line); }
.pgal-report[data-state="armed"] { color: var(--warn); border-color: var(--line-2); }
.pgal-report[data-state="done"] { color: var(--ok); cursor: default; }
.pgal-report[data-state="failed"] { color: var(--danger); border-color: var(--line-2); }
.pgal-report[hidden] { display: none; }

/* ── more ─────────────────────────────────────────────────────────────── */

.pgal-more {
  display: block;
  margin: 22px auto 0;
  height: 28px;
  padding: 0 18px;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.pgal-more:hover { background: #26272c; }
.pgal-more[disabled] { color: var(--fg-3); cursor: default; }
.pgal-more[hidden] { display: none; }

/* ── foot ─────────────────────────────────────────────────────────────── */

.pgal-foot {
  display: block;
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 0 16px 30px;
  color: var(--fg-3);
  font-size: 11px;
}
.pgal-foot[hidden] { display: none; }

/* ── the two views ────────────────────────────────────────────────────────
   "Everyone" and "Mine". Quiet: a text pair with the current one underlined by the one accent this
   product already has. Not a segmented control, not pills, not a second navigation bar — the page
   has one header and this sits inside the content, above the heading it changes.

   ⚠️ EVERY CLASS BELOW THAT SETS A `display` CARRIES ITS OWN `[hidden]` RULE. See this file's
   header: a `display` on a class outranks the UA sheet's `[hidden] { display: none }`, this repo
   has hit it five times, and test/publicgallery.test.mjs scans for it mechanically. */

.pgal-tabs {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
}
.pgal-tabs[hidden] { display: none; }

.pgal-tab {
  display: inline-flex;
  align-items: center;
  padding: 2px 0;
  font-size: 12px;
  color: var(--fg-3);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.pgal-tab:hover { color: var(--fg-2); }
.pgal-tab.is-current {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.pgal-tab[hidden] { display: none; }

/* ── your own items ───────────────────────────────────────────────────────
   Everything here is scoped to a Mine tile and does not touch the public grid. */

/* The one fact this view exists to make visible: can strangers see this. It replaces the creator
   name, which on your own shelf would be your own name under every tile. */
.pgal-flag {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  height: 16px;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--fg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pgal-flag[data-state="public"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.pgal-flag[data-state="private"] { color: var(--fg-2); }
.pgal-flag[data-state="unknown"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.pgal-flag[hidden] { display: none; }

.pgal-owns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.pgal-owns[hidden] { display: none; }

/* The same weight as `.pgal-report` — quiet until you go looking. Three of these four change
   something on a public page, so none of them shouts and all of them carry a WORD: an unlabelled
   icon is not a shipped control. */
.pgal-own {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font: inherit;
  font-size: 11px;
  color: var(--fg-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.pgal-own:hover { color: var(--fg-2); border-color: var(--line); }
.pgal-own.is-on { color: var(--warn); border-color: var(--line); }
.pgal-own.is-danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.pgal-own[disabled] { color: var(--fg-3); opacity: 0.5; cursor: default; }
.pgal-own[hidden] { display: none; }

.pgal-tile.is-busy { opacity: 0.75; }

/* One outcome line. It is `role="status"`, so what goes in it is announced — which is the whole
   reason a failed take-down may never read like a successful one. */
.pgal-said {
  display: block;
  margin: 4px 0 0;
  color: var(--fg-2);
  font-size: 11px;
}
.pgal-said[hidden] { display: none; }

/* The page-level one — where a delete's outcome lands, because the tile it belonged to has gone. */
#pgalSaid { margin: 0 0 14px; }

/* ── the moderation page at /admin.html ───────────────────────────────────
   ⚠️ IT LIVES IN THIS FILE ON PURPOSE. One product, one palette, one set of tokens; a second
   stylesheet is how a second visual language starts. The prefix is `adm-` so a grep for one page's
   classes cannot land in the other's, exactly as `pgal-` exists so a grep cannot land in `gal-`.

   ⚠️ THE `[hidden]` SCAN IN test/publicgallery.test.mjs ONLY MATCHES `pgal-`, SO IT DOES NOT COVER
   ANY OF THIS. test/adminui.test.mjs runs the same scan over `adm-`; the rule is identical and it
   is enforced, just by a different file. */

.adm-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 40px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.adm-top[hidden] { display: none; }

.adm-page {
  display: block;
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 26px 16px 64px;
}
.adm-page[hidden] { display: none; }

.adm-state {
  display: block;
  padding: 0 0 18px;
}
.adm-state[hidden] { display: none; }

.adm-heading {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.adm-note {
  margin: 6px 0 0;
  color: var(--fg-2);
  max-width: 64ch;
}

.adm-said {
  display: block;
  margin: 10px 0 0;
  color: var(--fg-2);
  font-size: 11px;
}
.adm-said[hidden] { display: none; }

/* Everything below is BUILT BY THE MODULE, never by the markup. admin.html ships an empty box. */
.adm-body {
  display: block;
  margin-top: 20px;
}
.adm-body[hidden] { display: none; }

.adm-section {
  display: block;
  margin: 0 0 28px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--line);
}
.adm-section[hidden] { display: none; }

.adm-h2 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.adm-sub {
  margin: 0 0 12px;
  color: var(--fg-3);
  font-size: 11px;
  max-width: 64ch;
}

/* The kill switches. A SEPARATE REGION from the queue, deliberately: these change the product for
   everybody and a misclick here is an outage, not a moderation decision. */
.adm-flag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.adm-flag[hidden] { display: none; }

.adm-flagname {
  display: block;
  min-width: 0;
  flex: 1;
}
.adm-flagname[hidden] { display: none; }

.adm-flagstate {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--fg-3);
}
.adm-flagstate[data-state="on"] { color: var(--ok); }
.adm-flagstate[data-state="off"] { color: var(--danger); }
.adm-flagstate[data-state="unknown"] { color: var(--warn); }

.adm-btn {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  font: inherit;
  font-size: 11px;
  color: var(--fg);
  text-decoration: none;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.adm-btn:hover { background: #26272c; }
.adm-btn.is-danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line-2)); }
.adm-btn[disabled] { color: var(--fg-3); opacity: 0.5; cursor: default; }
.adm-btn[hidden] { display: none; }

/* One reported item. A row, not a card grid: a queue is read top to bottom. */
.adm-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.adm-row[hidden] { display: none; }

.adm-shot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  background-color: var(--stage-bg);
  background-image:
    linear-gradient(45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--check-a) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.adm-shot[hidden] { display: none; }

/* ⚠️ BLURRED UNTIL ASKED FOR, AND THIS IS A DUTY-OF-CARE DECISION RATHER THAN A SECURITY ONE. A
   moderation queue is where the worst thing anybody uploaded arrives, and it arrives without
   warning on a page somebody opened to clear a backlog. The still is there, it is just not thrown
   at them; the row's own control takes the blur off. */
.adm-still {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: blur(9px);
}
.adm-shot.is-shown .adm-still { filter: none; }
.adm-still[hidden] { display: none; }

.adm-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--fg-3);
  font-size: 10px;
  text-align: center;
  padding: 0 4px;
}
.adm-plate[hidden] { display: none; }

.adm-meta {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1;
}
.adm-meta[hidden] { display: none; }

.adm-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--fg-3);
  font-size: 11px;
}
.adm-facts[hidden] { display: none; }

/* ⚠️ WHAT A STRANGER TYPED. The server clamps it to 500 characters and this clamps it again; it is
   set with textContent and it is visually quoted so it reads as the reporter speaking rather than
   as the page saying something. It never goes in a title=, an aria-label or a confirmation. */
.adm-reason {
  display: block;
  margin: 0;
  padding: 4px 0 4px 8px;
  color: var(--fg-2);
  font-size: 11px;
  border-left: 2px solid var(--line-2);
  overflow-wrap: anywhere;
}
.adm-reason[hidden] { display: none; }

.adm-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.adm-acts[hidden] { display: none; }

.adm-foot {
  display: block;
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 0 16px 30px;
  color: var(--fg-3);
  font-size: 11px;
}
.adm-foot[hidden] { display: none; }

/* Nothing here moves on its own; this is the belt to that brace, for anything a browser would
   animate for us. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 520px) {
  :root { --tile-w: 148px; }
  .pgal-page { padding: 18px 12px 48px; }
}
