/*
 * @strongtechnical/ui: STS brand tokens and base component classes (docs/brand.md).
 *
 * Every colour is a token here; components never use a literal colour. Light is the default;
 * dark follows the system unless the header toggle pins one (html[data-theme="light"|"dark"],
 * remembered in the app's theme cookie). Blue is the single accent; signal colours are for
 * status only; the marquee light (warm bulb gold) marks only the thing that is moving.
 *
 * Use: in the app's own globals.css,
 *   @import "tailwindcss";
 *   @import "@strongtechnical/ui/styles/globals.css";
 *   @source "../../node_modules/@strongtechnical/ui/dist";
 * then the app's own classes after it.
 */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-wash: #f0f7fc; /* Blue Wash */
  --card: #ffffff; /* Paper */
  --fg: #1a1a1a; /* Ink */
  --muted: #5a6572; /* Slate */
  --line: #d9dee3; /* Mist */
  --accent: #1b8ccd; /* STS Blue */
  --accent-deep: #136394; /* Blue Deep */
  --tint: #d9ebf7; /* Blue Tint */
  --on-accent: #ffffff;
  --light: #e0a400; /* marquee light */
  --light-fill: #fbf0c8;
  --light-glow: rgba(240, 190, 80, 0.75);
  --light-label: #8a6500; /* the light's hue, dark enough to read on white */
  --on-light: #1a1a1a; /* text and glyphs on the light, both themes */
  --ok: #2e9e5b;
  --ok-tint: #ddf1e4;
  --warn: #e0a400;
  --warn-text: #8a6500; /* amber text on light grounds (contrast) */
  --warn-tint: #fbf1d1;
  --bad: #c4453a;
  --bad-tint: #f7dedb;
  --scrim: rgba(0, 0, 0, 0.4);
  --tile-band: #136394; /* content tile caption: Blue Deep in both themes, white text */
  --logo-light-display: inline;
  --logo-dark-display: none;
}

/* Dark: the system asks for it and the toggle does not pin light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171513;
    --bg-wash: #211e1a;
    --card: #1e1b18;
    --fg: #f4f0e8;
    --muted: #a39b8e;
    --line: #332e29;
    --accent: #1b8ccd;
    --accent-deep: #8cc8ee;
    --tint: #153449;
    --light: #e0a400;
    --light-fill: #3a2d12;
    --light-label: #f0be3a;
    --ok: #4cc27a;
    --ok-tint: #1f3a2a;
    --warn: #f0be3a;
    --warn-text: #f0be3a;
    --warn-tint: #3a2f14;
    --bad: #e0675c;
    --bad-tint: #4a2320;
    --scrim: rgba(0, 0, 0, 0.6);
    --logo-light-display: none;
    --logo-dark-display: inline;
  }
}

/* Dark pinned by the toggle (same values as above). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171513;
  --bg-wash: #211e1a;
  --card: #1e1b18;
  --fg: #f4f0e8;
  --muted: #a39b8e;
  --line: #332e29;
  --accent: #1b8ccd;
  --accent-deep: #8cc8ee;
  --tint: #153449;
  --light: #e0a400;
  --light-fill: #3a2d12;
  --light-label: #f0be3a;
  --ok: #4cc27a;
  --ok-tint: #1f3a2a;
  --warn: #f0be3a;
  --warn-text: #f0be3a;
  --warn-tint: #3a2f14;
  --bad: #e0675c;
  --bad-tint: #4a2320;
  --scrim: rgba(0, 0, 0, 0.6);
  --logo-light-display: none;
  --logo-dark-display: inline;
}

/* The names the components use, mapped onto the brand tokens. */
:root {
  --background: var(--bg);
  --surface: var(--card);
  --foreground: var(--fg);
  --border: var(--line);
  --brand: var(--accent);
  --brand-deep: var(--accent-deep);
  --brand-tint: var(--tint);
  --brand-foreground: var(--on-accent);
  --header: var(--card);
  --header-foreground: var(--fg);
  --ok-bg: var(--ok-tint);
  --warn-bg: var(--warn-tint);
  --danger: var(--bad);
  --danger-bg: var(--bad-tint);
}

@theme inline {
  --color-background: var(--background);
  --color-surface: var(--surface);
  --color-foreground: var(--foreground);
  --color-muted: var(--muted);
  --color-border: var(--border);
  --color-brand: var(--brand);
  --color-brand-foreground: var(--brand-foreground);
  --color-header: var(--header);
  --color-header-foreground: var(--header-foreground);
  --color-ok: var(--ok);
  --color-ok-bg: var(--ok-bg);
  --color-warn: var(--warn-text);
  --color-warn-bg: var(--warn-bg);
  --color-danger: var(--danger);
  --color-danger-bg: var(--danger-bg);
  --color-brand-deep: var(--brand-deep);
  --color-brand-tint: var(--brand-tint);
  --color-bg-wash: var(--bg-wash);
  --color-card: var(--card);
  --color-line: var(--line);
  --color-light: var(--light);
  --color-light-fill: var(--light-fill);
  --color-light-label: var(--light-label);
  --color-warn-text: var(--warn-text);
  --color-scrim: var(--scrim);
  --color-tile-band: var(--tile-band);
  --color-on-accent: var(--on-accent);
  --color-on-light: var(--on-light);
  --font-heading: var(--font-montserrat), var(--font-inter), system-ui, sans-serif;
  --font-sans: var(--font-inter), system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, Menlo, monospace;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
}
h1 {
  color: var(--fg);
  font-weight: 800;
}

/* The logo lockup for the theme: black on light, white on dark. */
.logo-for-light {
  display: var(--logo-light-display);
}
.logo-for-dark {
  display: var(--logo-dark-display);
}
h2 {
  color: var(--brand);
  font-weight: 600;
}

@layer components {
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
  }
  .input {
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
  }
  .input:focus {
    outline: 2px solid var(--brand);
    outline-offset: 0;
  }
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--foreground);
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
  }
  .btn:hover:not(:disabled) {
    border-color: var(--muted);
  }
  .btn:focus-visible,
  nav a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }
  .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }
  .btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-foreground);
  }
  .btn-primary:hover:not(:disabled) {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
  }
  .btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-accent);
  }
  .btn-danger:hover:not(:disabled) {
    filter: brightness(0.9);
    border-color: var(--danger);
  }
  .btn-sm {
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
  }
  /* Play: the marquee light, dark text in both themes. */
  .btn-light {
    background: var(--light);
    border-color: var(--light);
    color: var(--on-light);
    font-weight: 600;
  }
  .btn-light:hover:not(:disabled) {
    filter: brightness(1.06);
    border-color: var(--light);
  }
  /* The round play glyph over a tile: hidden until the tile (.has-play) is hovered or the glyph focused. */
  .play-glyph {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background: var(--light);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    display: grid;
    place-items: center;
    opacity: 0;
    /* Invisible means not clickable: a click on the tile's middle opens the tile, not the player. */
    pointer-events: none;
    cursor: pointer;
    z-index: 2;
  }
  .play-glyph span {
    border-style: solid;
    border-width: 0.5rem 0 0.5rem 0.8rem;
    border-color: transparent transparent transparent var(--on-light);
    margin-left: 0.2rem;
  }
  .has-play:hover .play-glyph,
  .play-glyph:focus-visible {
    opacity: 1;
    pointer-events: auto;
  }
  .play-glyph:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }
  .play-glyph:disabled {
    background: var(--muted);
    cursor: not-allowed;
  }
  /* Row tiles (48 x 72): a small glyph in the bottom-right corner, leaving the poster to the lightbox. */
  .play-glyph-corner {
    inset: auto 2px 2px auto;
    margin: 0;
    width: 1.5rem;
    height: 1.5rem;
  }
  .play-glyph-corner span {
    border-width: 0.3rem 0 0.3rem 0.5rem;
    margin-left: 0.1rem;
  }
  .play-glyph[data-busy] {
    opacity: 0.7;
  }
  .table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
  }
  .table th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
  }
  .table td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    vertical-align: top;
  }
  .badge {
    display: inline-block;
    border-radius: 9999px;
    padding: 0.05rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
  }
  .badge-warn {
    background: var(--warn-bg);
    color: var(--warn-text);
  }
  .badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
  }
  .badge-muted {
    background: var(--bg-wash);
    color: var(--muted);
    border: 1px solid var(--border);
  }
}

/*
 * Advanced view (2026-10-19): sections only STS admins see with "Show advanced" on carry a dashed
 * brand-tint edge and a small "Advanced" tag, so it is obvious what other users do not see.
 */
.adv {
  position: relative;
  border-left: 2px dashed var(--brand-tint);
  padding-left: 0.75rem;
}
.adv-tag {
  display: inline-block;
  border: 1px dashed var(--brand-tint);
  border-radius: 0.25rem;
  padding: 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: middle;
}
