@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..700&family=Merriweather:wght@300..700&display=swap');

:root {
  --bg-base: #1f1f1f;
  --bg-header: #2b2b2b;
  --bg-row-even: #272727;
  --bg-row-odd: #212121;
  --bg-hover: #2d2d2d;
  --text-light: #fae8c8;
  --text-muted: #aaaaaa;
  --border: #3a3a3a;
  --accent: #5f43b2;
}

:root.light {
  --bg-base: #f7f7f8;
  --bg-header: #ffffff;
  --bg-row-even: #f2f2f3;
  --bg-row-odd: #ffffff;
  --bg-hover: #f0f0f2;
  --text-light: #1d1d1f;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #6b5bd1;
}

/* Sticky footer layout */
html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* Allow main tab content and gear table container to expand and scroll */
.tab-content {
  display: none;
  flex: 1 0 auto;
  overflow: auto;
}
.tab-content.active {
  display: block;
}

/* Gear Search sub-tabs */
.gear-tab-content {
  display: none;
}
.gear-tab-content.active {
  display: block;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-light);
  overflow-x: hidden;
  transition: background-color .2s ease, color .2s ease;
}

.site-main {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

/* Allow full-bleed layout when Equipment tab is active */
body.full-width .site-main {
  max-width: none;
}

h1 {
  text-align: left;
  margin: 0;
  font-size: 1.5rem;
  font-family: 'Merriweather', serif;
  font-weight: 600;
}

h2, h3, h4 {
  font-family: 'Merriweather', serif;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-header);
  color: var(--text-light);
  padding: 10px 16px;
  gap: 12px;
}

.site-header .title {
  letter-spacing: 0.2px;
}

.site-header #themeToggleBtn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.site-header .high-score {
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: right;
  line-height: 1.2;
}

a {
  color: #ffd700;
  text-decoration: none;
  transition: color .2s ease;
}
a:hover {
  text-decoration: underline;
  color: #ffd700;
}

.accent {
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid #444;
  margin: 8px 10px 12px;
  background-color: var(--bg-header);
  position: sticky;
  top: 0;
  z-index: 20;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 10px 16px;
  cursor: pointer;
  background-color: var(--bg-header);
  color: var(--text-light);
  margin-right: 2px;
  font-size: .95rem;
  font-weight: 500;
  border: none;
  appearance: none;
  transition: background-color .2s ease;
  border-radius: 6px 6px 0 0;
  flex: 0 0 auto;
  white-space: nowrap;
}
.tab.disabled {
  color: var(--text-muted);
  cursor: default;
  pointer-events: none;
  opacity: .6;
}
.tab.active {
  background-color: #3a3a3a;
  border-top: 2px solid var(--accent);
  color: var(--text-light);
}
.tab:hover {
  background-color: var(--bg-hover);
}

/* Global focus styles */
button:focus-visible,
select:focus-visible,
input:focus-visible,
.tab:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin: 0 10px 12px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02));
  border: 1px solid var(--border);
  border-radius: 10px;
}
.control-label {
  margin-right: 6px;
  font-size: .95rem;
}

.btn-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-light);
  margin-right: 6px;
}

button {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-header);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background-color .2s ease, transform .05s ease;
  margin-right: 8px;
}
button:hover {
  background-color: var(--bg-hover);
}
button:active {
  transform: translateY(1px);
}

select {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-header);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: .95rem;
  cursor: pointer;
  margin-right: 12px;
  transition: background-color .2s ease;
}
select:hover {
  background-color: var(--bg-hover);
}
select:focus {
  outline: none;
}

.search-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 10px 6px 34px;
  margin-right: 12px;
  color: var(--text-light);
}
.search-wrapper .search-icon {
  position: absolute;
  left: 8px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}
.search-wrapper input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-light);
  font-size: .95rem;
  width: 200px;
}
.search-wrapper input::placeholder {
  color: var(--text-muted);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  position: absolute;
  top: 0;
  right: 0;
}

.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  z-index: 10000;
  min-width: 200px;
}
.dropdown-content input[type=checkbox] {
  margin-right: 6px;
}
.dropdown-content label {
  display: flex;
  align-items: center;
  font-size: .9rem;
  color: var(--text-light);
  margin-bottom: 6px;
  cursor: pointer;
}
.dropdown-content label:hover {
  color: var(--accent);
}

#tableContainer {
  width: 100%;
  padding: 0 10px 24px 10px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  flex: 1 0 auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.table-dense th,
.table-dense td {
  padding: 6px 8px;
}

th, td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  background-clip: padding-box;
}

/* Subtle column separators */
#gearTable td,
#gearTable th {
  border-right-color: rgba(255,255,255,0.06);
}

/* Gear-table header row stays fixed */
#gearTable thead th {
  position: sticky;
  top: 0;
  background-color: var(--bg-header);
  z-index: 100;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

/* Only gear-table first two columns stick */
#gearTable th:nth-child(1),
#gearTable td:nth-child(1) {
  position: sticky;
  left: 0;
  background-color: var(--bg-row-odd);
  z-index: 50;
  width: 60px;
}
#gearTable th:nth-child(2),
#gearTable td:nth-child(2) {
  position: sticky;
  left: 60px;
  background-color: var(--bg-row-even);
  z-index: 50;
  width: 100px;
}

th {
  background-color: var(--bg-header);
  color: var(--text-light);
  font-weight: 500;
}
tr:nth-child(even) {
  background-color: var(--bg-row-even);
}
tr:nth-child(odd) {
  background-color: var(--bg-row-odd);
}
tr:hover {
  background-color: var(--bg-hover);
  cursor: pointer;
}

/* Card style wrappers */
.scoreboard,
.calendar-container,
#tableContainer {
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.12);
}

.scoreboard { padding: 12px; }
.calendar-container { padding: 12px; }

/* Generic card */
.card {
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.12);
}

/* Gear table hover accent */
#gearTable tbody tr:hover {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Equipment table colors */
#gearTable tbody tr:nth-child(even) {
  background-color: #2a2a2a;
}
#gearTable tbody tr:nth-child(odd) {
  background-color: #1c1c1c;
}
#gearTable tbody tr:hover {
  background-color: #333333;
}
#gearTable tbody tr.colored-row:hover {
  filter: brightness(1.2);
}
#gearTable tbody tr {
  border-bottom: 1px solid #333;
}
#gearTable tbody tr:last-child {
  border-bottom: none;
}

th.sortable {
  cursor: pointer;
}
th.sorted-asc::after {
  content: ' \25B2';
}
th.sorted-desc::after {
  content: ' \25BC';
}

.scroll-sync-bar {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  height: 16px;
  position: fixed;
  bottom: 0;
  left: 0;
  background: var(--bg-base);
  z-index: 9999;
}
.scroll-sync-inner {
  height: 1px;
}

@media screen and (max-width: 600px) {
  #tableContainer {
    overflow-x: hidden;
  }
  #scrollSyncBar {
    display: none;
  }
  #gearTable thead {
    display: none;
  }
  #gearTable,
  #gearTable tbody,
  #gearTable tr,
  #gearTable td {
    display: block;
    width: 100%;
  }
  #gearTable tr {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
  }
  #gearTable td {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    border: none;
    border-bottom: 1px solid var(--border);
  }
  #gearTable td:last-child {
    border-bottom: none;
  }
  #gearTable td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 6px;
  }
}


/* --- Overlay styles --- */
#detailOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#detailOverlay.open {
  display: flex;
  animation: overlayFade .2s ease;
}
#detailOverlay .overlay-card {
  background: var(--bg-header);
  padding: 22px;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90%;
  overflow-y: auto;
  position: relative;
  animation: overlayZoom .2s ease;
}
#detailOverlay .overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes overlayZoom {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#pageFooter {
  background-color: var(--bg-header);
  color: var(--text-light);
  text-align: center;
  padding: 20px 0;
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Hide the scroll-sync bar when Consumables is the active tab */
#consumables.active ~ .scroll-sync-bar {
  display: none;
}

/* ————————— Condensed/Expanded toggle styles ————————— */

/* When “condensed” is on, force a fixed table layout (fits in viewport) */
#tableContainer.condensed #gearTable {
  table-layout: fixed;
}

/* When “condensed” is off (expanded), allow auto layout so all columns show */
#tableContainer:not(.condensed) #gearTable {
  table-layout: auto;
}

/* --- Overlay content styling --- */
#detailOverlay h2 {
  margin-top: 0;
  font-size: 1.2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 12px;
}
#detailOverlay table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: .9rem;
  table-layout: fixed;
}
#detailOverlay table td {
  padding: 4px 0;
  border: none;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
#detailOverlay table.drawer-gear td:first-child {
  width: 110px;
  padding-right: 8px;
}
#detailOverlay ul {
  list-style: disc;
  padding-left: 0;
  margin: 0 0 0 1em;
  font-size: .9rem;
}
#detailOverlay ul li {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#detailOverlay h3,
#detailOverlay h4 {
  margin: 8px 0 6px;
  font-size: 1rem;
}

hr.fade-line {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 8px 0;
}

/* --------- High Scores styles --------- */
#scores {
  padding: 20px;
}
.scoreboard {
  margin-bottom: 24px;
}
.scoreboard.disabled {
  color: var(--text-muted);
  pointer-events: none;
}
.scoreboard h2 {
  margin: 0 0 8px 0;
  font-size: 1.3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.scoreboard h2 small {
  font-size: 0.8rem;
  font-weight: normal;
}
.scoreboard ol,
.scoreboard ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.scoreboard li {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

#raceChartBoard .legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  margin-top: 8px;
}

#classChartBoard .legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  margin-top: 8px;
}

#raceChartBoard,
#classChartBoard {
  position: relative;
  text-align: center;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-header);
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 2px 6px;
  font-size: 0.8rem;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 5;
  display: none;
}

#raceChartBoard .legend li {
  display: flex;
  align-items: center;
  border-bottom: none;
  padding: 0;
  font-size: 0.9rem;
}

#classChartBoard .legend li {
  display: flex;
  align-items: center;
  border-bottom: none;
  padding: 0;
  font-size: 0.9rem;
}

#raceChartBoard .legend li.active {
  color: var(--accent);
  font-weight: bold;
}

#classChartBoard .legend li.active {
  color: var(--accent);
  font-weight: bold;
}

#raceChartBoard .legend .color-box {
  width: 12px;
  height: 12px;
  margin-right: 6px;
}

#classChartBoard .legend .color-box {
  width: 12px;
  height: 12px;
  margin-right: 6px;
}

#kingBogling {
  text-align: center;
}
#kingBogling h2 {
  border-bottom: none;
  margin-bottom: 0;
  font-size: 1.4rem;
}
#kingBogling p {
  margin: 0;
  font-size: 1.05rem;
}


.score-pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
}

#attendance .score-pair {
  gap: 40px;
}

.score-pair .scoreboard {
  flex: 1 1 260px;
  max-width: 300px;
}

#attendance .score-pair .scoreboard {
  flex: 1 1 320px;
  max-width: 360px;
}

.wow-tooltip {
  background: #080d21;
  border: 1px solid #aaa;
  padding: 8px;
  width: 280px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  color: #fff;
  z-index: 10000;
}
.wow-tooltip .name {
  color: #a335ee;
  margin-bottom: 4px;
}
.wow-tooltip .ilevel {
  color: #ffd100;
  margin-bottom: 4px;
}
.wow-tooltip .bind {
  margin-bottom: 4px;
}
.wow-tooltip .slot-type {
  overflow: hidden;
  margin-bottom: 4px;
}
.wow-tooltip .slot {
  float: left;
}
.wow-tooltip .type {
  float: right;
}
.wow-tooltip .armor {
  margin-bottom: 4px;
}
.wow-tooltip .stat {
  margin-bottom: 4px;
}
.wow-tooltip .stat.green {
  color: #1eff00;
}
.wow-tooltip .durability {
  margin-bottom: 4px;
}
.wow-tooltip .requires {
  margin-bottom: 6px;
}
.wow-tooltip .set-name {
  color: #ffd100;
  font-weight: bold;
  margin-top: 6px;
  margin-bottom: 2px;
}
.wow-tooltip .set-list {
  list-style: none;
  padding-left: 16px;
  margin: 0;
  color: #9d9d9d;
}
.wow-tooltip .set-bonuses {
  margin-top: 6px;
}
.wow-tooltip .set-bonus {
  color: #9d9d9d;
  margin-bottom: 2px;
}
.wow-tooltip .bonus-count {
  color: #ffd100;
}
.wow-tooltip .speed {
  float: right;
  clear: right;
}
.wow-tooltip .dps {
  color: #fff;
}

.attendance-table {
  width: 100%;
  border-collapse: collapse;
}

.attendance-table th,
.attendance-table td {
  padding: 0.5em;
  border: 1px solid var(--border);
  text-align: left;
}
.attendance-table td:first-child {
  width: 2em;
}
.attendance-table td:nth-child(2) {
  width: 8em;
}
.raid-history-table {
  width: auto;
  margin: 0 auto;
}
.raid-history-table td:first-child,
.raid-history-table td:nth-child(2) {
  width: auto;
}
.progress {
  width: 100%;
  background: var(--bg-row-even);
  border-radius: 4px;
  overflow: hidden;
  height: 1em;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  line-height: 1em;
  color: #fff;
  font-size: 0.8em;
  text-align: center;
}

.char-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.char-layout .gear-col {
  flex: 0 0 220px;
}
.char-layout .info-col {
  flex: 1 1 auto;
}
@media (max-width: 700px) {
  .char-layout {
    flex-direction: column;
  }
}
