/* =====================
   Design Tokens
===================== */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1e40af;
  --radius: 10px;
  --header-height: 64px;
  --sidebar-width: 210px;
  --shadow: 0 10px 20px rgba(0,0,0,0.05);
}

/* =====================
   Base
===================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

/* =====================
   Header
===================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.site-title {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.3;
}

.nav-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.nav-toggle:hover {
  background: var(--bg);
}

/* =====================
   Layout / Sidebar
===================== */
.layout {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  flex: none;
  width: var(--sidebar-width);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: white;
  border-right: 1px solid var(--border);
}

.sidebar a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.sidebar a:hover {
  background: var(--bg);
}

.sidebar a.active {
  background: var(--accent);
  color: white;
}

.nav-collapsed .sidebar {
  display: none;
}

.nav-scrim {
  display: none;
}

.container {
  flex: 1;
  min-width: 0;
  max-width: 1300px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* =====================
   Cards
===================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
}

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

/* =====================
   Tables
===================== */
.table-wrapper {
  overflow-x: auto;
  margin-top: 12px;
}

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

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

th {
  background: #f1f5f9;
  font-weight: 600;
}

.sortable th {
  cursor: pointer;
}

.text-col {
  text-align: left;
  white-space: nowrap;
}

.load-error {
  margin: 16px 0 0;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
}

/* =====================
   This Week
===================== */
.status-line {
  margin: 0 0 8px;
  color: var(--muted);
}

.winner {
  white-space: nowrap;
}

.badge {
  margin-left: 4px;
  padding: 2px 8px;
  background: var(--accent);
  border-radius: 999px;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  vertical-align: middle;
}

/* Week number stays put while the rest of a wide table scrolls sideways. */
#weeks-table .week-col,
#weeks-table th:first-child {
  position: sticky;
  left: 0;
  white-space: nowrap;
  font-weight: 600;
}

#weeks-table .week-col {
  background: var(--card);
}

/* Long award names wrap into a readable block, not a one-word-wide column. */
#weeks-table th:not(:first-child) {
  min-width: 120px;
}

#weeks-table .week-in-progress td {
  background: #eff6ff;
}

#weeks-table .week-upcoming td {
  color: var(--muted);
}

#weeks-table tbody tr:hover td {
  background: var(--bg);
}

tbody tr:hover {
  background: #f8fafc;
}

/* =====================
   Details / Summary
===================== */
details {
  margin-top: 20px;
}

summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 12px;
}

/* =====================
   Forms
===================== */
label {
  display: block;
  margin-top: 16px;
  font-weight: 600;
}

select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 6px;
}

/* =====================
   Survivor Pills
===================== */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
}

.pill-list li {
  background: #eef2ff;
  color: #3730a3;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.pill-list li.at-risk {
  background: #fef3c7;
  color: #92400e;
}

/* =====================
   Responsive
===================== */
@media (max-width: 768px) {
  .app-header {
    padding: 0 12px;
  }

  .container {
    padding: 20px 12px;
  }

  .card {
    padding: 16px;
  }

  th, td {
    padding: 10px 8px;
  }

  .text-col {
    white-space: normal;
  }

  /* The sidebar slides over the page instead of sitting beside it, and
     always starts closed - .nav-collapsed (the wide-screen preference)
     doesn't apply here, .nav-open does. */
  .sidebar,
  .nav-collapsed .sidebar {
    display: flex;
    position: fixed;
    top: var(--header-height);
    left: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
  }
}
