/* =================================================================
 * AEX Killfeed Master Stylesheet
 * =================================================================
 * 
 * 🎯 MAINTAINABILITY FIRST! 
 * 
 * This is the main CSS file that imports all other CSS files.
 * Think of it as the "table of contents" for all styling.
 * 
 * 🔍 TROUBLESHOOTING:
 * - Colors wrong? → Check themes.css
 * - Home page broken? → Check home.css  
 * - PU/AC pages broken? → Check below in this file
 * - Dropdowns/buttons broken? → Check below in this file
 * 
 * =================================================================*/

/* Import theme colors and variables first */
@import url('themes.css');
/* Import header-specific styles */
@import url('header.css');

/* =================================================================
 * BASE LAYOUT & TYPOGRAPHY
 * =================================================================
 * Core styles that apply to every page
 * =================================================================*/

/* Apply theme variables to main elements */
html {
  background: var(--bg); 
  color: var(--text); 
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg); 
  color: var(--text); 
  font-family: var(--font-sans);
  min-height: 98vh;
  display: flex;
  flex-direction: column; 
  overflow-y: auto; /* Only show vertical scrollbar when needed */
}
h1,h2,h3,h4,h5 { color: var(--text-strong); }
a { color: var(--link); }

/* =================================================================
 * PAGE LAYOUT SYSTEM (Used by PU/AC pages)
 * =================================================================*/

/* layout shell */
main.page {
  flex: 1 1 auto;
  display: grid;
  grid-template-areas:
    "filters  filters"
    "results  summary"
    "results  orgs";
  grid-template-columns: 1fr fit-content(42ch);
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 12px;
}

/* mobile: summary above results (your ask) */
@media (max-width: 800px) {
  main.page {
    grid-template-areas:
      "filters"
      "summary"
      "orgs"
      "results";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
}

/* Footer stays at the bottom */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  text-align: left;
  font-size: 1rem;
}
.site-footer-content {
  padding: .5rem 0 1rem 1ch;
}
.page .results, .page .summary {
  min-height: unset;
  overflow: unset;
}

/* areas */
.page .filters { grid-area: filters; }
.page .results { grid-area: results; min-height: 0; overflow: auto; }
.page .summary { grid-area: summary; min-height: 0; overflow: auto; }
.page .summary { justify-self: start; }  /* don't stretch inside the track */
.page .orgs { grid-area: orgs; min-height: 0; overflow: auto; }

/* =================================================================
 * COMMON COMPONENTS
 * =================================================================
 * Styles used across multiple pages (panels, tables, forms, etc.)
 * =================================================================*/

/* Tables and panels pick up theme shades */
.results table { background: var(--surface-1); }
.summary { background: var(--surface-2); border: 1px solid var(--border-weak); border-radius: 8px; padding: 8px; }
.filters { background: var(--surface-2); border: 1px solid var(--border-weak); border-radius: 8px; padding: 8px; }

/* =================================================================
 * FILTERS RESPONSIVE LAYOUT
 * =================================================================*/

.filters-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filters-main-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0; /* Allow shrinking */
}

.filters-realm-section {
  display: flex;
  align-items: center;
  flex-shrink: 0; /* Don't shrink the realm dropdown */
}

/* =================================================================
 * PLAYER SEARCH AUTOCOMPLETE
 * =================================================================*/

.player-input-container {
  position: relative;
  display: inline-block;
}

/* Custom scrollbar for autocomplete dropdown with smooth fade transitions */
.player-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg); /* Use darker page background */
  border: 1px solid var(--border-weak);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 0; /* Start collapsed for sweet slide animation */
  overflow: hidden; /* Hide content during animation */
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); /* Stronger shadow for dark theme */
  opacity: 0;
  transform: translateY(-10px); /* Start slightly above for slide effect */
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease-out 0.05s, /* Slight delay for smoother feel */
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s ease-out,
              height 0.2s ease-out; /* Smooth height transitions for content changes */
  pointer-events: none; /* Prevent interaction when closed */
  /* Use native scrollbar styling for better transition support */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent; /* Start invisible */
}

/* When autocomplete dropdown is shown - smooth slide down animation */
.player-autocomplete-dropdown.show {
  max-height: 350px; /* Height for ~7 items with padding (50px per item) */
  overflow-y: auto; /* Re-enable scrolling when open */
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto; /* Re-enable interaction when open */
}

/* Firefox scrollbar styling with transitions */
.player-autocomplete-dropdown:hover {
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  transition: scrollbar-color 0.3s ease-in-out;
}

.player-autocomplete-dropdown.has-scroll {
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  transition: scrollbar-color 0.3s ease-in-out;
}

/* Webkit scrollbar with improved transition approach */
.player-autocomplete-dropdown::-webkit-scrollbar {
  width: 12px;
}

.player-autocomplete-dropdown::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

.player-autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: transparent; /* Start completely transparent */
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
  /* Use background transitions instead of opacity for better support */
  transition: background-color 0.4s ease-in-out, box-shadow 0.4s ease-in-out;
}

/* Show scrollbar on hover with background transition */
.player-autocomplete-dropdown:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Show scrollbar when content overflows */
.player-autocomplete-dropdown.has-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.player-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2) !important;
}

.player-autocomplete-dropdown::-webkit-scrollbar-thumb:active {
  background: rgba(255, 255, 255, 0.5) !important;
}

.player-autocomplete-option {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-weak);
  transition: background-color 0.15s ease;
  color: var(--text); /* Use consistent text color */
}

.player-autocomplete-option:last-child {
  border-bottom: none;
}

.player-autocomplete-option:hover,
.player-autocomplete-option.highlighted {
  background: var(--border-weak); /* Match realm dropdown hover style */
  color: var(--text-strong);
}

.player-autocomplete-option .name {
  font-weight: 500;
}

.player-autocomplete-option .name mark {
  background: var(--accent);
  color: var(--text-strong);
  padding: 0 2px;
  border-radius: 2px;
}

.player-autocomplete-loading {
  padding: 12px;
  text-align: center;
  color: var(--text-weak);
  font-style: italic;
}

/* Smaller, more subtle typing indicator */
.player-autocomplete-loading.typing {
  font-size: 0.75em;
  padding: 8px 12px;
  opacity: 0.7;
}

/* Hide scrollbar during height animations to prevent visual artifacts */
.player-autocomplete-dropdown.resizing {
  overflow: hidden !important;
  scrollbar-color: transparent transparent !important; /* Firefox */
}

.player-autocomplete-dropdown.resizing::-webkit-scrollbar-thumb {
  background: transparent !important; /* Webkit - force hide during animation */
  box-shadow: none !important;
  transition: none !important; /* No transition during resize for instant hide */
}

.player-autocomplete-no-results {
  padding: 12px;
  text-align: center;
  color: var(--text-weak);
}

/* Mobile responsive: Stack realm dropdown below main controls */
@media (max-width: 800px) {
  .filters-form {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  
  .filters-main-controls {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    /* Keep main controls on one row if possible */
    min-width: 0;
  }
  
  .filters-main-controls label {
    /* Make labels more compact */
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
  }
  
  .player-input-container {
    /* Allow search field to shrink as needed */
    min-width: 140px;
    max-width: 200px;
    flex: 1;
  }
  
  .filters-realm-section {
    justify-content: center;
    width: 100%;
  }
  
  .realm-dropdown-container {
    max-width: 100% !important;
    width: 250px;
  }
}

/* Very small screens: Only then allow more vertical stacking */
@media (max-width: 480px) {
  .filters-main-controls {
    /* More aggressive stacking only on very small screens */
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  
  .player-input-container {
    min-width: 160px;
    max-width: 100%;
  }
  
  .search-button {
    min-width: 120px;
  }
}
.orgs { background: var(--surface-2); border: 1px solid var(--border-weak); border-radius: 8px; padding: 8px; }
button { background: var(--accent-2); color: var(--text-strong); border: 1px solid var(--border-weak); border-radius: 6px; }
button:hover { filter: brightness(1.1); }

/* Enhanced search button styling to match dropdown design language */
.search-button {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-weak);
  border-radius: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.95em;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  min-height: 36px; /* Match dropdown input height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.search-button:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  filter: none; /* Override the generic button filter */
}

.search-button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 2, 3, 129), 0.2);
}

.search-button:active {
  background: var(--border-weak);
  transform: translateY(1px); /* Subtle press effect */
}
input, select { background: var(--surface-1); color: var(--text); border: 1px solid var(--border-weak); border-radius: 6px; padding: 4px 8px; }

.site-title {
  font-size: 1.8rem;   /* ~28–30px depending on browser */
  font-weight: 700;    /* already bold, but reinforces */
}

.summary h2 { margin: 4px 0 0px; padding-bottom: 0;}
.summary h3, .summary h4 { margin: 4px 0 0; }
.summary ol { margin: 4px 0 0px 1.25rem; padding: .4rem; font-variant-numeric: tabular-nums;}
.summary ul { margin: 4px 0 8px; padding: 0;}
.summary ul:last-of-type { margin-bottom: 1.25rem; }
.summary ol li, .summary ul li { margin: 2px 0 0px 1.25rem;}
.summary .leaderboard-title { margin-bottom: 1rem; border-bottom: 1px solid var(--border-weak);}

/* Summary + anywhere you used <span class="player-link"> */
.summary .player-link,
.results .player-link:not(td) {
  display: inline-block;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 2px;
  transition: background 0.2s, filter 0.2s;
}
.summary .player-link:hover,
.results .player-link:not(td):hover {
  background: var(--border-weak);
  filter: brightness(1.2);
}

/* Table cell flavor: keep display as table-cell, still look clickable */
.results td.player-link {
  cursor: pointer;                  /* paw says "click this" */
  /* optional: a touch of inner padding so hitbox feels nicer without shifting layout */
  padding-left: 6px;
  padding-right: 6px;
  border-radius: 3px;               /* has no visual effect unless background changes */
  transition: background 0.2s, filter 0.2s;
}
.results td.player-link:hover {
  background: var(--border-weak);   /* plays nice with your zebra striping */
  filter: brightness(1.2);
}

/* (nice on mobile) brief press feedback */
.summary .player-link:active,
.results .player-link:active {
  filter: brightness(1.3);
}

/* Keep table cells one line, truncate overflow */
 .results table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.results th, .results td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 6px 8px;
  vertical-align: middle;
}

.results td.player-col, .results th.player-col {
  white-space: normal;
  overflow: clip;
  text-overflow: clip;
}

.results td.num-col {
  width: 10%; /* shrink to fit content */
  white-space: nowrap;  /* don't let numbers wrap */
  text-align: left;    /* optional: numbers usually look better aligned */
}

/* (bonus) sticky header while scrolling results */
.results thead th {
  position: sticky; top: 0;
  background: var(--table-header-bg);
  color: var(--table-header-fg);
  z-index: 1;
  text-align: left;
}
.results tbody tr:nth-child(odd) {
  background: var(--table-row-odd);
}
.results tbody tr:nth-child(even) {
  background: var(--table-row-even);
}
 /* Optional: keep text readable over zebras */
.results tbody td { color: var(--text); }

/* Optional: hover row highlight that respects theme */
.results tbody tr:hover { filter: brightness(1.25); }

.results tbody tr .fx-trBlink { 
  animation: blink90s 0.5s 1s 2; /* 0.5s duration, 1s delay, play 2 times, then stop */
}

/* =================================================================
 * PLAYER INPUT STYLES (matching Realm dropdown)
 * =================================================================*/

.player-input-container {
  position: relative;
  display: inline-block;
  min-width: 200px;
  max-width: 250px;
}

.player-search-input {
  width: 100%;
  max-width: 100%;
  min-width: 200px;
  padding: 8px 12px;
  padding-right: 32px; /* space for clear button */
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-weak);
  border-radius: 6px;
  font-family: inherit;
  font-size: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.player-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 2, 3, 129), 0.2);
}

.player-search-input::placeholder {
  color: var(--text);
  opacity: 0.6;
}

/* Clear button styling to match dropdown arrow */
.input-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1em;
  color: var(--text);
  opacity: 0.6;
  padding: 2px;
  border-radius: 3px;
  transition: opacity 0.2s, background 0.2s;
  display: none; /* Hidden by default, shown via JS */
}

.input-clear-btn:hover {
  opacity: 1;
  background: var(--border-weak);
}

.input-clear-btn:focus {
  outline: none;
  opacity: 1;
  background: var(--border-weak);
}

/* =================================================================
 * REALM DROPDOWN STYLES (Custom searchable dropdown)
 * =================================================================*/

.realm-dropdown-container {
  position: relative;
  display: inline-block; /* Keep as inline-block for proper flexbox child behavior */
  width: 250px; /* Fixed width to prevent resizing when thumbnail appears */
  max-width: 250px; /* Prevent overflow by capping max width */
}

/* Main input that shows selected value */
.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 100%; /* Take full width of container */
}

/* Container for the selected display (thumbnail + input) */
.dropdown-display {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%; /* Take full width of parent container */
  height: 38px; /* Fixed height to prevent vertical expansion */
  background: var(--surface-1);
  border: 1px solid var(--border-weak);
  border-radius: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box; /* Include border in width calculation */
}

.dropdown-display:hover {
  border-color: var(--accent);
}

.dropdown-display:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 2, 3, 129), 0.2);
}

/* Thumbnail in the main dropdown display */
.selected-realm-thumb {
  width: 20px;
  height: 20px;
  margin: 0 8px 0 12px; /* Remove vertical margins to prevent height expansion */
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.realm-search-input {
  width: 100%; /* Take full width of parent container */
  max-width: 100%; /* Ensure it doesn't exceed container */
  padding: 9px 32px 9px 12px; /* Adjusted padding for fixed height (38px total) */
  background: transparent; /* Let the dropdown-display handle the background */
  color: var(--text);
  border: none; /* Border is handled by dropdown-display */
  border-radius: 0; /* Border radius handled by dropdown-display */
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  box-sizing: border-box; /* Include padding in width calculation */
  outline: none; /* Focus handled by dropdown-display */
  line-height: 1.2; /* Consistent line height */
}

/* When there's a thumbnail, reduce left padding but maintain overall height */
.selected-realm-thumb:not([style*="display: none"]) + .realm-search-input {
  padding-left: 8px; /* Reduced padding when thumbnail is visible */
}

.realm-search-input[readonly] {
  cursor: pointer;
  background: transparent;
}

.realm-search-input::placeholder {
  color: var(--text);
  opacity: 0.7;
}

/* Dropdown arrow positioned for fixed height container */
.dropdown-arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text);
  font-size: 0.8em;
  user-select: none;
  transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-arrow {
  transform: translateY(-50%) rotate(180deg);
}

/* Dropdown list container with sexy slide animations */
.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%; /* Use 100% width instead of right: 0 to stay within parent */
  z-index: 1000;
  background: var(--surface-1);
  border: 1px solid var(--border-weak);
  border-radius: 6px;
  margin-top: 2px;
  max-height: 0; /* Start collapsed for animation */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px); /* Start slightly above for slide effect */
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease-out 0.05s, /* Slight delay for smoother feel */
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s ease-out;
  pointer-events: none; /* Prevent interaction when closed */
}

/* When dropdown is open - smooth slide down animation */
.custom-dropdown.open .dropdown-list {
  max-height: 400px; /* Enough for ~9-10 items + search bar */
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto; /* Re-enable interaction when open */
}

/* Search input inside dropdown */
.search-filter {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--border-weak);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9em;
}

.search-filter:focus {
  outline: none;
  background: var(--surface-1);
}

.search-filter::placeholder {
  color: var(--text);
  opacity: 0.6;
}

/* Options container with smooth scrolling - limits to ~9-10 visible items */
.options-container {
  max-height: 320px; /* ~10 items at 32px each = 320px */
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--border-weak) transparent; /* Firefox */
}

/* Custom scrollbar styling for Webkit browsers */
.options-container::-webkit-scrollbar {
  width: 6px;
}

.options-container::-webkit-scrollbar-track {
  background: transparent;
}

.options-container::-webkit-scrollbar-thumb {
  background-color: var(--border-weak);
  border-radius: 3px;
  transition: background-color 0.2s;
}

.options-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent);
}

/* Individual dropdown option */
.dropdown-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid transparent;
}

.dropdown-option:hover,
.dropdown-option.highlighted {
  background: var(--border-weak);
}

.dropdown-option.selected {
  background: var(--accent-2);
  color: var(--text-strong);
}

.dropdown-option:last-child {
  border-bottom: none;
}

.option-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Realm thumbnail styling - makes those Discord server icons look sexy as hell */
.realm-thumb {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0; /* Prevent thumbnail from getting squished by long text */
  border: 1px solid var(--border-weak);
  transition: border-color 0.2s;
}

/* Placeholder for realms without thumbnails - maintains consistent spacing */
.realm-thumb-placeholder {
  background: var(--surface-2);
  border: 1px solid var(--border-weak);
  opacity: 0.5;
}

/* Slightly highlight thumbnail when option is hovered/selected */
.dropdown-option:hover .realm-thumb,
.dropdown-option.highlighted .realm-thumb {
  border-color: var(--accent);
}

.dropdown-option.selected .realm-thumb {
  border-color: var(--text-strong);
}

/* Hidden input for form submission */
.realm-value {
  display: none;
}

.realm-dropdown-empty {
  padding: 12px;
  text-align: center;
  color: var(--text);
  opacity: 0.7;
  font-style: italic;
}

/* =================================================================
 * ORGANIZATION CARDS
 * =================================================================*/

.orgs-card.hidden { display: none; }

.orgs-card .card-title {
  font-weight: bold;
  margin-bottom: 6px;
}

.orgs-card .card-body { 
  font-size: 0.95rem;
  line-height: 1.3;
}

.orgs-loading { opacity: 0.8; font-style: italic; }
.orgs-error   { color: var(--accent-warn, #c98000); margin: 6px 0; }
.orgs-stale   { font-size: 0.85em; margin-left: 6px; opacity: 0.9; }

.orgs-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.orgs-divider { margin: 8px 0 4px; font-weight: 600; opacity: 0.9; }

.orgs-list { list-style: none; padding: 0; margin: 0; }
.org-item { padding: 3px 0; border-bottom: 1px dashed var(--border-weak, #556); }
.org-item:last-child { border-bottom: 0; }

.org-item.primary { font-weight: 600; }
.org-sid { font-family: monospace; padding: 1px 4px; border: 1px solid var(--border-weak, #556); border-radius: 3px; }
.org-name { margin-left: 6px; }
.org-role { opacity: 0.85; }

/* Organization thumbnail styling - tiny images for main orgs because "more visual = less boring" */
.org-thumbnail {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
  object-fit: cover; /* Keep aspect ratio, crop if needed */
  border: 1px solid var(--border-weak, #556);
  opacity: 0.9;
  flex-shrink: 0; /* Don't let it get squished by long org names */
}

/* Style the org item when it has a thumbnail - make it flex to align properly */
.org-item.has-thumbnail {
  display: flex;
  align-items: center;
}

.org-item.has-thumbnail .org-content {
  display: flex;
  align-items: center;
  flex: 1;
}

/* =================================================================
 * THEME DROPDOWN STYLING (Reuse realm dropdown animations)
 * =================================================================*/

.theme-dropdown-container {
  position: relative;
  display: inline-block;
  width: 110px !important; /* Fixed width sized for "90's HTML" + padding + arrow - force override */
  min-width: 110px; /* Prevent shrinking */
  max-width: 110px !important; /* Ensure no inheritance from realm dropdown */
}

.theme-dropdown-display {
  height: 32px; /* Slightly smaller than realm dropdown for header */
}

.theme-search-input {
  width: 100%;
  padding: 6px 28px 6px 8px; /* Smaller padding for compact header */
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-weak);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9em; /* Slightly smaller font */
  cursor: pointer;
  box-sizing: border-box;
  outline: none;
  line-height: 1.2;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.theme-search-input:hover,
.theme-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 2, 3, 129), 0.2);
}

/* Theme dropdown animations - explicit rules to ensure proper inheritance */
.theme-dropdown-container .custom-dropdown {
  width: 100% !important; /* Force theme dropdown to use container width, not realm width */
  max-width: 100% !important;
}

.theme-dropdown-container .dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100% !important; /* Match container width for consistency - force override */
  z-index: 1000;
  background: var(--surface-1);
  border: 1px solid var(--border-weak);
  border-radius: 6px;
  margin-top: 2px;
  max-height: 0; /* Start collapsed for animation */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px); /* Start slightly above for slide effect */
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease-out 0.05s, /* Slight delay for smoother feel */
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s ease-out;
  pointer-events: none; /* Prevent interaction when closed */
}

/* When theme dropdown is open - smooth slide down animation */
.theme-dropdown-container .custom-dropdown.open .dropdown-list {
  max-height: 200px; /* Enough for 3 theme options */
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto; /* Re-enable interaction when open */
}

/* Theme dropdown options container */
.theme-dropdown-container .options-container {
  max-height: 150px; /* Smaller than realm dropdown since fewer options */
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* =================================================================
 * SPECIAL EFFECT CLASSES (Used across multiple pages)
 * =================================================================
 * These provide the fancy animations and visual effects
 * =================================================================*/

/* Default states for all effects (disabled unless theme activates them) */
.fx-rainbow {
  background: none;
  background-size: auto;
  -webkit-background-clip: initial;
          background-clip: border-box;
  color: inherit;
  -webkit-text-fill-color: initial;
  animation: none; 
}
.fx-glow    { text-shadow: none; animation: none; }
.fx-blink   { animation: none; }
.fx-shimmer { background: none; color: inherit; -webkit-text-fill-color: initial; animation: none; }
.fx-scan { position: relative; }
.fx-scan::after {
  content: "";
  position: absolute; 
  inset: 0;
  background: none;
  pointer-events: none;
  animation: none; 
}

.fx-marquee, .fx-marqueeReverse { 
  animation: none;  
}

.fx-type {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid currentColor;
  font-family: Consolas, "Courier New", Menlo, Monaco, monospace;
  /* animations are attached per-theme */
}

.fx-underline-wiggle {
  animation: none; 
}

.fx-sparkle { position: relative; }
.fx-sparkle::before, .fx-sparkle::after {
  content: "✦"; 
  position: absolute; 
  color: #ff00ff; 
  opacity: 0;
}
.fx-sparkle::before { top: -0.6em; left: -0.8em; }
.fx-sparkle::after  { bottom: -0.6em; right: -0.8em; color: #00ffff; }

/* Terminal Theme Special Effects */
html[data-theme="terminal"] .fx-scan::after {
  background: repeating-linear-gradient(0deg, rgba(150,255,150,0.05), rgba(150,255,150,0.05) 1px, transparent 1px, transparent 3px);
  animation: scan 0.8s linear infinite; 
}

/* =================================================================
 * LEGACY/EXPERIMENTAL STYLES
 * =================================================================*/

/* 3D button bevel and neon borders */
.btn-95 {
  border: 2px outset #fff;
  background: linear-gradient(#111, #222);
  color: var(--text-strong);
  box-shadow: 0 0 6px rgba(0,255,255,0.5), 0 0 12px rgba(255,0,255,0.4) inset;
}
.btn-95:active { border-style: inset; }

/* Neon border */
.border-neon {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--surface-2),var(--surface-2)) padding-box,
    linear-gradient(90deg, #ff00ff, #00ffff, #ffff00, #ff00ff) border-box;
  background-size: 100% 100%, 300% 100%;
  animation: rainbowSlide 6s linear infinite;
  border-radius: 8px;
}

/* =================================================================
 * TABLE RESPONSIVE BEHAVIOR
 * =================================================================*/

/* Mobile layout adjustments for page components */
@media (max-width: 800px) {
  main.page {
    /* single column, but clamp it to the container so nothing overflows */
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .page .summary {
    justify-self: stretch;     /* full column width */
    box-sizing: border-box;    /* borders/padding included in the box */
    max-width: 100%;           /* never exceed the grid track */
    /* remove any explicit width you may have added earlier */
    width: auto;
  }
  .page .results {
    box-sizing: border-box;
    max-width: 100%;
    width: auto;
  }
}

/* PU results: Date/Time, Attacker, Victim, DeathType, Weapon, Zone, Guild */
@media (max-width: 1000px) {
  /* hide cols 4..7 (DeathType, Weapon, Zone, Guild) */
  #puTable th:nth-child(n+4), #puTable td:nth-child(n+4) { display: none; }

  /* let date/time wrap */
  #puTable td:nth-child(1) { white-space: normal; }
}

/* Do the same for AC if needed: keep Date, Name, Mode; hide the rest */
@media (max-width: 800px) {
  #acTable th:nth-child(n+4), #acTable td:nth-child(n+4)  { display: none; } /* e.g., K/D details, etc. */

  /* let date/time wrap */
  #acTable td:nth-child(1) { white-space: normal; }
}

@media (max-width: 500px) {
  .theme-picker label {
    display: none;
  }
}

/* =================================================================
 * LEGAL PAGES STYLING (Terms of Service & Privacy Policy)
 * =================================================================
 * Professional legal document styling that integrates with the theme system
 * WITHOUT animations for serious legal document vibe
 * =================================================================*/

.legal-page {
  flex: 1 1 auto;
  background: var(--bg);
  color: var(--text);
  min-height: calc(100vh - 120px); /* Account for header/footer */
  padding: 2rem 1rem;
}

.legal-container {
  max-width: 900px;
  margin: 0 auto;
}

.legal-content {
  background: var(--surface-1);
  border: 2px solid var(--border-weak);
  border-radius: 8px;
  overflow: hidden;
}

.legal-header {
  background: var(--surface-2);
  padding: 2rem;
  border-bottom: 2px solid var(--border-weak);
  text-align: center;
}

.legal-header h1 {
  color: var(--text-strong);
  font-size: 2.5rem;
  margin: 0 0 1rem 0;
  font-weight: 700;
}

.legal-updated {
  color: var(--text);
  font-size: 1rem;
  opacity: 0.8;
}

.legal-body {
  padding: 2rem;
}

.legal-notice {
  background: var(--accent-2);
  color: var(--text-strong);
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 2rem;
  font-weight: 600;
  border: 2px solid var(--border-weak);
}

.legal-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-weak);
}

.legal-section:last-of-type {
  border-bottom: none;
}

.legal-section h2 {
  color: var(--text-strong);
  font-size: 1.8rem;
  margin: 0 0 1rem 0;
  font-weight: 700;
}

.legal-section h3 {
  color: var(--text-strong);
  font-size: 1.4rem;
  margin: 0 0 1rem 0;
  font-weight: 600;
}

.legal-section h4 {
  color: var(--text-strong);
  font-size: 1.2rem;
  margin: 1.5rem 0 0.5rem 0;
  font-weight: 600;
}

.legal-section p {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.legal-section ul {
  color: var(--text);
  line-height: 1.6;
  margin: 1rem 0;
  padding-left: 2rem;
}

.legal-section li {
  margin-bottom: 0.5rem;
}

.legal-section strong {
  color: var(--text-strong);
  font-weight: 600;
}

.legal-section a {
  color: var(--link);
  text-decoration: underline;
}

.legal-section a:hover {
  color: var(--text-strong);
  text-decoration: none;
}

.legal-warning {
  /* background: var(--warning); */
  color: var(--text-strong);
  padding: 1rem;
  border-radius: 6px;
  margin: 2rem 0;
  font-weight: 600;
  border: 2px solid var(--border-weak);
}

.legal-success {
  background: var(--success);
  color: var(--text-strong);
  padding: 1rem;
  border-radius: 6px;
  margin: 2rem 0;
  font-weight: 600;
  border: 2px solid var(--border-weak);
}

.legal-actions {
  text-align: center;
  padding: 2rem 0 0 0;
  border-top: 2px solid var(--border-weak);
}

.legal-btn {
  display: inline-block;
  background: var(--accent);
  color: var(--text-strong);
  padding: 1rem 2rem;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1.1rem;
  border: 2px solid var(--border-weak);
  transition: background-color 0.2s ease;
}

.legal-btn:hover {
  background: var(--accent-2);
  color: var(--text-strong);
  text-decoration: none;
}

/* Responsive design for legal pages */
@media (max-width: 768px) {
  .legal-page {
    padding: 1rem 0.5rem;
  }
  
  .legal-header {
    padding: 1.5rem 1rem;
  }
  
  .legal-header h1 {
    font-size: 2rem;
  }
  
  .legal-body {
    padding: 1.5rem 1rem;
  }
  
  .legal-section h2 {
    font-size: 1.5rem;
  }
  
  .legal-section h3 {
    font-size: 1.3rem;
  }
  
  .legal-section ul {
    padding-left: 1.5rem;
  }
}

/* Theme-specific adjustments for legal pages */

/* Retro90s theme: tone down the chaos for legal docs */
html[data-theme="retro90s"] .legal-notice,
html[data-theme="retro90s"] .legal-warning,
html[data-theme="retro90s"] .legal-success {
  /* Use theme colors but reduce visual intensity */
  border-width: 1px;
}

/* Terminal theme: clean monospace aesthetic */
html[data-theme="terminal"] .legal-page {
  font-family: var(--font-mono);
}

html[data-theme="terminal"] .legal-header h1 {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Coffee theme: warm and readable */
html[data-theme="coffee"] .legal-page {
  font-family: var(--font-coffee);
  font-size: 1.1rem;
}

html[data-theme="coffee"] .legal-header h1 {
  font-family: var(--font-coffee);
  font-weight: 700;
}