/* ==========================================
   Reference Panel — Slide-out Compendium
   ========================================== */

/* Toggle button */
.ref-panel-toggle {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: var(--shadow-lg), 0 4px 12px rgba(184, 134, 11, 0.2);
  transition: all var(--transition-normal);
  line-height: 1;
}

.ref-panel-toggle:hover {
  background: var(--accent-gold);
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-lg), 0 4px 20px rgba(184, 134, 11, 0.35);
}

.ref-panel-toggle.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

@media (min-width: 769px) {
  .ref-panel-toggle {
    bottom: 24px;
  }
}

/* Panel container */
.ref-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 330px;
  max-width: 90vw;
  height: 100%;
  z-index: 500;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  box-shadow: -6px 0 30px rgba(0, 0, 0, 0.2);
  border-left: 1px solid var(--border-color);
}

.ref-panel.open {
  transform: translateX(0);
}

/* Header */
.ref-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-dark);
  color: var(--text-inverse);
  flex-shrink: 0;
  border-bottom: 2px solid var(--accent-gold-dark);
}

.ref-panel-header h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.03em;
}

.ref-panel-close {
  background: none;
  border: none;
  color: var(--text-inverse);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.ref-panel-close:hover {
  opacity: 1;
}

/* Scrollable body */
.ref-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---- Accordion items ---- */
.ref-panel-accordion {
  border-bottom: 1px solid var(--border-light);
}

.ref-panel-accordion:last-child {
  border-bottom: none;
}

.ref-panel-accordion-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 10px var(--space-sm);
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
  border-left: 4px solid var(--tile-color, #999);
}

.ref-panel-accordion-header:hover {
  background: var(--bg-secondary);
}

.ref-panel-card-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ref-panel-card-icon svg {
  width: 20px;
  height: 20px;
}

.ref-panel-card-icon .tile-img-wrap {
  width: 22px;
  height: 22px;
}

.ref-panel-card-icon .tile-badge {
  width: 10px;
  height: 10px;
}

.ref-panel-card-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  flex: 1;
  color: var(--text-primary);
}

.ref-panel-chevron {
  font-size: 0.6rem;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.ref-panel-accordion.open .ref-panel-chevron {
  transform: rotate(180deg);
}

/* Accordion body */
.ref-panel-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 var(--space-sm);
}

.ref-panel-accordion.open .ref-panel-accordion-body {
  max-height: 500px;
  padding: var(--space-xs) var(--space-sm) var(--space-md);
}

/* Rule text */
.ref-panel-rule {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  line-height: 1.5;
}

/* Scoring table */
.ref-panel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.ref-panel-table tr {
  border-bottom: 1px solid var(--divider);
}

.ref-panel-table tr:last-child {
  border-bottom: none;
}

.ref-panel-table-label {
  padding: 3px 4px;
  color: var(--text-secondary);
}

.ref-panel-table-pts {
  padding: 3px 4px;
  text-align: right;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  font-family: var(--font-heading);
}

/* Special rule note */
.ref-panel-special {
  margin-top: var(--space-xs);
  padding: var(--space-xs);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.4;
}
