:root {
    --bg-color: #fcfbf7;
    --card-bg: #ffffff;
    --border-color: #1a1a1a;
    --accent-color: #ff5e3a;
    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --maroon-accent: #1a1a1a;
    --font-heading: 'Archivo Black', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    background-image: radial-gradient(circle at 1px 1px, #e5e5e5 1.5px, transparent 0);
    background-size: 32px 32px;
    overflow-x: hidden;
}

/* Page Transitions */
section {
    display: none;
    min-height: 100vh;
    padding: 160px 5% 5rem 5%;
    animation: fadeInProject 0.6s ease-out;
    width: 100%;
    overflow-x: hidden;
}

section.active-page {
    display: block;
}

@keyframes fadeInProject {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1.25rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    border-bottom: 2px solid var(--border-color);
    z-index: 1000;
}

nav .logo {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    text-transform: uppercase;
}

nav > ul {
    display: flex;
    align-items: stretch; /* Standardize item heights */
    list-style: none;
    height: 100%;
}

nav > ul > li {
    display: flex;
}

.dropdown-content li {
    display: block;
}

nav ul > li > a {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: .5rem 1rem;
    border-left: 1px solid var(--border-color);
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    white-space: nowrap;
}

/* Ensure dropdown links don't inherit the header-height flex logic */
.dropdown-content li a {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    min-width: 0 !important;
    padding: 1rem 1.5rem !important;
    text-align: left !important;
    font-size: 0.7rem !important;
    border-left: none !important;
    border-bottom: 2px solid var(--border-color);
}

nav ul > li > a:hover {
    background: var(--accent-color);
    color: white;
}

/* Mobile Menu Toggle */
.menu-btn {
    display: none;
}
.hamburger, .hamburger::before, .hamburger::after {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-primary);
    position: relative;
    transition: all 0.3s;
}
.hamburger::before, .hamburger::after { content: ''; position: absolute; }
.hamburger::before { top: -8px; }
.hamburger::after { top: 8px; }

/* Dropdown */
.dropdown {
    position: relative;
    display: block;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    min-width: 220px;
    list-style: none;
    padding: 0;
    box-shadow: 8px 8px 0 var(--border-color);
    z-index: 1001;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content li {
    width: 100%;
}

.dropdown-content li a {
    border-left: none !important;
    border-bottom: 2px solid var(--border-color);
    width: 100%;
    display: block;
}

.dropdown-content li:last-child a {
    border-bottom: none;
}

/* Hero Content */
.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1900px;
    margin: 0 auto;
}

.hero-content h1 {
    font-family: var(--font-heading);
    font-size: clamp(3rem, 12vw, 8rem);
    line-height: 0.85;
    letter-spacing: -3px;
    text-transform: uppercase;
    text-align: center;
    color: var(--text-primary);
}

.spec-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 3px solid var(--border-color);
    background: white;
    width: 100%;
}

.spec-item {
    padding: 1.5rem;
    border-right: 2px solid var(--border-color);
}

.spec-item:last-child {
    border-right: none;
}

.spec-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

.spec-value {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
}

/* Shared Components */
.section-tag {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--accent-color);
    margin-bottom: 1rem;
    display: block;
}

h2 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    text-transform: uppercase;
    margin-bottom: 3.5rem;
}

.card {
    background: var(--card-bg);
    border: 3px solid var(--border-color);
    padding: 3.5rem;
    position: relative;
    transition: all 0.3s;
    text-align: left;
    margin-bottom: 2rem;
}

.card:hover {
    box-shadow:
        8px 8px 0 var(--accent-color),
        20px 20px 0 var(--border-color);
}

/* Technical Details */
.divider {
    border-top: 2px dashed #ccc;
    margin: 5rem 0;
    width: 100%;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--border-color);
    color: white;
    padding: 1.2rem;
    text-align: center;
    font-size: 0.7rem;
    text-transform: uppercase;
}

td {
    padding: 1.5rem;
    border: 1.5px solid var(--border-color);
    font-size: 0.95rem;
    font-weight: 600;
}

tr:hover td {
    background: var(--accent-color);
    color: white;
}

/* Morphological Chart - Optimized for Standard Table Width Logic */
.morph-table tr:hover .morph-cell {
    background: transparent !important;
    color: inherit !important;
}

.morph-table tr:hover .morph-label {
    background: var(--accent-color) !important;
    color: white !important;
}

.morph-label {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    background: #fcfcfc;
    vertical-align: middle;
    padding: 1.2rem 0.5rem !important;
    text-align: center;
    border-right: 2px solid var(--border-color) !important;
}

.morph-cell {
    text-align: center;
    padding: 1rem 0.5rem;
    vertical-align: middle;
    min-width: 140px; /* Grow to 100% width, min-width for overflow */
}

.morph-cell span {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 0.6rem;
    color: var(--text-primary);
}

.morph-img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Function Tree */
/* New Function Tree Styles - Orange Theme */
.line-dark { background-color: #e65100; }
.line-v { width: 3.5px; }
.line-h { height: 3.5px; }

.arrow-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.arrow-down {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 11px solid #e65100;
    margin-top: -1px;
}

.main-title {
    background-color: #ef6c00;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.2rem 2.5rem;
    border-radius: 0.75rem;
    font-weight: 800;
    font-size: 1.6rem;
    z-index: 10;
    text-align: center;
    letter-spacing: 1px;
}

.category-box {
    background: linear-gradient(to bottom, #ffcc80, #ffb74d);
    border: 2px solid #ffa726;
    color: #4e342e;
    box-shadow: 0 3px 6px -2px rgba(0, 0, 0, 0.1);
    padding: 0.85rem;
    border-radius: 0.6rem;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    z-index: 10;
}

.item-box {
    background: linear-gradient(to bottom, #fff3e0, #ffe0b2);
    border: 1px solid #ffcc80;
    color: #5d4037;
    box-shadow: 0 1px 3px -1px rgba(0, 0, 0, 0.08);
    padding: 0.75rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    z-index: 10;
}

.box-width {
    width: 82%;
    max-width: 180px;
}

.ft-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 850px;
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
}

/* Standardized Premium Table Styling */
.standard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    background: white;
    border: 2px solid var(--border-color);
}

.standard-table th {
    background: #1a1a1a; /* Professional Dark/Black Header */
    color: white;
    padding: 1.2rem;
    text-align: center;
    font-size: 0.85rem;
    text-transform: uppercase;
    font-family: var(--font-heading);
    letter-spacing: 1px;
    border: 1px solid #333;
}

.standard-table td {
    padding: 1.2rem;
    border: 1.5px solid #e0e0e0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
}

.standard-table .left-align {
    text-align: left;
    padding-left: 2rem;
}

.standard-table tr:hover td {
    background: #f8f9fa;
    color: var(--text-primary);
}



/* Concept Generation Tables */
.concept-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2.5rem;
    background: white;
    border: 2px solid var(--border-color);
}

.concept-table th {
    background: #1a1a1a;
    color: white;
    padding: 1.2rem;
    text-align: center;
    font-size: 0.85rem;
    text-transform: uppercase;
    font-family: var(--font-heading);
    border: 1px solid #333;
}

.concept-table td {
    padding: 1.2rem;
    border: 1.5px solid #e0e0e0;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
}

.concept-table .left-align {
    text-align: left;
    padding-left: 2rem;
}

.score-plus {
    color: #2e7d32;
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: 1px;
}

.score-minus {
    color: #c62828;
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: 1px;
}

.score-datum {
    color: #757575;
    font-weight: 800;
    font-size: 1.6rem;
}


.total-row td {
    background: #f8f9fa;
    font-weight: 800;
    font-size: 1rem;
}

.total-row.plus td { color: #2e7d32; background: #e8f5e9; }
.total-row.minus td { color: #c62828; background: #ffebee; }
.total-row.final td { background: #fff3e0; color: #e65100; border-top: 2px solid #e65100; }

/* Justification Tables */
.justification-table td {
    font-size: 0.85rem;
}

.justification-table .design-no {
    background: #e3f2fd;
    font-weight: 800;
    font-size: 1.2rem;
    color: #0d47a1;
    width: 60px;
}

.obj-name {
    background: #f5f5f5;
    font-weight: 700;
    width: 180px;
}

.just-text {
    text-align: left !important;
    padding-left: 1.5rem !important;
    font-style: italic;
    color: #444;
}

/* Design block separator for consolidated table */
.design-separator td {
    border-top: 3px solid #1a1a1a !important;
}

/* Ensure Design No column looks premium */
.justification-table .design-no {
    background: #f8f9fa;
    color: #1a1a1a;
    font-weight: 900;
    font-size: 1.5rem;
    border-right: 2px solid var(--border-color);
    vertical-align: middle;
}

/* Sewage Problem Grids Strategy */
.sewage-grid-1, .sewage-grid-2 {
    display: grid;
    gap: 4rem;
    align-items: start;
}
.sewage-grid-1 {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
        "q1 fig2"
        "q2 fig2";
}
.sewage-grid-2 {
    margin-top: 4rem;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
        "fig3 q3"
        "fig3 q4";
}
.sewage-grid-1 .q1 { grid-area: q1; margin-bottom: 2.5rem; }
.sewage-grid-1 .q2 { grid-area: q2; margin-bottom: 2.5rem; }
.sewage-grid-1 .fig2 { grid-area: fig2; }
.sewage-grid-2 .q3 { grid-area: q3; margin-bottom: 2.5rem; }
.sewage-grid-2 .q4 { grid-area: q4; margin-bottom: 2.5rem; }
.sewage-grid-2 .fig3 { grid-area: fig3; }


/* ------------------------------------- */
/* RESPONSIVE DESIGN                     */
/* ------------------------------------- */
@media (max-width: 900px) {
    .ft-container {
        transform: scale(0.75);
        transform-origin: top center;
        margin-top: 0;
        margin-bottom: -150px; /* Offset the scale white space */
    }
}

@media (max-width: 768px) {
    /* Base spacing & Typography */
    section {
        padding: 160px 4% 3rem 4%;
    }
    
    h1 {
        font-size: clamp(2.2rem, 12vw, 4rem) !important;
        margin-bottom: 2rem !important;
        text-align: center;
        hyphens: auto;
    }

    h2 {
        font-size: 2.2rem;
        margin-bottom: 2rem;
    }

    h3 {
        font-size: clamp(1.4rem, 8vw, 1.8rem) !important;
        hyphens: auto;
    }

    /* Card overrides */
    .card {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem !important;
        overflow-x: hidden;
    }

    /* Navigation stacking & mobile menu */
    nav {
        flex-direction: column;
        padding: 1rem 4%;
        align-items: flex-start;
    }
    
    .menu-btn {
        display: block !important;
    }
    
    nav ul {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
    }
    
    nav ul.active {
        display: flex;
        animation: slideDownMenu 0.3s ease-out;
    }
    
    @keyframes slideDownMenu {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    nav ul li {
        width: 100%;
    }
    
    nav ul li a {
        border-left: none;
        padding: 1rem;
        font-size: 0.8rem;
        display: block;
        width: 100%;
        border-bottom: 1px solid #e0e0e0;
        text-align: left;
    }
    
    nav ul li:last-child a {
        border-bottom: none;
    }
    
    .dropdown-content {
        position: relative;
        min-width: 100%;
        box-shadow: none;
        border-right: none;
        border-left: none;
        border-bottom: 2px solid var(--border-color);
        margin-top: 0.5rem;
    }

    /* Grids & Spec Boxes -> Single Column Override */
    .spec-box {
        grid-template-columns: 1fr !important;
        text-align: center;
    }
    
    .spec-item {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
    }
    
    .spec-item:last-child {
        border-bottom: none;
    }

    /* Global dynamic target for inline grids (Personnel, Concept Gallery, Car Reflection, Identification Activity) */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: repeat(2, 1fr)"],
    div[style*="grid-template-columns: 1fr 1.5fr"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    /* Reordered Layout for Sewage Questions */
    .sewage-grid-1, .sewage-grid-2 {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        margin-top: 2rem;
    }
    .sewage-grid-1 {
        grid-template-areas: 
            "q1"
            "fig2"
            "q2" !important;
    }
    .sewage-grid-2 {
        grid-template-areas: 
            "q3"
            "fig3"
            "q4" !important;
    }
    
    /* Concept Generation Design 5 & Team Roster centered fix on mobile */
    div[style*="grid-column: 1 / span 2"],
    div[style*="grid-column: span 2"] {
        grid-column: 1 !important;
    }
    
    div[style*="flex: 0 0 50%"] {
        flex: 0 0 100% !important;
        border-right: none !important;
        border-left: none !important;
    }

    /* Tables */
    .concept-table, .standard-table, .justification-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-container {
        width: 100%;
        overflow-x: auto;
        position: relative;
    }

    /* Swipe Indicator for Scrollable Containers */
    .table-container::after {
        content: "← SWIPE TO EXPLORE →";
        display: block;
        text-align: center;
        width: 100%;
        font-size: 0.7rem;
        font-family: var(--font-heading);
        font-weight: 800;
        color: #b0b0b0;
        margin-top: 1rem;
        letter-spacing: 2px;
        animation: pulseFade 2s infinite ease-in-out;
    }

    @keyframes pulseFade {
        0% { opacity: 0.4; }
        50% { opacity: 1; }
        100% { opacity: 0.4; }
    }

    /* Function Tree mobile scale */
    .ft-container {
        transform: scale(0.32);
        transform-origin: top left;
        margin-left: calc((100% - 272px) / 2); /* Perfectly center 850px * 0.32 visual width */
        margin-top: 0;
        margin-bottom: -500px;
    }

    /* Force mobile concept gallery images to render as a perfect square */
    div[style*="border: 2px dashed #e0e0e0"] img,
    div[style*="border: 2px dashed"] img {
        height: auto !important;
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }
    
    /* Remove excessive whitespace inside Concept Design boxes on Mobile */
    div[style*="padding: 3rem"][style*="background: white"], 
    div[style*="padding: 3rem;"][style*="background: white;"] {
        padding: 1rem !important;
    }
    
    /* Reduce gap between 'DESIGN X' header and sketch on Mobile */
    div[style*="padding: 3rem"] h4 {
        margin-bottom: 1rem !important;
    }
    
    /* Fix Concept Generation Title Box Overflow on Mobile */
    div[style*="padding: 3rem 4rem 1.5rem 4rem;"] {
        padding: 1.5rem !important;
    }
    
    /* Prevent double-padding on full-bleed cards (like Activity 03) */
    div.card[style*="padding: 0"] {
        padding: 0 !important;
    }
}

/* FUNCTION TREE MODAL CANVAS */
body.modal-open {
    overflow: hidden; /* Stop background scrolling */
}

.ft-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: none;
    flex-direction: column;
}

.ft-modal-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: transform 0.2s;
}

.ft-modal-close:hover {
    transform: scale(1.1);
}

.ft-modal-content {
    flex: 1;
    width: 100%;
    height: 100%; 
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    overflow: hidden; /* Pan and zoom handled purely via transform matrix */
}

.ft-modal-content:active {
    cursor: grabbing;
}

.ft-modal-content .ft-container {
    transform-origin: center center !important;
    will-change: transform; /* Hint for hardware acceleration during pan/zoom */
    /* Remove any margins cloned from the thumbnail version */
    margin: 0 !important;
}

footer {
    padding: 8rem 5% 4rem 5%;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #aaa;
    background: transparent;
}
