/* Simulator Layout */
.simulator-page {
    padding-top: 0; /* Reset standard padding */
    min-height: 100vh;
    background-color: var(--bg);
    color: var(--fg);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Subtle ambient background to reduce "flat black" feel */
.simulator-page::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(700px circle at 12% 18%, var(--accent-light), transparent 55%),
        radial-gradient(800px circle at 88% 0%, rgba(255, 255, 255, 0.04), transparent 60%),
        radial-gradient(700px circle at 90% 85%, rgba(255, 255, 255, 0.02), transparent 55%);
    opacity: 0.9;
    transform: translate3d(0, 0, 0);
    animation: ambientShift 18s ease-in-out infinite;
    z-index: 0;
}

@keyframes ambientShift {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, -10px, 0); }
}

/* Sticky Dashboard */
.dashboard-wrapper {
    position: sticky;
    top: -1px; /* Slight negative offset to prevent top content from being hidden */
    z-index: 100; /* Above everything when scrolling */
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    box-shadow: var(--shadow-md);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sim-logo {
    font-family: 'Roboto', sans-serif;
    font-weight: 600;
    color: var(--accent);
    font-size: 1.1rem;
}

.dashboard-controls {
    display: flex;
    gap: 1rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.btn-text:hover:not(:disabled) {
    color: var(--fg);
    transform: translateY(-1px);
}

.btn-text:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Dashboard Panes */
.dashboard-panes {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* Flip Card Container */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front {
    position: relative;
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.flip-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: rotateY(180deg);
}

.clickable {
    cursor: pointer;
}

.explanation-content {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.explanation-content h3 {
    font-family: 'Roboto', sans-serif;
    font-size: 1.3rem;
    margin: 0 0 1rem 0;
    color: var(--accent);
}

.explanation-content p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 0.8rem 0;
    color: rgba(255, 255, 255, 0.85);
}

.explanation-content ul {
    margin: 0 0 1rem 0;
    padding-left: 1.2rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.explanation-content li {
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
}

.explanation-content .tip {
    font-style: italic;
    color: #22c55e;
    font-size: 0.85rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

@media (min-width: 900px) {
    .dashboard-wrapper {
        padding: 1rem 3rem;
    }
    
    .dashboard-panes {
        grid-template-columns: 40% 1fr;
        gap: 1.5rem;
    }

    /* Desktop table sizing: first column (TOTAL) is 2× each other column */
    .aspect-table thead th:first-child,
    .aspect-table tbody td:first-child,
    .aspect-table tbody th:first-child {
        width: 28.57%;
    }

    .aspect-table thead th:nth-child(2),
    .aspect-table thead th:nth-child(3),
    .aspect-table thead th:nth-child(4),
    .aspect-table thead th:nth-child(5),
    .aspect-table thead th:nth-child(6),
    .aspect-table tbody td:nth-child(2),
    .aspect-table tbody td:nth-child(3),
    .aspect-table tbody td:nth-child(4),
    .aspect-table tbody td:nth-child(5),
    .aspect-table tbody td:nth-child(6),
    .aspect-table tbody th:nth-child(2),
    .aspect-table tbody th:nth-child(3),
    .aspect-table tbody th:nth-child(4),
    .aspect-table tbody th:nth-child(5),
    .aspect-table tbody th:nth-child(6) {
        width: 14.285%;
    }

    /* Show desktop format on desktop, hide mobile format */
    .aspect-table .current-row .mobile-format {
        display: none;
    }
    
    .aspect-table .current-row .desktop-format {
        display: inline;
    }
}

/* Graph Pane */
.pane-graph {
    height: 280px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow: visible;
    padding: 0.5rem 0.5rem 0.65rem;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.3s ease;
    position: relative;
}

.pane-graph::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 8px;
    padding: 1px;
    background: linear-gradient(135deg, var(--accent) 0%, transparent 50%, rgba(59, 130, 246, 0.3) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pane-graph:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.15), 0 0 40px rgba(59, 130, 246, 0.1);
}

.pane-graph:hover::before {
    opacity: 0.6;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.pane-label {
    font-size: 0.7rem;
    color: var(--fg-subtle);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 0.1rem;
    line-height: 1;
}

#growthChart {
    display: block;
    width: 100%;
    height: 100%;
    flex: 1;
}

/* Chart animations */
#growthChart .chart-segment-anim {
    animation: chartGrow 1s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

@keyframes chartGrow {
    to {
        stroke-dashoffset: 0;
    }
}

#growthChart .burst-ring {
    animation: burstRing 450ms ease-out both;
}

#growthChart .chart-dot-pop {
    animation: dotPop 280ms ease-out both;
}

@keyframes dotPop {
    0% {
        opacity: 0;
        r: 1;
    }
    100% {
        opacity: 1;
        r: 5;
    }
}

@keyframes burstRing {
    0% {
        opacity: 0;
        r: 5;
        stroke-width: 3;
    }
    30% {
        opacity: 0.9;
        stroke-width: 2;
    }
    100% {
        opacity: 0;
        r: 20;
        stroke-width: 0;
    }
}

#growthChart circle {
    transition: r 0.2s ease;
}

#growthChart circle:hover {
    r: 6;
}

/* Data Pane */
.pane-data {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.aspect-table-wrap {
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.aspect-table-wrap:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.aspect-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    table-layout: fixed;
}

.aspect-table thead th {
    font-size: 0.65rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.4rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.01);
    white-space: nowrap;
}

.aspect-table thead th:last-child {
    border-right: none;
}

.aspect-table thead th:first-child {
    width: 35%;
}

.aspect-table thead th:nth-child(2),
.aspect-table thead th:nth-child(3) {
    width: 13%;
}

.aspect-table thead th:nth-child(4),
.aspect-table thead th:nth-child(5),
.aspect-table thead th:nth-child(6) {
    width: 13%;
}

.aspect-table thead th:first-child,
.aspect-table tbody td:first-child {
    text-align: left;
}

.aspect-table tbody td {
    padding: 0.45rem 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.8rem;
    color: #ddd;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aspect-table tbody td:last-child {
    border-right: none;
}

/* Light zebra striping (decision rows only; TOTAL + header excluded) */
.aspect-table tbody tr.zebra-even {
    background: rgba(255, 255, 255, 0.04);
}

.aspect-table tbody tr.zebra-odd {
    background: rgba(255, 255, 255, 0.02);
}

.aspect-table tbody tr.current-row td {
    font-weight: 600;
    font-size: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Hide desktop format by default, show mobile */
.aspect-table .current-row .desktop-format {
    display: none;
}

.aspect-table .current-row .mobile-format {
    display: inline;
}

.aspect-table tbody tr.header-row th {
    font-size: 0.65rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.4rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.01);
    white-space: nowrap;
    font-weight: 400;
}

.aspect-table tbody tr.header-row th:last-child {
    border-right: none;
}

.aspect-table tbody tr.header-row th:first-child {
    text-align: left;
}

.aspect-table tbody td.delta-pos-low {
    color: #86efac !important;
    font-weight: 500;
}

.aspect-table tbody td.delta-pos-medium {
    color: #22c55e !important;
    font-weight: 600;
}

.aspect-table tbody td.delta-pos-high {
    color: #16a34a !important;
    font-weight: 700;
    background: rgba(34, 197, 94, 0.08);
}

.aspect-table tbody td.delta-neg {
    color: #ff6b6b !important;
    font-weight: 600;
}

.aspect-table tbody td.delta-cost-good {
    color: #fbbf24 !important;
    font-weight: 600;
}

.aspect-table tbody td.delta-cost-bad {
    color: #ff6b6b !important;
    font-weight: 600;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1rem;
}

@media (min-width: 600px) {
    .metric-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

.metric.secondary {
    opacity: 0.7;
}

.metric .label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
}

.metric .value {
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

.active-costs {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #ff6b6b;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* Scroll Container */
.simulator-scroll-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem;
    width: 100%;
}

@media (min-width: 900px) {
    .simulator-scroll-container {
        max-width: 1000px;
        padding: 4rem 3rem;
    }
}

/* Particle canvas for 3D effect */
#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

/* Hero */
.hero-section {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeIn 0.8s ease;
}

.hero-section h1 {
    font-family: 'Roboto', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.hero-sub {
    font-size: 1.2rem;
    color: var(--fg-muted);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.follower-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.follower-input-group label {
    font-size: 0.9rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.follower-input-group input {
    width: 100%;
    max-width: 160px;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    color: var(--fg);
    font-family: 'Inter', sans-serif;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.follower-input-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.085);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-primary:disabled {
    opacity: 1;
    cursor: not-allowed;
    background: rgba(100, 100, 100, 0.3);
    color: rgba(255, 255, 255, 0.4);
    border-color: rgba(100, 100, 100, 0.4);
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
    background: rgba(100, 100, 100, 0.3);
}

.disclaimer {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #555;
}

/* Chapters */
.chapter-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 3rem; /* Space between chapters */
    /* opacity: 0;  <-- Removed to fix visibility when animation is disabled */
    /* transform: translateY(20px); <-- Removed, handled in keyframes */
    animation: slideUp 0.6s forwards;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.3s ease;
    position: relative;
}

.chapter-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.1), 0 0 40px rgba(59, 130, 246, 0.05);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter-card h3 {
    font-family: 'Roboto', sans-serif;
    font-size: 1.9rem;
    margin: 1rem 0;
    color: var(--accent);
}

.chapter-card p {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: rgba(255, 255, 255, 0.85);
}

.choices-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 600px) {
    .choices-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.choice-feedback {
    margin-top: 1.5rem;
    padding: 1rem 1.2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    animation: fadeIn 0.4s ease;
}

.choice-feedback.excellent {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.4);
}

.choice-feedback.valid {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-hover);
}

.feedback-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.choice-feedback.excellent .feedback-title {
    color: #22c55e;
}

.choice-feedback.valid .feedback-title {
    color: var(--fg);
}

.feedback-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
}

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


.simulator-scroll-container {
    padding: 2rem 0.4rem;
}

.choice-btn {
    background: transparent;
    border: 1px solid var(--border-hover);
    padding: 1.2rem;
    border-radius: 8px;
    color: var(--fg);
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    font-family: 'Inter', sans-serif;
}

.choice-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.choice-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.choice-btn p {
    font-size: 1.2rem;
    margin: 0.2rem;
    opacity: 0.85;
    line-height: 1;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-fg);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.btn-primary:hover {
    transform: scale(1.05);
    background: var(--btn-primary-hover);
    box-shadow: var(--shadow-sm);
}

@media (prefers-reduced-motion: reduce) {
    .simulator-page::before {
        animation: none;
    }

    .chapter-card,
    .choice-btn,
    .btn-primary,
    .btn-text,
    .pane-graph {
        transition: none;
        animation: none;
        transform: none;
    }
}

.btn-large {
    font-size: 1.2rem;
    padding: 1.2rem 3rem;
}

/* End Screen */
.end-screen {
    text-align: center;
    padding: 2rem;
}

.end-screen h2 {
    font-family: 'Roboto', sans-serif;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.verdict {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #ccc;
}


/* Mobile: heavily reduce all margins/padding */
@media (max-width: 600px) {
    .dashboard-wrapper {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        padding: 0.5rem;
    }

    .dashboard-panes {
        gap: 0.5rem;
    }

    .pane-graph {
        height: 200px;
        padding: 0.35rem 0.35rem 0.5rem;
    }

    .graph-header {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .sim-logo {
        font-size: 0.9rem;
    }

    .btn-text {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    .pane-label {
        font-size: 0.6rem;
    }

    .aspect-table th,
    .aspect-table td {
        padding: 0.25rem 0.3rem;
        font-size: 0.65rem;
    }

    .aspect-table tbody tr.header-row th {
        white-space: normal;
        line-height: 1.2;
        word-break: break-word;
    }

    .aspect-table .current-row td {
        font-size: 0.85rem;
        padding: 0.35rem 0.3rem;
    }

    .simulator-scroll-container {
        padding: 1.5rem 0.5rem;
    }

    .hero-section {
        margin-bottom: 2rem;
    }

    .hero-section h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .hero-sub {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .follower-input-group {
        margin-bottom: 1rem;
        gap: 0.3rem;
    }

    .btn-primary {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }

    .chapter-card {
        padding: 1rem;
        margin-bottom: 2rem;
    }

    .chapter-card h3 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .chapter-card > p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .choices-grid {
        gap: 0.5rem;
    }

    .choice-btn {
        padding: 1rem;
        margin: 1rem 0;
    }

    .choice-btn p {
        font-size:1rem;
    }

    .end-screen {
        padding: 1rem;
    }

    .end-screen h2 {
        font-size: 1.5rem;
    }

    .verdict {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
}
