/* ── Glossary Modal ───────────────────────────────────────────────────────── */
/* Scoped entirely to #glossary-modal. Safe to delete with glossary.js.       */

#glossary-modal[hidden] { display: none; }

#glossary-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 18px;
}

#glossary-modal .gl-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 1, 0.80);
}

#glossary-modal .gl-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid #8a6520;
  background: #f2e8c8;
  color: #1e0e00;
  box-shadow: 0 20px 70px rgba(0,0,0,0.7), inset 0 0 0 1px rgba(255,240,180,0.35);
}

/* ── Header ── */

#glossary-modal .gl-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 11px;
  border-bottom: 1px solid rgba(140,100,30,0.35);
  background: #f2e8c8;
  z-index: 1;
}

#glossary-modal .gl-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#glossary-modal .gl-kicker {
  color: #6a7e6e;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#glossary-modal .gl-title {
  color: #1e0e00;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

#glossary-modal .gl-close {
  width: 32px;
  height: 32px;
  border: 1px solid #8a6520;
  background: rgba(0,0,0,0.08);
  color: #3a2000;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}

#glossary-modal .gl-close:hover {
  background: rgba(0,0,0,0.14);
  border-color: var(--choice);
}

/* ── Body ── */

#glossary-modal .gl-body {
  padding: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Area ── */

#glossary-modal .gl-area {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#glossary-modal .gl-area + .gl-area {
  border-top: 2px solid rgba(140,100,30,0.4);
}

/* shared chevron */
#glossary-modal .gl-chevron {
  font-size: 9px;
  color: #8a6520;
  transition: transform 0.22s ease;
  flex-shrink: 0;
}

/* area toggle — top level */
#glossary-modal .gl-area-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 16px 18px;
  border: none;
  background: rgba(0,0,0,0.06);
  color: #1e0e00;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s;
}

#glossary-modal .gl-area-toggle:hover { background: rgba(0,0,0,0.10); }

#glossary-modal .gl-area-toggle[aria-expanded="true"] .gl-chevron {
  transform: rotate(90deg);
}

#glossary-modal .gl-area-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
}

#glossary-modal .gl-area-content.open { max-height: 9999px; }

#glossary-modal .gl-area-desc {
  padding: 10px 18px 12px;
  color: #3a2400;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 15px;
  line-height: 1.55;
  border-bottom: 1px solid rgba(140,100,30,0.2);
}

/* sub-area toggle — second level */
#glossary-modal .gl-subarea-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 18px 12px 26px;
  border: none;
  border-top: 1px solid rgba(140,100,30,0.18);
  background: rgba(255,255,255,0.30);
  color: #2a1600;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s;
}

#glossary-modal .gl-subarea-toggle:hover { background: rgba(255,255,255,0.50); }

#glossary-modal .gl-subarea-toggle[aria-expanded="true"] .gl-chevron {
  transform: rotate(90deg);
}

#glossary-modal .gl-subarea-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
  background: rgba(255,255,255,0.12);
  border-left: 3px solid rgba(140,100,30,0.22);
  margin-left: 14px;
}

#glossary-modal .gl-subarea-content.open { max-height: 9999px; }

#glossary-modal .gl-subarea-desc {
  padding: 10px 16px;
  color: #3a2400;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 14.5px;
  line-height: 1.55;
  border-bottom: 1px solid rgba(140,100,30,0.15);
}

/* ── Section ── */

#glossary-modal .gl-section {
  padding: 14px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#glossary-modal .gl-section + .gl-section { margin-top: 6px; }

#glossary-modal .gl-section-heading {
  color: #1e0e00;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(140,100,30,0.28);
}

#glossary-modal .gl-section-desc {
  color: #4a3000;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 14px;
  line-height: 1.55;
  padding: 2px 0 4px;
}

/* ── Entries ── */

#glossary-modal .gl-entries {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(140,100,30,0.25);
  margin-bottom: 10px;
}

#glossary-modal .gl-entry {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(140,100,30,0.14);
  background: rgba(255,255,255,0.25);
}

#glossary-modal .gl-entry:last-child { border-bottom: none; }

/* ── Icon cell ── */

#glossary-modal .gl-icon-cell {
  display: grid;
  place-items: center;
  width: 44px;
  height: 38px;
  flex-shrink: 0;
}

#glossary-modal .gl-icon-img {
  max-width: 30px;
  max-height: 30px;
  object-fit: contain;
}

/* die previews */

#glossary-modal .gl-die {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--gl-die-border);
  background: var(--gl-die-bg);
  color: #fff7dc;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 0 rgba(0,0,0,0.38), 0 0 8px var(--gl-die-glow);
}

#glossary-modal .gl-die.attack {
  --gl-die-bg: linear-gradient(145deg, #7b1814, #b33a32);
  --gl-die-border: #e07158;
  --gl-die-glow: rgba(179,58,50,0.42);
}

#glossary-modal .gl-die.defense {
  --gl-die-bg: linear-gradient(145deg, #145666, #2f7f91);
  --gl-die-border: #7fc7ba;
  --gl-die-glow: rgba(47,127,145,0.42);
}

#glossary-modal .gl-die.enemy {
  --gl-die-bg: linear-gradient(145deg, #191411, #5b4436);
  --gl-die-border: #d9c2a0;
  --gl-die-glow: rgba(65,41,27,0.5);
}

#glossary-modal .gl-die.flat {
  --gl-die-bg: #59431c;
  --gl-die-border: #ad8a34;
  --gl-die-glow: rgba(173,138,52,0.3);
  color: #f9e6a7;
  width: auto;
  min-width: 28px;
  padding: 0 5px;
  font-size: 11px;
}

/* resource dot */

#glossary-modal .gl-resource-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gl-res-color);
  box-shadow: 0 0 8px var(--gl-res-color);
}

/* glyph */

#glossary-modal .gl-glyph {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: center;
}

/* ── Entry text ── */

#glossary-modal .gl-entry-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#glossary-modal .gl-entry-name {
  color: #1e0e00;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

#glossary-modal .gl-entry-desc {
  color: #3a2400;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 14px;
  line-height: 1.48;
}
