/* ==========================================================================
   SECTION 1: MODAL OVERLAY & INERT ACCESSIBILITY
   ========================================================================== */

/* Overlay Container - Defines container query context for responsive child elements */
.wiki-modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5cqw;
  container-type: inline-size;
  container-name: game;
}

/* Visibility states */
.wiki-modal-overlay.hidden,
.wiki-modal-overlay[hidden] {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Inert target styling */
.menu-container[inert],
.initscreen-container[inert] {
  pointer-events: none !important;
  user-select: none !important;
  filter: blur(1px);
  transition: filter 0.2s ease-in-out;
}

[inert],
[inert] * {
  pointer-events: none !important;
  user-select: none !important;
}


/* ==========================================================================
   SECTION 2: MODAL CONTAINER SHELL & FOCUS STYLES
   ========================================================================== */

.wiki-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(5, 3, 2, 0.85);
  backdrop-filter: blur(4px);
}

/* Main modal shell - Added max-width & max-height caps for ultra-wide displays */
.wiki-modal-container {
  position: relative;
  z-index: 1001;
  width: 92%;
  max-width: 1100px;
  height: 85%;
  max-height: 850px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 1.5cqw;
  background-color: var(--bg-wood-dark, #1a0f0a);
  border: 0.25cqw solid var(--border-gold, #c89d38);
  box-shadow: 0 1cqh 3cqw rgba(0, 0, 0, 0.8);
}

.wiki-modal-container button:focus-visible,
.wiki-modal-container [tabindex]:focus-visible,
.wiki-modal-container select:focus-visible {
  outline: 0.4cqw solid var(--border-gold-light, #f3d078);
  outline-offset: 0.4cqw;
}


/* ==========================================================================
   SECTION 3: HEADER COMPONENT
   ========================================================================== */

.wiki-modal-header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1cqh;
  padding: 2.5cqh 3.5cqw;
  background-color: var(--bg-wood-dark, #1a0f0a);
  border-bottom: 0.25cqw solid var(--border-gold, #c89d38);
}

.wiki-header-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5cqh;
}

.wiki-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1rem, 4.5cqw, 1.4rem);
  font-weight: 700;
  color: var(--text-gold, #e2b755);
  letter-spacing: 0.05em;
  margin: 0;
  text-shadow: 0.2cqw 0.2cqw 0.4cqw rgba(0, 0, 0, 0.8);
}

.wiki-subtitle {
  font-size: clamp(0.65rem, 2.5cqw, 0.8rem);
  color: #c0b098;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wiki-close-btn {
  position: absolute;
  top: 2.5cqh;
  right: 3.5cqw;
  border: none;
  cursor: pointer;
  line-height: 1;
  width: clamp(2rem, 9cqw, 3rem);
  height: clamp(2rem, 9cqw, 3rem);
  border-radius: 50%;
  background-color: #d9534f;
  border: 0.25cqw solid var(--border-gold, #c89d38);
  color: #ffffff;
  font-size: clamp(1.2rem, 5.5cqw, 1.8rem);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.wiki-close-btn:focus-visible {
  outline: 0.4cqw solid var(--border-gold-light, #f3d078);
  outline-offset: 0.4cqw;
}

.wiki-close-btn:hover {
  background-color: #ec7063;
  border-color: var(--border-gold-light, #f3d078);
  transform: scale(1.05);
}


/* ==========================================================================
   SECTION 4: MAIN LAYOUT & NAVIGATION SIDEBAR
   ========================================================================== */

.wiki-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.wiki-sidebar {
  width: 100%;
  background-color: rgba(20, 12, 8, 0.75);
  border-bottom: 0.2cqw solid rgba(200, 157, 56, 0.3);
  display: flex;
  flex-direction: column;
  gap: 1cqh;
  padding: 1.5cqh 3.5cqw;
}

.wiki-tab-select {
  width: 100%;
  padding: 1.5cqh 2cqw;
  background-color: var(--bg-wood-mid, #2c1a12);
  border: 0.2cqw solid var(--border-gold, #c89d38);
  border-radius: 1cqw;
  font-family: 'Cinzel', serif;
  font-size: clamp(0.7rem, 2.8cqw, 0.9rem);
  font-weight: 600;
  color: var(--text-gold, #e2b755);
  cursor: pointer;
  transition: border-color 0.15s ease, outline 0.15s ease;
}

.wiki-tab-select:focus,
.wiki-tab-select:hover {
  outline: 0.3cqw solid var(--border-gold-light, #f3d078);
  outline-offset: 0.1cqw;
}

.wiki-tab-select option {
  background-color: var(--bg-wood-dark, #1a0f0a);
  color: var(--text-gold, #e2b755);
  padding: 1cqh 1cqw;
}


/* ==========================================================================
   SECTION 5: MAIN CONTENT AREA & SCROLLBAR FINE-TUNING
   ========================================================================== */

.wiki-content-area {
  flex: 1;
  padding: 3cqw;
  overflow-y: auto;
  overflow-x: hidden; /* Prevents unwanted horizontal scrollbars */
  scrollbar-width: thin;
  scrollbar-color: var(--border-gold, #c89d38) rgba(26, 15, 10, 0.85);
}

.wiki-content-area::-webkit-scrollbar {
  width: 0.8cqw;
  min-width: 6px;
}

.wiki-content-area::-webkit-scrollbar-track {
  background: rgba(26, 15, 10, 0.85);
  border-radius: 0.4cqw;
  border: 0.1cqw solid rgba(200, 157, 56, 0.25);
}

.wiki-content-area::-webkit-scrollbar-thumb {
  background: var(--border-gold, #c89d38);
  border-radius: 0.4cqw;
  border: 0.1cqw solid rgba(44, 26, 18, 0.6);
  box-shadow: inset 0 0 0.3cqw rgba(255, 255, 255, 0.3);
}

.wiki-content-area::-webkit-scrollbar-thumb:hover {
  background: var(--border-gold-light, #f3d078);
}

.wiki-tab-panel {
  display: block;
}

.wiki-tab-panel.hidden,
.wiki-tab-panel[hidden] {
  display: none !important;
}


/* ==========================================================================
   SECTION 6: UNIT MAIN STATS CARDS & STAT METRICS (#wiki-tab-stats)
   ========================================================================== */

/* Responsive Grid Layout */
#wiki-tab-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 1.25rem;
}

.wiki-stat-card,
#wiki-tab-stats .wiki-card {
  background: var(--bg-wood-dark, #1a0f0a);
  border: 0.2cqw solid rgba(200, 157, 56, 0.35);
  border-radius: 1.2cqw;
  padding: 1.5rem;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0; /* Prevents grid item expansion beyond track boundaries */
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.wiki-stat-card:hover,
#wiki-tab-stats .wiki-card:hover {
  border-color: var(--border-gold-light, #f3d078);
  box-shadow: 0 0.5cqh 1.5cqw rgba(0, 0, 0, 0.6);
  transform: translateY(-0.2cqh);
}

/* Card Heading Fix: Changed from flex to block to preserve inline text flow */
.wiki-stat-card h3,
#wiki-tab-stats .wiki-card h3,
.wiki-card h3 {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.85rem, 2.5cqw, 1.05rem);
  color: var(--text-gold, #e2b755);
  margin-bottom: 0.8cqh;
  display: block;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Inline code tags inside card titles */
.wiki-stat-card h3 code,
.wiki-card h3 code {
  display: inline-block;
  vertical-align: middle;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--text-gold-light, #f3d078);
  background: rgba(0, 0, 0, 0.5);
  border: 0.1cqw solid rgba(200, 157, 56, 0.35);
  padding: 0.1cqh 0.4cqw;
  border-radius: 0.4cqw;
  text-shadow: 0 0 0.3cqw rgba(226, 183, 85, 0.3);
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.wiki-stat-card p,
#wiki-tab-stats .wiki-card p {
  font-size: clamp(0.68rem, 2.4cqw, 0.85rem);
  color: #d4c5b0;
  line-height: 1.5;
  margin-bottom: 1.2cqh;
}

/* Stat Metric Badges */
.stat-badge-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.5);
  border: 0.15cqw solid rgba(200, 157, 56, 0.3);
  border-radius: 0.8cqw;
  padding: 0.6cqh 1.2cqw;
  margin-top: auto;
  gap: 0.5rem;
}

.stat-badge-key {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.6rem, 2.2cqw, 0.75rem);
  font-weight: 600;
  color: #e0d5c1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-badge-val {
  font-family: monospace;
  font-size: clamp(0.65rem, 2.4cqw, 0.82rem);
  font-weight: 700;
  color: var(--text-gold-light, #f3d078);
  background: rgba(200, 157, 56, 0.2);
  border: 0.1cqw solid var(--border-gold, #c89d38);
  border-radius: 0.5cqw;
  padding: 0.2cqh 0.8cqw;
  text-shadow: 0 0 0.3cqw rgba(226, 183, 85, 0.4);
  word-break: break-all;
}


/* ==========================================================================
   SECTION 7: FORMULA CALLOUT BOX STYLING
   ========================================================================== */

.wiki-formula-card,
.wiki-formula-box {
  background: rgba(0, 0, 0, 0.5);
  border: 0.15cqw solid var(--border-gold, #c89d38);
  border-radius: 1cqw;
  padding: 1.5cqh 2cqw;
  margin-top: 1cqh;
  margin-bottom: 1.8cqh;
  box-shadow: inset 0 0 1cqw rgba(0, 0, 0, 0.6);
  min-width: 0;
}

.wiki-formula-card h3,
.wiki-formula-box h3,
.wiki-formula-card h4,
.wiki-formula-box h4 {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.8rem, 3cqw, 1.05rem);
  color: var(--text-gold, #e2b755);
  margin-bottom: 0.8cqh;
}

.wiki-formula-card code,
.wiki-formula-box code,
.wiki-formula-card p,
.wiki-formula-box p {
  font-family: monospace;
  font-size: clamp(0.72rem, 2.7cqw, 0.92rem);
  color: var(--text-gold-light, #f3d078);
  text-shadow: 0 0 0.4cqw rgba(226, 183, 85, 0.45);
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
}


/* ==========================================================================
   SECTION 8: STATUS EFFECT BADGES (.status-badge)
   ========================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5cqw;
  font-family: 'Inter', sans-serif;
  font-size: clamp(0.62rem, 2.2cqw, 0.78rem);
  font-weight: 600;
  line-height: 1;
  padding: 0.4cqh 1.2cqw;
  border-radius: 1cqw;
  margin: 0.2cqh 0.3cqw;
  box-shadow: 0 0.2cqh 0.6cqw rgba(0, 0, 0, 0.4);
}

.badge-cc-hard {
  background-color: rgba(139, 0, 0, 0.85);
  border: 0.15cqw solid #ff4d4d;
  color: #ffffff;
}

.badge-cc-soft {
  background-color: rgba(180, 83, 9, 0.85);
  border: 0.15cqw solid #fb923c;
  color: #ffffff;
}

.badge-buff {
  background-color: rgba(6, 78, 59, 0.85);
  border: 0.15cqw solid #34d399;
  color: #ffffff;
}

.badge-debuff {
  background-color: rgba(88, 28, 28, 0.85);
  border: 0.15cqw solid #f87171;
  color: #ffffff;
}


/* ==========================================================================
   SECTION 9: UNITS GRID & CARD DISPLAY
   ========================================================================== */

.wiki-unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 1.25rem;
}

.wiki-unit-card {
  background: var(--bg-wood-dark, #1a0f0a);
  border: 0.2cqw solid rgba(200, 157, 56, 0.4);
  border-radius: 1.5cqw;
  padding: 2cqh 1.5cqw;
  text-align: center;
  cursor: pointer;
  min-width: 0;
  box-sizing: border-box;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.wiki-unit-card:hover {
  transform: translateY(-0.5cqh);
  border-color: var(--border-gold-light, #f3d078);
  box-shadow: 0 0.8cqh 2cqw rgba(0, 0, 0, 0.5);
}

.wiki-unit-icon {
  font-size: clamp(1.4rem, 6cqw, 2.2rem);
  margin-bottom: 0.8cqh;
  display: block;
}

.wiki-unit-name {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.7rem, 2.8cqw, 0.9rem);
  font-weight: 700;
  color: var(--text-gold, #e2b755);
}

.wiki-unit-role {
  font-size: clamp(0.6rem, 2.2cqw, 0.75rem);
  text-transform: uppercase;
  color: #c0b098;
}


/* ==========================================================================
   SECTION 10: DETAILED UNIT VIEW & STATS
   ========================================================================== */

.wiki-unit-detail {
  background-color: rgba(20, 12, 8, 0.75);
  border: 0.2cqw solid var(--border-gold, #c89d38);
  border-radius: 1.5cqw;
  padding: 3cqw;
  color: #d4c5b0;
  min-width: 0;
}

.wiki-back-btn {
  background: var(--bg-wood-mid, #2c1a12);
  border: 0.2cqw solid var(--border-gold, #c89d38);
  color: var(--text-gold, #e2b755);
  padding: 1cqh 2.5cqw;
  border-radius: 1cqw;
  cursor: pointer;
  font-size: clamp(0.65rem, 2.5cqw, 0.85rem);
  margin-bottom: 2cqh;
}

.wiki-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.2cqh 0;
  font-size: clamp(0.7rem, 2.8cqw, 0.9rem);
  color: #d4c5b0;
}

.stat-tag {
  background: rgba(0, 0, 0, 0.5);
  padding: 0.8cqh 1.8cqw;
  border-radius: 0.8cqw;
  border: 0.2cqw solid rgba(200, 157, 56, 0.3);
  color: #e0d5c1;
}


/* ==========================================================================
   SECTION 11: GENERAL WIKI CARDS & ROLE TEXT UTILITIES
   ========================================================================== */

.wiki-card {
  background: var(--bg-wood-dark, #1a0f0a);
  border: 0.2cqw solid rgba(200, 157, 56, 0.35);
  border-radius: 1.5cqw;
  padding: 2.5cqw;
  margin-bottom: 2cqh;
  color: #d4c5b0;
  min-width: 0;
}

.wiki-card p {
  font-size: clamp(0.68rem, 2.4cqw, 0.85rem);
  color: #d4c5b0;
  line-height: 1.5;
  margin-bottom: 1cqh;
}

.wiki-card p:last-child {
  margin-bottom: 0;
}

.wiki-card code {
  font-family: monospace;
  font-size: 0.95em;
  color: var(--text-gold-light, #f3d078);
  background: rgba(0, 0, 0, 0.5);
  border: 0.1cqw solid rgba(200, 157, 56, 0.35);
  padding: 0.15cqh 0.5cqw;
  border-radius: 0.4cqw;
  text-shadow: 0 0 0.3cqw rgba(226, 183, 85, 0.3);
  word-break: break-all;
  overflow-wrap: anywhere;
}

.wiki-card ul {
  margin-top: 0.8cqh;
  margin-bottom: 0.8cqh;
  padding-left: 2.5cqw;
}

.wiki-card li {
  font-size: clamp(0.68rem, 2.4cqw, 0.85rem);
  color: #d4c5b0;
  margin-bottom: 0.6cqh;
  line-height: 1.45;
}

.wiki-card li strong {
  color: var(--text-gold, #e2b755);
}

.text-tank {
  color: var(--hp-green, #2ecc71);
}

.text-dps {
  color: var(--hp-red, #e74c3c);
}

.text-support {
  color: var(--mana-blue, #3498db);
}


/* ==========================================================================
   SECTION 12: RESPONSIVE CONTAINER QUERIES
   ========================================================================== */

@container game (max-width: 500px) {
  .wiki-modal-body {
    flex-direction: column;
  }

  .wiki-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 0.2cqw solid rgba(200, 157, 56, 0.3);
    padding: 1.5cqh 1.5cqw;
  }

  .wiki-tab-select {
    width: 100%;
    font-size: clamp(0.75rem, 3.5cqw, 0.95rem);
  }

  #wiki-tab-stats,
  .wiki-unit-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .wiki-formula-card,
  .wiki-formula-box {
    padding: 1.2cqh 1.5cqw;
  }
}