/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --earth-forest: #6B7F5F;
    --earth-sage: #8B9D83;
    --earth-clay: #A0826D;
    --earth-moss: #6B7F5F;
    --earth-terracotta: #C8956B;
    --earth-sand: #D4C4A8;
    --earth-cream: #F5F1E8;
    --earth-dark: #3A3A3A;
    --page-bg: #ffffff;
    --card-bg: #ffffff;
    --window-pane: #BFE0EC;
    /* Hero text sits on a sky background in both themes, so it stays
       a consistent soft, airy tone rather than inverting like the rest of the page */
    --hero-title-color: #F7FAFD;
    --hero-desc-color: #F0F5F9;
}

/* Dark theme — swapped via data-theme on <html>, see theme-toggle JS */
:root[data-theme="dark"] {
    --earth-forest: #8FAE84;
    --earth-sage: #9DBB94;
    --earth-clay: #D8B199;
    --earth-moss: #8FAE84;
    --earth-terracotta: #E0B183;
    --earth-sand: #2A241E;
    --earth-cream: #1F1B18;
    --earth-dark: #EDE8E0;
    --page-bg: #121010;
    --card-bg: #1F1B18;
    --window-pane: #F4C563;
}

/* Smooth fade between themes */
body, .header, .hero, .about, .status, .contact, .footer,
.status-card, .stat, .contact-form, .service-card, .meter,
.form-group input, .form-group select, .form-group textarea {
    transition: background-color 1.2s ease, color 1.2s ease, border-color 1.2s ease, box-shadow 1.2s ease;
}

.torp-svg .window-pane,
.sky-day,
.sky-night {
    transition: fill 1.2s ease, opacity 1.4s ease;
}

.sky-day  { opacity: 1; }
.sky-night { opacity: 0; }
:root[data-theme="dark"] .sky-day  { opacity: 0; }
:root[data-theme="dark"] .sky-night { opacity: 1; }

:root[data-theme="dark"] body {
    color: var(--earth-dark);
}

:root[data-theme="dark"] .header {
    background: #14121F;
    border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

/* Brand green reads oddly in dark mode's cooler/night palette — neutralize to ink */
:root[data-theme="dark"] .nav-logo a,
:root[data-theme="dark"] .section-header h2,
:root[data-theme="dark"] .about-text h3,
:root[data-theme="dark"] .service-card h3,
:root[data-theme="dark"] .stat h4 {
    color: var(--earth-dark);
}

/* Buttons and footer: swap the green sage/moss gradient for the same
   midnight blue used in the night sky background */
:root[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #3A5A99 0%, #1E3A6B 100%);
    color: #F0F5F9;
}

:root[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 10px 20px rgba(30, 58, 107, 0.5);
}

:root[data-theme="dark"] .footer {
    background: linear-gradient(135deg, #1E1B3F 0%, #0B1026 100%);
}

/* footer headings use --earth-cream for text, which flips dark in dark mode —
   fine against the old green footer, broken against the now-dark background */
:root[data-theme="dark"] .footer-section h3,
:root[data-theme="dark"] .footer-section h4 {
    color: var(--earth-dark);
}

/* Theme toggle button */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--earth-clay);
    color: var(--earth-clay);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: background-color 1.2s ease, color 1.2s ease, border-color 1.2s ease, transform 0.3s ease;
}

.theme-toggle:hover {
    background: var(--earth-clay);
    color: var(--earth-cream);
    transform: rotate(15deg);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: var(--page-bg);
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: #666;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--earth-sage) 0%, var(--earth-moss) 100%);
    color: white;
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(107, 127, 95, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--earth-clay);
    border: 2px solid var(--earth-clay);
}

.btn-secondary:hover {
    background: var(--earth-clay);
    color: white;
    transform: translateY(-2px);
}

/* Header */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    background: var(--earth-cream);
    backdrop-filter: blur(10px);
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    border-bottom: 2px solid rgba(139, 157, 131, 0.2);
}

.navbar {
    padding: 1rem 0;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav-logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--earth-moss);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: var(--earth-clay);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--earth-sage);
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background: linear-gradient(135deg, var(--earth-sage) 0%, var(--earth-moss) 100%);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    width: 25px;
    height: 3px;
    background: var(--earth-moss);
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--earth-cream) 0%, var(--earth-sand) 100%);
    color: var(--earth-dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding-top: 80px;
}

.hero-sky {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.hero-sky svg {
    width: 100%;
    height: 100%;
    display: block;
}

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

.hero-content {
    text-align: center;
    max-width: 100%;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    color: var(--hero-title-color);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55), 0 0 16px rgba(0, 0, 0, 0.35);
}

.hero-description {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: var(--hero-desc-color);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55), 0 0 16px rgba(0, 0, 0, 0.35);
}

/* Section Headers */
.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--earth-moss);
}

.section-header p {
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
    color: var(--earth-clay);
}

/* About Section */
.about {
    padding: 100px 0;
    background: var(--earth-cream);
}

.about-content {
    display: block;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.about-text h3 {
    color: var(--earth-moss);
    margin-bottom: 1.5rem;
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 2rem;
}

.stat {
    text-align: center;
    padding: 1.5rem;
    background: var(--earth-cream);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat h4 {
    font-size: 2rem;
    color: var(--earth-sage);
    margin-bottom: 0.5rem;
}

.stat p {
    color: var(--earth-clay);
    font-size: 0.9rem;
    margin: 0;
}

/* Status Section */
.status {
    padding: 100px 0;
    background: var(--page-bg);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
}

.status-card {
    background: var(--earth-cream);
    padding: 1.5rem;
    border-radius: 10px;
    text-align: left;
    border: 1px solid rgba(160, 130, 109, 0.15);
}

.status-card-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.9rem;
}

.status-card-icon {
    font-size: 0.95rem;
    color: var(--earth-clay);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.status-card h3 {
    color: var(--earth-dark);
    margin-bottom: 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.75;
}

.status-value {
    font-size: 2rem;
    font-weight: 600;
    font-variant-numeric: proportional-nums;
    color: var(--earth-dark);
    margin-bottom: 0.3rem;
    line-height: 1.1;
}

.status-label {
    color: var(--earth-clay);
    font-size: 0.85rem;
    margin: 0;
}

/* Meter — severity-colored progress bar for percentage metrics */
.meter {
    margin-top: 0.9rem;
    height: 6px;
    border-radius: 3px;
    background: var(--earth-sand);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: #cde9cd;
    transition: width 0.6s ease, background-color 0.3s ease;
}

.meter-fill.sev-good    { background: #0ca30c; }
.meter-fill.sev-warning { background: #fab219; }
.meter-fill.sev-serious { background: #ec835a; }
.meter-fill.sev-critical { background: #d03b3b; }

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.service-card {
    background: var(--earth-cream);
    padding: 2.5rem 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(139, 157, 131, 0.2);
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 50px rgba(107, 127, 95, 0.15);
}

.service-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.service-card h3 {
    color: var(--earth-moss);
    margin-bottom: 1rem;
}

.service-card p {
    color: #666;
    line-height: 1.6;
}

/* Contact Section */
.contact {
    padding: 100px 0;
    background: var(--earth-cream);
}

.contact-content {
    display: flex;
    justify-content: center;
}

/* Contact Form */
.contact-form {
    background: var(--earth-cream);
    padding: 2.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--earth-clay);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(139, 157, 131, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--earth-sage);
}

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

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--earth-moss) 0%, var(--earth-forest) 100%);
    color: white;
    padding: 60px 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1.5rem;
    color: var(--earth-cream);
}

.footer-section p {
    color: rgba(250, 248, 241, 0.9);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: rgba(250, 248, 241, 0.9);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section ul li a:hover {
    color: var(--earth-cream);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(250, 248, 241, 0.2);
    color: rgba(250, 248, 241, 0.9);
}

/* Loading and Animation Classes */
.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Scroll to top button */
.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--earth-sage) 0%, var(--earth-moss) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(107, 127, 95, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background: var(--earth-cream);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .nav-toggle.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .about-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.8rem; }
    
    .container {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .btn {
        padding: 10px 25px;
    }
    
    .contact-form {
        padding: 1.5rem;
    }
}

/* Force mobile stacking for hero services */
@media (max-width: 600px) {
    .hero .services-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 30px !important;
    }
}

/* Torp with matrix-style chimney "smoke" */
.torp-widget {
    position: relative;
    width: 220px;
    margin: 2.5rem auto;
}

.torp-svg {
    width: 100%;
    display: block;
}

.matrix-stream {
    position: absolute;
    bottom: 75%;
    left: 50%;
    width: 60px;
    height: 140px;
    overflow: visible;
    pointer-events: none;
}

.matrix-stream span {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 14px;
    color: #00ff41;
    text-shadow: 0 0 6px #00ff41;
    opacity: 0;
    animation: torp-rise 3.2s linear infinite;
}

.matrix-stream span:nth-child(1)  { left: 38%; animation-delay: 0s;    --dx: -15px; }
.matrix-stream span:nth-child(2)  { left: 58%; animation-delay: 0.2s;  --dx: 14px; }
.matrix-stream span:nth-child(3)  { left: 42%; animation-delay: 0.4s;  --dx: -8px; }
.matrix-stream span:nth-child(4)  { left: 62%; animation-delay: 0.6s;  --dx: 18px; }
.matrix-stream span:nth-child(5)  { left: 50%; animation-delay: 0.8s;  --dx: 3px; }
.matrix-stream span:nth-child(6)  { left: 36%; animation-delay: 1.0s;  --dx: -18px; }
.matrix-stream span:nth-child(7)  { left: 56%; animation-delay: 1.2s;  --dx: 10px; }
.matrix-stream span:nth-child(8)  { left: 44%; animation-delay: 1.4s;  --dx: -5px; }
.matrix-stream span:nth-child(9)  { left: 40%; animation-delay: 1.6s;  --dx: -12px; }
.matrix-stream span:nth-child(10) { left: 60%; animation-delay: 1.8s;  --dx: 16px; }
.matrix-stream span:nth-child(11) { left: 48%; animation-delay: 2.0s;  --dx: 0px; }
.matrix-stream span:nth-child(12) { left: 64%; animation-delay: 2.2s;  --dx: 20px; }
.matrix-stream span:nth-child(13) { left: 54%; animation-delay: 2.4s;  --dx: 7px; }
.matrix-stream span:nth-child(14) { left: 34%; animation-delay: 2.6s;  --dx: -20px; }
.matrix-stream span:nth-child(15) { left: 59%; animation-delay: 2.8s;  --dx: 12px; }
.matrix-stream span:nth-child(16) { left: 39%; animation-delay: 3.0s;  --dx: -14px; }

@keyframes torp-rise {
    0%   { bottom: 0; opacity: 0; transform: translateX(-50%) translateX(0) scale(0.8); }
    10%  { opacity: 1; }
    80%  { opacity: 0.8; }
    100% { bottom: 150px; opacity: 0; transform: translateX(-50%) translateX(var(--dx, 10px)) scale(1.15); }
}
