/* LoreBoard — shared.css
 * Components shared by every surface and by the dashboard views.
 * Everything is driven by the CSS custom properties that render.js writes
 * onto the app container from the config theme. No external assets.
 */

/* ------------------------------------------------------------- defaults */
/* Theme fallbacks. render.js overwrites the color, radius, opacity and font
 * values on the container; the spacing and touch sizes are not themed. */
.sb-app {
  --sb-bg: #0e0e10;
  --sb-bg-a: rgba(14, 14, 16, 0.92);
  --sb-fg: #efeff1;
  --sb-accent: #9146ff;
  --sb-accent-soft: rgba(145, 70, 255, 0.18);
  --sb-accent-fg: #ffffff;
  --sb-radius: 8px;
  --sb-radius-sm: 5px;
  --sb-opacity: 0.92;
  --sb-card: rgba(255, 255, 255, 0.07);
  --sb-card-hover: rgba(255, 255, 255, 0.13);
  --sb-border: rgba(239, 239, 241, 0.16);
  --sb-border-strong: rgba(239, 239, 241, 0.3);
  --sb-muted: rgba(239, 239, 241, 0.66);
  --sb-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --sb-gap: 10px;
  --sb-pad: 12px;
  --sb-touch: 36px;

  color: var(--sb-fg);
  font-family: var(--sb-font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.sb-app *,
.sb-app *::before,
.sb-app *::after { box-sizing: border-box; }

.sb-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------- tray */

.sb-tray {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sb-bg-a);
  color: var(--sb-fg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.sb-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sb-gap);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border-strong) transparent;
}

.sb-scroll::-webkit-scrollbar { width: 8px; }
.sb-scroll::-webkit-scrollbar-track { background: transparent; }
.sb-scroll::-webkit-scrollbar-thumb {
  background: var(--sb-border-strong);
  border-radius: 4px;
}

/* ----------------------------------------------------------------- tabs */

.sb-tabs {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 8px 0 8px;
  border-bottom: 1px solid var(--sb-border);
  background: var(--sb-card);
}

.sb-tab {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--sb-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: var(--sb-radius-sm) var(--sb-radius-sm) 0 0;
  padding: 0 12px;
  min-height: var(--sb-touch);
  cursor: pointer;
  white-space: nowrap;
}

.sb-tab:hover { color: var(--sb-fg); background: var(--sb-card-hover); }
.sb-tab.is-active {
  color: var(--sb-fg);
  border-bottom-color: var(--sb-accent);
  background: var(--sb-accent-soft);
}
.sb-tab:focus-visible,
.sb-pill:focus-visible,
.sb-link:focus-visible,
.sb-select:focus-visible {
  outline: 2px solid var(--sb-accent);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- grid */

.sb-grid {
  display: grid;
  gap: var(--sb-gap);
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.sb-grid[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sb-grid[data-cols="2"] > .sb-block[data-size="wide"] { grid-column: 1 / -1; }

.sb-empty {
  margin: 0;
  padding: var(--sb-pad);
  color: var(--sb-muted);
  font-size: 13px;
}

/* --------------------------------------------------------------- blocks */

.sb-block {
  min-width: 0;
  background: var(--sb-card);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  padding: var(--sb-pad);
}

.sb-block-title {
  margin: 0 0 7px 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--sb-fg);
  /* A title with no spaces must break at the card edge, not overflow it —
   * half-width cards are ~150px in a 318px panel. */
  overflow-wrap: anywhere;
}

.sb-block-body { min-width: 0; }

/* ------------------------------------------------------------ rich text */

.sb-rt > :first-child { margin-top: 0; }
.sb-rt > :last-child { margin-bottom: 0; }

.sb-rt-p {
  margin: 0 0 9px 0;
  font-size: 15.5px;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: break-word;
}

.sb-rt-h {
  margin: 12px 0 6px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--sb-fg);
}

.sb-rt-ul {
  margin: 0 0 8px 0;
  padding-left: 18px;
  list-style: disc;
}

.sb-rt-ul li { margin: 0 0 4px 0; overflow-wrap: break-word; }
.sb-rt strong { font-weight: 700; color: var(--sb-fg); }
.sb-rt em { font-style: italic; }

/* --------------------------------------------------------------- select */

.sb-select {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  min-height: var(--sb-touch);
  padding: 6px 30px 6px 10px;
  margin: 0 0 10px 0;
  font: inherit;
  font-size: 14px;
  color: var(--sb-fg);
  background-color: var(--sb-bg);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% + 1px), calc(100% - 11px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--sb-border-strong);
  border-radius: var(--sb-radius-sm);
  cursor: pointer;
}

.sb-select option { color: #111; background: #fff; }

/* ---------------------------------------------------------------- links */

.sb-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--sb-touch);
  padding: 8px 10px;
  color: var(--sb-fg);
  text-decoration: none;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius-sm);
}

.sb-link:hover,
.sb-link:focus { background: var(--sb-card-hover); border-color: var(--sb-accent); }

.sb-link-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  overflow-wrap: break-word;
}

/* Off-site indicator — Twitch Guidelines 4.6.2. Always visible. */
.sb-ext-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--sb-accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-links-note {
  margin: 8px 0 0 0;
  font-size: 11px;
  color: var(--sb-muted);
}

/* ------------------------------------------------------------- countdown */

/* The readout centers in whatever height the card ends up with: in a two-column
   row the neighboring card usually sets that height. */
.sb-block-countdown { display: flex; flex-direction: column; }
.sb-block-countdown .sb-count {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 2.4em;
}

/* The target moment in the viewer's own local time, under the counter. */
.sb-count-when {
  margin: 0;
  font-size: 11.5px;
  color: var(--sb-muted);
  text-align: center;
}

.sb-count-time {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  overflow-wrap: anywhere;   /* long end messages break, not overflow */
  /* Fixed-width digits so the readout does not wobble as it ticks. */
  font-variant-numeric: tabular-nums;
}

.sb-count-time.is-done {
  font-size: 18px;
  color: var(--sb-accent);
}

/* Developer attribution, pinned under the scrolling content rather than inside
 * it: it is chrome, not board content, so it does not scroll away. Quiet by
 * default, readable on hover. */
.sb-attrib {
  margin: 0;
  padding-top: 10px;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  color: var(--sb-muted);
}

.sb-attrib-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.sb-attrib-link:hover,
.sb-attrib-link:focus-visible {
  color: var(--sb-fg);
  text-decoration: underline;
}

/* ----------------------------------------------------------------- pill */

/* Base pill. Which border is dropped and which corners are rounded depends on
 * the edge it is anchored to — viewer.css owns that, per anchor. */
.sb-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--sb-fg);
  background: var(--sb-bg-a);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  white-space: nowrap;
}

/* Labels are capped at 16 characters by the schema, so the pill can size to
 * its text; the ellipsis is only a guard against an out-of-band config. */
.sb-pill-label {
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-pill:hover { background: var(--sb-card-hover); }

.sb-pill-icon,
.sb-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-pill-icon { stroke: var(--sb-accent); }
.sb-chevron { transition: transform 0.18s ease; }
.is-open .sb-chevron { transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  .sb-chevron { transition: none; }
}
