/* Google Sans Font */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap');

/* Fallback if Google Sans not available */
@font-face {
    font-family: 'Google Sans';
    src: local('Google Sans'), local('GoogleSans-Regular');
    font-weight: 400;
}

/* CSS Variables */
:root {
    --font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --color-solar: #fbbc05;
    --color-wind: #4285f4;
    --color-storage: #673ab7;
    --color-cleanfirm: #ff7900;
    --color-gas: #ea4335;
    --color-text: #202124;
    --color-text-secondary: #5f6368;
    --color-background: #ffffff;
    --color-surface: #f8f9fa;
    --color-border: #dadce0;
    --max-width: 900px;
    --spacing-unit: 8px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background-color: var(--color-background);
    line-height: 1.6;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

h2 {
    font-size: 1.75rem;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: calc(var(--spacing-unit) * 1.5);
}

h3 {
    font-size: 1.25rem;
}

p {
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--color-text-secondary);
}

/* Layout */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 3);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #1a73e8 0%, #34a853 100%);
    color: white;
    padding: calc(var(--spacing-unit) * 10) 0;
    text-align: center;
}

.hero h1 {
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: white;
}

.hero .subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    max-width: 600px;
    margin: 0 auto;
}

.hero .hero-link {
    margin-top: calc(var(--spacing-unit) * 3);
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

.hero .hero-link a {
    color: white;
    text-decoration: underline;
    font-weight: 500;
}

.hero .hero-link a:hover {
    color: var(--color-solar);
}

.hero .hero-cta {
    font-size: 1.4rem;
    font-weight: 500;
    color: white;
    margin-top: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

/* Part Headers */
.part-header {
    text-align: center;
    padding: calc(var(--spacing-unit) * 8) 0 calc(var(--spacing-unit) * 4);
    margin-top: calc(var(--spacing-unit) * 4);
    border-top: 3px solid var(--color-border);
}

.part-header:first-of-type {
    border-top: none;
    margin-top: 0;
}

.part-label {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-wind);
    margin-bottom: calc(var(--spacing-unit) * 1);
}

.part-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: calc(var(--spacing-unit) * 1);
    border-bottom: none;
    padding-bottom: 0;
}

.part-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-bottom: 0;
}

/* Transition Text */
.transition-text {
    font-size: 1.1rem;
    color: var(--color-text);
    text-align: center;
    padding: calc(var(--spacing-unit) * 3) 0;
    margin-top: calc(var(--spacing-unit) * 2);
    font-weight: 500;
}

/* Keystone Section */
.keystone-section {
    background: linear-gradient(135deg, #fff8e1 0%, #fff3e0 100%);
    border-radius: 12px;
    padding: calc(var(--spacing-unit) * 5);
    margin: calc(var(--spacing-unit) * 4) 0;
    border: 2px solid var(--color-cleanfirm);
}

.keystone-section h2 {
    color: var(--color-cleanfirm);
    border-bottom-color: var(--color-cleanfirm);
}

/* Two Column Layout */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--spacing-unit) * 4);
    margin: calc(var(--spacing-unit) * 4) 0;
}

.two-column .column {
    background: white;
    padding: calc(var(--spacing-unit) * 3);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.two-column .column h3 {
    color: var(--color-cleanfirm);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
}

.two-column .column p {
    margin-bottom: 0;
    color: var(--color-text-secondary);
}

@media (max-width: 600px) {
    .two-column {
        grid-template-columns: 1fr;
    }
}

/* Sections */
.section {
    padding: calc(var(--spacing-unit) * 8) 0;
    border-bottom: 1px solid var(--color-border);
}

.section:last-child {
    border-bottom: none;
}

/* Charts */
.chart-container {
    width: 100%;
    min-height: 400px;
    margin: calc(var(--spacing-unit) * 4) 0;
    background-color: var(--color-surface);
    border-radius: 8px;
    padding: calc(var(--spacing-unit) * 2);
}

/* Insights */
.insight {
    font-style: italic;
    color: var(--color-text);
    padding-left: calc(var(--spacing-unit) * 2);
    border-left: 3px solid var(--color-wind);
}

.insight em {
    color: var(--color-cleanfirm);
    font-weight: 500;
}

/* Callouts */
.callout {
    background-color: var(--color-surface);
    border-left: 4px solid var(--color-wind);
    padding: calc(var(--spacing-unit) * 3);
    margin: calc(var(--spacing-unit) * 3) 0;
    border-radius: 0 8px 8px 0;
}

.callout strong {
    color: var(--color-text);
}

.callout.warning {
    border-left-color: var(--color-solar);
    background-color: #fffde7;
}

.callout.danger {
    border-left-color: var(--color-gas);
    background-color: #ffebee;
}

/* Region Notes */
.region-notes {
    list-style: none;
    margin-top: calc(var(--spacing-unit) * 3);
}

/* Chart Notes */
.chart-note {
    font-size: 0.95em;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-top: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.region-notes li {
    padding: calc(var(--spacing-unit) * 2) 0;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.region-notes li:last-child {
    border-bottom: none;
}

.region-notes strong {
    color: var(--color-text);
}

/* Implications Grid */
.implications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: calc(var(--spacing-unit) * 3);
    margin-top: calc(var(--spacing-unit) * 4);
}

.implication-card {
    background-color: var(--color-surface);
    padding: calc(var(--spacing-unit) * 3);
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.implication-card h3 {
    color: var(--color-text);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    font-size: 1.1rem;
}

.implication-card p {
    margin-bottom: 0;
    font-size: 0.95rem;
}

/* Footer */
footer {
    text-align: center;
    padding: calc(var(--spacing-unit) * 6) 0;
}

footer p {
    font-size: 0.9rem;
}

footer .footer-cta {
    margin-top: calc(var(--spacing-unit) * 2);
    font-size: 1rem;
    color: var(--color-text);
}

footer .footer-cta a {
    color: var(--color-wind);
    text-decoration: none;
    font-weight: 500;
}

footer .footer-cta a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .hero {
        padding: calc(var(--spacing-unit) * 6) 0;
    }

    .hero .subtitle {
        font-size: 1.1rem;
    }

    .section {
        padding: calc(var(--spacing-unit) * 5) 0;
    }

    .chart-container {
        min-height: 300px;
    }

    .implications-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading state for charts */
.chart-container::before {
    content: 'Loading chart...';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.chart-container.loaded::before {
    display: none;
}

/* Plotly chart overrides */
.js-plotly-plot .plotly .modebar {
    right: 10px !important;
}

/* ============================================ */
/* NAVIGATION & PROGRESS FEATURES */
/* ============================================ */

/* Progress Bar */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-wind), var(--color-solar));
    z-index: 1000;
    transition: width 0.1s ease;
}

/* Navigation Sidebar */
#nav-sidebar {
    position: fixed;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 1.5);
    padding: calc(var(--spacing-unit) * 2.5) calc(var(--spacing-unit) * 2);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    min-width: 200px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1.5);
    cursor: pointer;
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 1.5);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: rgba(66, 133, 244, 0.1);
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.nav-item:hover .nav-dot {
    background: var(--color-wind);
    transform: scale(1.2);
}

.nav-item.active .nav-dot {
    background: var(--color-wind);
    transform: scale(1.4);
}

.nav-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.nav-item:hover .nav-label {
    color: var(--color-text);
}

.nav-item.active .nav-label {
    color: var(--color-wind);
    font-weight: 600;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-wind);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 998;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#back-to-top:hover {
    background: var(--color-solar);
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Section Progress Indicator */
.section-marker {
    position: relative;
}

.section-marker::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    transition: background 0.3s ease;
}

.section-marker.in-view::before {
    background: var(--color-wind);
}

/* Section Indicator */
#section-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 997;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

#section-indicator.visible {
    opacity: 1;
    visibility: visible;
}

/* Mobile adjustments */
@media (max-width: 1200px) {
    #nav-sidebar {
        right: 20px;
        min-width: 180px;
    }

    .nav-label {
        font-size: 0.8rem;
    }
}

@media (max-width: 1024px) {
    #nav-sidebar {
        right: 16px;
        padding: calc(var(--spacing-unit) * 2);
        gap: calc(var(--spacing-unit) * 1.25);
        min-width: 160px;
    }

    .nav-item {
        padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1);
        gap: calc(var(--spacing-unit) * 1);
    }

    .nav-dot {
        width: 8px;
        height: 8px;
    }

    .nav-label {
        font-size: 0.75rem;
    }

    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
    }

    #section-indicator {
        bottom: 80px;
        font-size: 0.85rem;
        padding: 8px 20px;
    }
}

@media (max-width: 768px) {
    #nav-sidebar {
        display: none;
    }

    #back-to-top {
        bottom: 16px;
        right: 16px;
    }

    #section-indicator {
        bottom: 70px;
        font-size: 0.8rem;
        padding: 8px 18px;
    }
}

/* Export Text Button */
.export-text-button {
    background: var(--color-wind);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.export-text-button:hover {
    background: #1557b0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    border: none;
    padding: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

.modal-body {
    padding: 24px 32px;
    overflow-y: auto;
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.action-button {
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    background: white;
    color: var(--color-text);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.action-button:hover {
    background: var(--color-surface);
    border-color: var(--color-wind);
}

.action-button.primary {
    background: var(--color-wind);
    color: white;
    border-color: var(--color-wind);
}

.action-button.primary:hover {
    background: #1557b0;
}

#text-content {
    width: 100%;
    min-height: 400px;
    max-height: 500px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    resize: vertical;
    color: var(--color-text);
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .action-button {
        width: 100%;
    }

    #text-content {
        min-height: 300px;
        font-size: 0.8rem;
    }
}

/* Assumptions Dropdown */
.assumptions-dropdown {
    margin: calc(var(--spacing-unit) * 2) 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
}

.assumptions-dropdown summary {
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2);
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1);
}

.assumptions-dropdown summary::-webkit-details-marker {
    display: none;
}

.assumptions-dropdown summary::before {
    content: '▶';
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.assumptions-dropdown[open] summary::before {
    transform: rotate(90deg);
}

.assumptions-dropdown summary:hover {
    color: var(--color-text);
}

.assumptions-content {
    padding: calc(var(--spacing-unit) * 2);
    border-top: 1px solid var(--color-border);
}

.assumptions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.assumptions-table th,
.assumptions-table td {
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 1.5);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.assumptions-table th {
    font-weight: 500;
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.02);
}

.assumptions-table td {
    color: var(--color-text-secondary);
}

.assumptions-table td:first-child {
    font-weight: 500;
    color: var(--color-text);
}

.assumptions-table tr:last-child td {
    border-bottom: none;
}

.assumptions-note {
    margin-top: calc(var(--spacing-unit) * 2);
    margin-bottom: 0;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}
