/*
 * theme.css — shared design tokens & components for Graveyard Squad
 * (250_IDEAS.md section 11: Design system & visual polish, items 176-190)
 *
 * Idea #176: a single shared source of truth for the CSS custom properties
 * that roster.html, player.html, link.html, and admin.html each used to
 * redefine independently in their own :root blocks. Each template still
 * keeps a local :root for page-specific extras, but the canonical palette,
 * spacing scale, and shared components now live here, loaded via
 * <link rel="stylesheet" href="/static/theme.css"> before each page's own
 * <style> block (so a page's local :root can still override a token if it
 * genuinely needs to, but no longer has to redeclare the whole palette).
 *
 * Idea #178: this file (plus STYLE_GUIDE.md) is the documentation of the
 * color tokens, spacing scale, and type scale referenced there.
 */

:root {
  /* --- Color tokens (shared across all four templates) --- */
  --gy-bg:        #0b0c10;
  --gy-surface:   #111418;
  --gy-panel:     #111820;
  --gy-border:    #1e2530;
  --gy-accent:    #00e5ff;
  --gy-ok:        #00e096;
  --gy-warn:      #ffaa00;
  --gy-err:       #ff3d71;
  --gy-text:      #c5c6c7;
  --gy-dim:       #888;
  --gy-text-bright: #f0f0f0; /* idea #171: off-white instead of pure white */

  /* --- Spacing scale (idea #185) — standardizes the 8/10/12/14/16/20/24px
     values that were scattered ad hoc through each template's CSS. New
     components in this file use these tokens; existing per-page rules are
     left as-is to avoid a risky full rewrite, but should migrate here over
     time. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* --- Type scale (idea #178) --- */
  --font-mono: 'Share Tech Mono', monospace;
  --font-ui:   'Barlow Condensed', sans-serif;
  --text-xs:  11px;
  --text-sm:  13px;
  --text-md:  15px;
  --text-lg:  20px;
  --text-xl:  28px;
}

/* Idea #187: light theme override. Toggled by adding data-theme="light" to
   <html> (see the toggleTheme() JS added to each page); dark stays default. */
html[data-theme="light"] {
  --gy-bg:        #f4f5f7;
  --gy-surface:   #ffffff;
  --gy-panel:     #ffffff;
  --gy-border:    #d7dbe0;
  --gy-text:      #23272e;
  --gy-dim:       #6b7280;
  --gy-text-bright: #0b0c10;
}
html[data-theme="light"] body { background: var(--gy-bg); }

.theme-toggle-btn {
  background: none; border: 1px solid var(--gy-border, #1e2530); border-radius: 4px;
  color: var(--gy-dim, #888); font-size: 14px; padding: 4px 10px; cursor: pointer;
}
.theme-toggle-btn:hover { color: var(--gy-text-bright, #f0f0f0); }

/* Idea #182: a shared button base. Existing button classes
   (.btn-refresh/.btn-danger/.btn-strike/.btn-dm/.btn-save/...) are left in
   place so nothing visually regresses; this base class is meant for new
   buttons going forward and can be added alongside an existing class
   (class="btn btn-refresh") to pick up the shared focus/active handling. */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: 4px; border: 1px solid var(--gy-border);
  font-family: var(--font-ui); font-weight: 700; font-size: var(--text-sm);
  letter-spacing: 0.5px; text-transform: uppercase; cursor: pointer;
  background: rgba(255,255,255,0.04); color: var(--gy-text);
  transition: background .15s, opacity .15s, transform .1s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Idea #190: every interactive control gets a distinct :active state, not
   just :hover — a quick "press" feedback via scale, on top of whatever
   hover/focus-visible treatment the element already defines. */
button:not(:disabled):active,
.btn:not(:disabled):active,
a.btn:not(:disabled):active {
  transform: scale(0.97);
}

/* Idea #177: one documented card pattern. admin.html's .diag-card and the
   public pages' various "dash-card"/panel blocks are visually near-identical
   but were built independently — .card is the consolidated version new
   panels should use. */
.card {
  background: var(--gy-panel); border: 1px solid var(--gy-border);
  border-radius: 6px; padding: var(--space-4);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.card-title {
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 2px;
  text-transform: uppercase; color: var(--gy-accent); margin-bottom: var(--space-3);
  padding-bottom: var(--space-2); border-bottom: 1px solid var(--gy-border);
}

/* Idea #186: a subtle "freshness" glow on stat cards, based on a
   data-fresh="true|false" attribute set by each page's own JS once it knows
   how old the underlying data is (e.g. last harvest run < 1hr old). */
.card[data-fresh="true"], .stat-card[data-fresh="true"] {
  box-shadow: 0 0 0 1px rgba(0,224,150,0.35), 0 4px 15px rgba(0,0,0,0.3);
}
.card[data-fresh="false"], .stat-card[data-fresh="false"] {
  box-shadow: 0 0 0 1px rgba(255,170,0,0.25), 0 4px 15px rgba(0,0,0,0.3);
}
.freshness-label {
  font-family: var(--font-mono); font-size: 10px; color: var(--gy-dim);
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
}
.freshness-label.fresh::before { content: '●'; color: var(--gy-ok); }
.freshness-label.stale::before { content: '●'; color: var(--gy-warn); }

/* Idea #180: reusable empty-state component (icon + heading + subtext)
   instead of a bare "No battles found" text line. */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--space-6) var(--space-4); color: var(--gy-dim);
}
.empty-state-icon { font-size: 32px; margin-bottom: var(--space-2); opacity: 0.7; }
.empty-state-title { font-weight: 700; color: var(--gy-text); margin-bottom: 4px; font-size: var(--text-md); }
.empty-state-sub { font-size: var(--text-sm); }

/* Idea #181: skeleton loading placeholders instead of a spinner + "Loading…"
   text line, for a more modern perceived-performance feel. */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 37%, rgba(255,255,255,0.04) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 4px;
}
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-40 { width: 40%; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; opacity: 0.6; }
}

/* Idea #179: consistent sizing/baseline for the emoji-as-icon approach used
   throughout instead of a real icon font — keeps the playful tone but stops
   size/weight from drifting instance to instance. See STYLE_GUIDE.md for the
   agreed emoji-to-concept mapping. */
.icon { display: inline-block; font-size: 1em; line-height: 1; vertical-align: -0.1em; }


/* ==========================================================================
   Graveyard Squad — Compact Header, Hamburger Popover, Collapsible Panels
   & Mobile-First Polish (2026-11-23)
   ========================================================================== */

:root {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

/* Sticky compact single-row header */
.gy-header {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  min-height: 56px;
  background: color-mix(in srgb, var(--gy-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gy-border);
}

.gy-brand {
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gy-accent);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.gy-brand span {
  color: var(--gy-text-bright);
  font-weight: 600;
}

.gy-header-search {
  flex: 1;
  max-width: 300px;
  min-width: 120px;
}

.gy-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.gy-menu-btn {
  anchor-name: --gy-menu-btn;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--gy-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--gy-text-bright);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.gy-menu-btn:hover {
  border-color: var(--gy-accent);
  color: var(--gy-accent);
}

.gy-menu-btn:focus-visible {
  outline: 2px solid var(--gy-accent);
  outline-offset: 2px;
}

/* Native Popover Hamburger Menu */
.gy-menu-popover {
  position: fixed;
  inset: auto;
  inset-block-start: 4rem;
  inset-block-start: anchor(--gy-menu-btn bottom);
  inset-inline-end: 14px;
  inline-size: min(88dvw, 310px);
  max-inline-size: calc(100dvw - 24px);
  block-size: fit-content;
  max-block-size: calc(100dvh - 5rem);
  margin-block-start: 8px;
  padding: 12px;
  overflow-y: auto;
  background: var(--gy-panel);
  color: var(--gy-text);
  border: 1px solid var(--gy-border);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}

.gy-menu-popover::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.gy-menu-popover:is(:popover-open, .\:popover-open) {
  display: grid;
  gap: 6px;
}

@media (prefers-reduced-motion: no-preference) {
  .gy-menu-popover {
    opacity: 0;
    translate: 0 -6px;
    transition: opacity 0.16s ease, translate 0.16s ease, display 0.16s ease, overlay 0.16s ease;
    transition-behavior: allow-discrete;
  }
  .gy-menu-popover:is(:popover-open, .\:popover-open) {
    opacity: 1;
    translate: 0 0;
  }
  @starting-style {
    .gy-menu-popover:is(:popover-open, .\:popover-open) {
      opacity: 0;
      translate: 0 -6px;
    }
  }
}

.gy-menu-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gy-dim);
  padding: 8px 8px 2px;
}

.gy-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gy-text-bright);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.gy-menu-item:hover {
  background: rgba(0, 229, 255, 0.09);
  border-color: rgba(0, 229, 255, 0.25);
  color: var(--gy-accent);
}

.gy-menu-item[aria-current="page"] {
  background: rgba(0, 229, 255, 0.12);
  border-color: rgba(0, 229, 255, 0.45);
  color: var(--gy-accent);
}

.gy-menu-divider {
  height: 1px;
  background: var(--gy-border);
  margin: 4px 0;
}

.gy-menu-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
}

/* Slim status metadata strip under header */
.gy-meta-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--gy-border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gy-dim);
}

.gy-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gy-surface);
  border: 1px solid var(--gy-border);
  color: var(--gy-text);
  white-space: nowrap;
}

/* Collapsible <details class="gy-collapse"> sections */
details.gy-collapse {
  background: var(--gy-panel);
  border: 1px solid var(--gy-border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: clip;
}

details.gy-collapse > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gy-text-bright);
  user-select: none;
  transition: background-color 0.15s ease;
}

details.gy-collapse > summary::-webkit-details-marker {
  display: none;
}

details.gy-collapse > summary::before {
  content: "▸";
  display: inline-block;
  color: var(--gy-accent);
  font-size: 14px;
  line-height: 1;
  transition: rotate 0.18s ease;
}

details.gy-collapse[open] > summary::before {
  rotate: 90deg;
}

details.gy-collapse > summary:hover {
  background: rgba(0, 229, 255, 0.05);
}

details.gy-collapse > summary:focus-visible {
  outline: 2px solid var(--gy-accent);
  outline-offset: -2px;
}

.gy-collapse-sub {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gy-dim);
}

.gy-collapse-body {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--gy-border);
}

details.gy-collapse::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

details.gy-collapse:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  details.gy-collapse::details-content {
    transition: block-size 0.24s ease, content-visibility 0.24s ease, display 0.24s ease;
    transition-behavior: allow-discrete;
  }
}

/* Mobile-first polish */
@media (max-width: 768px) {
  .gy-header {
    padding: 8px 12px;
    gap: 8px;
  }
  .gy-brand {
    font-size: 18px;
  }
  .gy-header-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .gy-header {
    flex-wrap: wrap;
  }
  .gy-hide-mobile {
    display: none !important;
  }
  .gy-meta-strip {
    padding: 8px 12px;
    gap: 6px;
    font-size: 11px;
  }
  details.gy-collapse > summary {
    padding: 12px 14px;
    font-size: 15px;
  }
  .gy-collapse-body {
    padding: 12px;
  }
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #rosterTable th:first-child,
  #rosterTable td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--gy-panel);
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.35);
  }
  #rosterTable thead th:first-child {
    z-index: 3;
    background: var(--gy-surface);
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Prevent Windows Chrome white-on-white native <option> dropdowns in dark mode */
select,
select option,
select optgroup {
  background-color: var(--gy-surface);
  color: var(--gy-text-bright);
}

/* ── Mobile / Compact Card View for #rosterTable (single DOM source of truth) ── */
.roster-view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.roster-view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.roster-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--gy-border);
  background: var(--gy-surface);
  color: var(--gy-text-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.roster-view-btn:hover,
.roster-view-btn.active {
  border-color: var(--gy-accent);
  color: var(--gy-accent);
}
#card-roster-table.roster-cards-mode {
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}
#card-roster-table.roster-cards-mode table {
  display: block;
  width: 100%;
  min-width: 0 !important;
}
#card-roster-table.roster-cards-mode thead {
  display: none;
}
#card-roster-table.roster-cards-mode tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
#card-roster-table.roster-cards-mode tbody tr {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  padding: 12px 14px;
  background: var(--gy-panel);
  border: 1px solid var(--gy-border);
  border-radius: 10px;
}
#card-roster-table.roster-cards-mode tbody tr[data-own="1"] {
  border-color: var(--gy-accent);
}
#card-roster-table.roster-cards-mode tbody td {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0 !important;
  border: none !important;
  position: static !important;
  background: transparent !important;
  font-size: 13px;
  white-space: nowrap;
}
#card-roster-table.roster-cards-mode tbody td:first-child {
  grid-column: 1 / -1;
  padding-bottom: 6px !important;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--gy-border) !important;
  font-size: 15px;
}
#card-roster-table.roster-cards-mode tbody td[data-label]::before {
  content: attr(data-label);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gy-dim);
  font-weight: 400;
}
