/* ==========================================================================
   section-espaco.css - Seção 8: O Nosso Espaço
   Design System Fiel ao Figma · 100% Mobile-First com clamp()
   Fundo Papel Nobre: #F6F1E8 · Galeria Contínua com Marquees Alternados
   ========================================================================== */

.section-espaco {
    position: relative;
    width: 100%;
    background-color: var(--color-base-papel, #F6F1E8);
    isolation: isolate;
    overflow: hidden;
    padding-top: clamp(64px, 8vw, 96px);
    padding-bottom: clamp(64px, 8vw, 96px);
    padding-left: clamp(20px, 5vw, 64px);
    padding-right: clamp(20px, 5vw, 64px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(32px, 4vw, 40px);
}

/* --------------------------------------------------------------------------
   Background: Marca d'água & Fade Radial
   -------------------------------------------------------------------------- */
.section-espaco__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.section-espaco__pattern {
    position: absolute;
    inset: 0;
    background-image: url('../images/pattern-casanova.svg');
    background-repeat: repeat;
    background-size: 80px 80px;
    opacity: 0.15;
}

.section-espaco__fade {
    position: absolute;
    inset: 0;
    background: radial-gradient(50% 50% at 50% 50%, rgba(246, 241, 232, 0) 0%, rgba(246, 241, 232, 0.3) 60%, #F6F1E8 100%);
}

/* Glows estruturados com display: none conforme especificações do Figma */
.section-espaco__glow-soft,
.section-espaco__glow-strong {
    display: none;
}

/* --------------------------------------------------------------------------
   Cabeçalho da Seção (SectionTitle - 560px max)
   -------------------------------------------------------------------------- */
.section-espaco__header {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    gap: 24px;
    width: 100%;
    max-width: 560px;
    box-sizing: border-box;
    text-align: center;
}

/* Régua centralizada de 48px x 3px com cantos suaves */
.section-espaco__ruler {
    width: 48px;
    height: 3px;
    border-radius: 2px;
    background-color: var(--casa-acento-600, #8A5B3B);
    flex: none;
    order: 0;
    transition: background-color 0.3s ease;
}

/* Cores contextuais específicas de cada casa para a régua / eyebrow */
.context-casanova .section-espaco__ruler,
.section-espaco--casanova .section-espaco__ruler {
    background-color: #8A5B3B;
}

.context-casanostra .section-espaco__ruler,
.section-espaco--casanostra .section-espaco__ruler {
    background-color: #3F693B;
}

.context-pizza .section-espaco__ruler,
.context-pizza-a-pezzi .section-espaco__ruler,
.section-espaco--pizza-a-pezzi .section-espaco__ruler {
    background-color: #D81814;
}

/* Grupo de texto (Sobretítulo + Título + Subtítulo) */
.section-espaco__text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Eyebrow / Sobretítulo: Source Sans 3 · SemiBold (600) · 14px */
.section-espaco__eyebrow {
    font-family: var(--font-sans, 'Source Sans 3', sans-serif);
    font-style: normal;
    font-weight: 600;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--color-neutral-700, #6F6A63);
    margin: 0;
}

/* Título: Source Serif Pro / 4 · SemiBold (600) · 44px · line-height 106% */
.section-espaco__title {
    font-family: var(--font-serif, 'Source Serif Pro', 'Source Serif 4', Georgia, serif);
    font-style: normal;
    font-weight: 600;
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1.06;
    letter-spacing: -0.015em;
    text-align: center;
    text-transform: uppercase;
    color: var(--color-neutral-900, #111111);
    margin: 0;
    padding: 0;
    width: 100%;
}

.section-espaco__title p {
    margin: 0;
    font: inherit;
    color: inherit;
    line-height: inherit;
    display: inline;
}

.section-espaco__title em,
.section-espaco__title i {
    font-style: italic;
    font-family: inherit;
}

.section-espaco__title strong,
.section-espaco__title b {
    font-weight: 700;
}

/* Subtítulo: Source Sans 3 · Regular (400) · 18px · line-height 150% */
.section-espaco__subtitle {
    font-family: var(--font-sans, 'Source Sans 3', sans-serif);
    font-style: normal;
    font-weight: 400;
    font-size: clamp(16px, 1.4vw, 18px);
    line-height: 1.5;
    text-align: center;
    color: var(--color-neutral-800, #3A3733);
    margin: 0;
    max-width: 560px;
}

.section-espaco__subtitle p {
    margin: 0 0 8px 0;
}

.section-espaco__subtitle p:last-child {
    margin-bottom: 0;
}

.section-espaco__subtitle strong {
    font-weight: 600;
    color: var(--color-neutral-900, #111111);
}

/* --------------------------------------------------------------------------
   Grelha de Fileiras Animadas (Marquees)
   Largura máxima de 1152px (Figma: width 1152px / max-width 1400px dentro de 1280px)
   -------------------------------------------------------------------------- */
.section-espaco__grid {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 1152px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(16px, 2.2vw, 24px);
    box-sizing: border-box;
    overflow: hidden;
}

/* Container de cada fileira */
.section-espaco__row {
    position: relative;
    width: 100%;
    overflow: hidden;
    user-select: none;
    display: flex;
    align-items: center;
    outline: none;
}

.section-espaco__row:focus-visible {
    box-shadow: inset 0 0 0 2px var(--casa-acento-600, #8A5B3B);
}

/* Alturas fluidas calibradas por clamp() com paridade ao Figma */
.section-espaco__row--1 {
    height: clamp(180px, 24vw, 307px);
}

.section-espaco__row--2 {
    height: clamp(130px, 16.5vw, 211px);
}

.section-espaco__row--3 {
    height: clamp(120px, 15vw, 192px);
}

/* Track flexível contendo os grupos duplicados */
.section-espaco__track {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: max-content;
    height: 100%;
    gap: clamp(14px, 1.8vw, 23px);
}

/* Grupo de fotos */
.section-espaco__group {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 100%;
    gap: clamp(14px, 1.8vw, 23px);
    flex-shrink: 0;
    will-change: transform;
}

/* --------------------------------------------------------------------------
   Animações de Marquee Contínuo (GPU-accelerated)
   Fileira 1: Direita -> Esquerda
   Fileira 2: Esquerda -> Direita (sentido inverso)
   Fileira 3: Direita -> Esquerda
   -------------------------------------------------------------------------- */
.section-espaco__row--left .section-espaco__group {
    animation: espacoMarqueeLeft 42s linear infinite;
}

.section-espaco__row--right .section-espaco__group {
    animation: espacoMarqueeRight 42s linear infinite;
}

@keyframes espacoMarqueeLeft {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        transform: translate3d(calc(-100% - clamp(14px, 1.8vw, 23px)), 0, 0);
    }
}

@keyframes espacoMarqueeRight {
    0% {
        transform: translate3d(calc(-100% - clamp(14px, 1.8vw, 23px)), 0, 0);
    }
    100% {
        transform: translate3d(0, 0, 0);
    }
}

/* Pausa suave ao passar o mouse ou focar para permitir inspeção da fotografia */
.section-espaco__row:hover .section-espaco__group,
.section-espaco__row:focus-within .section-espaco__group {
    animation-play-state: paused;
}

/* --------------------------------------------------------------------------
   Itens Fotográficos e Proporções do Figma
   -------------------------------------------------------------------------- */
.section-espaco__item {
    position: relative;
    height: 100%;
    width: auto;
    aspect-ratio: var(--aspect-ratio, 16 / 9);
    flex: 0 0 auto;
    overflow: hidden;
    background-color: var(--color-neutral-300, #E8E2D6);
    box-sizing: border-box;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}

/* Classes utilitárias correspondentes aos presets do ACF por fileira */
.section-espaco__row--1 .section-espaco__item--larga {
    --slot-w: 538px;
    --slot-h: 307px;
    --aspect-ratio: 538 / 307;
}
.section-espaco__row--1 .section-espaco__item--media {
    --slot-w: 326px;
    --slot-h: 307px;
    --aspect-ratio: 326 / 307;
}
.section-espaco__row--1 .section-espaco__item--estreita {
    --slot-w: 242px;
    --slot-h: 307px;
    --aspect-ratio: 242 / 307;
}

.section-espaco__row--2 .section-espaco__item--larga {
    --slot-w: 553px;
    --slot-h: 211px;
    --aspect-ratio: 553 / 211;
}
.section-espaco__row--2 .section-espaco__item--media {
    --slot-w: 276px;
    --slot-h: 211px;
    --aspect-ratio: 276 / 211;
}
.section-espaco__row--2 .section-espaco__item--estreita {
    --slot-w: 200px;
    --slot-h: 211px;
    --aspect-ratio: 200 / 211;
}

.section-espaco__row--3 .section-espaco__item--larga {
    --slot-w: 557px;
    --slot-h: 192px;
    --aspect-ratio: 557 / 192;
}
.section-espaco__row--3 .section-espaco__item--media {
    --slot-w: 376px;
    --slot-h: 192px;
    --aspect-ratio: 376 / 192;
}
.section-espaco__row--3 .section-espaco__item--estreita {
    --slot-w: 173px;
    --slot-h: 192px;
    --aspect-ratio: 173 / 192;
}

/* No desktop, fixa as dimensões exatas de slot para estabilidade visual perfeita */
@media (min-width: 1024px) {
    .section-espaco__row--1 {
        height: 307px;
    }
    .section-espaco__row--2 {
        height: 211px;
    }
    .section-espaco__row--3 {
        height: 192px;
    }
    .section-espaco__item {
        width: var(--slot-w);
        height: var(--slot-h);
        flex: 0 0 var(--slot-w);
    }
}

.section-espaco__item:hover {
    transform: translateY(-2px) scale(1.015);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    z-index: 2;
}

.section-espaco__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-espaco__item:hover .section-espaco__img {
    transform: scale(1.04);
}

/* --------------------------------------------------------------------------
   Skeleton Estrutural Limpo (Regra rígida GEMINI: zero imagens fictícias)
   -------------------------------------------------------------------------- */
.section-espaco__item--skeleton {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(216, 210, 200, 0.45) 0%, rgba(216, 210, 200, 0.15) 50%, rgba(216, 210, 200, 0.45) 100%);
    background-size: 200% 200%;
    animation: section-espaco-shimmer 3s ease infinite;
    cursor: default;
}

.section-espaco__item--skeleton:hover {
    transform: none;
    box-shadow: none;
}

.section-espaco__skeleton-shimmer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    box-sizing: border-box;
    color: var(--color-neutral-600, #8E887E);
    font-family: var(--font-sans, 'Source Sans 3', sans-serif);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.section-espaco__skeleton-shimmer svg {
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

@keyframes section-espaco-shimmer {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* --------------------------------------------------------------------------
   Acessibilidade: Redução de Movimento
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .section-espaco__row--left .section-espaco__group,
    .section-espaco__row--right .section-espaco__group {
        animation: none !important;
    }
    
    .section-espaco__row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .section-espaco__item {
        scroll-snap-align: start;
        transition: none;
    }

    .section-espaco__item:hover {
        transform: none;
    }

    .section-espaco__item--skeleton {
        animation: none;
    }
}
