/* ═══════════════════════════════════════════════════════════════
   Adventure Hook Generator — Clean Modern Style
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e1e4e8;
    --text: #1a1a2e;
    --text-muted: #586069;
    --primary: #4a6cf7;
    --primary-hover: #3b5de7;
    --accent: #e8ecff;
    --danger: #e74c3c;
    --success: #27ae60;
    --stat-bg: #fdf6e3;
    --stat-border: #8b4513;
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ═══ HEADER ═══ */
header {
    text-align: center;
    margin-bottom: 28px;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ═══ FIELD GUIDE ═══ */
.guide {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.guide.collapsed .guide-grid {
    display: none;
}

.guide.collapsed .guide-toggle::after {
    content: ' ▼';
}

.guide.collapsed .guide-toggle {
    content: 'Show Guide';
}

.guide h2 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    color: var(--text);
}

.guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.guide-card {
    background: var(--accent);
    border-radius: 6px;
    padding: 14px;
}

.guide-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.guide-card ul {
    list-style: none;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.guide-card li {
    margin-bottom: 4px;
    line-height: 1.4;
}

.guide-card li strong {
    color: var(--text);
}

.guide-toggle {
    display: block;
    margin: 14px auto 0;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
}

/* ═══ FORM ═══ */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.form-section h2 {
    font-size: 1.1rem;
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
}

.field {
    display: flex;
    flex-direction: column;
}

.field.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.required {
    color: var(--danger);
}

input,
select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.12);
}

button[type="submit"] {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

button[type="submit"]:hover {
    background: var(--primary-hover);
}

button[type="submit"]:disabled {
    background: #aab;
    cursor: wait;
}

/* ═══ OUTPUT ═══ */
.output-section {
    margin-top: 28px;
}

.output-section h2 {
    font-size: 1.2rem;
    margin-bottom: 18px;
}

.output-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
}

.output-block h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary);
}

.output-content {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.65;
}

.output-content p {
    margin-bottom: 8px;
}

/* Villain stack (vertical) */
.villain-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.villain-card {
    margin-bottom: 0;
}

/* NPC list */
.npc-list {
    list-style: none;
    font-size: 0.9rem;
}

.npc-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.npc-list li:last-child {
    border-bottom: none;
}

/* ═══ STAT BLOCKS ═══ */
.stat-blocks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.stat-block {
    background: var(--stat-bg);
    border: 2px solid var(--stat-border);
    border-radius: 4px;
    padding: 16px 18px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.stat-header h4 {
    font-size: 1.05rem;
    color: var(--stat-border);
    margin: 0;
}

.cr-badge {
    background: var(--stat-border);
    color: #fff;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.stat-subheader {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-divider {
    height: 2px;
    background: var(--stat-border);
    opacity: 0.3;
    margin: 8px 0;
}

.stat-row {
    margin-bottom: 3px;
}

.stat-row strong {
    color: var(--stat-border);
}

.stat-row.abilities {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    letter-spacing: 0.3px;
    text-align: center;
    padding: 4px 0;
}

.stat-section {
    margin-top: 6px;
    margin-bottom: 6px;
}

.stat-section em {
    font-weight: 600;
    font-style: italic;
}

/* ═══ ERROR ═══ */
.error-banner {
    background: #fef0f0;
    border: 1px solid #f5c6cb;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-top: 16px;
    font-size: 0.9rem;
}

/* ═══ PORTRAIT GENERATION ═══ */
.portrait-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.portrait-btn:hover {
    background: var(--accent);
}

.portrait-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.portrait-container {
    margin-bottom: 12px;
}

.portrait-wrapper {
    width: 100%;
    margin-top: 8px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--stat-border);
}

.character-portrait {
    width: 100%;
    height: auto;
    display: block;
}

.img-loading {
    font-size: 0.85rem;
    color: var(--primary);
    text-align: center;
    padding: 12px;
    background: rgba(74, 108, 247, 0.05);
    border-radius: 4px;
    animation: pulse 1.5s infinite;
}

.img-error {
    font-size: 0.85rem;
    color: var(--danger);
    text-align: center;
    padding: 8px;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* ═══ NPC LIST ═══ */
.npc-list {
    list-style: none;
    padding: 0;
}

.npc-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.npc-item:last-child {
    border-bottom: none;
}

.npc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.npc-row span {
    font-weight: 500;
    color: var(--text-main);
}

/* ═══ ENCOUNTER CONFIGS ═══ */
.encounter-configs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 14px;
}

.encounter-card {
    background: var(--stat-bg);
    border: 1px solid var(--stat-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.encounter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.2);
    padding-bottom: 8px;
}

.encounter-header h4 {
    font-size: 1.05rem;
    color: var(--primary);
    margin: 0;
}

.budget-badge {
    background: var(--accent);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.encounter-roster {
    list-style: none;
    padding: 0;
    margin: 0;
}

.encounter-roster li {
    font-size: 0.95rem;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
}

.encounter-roster li:last-child {
    border-bottom: none;
}

.encounter-roster li strong {
    color: var(--danger);
    margin-right: 6px;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 700px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }

    .villain-grid {
        grid-template-columns: 1fr;
    }
}