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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    --sage-green: #6f9b79;
    --forest-green: #1f3b2d;
    --terracotta: #d7934f;
    --warm-cream: #f6f1e6;
    --earth-brown: #2c241f;
    --soft-sand: #e4d7c3;
    --moss-green: #4f7c66;
    --clay-orange: #f0ba6d;
    --text-dark: #1f1a17;
    --text-light: #fdfaf5;
    --legal-green: #4ea67a;
    --medical-blue: #6ba5c9;
    --decrim-yellow: #efc166;
    --illegal-red: #c45b4d;
    --midnight: #0f1c16;
    --glass-overlay: rgba(18, 31, 26, 0.6);
    --button-gold: #f8d14a;
    --button-gold-deep: #d9a441;
    --text-gold: #ffd700;
    --time-space-font: 'Time and Space', 'Semyon Soviet', 'Merriweather', 'Montserrat', serif;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: url('cannabis-legality-map-background-banner.png') center center / cover no-repeat fixed;
    background-color: var(--midnight);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

/* Global scrollbar styling */
::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-track {
    background: linear-gradient(180deg, rgba(246, 241, 230, 0.4), rgba(79, 124, 102, 0.25));
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--terracotta), var(--forest-green));
    border-radius: 10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--sage-green), var(--forest-green));
}

/* Header Styles */
.header,
.map-section,
.federal-section {
    background: linear-gradient(145deg, rgba(52, 102, 76, 0.9), rgba(98, 146, 116, 0.85));
    border-radius: 20px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.06);
}

.footer {
    background: linear-gradient(145deg, rgba(12, 23, 18, 0.9), rgba(41, 70, 55, 0.85));
    border-radius: 20px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.06);
}

h1, h2 {
    font-family: 'Semyon Soviet', 'Merriweather', 'Montserrat', serif;
    letter-spacing: 0.5px;
    white-space: normal;
    display: block;
    max-width: 100%;
    word-break: keep-all;
}

h3, h4 {
    font-family: 'Merom Sans', 'Merriweather', 'Montserrat', sans-serif;
    letter-spacing: 0.5px;
    white-space: normal;
    display: block;
    max-width: 100%;
    word-break: keep-all;
}

li, span, button {
    color: var(--text-light);
}

p {
    font-family: 'Neomatrix Code Regular', 'Dogica', 'Montserrat', sans-serif;
    color: var(--text-gold);
}

.header {
    backdrop-filter: blur(12px);
    padding: 50px 40px;
    margin-bottom: 50px;
    position: relative;
    overflow: hidden;
}

.hero-banner {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    margin-bottom: 32px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    width: 100%;
}

.hero-banner-image {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    aspect-ratio: unset;
}

.hero-details {
    display: flex;
    flex-direction: column;
    gap: 22px;
    align-items: center;
    text-align: center;
    width: 100%;
}

.hero-text {
    max-width: 780px;
}

.hero-text h1 {
    font-size: clamp(2.1rem, 2.4vw + 1rem, 3.1rem);
    color: var(--text-light);
    text-shadow: 0 10px 35px rgba(0, 0, 0, 0.65);
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.1;
    font-family: var(--time-space-font);
}

.subtitle {
    text-align: center;
    color: var(--text-gold);
    font-size: 1.15em;
    font-style: normal;
    font-weight: 300;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.legend {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    padding-top: 26px;
    border-top: 2px solid var(--sage-green);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1em;
    color: var(--warm-cream);
    font-weight: 500;
}

.legend-color {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    border: 3px solid var(--earth-brown);
    box-shadow: 0 4px 12px rgba(107, 91, 77, 0.2);
}

.legend-color.fully-legal {
    background: var(--legal-green);
    box-shadow: 0 4px 12px rgba(107, 142, 107, 0.4);
}

.legend-color.medical-only {
    background: var(--medical-blue);
    box-shadow: 0 4px 12px rgba(127, 167, 196, 0.4);
}

.legend-color.decriminalized {
    background: var(--decrim-yellow);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
}

.legend-color.illegal {
    background: var(--illegal-red);
    box-shadow: 0 4px 12px rgba(184, 92, 82, 0.4);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
    margin-bottom: 50px;
}

/* Map Section */
.map-section {
    padding: 40px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.map-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.view-toggle {
    background: linear-gradient(135deg, var(--button-gold), var(--button-gold-deep));
    color: #111;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, border-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.view-toggle:hover,
.view-toggle:focus {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
    outline: none;
    border-color: rgba(0, 0, 0, 0.2);
}

.view-toggle:active {
    transform: translateY(0);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.view-toggle.is-global,
.view-toggle.is-territory {
    background: linear-gradient(135deg, #ffd761, #e4b63b);
}

.control-hint {
    color: var(--text-gold);
    font-size: 0.95em;
    opacity: 0.9;
}

.map-container {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.4)),
                url('light-yellow-background.webp') center / cover no-repeat;
    border-radius: 18px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.4);
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.map-container svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(107, 91, 77, 0.15));
}

.state {
    stroke: var(--earth-brown);
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.4s ease;
    opacity: 0.9;
    touch-action: manipulation; /* Prevents double-tap zoom */
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on iOS */
}

.state:hover,
.state:active,
.state:focus {
    opacity: 1;
    filter: brightness(1.1);
    stroke: var(--forest-green);
    stroke-width: 2.5;
    transform: translateY(-2px);
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
    .state:active {
        opacity: 1;
        filter: brightness(1.15);
        stroke: var(--forest-green);
        stroke-width: 3;
    }
}

.territory-marker {
    stroke: var(--earth-brown);
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.95;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.18));
}

.territory-marker:hover,
.territory-marker:active,
.territory-marker:focus {
    opacity: 1;
    filter: brightness(1.1);
    stroke: var(--forest-green);
    stroke-width: 2;
}

.territory-label {
    font-weight: 700;
    fill: var(--earth-brown);
    pointer-events: none;
    font-size: 1em;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.state.fully-legal,
.territory-marker.fully-legal,
.territory-outline.fully-legal {
    fill: var(--legal-green);
}

.state.medical-only,
.territory-marker.medical-only,
.territory-outline.medical-only {
    fill: var(--medical-blue);
}

.state.decriminalized,
.territory-marker.decriminalized,
.territory-outline.decriminalized {
    fill: var(--decrim-yellow);
}

.state.illegal,
.territory-marker.illegal,
.territory-outline.illegal {
    fill: var(--illegal-red);
}

.territory-slides {
    pointer-events: none;
}

.territory-slide {
    pointer-events: all;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.18));
    transform: translate(var(--slide-x, 0), var(--slide-y, 0));
    transform-box: fill-box;
    transform-origin: center;
    will-change: transform, filter;
}

.territory-slide:hover {
    transform: translate(var(--slide-x, 0), var(--slide-y, 0)) translateY(-6px);
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.22));
}

.territory-slide-bg {
    fill: var(--warm-cream);
    stroke: var(--earth-brown);
    stroke-width: 2px;
    rx: 16px;
    ry: 16px;
}

.territory-outline {
    stroke: var(--earth-brown);
    stroke-width: 2.5px;
    fill-opacity: 0.95;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.2));
}

.territory-slide-title {
    font-weight: 700;
    fill: var(--earth-brown);
    font-size: 1.15em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.6px;
}

.map-instruction {
    text-align: center;
    color: var(--text-gold);
    font-style: normal;
    font-size: 1em;
    font-weight: 300;
}

.map-error {
    color: #b34c4c;
    text-align: center;
    padding: 32px 16px;
    font-weight: 600;
    background: #fff5f5;
    border: 1px solid #e2b4b4;
    border-radius: 8px;
}

/* Federal Section */
.federal-section {
    padding: 40px;
    max-height: 700px;
    overflow-y: auto;
    scrollbar-width: thick;
    scrollbar-color: var(--forest-green) var(--warm-cream);
}

.federal-section h2 {
    color: var(--clay-orange);
    margin-bottom: 30px;
    text-align: center;
    font-size: clamp(1.4rem, 0.8vw + 1rem, 1.9rem);
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    font-weight: 700;
    line-height: 1.1;
    font-family: var(--time-space-font);
}

.federal-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    background: url('light-yellow-background.webp') center / cover no-repeat;
    padding: 20px;
    border-radius: 16px;
}

.federal-item {
    background: linear-gradient(135deg, rgba(246, 241, 230, 0.9), rgba(228, 215, 195, 0.85));
    padding: 25px;
    border-radius: 14px;
    border-left: 5px solid var(--terracotta);
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.federal-item:hover {
    transform: translateY(-4px);
    border-left-color: var(--forest-green);
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.35);
}

.federal-item-image {
    width: 100%;
    max-width: 150px;
    height: auto;
    border-radius: 8px;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 2px 8px rgba(107, 91, 77, 0.15);
    background: url('light-yellow-background.webp') center / cover no-repeat;
    padding: 10px;
}

.federal-item h3 {
    color: var(--forest-green);
    margin-bottom: 12px;
    font-size: clamp(1.1rem, 0.9vw + 0.9rem, 1.45rem);
    font-weight: 500;
    line-height: 1.15;
}

.federal-item p {
    margin-bottom: 10px;
    line-height: 1.7;
    font-size: 0.98em;
    color: var(--text-dark);
}

.federal-item strong {
    color: var(--forest-green);
    font-weight: 600;
}

.federal-section::-webkit-scrollbar {
    width: 18px;
}

.federal-section::-webkit-scrollbar-track {
    background: linear-gradient(180deg, rgba(244, 239, 227, 0.9), rgba(232, 220, 196, 0.8));
    border-radius: 12px;
    border: 3px solid rgba(107, 91, 77, 0.3);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.12);
}

.federal-section::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--forest-green), var(--sage-green));
    border-radius: 10px;
    border: 4px solid rgba(244, 239, 227, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.federal-section::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--legal-green), var(--forest-green));
}

.federal-section::-webkit-scrollbar-thumb:active {
    background: linear-gradient(135deg, var(--terracotta), var(--forest-green));
    border-color: rgba(232, 220, 196, 0.95);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(107, 91, 77, 0.85);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(145deg, rgba(52, 102, 76, 0.9), rgba(98, 146, 116, 0.85));
    margin: 5% auto;
    padding: 50px;
    border: 4px solid var(--sage-green);
    border-radius: 25px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(107, 91, 77, 0.3);
    animation: slideIn 0.4s ease;
}

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

.close {
    color: var(--earth-brown);
    float: right;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
}

.close:hover {
    color: var(--terracotta);
    transform: rotate(90deg);
}

#stateName {
    color: var(--text-gold);
    text-align: center;
    margin-bottom: 35px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(107, 91, 77, 0.1);
    font-weight: 400;
    font-family: var(--time-space-font);
}

.state-info-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    background: url('light-yellow-background.webp') center / cover no-repeat;
    padding: 20px;
    border-radius: 16px;
}

.info-section {
    background: rgba(255, 255, 255, 0.6);
    padding: 25px;
    border-radius: 15px;
    border-left: 5px solid var(--terracotta);
    box-shadow: 0 2px 8px rgba(107, 91, 77, 0.1);
}

.info-section h3 {
    color: var(--forest-green);
    margin-bottom: 18px;
    font-size: 1.5em;
    font-weight: 500;
}

.info-section h4 {
    color: #000;
    margin-top: 18px;
    margin-bottom: 12px;
    font-weight: 600;
}

.info-section ul {
    margin-left: 20px;
    line-height: 1.9;
}

.info-section li {
    margin-bottom: 10px;
    color: var(--text-dark);
}

.info-section p {
    color: #000;
    line-height: 1.7;
}

.status-badge {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    margin-bottom: 18px;
    box-shadow: 0 4px 12px rgba(107, 91, 77, 0.2);
    border: 2px solid var(--earth-brown);
}

.status-legal {
    background: var(--legal-green);
    color: white;
}

.status-medical {
    background: var(--medical-blue);
    color: white;
}

.status-decrim {
    background: var(--decrim-yellow);
    color: var(--text-dark);
}

.status-illegal {
    background: var(--illegal-red);
    color: white;
}

/* Footer */
.footer {
    padding: 35px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.footer-branding {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.footer-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.logo-separator {
    color: var(--text-gold);
    font-weight: 800;
    font-size: 2rem;
    line-height: 1;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.footer-logo {
    height: 64px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.footer-logo:hover {
    transform: scale(1.03);
}

.footer-logo-ismokeshop {
    height: 70px;
}

.footer p {
    margin-bottom: 12px;
    font-size: 1em;
    color: var(--text-gold);
}

.footer strong {
    color: var(--text-gold);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    font-weight: 600;
}

.footer a {
    color: var(--sage-green);
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.footer a:hover {
    color: var(--terracotta);
    border-bottom: 2px solid var(--terracotta);
}

.disclaimer {
    font-size: 0.9em;
    color: var(--text-gold);
    font-style: normal;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--sage-green);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .federal-section {
        max-height: none;
    }

    .legend {
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 20px;
    }

    .logo-section h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    .legend {
        gap: 10px;
    }

    .legend-item {
        font-size: 0.85em;
    }

    .legend-color {
        width: 25px;
        height: 25px;
    }

    .map-section, .federal-section {
        padding: 20px;
    }

    .map-container {
        min-height: 300px;
        padding: 15px;
    }

    .map-instruction {
        font-size: 0.9em;
    }

    .modal-content {
        width: 95%;
        padding: 25px;
        margin: 10% auto;
        max-height: 80vh;
    }

    #stateName {
        font-size: 1.6em;
    }

    .info-section h3 {
        font-size: 1.2em;
    }

    .federal-section {
        max-height: 500px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .header {
        padding: 15px;
        margin-bottom: 20px;
    }

    .logo-section h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    .subtitle {
        font-size: 0.9em;
        margin-bottom: 20px;
    }

    .legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding-top: 15px;
    }

    .map-section {
        padding: 15px;
    }

    .map-container {
        min-height: 250px;
        padding: 10px;
    }

    .map-instruction {
        font-size: 0.85em;
    }

    .federal-section {
        padding: 15px;
        max-height: 400px;
    }

    .federal-section h2 {
        font-size: 1.4em;
        margin-bottom: 20px;
    }

    .federal-item {
        padding: 15px;
    }

    .federal-item h3 {
        font-size: 1.1em;
    }

    .modal-content {
        padding: 20px;
        margin: 5% auto;
        max-height: 90vh;
    }

    #stateName {
        font-size: 1.4em;
        margin-bottom: 25px;
    }

    .info-section {
        padding: 20px;
    }

    .info-section h3 {
        font-size: 1.1em;
    }

    .close {
        font-size: 32px;
    }
}

/* Landscape orientation for mobile devices */
@media (max-width: 896px) and (orientation: landscape) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 15px 20px;
        margin-bottom: 20px;
    }

    .logo-section h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.95em;
        margin-bottom: 15px;
    }

    .legend {
        padding-top: 15px;
    }

    .main-content {
        gap: 20px;
    }

    .map-container {
        min-height: 350px;
    }

    .federal-section {
        max-height: 350px;
    }

    .modal-content {
        margin: 2% auto;
        max-height: 95vh;
        padding: 20px;
    }

    #stateName {
        font-size: 1.5em;
        margin-bottom: 20px;
    }

    .info-section {
        padding: 15px;
    }
}

/* Improved scrolling for touch devices */
.federal-section,
.modal-content {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Focus styles for accessibility */
.state:focus {
    outline: 3px solid var(--forest-green);
    outline-offset: 2px;
}

/* Improve button touch targets on mobile */
@media (max-width: 768px) {
    .close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
