/* CSS Variables Strategy for Manual Toggle */
:root {
    /* Light Theme Defaults */
    --primary-color: #4298B4;
    --agree-color: #33a474;
    --disagree-color: #88619a;
    --neutral-color: #d1d5db;
    --text-color: #333333;
    --bg-color: #f7f9fa;
    --card-bg: #ffffff;
    --transition-speed: 0.3s;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --border-color: #eeeeee;
}

/* Dark Theme Class */
body.dark-mode {
    --text-color: #eeeeee;
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --neutral-color: #4b5563;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --border-color: #2a2a40;
}

/* Enneagram Images Adjustments */
.ennea-list-img {
    width: 100px;
    height: auto;
    margin: 0 auto 10px;
    display: block;
    mix-blend-mode: multiply;
    /* Default for Light Mode (Black lines) */
}

body.dark-mode .ennea-list-img {
    filter: invert(1);
    mix-blend-mode: screen;
    /* Dark Mode (White lines) */
}

.detail-hero .ennea-detail-img {
    filter: none;
    /* Remove drop-shadow and invert */
    mix-blend-mode: multiply;
    /* White becomes transparent, Black stays Black */
}

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

body {
    font-family: 'Open Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background var(--transition-speed), color var(--transition-speed);
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.main-header {
    background: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background var(--transition-speed);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.7;
    cursor: pointer;
    padding: 5px 10px;
    transition: all 0.2s;
}

.nav-btn.active,
.nav-btn:hover {
    color: var(--primary-color);
    opacity: 1;
}


.icon-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: var(--neutral-color);
}

/* Views */
.view {
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Landing */
.hero {
    text-align: center;
    padding: 2rem 0;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-family: 'Lora', serif;
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    opacity: 0.8;
}

.test-selection-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.test-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    width: 300px;
    box-shadow: 0 4px 6px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: transform 0.3s, box-shadow 0.3s, background var(--transition-speed);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.test-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px var(--shadow-color);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.enneagram-icon {
    color: var(--primary-color);
}

.mbti-icon {
    color: #88619a;
}

.test-card h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.test-card p {
    margin-bottom: 1.5rem;
    flex-grow: 1;
    opacity: 0.8;
}

.card-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Buttons */
.btn-primary {
    background-color: var(--disagree-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary:hover {
    background-color: #704e82;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--neutral-color);
    color: var(--text-color);
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-secondary:hover {
    opacity: 0.9;
}

/* Questions */
.test-header {
    text-align: center;
    margin-bottom: 3rem;
}

.progress-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar-bg {
    flex: 1;
    height: 8px;
    background: var(--neutral-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--disagree-color);
    transition: width 0.3s ease;
}

.question-card {
    background: var(--card-bg);
    padding: 2rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    animation: fadeIn 0.5s ease;
    transition: background var(--transition-speed);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-text {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.options-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.option-label {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    display: none;
}

@media(min-width: 768px) {
    .option-label {
        display: block;
    }
}

.agree-label {
    color: var(--agree-color);
}

.disagree-label {
    color: var(--disagree-color);
}

.radio-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.radio-option {
    position: relative;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid;
    background: transparent;
    transition: all 0.2s;
}

.size-3 {
    width: 45px;
    height: 45px;
}

.size-2 {
    width: 35px;
    height: 35px;
}

.size-1 {
    width: 28px;
    height: 28px;
}

.size-0 {
    width: 22px;
    height: 22px;
    border-color: var(--neutral-color);
}

.agree.size-3,
.agree.size-2,
.agree.size-1 {
    border-color: var(--agree-color);
}

.disagree.size-3,
.disagree.size-2,
.disagree.size-1 {
    border-color: var(--disagree-color);
}

.agree:hover {
    background-color: rgba(51, 164, 116, 0.2);
}

.disagree:hover {
    background-color: rgba(136, 97, 154, 0.2);
}

.size-0:hover {
    background-color: var(--neutral-color);
}

.radio-option.selected.agree {
    background-color: var(--agree-color);
}

.radio-option.selected.disagree {
    background-color: var(--disagree-color);
}

.radio-option.selected.size-0 {
    background-color: #9ca3af;
    border-color: #9ca3af;
}

.test-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 3rem;
    padding-bottom: 3rem;
}

/* Results */
.results-container {
    text-align: center;
}

.results-visualization {
    max-width: 500px;
    margin: 0 auto;
}

#detailed-scores {
    margin-top: 3rem;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.score-row {
    margin-bottom: 1rem;
}

.score-label {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.score-bar-bg {
    background: var(--neutral-color);
    height: 10px;
    border-radius: 5px;
    margin-top: 5px;
}

.score-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 5px;
    width: 0;
    transition: width 1s ease-out;
}

/* MBTI Bars */
.mbti-bar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 10px;
}

.mbti-trait {
    width: 15%;
    font-weight: bold;
    text-align: center;
    font-size: 0.9rem;
}

.mbti-bar-container {
    flex: 1;
    height: 12px;
    background: var(--neutral-color);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
}

.mbti-bar-left {
    background-color: var(--agree-color);
    height: 100%;
}

.mbti-bar-right {
    background-color: var(--disagree-color);
    height: 100%;
}

.mbti-mid {
    width: 2px;
    background: var(--card-bg);
}

/* Types View */
.types-header {
    margin-bottom: 2rem;
    text-align: center;
}

.types-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.tab-btn {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.tab-btn.active {
    background: var(--text-color);
    color: var(--bg-color);
    border-color: var(--text-color);
}

.types-grid {
    display: grid;
    gap: 2rem;
}

.type-group h3 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.type-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.type-item {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
    border: 1px solid var(--border-color);
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, background var(--transition-speed);
}

.type-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 10px var(--shadow-color);
    background: var(--bg-color);
}

.type-item img {
    width: 80px;
    height: auto;
    margin-bottom: 10px;
}

.type-item h4 {
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 700;
}

.type-item span {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.85rem;
    display: block;
    margin-bottom: 8px;
}

.type-desc {
    font-size: 0.8rem;
    opacity: 0.6;
    line-height: 1.4;
}

/* --- Mobile Responsive Rules --- */
@media (max-width: 768px) {

    /* Header & Nav */
    .main-header {
        padding: 0.8rem 1rem;
    }

    .header-container {
        flex-direction: column;
        gap: 10px;
    }

    .nav-container {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Hero */
    .hero h1 {
        font-size: 2rem;
        padding: 0 10px;
    }

    .subtitle {
        font-size: 1rem;
        padding: 0 15px;
    }

    .test-card {
        width: 100%;
        margin: 0 20px;
        max-width: 350px;
    }

    /* Question Interface */
    .question-card {
        padding: 1.5rem 10px;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .options-container {
        flex-direction: column;
        gap: 10px;
        position: relative;
        padding-top: 25px;
        /* Space for labels */
    }

    .option-label {
        display: block !important;
        /* Force show */
        position: absolute;
        top: 0;
        font-size: 0.8rem;
    }

    .agree-label {
        left: 10px;
    }

    .disagree-label {
        right: 10px;
    }

    .radio-container {
        gap: 8px;
        /* Reduce gap */
    }

    /* Resize circles */
    .size-3 {
        width: 35px;
        height: 35px;
    }

    .size-2 {
        width: 28px;
        height: 28px;
    }

    .size-1 {
        width: 22px;
        height: 22px;
    }

    .size-0 {
        width: 18px;
        height: 18px;
    }

    /* Results */
    .results-container {
        padding: 0 10px;
    }

    #result-type-title {
        font-size: 2.5rem !important;
    }

    /* MBTI Bars Stacked */
    .mbti-bar-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "labelL labelR"
            "bar bar";
        gap: 5px;
        margin-bottom: 1.5rem;
    }

    .mbti-trait {
        width: auto;
        font-size: 0.85rem;
    }

    .mbti-trait:first-child {
        grid-area: labelL;
        text-align: left;
    }

    .mbti-trait:last-child {
        grid-area: labelR;
        text-align: right;
    }

    .mbti-bar-container {
        grid-area: bar;
        width: 100%;
    }

    /* Types Grid */
    .type-list {
        grid-template-columns: 1fr;
        /* Single column */
    }
}

/* --- Detailed View Styles (Migrated) --- */

/* Hero Banner */
.detail-hero {
    border-radius: 20px;
    padding: 3rem;
    color: white;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.detail-hero h1 {
    font-family: 'Lora', serif;
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

.detail-hero h2 {
    font-size: 1.5rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    font-weight: 400;
}

.detail-hero img {
    height: 250px;
    margin-top: 2rem;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

/* Content Sections */
.content-section {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
    text-align: left;
}

.content-section h3 {
    font-family: 'Lora', serif;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    position: relative;
}

.content-section p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.list-box {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 10px;
    margin-top: 1rem;
}

.list-box ul {
    list-style: none;
    padding: 0;
}

.list-box li {
    margin-bottom: 10px;
    padding-left: 25px;
    position: relative;
}

.list-box li::before {
    content: "•";
    color: var(--primary-color);
    font-size: 2rem;
    position: absolute;
    left: 0;
    top: -10px;
}

/* Group Colors */
.bg-analysts {
    background: linear-gradient(135deg, #88619a, #684a75);
    --accent: #88619a;
}

.bg-diplomats {
    background: linear-gradient(135deg, #33a474, #267a56);
    --accent: #33a474;
}

.bg-sentinels {
    background: linear-gradient(135deg, #4298B4, #32738a);
    --accent: #4298B4;
}

.bg-explorers {
    background: linear-gradient(135deg, #e4a23b, #c2882e);
    --accent: #e4a23b;
}

.text-analysts {
    color: #88619a;
}

.text-diplomats {
    color: #33a474;
}

.text-sentinels {
    color: #4298B4;
}

.text-explorers {
    color: #e4a23b;
}

/* Detail Nav specific */
.detail-nav {
    margin-bottom: 2rem;
}

.back-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.back-btn:hover {
    transform: translateX(-5px);
    box-shadow: 0 5px 15px var(--shadow-color);
}

/* Mobile Adjustment for Detail Hero */
@media (max-width: 768px) {
    .detail-hero {
        padding: 2rem 1rem;
    }

    .detail-hero h1 {
        font-size: 2.2rem;
        word-break: break-word;
        line-height: 1.2;
    }

    .detail-hero h2 {
        font-size: 1.2rem;
    }

    .detail-hero img {
        height: 180px;
    }

    .content-section {
        padding: 1.5rem;
    }

    .content-section h3 {
        font-size: 1.5rem;
    }
}