/* Retro Terminal Styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark mode (default) */
    --bg-color: #2a2a2a;
    --text-color: #B87333;
    --text-dim: #8B6F47;
    --border-color: #B87333;
    --glow-color: rgba(184, 115, 51, 0.15);
    --hover-glow: rgba(184, 115, 51, 0.25);
    --svg-bg: #1a1a1a;
    --overlay-bg: rgba(0, 0, 0, 0.2);
    --input-bg: rgba(0, 0, 0, 0.3);
    --vector-bg: rgba(0, 0, 0, 0.3);
}

/* Light mode */
@media (prefers-color-scheme: light) {
    :root:not(.dark-mode) {
        --bg-color: #E8E3D8;
        --text-color: #2a2a2a;
        --text-dim: #4a4a4a;
        --border-color: #6B5B4A;
        --glow-color: rgba(107, 91, 74, 0.1);
        --hover-glow: rgba(107, 91, 74, 0.15);
        --svg-bg: #D4CDC0;
        --overlay-bg: rgba(255, 255, 255, 0.3);
        --input-bg: rgba(255, 255, 255, 0.5);
        --vector-bg: rgba(255, 255, 255, 0.4);
    }
}

/* Manual light mode class */
.light-mode {
    --bg-color: #E8E3D8;
    --text-color: #2a2a2a;
    --text-dim: #4a4a4a;
    --border-color: #6B5B4A;
    --glow-color: rgba(107, 91, 74, 0.1);
    --hover-glow: rgba(107, 91, 74, 0.15);
    --svg-bg: #D4CDC0;
    --overlay-bg: rgba(255, 255, 255, 0.3);
    --input-bg: rgba(255, 255, 255, 0.5);
    --vector-bg: rgba(255, 255, 255, 0.4);
}

/* Manual dark mode class (overrides light preference) */
.dark-mode {
    --bg-color: #2a2a2a;
    --text-color: #B87333;
    --text-dim: #8B6F47;
    --border-color: #B87333;
    --glow-color: rgba(184, 115, 51, 0.15);
    --hover-glow: rgba(184, 115, 51, 0.25);
    --svg-bg: #1a1a1a;
    --overlay-bg: rgba(0, 0, 0, 0.2);
    --input-bg: rgba(0, 0, 0, 0.3);
    --vector-bg: rgba(0, 0, 0, 0.3);
}

html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scan line effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: -1;
    opacity: 0.3;
    animation: scanline 8s linear infinite;
}

/* Disable scanline overlay completely on mobile - it blocks touch on iOS Safari */
@media (max-width: 768px) {
    body::before {
        display: none !important;
        content: none !important;
    }
}

html.light-mode body::before {
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.05),
        rgba(255, 255, 255, 0.05) 1px,
        transparent 1px,
        transparent 2px
    );
    opacity: 0.2;
}

@keyframes scanline {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(4px);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Navigation */
.nav {
    display: flex;
    gap: 20px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--text-color);
    text-shadow: 0 0 4px var(--glow-color);
}

.nav-link.active {
    color: var(--text-color);
    text-shadow: 0 0 4px var(--glow-color);
}

.nav-link.active::after {
    content: ' >';
}

/* Main Content */
.main-content {
    padding: 10px 0; /* Reduced top padding to bring hero closer to nav */
}

.title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 8px var(--glow-color);
}

/* Hero Section */
.hero-section {
    position: relative;
    text-align: center;
    margin-bottom: 60px;
    padding: 30px 0 80px 0; /* Reduced top padding to move closer to nav */
    min-height: 680px; /* Increased to prevent bottom cutoff */
    overflow: hidden;
}

.hero-waveform-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.4; /* Increased from 0.3 for better visibility */
    pointer-events: none;
}

.hero-waveform-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 1;
    padding: 20px;
    background: linear-gradient(
        to bottom,
        rgba(42, 42, 42, 0.5) 0%,
        rgba(42, 42, 42, 0.4) 50%,
        rgba(42, 42, 42, 0.5) 100%
    );
    backdrop-filter: blur(0.5px);
    border: 1px solid rgba(184, 115, 51, 0.2);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(184, 115, 51, 0.1);
    margin: 0 auto;
    max-width: 90%;
}

html.light-mode .hero-content {
    background: linear-gradient(
        to bottom,
        rgba(232, 227, 216, 0.35) 0%,
        rgba(232, 227, 216, 0.3) 50%,
        rgba(232, 227, 216, 0.35) 100%
    );
    border: 1px solid rgba(107, 91, 74, 0.3);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2), inset 0 0 20px rgba(107, 91, 74, 0.1);
    backdrop-filter: blur(0.5px);
}

.hero-title {
    font-size: 48px;
    font-weight: 600;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 
        0 0 4px var(--text-color),
        0 2px 4px rgba(0, 0, 0, 0.8),
        2px 2px 4px rgba(0, 0, 0, 0.6);
    color: var(--text-color);
    position: relative;
}

html.light-mode .hero-title {
    text-shadow: 
        0 0 3px var(--text-color),
        0 2px 4px rgba(0, 0, 0, 0.3),
        2px 2px 4px rgba(0, 0, 0, 0.2);
}

.hero-tagline {
    font-size: 18px;
    color: var(--text-color);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 400;
    text-shadow: 
        0 0 3px var(--text-color),
        0 1px 2px rgba(0, 0, 0, 0.7);
    position: relative;
}

html.light-mode .hero-tagline {
    text-shadow: 
        0 0 2px var(--text-color),
        0 1px 2px rgba(0, 0, 0, 0.2);
}

.section-title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-color);
}

.text-content {
    margin-top: 15px;
}

/* Services Preview */
.services-preview {
    margin-bottom: 60px;
}

.service-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.service-card {
    display: block;
    padding: 25px;
    border: 1px solid var(--border-color);
    background-color: var(--overlay-bg);
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 0 8px var(--glow-color);
}

.service-card:hover {
    box-shadow: 0 0 16px var(--hover-glow);
    transform: translateY(-2px);
    border-color: var(--text-color);
}

.service-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-color);
}

.service-card-desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
}

.services-link {
    text-align: center;
    margin-top: 30px;
}

.link-button {
    display: inline-block;
    padding: 12px 30px;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 0 8px var(--glow-color);
}

.link-button:hover {
    box-shadow: 0 0 16px var(--hover-glow);
    background-color: var(--overlay-bg);
}

.vector-section {
    margin-top: 60px;
}

/* Services Page Styles */
.service-section {
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--overlay-bg);
    box-shadow: 0 0 8px var(--glow-color);
    transition: all 0.3s ease;
}

.service-section:hover {
    box-shadow: 0 0 12px var(--hover-glow);
}

.service-header {
    width: 100%;
    padding: 20px 25px;
    background-color: transparent;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--text-color);
    transition: all 0.3s ease;
    /* iOS Safari touch handling */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.service-header:hover {
    background-color: rgba(184, 115, 51, 0.05);
}

.service-header:active {
    background-color: rgba(184, 115, 51, 0.1);
}

.service-name {
    font-size: 18px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.service-toggle {
    font-size: 24px;
    font-weight: 300;
    transition: transform 0.3s ease;
    color: var(--text-dim);
}

.service-header[aria-expanded="true"] .service-toggle {
    transform: rotate(45deg);
}

.service-content {
    padding: 0 25px 25px 25px;
    border-top: 1px solid var(--border-color);
    margin-top: 0;
    /* Hidden by default */
    display: none;
}

.service-content.expanded {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

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

/* Mobile padding adjustments */
@media (max-width: 768px) {
    .service-content.expanded {
        padding: 0 15px 20px 15px;
    }
}

@media (max-width: 480px) {
    .service-content.expanded {
        padding: 0 10px 15px 10px;
    }
}

/* Canvas visibility in accordion */
.service-content canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.service-description {
    margin-bottom: 30px;
    padding-top: 20px;
}

.subsection-title {
    font-size: 16px;
    font-weight: 500;
    margin: 30px 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-color);
}

/* 3D Container for Service SVGs */
.service-3d-container {
    width: 100%;
    height: 400px;
    margin: 30px 0;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    position: relative;
    overflow: hidden;
}

.service-3d-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.project-timeline-container {
    width: 100%;
    height: 400px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.project-timeline-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.tcc-coordination-container {
    width: 100%;
    height: 400px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.tcc-coordination-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.load-flow-container {
    width: 100%;
    height: 400px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.load-flow-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.power-system-waveform-container {
    width: 100%;
    height: 400px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.power-system-waveform-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

.hydropower-generator-container {
    width: 100%;
    height: 400px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.hydropower-generator-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

.hydropower-control-board-container {
    width: 100%;
    height: 680px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.hydropower-control-board-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

.nerc-compliance-container {
    width: 100%;
    height: 600px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.nerc-compliance-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

.automation-pipeline-container {
    width: 100%;
    height: 600px;
    margin: 30px 0;
    padding: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    box-shadow: 0 0 8px var(--glow-color);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.automation-pipeline-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

/* COMTRADE Section */
.comtrade-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.comtrade-upload {
    margin: 20px 0;
}

/* Waveform Container */
.waveform-container {
    margin-top: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    padding: 20px;
}

#waveform-canvas {
    width: 100%;
    height: 400px;
    display: block;
    background-color: var(--svg-bg);
}

.waveform-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.waveform-btn {
    padding: 8px 20px;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.waveform-btn:hover {
    background-color: rgba(184, 115, 51, 0.1);
    box-shadow: 0 0 6px var(--glow-color);
}

.waveform-scrubber {
    flex: 1;
    height: 4px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.waveform-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background-color: var(--text-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    box-shadow: 0 0 4px var(--glow-color);
}

.waveform-scrubber::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background-color: var(--text-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    box-shadow: 0 0 4px var(--glow-color);
}

.waveform-time {
    font-size: 12px;
    color: var(--text-dim);
    font-family: 'IBM Plex Mono', monospace;
    min-width: 60px;
    text-align: right;
}

.content-section {
    margin-bottom: 40px;
}

.text {
    font-size: 14px;
    margin-bottom: 15px;
    color: var(--text-color);
    line-height: 1.8;
}

/* Terminal Frame */
.terminal-frame {
    border: 1px solid var(--border-color);
    padding: 20px;
    margin: 30px 0;
    background-color: var(--overlay-bg);
    box-shadow: 0 0 8px var(--glow-color);
    transition: all 0.3s ease;
}

.terminal-frame:hover {
    box-shadow: 0 0 12px var(--hover-glow);
}

.terminal-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    color: var(--text-dim);
}

.vector-container {
    border: 1px solid var(--border-color);
    background-color: var(--vector-bg);
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
}

#vector-svg {
    display: block;
    width: 100%;
    height: 400px;
    background-color: var(--svg-bg);
}

/* Upload Section */
.upload-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-input {
    display: none;
}

.file-label {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-label:hover {
    background-color: rgba(184, 115, 51, 0.1);
    box-shadow: 0 0 6px var(--glow-color);
}

html.light-mode .file-label:hover {
    background-color: rgba(107, 91, 74, 0.1);
}

/* Contact Form */
.contact-form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 25px;
}

.form-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: var(--text-dim);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--text-color);
    box-shadow: 0 0 6px var(--glow-color);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.submit-btn {
    padding: 12px 30px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background-color: rgba(184, 115, 51, 0.1);
    box-shadow: 0 0 8px var(--hover-glow);
}

html.light-mode .submit-btn:hover {
    background-color: rgba(107, 91, 74, 0.1);
}

.submit-btn:active {
    transform: translateY(1px);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-message {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.form-message.success {
    border-color: #00AA00;
    color: #00AA00;
    background-color: rgba(0, 170, 0, 0.1);
}

.form-message.error {
    border-color: #CC0000;
    color: #CC0000;
    background-color: rgba(204, 0, 0, 0.1);
}

html.light-mode .form-message.success {
    border-color: #00AA00;
    background-color: rgba(0, 170, 0, 0.05);
}

html.light-mode .form-message.error {
    border-color: #CC0000;
    background-color: rgba(204, 0, 0, 0.05);
}

/* ============================================
   MOBILE RESPONSIVENESS OPTIMIZATION
   ============================================ */

/* Hamburger Menu Button - Hidden by default, only show on mobile */
.mobile-menu-toggle {
    display: none !important;
    position: fixed;
    top: 15px;
    left: 15px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1002;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    padding: 0;
    /* iOS Safari touch handling */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.mobile-menu-overlay {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block !important;
    opacity: 1;
    pointer-events: auto;
}

.mobile-nav {
    display: none !important;
    visibility: hidden !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 80%;
    height: 100%;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    padding: 70px 20px 20px 20px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1002;
    overflow-y: auto;
    opacity: 0;
}

.mobile-menu-overlay.active .mobile-nav {
    display: block !important;
    visibility: visible !important;
    transform: translateX(0);
    opacity: 1;
}

.mobile-menu-toggle:hover {
    border-color: var(--text-color);
    box-shadow: 0 0 6px var(--glow-color);
}

.mobile-menu-toggle:active {
    opacity: 0.8;
}

.mobile-menu-toggle::before {
    content: '☰';
}

.mobile-menu-toggle.active::before {
    content: '✕';
}

.mobile-nav .nav-link {
    display: block;
    padding: 15px 0;
    font-size: 16px;
    min-height: 44px;
    border-bottom: 1px solid rgba(184, 115, 51, 0.2);
}

.mobile-nav .nav-link:last-child {
    border-bottom: none;
}

/* Desktop - Ensure mobile menu is completely hidden */
@media (min-width: 769px) {
    .mobile-menu-toggle,
    .mobile-menu-overlay,
    .mobile-nav {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Tablet Breakpoint (1024px) */
@media (max-width: 1024px) {
    .hero-title {
        font-size: 40px;
        letter-spacing: 3px;
    }

    .hero-tagline {
        font-size: 16px;
    }

    .title {
        font-size: 28px;
    }

    .section-title {
        font-size: 18px;
    }

    .project-timeline-container,
    .tcc-coordination-container,
    .load-flow-container,
    .power-system-waveform-container,
    .hydropower-generator-container,
    .service-3d-container {
        height: 350px;
        padding: 20px;
    }

    .hydropower-control-board-container {
        height: 600px;
        padding: 20px;
    }

    .nerc-compliance-container {
        height: 500px;
        padding: 20px;
    }

    .automation-pipeline-container {
        height: 500px;
        padding: 20px;
    }
}

/* Mobile Landscape Breakpoint (768px) */
@media (max-width: 768px) {
    body {
        line-height: 1.7;
    }

    .container {
        padding: 15px;
    }

    /* Mobile Menu */
    .mobile-menu-toggle {
        display: flex !important;
    }

    /* mobile-menu-overlay stays display:none until .active is added by JS */

    /* mobile-nav visibility is controlled by .mobile-menu-overlay.active */

    .nav {
        display: none;
    }

    /* Typography */
    .hero-title {
        font-size: 32px;
        letter-spacing: 2px;
        margin-bottom: 15px;
    }

    .hero-tagline {
        font-size: 14px;
        letter-spacing: 1.5px;
    }

    .title {
        font-size: 24px;
        letter-spacing: 2px;
        margin-bottom: 25px;
    }

    .section-title {
        font-size: 18px;
        letter-spacing: 1.5px;
        margin-bottom: 15px;
    }

    .text {
        font-size: 15px;
        line-height: 1.8;
        margin-bottom: 12px;
    }

    /* Hero Section */
    .hero-section {
        min-height: auto;
        padding: 15px 0 50px 0;
        margin-bottom: 40px;
    }

    .hero-content {
        max-width: 95%;
        padding: 15px;
    }

    /* Service Cards */
    .service-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .service-card {
        padding: 20px;
    }

    .service-card-title {
        font-size: 15px;
    }

    .service-card-desc {
        font-size: 13px;
    }

    /* Canvas Containers - IMPROVED mobile sizing */
    .project-timeline-container,
    .tcc-coordination-container,
    .load-flow-container,
    .power-system-waveform-container,
    .hydropower-generator-container,
    .service-3d-container {
        height: 280px;
        padding: 15px;
        margin: 20px 0;
        min-height: 220px;
    }

    .hydropower-control-board-container {
        /* 8 meters in 2-col grid + breaker needs more height on mobile */
        height: 600px;
        padding: 15px;
        margin: 20px 0;
        min-height: 500px;
    }

    .nerc-compliance-container {
        height: 350px;
        padding: 15px;
        margin: 20px 0;
        min-height: 280px;
    }

    .automation-pipeline-container {
        height: 350px;
        padding: 15px;
        margin: 20px 0;
        min-height: 280px;
    }
    
    /* Canvas responsive behavior */
    .project-timeline-container canvas,
    .tcc-coordination-container canvas,
    .load-flow-container canvas,
    .power-system-waveform-container canvas,
    .hydropower-generator-container canvas,
    .service-3d-container canvas,
    .hydropower-control-board-container canvas,
    .nerc-compliance-container canvas,
    .automation-pipeline-container canvas {
        display: block;
        max-width: 100%;
        /* Touch action for better mobile interaction */
        touch-action: pan-x pan-y;
    }

    #waveform-canvas {
        height: 280px;
    }

    #vector-svg {
        height: 280px;
    }

    /* Touch Targets */
    .nav-link,
    .link-button,
    .submit-btn,
    .waveform-btn,
    .file-label {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .service-header {
        min-height: 60px;
        padding: 15px 20px;
    }

    /* Forms */
    .form-input,
    .form-textarea {
        padding: 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .form-label {
        font-size: 13px;
    }

    .submit-btn {
        padding: 14px 30px;
        font-size: 13px;
        width: 100%;
    }

    /* Spacing */
    .content-section {
        margin-bottom: 30px;
    }

    .services-preview {
        margin-bottom: 40px;
    }

    .main-content {
        padding: 5px 0;
    }

    .terminal-frame {
        padding: 15px;
        margin: 20px 0;
    }

    .upload-section {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .file-label {
        text-align: center;
        padding: 12px 20px;
    }

    .link-button {
        padding: 14px 25px;
        font-size: 13px;
    }

    .service-content {
        padding: 0 20px 20px 20px;
    }

    .service-description {
        padding-top: 15px;
        margin-bottom: 20px;
    }
}

/* Mobile Portrait Breakpoint (480px) */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    /* Typography */
    .hero-title {
        font-size: 28px;
        letter-spacing: 1.5px;
    }

    .hero-tagline {
        font-size: 13px;
        letter-spacing: 1px;
    }

    .title {
        font-size: 20px;
        letter-spacing: 1.5px;
        margin-bottom: 20px;
    }

    .section-title {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .text {
        font-size: 15px;
        line-height: 1.8;
    }

    .service-card-title {
        font-size: 14px;
    }

    .service-card-desc {
        font-size: 12px;
    }

    .service-name {
        font-size: 16px;
    }

    /* Hero Section */
    .hero-section {
        padding: 10px 0 40px 0;
        margin-bottom: 30px;
    }

    .hero-content {
        padding: 12px;
    }

    /* Canvas Containers - Aggressive mobile sizing */
    .project-timeline-container,
    .tcc-coordination-container,
    .load-flow-container,
    .power-system-waveform-container,
    .hydropower-generator-container,
    .service-3d-container {
        height: 240px;
        padding: 12px;
        margin: 15px 0;
        min-height: 180px;
    }

    .hydropower-control-board-container {
        height: 550px;
        padding: 12px;
        margin: 15px 0;
        min-height: 450px;
    }

    .nerc-compliance-container {
        height: 260px;
        padding: 12px;
        margin: 15px 0;
        min-height: 200px;
    }

    .automation-pipeline-container {
        height: 260px;
        padding: 12px;
        margin: 15px 0;
        min-height: 200px;
    }

    #waveform-canvas {
        height: 240px;
    }

    #vector-svg {
        height: 240px;
    }

    /* Spacing */
    .content-section {
        margin-bottom: 25px;
    }

    .services-preview {
        margin-bottom: 30px;
    }

    .service-cards {
        gap: 12px;
        margin-bottom: 20px;
    }

    .service-card {
        padding: 15px;
    }

    .services-link {
        margin-top: 20px;
    }
}

/* Small Mobile Breakpoint (360px) */
@media (max-width: 360px) {
    .container {
        padding: 8px;
    }

    /* Typography */
    .hero-title {
        font-size: 24px;
        letter-spacing: 1px;
    }

    .hero-tagline {
        font-size: 12px;
    }

    .title {
        font-size: 18px;
    }

    .section-title {
        font-size: 15px;
    }

    .text {
        font-size: 14px;
    }

    /* Canvas Containers - Smallest screens */
    .project-timeline-container,
    .tcc-coordination-container,
    .load-flow-container,
    .power-system-waveform-container,
    .hydropower-generator-container,
    .service-3d-container {
        height: 200px;
        padding: 10px;
        margin: 12px 0;
        min-height: 160px;
    }

    .hydropower-control-board-container {
        height: 260px;
        padding: 10px;
        margin: 12px 0;
        min-height: 220px;
    }

    .nerc-compliance-container {
        height: 220px;
        padding: 10px;
        margin: 12px 0;
        min-height: 180px;
    }

    .automation-pipeline-container {
        height: 220px;
        padding: 10px;
        margin: 12px 0;
        min-height: 180px;
    }

    #waveform-canvas {
        height: 200px;
    }

    #vector-svg {
        height: 200px;
    }

    /* Mobile Menu */
    .mobile-nav {
        width: 260px;
    }
}

/* ============================================
   MOBILE FIXES - IMPROVED SCALING & SIZING
   Added by Porco for Jordan - 2026-01-25
   ============================================ */

/* Prevent horizontal scroll on all mobile */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .container {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Ensure images and media scale properly (NOT canvas - JS controls canvas sizing) */
    img, svg, video {
        max-width: 100%;
        height: auto;
    }

    /* Better canvas container scaling */
    .hero-waveform-container {
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }

    /* Ensure service sections don't overflow */
    .service-section {
        max-width: 100%;
        overflow-x: hidden;
    }

    .service-content {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Canvas touch improvements */
    canvas {
        touch-action: pan-x pan-y;
    }
}

/* Extra small screens - aggressive scaling */
@media (max-width: 375px) {
    .hero-title {
        font-size: 22px;
        letter-spacing: 0.5px;
        word-break: break-word;
    }

    .hero-tagline {
        font-size: 11px;
        letter-spacing: 0.5px;
    }

    .hero-content {
        padding: 10px;
        max-width: 98%;
    }

    .hero-section {
        min-height: auto;
        padding: 8px 0 30px 0;
    }

    /* Smaller canvas on tiny screens */
    .project-timeline-container,
    .tcc-coordination-container,
    .load-flow-container,
    .power-system-waveform-container,
    .hydropower-generator-container,
    .service-3d-container {
        height: 180px;
        padding: 10px;
        min-height: 150px;
    }

    .hydropower-control-board-container {
        height: 260px;
        min-height: 220px;
    }

    .nerc-compliance-container {
        height: 220px;
        min-height: 200px;
    }

    .automation-pipeline-container {
        height: 220px;
        min-height: 200px;
    }

    /* Service cards tighter on small screens */
    .service-card {
        padding: 12px;
    }

    .service-card-title {
        font-size: 13px;
    }

    .service-card-desc {
        font-size: 11px;
    }

    .service-name {
        font-size: 14px;
    }

    .service-header {
        padding: 12px 15px;
    }
}

/* Landscape mobile - ensure proper height */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
        padding: 10px 0 30px 0;
    }

    .project-timeline-container,
    .tcc-coordination-container,
    .load-flow-container,
    .power-system-waveform-container,
    .hydropower-generator-container,
    .service-3d-container {
        height: 220px;
    }

    .hydropower-control-board-container {
        height: 300px;
    }
}

/* Text Readability Improvements */
@media (max-width: 768px) {
    .text {
        word-break: break-word;
        hyphens: auto;
    }

    .service-card-desc,
    .service-description .text {
        word-break: break-word;
    }
}

/* Theme Toggle Button - Extremely Subtle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-dim);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.theme-toggle:hover {
    opacity: 0.7;
    border-color: var(--text-color);
    color: var(--text-color);
}

.theme-toggle:active {
    opacity: 1;
}

.theme-toggle::before {
    content: '☀';
    font-size: 14px;
}

html.dark-mode .theme-toggle::before {
    content: '☀';
}

html.light-mode .theme-toggle::before {
    content: '☾';
}

/* SVG placeholder text color */
.svg-placeholder-text {
    fill: var(--text-color);
}

/* Theme Toggle Mobile Positioning */
@media (max-width: 768px) {
    .theme-toggle {
        top: 15px;
        right: 15px;
        width: 44px;
        height: 44px;
        font-size: 16px;
        opacity: 0.8;
    }
    
    .theme-toggle:active {
        opacity: 1;
        transform: scale(0.95);
    }
}

@media (max-width: 480px) {
    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

/* Touch Active States */
@media (max-width: 768px) {
    .nav-link:active,
    .link-button:active,
    .submit-btn:active,
    .waveform-btn:active,
    .file-label:active,
    .service-header:active {
        opacity: 0.7;
        transform: scale(0.98);
    }

    .service-card:active {
        transform: translateY(0);
        box-shadow: 0 0 8px var(--glow-color);
    }
}

