/* ============================================================
   Archetype Gallery — styles
   Matches mortgage-info.html CSS variables (--accent etc.)
   ============================================================ */

.archetype-gallery h3 { margin-top: 24px; }

.archetype-disclaimer-top {
    background: var(--info-bg, rgba(99, 102, 241, 0.07));
    color: var(--info-text, #4338ca);
    border-right: 4px solid var(--info-text, #4338ca);
    border-radius: var(--radius-sm, 8px);
    padding: 14px 16px;
    margin: 14px 0 20px;
    font-size: 0.92rem;
    line-height: 1.65;
}

.archetype-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 18px;
}

.archetype-card {
    background: var(--bg-white, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-lg, 14px);
    padding: 22px 24px;
    border-right: 4px solid var(--accent, #10b981);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.archetype-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
}

.archetype-card-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-body, #1e293b);
    line-height: 1.3;
}

.archetype-card-name-en {
    font-weight: 400;
    color: var(--text-muted, #64748b);
    font-size: 0.88rem;
}

.archetype-card-id {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    background: var(--bg-page, #f8fafc);
    padding: 3px 9px;
    border-radius: 999px;
    font-family: 'Menlo', 'Consolas', monospace;
    white-space: nowrap;
    border: 1px solid var(--border, #e2e8f0);
}

.archetype-card-philosophy {
    font-size: 0.95rem;
    color: var(--text-body, #1e293b);
    line-height: 1.65;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--accent-soft, rgba(16, 185, 129, 0.08));
    border-radius: var(--radius-sm, 8px);
    border-right: 3px solid var(--accent, #10b981);
}

/* Mix bar visualization */
.archetype-mix-visual {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    margin: 14px 0 8px;
    border: 1px solid var(--border, #e2e8f0);
}

.archetype-mix-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.82rem;
    transition: filter 0.15s;
}

.archetype-mix-segment:hover { filter: brightness(0.92); }

.archetype-mix-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 14px;
}

.archetype-mix-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.archetype-mix-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Loan input row */
.archetype-loan-input {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0;
    padding: 12px 14px;
    background: var(--bg-page, #f8fafc);
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border, #e2e8f0);
}

.archetype-loan-input label {
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
    font-weight: 600;
}

.archetype-loan-input input {
    padding: 6px 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 130px;
    text-align: right;
    background: var(--bg-white, #ffffff);
}

.archetype-loan-input input:focus {
    outline: 2px solid var(--accent, #10b981);
    outline-offset: 1px;
}

.archetype-pmt-output {
    margin-right: auto;
    text-align: left;
    min-width: 200px;
}

.archetype-pmt-breakdown {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 4px;
}

.archetype-pmt-total {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-body, #1e293b);
}

/* Card sections */
.archetype-card-section { margin-top: 18px; }

.archetype-card-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-body, #1e293b);
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.archetype-card-section h4::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--accent, #10b981);
    border-radius: 2px;
}

.archetype-card-section.gives-up h4::before { background: #ef4444; }
.archetype-card-section.describes h4::before { background: #6366f1; }
.archetype-card-section.stress h4::before { background: #f59e0b; }

.archetype-card-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.archetype-card-section li {
    padding: 6px 18px 6px 0;
    position: relative;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-body, #1e293b);
}

.archetype-card-section li::before {
    content: '•';
    position: absolute;
    right: 0;
    color: var(--accent, #10b981);
    font-weight: 700;
}

.archetype-card-section.gives-up li::before { color: #ef4444; }
.archetype-card-section.describes li::before { color: #6366f1; }

/* Stress table */
.archetype-stress-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 0.85rem;
}

.archetype-stress-table th,
.archetype-stress-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    text-align: right;
}

.archetype-stress-table th {
    background: var(--bg-page, #f8fafc);
    font-weight: 700;
    color: var(--text-muted, #64748b);
    font-size: 0.78rem;
}

.archetype-stress-table td.delta-positive { color: #b91c1c; font-weight: 600; }
.archetype-stress-table td.delta-negative { color: var(--accent-dark, #047857); font-weight: 600; }
.archetype-stress-table tr.baseline { background: var(--accent-soft, rgba(16, 185, 129, 0.08)); }
.archetype-stress-table tr.baseline td { font-weight: 700; }

/* Actions row */
.archetype-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.archetype-btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border, #e2e8f0);
    background: var(--bg-white, #ffffff);
    color: var(--text-body, #1e293b);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.archetype-btn:hover {
    background: var(--bg-page, #f8fafc);
    border-color: var(--text-muted, #64748b);
}

.archetype-btn-primary {
    background: var(--accent, #10b981);
    color: white;
    border-color: var(--accent, #10b981);
}

.archetype-btn-primary:hover {
    background: var(--accent-dark, #047857);
    border-color: var(--accent-dark, #047857);
}

.archetype-btn-primary:focus {
    outline: 2px solid var(--accent-dark, #047857);
    outline-offset: 2px;
}

/* Expandable narrative + sources */
.archetype-expand {
    margin-top: 16px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.archetype-expand-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 0;
    width: 100%;
    text-align: right;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--accent-dark, #047857);
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
}

.archetype-expand-toggle::-webkit-details-marker { display: none; }
.archetype-expand-toggle::marker { content: ''; }

.archetype-expand-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.archetype-expand[open] .archetype-expand-toggle::after {
    transform: rotate(180deg);
}

.archetype-expand-content {
    padding: 12px 0 18px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-body, #1e293b);
}

.archetype-expand-content h1,
.archetype-expand-content h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 18px 0 8px;
    color: var(--text-body, #1e293b);
}

.archetype-expand-content h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 14px 0 6px;
    color: var(--text-body, #1e293b);
}

.archetype-expand-content h4 {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 12px 0 6px;
    color: var(--text-muted, #64748b);
}

.archetype-expand-content p { margin: 8px 0; }

.archetype-expand-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.85rem;
}

.archetype-expand-content th,
.archetype-expand-content td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    text-align: right;
}

.archetype-expand-content th {
    background: var(--bg-page, #f8fafc);
    font-weight: 700;
    color: var(--text-muted, #64748b);
}

.archetype-expand-content blockquote {
    border-right: 3px solid var(--accent, #10b981);
    background: var(--accent-soft, rgba(16, 185, 129, 0.08));
    padding: 10px 14px;
    margin: 12px 0;
    color: var(--text-body, #1e293b);
    border-radius: 0 6px 6px 0;
}

.archetype-expand-content ul,
.archetype-expand-content ol {
    margin: 8px 22px;
}

.archetype-expand-content li { margin: 4px 0; }

.archetype-expand-content code {
    background: var(--bg-page, #f8fafc);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 0.85em;
}

.archetype-expand-content strong { font-weight: 700; }

.archetype-expand-content hr {
    border: 0;
    border-top: 1px solid var(--border, #e2e8f0);
    margin: 14px 0;
}

/* Citations */
.archetype-citation-list {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.archetype-citation {
    padding: 10px 12px;
    background: var(--bg-page, #f8fafc);
    border-right: 3px solid var(--info-text, #4338ca);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.85rem;
}

.archetype-citation-title {
    font-weight: 700;
    color: var(--text-body, #1e293b);
    margin-bottom: 4px;
}

.archetype-citation-meta {
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 6px;
}

.archetype-citation-body {
    font-size: 0.82rem;
    color: var(--text-body, #1e293b);
    margin-bottom: 6px;
    line-height: 1.55;
}

.archetype-citation a {
    color: var(--accent-dark, #047857);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
}

.archetype-citation a:hover { text-decoration: underline; }

/* Legal disclaimer at bottom of each card */
.archetype-card-disclaimer {
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--bg-page, #f8fafc);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    line-height: 1.6;
    border-right: 3px solid var(--text-mute2, #94a3b8);
}

/* Loading / error states */
.archetype-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 0.95rem;
}

.archetype-error {
    padding: 16px;
    background: var(--danger-bg, #fee2e2);
    color: var(--danger-text, #991b1b);
    border: 1px solid var(--danger-border, #fecaca);
    border-radius: var(--radius-sm, 8px);
    margin: 14px 0;
    font-size: 0.9rem;
    line-height: 1.55;
}

.archetype-error small {
    display: block;
    margin-top: 6px;
    opacity: 0.85;
    font-size: 0.82rem;
}

/* Toast on "load to builder" */
.archetype-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-dark, #047857);
    color: white;
    padding: 14px 22px;
    border-radius: var(--radius, 10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.92rem;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.archetype-toast.show { opacity: 1; }

/* Mobile responsive */
@media (max-width: 600px) {
    .archetype-card { padding: 18px 16px; }
    .archetype-card-header { flex-direction: column; gap: 8px; }
    .archetype-card-id { align-self: flex-start; }
    .archetype-loan-input { flex-direction: column; align-items: stretch; }
    .archetype-pmt-output { margin-right: 0; text-align: right; }
    .archetype-mix-legend { gap: 10px; }
}
