/* ============================================================
   STYLES: how the page looks.
   Leo: change these colors and fonts to restyle the whole app!
   ============================================================ */
:root {
  --bg: #1a1424;            /* page background */
  --bg-glow: #3a2458;       /* the purple glow behind everything */
  --text: #f3ead8;          /* main text color */
  --muted: #b9a9cf;         /* softer text */
  --accent: #ff7a3d;        /* the big button */
  --accent-dark: #c4491a;
  --parchment: #f6ecd2;     /* stat block paper */
  --ink: #2b1d14;           /* stat block text */
  --dnd-red: #8a1c1c;       /* stat block headings */
  --title-font: "Cinzel", Georgia, serif;
  --body-font: "Crimson Text", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
  font-family: var(--body-font);
  font-size: 18px;
}

button {
  font: 600 16px var(--body-font);
  padding: 10px 18px;
  border-radius: 10px;
  border: 0;
  background: #4b3870;
  color: var(--text);
  cursor: pointer;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: transparent; border: 1px solid var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 14px 24px;
}
.logo {
  margin: 0;
  font: 800 32px var(--title-font);
  letter-spacing: 1px;
  background: linear-gradient(90deg, #ffb347, #ff5e62, #c86dd7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tier { display: flex; align-items: center; gap: 12px; }
.badge { padding: 4px 12px; border-radius: 999px; background: #2e2342; color: var(--muted); font-size: 15px; }
.badge.leo { background: #2f6b3a; color: #e6ffe9; }
.link-btn { background: none; padding: 4px; color: var(--muted); text-decoration: underline; font-size: 15px; }

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 60px; }

/* ---------- Controls ---------- */
.controls { text-align: center; margin: 24px 0 32px; }
.tone { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; justify-content: center; }
.tone input { width: min(320px, 60vw); accent-color: var(--accent); }
.tone-label { color: var(--muted); }
.summon {
  display: block; margin: 0 auto;
  font: 800 26px var(--title-font);
  padding: 18px 40px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  box-shadow: 0 6px 0 #7a2a0c, 0 10px 30px rgba(255, 122, 61, 0.35);
  border-radius: 16px;
}
.summon:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a2a0c; }
.message { min-height: 1.4em; color: #ffcf8a; }

/* ---------- Loading ---------- */
.loading { text-align: center; color: var(--muted); }
.spinner {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border: 6px solid #3d2f57; border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result ---------- */
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.edit-hint { text-align: center; color: #ffcf8a; margin: 0 0 12px; }
.result-grid { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: start; }
@media (max-width: 820px) { .result-grid { grid-template-columns: 1fr; justify-items: center; } }

/* Editable text glows in edit mode */
.editing [data-field] { outline: 2px dashed rgba(255, 207, 138, 0.7); outline-offset: 2px; border-radius: 3px; cursor: text; }
.editing [data-field]:focus { outline: 2px solid #ffcf8a; background: rgba(255, 207, 138, 0.15); }

/* ---------- D&D stat block ---------- */
.statblock, .backstory {
  background: var(--parchment);
  color: var(--ink);
  padding: 18px 22px;
  border-top: 5px solid var(--dnd-red);
  border-bottom: 5px solid var(--dnd-red);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  margin-bottom: 20px;
  width: 100%;
}
.statblock h2 { font: 800 26px var(--title-font); color: var(--dnd-red); margin: 0; }
.statblock .subtitle { font-style: italic; margin: 0 0 6px; }
.statblock hr { border: 0; height: 3px; background: linear-gradient(90deg, var(--dnd-red), transparent); margin: 8px 0; }
.statblock p { margin: 3px 0; }
.statblock b { color: var(--dnd-red); }
.abilities { display: grid; grid-template-columns: repeat(6, 1fr); text-align: center; color: var(--dnd-red); }
.abilities div > span { display: block; color: var(--ink); }
.statblock h3 { font: 600 20px var(--title-font); color: var(--dnd-red); border-bottom: 1px solid var(--dnd-red); margin: 12px 0 6px; }
.statblock .entry { margin: 6px 0; }
.statblock .entry-name { font-weight: 700; font-style: italic; }
.backstory h2 { font: 600 22px var(--title-font); color: var(--dnd-red); margin: 0 0 8px; }
.backstory-text { white-space: pre-line; line-height: 1.45; }

/* ---------- Passcode dialog ---------- */
dialog { background: #2a2038; color: var(--text); border: 1px solid #4b3870; border-radius: 14px; padding: 24px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { font-family: var(--title-font); margin-top: 0; }
dialog input { width: 100%; font-size: 18px; padding: 10px; border-radius: 8px; border: 1px solid #4b3870; background: #1a1424; color: var(--text); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
