/*
 * My RPG Source
 * Standalone Rules, Races, Species, Equipment, Spells & Magic Items Codex
 */

.codex-shell {
  width: min(1220px, calc(100% - 32px));
}

.codex-hero {
  padding-bottom: 30px;
}

.codex-stat-grid {
  margin-top: 30px;

  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
}

.codex-stat {
  min-height: 96px;
  padding: 16px;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  border-radius: 14px;

  text-align: center;
}

.codex-stat strong {
  color: var(--accent);
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.5rem, 4vw, 2.15rem);
  line-height: 1.1;
}

.codex-stat span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.codex-introduction {
  margin-top: 0;
}

.codex-workspace {
  margin-top: 28px;
}

.codex-filter-panel {
  padding: clamp(20px, 4vw, 30px);

  background: rgba(12, 18, 25, 0.78);
  border: 1px solid var(--border);
  border-radius: 20px;

  box-shadow: 0 18px 40px var(--shadow);
}

.codex-filter-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.codex-filter-heading h2 {
  margin-bottom: 0;
}

#codex-reset,
#codex-load-more {
  padding: 10px 16px;

  color: #ffffff;
  background: #6c3483;

  border: 1px solid #d2b4de;
  border-radius: 10px;

  font: inherit;
  font-weight: 700;

  cursor: pointer;
}

#codex-reset:hover,
#codex-load-more:hover {
  background: #884ea0;
}

.codex-filter-grid {
  margin-top: 22px;

  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.codex-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.codex-field-search {
  grid-column: span 2;
}

.codex-field label {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.codex-field input,
.codex-field select {
  min-height: 44px;
  width: 100%;
  padding: 9px 11px;

  color: #17212c;
  background: #fffdf6;

  border: 2px solid transparent;
  border-radius: 9px;

  font: inherit;
  font-size: 0.94rem;
}

.codex-field input:focus,
.codex-field select:focus {
  border-color: #b784cf;
  outline: none;
  box-shadow: 0 0 0 3px rgba(183, 132, 207, 0.22);
}

.codex-field.is-inactive {
  opacity: 0.42;
}

.codex-field.is-inactive select {
  cursor: not-allowed;
}

.codex-results-heading {
  margin: 24px 2px 12px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

#codex-status {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.codex-results-tip {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.codex-results {
  display: grid;
  gap: 12px;
}

.codex-entry {
  overflow: hidden;

  background: rgba(244, 236, 216, 0.065);
  border: 1px solid var(--border);
  border-radius: 14px;

  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.codex-entry[open] {
  background: rgba(244, 236, 216, 0.10);
  border-color: rgba(221, 161, 94, 0.52);
}

.codex-entry summary {
  padding: 16px 18px;

  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;

  cursor: pointer;
  list-style: none;
}

.codex-entry summary::-webkit-details-marker {
  display: none;
}

.codex-entry summary::after {
  content: "+";

  width: 30px;
  height: 30px;

  display: grid;
  place-items: center;

  color: #ffffff;
  background: rgba(142, 68, 173, 0.68);
  border: 1px solid rgba(210, 180, 222, 0.58);
  border-radius: 50%;

  font-family: Arial, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.codex-entry[open] summary::after {
  content: "−";
}

.codex-entry-title {
  min-width: 0;
}

.codex-entry-title h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.02rem, 2.3vw, 1.23rem);
}

.codex-entry-meta {
  margin-top: 8px;

  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.codex-badge {
  padding: 3px 8px;

  display: inline-flex;
  align-items: center;

  color: var(--text);
  background: rgba(255, 255, 255, 0.075);

  border: 1px solid var(--border);
  border-radius: 999px;

  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
}

.codex-badge-edition {
  color: #fff6bf;
  background: rgba(241, 196, 15, 0.12);
  border-color: rgba(241, 196, 15, 0.36);
}

.codex-badge-spell {
  color: #ead7ff;
  background: rgba(142, 68, 173, 0.18);
  border-color: rgba(183, 132, 207, 0.46);
}

.codex-badge-item {
  color: #d9f7ef;
  background: rgba(22, 160, 133, 0.16);
  border-color: rgba(72, 201, 176, 0.42);
}

.codex-badge-ancestry {
  color: #dff7d9;
  background: rgba(39, 174, 96, 0.17);
  border-color: rgba(88, 214, 141, 0.46);
}

.codex-badge-equipment {
  color: #d8f0ff;
  background: rgba(41, 128, 185, 0.17);
  border-color: rgba(93, 173, 226, 0.46);
}

.codex-entry-body {
  padding: 0 18px 20px;
  border-top: 1px solid var(--border);
}

.codex-facts {
  margin: 16px 0;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.codex-fact {
  padding: 10px 12px;

  background: rgba(0, 0, 0, 0.16);
  border-radius: 9px;
}

.codex-fact dt {
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.codex-fact dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.codex-description {
  margin: 0;
  color: var(--muted);
  white-space: pre-line;
}

.codex-entry-body a,
.codex-attribution a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.codex-source-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

.codex-load-row {
  padding-top: 22px;
  text-align: center;
}

#codex-load-more {
  min-width: 220px;
}

.codex-error {
  margin-top: 16px;
  padding: 20px;

  background: rgba(192, 57, 43, 0.14);
  border: 1px solid rgba(231, 76, 60, 0.48);
  border-radius: 14px;
}

.codex-error h2 {
  color: #ffb7ad;
}

.codex-empty {
  padding: 34px 20px;

  color: var(--muted);
  background: rgba(244, 236, 216, 0.055);
  border: 1px dashed var(--border);
  border-radius: 14px;

  text-align: center;
}

.codex-attribution .attribution + .attribution {
  margin-top: 16px;
}

@media (max-width: 900px) {
  .codex-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .codex-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .codex-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .codex-filter-heading,
  .codex-results-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  #codex-reset {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .codex-filter-grid,
  .codex-facts {
    grid-template-columns: 1fr;
  }

  .codex-field-search {
    grid-column: auto;
  }

  .codex-entry summary {
    padding: 14px;
  }

  .codex-entry-body {
    padding: 0 14px 18px;
  }
}

@media print {
  .codex-filter-panel,
  .codex-load-row,
  .codex-results-tip {
    display: none !important;
  }

  .codex-entry {
    break-inside: avoid;
  }
}

/* Complete Rules Codex additions */
.codex-start-grid {
  margin-top: 20px;

  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.codex-start-grid a {
  padding: 12px 14px;

  color: var(--text);
  background: rgba(142, 68, 173, 0.13);

  border: 1px solid rgba(183, 132, 207, 0.34);
  border-radius: 10px;

  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.codex-start-grid a:hover,
.codex-start-grid a:focus-visible {
  background: rgba(142, 68, 173, 0.24);
  border-color: rgba(210, 180, 222, 0.62);
}

.codex-field-note {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.codex-badge-rule {
  color: #ffe9c7;
  background: rgba(211, 132, 43, 0.17);
  border-color: rgba(221, 161, 94, 0.46);
}

.codex-rule-section {
  margin-top: 18px;
}

.codex-rule-section h4 {
  margin: 0 0 6px;

  color: var(--accent-2);

  font-family: "Cinzel", Georgia, serif;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.codex-rule-section p,
.codex-rule-section ul {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.codex-rule-section ul {
  padding-left: 20px;
}

.codex-rule-section li + li {
  margin-top: 5px;
}

.codex-related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.codex-related-links button {
  padding: 6px 9px;

  color: #ead7ff;
  background: rgba(142, 68, 173, 0.16);

  border: 1px solid rgba(183, 132, 207, 0.4);
  border-radius: 999px;

  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;

  cursor: pointer;
}

.codex-related-links button:hover,
.codex-related-links button:focus-visible {
  background: rgba(142, 68, 173, 0.29);
}

.codex-entry summary:focus-visible {
  outline: 3px solid rgba(183, 132, 207, 0.6);
  outline-offset: -3px;
}

@media (max-width: 900px) {
  .codex-start-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .codex-start-grid {
    grid-template-columns: 1fr;
  }
}


/* Class foundations */
.codex-badge-class {
  color: #dff7ff;
  background: rgba(33, 150, 243, 0.16);
  border-color: rgba(100, 181, 246, 0.48);
}

.codex-table-note {
  margin-bottom: 10px !important;
  font-size: 0.82rem;
}

.codex-table-wrapper {
  overflow-x: auto;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.codex-table-wrapper:focus-visible {
  outline: 3px solid rgba(100, 181, 246, 0.6);
  outline-offset: 3px;
}

.codex-progression-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  color: var(--text);
  background: rgba(0, 0, 0, 0.12);
}

.codex-progression-table th,
.codex-progression-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.codex-progression-table thead th {
  color: var(--accent);
  background: rgba(0, 0, 0, 0.22);
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.76rem;
  letter-spacing: 0.035em;
}

.codex-progression-table tbody th {
  width: 70px;
  color: var(--accent-2);
}

.codex-progression-table tbody tr:last-child th,
.codex-progression-table tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 520px) {
  .codex-progression-table th,
  .codex-progression-table td {
    padding: 8px;
  }
}
