/* ROOF ENGINEERING SYSTEM STYLES (REFINED) */

.roof-system-section {
    padding: 80px 0;
    overflow: hidden;
    background: linear-gradient(135deg, #f9fbfd 0%, #f1f4f8 100%);
    font-family: 'Manrope', sans-serif;
}

.roof-sys-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.roof-sys-header {
    text-align: center;
    margin-bottom: 60px;
    max-width: 800px;
}

.sys-title {
    font-size: 38px;
    line-height: 1.2;
    margin-bottom: 15px;
    color: #222;
    font-weight: 300;
}

.sys-title .accent-text {
    font-weight: 800;
    color: #12C868;
    position: relative;
    display: inline-block;
}

.sys-title .accent-text::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: 8px;
    background: rgba(18, 200, 104, 0.2);
    z-index: -1;
}

.sys-subtitle {
    font-size: 18px;
    color: #666;
    line-height: 1.5;
}

/* 3D SCENE */
.roof-engineering-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.iso-scene {
    width: 320px;
    height: 320px;
    position: relative;
    perspective: 2000px;
    margin-bottom: 60px;
    cursor: grab;
    /* Indicates rotation capability */
    /* Adjust initial view angle */
    transform: scale(1.1);
}

.roof-layers {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    /* Isometric Angle */
    transform: rotateX(60deg) rotateZ(-45deg);
    transition: transform 0.5s ease;
}

/* Base Layer Style */
/* Standard Box Model: Width=240, Height=240 */
.layer {
    position: absolute;
    width: 240px;
    height: 240px;
    top: 50%;
    left: 50%;
    margin-top: -120px;
    margin-left: -120px;
    transform-style: preserve-3d;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: pointer;
}

/* Layer thickness var default */
.layer {
    --th: 10px;
}

/* FACES */
.layer-face {
    position: absolute;
    /* Border to hide micro-gaps (anti-aliasing) */
    /* border: 1px solid rgba(0,0,0,0.05); */
    backface-visibility: hidden;
    /* optional */
}

/* TOP FACE */
.layer-face.top {
    width: 100%;
    height: 100%;
    transform: translateZ(var(--th));
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.05);
    /* inner depth */
}

/* SIDE 1 (South/Front-Right in ISO) */
.layer-face.side-1 {
    width: 100%;
    height: var(--th);
    bottom: 0;
    left: 0;
    transform-origin: bottom;
    transform: rotateX(-90deg);
    filter: brightness(0.85);
    /* Shade */
}

/* SIDE 2 (East/Front-Left in ISO) */
.layer-face.side-2 {
    width: var(--th);
    height: 100%;
    right: 0;
    top: 0;
    transform-origin: right;
    transform: rotateY(90deg);
    filter: brightness(0.7);
    /* Darker Shade */
}


/* SIDE 3 (North/Back-Right in ISO) */
.layer-face.side-3 {
    width: 100%;
    height: var(--th);
    top: 0;
    left: 0;
    transform-origin: top;
    transform: rotateX(90deg);
    filter: brightness(0.6);
}

/* SIDE 4 (West/Back-Left in ISO) */
.layer-face.side-4 {
    width: var(--th);
    height: 100%;
    left: 0;
    top: 0;
    transform-origin: left;
    transform: rotateY(-90deg);
    filter: brightness(0.5);
}

/* BOTTOM FACE */
.layer-face.bottom {
    width: 100%;
    height: 100%;
    transform: translateZ(0);
    /* Base level */
    background: inherit;
    filter: brightness(0.3);
}


/* 3-Column Grid System */
.roof-types-grid {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 40px;
}

.roof-card {
    flex: 1;
    min-width: 300px;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.roof-card-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 30px;
    color: #333;
    text-align: center;
}

/* --- NEW LAYER VARIANTS --- */

/* METAL TILE FINISH (Monterrey Wave) */
.layer-6-finish .top {
    background-color: #2F4F4F;
    /* Complex gradient to simulate waves and steps */
    background-image:
        /* Horizontal shadow/steps every 50px */
        repeating-linear-gradient(180deg,
            rgba(255, 255, 255, 0.1) 0px,
            transparent 5px,
            transparent 45px,
            rgba(0, 0, 0, 0.3) 50px),
        /* Vertical waves repeating */
        repeating-linear-gradient(90deg,
            #2F4F4F 0px,
            #3a6060 15px,
            #223a3a 30px,
            #2F4F4F 45px);
    background-size: 100% 50px, 45px 100%;
    background-blend-mode: overlay;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.layer-6-finish .side-1,
.layer-6-finish .side-2,
.layer-6-finish .side-3,
.layer-6-finish .side-4 {
    background: #1e3333;
}

/* FALZ FINISH (Grey, Vertical Lines) */
.layer-finish-falz .top {
    background-color: var(--finish-color, #708090);
    /* Slate Grey default */
    background-image: repeating-linear-gradient(90deg,
            rgba(0, 0, 0, 0.2) 0px,
            rgba(0, 0, 0, 0.2) 2px,
            transparent 2px,
            transparent 50px);
    /* Vertical Seams */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.layer-finish-falz .side-1,
.layer-finish-falz .side-2,
.layer-finish-falz .side-3,
.layer-finish-falz .side-4 {
    background: var(--finish-side-color, #505c66);
}

/* SOFT ROOF FINISH (Textured, Asphalt) */
.layer-finish-soft .top {
    background-color: var(--finish-color, #3a3a3a);
    /* Hexagon/Shingle Pattern simulation */
    background-image:
        linear-gradient(45deg, rgba(0, 0, 0, 0.5) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.5) 75%, rgba(0, 0, 0, 0.5)),
        linear-gradient(-45deg, rgba(0, 0, 0, 0.5) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.5) 75%, rgba(0, 0, 0, 0.5));
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    /* Adjusted to be overlay-friendly for color changing */
}

.layer-finish-soft .side-1,
.layer-finish-soft .side-2,
.layer-finish-soft .side-3,
.layer-finish-soft .side-4 {
    background: var(--finish-side-color, #222);
    filter: brightness(0.6);
}

/* OSB Layer */
/* OSB LAYER (For Soft Roof) */
.layer-osb {
    --th: 12px;
}

.layer-osb .top {
    background: #dcb172;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.4"/></svg>');
}

.layer-osb .side-1,
.layer-osb .side-2,
.layer-osb .side-3,
.layer-osb .side-4 {
    background: #b08d55;
}

/* 1. RAFTERS (Bottom) */
.layer-1-rafters {
    --th: 20px;
}

.layer-1-rafters .top {
    background: repeating-linear-gradient(90deg, #deb887, #deb887 40px, rgba(0, 0, 0, 0.1) 40px, rgba(0, 0, 0, 0.1) 41px);
    background-color: #d2a470;
}

.layer-1-rafters .side-1,
.layer-1-rafters .side-2,
.layer-1-rafters .side-3,
.layer-1-rafters .side-4 {
    background: #8B4513;
}

/* 2. VAPOR (Thin White) */
.layer-2-vapor {
    --th: 2px;
}

.layer-2-vapor .top {
    background: rgba(255, 255, 255, 0.95);
    opacity: 0.9;
}

.layer-2-vapor .side-1,
.layer-2-vapor .side-2,
.layer-2-vapor .side-3,
.layer-2-vapor .side-4 {
    background: #ccc;
}

/* 3. INSULATION (Thick Yellow) */
.layer-3-insulation {
    --th: 40px;
}

.layer-3-insulation .top {
    background: #eedd82;
    background-image: radial-gradient(rgba(0, 0, 0, 0.1) 15%, transparent 16%);
    background-size: 8px 8px;
}

.layer-3-insulation .side-1,
.layer-3-insulation .side-2,
.layer-3-insulation .side-3,
.layer-3-insulation .side-4 {
    background: #DAA520;
    /* Texture for side of insulation */
    background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.05) 0px, rgba(0, 0, 0, 0.05) 2px, transparent 2px, transparent 4px);
}

/* 4. MEMBRANE (Grey/Black) */
.layer-4-membrane {
    --th: 3px;
}

.layer-4-membrane .top {
    background: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.2);
    font-size: 10px;
    letter-spacing: 2px;
}

.layer-4-membrane .top::after {
    content: "TYVEK TYVEK";
    transform: rotate(-45deg);
}

.layer-4-membrane .side-1,
.layer-4-membrane .side-2,
.layer-4-membrane .side-3,
.layer-4-membrane .side-4 {
    background: #333;
}

/* 5. BATTEN (Wood Strips) */
.layer-5-batten {
    --th: 8px;
}

.layer-5-batten .top {
    background-color: rgba(205, 133, 63, 0.2);
    background-image: repeating-linear-gradient(0deg, #cd853f, #cd853f 15px, transparent 15px, transparent 40px);
}

.layer-5-batten .side-1,
.layer-5-batten .side-3 {
    background: #8B4513;
    /* Solid ends */
}

/* Sides showing gaps */
.layer-5-batten .side-2,
.layer-5-batten .side-4 {
    background-image: repeating-linear-gradient(0deg, #8B4513, #8B4513 15px, transparent 15px, transparent 40px);
}


/* 6. FINISH (Metal Tile - Monterrey Profile) */
.layer-6-finish {
    --th: 6px;
}

.layer-6-finish .top {
    background-color: var(--finish-color, #354a5e);
    /* Classic Grey-Blue RAL 5008 */

    /* COMPLEX REALISTIC TILE TEXTURE */
    background-image:
        /* 1. Horizontal Steps (Shadow at the drop of the tile step) */
        repeating-linear-gradient(180deg,
            transparent 0px,
            transparent 38px,
            rgba(0, 0, 0, 0.6) 40px),
        /* 2. Vertical Waves (Cylindrical 3D effect) */
        repeating-linear-gradient(90deg,
            transparent 0px,
            rgba(255, 255, 255, 0.25) 10px,
            /* Specular High */
            transparent 20px,
            rgba(0, 0, 0, 0.3) 30px,
            /* Deep Shadow */
            transparent 40px);

    /* Synced with Batten pitch (40px) */
    background-size: 100% 40px, 40px 100%;

    /* Glossy Finish */
    filter: contrast(1.1) brightness(1.1);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.layer-6-finish .side-1,
.layer-6-finish .side-2,
.layer-6-finish .side-3,
.layer-6-finish .side-4 {
    background: var(--finish-side-color, #2a3b4b);
    /* Darker cut edge */
}


/* INFO TOOLTIPS (Refined) */
.layer-info {
    position: absolute;
    width: 220px;
    background: #fff;
    padding: 12px 15px;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left: 3px solid #12C868;

    /* Position relative to layer center */
    left: 260px;
    /* Offset to right */
    top: 0;

    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s;
    pointer-events: none;
    z-index: 100;
}

/* Connect line */
.layer-info::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    width: 20px;
    height: 1px;
    background: #12C868;
    opacity: 0.5;
}

.layer:hover .layer-info,
.layer.active .layer-info {
    opacity: 1;
    transform: translateX(0);
}

.layer-info strong {
    display: block;
    color: #12C868;
    margin-bottom: 4px;
    font-size: 14px;
    text-transform: uppercase;
    font-weight: 700;
}


/* CONTROLS */
.sys-controls {
    margin-top: 30px;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.slider-hint {
    margin-bottom: 15px;
    font-size: 13px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.express-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

.express-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #12C868;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

.express-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
    background: #0ea855;
    cursor: grabbing;
}


/* CTA */
.sys-cta {
    margin-top: 50px;
}

.sys-btn {
    display: inline-block;
    padding: 16px 36px;
    background: #12C868;
    color: white;
    font-size: 16px;
    font-weight: 700;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 8px 25px rgba(18, 200, 104, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

.sys-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(18, 200, 104, 0.45);
}

/* MEDIA QUERIES */
@media (max-width: 768px) {
    .sys-title {
        font-size: 26px;
    }

    .roof-engineering-wrapper {
        overflow: visible;
    }

    .iso-scene {
        width: 260px;
        height: 260px;
        transform: scale(0.9);
        margin-bottom: 40px;
    }

    .layer {
        width: 220px;
        height: 220px;
        margin-top: -110px;
        margin-left: -110px;
    }

    .layer-info {
        position: fixed;
        bottom: 70px;
        /* Above nav/floating buttons */
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        width: 90%;
        max-width: 320px;
        text-align: center;
        border-left: none;
        border-top: 3px solid #12C868;
    }

    .layer-info::before {
        display: none;
    }

    .layer:hover .layer-info,
    .layer.active .layer-info {
        transform: translateX(-50%) translateY(0);
    }

    .sys-controls {
        margin-top: 10px;
    }
}

/* NEW LAYERS FOR PRO SPECS */

/* Counter-Batten (Vertical 50x50) */
/* Runs Perpendicular to Batten. Assuming Rafters/Counter run "Front-Back" (Side 2) */
.layer-counter {
    --th: 12px;
    /* Visual thickness for 50mm */
}

.layer-counter .top {
    /* Vertical Wood Strips */
    background-color: rgba(205, 133, 63, 0.2);
    /* 90deg for Vertical lines */
    background-image: repeating-linear-gradient(90deg, #cd853f, #cd853f 10px, transparent 10px, transparent 40px);
}

.layer-counter .side-1,
.layer-counter .side-3 {
    /* Cut ends of vertical strips */
    background-image: repeating-linear-gradient(90deg, #8B4513, #8B4513 10px, transparent 10px, transparent 40px);
}

.layer-counter .side-2,
.layer-counter .side-4 {
    /* Long side of strip - Solid */
    background: #8B4513;
}


/* Noise Reduction Tape (For Falz) */
.layer-tape {
    --th: 2px;
}

.layer-tape .top {
    background-color: transparent;
    /* Dark Grey Strips on top of batten (Horizontal) */
    background-image: repeating-linear-gradient(0deg, #333, #333 15px, transparent 15px, transparent 40px);
}

.layer-tape .side-1,
.layer-tape .side-2,
.layer-tape .side-3,
.layer-tape .side-4 {
    background: #333;
}


/* --- NEW STYLES APPENDED --- */

/* COLOR PICKER */
.color-picker-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 30px 0 50px;
    position: relative;
    z-index: 10;
}

.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    outline: none;
    background-color: var(--btn-color);
    /* Dynamically set */
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px #12C868, 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* GLOBAL TOOLTIP (Mouse Follow or Fixed) */
.roof-tooltip-overlay {
    position: fixed;
    /* Fixed to viewport to ensure visibility */
    top: 0;
    left: 0;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.98);
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-bottom: 3px solid #12C868;
    width: 240px;
    max-width: 90vw;
    text-align: center;

    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
    /* Highest Z */

    /* Centering logic handled by JS or via translate */
    transform: translate(-50%, -100%);
    /* Center horizontally, sit above cursor */
    margin-top: -15px;
    /* Offset from cursor */
}

.roof-tooltip-overlay.active {
    opacity: 1;
}

.roof-tooltip-overlay strong {
    display: block;
    color: #12C868;
    margin-bottom: 4px;
    font-size: 15px;
    text-transform: uppercase;
    font-weight: 800;
}

.roof-tooltip-overlay span {
    font-size: 13px;
    color: #444;
    line-height: 1.3;
    display: block;
}

/* HIDE OLD TOOLTIPS */
.layer-info {
    display: none !important;
}


/* --- THERMAL IMAGER WIDGET STYLES --- */

.thermal-section {
    padding: 80px 0;
    background: #1a1a2e;
    /* Dark Night Background */
    color: #fff;
    overflow: hidden;
    position: relative;
}

.thermal-section .sys-title {
    color: #fff;
}

.thermal-section .sys-subtitle {
    color: #ccc;
}

.thermal-container {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.thermal-wrapper {
    position: relative;
    height: 500px;
    margin: 40px auto;
    background: radial-gradient(circle at center, #2a2a45 0%, #1a1a2e 70%);
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* CONTROLS */
.thermal-toggle-group {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 30px;
}

.thermal-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    font-size: 14px;
}

.thermal-btn.active {
    background: #fff;
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

.thermal-btn[data-mode="thermal"].active {
    background: linear-gradient(45deg, #ff416c, #ff4b2b);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 75, 43, 0.5);
}


/* 3D HOUSE MODEL SCENE */
.thermal-scene {
    width: 300px;
    height: 300px;
    perspective: 1000px;
    transform: scale(1.2);
    cursor: grab;
}

.house-model {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(45deg);
    transition: transform 0.5s;
}

/* HOUSE PARTS */
.house-part {
    position: absolute;
    transform-style: preserve-3d;
}

/* 1. BASE (WALLS) */
.house-base {
    width: 160px;
    height: 120px;
    /* Height of box */
    /* Depth simulated by sides width */
    top: 50%;
    left: 50%;
    margin-top: -60px;
    margin-left: -80px;
}

.house-base .face {
    position: absolute;
    backface-visibility: hidden;
    /* Or visible for transparency */
    transition: background 0.5s;
}

.house-base .front {
    width: 160px;
    height: 120px;
    transform: translateZ(80px);
    background: #c5afa0;
    /* Brick */
}

.house-base .back {
    width: 160px;
    height: 120px;
    transform: translateZ(-80px) rotateY(180deg);
    background: #c5afa0;
}

.house-base .left {
    width: 160px;
    height: 120px;
    transform: rotateY(-90deg) translateZ(80px);
    background: #bca08d;
}

.house-base .right {
    width: 160px;
    height: 120px;
    transform: rotateY(90deg) translateZ(80px);
    background: #bca08d;
}

.house-base .top {
    width: 160px;
    height: 160px;
    transform: rotateX(90deg) translateZ(60px);
    background: #333;
}

/* Ceiling */


/* 2. ROOF SLOPE (Simple Shed/Gable simulation) */
/* We simply place a rotated flat box on top */
.roof-slope {
    width: 180px;
    height: 10px;
    /* Thickness */
    top: 50%;
    left: 50%;
    /* Position adjustments */
    transform: translate(-50%, -100%) translateY(-30px) translateZ(0) rotateX(15deg);
    /* This creates a slope */
}

.roof-slope .face {
    position: absolute;
    transition: background 0.5s;
}

.roof-slope .top {
    width: 180px;
    height: 180px;
    transform: rotateX(90deg) translateZ(5px);
    background: #354a5e;
    /* Metal Tile */
}

.roof-slope .bottom {
    width: 180px;
    height: 180px;
    transform: rotateX(-90deg) translateZ(5px);
    background: #222;
}

.roof-slope .front {
    width: 180px;
    height: 10px;
    transform: translateZ(90px);
    background: #2a3b4b;
}

.roof-slope .back {
    width: 180px;
    height: 10px;
    transform: translateZ(-90px) rotateY(180deg);
    background: #2a3b4b;
}

.roof-slope .left {
    width: 180px;
    height: 10px;
    transform: rotateY(-90deg) translateZ(90px);
    background: #2a3b4b;
}

.roof-slope .right {
    width: 180px;
    height: 10px;
    transform: rotateY(90deg) translateZ(90px);
    background: #2a3b4b;
}


/* 3. CHIMNEY */
.chimney {
    width: 40px;
    height: 60px;
    top: 50%;
    left: 50%;
    transform: translate(-30px, -130px) translateZ(30px);
}

.chimney .face {
    position: absolute;
    background: #8d5e48;
    /* Red Brick */
    transition: background 0.5s;
}

.chimney .front {
    width: 40px;
    height: 60px;
    transform: translateZ(20px);
}

.chimney .back {
    width: 40px;
    height: 60px;
    transform: translateZ(-20px) rotateY(180deg);
}

.chimney .left {
    width: 40px;
    height: 60px;
    transform: rotateY(-90deg) translateZ(20px);
}

.chimney .right {
    width: 40px;
    height: 60px;
    transform: rotateY(90deg) translateZ(20px);
}

.chimney .top {
    width: 40px;
    height: 40px;
    transform: rotateX(90deg) translateZ(30px);
    background: #333;
}


/* --- THERMAL MODE TEXTURES --- */
.thermal-wrapper.thermal-active .house-base .front,
.thermal-wrapper.thermal-active .house-base .back,
.thermal-wrapper.thermal-active .house-base .left,
.thermal-wrapper.thermal-active .house-base .right {
    /* Cold Walls (Blue) */
    background: linear-gradient(180deg, #001f3f, #0074d9);
    opacity: 0.9;
}

.thermal-wrapper.thermal-active .roof-slope .top {
    /* Cold Roof (Blue/Purple) */
    background: linear-gradient(45deg, #001f3f, #3d9970);
    /* HEAT LEAKS ADDED VIA HOTSPOTS */
}

.thermal-wrapper.thermal-active .chimney .face {
    /* HOT CHIMNEY (Red/Yellow) */
    background: linear-gradient(to top, #ff416c, #ff4b2b, #ffda79);
    filter: brightness(1.2);
    box-shadow: 0 0 20px rgba(255, 75, 43, 0.6);
}


/* HOTSPOTS (Visible in Thermal Mode) */
.heat-spot {
    position: absolute;
    width: 20px;
    height: 20px;
    transform-style: preserve-3d;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
    z-index: 100;
}

.thermal-wrapper.thermal-active .heat-spot {
    opacity: 1;
    pointer-events: auto;
}

/* Positions */
.heat-spot[data-defect="chimney"] {
    top: 50%;
    left: 50%;
    transform: translateZ(50px) rotateX(-20deg);
    /* Adjust to face camera */
}

.heat-spot[data-defect="ridge"] {
    top: 0;
    left: 50%;
    transform: translateZ(10px);
}

.heat-spot[data-defect="eaves"] {
    top: 0;
    left: 0;
    transform: translateZ(85px);
}


/* Pulse Effect */
.pulse-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 0, 0, 0.6);
    animation: thermalPulse 2s infinite;
    box-shadow: 0 0 10px #ff0000;
}

@keyframes thermalPulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.spot-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 5px red;
}


/* DEFECT MODAL CARD */
.defect-card {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(110%);
    /* Hidden */
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #ff4d4d;
    padding: 20px;
    border-radius: 10px;
    width: 300px;
    text-align: left;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.defect-card.active {
    transform: translateX(-50%) translateY(0);
}

.defect-title {
    color: #ff4d4d;
    margin: 0 0 10px 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.defect-desc {
    color: #ddd;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.small-btn {
    padding: 8px 16px;
    font-size: 12px;

}

/* Hide Old Thermal Widget */
#thermal-check {
    display: none !important;
}



/* --- ANALYZER BLOCK STYLES (PHOTO VERSION) --- */
.inspection-section {
    padding: 20px 0 60px;
    /* Reduced top padding as header is above */
    background: #fdfcf8;
}

.analyzer-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.analyzer-btn {
    padding: 12px 30px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: #555;
}

.analyzer-btn.active {
    background: #ff4d4d;
    color: #fff;
    border-color: #ff4d4d;
    box-shadow: 0 5px 15px rgba(255, 77, 77, 0.3);
}

.analyzer-btn[data-mode="good"].active {
    background: #12c868;
    border-color: #12c868;
    box-shadow: 0 5px 15px rgba(18, 200, 104, 0.3);
}

/* WRAPPER */
.inspection-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 550px;
    background: #eef2f5;
    border-radius: 20px;
    overflow: hidden;
    cursor: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* ROOF VIEW CONTAINER */
.roof-view-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    /* Ensure image fits */
}

/* PHOTO LAYER */
.roof-photo-layer {
    width: 100%;
    height: 100%;
    position: relative;
}

.roof-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.5s;
}

/* Mode Handling */
.inspection-wrapper.mode-bad .img-good {
    opacity: 0;
    pointer-events: none;
}

.inspection-wrapper.mode-bad .img-bad {
    opacity: 1;
}

.inspection-wrapper.mode-good .img-bad {
    opacity: 0;
    pointer-events: none;
}

.inspection-wrapper.mode-good .img-good {
    opacity: 1;
}

.inspection-wrapper.mode-bad .good-point {
    display: none;
}

.inspection-wrapper.mode-good .bad-point {
    display: none;
}

/* MARKERS */
.defect-marker-point,
.quality-marker-point {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    cursor: help;
}

.defect-marker-point {
    background: rgba(255, 77, 77, 0.3);
    border: 2px solid rgba(255, 77, 77, 0.6);
    animation: markerPulse 2s infinite;
}

.defect-marker-point::after {
    content: '?';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #a00;
    font-weight: bold;
}

.quality-marker-point {
    background: rgba(18, 200, 104, 0.8);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(18, 200, 104, 0.4);
}

@keyframes markerPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        background: rgba(255, 77, 77, 0.3);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        background: rgba(255, 77, 77, 0.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        background: rgba(255, 77, 77, 0.3);
    }
}

/* MAGNIFIER LENS */
.magnifier-lens {
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.2);
    background: #fff;
    overflow: hidden;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s;
    /* No transform transition for snappy follow */
}

/* ZOOMED CONTENT */
.magnifier-content {
    position: absolute;
    top: 0;
    left: 0;
    /* Size set by JS */
    transform-origin: 0 0;
}

.lens-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
}

.lens-crosshair::after {
    content: '';
    position: absolute;
    top: -9px;
    left: 9px;
    width: 2px;
    height: 20px;
    background: rgba(255, 255, 255, 0.5);
}

/* CARD */
.insp-card {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    min-width: 250px;
    max-width: 350px;
    border-left: 5px solid #ff4d4d;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 1000;
    display: flex;
    gap: 15px;
}

.insp-card.active {
    opacity: 1;
    transform: translateY(0);
}

.insp-icon {
    font-size: 24px;
}

.insp-title {
    margin: 0 0 5px;
    font-size: 16px;
    font-weight: 700;
}

.insp-desc {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #444;
}

/* INSTRUCTION */
.insp-instruction {
    position: absolute;
    bottom: 20px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}


/* --- FINAL FIXES (Step 96) --- */

/* 1. Fix Roof Pies Title Overlap */
.roof-card-title {
    position: relative;
    z-index: 10;
    margin-bottom: 60px;
    /* Increase space */
}

.iso-scene {
    margin-top: 40px;
    /* Push down */
    margin-bottom: 80px;
    /* More space below */
    z-index: 1;
}

/* 2. Color Updates (Orange Warning) */
.defect-marker-point {
    background: rgba(255, 107, 74, 0.4) !important;
    /* Soft Red/Orange */
    border-color: #ff6b4a !important;
}

.defect-marker-point::after {
    color: #cc3300 !important;
}

@keyframes markerPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        background: rgba(255, 107, 74, 0.4);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        background: rgba(255, 107, 74, 0.2);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        background: rgba(255, 107, 74, 0.4);
    }
}

/* Card Border for Bad Mode */
.insp-card.active {
    /* JS sets border-left-color, but we can override or use !important if needed, 
       but better to update JS. */
}

/* Update button active color if needed, but user said "Krasnykh u nas netu" (We don't have reds).
   So #ff4d4d used in JS should be orange.
   I will override button active state here just in case.
*/
.analyzer-btn[data-mode="bad"].active {
    background: #ff6b4a !important;
    /* Orange-Red */
    border-color: #ff6b4a !important;
    box-shadow: 0 5px 15px rgba(255, 107, 74, 0.3) !important;
}


/* --- FIX OVERLAP AND READABILITY (Step 122) --- */

.roof-card-title {
    margin-bottom: 110px !important;
    /* increased space to prevent overlap */
    position: relative;
    z-index: 20;
    /* Soft white glow to ensure contrast if extremey expanded */
    text-shadow: 0 2px 10px rgba(255, 255, 255, 1), 0 0 15px rgba(255, 255, 255, 0.8);
}

.iso-scene {
    /* Slightly reduce scale to keep within bounds */
    transform: scale(0.95) !important;
    margin-top: 20px !important;
}

/* Ensure container allows overflow if needed, or clips correctly */
.roof-card {
    overflow: visible;
}

/* --- MOBILE REFINEMENTS FOR INSPECTION --- */
@media (max-width: 900px) {
    .inspection-wrapper {
        height: 500px;
        cursor: auto;
        padding-top: 0 !important;
        /* no padding needed without lens */
    }

    /* Photo layer: explicit pixel heights to bypass % chain resolution issue */
    .roof-view-container {
        height: 500px !important;
        position: relative !important;
    }

    .roof-photo-layer {
        height: 500px !important;
        border-radius: 0 !important;
    }

    .roof-img {
        height: 500px !important;
    }

    .magnifier-lens,
    .insp-instruction {
        display: none !important;
    }

    .insp-card {
        bottom: 15px;
        left: 15px;
        right: 15px;
        min-width: unset;
        max-width: unset;
        padding: 15px;
        gap: 10px;
        z-index: 1000;
        /* Default mobile position slightly above bottom in case of layout shifts */
    }

    .defect-marker-point,
    .quality-marker-point {
        width: 35px;
        height: 35px;
        cursor: pointer;
        /* Enable pointers for mobile tap */
        pointer-events: auto !important;
    }

    .defect-marker-point::after {
        font-size: 16px;
    }

    .analyzer-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 0 15px;
    }
}

@media (max-width: 500px) {
    .inspection-wrapper {
        height: 400px;
    }

    .roof-view-container {
        height: 400px !important;
    }

    .roof-photo-layer {
        height: 400px !important;
    }

    .roof-img {
        height: 400px !important;
    }

    .insp-title {
        font-size: 14px;
        margin-bottom: 2px;
    }

    .insp-desc {
        font-size: 12px;
    }

    .insp-icon {
        font-size: 20px;
    }
}