/*
 * My RPG Source - Dynamic Spellcasting
 * Build 1: 2024 class-aware pages + smart Wizard profile.
 */

#spellcasting-pages { display: contents; }
.spellcasting-summary-box[hidden],
[data-legacy-spell-page][hidden] { display: none !important; }

.dynamic-spell-page { gap: 7px; }
.spell-source-heading { margin-bottom: 0; }
.spell-source-subtitle {
  margin: -2px 0 2px;
  font-size: 9px;
  text-align: center;
  opacity: 0.78;
}
.spell-source-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}
.spell-stat-card,
.spell-progress-card,
.spell-slots-line,
.smart-spell-tier,
.spell-manual-note {
  border: 1px solid var(--border-color);
  border-radius: 4px;
}
.spell-stat-card { padding: 5px; text-align: center; min-width: 0; }
.spell-stat-label {
  display: block;
  margin-bottom: 1px;
  font-size: 7.5px;
  text-transform: uppercase;
  opacity: 0.7;
}
.spell-stat-value { display: block; font-weight: 700; font-size: 11px; }
.spell-progress-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.spell-progress-card { padding: 5px; font-size: 9px; text-align: center; }
.spell-progress-card strong { display: block; font-size: 11px; }
.spell-slots-line { padding: 5px 7px; font-size: 8.5px; text-align: center; }
.spell-slots-line + .spell-slots-line { margin-top: -2px; }

.smart-spell-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-height: 0;
  flex: 1;
}
.smart-spell-column {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  min-height: 0;
}
.smart-spell-tier { padding: 5px; min-width: 0; }
.smart-spell-tier.is-locked { opacity: 0.58; }
.smart-spell-tier.has-stored-spells { opacity: 1; border-style: dashed; }
.smart-spell-tier-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding-bottom: 3px;
  margin-bottom: 4px;
  border-bottom: 1px dashed rgba(92, 64, 51, 0.35);
}
.smart-spell-tier-title {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 9px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.smart-spell-tier-meta { font-size: 7.5px; opacity: 0.72; text-align: right; }
.smart-spell-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px;
  align-items: center;
  margin-top: 3px;
}
.smart-spell-row.cantrip-row { grid-template-columns: minmax(0, 1fr) auto; }
.smart-spell-select {
  width: 100%; min-width: 0; height: 25px; padding: 2px 5px; font-size: 8.5px;
}
.smart-spell-prepared {
  display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; font-size: 7.5px;
}
.smart-spell-prepared input { margin: 0; }
.smart-spell-remove {
  width: 24px; min-width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--border-color); border-radius: 4px;
  background: transparent; color: var(--text-main); cursor: pointer; font-weight: 700;
}
.smart-spell-remove:hover,
.smart-spell-remove:focus-visible { background: rgba(92, 64, 51, 0.1); }
.smart-spell-add-row { margin-top: 4px; }
.smart-spell-full,
.smart-spell-warning,
.smart-spell-locked-message {
  margin: 4px 0 0;
  padding: 4px 5px;
  border-radius: 4px;
  font-size: 7.5px;
  text-align: center;
}
.smart-spell-full { opacity: 0.72; background: rgba(92, 64, 51, 0.07); }
.smart-spell-warning { border: 1px dashed var(--border-color); }
.smart-spell-locked-message { opacity: 0.72; }

.manual-spell-tier { flex: 1; min-height: 0; }
.manual-spell-tier textarea {
  width: 100%; min-height: 72px; height: 100%; resize: none; font-size: 9px;
}
.manual-spell-locked { min-height: 42px; display: flex; flex-direction: column; }
.spell-manual-note { padding: 5px; font-size: 8px; line-height: 1.35; }
.spell-source-notes {
  width: 100%; min-height: 100px; flex: 1; resize: none; font-size: 9px;
}

@media screen and (max-width: 900px) {
  .spell-source-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spell-progress-row { grid-template-columns: 1fr; }
  .smart-spell-grid { grid-template-columns: 1fr; }
  .dynamic-spell-page { height: auto; max-height: none; }
}

@media print {
  #spellcasting-pages { display: contents !important; }
  .smart-spell-remove,
  .smart-spell-add-row,
  .spell-manual-note,
  .smart-spell-warning { display: none !important; }
  .smart-spell-row { grid-template-columns: minmax(0, 1fr) auto !important; }
  .smart-spell-select { border-color: transparent !important; background: transparent !important; }
}


/* ==========================================================
   SPELLCASTING BUILD 2 - ALL 2024 SRD CASTER PROFILES
   ========================================================== */

.spell-slot-stack {
  display: grid;
  gap: 4px;
}

.secondary-slot-line {
  font-size: 7.75px;
  opacity: 0.78;
}

.always-prepared-box,
.spell-rule-note {
  padding: 5px 7px;
  border: 1px dashed var(--border-color);
  border-radius: 4px;
  font-size: 8px;
  line-height: 1.3;
}

.always-prepared-title {
  margin-bottom: 4px;
  font-family: "Cinzel", serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.35px;
  text-transform: uppercase;
}

.always-prepared-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.always-prepared-chip {
  padding: 2px 5px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 7.5px;
  white-space: nowrap;
}

.arcanum-tier .smart-spell-select {
  margin-top: 2px;
}

@media print {
  .spell-rule-note,
  .smart-spell-warning,
  .smart-spell-full,
  .smart-spell-locked-message {
    font-size: 7px;
  }

  body.printing-blank #spellcasting-pages {
    display: none !important;
  }

  body.printing-blank .spellcasting-summary-box {
    display: none !important;
  }
}


/* ==========================================================
   SPELLCASTING BUILD 3 - SUBCLASSES, 2014, KNOWLEDGE/CODEX
   ========================================================== */

.spell-row-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  min-width: max-content;
}

.spell-info-button,
.spell-codex-link,
.always-prepared-codex {
  min-height: 24px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 7.5px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.spell-info-button {
  width: 24px;
  padding: 0;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
}

.spell-codex-link:hover,
.spell-info-button:hover,
.always-prepared-codex:hover,
.spell-codex-link:focus-visible,
.spell-info-button:focus-visible,
.always-prepared-codex:focus-visible {
  background: rgba(92,64,51,0.10);
}

.always-prepared-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.always-prepared-spell {
  text-decoration: underline dotted rgba(92,64,51,0.48);
  text-underline-offset: 2px;
  cursor: help;
}

.always-prepared-codex {
  min-height: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0 3px;
  border-radius: 50%;
  font-size: 7px;
}

.subclass-magic-box {
  padding: 6px 7px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: rgba(92,64,51,0.045);
  font-size: 8px;
}

.subclass-magic-heading {
  margin-bottom: 4px;
  font-family: "Cinzel", serif;
  font-size: 8.5px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.subclass-choice-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  gap: 7px;
  align-items: center;
}

.subclass-choice-select {
  height: 25px;
  min-width: 0;
  font-size: 8px;
}

.subclass-magic-note {
  margin-top: 4px;
  font-size: 7.5px;
  line-height: 1.3;
  opacity: 0.78;
}

.subclass-bonus-tier {
  background: rgba(92,64,51,0.025);
}

@media screen and (max-width: 900px) {
  .spell-row-tools {
    flex-wrap: wrap;
  }

  .subclass-choice-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  .spell-info-button,
  .spell-codex-link,
  .always-prepared-codex,
  .subclass-magic-note {
    display: none !important;
  }

  .spell-row-tools {
    display: none !important;
  }
}
