/* Shared styles for the Audica EX website.
   Design system: dark theme with a blue/orange accent pair (matching the
   mod's own left-gun/right-gun colors), built as CSS variables so every
   page below stays in sync from one source of truth. */

:root {
  /* Surfaces */
  --bg: #0b0d12;
  --bg-elevated: #10131b;
  --surface: #161a22;
  --surface-2: #1e2430;
  --border: #262b36;
  --border-strong: #333a49;

  /* Text */
  --text: #edf0f4;
  --text-muted: #98a0ad;
  --text-faint: #6b7280;

  /* Accents — Audica's left gun (blue) / right gun (orange). These six are
     the defaults: nav.js overrides them on <html> with the logged-in
     player's own gun colors (left -> blue slot, right -> orange slot). */
  --blue: #00a6ff;
  --blue-soft: rgba(0, 166, 255, 0.14);
  --blue-strong: #3dbcff;
  --orange: #ff6600;
  --orange-soft: rgba(255, 102, 0, 0.14);
  --orange-strong: #ff8533;

  --gradient: linear-gradient(135deg, var(--blue) 0%, var(--orange) 100%);

  /* Status */
  --danger: #ff5470;
  --danger-strong: #d6304f;
  --success: #2ecc71;

  /* Shape/elevation */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

/* Several elements below (e.g. .pager) set their own `display` value, which
   has the same CSS specificity as the browser's built-in `[hidden] { display:
   none }` rule — and author styles always win specificity ties against
   user-agent styles, so `el.hidden = true` alone silently fails to hide them.
   This rule wins that tie explicitly, everywhere `hidden` is used. */
[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px 64px;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(560px circle at 12% 0%, var(--blue-soft), transparent 60%),
    radial-gradient(560px circle at 88% 0%, var(--orange-soft), transparent 60%);
  background-repeat: no-repeat;
}

/* Thin dark scrollbar (WebKit/Blink); Firefox falls back to `color-scheme: dark` above. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 10px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

::selection {
  background: var(--orange-soft);
  color: var(--text);
}

h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 4px 0 20px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 12px;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

a {
  color: var(--blue-strong);
}

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  color: var(--text);
}

/* -------------------------------------------------------------------
   Navigation
   ------------------------------------------------------------------- */
nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0 0 28px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease, background 0.15s ease;
}

nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

/* -------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------- */
form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  gap: 6px;
}

input,
select {
  padding: 9px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

input::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

/* -------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------- */
button {
  padding: 9px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  color: white;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button:hover {
  filter: brightness(1.1);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: var(--surface-2);
  color: var(--text-faint);
  cursor: not-allowed;
  filter: none;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

button.secondary:hover {
  background: var(--border-strong);
  filter: none;
}

button.danger {
  background: var(--danger-strong);
}

button.danger:hover {
  background: var(--danger);
  filter: none;
}

/* -------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:last-child td {
  border-bottom: none;
}

.tops-row:hover,
.run-row:hover {
  background: var(--surface-2);
}

.run-row {
  cursor: pointer;
}

/* -------------------------------------------------------------------
   Status text
   ------------------------------------------------------------------- */
.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 8px 0;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* -------------------------------------------------------------------
   Admin tool cards
   ------------------------------------------------------------------- */
#admin-tools {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

#admin-tools li {
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

#admin-tools li:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

#admin-tools li a {
  font-weight: 700;
  color: var(--blue-strong);
  text-decoration: none;
}

#admin-tools li a:hover {
  text-decoration: underline;
}

#admin-tools li p {
  margin: 6px 0 0;
}

/* -------------------------------------------------------------------
   Tabs
   ------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 9px 16px;
}

.tabs button:hover {
  background: var(--surface-2);
  color: var(--text);
  filter: none;
}

.tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--orange);
}

/* -------------------------------------------------------------------
   Song list / rows
   ------------------------------------------------------------------- */
.song-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.song-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
  transition: border-color 0.15s ease;
}

.song-row:hover {
  border-color: var(--border-strong);
}

.song-info {
  min-width: 0;
}

.song-title {
  font-weight: 700;
  color: var(--text);
}

.song-artist {
  margin-top: 2px;
}

.diff-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diff-badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--blue-soft);
  color: var(--blue-strong);
  transition: background 0.15s ease, color 0.15s ease;
}

.diff-badge:hover {
  background: var(--blue);
  color: #041420;
}

/* -------------------------------------------------------------------
   Chart data panels (heatmap / intensity graph / target data) and run
   stat blocks — dark HUD-style cards, matching the mod's own in-game
   look, now unified with the rest of the site's surface color.
   ------------------------------------------------------------------- */
.chart-panels {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas:
    "heatmap   target"
    "intensity target";
  gap: 12px;
  margin: 16px 0 24px;
}

#intensity-panel {
  grid-area: intensity;
}

#heatmap-panel {
  grid-area: heatmap;
}

#target-data-panel {
  grid-area: target;
}

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
}

.chart-panel h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: auto;
}

.target-data-table {
  width: 100%;
  margin-top: 0;
  background: transparent;
  border: none;
}

.target-data-table th,
.target-data-table td {
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 5px 6px;
  font-size: 0.82rem;
}

.target-data-table th {
  background: transparent;
  color: var(--text-faint);
  font-weight: 500;
}

.target-data-table img {
  display: block;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.3));
}

@media (max-width: 720px) {
  .chart-panels {
    grid-template-columns: 1fr;
    grid-template-areas:
      "heatmap"
      "intensity"
      "target";
  }
}

/* -------------------------------------------------------------------
   Run stats page (run.html) — text stat blocks (Timing/Aim/Chain/Misc)
   and the Timing/Aim/Song Timeline graph canvases.
   ------------------------------------------------------------------- */
.stat-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
}

.stat-block h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-block table {
  width: 100%;
  margin-top: 0;
  background: transparent;
  border: none;
}

.stat-block td {
  padding: 3px 4px;
  font-size: 0.85rem;
  border: none;
  color: inherit;
}

.stat-block td.count {
  text-align: right;
  color: var(--text-muted);
}

#run-content .chart-panel {
  margin-bottom: 16px;
}

#aim-graph-panel canvas {
  max-width: 420px;
  margin: 0 auto;
}

/* -------------------------------------------------------------------
   Admin: scoring-weights page (weights grid, bonus row, save row,
   rescore progress bar) — previously page-local inline styles, now
   part of the shared dark theme.
   ------------------------------------------------------------------- */
.weights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 12px;
}

.weights-grid table input[type="number"] {
  width: 100%;
}

.bonus-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  margin-top: 12px;
}

.bonus-row label {
  min-width: 160px;
}

.save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.progress-bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient);
  width: 0%;
  transition: width 0.2s ease;
}

/* -------------------------------------------------------------------
   Hero / info cards — used on index.html and similar landing content.
   ------------------------------------------------------------------- */
.hero-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  padding: 28px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.hero-card h1 {
  margin: 0 0 12px;
  font-size: 2rem;
}

.hero-card p {
  color: var(--text-muted);
  max-width: 640px;
  line-height: 1.6;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 20px;
}

/* Even vertical rhythm: any card that follows another card (or the hero, or
   a grid of cards) sits 20px below it. Cards inside a grid are spaced by the
   grid's own gap instead, so the sibling margin is cancelled there. */
.card + .card,
.hero-card + .card,
.card + .weights-grid,
.weights-grid + .card {
  margin-top: 20px;
}

.weights-grid > .card {
  margin-top: 0;
}

/* Keep the card's own padding as the only space above its title and below
   its last element, so the inside of every card is balanced. */
.card > h1:first-child,
.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

/* Link styled as a primary button (e.g. "View Leaderboard" on the home page). */
.btn {
  display: inline-block;
  padding: 9px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  color: white;
  text-decoration: none;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px);
}

.hero-card .btn {
  margin-top: 8px;
}

/* Login / register / password pages: one narrow, centered card with the
   form fields stacked full-width. */
.auth-card {
  max-width: 420px;
  margin: 32px auto 0;
  padding: 24px 28px;
}

.auth-card form {
  flex-direction: column;
  align-items: stretch;
}

/* ---------------------------------------------------------------------------
   Grade visual (see grade.js) — port of the mod's GradeDisplay.cs.
   --------------------------------------------------------------------------- */

.grade {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

/* Letter grades share the star grades' 1.7em-wide footprint and are centred
   in it, so both kinds line up in a column. The font is scaled up to sit
   closer to the stars' visual size; the width is divided by the same factor
   so the box stays 1.7em of the surrounding text. */
.grade-text {
  font-weight: 700;
  font-size: 1.2em;
  width: calc(1.7em / 1.2);
  text-align: center;
  white-space: nowrap;
}

.grade-stars svg {
  display: block;
  width: 1.7em;
  height: 1.7em;
  overflow: visible;
}

/* Each star sits at the origin of its own translated <g>, so rotating about
   0 0 spins it around its own centre, like the mod's per-star localEulerAngles. */
.grade-star {
  transform-origin: 0px 0px;
  animation: grade-star-wobble 3.1416s linear infinite;
}

/* Mod: angle = sin(t * 2) * 10°, starting at 0. Unity's +Z is counter-clockwise,
   CSS's positive rotate is clockwise, hence the flipped signs. Each segment is
   a quarter/half sine wave, so the easings below reproduce the sine exactly
   enough to be indistinguishable. Duration (π s) must match grade.js. */
@keyframes grade-star-wobble {
  0% { transform: rotate(0deg); animation-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1); }
  25% { transform: rotate(-10deg); animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  75% { transform: rotate(10deg); animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715); }
  100% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .grade-star {
    animation: none;
  }
}

/* Player gun-color swatches (profile.html) */
.gun-colors {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}

.gun-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
}

/* Account page: spacing between inline buttons */
#edit-nickname-btn,
#save-nickname-btn,
#cancel-nickname-btn,
#copy-key {
  margin-left: 0.5rem;
}

/* -------------------------------------------------------------------
   Watch list / compare pages
   ------------------------------------------------------------------- */
.diff-ahead {
  color: #3ddc84;
}

.diff-behind {
  color: var(--danger);
}

.compare-table td.num,
.compare-table th.num {
  text-align: right;
  white-space: nowrap;
}

.compare-table a {
  color: inherit;
}

#watch-row button,
.watch-add input {
  margin-right: 8px;
}

/* -------------------------------------------------------------------
   Platform badge (single-song leaderboard, v2.24)
   ------------------------------------------------------------------- */
.platform-badge {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.8em;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: nowrap;
}
