/* Self-contained Spellbook + Quill guide UI (docs/SPELLBOOK.md).
   HUD redesign workers: leave this file alone. */

.spellbook-panel {
  position: fixed;
  inset: 6% 8%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #1a2238 0%, #121828 55%, #0e1420 100%);
  color: #f3ecd8;
  border: 1px solid #3a4a6a;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  font: 500 0.95rem/1.4 "Alegreya Sans", sans-serif;
  overflow: hidden;
}
.spellbook-panel[hidden] { display: none !important; }

.spellbook-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid #2e3a55;
  background: rgba(20, 28, 48, 0.9);
}
.spellbook-head h2 {
  margin: 0;
  flex: 1;
  font: 700 1.35rem/1.2 Cinzel, serif;
  letter-spacing: 0.02em;
}
.spellbook-head .gate {
  font-size: 0.85rem;
  opacity: 0.85;
  color: #c9d6f0;
}
.spellbook-head .gate.is-open { color: #b8e0c8; }
.spellbook-close {
  appearance: none;
  border: 1px solid #5a6a88;
  background: transparent;
  color: inherit;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font: inherit;
}

.spellbook-body {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 1.1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
  align-content: start;
}

.spellbook-card {
  border: 1px solid #3a4a6a;
  background: rgba(28, 36, 56, 0.85);
  padding: 0.7rem 0.8rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 8.5rem;
}
.spellbook-card.is-locked {
  opacity: 0.55;
  filter: saturate(0.7);
}
.spellbook-card .row1 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
}
.spellbook-card .row1 b {
  font: 700 1.05rem/1.2 Cinzel, serif;
  flex: 1;
}
.spellbook-card .chip {
  font-size: 0.72rem;
  padding: 0.12rem 0.4rem;
  border: 1px solid #4a5a78;
  background: rgba(0, 0, 0, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.spellbook-card .chip.el-fire { border-color: #c45a30; color: #f0a070; }
.spellbook-card .chip.el-water { border-color: #3a7aaa; color: #8ec8e8; }
.spellbook-card .chip.el-earth { border-color: #7a6a40; color: #d0b878; }
.spellbook-card .chip.el-air { border-color: #5a8a9a; color: #b0d8e0; }
.spellbook-card .chip.el-light { border-color: #b0a060; color: #f0e8b0; }
.spellbook-card .chip.el-shadow { border-color: #5a4a70; color: #c0b0d8; }
.spellbook-card .chip.el-mind { border-color: #8a4a70; color: #e0a0c0; }
.spellbook-card .meta { opacity: 0.8; font-size: 0.85rem; }
.spellbook-card .role { opacity: 0.9; font-size: 0.88rem; }
.spellbook-card .stars {
  letter-spacing: 0.08em;
  color: #e8c86a;
  font-size: 0.95rem;
}
.spellbook-card .stars .dim { color: #4a5568; }
.spellbook-card button.slot-btn {
  margin-top: auto;
  appearance: none;
  border: 1px solid #6a7a98;
  background: #243048;
  color: inherit;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font: inherit;
}
.spellbook-card button.slot-btn:hover { background: #2e3c58; }

.guide-toast {
  position: fixed;
  top: 10%;
  right: 1.25rem;
  z-index: 36;
  max-width: min(22rem, 42vw);
  padding: 0.75rem 1rem 0.9rem;
  background: linear-gradient(180deg, #f4e8d0, #e4d0a8);
  color: #2a1e12;
  border: 1px solid #8a6a40;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  font: 500 0.95rem/1.35 "Alegreya Sans", sans-serif;
  pointer-events: auto;
}
.guide-toast[hidden] { display: none !important; }
.guide-toast b {
  display: block;
  margin-bottom: 0.35rem;
  font: 700 0.9rem Cinzel, serif;
}
.guide-toast p { margin: 0 0 0.35rem; }
.guide-toast p:last-of-type { margin-bottom: 0.5rem; }
.guide-skip {
  appearance: none;
  border: none;
  background: transparent;
  color: #6a5030;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0;
}

.guide-portrait {
  position: fixed;
  left: 1rem;
  bottom: 18%;
  z-index: 36;
  width: 5.5rem;
  text-align: center;
  pointer-events: none;
}
.guide-portrait[hidden] { display: none !important; }
.guide-portrait img {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  image-rendering: pixelated;
  border: 2px solid #c9a24a;
  background: #1a2238;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.guide-portrait-name {
  margin-top: 0.25rem;
  font: 700 0.75rem/1.2 Cinzel, serif;
  color: #f3ecd8;
  text-shadow: 0 1px 3px #000;
}

/* PM QA fix: the hotbar button overflowed into the next card — size rows to content, keep the button in flow */
.spellbook-body { grid-auto-rows: max-content; }
.spellbook-card { height: auto; overflow: visible; }
.spellbook-card > * { flex: none; }
.spellbook-card button.slot-btn { position: static; align-self: flex-start; margin-top: 0.4rem; }
