/* ArenaPro Stats — tokens from docs/design/DESIGN_TOKENS.md */

:root {
  --forest: #3f524f;
  --ochre: #dd9219;
  --sand: #ddd2bc;
  --cream: #f8f6f2;
  --dark: #3b3b3b;
  --olive: #626e67;
  --textsub: #82807b;
  --border: #afa897;
  --font-sans: Arial, Helvetica, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--dark);
  background: var(--cream);
}

/* —— Topbar (app pattern: bg-forest text-cream) —— */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--forest);
  color: var(--cream);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand img {
  display: block;
  border-radius: 0.25rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--cream);
}

.brand-sub {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ochre);
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--cream);
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

.nav-link:hover {
  background: color-mix(in srgb, var(--cream) 12%, transparent);
}

.nav-link.is-active {
  background: var(--ochre);
  color: var(--dark);
}

/* —— Layout —— */

.main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 3rem;
}

.view[hidden] {
  display: none !important;
}

.page-head {
  margin-bottom: 1rem;
}

.page-head h1 {
  margin: 0.35rem 0 0;
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--forest);
  line-height: 1.2;
}

.meta {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--textsub);
}

.status {
  margin: 0 0 0.75rem;
  min-height: 1.25rem;
  font-size: 0.875rem;
  color: var(--textsub);
}

.status.is-error {
  color: var(--forest);
  font-weight: 700;
}

/* —— Panels / cards —— */

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.cat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cat-card:hover {
  border-color: var(--forest);
}

.cat-card:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.cat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ochre);
}

.cat-card-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ochre);
}

.cat-card-count {
  font-size: 0.875rem;
  color: var(--olive);
  white-space: nowrap;
}

.cat-card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.cat-card-list li {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.95rem;
}

.cat-card-list .place {
  font-weight: 700;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}

.cat-card-list .name {
  color: var(--dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-card-list .pts {
  font-weight: 700;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}

.cat-card-cta {
  display: inline-block;
  margin-top: 0.85rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--forest);
}

/* —— Buttons —— */

.btn-back {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--forest);
  background: transparent;
  border: 1px solid var(--forest);
  border-radius: 0.375rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.btn-back:hover {
  background: color-mix(in srgb, var(--forest) 8%, transparent);
}

.btn-back:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* —— Podium —— */

.podium {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .podium {
    grid-template-columns: repeat(3, 1fr);
  }

  .podium-card:nth-child(1) {
    order: 2;
  }

  .podium-card:nth-child(2) {
    order: 1;
  }

  .podium-card:nth-child(3) {
    order: 3;
  }
}

.podium:empty {
  display: none;
}

.podium-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
}

.podium-card.is-first {
  border-color: var(--ochre);
  border-width: 2px;
}

.podium-place {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--olive);
}

.podium-name {
  margin: 0.35rem 0 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--forest);
}

.podium-sub {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--textsub);
}

.podium-value {
  margin: 0.5rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ochre);
  font-variant-numeric: tabular-nums;
}

/* —— Event list —— */

.event-list {
  display: grid;
  gap: 0.75rem;
}

.event-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.event-row:hover {
  border-color: var(--forest);
}

.event-row:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.event-row-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--forest);
}

.event-row-meta {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--textsub);
}

.event-row-cta {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--forest);
  white-space: nowrap;
}

.tools {
  margin-bottom: 1rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field span {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--olive);
}

.field input[type="file"],
.field select {
  font: inherit;
  color: var(--dark);
  background: #fff;
  border: 1px solid var(--sand);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
}

.field input[type="file"]:focus,
.field select:focus {
  outline: 2px solid var(--forest);
  outline-offset: 1px;
}

/* —— Tabs —— */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--forest);
  background: transparent;
  border: 1px solid var(--forest);
  border-radius: 0.375rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.tab:hover {
  background: color-mix(in srgb, var(--forest) 8%, transparent);
}

.tab.is-active {
  background: var(--forest);
  color: #fff;
}

.tab:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* —— Tables —— */

.tables {
  display: grid;
  gap: 1rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--forest);
  color: var(--cream);
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: var(--sand);
}

tbody tr:nth-child(odd) {
  background: #fff;
}

tbody tr.is-expandable {
  cursor: pointer;
}

tbody tr.is-expandable:hover td {
  background: color-mix(in srgb, var(--ochre) 14%, #fff);
}

tbody tr.is-cut-line td {
  border-bottom: 2px solid var(--ochre);
}

tbody tr.detail-row td {
  white-space: normal;
  background: var(--cream);
  color: var(--olive);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.delta {
  color: var(--textsub);
  font-size: 0.875rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-nt {
  background: var(--sand);
  color: var(--dark);
}

.badge-cut {
  background: color-mix(in srgb, var(--ochre) 22%, #fff);
  color: var(--dark);
}

.badge-out {
  background: var(--sand);
  color: var(--textsub);
}

.empty {
  margin: 0;
  color: var(--textsub);
  font-size: 0.9375rem;
}

.cut-note {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--textsub);
}

/* —— Footer —— */

.footer {
  text-align: center;
  padding: 0 1rem 2rem;
  color: var(--textsub);
  font-size: 0.875rem;
}

.footer code {
  font-size: 0.85em;
  background: var(--sand);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
}

@media (min-width: 768px) {
  .topbar {
    padding: 0.75rem 1.5rem;
  }

  .main {
    padding: 1.5rem 1.5rem 3rem;
  }
}
