/* ==========================================================================
   Loop Powered Carousel - Structural Stylesheet
   3-column × 3-row CSS Grid layout
   ========================================================================== */

/* CSS Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body.loop-carousel-page {
    font-size: 16px;
    line-height: 1.6;
    color: #ffffff;
    background: #000000;
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    position: relative;
    --ui-scale: 1;
}

/* ==========================================================================
   Background Image
   ========================================================================== */

.gc-carousel-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 1s ease-in-out;
    z-index: 1;
    --overlay-opacity: 0.3;
}

.gc-carousel-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to bottom, rgba(0,0,0, calc(var(--overlay-opacity) * 0.5)) 0%, transparent 20%),
        linear-gradient(to top, rgba(0,0,0, calc(var(--overlay-opacity) + 0.4)) 0%, rgba(0,0,0, var(--overlay-opacity)) 25%, transparent 50%),
        linear-gradient(to right, rgba(0,0,0, calc(var(--overlay-opacity) + 0.1)) 0%, transparent 30%);
    z-index: 2;
    pointer-events: none;
}

/* ==========================================================================
   Main 3×3 Grid
   
   LANDSCAPE (default):
   ┌──────────┬──────────────────┬──────────────────┐
   │ EPC      │                  │ Property X of X  │  Row 1 (1/3 each)
   ├──────────┴──────────────────┼──────────────────┤
   │ Stats                       │ Thumbnails       │  Row 2 (50/50)
   ├─────────────────────────────┼──────────────────┤
   │ Logo                        │ Counter+Addr+£   │  Row 3 (50/50)
   └─────────────────────────────┴──────────────────┘
   ========================================================================== */

.gc-carousel-container {
    position: relative;
    z-index: 10;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "epc      .         counter"
        "stats    stats     thumbs"
        "logo     logo      info";
    padding: 2rem;
    gap: 0;
}

/* ==========================================================================
   Row 1, Col 1: EPC Certificate
   ========================================================================== */

.epc-overlay {
    grid-area: epc;
    align-self: start;
    justify-self: start;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 0.5rem;
    padding: 0.75rem;
    max-width: 220px;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 1.2s;
}

.epc-overlay .epc-header h4 {
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.epc-overlay .epc-image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Row 1, Col 3: Property Counter
   ========================================================================== */

.gc-property-counter {
    grid-area: counter;
    justify-self: end;
    align-self: start;
    z-index: 200;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1.25rem;
    border-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
}

/* ==========================================================================
   Row 2, Col 1: Bed / Bath / Reception Stats
   ========================================================================== */

.gc-property-stats-left {
    grid-area: stats;
    align-self: center;
    justify-self: start;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 100;
    transition: margin 0.5s ease;
}

.property-stat {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    padding: 0.6rem 0.9rem;
    border-radius: 0.6rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    width: 6.5rem;
    backdrop-filter: blur(8px);
}

.property-stat svg {
    width: clamp(20px, calc(28px * var(--ui-scale)), 36px);
    height: clamp(20px, calc(28px * var(--ui-scale)), 36px);
    flex-shrink: 0;
    stroke: #333333;
    stroke-width: 2;
}

.property-stat span {
    font-size: clamp(1rem, calc(1.4rem * var(--ui-scale)), 1.9rem);
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

/* ==========================================================================
   Row 2, Col 3: Thumbnails (vertical sidebar in landscape)
   ========================================================================== */

.gc-thumbnail-overlay {
    grid-area: thumbs;
    align-self: center;
    justify-self: end;
    z-index: 100;
    opacity: 0;
    animation: slideInFromRight 0.8s ease forwards;
    animation-delay: 1.5s;
    transition: margin 0.5s ease;
}

.gc-carousel-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.gc-carousel-thumbnail {
    width: clamp(96px, calc(130px * var(--ui-scale)), 160px);
    height: clamp(64px, calc(85px * var(--ui-scale)), 104px);
    background-size: cover;
    background-position: center;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    opacity: 0.55;
    position: relative;
    overflow: hidden;
}

.gc-carousel-thumbnail:hover,
.gc-carousel-thumbnail.active {
    opacity: 1;
    border-color: #ffffff;
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.25);
    transform: scale(1.03);
}

/* ==========================================================================
   Row 3, Col 1: Logo
   ========================================================================== */

.gc-logo-container {
    grid-area: logo;
    align-self: end;
    justify-self: start;
    z-index: 100;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 1.5s;
}

.gc-logo-container img {
    width: auto;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

.gc-logo-container h1 {
    font-size: 1.5rem;
    font-weight: 300;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Row 3, Col 3: Image Counter + Address + Price
   ========================================================================== */

.gc-main-display {
    grid-area: info;
    align-self: end;
    justify-self: end;
    text-align: right;
    z-index: 100;
}

.image-counter {
    display: inline-block;
    font-size: clamp(0.8rem, calc(0.9rem * var(--ui-scale)), 1.2rem);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    padding: 0.3rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.property-info {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
    animation-delay: 0.3s;
}

.property-info h2 {
    font-size: clamp(1.2rem, calc(2.2rem * var(--ui-scale)), 3rem);
    font-weight: 400;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
    margin-bottom: 0.25rem;
    line-height: 1.25;
}

.property-price {
    font-size: clamp(1.6rem, calc(3.2rem * var(--ui-scale)), 4rem);
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
    line-height: 1.15;
}

.property-price-qualifier {
    font-size: clamp(0.9rem, calc(1.15rem * var(--ui-scale)), 1.5rem);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    margin-top: 0.2rem;
}

/* ==========================================================================
   Navigation Controls (absolute overlay, optional)
   ========================================================================== */

.carousel-admin-controls {
    position: absolute;
    top: 0;
    right: 2rem;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.carousel-admin-controls .nav-button {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    transition: background-color 0.3s ease;
}

.carousel-admin-controls .nav-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(60px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   Responsive – Smaller Landscape Screens (≤1200px)
   ========================================================================== */

@media (max-width: 1200px) {
    .gc-carousel-container {
        padding: 1.5rem;
    }

    .property-stat {
        width: 5.5rem;
        padding: 0.5rem 0.75rem;
    }

    .property-stat svg {
        width: 24px;
        height: 24px;
    }

    .property-stat span {
        font-size: 1.2rem;
    }

    .property-info h2 {
        font-size: 1.8rem;
    }

    .property-price {
        font-size: 2.6rem;
    }

    .gc-carousel-thumbnail {
        width: 110px;
        height: 72px;
    }

    .epc-overlay {
        max-width: 180px;
    }
}

/* ==========================================================================
   Responsive – Portrait Orientation
   
   PORTRAIT – rearranges to a top-bar layout:
   ┌──────────┬──────────────────┬──────────────────┐
   │ Stats    │ Thumbnails (h)   │ EPC              │  Row 1 (1/3 each)
   ├──────────┴──────────────────┼──────────────────┤
   │                             │                  │  Row 2 (1fr spacer)
   ├─────────────────────────────┼──────────────────┤
   │ Logo     │ Addr + £                             │  Row 3 (1/3 + 2/3)
   └──────────┴──────────────────────────────────────┘
   
   Counter hidden. Stats top-left. EPC top-right. Thumbnails horizontal centre.
   ========================================================================== */

@media (orientation: portrait) {
    .gc-carousel-container {
        grid-template-areas:
            "stats    thumbs    epc"
            ".        .         ."
            "logo     info      info";
        padding: 1.5rem;
    }

    /* Hide counter in portrait */
    .gc-property-counter {
        display: none;
    }

    /* Stats move to top-left */
    .gc-property-stats-left {
        align-self: start;
        justify-self: start;
    }

    .property-stat {
        width: auto;
        padding: 0.5rem 0.7rem;
    }

    .property-stat svg {
        width: 24px;
        height: 24px;
    }

    .property-stat span {
        font-size: 1.15rem;
    }

    /* Thumbnails flip to horizontal, centred at top */
    .gc-thumbnail-overlay {
        align-self: start;
        justify-self: center;
        animation-name: fadeInUp;
    }

    .gc-carousel-thumbnails {
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }

    .gc-carousel-thumbnail {
        width: 100px;
        height: 66px;
    }

    /* EPC moves to top-right in portrait */
    .epc-overlay {
        justify-self: end;
        max-width: 160px;
    }

    .property-info h2 {
        font-size: 1.8rem;
    }

    .property-price {
        font-size: 2.8rem;
    }
}

/* ==========================================================================
   Responsive – Small Portrait (≤768px, portrait)
   ========================================================================== */

@media (max-width: 768px) and (orientation: portrait) {
    .gc-carousel-container {
        padding: 1rem;
    }

    .epc-overlay {
        max-width: 100px;
        padding: 0.4rem;
    }

    .property-stat {
        width: auto;
        padding: 0.3rem 0.45rem;
        gap: 0.3rem;
    }

    .property-stat svg {
        width: 16px;
        height: 16px;
    }

    .property-stat span {
        font-size: 0.9rem;
    }

    .gc-carousel-thumbnail {
        width: 60px;
        height: 42px;
    }

    .property-info h2 {
        font-size: 1.2rem;
    }

    .property-price {
        font-size: 1.6rem;
    }
}

/* ==========================================================================
   Responsive – Small Landscape (≤768px, landscape – phones sideways)
   ========================================================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .gc-carousel-container {
        padding: 0.75rem;
    }

    .property-stat {
        width: 5rem;
        padding: 0.35rem 0.6rem;
        gap: 0.4rem;
    }

    .property-stat svg {
        width: 20px;
        height: 20px;
    }

    .property-stat span {
        font-size: 1rem;
    }

    .property-info h2 {
        font-size: 1.4rem;
    }

    .property-price {
        font-size: 2rem;
    }

    .gc-carousel-thumbnail {
        width: 80px;
        height: 54px;
    }

    .epc-overlay {
        max-width: 140px;
        padding: 0.5rem;
    }
}

/* ==========================================================================
   Forced Aspect Mode Overrides (from carousel settings)
   ========================================================================== */

/* Force portrait layout regardless of actual screen orientation */
body.carousel-mode-portrait .gc-carousel-container {
    grid-template-areas:
        "stats    thumbs    epc"
        ".        .         ."
        "logo     info      info";
    padding: 1.5rem;
}

body.carousel-mode-portrait .gc-property-counter {
    display: none;
}

body.carousel-mode-portrait .gc-property-stats-left {
    align-self: start;
    justify-self: start;
}

body.carousel-mode-portrait .gc-thumbnail-overlay {
    align-self: start;
    justify-self: center;
    animation-name: fadeInUp;
}

body.carousel-mode-portrait .gc-carousel-thumbnails {
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

body.carousel-mode-portrait .epc-overlay {
    justify-self: end;
}

/* Force landscape/default layout regardless of actual screen orientation */
body.carousel-mode-landscape .gc-carousel-container {
    grid-template-areas:
        "epc      .         counter"
        "stats    stats     thumbs"
        "logo     logo      info";
    padding: 2rem;
}

body.carousel-mode-landscape .gc-property-counter {
    display: block;
}

body.carousel-mode-landscape .gc-property-stats-left {
    align-self: center;
    justify-self: start;
}

body.carousel-mode-landscape .gc-thumbnail-overlay {
    align-self: center;
    justify-self: end;
    animation-name: slideInFromRight;
}

body.carousel-mode-landscape .gc-carousel-thumbnails {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

body.carousel-mode-landscape .epc-overlay {
    justify-self: start;
}

/* ==========================================================================
   Loading & Error States
   ========================================================================== */

.carousel-loading,
.carousel-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.carousel-loading h2,
.carousel-error h2 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 1rem;
    color: #ffffff;
}

.carousel-loading p,
.carousel-error p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    max-width: 600px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Carousel Disabled Notice
   ========================================================================== */

.carousel-disabled-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.carousel-notice-content {
    text-align: center;
    max-width: 600px;
    color: #333;
}

.carousel-notice-content h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: 300;
}

.carousel-notice-content p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.6;
}

.carousel-notice-actions {
    margin-top: 30px;
}

.carousel-notice-actions .button {
    display: inline-block;
    padding: 12px 24px;
    background: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.carousel-notice-actions .button:hover {
    background: #005a87;
    color: white;
}

/* ==========================================================================
   Progressive Loading Indicator
   ========================================================================== */

.carousel-loading-more {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 10px;
}

.carousel-loading-more.visible {
    display: flex;
}

/* ==========================================================================
   Accessibility & Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .gc-carousel-background::after {
        background: rgba(0, 0, 0, 0.8);
    }

    .property-stat {
        border: 2px solid #000;
    }

    .gc-carousel-thumbnail {
        border: 2px solid #ffffff !important;
    }
}

/* ==========================================================================
   Print (Hidden)
   ========================================================================== */

@media print {
    body.loop-carousel-page {
        display: none !important;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.screen-reader-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.hidden {
    display: none !important;
}
