/* spell_creator.css
 * Layout for the dedicated /rpg_tools/spell_creator page.
 * Editor styles live in /assets/js/spell_creator/spell-editor.css.
 */

/* Scoped accent — amber/gold preserves Spell Creator's identity.
   Inherits other surface tokens (--bg-secondary, --bg-tertiary, --border-color,
   --text-primary, --text-secondary) from main_style.css. */
.spell-creator-container {
    --accent-color: #ffb84d;
}
html.dark .spell-creator-container {
    --accent-color: #ffc769;
}

.spell-creator-main {
    padding: 2rem 1rem 4rem;
    min-height: calc(100vh - 200px);
}

.spell-creator-container {
    max-width: 1100px;
    margin: 0 auto;
    /* Clear the fixed site header. The site header has two rows (nav +
       auth buttons), totaling ~150px. 6rem (96px) was too tight and let
       the title overlap the auth row. 11rem (176px) gives breathing room. */
    padding-top: 11rem;
}

/* ─── Header ───────────────────────────────────────────── */

.spell-creator-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color, #444);
}

.spell-creator-title-row h1 {
    font-family: 'MedievalSharp', serif;
    font-size: 2.25rem;
    color: var(--accent-color, #ffb84d);
    margin: 0;
}

.spell-creator-subtitle {
    color: var(--text-secondary, #aaa);
    margin: 0.5rem 0 0;
    font-size: 1rem;
    max-width: 600px;
}

.spell-creator-quota {
    background: var(--bg-tertiary, #2c2d33);
    border: 1px solid var(--border-color, #444);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-width: 180px;
    text-align: right;
}

.spell-creator-quota-line {
    color: var(--text-secondary, #aaa);
}

.spell-creator-quota-count {
    color: var(--text-primary, #f0f0f0);
    font-weight: 700;
    font-size: 1.1rem;
}

.spell-creator-quota-warning {
    color: #e8a43d;
    margin-top: 0.25rem;
    font-size: 0.85rem;
}

.spell-creator-quota-upgrade {
    margin-top: 0.5rem;
    display: inline-block;
    color: var(--accent-color, #ffb84d);
    text-decoration: none;
    font-weight: 600;
}

.spell-creator-quota-upgrade:hover {
    text-decoration: underline;
}

.spell-creator-quota-anonymous {
    background: rgba(232, 164, 61, 0.12);
    border-color: rgba(232, 164, 61, 0.4);
    color: #e8a43d;
}

/* ─── Actions ──────────────────────────────────────────── */

.spell-creator-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.spell-creator-actions .btn {
    padding: 0.6rem 1.4rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.spell-creator-actions .btn-primary {
    background: var(--accent-color, #ffb84d);
    color: #1a1a1a;
}

.spell-creator-actions .btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.spell-creator-actions .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.spell-creator-actions .btn-secondary {
    background: var(--bg-tertiary, #2c2d33);
    color: var(--text-primary, #f0f0f0);
    border-color: var(--border-color, #444);
}

.spell-creator-actions .btn-secondary:hover {
    background: #383a42;
}

/* ─── Spell list (card grid) ───────────────────────────── */

.spell-creator-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* When the editor is open, hide the list + the action bar so the form
   is the only focus point. The shell adds .spell-creator-editor-open
   on the body when it mounts the editor and removes it on close. */
body.spell-creator-editor-open .spell-creator-list,
body.spell-creator-editor-open .spell-creator-actions {
    display: none;
}

.spell-creator-loading,
.spell-creator-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary, #aaa);
    font-size: 1rem;
}

.spell-creator-empty h3 {
    color: var(--text-primary, #f0f0f0);
    font-family: 'MedievalSharp', serif;
    margin-bottom: 0.5rem;
}

.spell-creator-card {
    background: var(--bg-secondary, #1e1f24);
    border: 1px solid var(--border-color, #444);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.spell-creator-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.spell-creator-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.spell-creator-card-name {
    font-family: 'MedievalSharp', serif;
    font-size: 1.25rem;
    color: var(--accent-color, #ffb84d);
    margin: 0;
}

.spell-creator-card-level {
    background: var(--bg-tertiary, #2c2d33);
    color: var(--text-primary, #f0f0f0);
    border-radius: 12px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.spell-creator-card-school {
    color: var(--text-secondary, #aaa);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.spell-creator-card-description {
    color: var(--text-primary, #f0f0f0);
    font-size: 0.9rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.spell-creator-card-completeness {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #aaa);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spell-creator-card-completeness-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary, #2c2d33);
    border-radius: 2px;
    overflow: hidden;
}

.spell-creator-card-completeness-fill {
    height: 100%;
    background: #888;
}

.spell-creator-card-completeness-fill.green { background: #4caf50; }
.spell-creator-card-completeness-fill.amber { background: #e8a43d; }
.spell-creator-card-completeness-fill.red { background: #d65a4a; }

.spell-creator-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color, #444);
    padding-top: 0.75rem;
}

.spell-creator-card-actions button {
    flex: 1;
    padding: 0.4rem 0.6rem;
    background: transparent;
    border: 1px solid var(--border-color, #444);
    color: var(--text-primary, #f0f0f0);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}

.spell-creator-card-actions button:hover {
    background: rgba(255, 255, 255, 0.06);
}

.spell-creator-card-actions .btn-edit {
    color: var(--accent-color, #ffb84d);
    border-color: rgba(255, 184, 77, 0.4);
}

.spell-creator-card-actions .btn-delete {
    color: #ff8c7a;
    border-color: rgba(214, 90, 74, 0.4);
}

.spell-creator-card-actions .btn-delete:hover {
    background: rgba(214, 90, 74, 0.15);
}

/* ─── Light mode ───────────────────────────────────────── */

html:not(.dark) body .spell-creator-title-row h1 { color: #b56e1f; }
html:not(.dark) body .spell-creator-card { background: #ffffff; border-color: #d0d0d0; }
html:not(.dark) body .spell-creator-card-name { color: #b56e1f; }
html:not(.dark) body .spell-creator-card-level,
html:not(.dark) body .spell-creator-quota { background: #f0f0f0; border-color: #d0d0d0; }
html:not(.dark) body .spell-creator-card-actions button { background: #f8f8f8; }
html:not(.dark) body .spell-creator-card-actions button:hover { background: #e8e8e8; }
html:not(.dark) body .spell-creator-header { border-bottom-color: #d0d0d0; }

/* ─── Mobile ───────────────────────────────────────────── */

@media (max-width: 600px) {
    .spell-creator-container { padding-top: 9rem; }
    .spell-creator-header { flex-direction: column; }
    .spell-creator-quota { text-align: left; width: 100%; }
    .spell-creator-actions { flex-direction: column; }
    .spell-creator-actions .btn { width: 100%; justify-content: center; }
    .spell-creator-list { grid-template-columns: 1fr; }
}
