/* ============================================================
   Wizard — visual style.
   Dark midnight palette with gold accents and a subtle starfield.
   Inter for body, Cinzel for headings.
   ============================================================ */

:root {
    --bg-deep:   #0b0a18;
    --bg:        #131229;
    --bg-card:   #1c1b3a;
    --bg-elev:   #25234a;
    --border:    #2e2c5e;
    --text:      #e9e8ff;
    --text-dim:  #b9b6dd;
    --muted:     #7e7ba3;
    --gold:      #e8c373;
    --gold-soft: #b89055;
    --primary:   #8a7bff;
    --primary-2: #b196ff;
    --danger:    #ff6e8a;
    --ok:        #71e0a6;
    --shadow:    0 6px 30px rgba(0, 0, 0, 0.45);
    --radius:    14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
}

body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(138, 123, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at 10% 110%, rgba(232, 195, 115, 0.10), transparent 60%),
        var(--bg-deep);
}

/* Subtle starfield: layered radial-gradient dots, fixed so they don't
   parallax out of view when scrolling. */
.stars {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.6), transparent 50%),
        radial-gradient(1px 1px at 70% 80%, rgba(255, 255, 255, 0.5), transparent 50%),
        radial-gradient(1px 1px at 40% 60%, rgba(255, 255, 255, 0.55), transparent 50%),
        radial-gradient(2px 2px at 85% 20%, rgba(232, 195, 115, 0.4),  transparent 50%),
        radial-gradient(1px 1px at 15% 85%, rgba(255, 255, 255, 0.4),  transparent 50%),
        radial-gradient(1.5px 1.5px at 60% 35%, rgba(177, 150, 255, 0.5), transparent 50%);
    opacity: 0.7;
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { color: var(--gold); }

h1, h2, h3 {
    font-family: 'Cinzel', 'Inter', serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}
h1 { font-size: 2rem; margin: 0 0 0.4em; }
h2 { font-size: 1.4rem; margin: 1.4em 0 0.5em; }
h3 { font-size: 1.05rem; margin: 0 0 0.3em; }

.muted   { color: var(--muted); }
.small   { font-size: 0.85em; }

/* --- Top bar ----------------------------------------------------------- */
.topbar {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 10, 24, 0.65);
    backdrop-filter: blur(8px);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: 'Cinzel', serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gold);
}
.brand:hover { color: var(--gold); }
.brand-glyph {
    font-size: 1.6rem;
    text-shadow: 0 0 14px rgba(232, 195, 115, 0.6);
}
.nav {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    font-size: 0.95rem;
}
.nav a { color: var(--text-dim); }
.nav a:hover { color: var(--gold); }
.nav-user { color: var(--muted); font-size: 0.9rem; }
.cta {
    padding: 6px 14px;
    border: 1px solid var(--gold-soft);
    border-radius: 999px;
    color: var(--gold) !important;
}
.cta:hover { background: rgba(232, 195, 115, 0.1); }
.link-btn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--text-dim);
    cursor: pointer;
    font: inherit;
}
.link-btn:hover { color: var(--gold); }

/* --- Page chrome ------------------------------------------------------- */
.page {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 36px auto 60px;
    padding: 0 28px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    margin-bottom: 1.4rem;
}

.section-title {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 1.6em 0 0.6em;
}

.footer {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

/* --- Flash ------------------------------------------------------------- */
.flash {
    max-width: 1080px;
    margin: 16px auto 0;
    padding: 12px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    position: relative;
    z-index: 2;
}
.flash-ok  { border-color: rgba(113, 224, 166, 0.35); color: var(--ok); }
.flash-err { border-color: rgba(255, 110, 138, 0.35); color: var(--danger); }
.inline-flash { margin: 12px 0; }

/* --- Buttons ----------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #0b0a18;
    box-shadow: 0 0 18px rgba(138, 123, 255, 0.35);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 26px rgba(138, 123, 255, 0.55);
    color: #0b0a18;
}
.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--gold); }
.btn-cast {
    background: linear-gradient(135deg, var(--gold) 0%, #f8d98a 100%);
    color: #0b0a18;
    box-shadow: 0 0 22px rgba(232, 195, 115, 0.45);
}
.btn-cast:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(232, 195, 115, 0.65);
    color: #0b0a18;
}
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(255, 110, 138, 0.45);
}
.btn-danger:hover { background: rgba(255, 110, 138, 0.12); }

.inline { display: inline; }

/* --- Hero / home ------------------------------------------------------- */
.hero {
    padding: 60px 0 40px;
    text-align: center;
}
.hero .title {
    font-size: 3rem;
    line-height: 1.1;
    margin-bottom: 0.4em;
}
.hero .title em {
    color: var(--gold);
    font-style: italic;
}
.hero .lede {
    max-width: 620px;
    margin: 0 auto 1.8em;
    color: var(--text-dim);
    font-size: 1.1rem;
}
.hero-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.schools .school-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 1rem;
}
.school {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    transition: border-color 0.15s, transform 0.15s;
}
.school:hover { border-color: var(--gold-soft); transform: translateY(-2px); }
.school-icon { font-size: 2rem; display: block; margin-bottom: 0.4rem; }
.school h3 { color: var(--gold); margin-bottom: 0.3rem; }
.school p { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

/* --- Forms ------------------------------------------------------------- */
.form-card {
    max-width: 460px;
    margin: 50px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 30px;
    box-shadow: var(--shadow);
}
.form-wide { max-width: 760px; }
.form-card h1 { margin-top: 0; }
.form-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.form-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; color: var(--text-dim); }
.form-card label span { font-weight: 600; color: var(--text); }
.form-card label small { color: var(--muted); font-weight: 400; }
.form-card input[type=text],
.form-card input[type=email],
.form-card input[type=password],
.form-card select,
.form-card textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.97rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-card textarea {
    font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.92rem;
    line-height: 1.5;
    resize: vertical;
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(138, 123, 255, 0.2);
}
.form-card .form-aside {
    margin-top: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 240px; }
.form-row .narrow { flex: 0 0 120px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

code { background: var(--bg-elev); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }

/* --- Spell grid -------------------------------------------------------- */
.spell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.spell-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.spell-card:hover {
    border-color: var(--gold-soft);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.spell-card header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.spell-emoji {
    font-size: 1.6rem;
    line-height: 1;
    text-shadow: 0 0 12px rgba(232, 195, 115, 0.35);
}
.spell-emoji.big { font-size: 2.6rem; }
.spell-name { margin: 0; flex: 1; font-size: 1.05rem; }
.spell-pill {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-elev);
    padding: 3px 9px;
    border-radius: 999px;
    color: var(--text-dim);
}
.spell-desc { color: var(--text-dim); font-size: 0.92rem; margin: 0; flex: 1; }
.spell-card footer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Subtle per-school border accent. Keeps the grid scannable at a glance. */
.spell-cat-divination    { border-left: 3px solid #6fb6ff; }
.spell-cat-transmutation { border-left: 3px solid #71e0a6; }
.spell-cat-conjuration   { border-left: 3px solid #b196ff; }
.spell-cat-illusion      { border-left: 3px solid #ff9bd0; }
.spell-cat-enchantment   { border-left: 3px solid #e8c373; }
.spell-cat-evocation     { border-left: 3px solid #ff8e6a; }

/* --- Cast pages -------------------------------------------------------- */
.cast-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}
.cast-header h1 { margin: 0 0 0.1em; }
.cast-output {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.prompt-peek {
    margin-top: 1.6rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}
.prompt-peek summary { cursor: pointer; color: var(--text-dim); font-size: 0.9rem; }
.prompt-peek pre {
    margin: 12px 0 0;
    white-space: pre-wrap;
    color: var(--text-dim);
    font-size: 0.88rem;
}
.ingredients { margin: 0; }
.ingredients dt { font-weight: 600; color: var(--gold); margin-top: 10px; }
.ingredients dd { margin: 4px 0 0; color: var(--text-dim); }

/* --- History ---------------------------------------------------------- */
.history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.history-link {
    display: grid;
    grid-template-columns: auto 200px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}
.history-link:hover { border-color: var(--gold-soft); color: var(--text); }
.history-meta { display: flex; flex-direction: column; }
.history-meta strong { color: var(--text); }
.history-preview { color: var(--text-dim); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-err { color: var(--danger); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.empty-state { color: var(--muted); padding: 40px 0; text-align: center; }

@media (max-width: 720px) {
    .hero .title { font-size: 2.2rem; }
    .topbar { padding: 14px 18px; }
    .nav { gap: 0.7rem; font-size: 0.9rem; }
    .nav-user { display: none; }
    .page { padding: 0 18px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .history-link { grid-template-columns: auto 1fr; }
    .history-preview { display: none; }
}
