/* ============================================================
   WIAA Team Championships — style.css
   Colors from branding.json
   Font: Titillium Web (Google Fonts)
   ============================================================ */

:root {
  --color-accent:     #ed1c24;
  --color-header-text:#9e1e2e;
  --color-secondary:  #b82e47;
  --color-tertiary:   #7b0b13;
  --color-body:       #3a3c3d;
  --color-bg:         #f5f5f5;
  --color-surface:    #ffffff;
  --color-border:     #ddd;
  --color-muted:      #888;
  --color-header-bg:  #9e1e2e;
  --color-thead-bg:   #7b0b13;
  --color-thead-txt:  #ffffff;
  --color-row-alt:    #fdf0f1;
  --color-row-hover:  #fae0e3;
  --radius:           6px;
  --shadow:           0 2px 8px rgba(0,0,0,.12);
}

/* ── Reset / Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Titillium Web', Arial, sans-serif;
  font-size: 15px;
  color: var(--color-body);
  background: var(--color-bg);
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────── */
header {
  background: var(--color-header-bg);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  box-shadow: var(--shadow);
}

header img.logo {
  height: 44px;
  width: auto;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.2;
}

header h1 span {
  display: block;
  font-size: .8rem;
  font-weight: 400;
  opacity: .85;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── Main layout ─────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 3px solid var(--color-header-bg);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 22px;
  border: none;
  background: #e5e5e5;
  color: var(--color-body);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  letter-spacing: .02em;
  transition: background .15s, color .15s;
}

.tab-btn:hover {
  background: var(--color-secondary);
  color: #fff;
}

.tab-btn.active {
  background: var(--color-header-bg);
  color: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards / panels ──────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

/* ── Legend Card ─────────────────────────────────────────── */
.legend-card {
  padding: 16px 24px;
}

.legend-title {
  font-size: .95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-header-text);
  margin-bottom: 12px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  line-height: 1.4;
}

.legend-item .icon-coop,
.legend-item .icon-vacated {
  flex-shrink: 0;
}

.legend-text {
  color: var(--color-body);
}

.legend-text strong {
  color: var(--color-header-text);
}

/* ── Form controls ───────────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 200px;
}

.control-group label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-header-text);
}

select, input[type="text"] {
  font-family: inherit;
  font-size: .95rem;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--color-body);
  outline: none;
  transition: border-color .15s;
}

select:focus, input[type="text"]:focus {
  border-color: var(--color-secondary);
}

select:disabled {
  background: #f0f0f0;
  color: var(--color-muted);
  cursor: not-allowed;
}

.btn-reset {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-muted);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.btn-reset:hover {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

/* ── Autocomplete ────────────────────────────────────────── */
.autocomplete-wrapper {
  position: relative;
  min-width: 300px;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow);
}

.autocomplete-list li {
  list-style: none;
  padding: 9px 14px;
  cursor: pointer;
  font-size: .95rem;
}

.autocomplete-list li:hover,
.autocomplete-list li.highlighted {
  background: var(--color-row-alt);
  color: var(--color-header-text);
}

.autocomplete-list li mark {
  background: none;
  color: var(--color-accent);
  font-weight: 700;
}

/* ── Results header ──────────────────────────────────────── */
.result-meta {
  font-size: .85rem;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.result-meta strong {
  color: var(--color-header-text);
  font-size: 1rem;
}

/* ── Table ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--color-surface);
}

thead th {
  background: var(--color-thead-bg);
  color: var(--color-thead-txt);
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  user-select: none;
}

thead th.sortable {
  cursor: pointer;
}

thead th.sortable:hover {
  background: var(--color-secondary);
}

thead th .sort-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: .75rem;
  opacity: .6;
}

thead th.sort-asc .sort-icon::after  { content: '▲'; opacity: 1; }
thead th.sort-desc .sort-icon::after { content: '▼'; opacity: 1; }
thead th:not(.sort-asc):not(.sort-desc) .sort-icon::after { content: '⇅'; }

tbody tr:nth-child(even) { background: var(--color-row-alt); }
tbody tr:hover           { background: var(--color-row-hover); }

tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

td.center, th.center { text-align: center; }

/* ── Icons ───────────────────────────────────────────────── */
.icon-coop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-secondary);
  font-weight: 700;
  font-size: 1.1rem;
  title: "Co-op";
}

.icon-vacated {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-secondary);
  title: "Vacated";
}

.icon-vacated svg {
  width: 18px;
  height: 18px;
}

/* ── Insights ────────────────────────────────────────────── */
.insights-questions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.question-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  font-size: .92rem;
  line-height: 1.4;
}

.question-card:hover {
  border-color: var(--color-secondary);
  box-shadow: var(--shadow);
  color: var(--color-header-text);
}

.question-card.active {
  border-color: var(--color-header-bg);
  background: var(--color-row-alt);
  color: var(--color-header-text);
  font-weight: 600;
}

.question-card .q-num {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-muted);
  display: block;
  margin-bottom: 4px;
}

.insight-controls {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

/* ── Browse by School ────────────────────────────────────── */
.browse-school-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.browse-school-block {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.browse-school-block .table-wrapper {
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: none;
}

.browse-school-header {
  padding: 10px 16px;
  background: var(--color-body);
  color: #fff;
}

.bbs-name {
  font-size: 1rem;
  font-weight: 700;
  color: inherit;
}

.bbs-count {
  font-size: .85rem;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
}

.bbs-sport {
  white-space: nowrap;
  font-weight: 600;
  color: var(--color-body);
  width: 1%;
  min-width: var(--bbs-sport-width, auto);
  padding-right: 20px !important;
}

.bbs-champs {
  line-height: 1.8;
}

.champ-token {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.champ-sep {
  color: var(--color-muted);
}

.bbs-empty {
  padding: 12px 16px;
  margin: 0;
  font-style: italic;
  color: var(--color-muted);
}

/* ── Empty / loading states ──────────────────────────────── */
.state-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-muted);
  font-size: .95rem;
}

/* ── School year badge ───────────────────────────────────── */
.sy-badge {
  font-size: .8rem;
  color: var(--color-muted);
  font-style: italic;
  white-space: nowrap;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  header h1 { font-size: 1.1rem; }
  .tabs      { gap: 2px; }
  .tab-btn   { padding: 8px 12px; font-size: .85rem; }
  .controls  { flex-direction: column; }
  .control-group { min-width: 100%; }
}
