/* ==========================================================================
   South Sudan Crisis Group - Main Stylesheet
   Production-ready, responsive, and accessible CSS
   ========================================================================== */

/* ==========================================================================
   CSS Reset and Base Styles
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #ffffff;
    background-color: #44546a;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 1rem 0;
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: #FFFFFF;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: #FFFFFF;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    color: #4effd0;
    font-weight: 600;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

h4 {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 600;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    line-height: 1.5;
    margin: 0 0 1rem 0;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

a {
    color: #4effd0;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 0.2em;
    transition: color 0.3s ease;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

a:hover,
a:focus {
    color: #FFFFFF;
    text-decoration-style: solid;
}

a:visited {
    color: #4effd0;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ==========================================================================
   Loading Screen
   ========================================================================== */

.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease-out;
}

.loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-spin {
    width: 40px;
    height: 40px;
    border: 5px solid #333;
    border-top: 5px solid #d3d3d3;
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #717C7D;
    z-index: 9998;
}

.progress-bar {
    height: 100%;
    background: #4effd0;
    width: 0%;
    transition: width 0.3s ease;
}

/* ==========================================================================
   Scrollytelling Section
   ========================================================================== */

.scrollytelling-section {
    position: relative;
    height: 100vh;
    overflow: hidden;
}

.pinned-map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    transition: all 0.3s ease;
}

/* Enhanced Map Visual Effects */
.pinned-map::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(78, 255, 208, 0.05) 0%, 
        rgba(255, 107, 107, 0.05) 50%, 
        rgba(78, 255, 208, 0.05) 100%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease;
    animation: mapGlow 4s ease-in-out infinite alternate;
}

.pinned-map::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, 
        rgba(78, 255, 208, 0.1) 0%, 
        transparent 70%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.pinned-map:hover::before,
.pinned-map:hover::after {
    opacity: 1;
}

@keyframes mapGlow {
    0% {
        opacity: 0.3;
        transform: scale(1);
    }
    100% {
        opacity: 0.6;
        transform: scale(1.02);
    }
}

/* Unpinned map state */
#map:not(.pinned-map) {
    position: relative;
    width: 100%;
    height: 400px;
    z-index: auto;
}

.scrolling-content {
    position: relative;
    z-index: 2;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.content-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem;
    position: relative;
}

/* Panel positioning - alternate sides */
.panel-center {
    justify-content: center;
}

.panel-left {
    justify-content: flex-start;
    padding-left: 2rem;
}

.panel-right {
    justify-content: flex-end;
    padding-right: 2rem;
}

.panel-content {
    max-width: 400px;
    width: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 2rem;
    color: #fff;
    box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3);
    border: 2px solid #ffffff;
    margin: 0 1rem;
    position: relative;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Panel Types */
.header-panel .panel-content {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    text-align: center;
    max-width: 400px;
    min-height: 120px;
    height: auto;
    padding: 1.125rem 1.5rem;
    border: 2px solid #4effd0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: -120px;
    box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3), 0 0 20px rgba(78, 255, 208, 0.8), 0 0 40px rgba(78, 255, 208, 0.4);
    position: relative;
    overflow-y: auto;
    box-sizing: border-box;
}

.narrative-panel .panel-content {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    border: 2px solid #ffffff;
    box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3);
}

.visual-panel .panel-content {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    border: 2px solid #ffffff;
    box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3);
}

.data-panel .panel-content {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    color: #ffffff;
    border: 2px solid #ffffff;
    box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3);
}

.conclusion-panel .panel-content {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    border: 2px solid #ffffff;
    box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3);
}

/* Panel Scrollbar Styling */
.panel-content::-webkit-scrollbar {
    width: 16px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.15);
    margin-top: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #4effd0;
    border-radius: 8px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(78, 255, 208, 0.8);
}

/* Panel Content Elements */
.panel-content h1 {
    font-size: clamp(1.125rem, 2.625vw, 1.875rem);
    margin-bottom: 0.5rem;
    margin-top: -15px;
    color: #4effd0;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.15em;
    text-align: center;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.panel-content h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 1.5rem;
    color: #FFFFFF;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.panel-content h3 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: 1.5rem;
    color: #4effd0;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.panel-content p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.panel-content .hedp {
    font-size: clamp(0.825rem, 2.1vw, 1.05rem);
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-align: center;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
    max-width: 90%;
    margin: 0 auto;
}

/* Logo centering */
.panel-content .logo {
    display: block;
    margin: 0 auto 0.5rem auto;
    width: 60px;
    height: 60px;
}

/* Responsive logo sizing */
@media (max-width: 768px) {
    .panel-content .logo {
        width: 45px;
        height: 45px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .panel-content .logo {
        width: 52px;
        height: 52px;
    }
}

.panel-content ul {
    list-style-type: none;
    padding: 0;
    margin: 1.5rem 0;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.panel-content li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.panel-content li::before {
    content: '•';
    color: #4effd0;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Visual Panel Styles */
.visual-container {
    margin: 2rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.visual-image {
    width: 100%;
    height: auto;
    display: block;
}

.visual-credit {
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
    margin-top: 1rem;
    opacity: 0.8;
}

/* Data Panel Styles */
.data-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.data-item {
    text-align: center;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.data-number {
    display: block;
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    font-weight: bold;
    color: #4effd0;
    margin-bottom: 0.5rem;
}

/* Smaller font size for the solar data specifically */
.data-number.solar-data {
    font-size: clamp(1.25rem, 4.5vw, 1.8rem);
}

.data-label {
    display: block;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
}

/* Post-Scrollytelling Content */
.post-scrollytelling {
    padding: 4rem 2rem;
    background: #f8f9fa;
    color: #333;
    position: relative;
    z-index: 3;
}

.post-scrollytelling h2 {
    color: #44546a;
    margin-bottom: 1.5rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.cta-button {
    display: inline-block;
    padding: 1rem 2rem;
    background: #E87722;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.cta-button:hover {
    background: #FFB81C;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Mobile CTA layout */
@media (max-width: 768px) {
    .cta-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .cta-button {
        width: 100%;
        text-align: center;
        padding: 0.9rem 1.25rem;
    }
}

/* Special styling for View Now button */
.cta-button[href*="drive.google.com"] {
    background: #44546a;
    color: #4effd0;
    border: 2px solid #44546a;
}

.cta-button[href*="drive.google.com"]:hover,
.cta-button[href*="drive.google.com"]:focus {
    background: #5a6b7a;
    color: #4effd0;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(68, 84, 106, 0.3);
    outline: 2px solid #44546a;
    outline-offset: 2px;
}

/* Special styling for Book Demo button */
#bookDemoBtn {
    background: #44546a;
    color: #4effd0;
    border: 2px solid #44546a;
}

#bookDemoBtn:hover,
#bookDemoBtn:focus {
    background: #5a6b7a;
    color: #4effd0;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(68, 84, 106, 0.3);
    outline: 2px solid #44546a;
    outline-offset: 2px;
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
    background-color: #44546a;
    backdrop-filter: blur(10px);
    background-image: none;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    z-index: 10000;
    padding: 0;
    position: relative;
    border-bottom: none;
    width: 100%;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 55px;
    position: relative;
}

.logo {
    position: relative;
    margin-left: -630px;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
}

.logo img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
}

.logo-text {
    display: block;
    color: #FFFFFF;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.2;
}

.nav {
    transform: translateX(650px);
    display: flex;
    align-items: center;
}

/* Header responsive fixes: remove magic offsets on smaller screens */
@media (max-width: 1024px) {
    .logo {
        margin-left: 0;
    }
    .nav {
        transform: none;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
        height: auto;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

.nav ul {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav li {
    margin-left: 15px;
}

.nav li:first-child {
    margin-left: 0;
}

.nav a {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    color: #FFFFFF;
    fill: #FFFFFF;
    cursor: pointer;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.2;
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav a:hover,
.nav a:focus {
    color: #4effd0;
    fill: #4effd0;
    text-decoration: none;
}

.nav a.active {
    position: relative;
    color: #4effd0;
    fill: #4effd0;
    font-weight: 500;
    text-decoration: none;
}

.nav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 0);
    width: calc(100% - 20px);
    height: 2px;
    background: #4effd0;
}

.main-title {
    margin: 10% auto 1%;
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.1em;
    max-width: 80%;
}

.subtitle {
    margin: 0 auto 2%;
    text-align: center;
    font-weight: 500;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: #DFD7D5;
    max-width: 70%;
}

.hedp {
    text-align: center;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.6rem);
    line-height: 1.5;
    letter-spacing: 0.01em;
    max-width: 60%;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ==========================================================================
   Explore Button
   ========================================================================== */

.explore-btn {
    display: block;
    margin: 2% auto 0;
    padding: 1rem 2rem;
    background: transparent;
    border: 2px solid #c0afa5;
    color: #E1E0E0;
    font-size: clamp(1rem, 2vw, 1.25rem);
    font-family: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 200px;
}

.explore-btn:hover,
.explore-btn:focus {
    background-color: #fff;
    color: #000;
    border-color: #fff;
    outline: 2px solid #E87722;
    outline-offset: 2px;
}

.explore-btn.active {
    background-color: #fff;
    color: #000;
}

/* ==========================================================================
   Map Inset
   ========================================================================== */

.map-inset {
    position: fixed;
    bottom: 50px;
    right: 30px;
    width: clamp(200px, 25vw, 250px);
    height: 180px;
    max-width: 100%;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Main Content Sections
   ========================================================================== */

.main-content {
    position: relative;
    z-index: 3;
}

.section {
    padding: 20vh 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step {
    padding-bottom: 50vh;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ==========================================================================
   Section Types
   ========================================================================== */

.intro-section .step {
    margin-top: 50%;
}

.narrative-section .step {
    background-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0) 59%,
        rgba(0, 0, 0, 0.95) 100%
    );
    padding: 5% 0;
}

.video-section .step {
    background-image: url('../assets/texturebg.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    padding: 5px 0;
}

.chart-section .step {
    background-color: #5f3830;
    width: 60vw;
    max-width: 800px;
    margin: 0 auto;
}

.end-section .step {
    background-color: #5f3830;
}

/* ==========================================================================
   Content Layouts
   ========================================================================== */

.centered {
    width: 50vw;
    margin: 0 auto;
}

.lefty {
    width: 33vw;
}

.righty {
    width: 33vw;
    margin-left: 67vw;
}

.fully {
    width: 100%;
    margin: auto;
}

.light {
    color: #444;
    background-color: #5f3830;
    border-radius: 25px;
    padding: 2rem;
}

.lefty .light {
    border-radius: 0 25px 25px 0;
}

.righty .light {
    border-radius: 25px 0 0 25px;
}

/* ==========================================================================
   Video Styles
   ========================================================================== */

.html-video-container {
    max-width: 100%;
    height: auto;
    max-height: 100%;
    opacity: 1;
    border-radius: 8px;
    object-fit: cover;
}

.video-container {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    border-radius: 8px;
    background: #f0f0f0;
}

.video-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Chart Container
   ========================================================================== */

.chart-container {
    width: 100%;
    height: 400px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

/* ==========================================================================
   Legend Styles
   ========================================================================== */

.legend {
    position: fixed;
    bottom: 30px;
    color: #E4E4E4;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    display: none;
    z-index: 2;
    font-family: inherit;
    font-weight: 400;
    backdrop-filter: blur(10px);
}

.left-legend {
    left: 30px;
}

.right-legend {
    right: 30px;
}

.legend h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

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

.legend-ul li {
    display: flex;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.legend span {
    display: inline-block;
    width: 20px;
    height: 12px;
    margin-right: 0.5rem;
    border-radius: 4px;
}

.endleg {
    position: fixed;
    top: 30px;
    right: 30px;
    color: #E4E4E4;
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem;
    border-radius: 8px;
    display: none;
    z-index: 2;
    backdrop-filter: blur(10px);
}

/* ==========================================================================
   Legend Colors
   ========================================================================== */

.green {
    background-color: #5a7e71;
}

.red {
    background-color: #b65d61;
}

.oj {
    background-color: #ed924e;
}

.blue {
    background-color: #457d97;
}

.rain {
    background-color: #003e51;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    width: 100%;
    min-height: 10vh;
    padding: 1rem 2rem;
    background-color: #44546a;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    position: relative;
    z-index: 5;
    border-top: 1px solid rgba(78, 255, 208, 0.2);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.footer-logo-img {
    width: 60px;
    height: 60px;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.footer-logo-img:hover {
    opacity: 1;
}

.credits {
    font-size: 0.9rem;
    color: #FFFFFF;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.credits p {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Responsive Scrollytelling
   ========================================================================== */

/* Mobile styles */
@media (max-width: 768px) {
    .scrollytelling-section {
        height: auto;
        min-height: 100vh;
    }
    
    .scrolling-content {
        height: auto;
        overflow-y: visible;
    }
    
    .content-panel {
        min-height: 65vh; /* shorter panels to reveal more background */
        padding: 1rem;
        justify-content: center;
        margin-bottom: 16rem; /* doubled again for more background space */
    }
    
    .panel-left,
    .panel-right {
        justify-content: center;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .panel-content {
        max-width: 92%;
        margin: 0;
        padding: 1.25rem;
    }
    
    .header-panel .panel-content {
        max-width: 85%;
        min-height: 90px;
        padding: 0.75rem 1.125rem;
        margin-top: -120px;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(8px);
        border: 2px solid #4effd0;
        box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3), 0 0 20px rgba(78, 255, 208, 0.8), 0 0 40px rgba(78, 255, 208, 0.4);
    }
    
    .panel-content .hedp {
        max-width: 95%;
    }

    /* Reduce font size ~20% for all text inside content panels */
    .panel-content h1,
    .panel-content h2,
    .panel-content h3,
    .panel-content h4,
    .panel-content p,
    .panel-content li,
    .panel-content .hedp,
    .panel-content .data-number,
    .panel-content .data-label,
    .panel-content .visual-credit {
        font-size: 0.8em;
    }

    /* Reduce images inside panels by ~20% */
    .panel-content .visual-image {
        width: 80%;
        height: auto;
        margin-left: auto;
        margin-right: auto;
    }

    /* Reduce header panel logo by ~20% on mobile */
    .panel-content .logo {
        width: 36px;
        height: 36px;
    }

    /* Mobile-only adjustments for "Arequipa, Peru: Our first Pilot City" panel */
    .content-panel[data-map-state="data"] .data-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2x2 grid on mobile */
        gap: 0.75rem;
    }

    .content-panel[data-map-state="data"] .data-item {
        padding: 0.5rem; /* shorter subpanels */
        min-height: 64px;
    }

    .content-panel[data-map-state="data"] .data-number,
    .content-panel[data-map-state="data"] .data-label {
        font-size: 0.75em; /* further reduce to keep proportions on small screens */
    }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .panel-content {
        max-width: 360px;
    }
    
    .header-panel .panel-content {
        max-width: 380px;
        min-height: 105px;
        padding: 1.125rem 1.5rem;
        margin-top: -120px;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(8px);
        border: 2px solid #4effd0;
        box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3), 0 0 20px rgba(78, 255, 208, 0.8), 0 0 40px rgba(78, 255, 208, 0.4);
    }
    
    .panel-content .hedp {
        max-width: 85%;
    }
}

/* Desktop styles */
@media (min-width: 1025px) {
    .panel-content {
        max-width: 400px;
    }
    
    .header-panel .panel-content {
        max-width: 400px;
        min-height: 120px;
        padding: 1.125rem 1.5rem;
        margin-top: -120px;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(8px);
        border: 2px solid #4effd0;
        box-shadow: 0 8px 32px rgba(68, 84, 106, 0.3), 0 0 20px rgba(78, 255, 208, 0.8), 0 0 40px rgba(78, 255, 208, 0.4);
    }
    
    .panel-content .hedp {
        max-width: 80%;
    }
}

/* Small devices (phones, 320px and up) */
@media (max-width: 480px) {
    .header {
        padding: 1rem;
    }
    
    .logo {
        position: static;
        margin: 0 auto 1rem;
        display: block;
    }
    
    .main-title {
        margin: 1rem auto;
        font-size: 1.5rem;
    }
    
    .hedp {
        display: none;
    }
    
    .explore-btn {
        display: none;
    }
    
    .map-inset {
        display: none;
    }
    
    .section {
        padding: 10vh 0;
    }
    
    .content-wrapper {
        padding: 0 0.75rem;
    }
    
    .light {
        padding: 1rem;
        border-radius: 15px;
    }
    
    .centered,
    .lefty,
    .righty,
    .fully {
        width: 90vw;
        margin: 0 auto;
    }
    
    .lefty .light,
    .righty .light {
        border-radius: 15px;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .credits {
        text-align: left;
    }
    
    .legend {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .legend span {
        width: 16px;
        height: 10px;
    }
}

/* Improve data grid spacing on small screens */
@media (max-width: 480px) {
    .data-container {
        gap: 1rem;
    }
    .data-item {
        padding: 1rem;
    }
}

/* Legend spacing and sizing tweaks for narrow viewports */
@media (max-width: 768px) {
    .legend.left-legend { left: 16px; bottom: 16px; }
    .legend.right-legend { right: 16px; bottom: 16px; }
}

/* Ultra-small device safeguards */
@media (max-width: 360px) {
    h1 { font-size: clamp(1.5rem, 8vw, 2rem); }
    p { font-size: clamp(0.95rem, 3.8vw, 1.05rem); }
    .panel-content { padding: 1rem; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 481px) and (max-width: 768px) {
    .logo {
        width: 75px;
        height: 75px;
    }
    
    .main-title {
        font-size: 2rem;
    }
    
    .hedp {
        font-size: 1.1rem;
        max-width: 80%;
    }
    
    .explore-btn {
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }
    
    .map-inset {
        width: 200px;
        height: 150px;
    }
    
    .section {
        padding: 15vh 0;
    }
    
    .content-wrapper {
        padding: 0 1.5rem;
    }
}

/* Large devices (desktops, 1024px and up) */
@media (min-width: 769px) and (max-width: 1024px) {
    .logo {
        width: 100px;
        height: 100px;
    }
    
    .main-title {
        font-size: 3rem;
    }
    
    .hedp {
        font-size: 1.3rem;
        max-width: 70%;
    }
    
    .explore-btn {
        font-size: 1.1rem;
    }
    
    .map-inset {
        width: 220px;
        height: 160px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1025px) {
    .main-title {
        font-size: 4.5rem;
    }
    
    .hedp {
        font-size: 1.6rem;
        max-width: 60%;
    }
    
    .explore-btn {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

/* Focus styles */
*:focus {
    outline: 2px solid #E87722;
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .light {
        background-color: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .legend,
    .endleg {
        background: #000;
        border: 2px solid #fff;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .map-container,
    .map-inset,
    .explore-btn,
    .legend,
    .endleg,
    .loader {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .header {
        position: static;
        background: white;
    }
    
    .main-content {
        position: static;
    }
    
    .section {
        page-break-inside: avoid;
        padding: 1rem 0;
    }
}

/* ==========================================================================
   Mapbox Overrides
   ========================================================================== */

.mapboxgl-ctrl-attrib-inner {
    padding-right: 15px !important;
}

.mapboxgl-ctrl-top-right {
    top: 1% !important;
    right: 1% !important;
}

.mapboxgl-popup-content {
    font-family: inherit;
    color: #000;
}

.mapboxgl-popup-content strong {
    font-size: 14px;
    color: #000;
}

.mapboxgl-popup-content p {
    font-size: 13px;
    line-height: 1.4;
    color: #000;
}

.mapboxgl-popup-close-button {
    font-size: 24px;
}

/* Touch device fixes */
.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,
.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas {
    touch-action: unset;
}

/* ==========================================================================
   Scrollytelling Effects
   ========================================================================== */

.step {
    position: relative;
    z-index: 2;
}

.step::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.1) 0%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.step.active::before {
    opacity: 1;
}

.step h2,
.step h3 {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease 0.2s, transform 0.8s ease 0.2s;
}

.step.active h2,
.step.active h3 {
    opacity: 1;
    transform: translateY(0);
}

.step p {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.4s, transform 0.8s ease 0.4s;
}

.step.active p {
    opacity: 1;
    transform: translateY(0);
}

.step ul {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.6s, transform 0.8s ease 0.6s;
}

.step.active ul {
    opacity: 1;
    transform: translateY(0);
}

.step li {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.step.active li {
    opacity: 1;
    transform: translateX(0);
}

.step.active li:nth-child(1) { transition-delay: 0.8s; }
.step.active li:nth-child(2) { transition-delay: 0.9s; }
.step.active li:nth-child(3) { transition-delay: 1.0s; }
.step.active li:nth-child(4) { transition-delay: 1.1s; }

/* Enhanced visual effects for active steps */
.step.active .light {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
    transition: box-shadow 0.8s ease, transform 0.8s ease;
}

/* ==========================================================================
   Map Controls
   ========================================================================== */

.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(78, 255, 208, 0.3);
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background: rgba(78, 255, 208, 0.1);
    border: 1px solid rgba(78, 255, 208, 0.5);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: #4effd0;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(78, 255, 208, 0.2);
}

.map-control-btn:hover,
.map-control-btn:focus {
    background: rgba(78, 255, 208, 0.2);
    border-color: #4effd0;
    outline: 2px solid #4effd0;
    outline-offset: 2px;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(78, 255, 208, 0.4);
}

.map-control-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Demo Form Modal
   ========================================================================== */

.demo-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', 'Roboto', 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

.demo-modal.show {
    display: flex;
}

.demo-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(68, 84, 106, 0.9);
    backdrop-filter: blur(8px);
}

.demo-modal-content {
    position: relative;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #4effd0;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(78, 255, 208, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.demo-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(78, 255, 208, 0.3);
}

.demo-modal-header h3 {
    color: #4effd0;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.demo-modal-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.demo-modal-close:hover,
.demo-modal-close:focus {
    background: rgba(78, 255, 208, 0.1);
    color: #4effd0;
    outline: 2px solid #4effd0;
    outline-offset: 2px;
}

.demo-modal-body {
    padding: 2rem;
}

.demo-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: #ffffff;
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(78, 255, 208, 0.3);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    color: #ffffff;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4effd0;
    background: rgba(78, 255, 208, 0.05);
    box-shadow: 0 0 0 3px rgba(78, 255, 208, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.captcha-group {
    margin: 0.5rem 0;
}

.captcha-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(78, 255, 208, 0.2);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.captcha-container:hover {
    border-color: rgba(78, 255, 208, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

.captcha-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: #4effd0;
}

.captcha-container label {
    margin: 0;
    color: #ffffff;
    font-size: 0.95rem;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}

.captcha-icon {
    margin-left: auto;
    font-size: 1.2rem;
    opacity: 0.7;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(78, 255, 208, 0.2);
}

.btn-cancel,
.btn-submit {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-cancel {
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-cancel:hover,
.btn-cancel:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.btn-submit {
    background: #4effd0;
    color: #000000;
    border: 1px solid #4effd0;
}

.btn-submit:hover,
.btn-submit:focus {
    background: #ffffff;
    color: #000000;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 255, 208, 0.3);
    outline: 2px solid #4effd0;
    outline-offset: 2px;
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .demo-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .demo-modal-header,
    .demo-modal-body {
        padding: 1rem 1.5rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-cancel,
    .btn-submit {
        width: 100%;
    }
}

/* ==========================================================================
   Map Fallback
   ========================================================================== */

.map-fallback {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.fallback-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}

.fallback-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
}

.fallback-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: #E87722;
}

.fallback-content p {
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
    line-height: 1.4;
}

.fallback-link {
    display: inline-block;
    background: #E87722;
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.fallback-link:hover,
.fallback-link:focus {
    background: #FFB81C;
    outline: 2px solid #fff;
    outline-offset: 2px;
}
