/* ==========================================================================
   StatsHub — Constructivism
   Sharp geometry, asymmetry, motion. No decoration, no rounded corners.
   Reference palette: poster red, ink black, paper white, signal yellow.
   ========================================================================== */

:root {
  /* customizable via config.yml theme: — these stay wired to the API */
  --primary: #E8332A;
  --secondary: #0A0A0A;
  --accent: #F2C230;
  --background: #F5F5F0;
  --text: #0A0A0A;

  /* fixed constructivist constants — not exposed to config, part of the visual system */
  --ink: #0A0A0A;
  --paper: #F5F5F0;
  --paper-dim: #E8E7E0;
  --grey: #6F6F68;
  --line: #0A0A0A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* faint diagonal construction lines across the whole page — the geometry grid */
#app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(115deg, transparent 0 140px, rgba(10,10,10,0.035) 140px 141px),
    repeating-linear-gradient(25deg, transparent 0 180px, rgba(10,10,10,0.03) 180px 181px);
}

h1, h2, h3, .display {
  font-family: "Arial Black", "Archivo Black", "Helvetica Neue", sans-serif;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  font-weight: 900;
}

/* ---------- Topbar ---------- */

.topbar {
  background: var(--ink);
  border-bottom: 4px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
}

.brand {
  font-family: "Arial Black", "Archivo Black", sans-serif;
  font-weight: 900;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  padding: 16px 24px;
  background: var(--primary);
  clip-path: polygon(0 0, 100% 0, 92% 100%, 0% 100%);
  padding-right: 44px;
  margin-right: -20px;
  position: relative;
  z-index: 3;
}

.brand img { height: 26px; filter: invert(1); }

.tabs {
  display: flex;
  gap: 0;
  flex: 1;
  align-items: stretch;
}

.tab-btn {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(245,245,240,0.15);
  color: var(--paper);
  opacity: 0.55;
  padding: 0 22px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: opacity 0.12s ease, background 0.12s ease;
  position: relative;
}

.tab-btn:hover { opacity: 0.9; background: rgba(245,245,240,0.06); }
.tab-btn.active {
  opacity: 1;
  color: var(--ink);
  background: var(--accent);
}

.online-pill {
  background: var(--paper);
  color: var(--ink);
  padding: 0 18px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 4px solid var(--primary);
}

.dot {
  width: 9px;
  height: 9px;
  background: var(--primary);
  display: inline-block;
  border-radius: 0;
  transform: rotate(45deg);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: rotate(45deg) scale(1); }
  50% { opacity: 0.4; transform: rotate(45deg) scale(1.4); }
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "Arial Black", "Archivo Black", sans-serif;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: var(--accent);
  padding: 6px 16px;
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0% 100%);
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--primary);
  display: inline-block;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

/* ---------- Layout ---------- */

.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  width: 100%;
  flex: 1;
  position: relative;
  z-index: 1;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: sweepIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }

@keyframes sweepIn {
  from { opacity: 0; transform: translateX(-10px); clip-path: inset(0 100% 0 0); }
  to { opacity: 1; transform: translateX(0); clip-path: inset(0 0 0 0); }
}

/* ---------- Stat cards: offset, asymmetric grid, hard edges ---------- */

.cards-row {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr 1fr;
  gap: 0;
  border: 3px solid var(--ink);
}

/* modifikator pro cards-row se 3 kartami (napr. ekonomika) - bez tohoto by
   4-sloupcovy grid pridal prazdny 4. sloupec a vlevo vznikla mezera navic */
.cards-row-3 {
  grid-template-columns: 1.6fr 1fr 1fr;
}

/* mezera pod kartami - staci jednou, bez ohledu na to, jestli po nich
   nasleduje cards-caption text (economy tab) nebo primo panel (overview tab) */
.cards-row + .cards-caption,
.cards-row + .panel {
  margin-top: 32px;
}

.cards-caption + .panel {
  margin-top: 32px;
}

@media (max-width: 860px) {
  .cards-row { grid-template-columns: 1fr 1fr; }
  .stat-card-hero { grid-column: 1 / -1; }
  .stat-card-hero .stat-card-value { font-size: 48px; }
  .stat-card-value { font-size: 30px; }
}

.cards-caption {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--grey);
  margin: 0 2px 32px;
}

.stat-card {
  background: var(--paper);
  border-right: 3px solid var(--ink);
  padding: 20px 20px 24px;
  position: relative;
  overflow: hidden;
}

.stat-card:last-child { border-right: none; }

.stat-card-hero {
  background: var(--ink) !important;
  padding: 28px 28px 32px;
  position: relative;
}

.stat-card-hero .stat-card-label { color: rgba(245,245,240,0.6) !important; font-size: 12px; }

.stat-card-hero .stat-card-value {
  color: var(--paper) !important;
  font-size: 76px;
  position: relative;
  z-index: 2;
}

.stat-card-hero .stat-card-value.long-value {
  font-size: 40px;
}

.stat-card-sublabel {
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 2;
  margin-top: 4px;
}

.stat-card-hero::after {
  content: "";
  position: absolute;
  bottom: -60px;
  right: -60px;
  width: 180px;
  height: 180px;
  background: var(--primary);
  transform: rotate(45deg);
  z-index: 1;
  animation: hero-rotate 12s linear infinite;
}

@keyframes hero-rotate {
  from { transform: rotate(45deg); }
  to { transform: rotate(405deg); }
}

/* small corner triangle on the three regular cards (2nd/3rd/4th in the row) */
.stat-card:not(.stat-card-hero)::after {
  content: "";
  position: absolute;
  top: -20px;
  right: -20px;
  width: 46px;
  height: 46px;
  background: var(--primary);
  transform: rotate(45deg);
  opacity: 0.9;
}

.stat-card:nth-child(2):not(.stat-card-hero)::after { background: var(--ink); }
.stat-card:nth-child(3)::after { background: var(--accent); }
.stat-card:nth-child(4)::after { background: var(--ink); }

.stat-card-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.stat-card-value {
  font-family: "Arial Black", "Archivo Black", sans-serif;
  font-size: 40px;
  line-height: 1;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
  transition: color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card-value.flash { animation: value-flash 0.6s ease; }

@keyframes value-flash {
  0% { color: var(--primary); transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---------- Panels ---------- */

.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  padding: 24px;
  margin-bottom: 28px;
  position: relative;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 18px 0;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel h2::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--primary);
  display: inline-block;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 18px;
}

.panel-header h2 { margin: 0; padding-bottom: 0; border-bottom: none; }

.panel-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 780px) {
  .panel-grid { grid-template-columns: 1fr; }
}

/* second panel in a grid nudged for asymmetry on wide screens */
@media (min-width: 781px) {
  .panel-grid .panel:nth-child(2) { margin-top: 28px; }
}

.range-select { display: flex; gap: 0; border: 2px solid var(--ink); }

.range-btn {
  background: var(--paper);
  border: none;
  border-right: 2px solid var(--ink);
  color: var(--ink);
  opacity: 0.5;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.range-btn:last-child { border-right: none; }
.range-btn.active { background: var(--ink); color: var(--paper); opacity: 1; }

#graph-canvas { width: 100%; display: block; cursor: crosshair; }

.graph-panel { position: relative; overflow: visible; }

.graph-tag {
  position: absolute;
  top: -14px;
  right: 28px;
  background: var(--ink);
  color: var(--paper);
  font-family: "Arial Black", "Archivo Black", sans-serif;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 5px 14px;
  transform: rotate(-2deg);
  z-index: 2;
}

.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 5;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.08s ease;
  border: 2px solid var(--paper);
  box-shadow: 3px 3px 0 var(--primary);
}

.graph-tooltip.visible { opacity: 1; }

.graph-tooltip .tt-value {
  font-family: "Arial Black", "Archivo Black", sans-serif;
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
}

.graph-tooltip .tt-time {
  display: block;
  color: rgba(245,245,240,0.6);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

/* ---------- Mini lists ---------- */

.mini-list { display: flex; flex-direction: column; gap: 0; }

.mini-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--paper-dim);
  font-size: 14px;
}

.mini-list-item:last-child { border-bottom: none; }
.mini-list-item .name { font-weight: 700; }
.mini-list-item .value {
  color: var(--ink);
  font-weight: 800;
  background: var(--accent);
  padding: 2px 8px;
  font-size: 12px;
}

/* ---------- Tables ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 11px 12px;
  color: var(--paper);
  background: var(--ink);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table th:last-child { text-align: right; }

.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--paper-dim);
  font-weight: 600;
}

.data-table tbody tr:nth-child(even) { background: var(--paper-dim); }
.data-table tbody tr:hover { background: rgba(232,51,42,0.1); }

/* first column (rank/index) reads as a strong left rule per row */
.data-table td:first-child { border-left: 3px solid transparent; }
.data-table tbody tr:hover td:first-child { border-left-color: var(--primary); }

/* value column (rightmost) is the payoff of each row - give it weight */
.data-table td:last-child {
  font-family: "Arial Black", "Archivo Black", sans-serif;
  font-weight: 900;
  text-align: right;
}

/* ---------- Form controls ---------- */

select, input[type="text"] {
  background: var(--paper);
  border: 2px solid var(--ink);
  color: var(--ink);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 0;
}

select:focus, input[type="text"]:focus {
  outline: 3px solid var(--accent);
  outline-offset: -1px;
}

input[type="text"]::placeholder { color: var(--grey); font-weight: 500; }

/* ---------- Footer ---------- */

.footer {
  padding: 18px 24px 26px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0;
  border: 2px solid var(--ink);
}

.footer-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 8px 16px;
  border-right: 2px solid var(--ink);
  transition: background 0.12s ease, color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.footer-link:last-child { border-right: none; }

.footer-link:hover {
  background: var(--ink);
  color: var(--paper);
}

.footer-link-discord::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--primary);
  display: inline-block;
  transform: rotate(45deg);
  flex-shrink: 0;
}

.footer-link-discord:hover::before { background: var(--accent); }

@media (max-width: 560px) {
  .footer-inner { justify-content: center; }
}

/* ---------- Rank badges: geometric, not circular ---------- */

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--paper-dim);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  border: 2px solid var(--ink);
}

.rank-badge.gold { background: var(--accent); }
.rank-badge.silver { background: #D8D8D0; }
.rank-badge.bronze { background: var(--primary); color: var(--paper); }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .dot, .live-dot, .tab-panel.active, .stat-card-value.flash {
    animation: none !important;
  }
}
