/* Panels, dialogue and the parchment UI. Loaded after styles.css. */

/* ----------------------------------------------------------------- dialogue */

.dialogue-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 clamp(12px, 3vw, 32px) clamp(18px, 5vh, 52px);
  background: linear-gradient(180deg, transparent 30%, rgba(5, 3, 13, 0.55) 78%, rgba(5, 3, 13, 0.8));
  pointer-events: none;
}

.dialogue-card {
  pointer-events: auto;
  position: relative;
  width: min(780px, 100%);
  padding: clamp(18px, 3vw, 30px);
  border-radius: 22px;
  border: 1px solid rgba(242, 206, 123, 0.55);
  background:
    radial-gradient(ellipse at 12% 0%, rgba(169, 155, 255, 0.16), transparent 55%),
    linear-gradient(165deg, rgba(31, 21, 56, 0.98), rgba(12, 8, 27, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62), inset 0 0 45px rgba(110, 84, 181, 0.16);
  animation: dialogue-in 280ms ease both;
}

.dialogue-ornament {
  position: absolute;
  top: -16px;
  left: 50%;
  width: 32px;
  height: 32px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(242, 206, 123, 0.55);
  background: #1a1134;
  color: var(--gold);
  font-size: 0.8rem;
  box-shadow: 0 0 20px rgba(242, 206, 123, 0.25);
}

.dialogue-speaker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.dialogue-face {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(242, 206, 123, 0.45);
  background: rgba(242, 206, 123, 0.08);
  font-size: 1rem;
}

.dialogue-text {
  margin: 12px 0 16px;
  font-family: var(--display);
  font-size: clamp(1.08rem, 2.2vw, 1.35rem);
  line-height: 1.6;
  color: #f5ecd9;
  text-wrap: pretty;
}

.dialogue-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dialogue-dots {
  display: flex;
  gap: 5px;
}

.dialogue-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(242, 206, 123, 0.24);
}

.dialogue-dots span.active {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(242, 206, 123, 0.7);
}

/* ------------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 30px);
  background: rgba(5, 3, 13, 0.72);
  backdrop-filter: blur(7px);
  animation: veil-in 180ms ease both;
}

.magic-panel {
  position: relative;
  width: min(940px, 100%);
  max-height: min(90vh, 940px);
  overflow-y: auto;
  padding: clamp(18px, 3.4vw, 38px);
  border-radius: 26px;
  border: 2px solid #c9a55a;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% -10%, rgba(255, 255, 255, 0.6), transparent 55%),
    radial-gradient(ellipse at 100% 110%, rgba(168, 122, 47, 0.18), transparent 55%),
    linear-gradient(158deg, #f9edd3 0%, #efdfbe 55%, #e6d0a8 100%);
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.62),
    inset 0 0 0 6px rgba(255, 255, 255, 0.22),
    inset 0 0 60px rgba(168, 122, 47, 0.12);
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 28, 58, 0.3) transparent;
  animation: panel-in 260ms cubic-bezier(0.18, 0.9, 0.24, 1) both;
}

.magic-panel::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(168, 122, 47, 0.25);
  border-radius: 18px;
  pointer-events: none;
}

.magic-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.panel-kicker {
  color: #8a632b;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.66rem;
  font-weight: 800;
  margin-bottom: 5px;
}

.magic-panel-head h2 {
  font-family: var(--display);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 500;
  line-height: 1;
  color: #2b1c3d;
  letter-spacing: 0.01em;
}

.panel-close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(42, 28, 58, 0.25);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  transition: background 150ms ease, transform 150ms ease;
}

.panel-close:hover {
  background: #fff8e5;
  transform: rotate(8deg) scale(1.04);
}

.panel-lede {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.6;
  max-width: 68ch;
}

.panel-note {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px dashed rgba(138, 99, 43, 0.45);
  background: rgba(255, 255, 255, 0.25);
  color: #59452e;
  font-size: 0.82rem;
  line-height: 1.6;
}

.panel-foot {
  margin-top: 18px;
  color: rgba(93, 74, 114, 0.8);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------- quests */

.quest-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 20px;
}

.quest-scroll {
  position: relative;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(138, 99, 43, 0.3);
  border-left: 4px solid #c9a55a;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.14));
  box-shadow: 0 6px 18px rgba(90, 62, 20, 0.08);
}

.quest-scroll.claimed {
  border-left-color: #6c9b63;
  background: linear-gradient(180deg, rgba(143, 224, 168, 0.18), rgba(255, 255, 255, 0.14));
}

.quest-scroll-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.quest-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(42, 28, 58, 0.07);
  font-size: 1.1rem;
}

.quest-scroll-head > div {
  flex: 1;
  min-width: 0;
}

.quest-scroll h3 {
  font-family: var(--display);
  font-size: 1.22rem;
  font-weight: 600;
  color: #2b1c3d;
}

.quest-giver {
  margin-top: 2px;
  color: #8a632b;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.quest-stamp {
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid #5f8a58;
  border-radius: 4px;
  color: #4e7548;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(2deg);
}

.quest-summary {
  margin-top: 9px;
  color: #5b4968;
  font-size: 0.86rem;
  line-height: 1.55;
}

.quest-objective {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.78rem;
  color: #4d3c5f;
}

.quest-objective strong {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: #2b1c3d;
}

.quest-track {
  flex-basis: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(42, 28, 58, 0.12);
  overflow: hidden;
}

.quest-track > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #c9a55a, #e9c878);
  transition: width 400ms ease;
}

.claimed .quest-track > span {
  background: linear-gradient(90deg, #6c9b63, #9ed08f);
}

.quest-reward {
  margin-top: 10px;
  color: #8a632b;
  font-size: 0.79rem;
  font-weight: 700;
}

.quest-reward span {
  margin-right: 4px;
}

.quest-next {
  margin-top: 16px;
  padding: 12px 15px;
  border-radius: 12px;
  background: rgba(42, 28, 58, 0.08);
  color: #4b3a5e;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- spellbook */

.spell-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.spell-card {
  display: flex;
  gap: 13px;
  padding: 15px;
  border-radius: 14px;
  border: 1px solid rgba(138, 99, 43, 0.32);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.16));
}

.spell-card.locked {
  opacity: 0.66;
  border-style: dashed;
  filter: saturate(0.6);
}

.spell-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(138, 99, 43, 0.4);
  background: radial-gradient(circle at 35% 25%, #fff8e6, #e7cf9f);
  color: #8a632b;
  font-size: 1.3rem;
}

.spell-copy {
  flex: 1;
  min-width: 0;
}

.spell-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spell-title-row h3 {
  font-family: var(--display);
  font-size: 1.25rem;
  color: #2b1c3d;
}

.spell-key {
  margin-left: auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1px solid rgba(42, 28, 58, 0.2);
  color: #6b587e;
  font-size: 0.66rem;
  font-weight: 700;
}

.spell-copy p {
  margin-top: 5px;
  color: #5b4968;
  font-size: 0.81rem;
  line-height: 1.45;
}

.spell-effect {
  color: #8a632b !important;
  font-weight: 700;
}

.spell-copy .small-button {
  margin-top: 10px;
}

.spell-locked-note {
  font-style: italic;
  color: #7b688d !important;
}

/* ---------------------------------------------------------------------- map */

.map-canvas {
  position: relative;
  width: 100%;
  height: clamp(340px, 50vh, 470px);
  margin-top: 18px;
  border-radius: 18px;
  border: 1px solid rgba(138, 99, 43, 0.3);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(169, 155, 255, 0.16), transparent 60%),
    repeating-linear-gradient(0deg, rgba(138, 99, 43, 0.05) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(138, 99, 43, 0.05) 0 1px, transparent 1px 28px),
    rgba(255, 252, 241, 0.4);
  overflow: hidden;
}

.map-canvas::before {
  content: '';
  position: absolute;
  inset: 7%;
  border: 1px dashed rgba(138, 99, 43, 0.25);
  border-radius: 12px;
  pointer-events: none;
}

.map-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-links line {
  stroke: rgba(138, 99, 43, 0.42);
  stroke-width: 0.7;
  stroke-dasharray: 1.6 1.4;
  vector-effect: non-scaling-stroke;
}

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(104px, 18vw, 150px);
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid var(--room-accent);
  background: linear-gradient(170deg, rgba(255, 253, 245, 0.94), rgba(244, 232, 207, 0.9));
  box-shadow: 0 8px 20px rgba(90, 62, 20, 0.14), inset 0 0 22px color-mix(in srgb, var(--room-accent) 16%, transparent);
  color: #33243f;
  text-align: center;
}

.map-node.sealed {
  border-style: dashed;
  border-color: rgba(93, 74, 114, 0.45);
  color: #6d5d7a;
  filter: grayscale(0.4);
  opacity: 0.8;
}

.map-node.here {
  box-shadow: 0 0 0 2px var(--room-accent), 0 12px 28px rgba(90, 62, 20, 0.2), inset 0 0 26px color-mix(in srgb, var(--room-accent) 24%, transparent);
}

.map-node-icon {
  font-size: 1.3rem;
  color: var(--room-accent);
  line-height: 1;
}

.map-node strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
}

.map-node-status {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7b688d;
}

.map-you {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--gold);
  font-size: 0.72rem;
  box-shadow: 0 0 0 3px rgba(255, 250, 235, 0.9);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  color: #5d4a6e;
  font-size: 0.72rem;
}

.map-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #8a632b;
}

.legend-dot.sealed {
  border-style: dashed;
  background: transparent;
}

.legend-dot.here {
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(242, 206, 123, 0.35);
}

/* ---------------------------------------------------------------- inventory */

.pet-card {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 20px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(138, 99, 43, 0.32);
  background:
    radial-gradient(circle at 12% 30%, rgba(169, 155, 255, 0.28), transparent 40%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18));
}

.pet-portrait {
  position: relative;
  flex: 0 0 auto;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(138, 99, 43, 0.35);
  background: radial-gradient(circle at 40% 30%, #fff8e8, #dfc79a);
}

.pet-owl {
  font-size: 3.2rem;
  filter: drop-shadow(0 4px 6px rgba(42, 28, 58, 0.25));
}

.pet-aura {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px dashed rgba(242, 206, 123, 0.7);
  animation: slow-spin 26s linear infinite;
}

.pet-copy h3 {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  color: #2b1c3d;
}

.pet-copy h3 span {
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #8a632b;
}

.pet-copy p {
  margin-top: 5px;
  color: #5b4968;
  font-size: 0.86rem;
  line-height: 1.5;
}

.pet-note {
  font-style: italic;
  color: #7b688d !important;
}

.section-title {
  margin-top: 24px;
  margin-bottom: 10px;
  font-family: var(--display);
  font-size: 1.3rem;
  color: #3a2a4e;
  border-bottom: 1px solid rgba(138, 99, 43, 0.25);
  padding-bottom: 6px;
}

.cosmetic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cosmetic-card {
  display: flex;
  gap: 11px;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid rgba(138, 99, 43, 0.28);
  background: rgba(255, 255, 255, 0.3);
}

.cosmetic-card.locked {
  opacity: 0.6;
  border-style: dashed;
}

.cosmetic-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(138, 99, 43, 0.3);
  color: #8a632b;
  font-size: 1.1rem;
}

.cosmetic-card h4 {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  color: #2b1c3d;
}

.cosmetic-card p {
  margin-top: 3px;
  color: #5b4968;
  font-size: 0.78rem;
  line-height: 1.45;
}

.cosmetic-card .small-button {
  margin-top: 8px;
  min-height: 36px;
  font-size: 0.78rem;
}

.locked-line {
  font-style: italic;
  color: #8a7a99 !important;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.badge {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed rgba(92, 74, 114, 0.35);
  background: rgba(255, 255, 255, 0.18);
  color: #6d5d7a;
}

.badge.earned {
  border-style: solid;
  border-color: rgba(138, 99, 43, 0.5);
  background: linear-gradient(160deg, rgba(255, 246, 220, 0.9), rgba(245, 229, 195, 0.7));
  color: #3a2a4e;
  box-shadow: 0 5px 14px rgba(138, 99, 43, 0.12);
}

.badge-icon {
  color: #b28a46;
  font-size: 1rem;
}

.badge strong {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
}

.badge span:last-child {
  font-size: 0.7rem;
  line-height: 1.4;
  opacity: 0.85;
}

/* ----------------------------------------------------------------- settings */

.settings-block {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(138, 99, 43, 0.25);
  background: rgba(255, 255, 255, 0.24);
}

.settings-block h3 {
  font-family: var(--display);
  font-size: 1.15rem;
  color: #3a2a4e;
  margin-bottom: 10px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.84rem;
  color: #4d3c5f;
  margin-bottom: 12px;
}

.range-row input[type='range'] {
  flex: 1;
  accent-color: #a87a2f;
  height: 28px;
}

.range-row output {
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #8a632b;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  border: 1px solid rgba(42, 28, 58, 0.22);
  background: rgba(255, 255, 255, 0.4);
  color: #4d3c5f;
  font-size: 0.82rem;
  font-weight: 600;
}

.toggle-track {
  position: relative;
  width: 34px;
  height: 22px;
  border-radius: 999px;
  background: rgba(42, 28, 58, 0.2);
  transition: background 150ms ease;
}

.toggle-track > span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff8e6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 150ms ease;
}

.toggle.on .toggle-track {
  background: #8a632b;
}

.toggle.on .toggle-track > span {
  transform: translateX(12px);
}

.settings-hint {
  margin-top: 10px;
  color: #5b4968;
  font-size: 0.78rem;
  line-height: 1.55;
}

.settings-hint.small {
  font-size: 0.7rem;
  opacity: 0.8;
}

.controls-list {
  margin: 0;
  padding-left: 18px;
  color: #4d3c5f;
  font-size: 0.82rem;
  line-height: 2;
}

.controls-list kbd {
  margin-right: 3px;
}

.save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

/* ------------------------------------------------------------------- motion */

@keyframes dialogue-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes veil-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slow-spin {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .dialogue-backdrop {
    padding-bottom: 12px;
  }

  .dialogue-card {
    border-radius: 18px;
    padding: 18px 16px;
  }

  .magic-panel {
    border-radius: 20px;
    padding: 20px 16px;
  }

  .magic-panel::before {
    inset: 8px;
  }

  .spell-grid,
  .cosmetic-grid,
  .badge-grid {
    grid-template-columns: 1fr;
  }

  .pet-card {
    flex-direction: column;
    text-align: center;
  }

  .quest-scroll {
    padding: 13px;
  }

  .map-canvas {
    height: 390px;
  }

  .map-node {
    width: 92px;
    min-height: 80px;
    padding: 8px 4px;
  }

  .map-node strong {
    font-size: 0.85rem;
  }

  .map-node-status {
    font-size: 0.55rem;
  }

  .map-links line {
    stroke-width: 1;
  }
}

@media (max-width: 480px) {
  .magic-panel-head h2 {
    font-size: 1.7rem;
  }

  .panel-lede {
    font-size: 0.85rem;
  }

  .dialogue-text {
    font-size: 1.05rem;
  }

  .map-canvas {
    height: 340px;
  }

  .map-node {
    width: 80px;
    min-height: 72px;
  }

  .map-node-icon {
    font-size: 1.05rem;
  }

  .map-node strong {
    font-size: 0.78rem;
  }
}
