/* ============================================================
   PM ARQUITECTURA - STYLESHEET
   Estudio de arquitectura con transiciones experimentales
   ============================================================ */

/* ==================== CSS RESET ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-snap-type: y mandatory;
  overflow-x: hidden;
  scroll-behavior: auto; /* Controlamos scroll con JS */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.no-scroll {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

/* ==================== CSS VARIABLES ==================== */
:root {
  /* Colores */
  --color-bg: #fafafa;
  --color-text: #333333;
  
  /* Tamaños de fuente */
  --font-size-hero: clamp(1.5rem, 3.5vw, 2.2rem);
  --font-size-project-name: clamp(2.5rem, 6vw, 4rem);
  --font-size-body: clamp(0.875rem, 1.2vw, 1rem);
  --font-size-label: clamp(0.65rem, 0.9vw, 0.75rem);
  --font-size-small: 0.8rem;
  
  /* Espaciado */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 2rem;
  --spacing-lg: 4rem;
  --spacing-xl: 6rem;
  
  /* Layout */
  --header-padding: clamp(2rem, 5vw, 3.5rem);
  --logo-size: clamp(45px, 6vw, 60px);
  --bullet-size: 8px;
  --instagram-size: 28px;
  
  /* Transiciones */
  --transition-duration: 1s;
  --transition-easing: cubic-bezier(0.77, 0, 0.175, 1);
  --transition-fast: 0.3s ease;
  
  /* Z-index */
  --z-preloader: 9999;
  --z-fixed-elements: 1000;
  --z-mask: 100;
  --z-content: 1;
}

/* ==================== PRELOADER ==================== */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--color-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-preloader);
  transition: opacity 0.6s ease 0.2s, visibility 0.6s ease 0.2s;
}

.preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader__logo {
  width: 100px;
  height: 100px;
}

.preloader__logo svg {
  width: 100%;
  height: 100%;
}

.preloader__path {
  fill: var(--color-text);
  opacity: 0;
  animation: preloaderFade 2s ease forwards;
}

@keyframes preloaderFade {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==================== ELEMENTOS FIJOS ==================== */
.fixed-elements {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-fixed-elements);
}

.fixed-elements > * {
  pointer-events: auto;
}

/* Logo fijo */
.logo {
  position: absolute;
  top: var(--header-padding);
  left: var(--header-padding);
  width: var(--logo-size);
  height: var(--logo-size);
  transition: var(--transition-fast);
}

.logo:hover {
  opacity: 0.7;
}

.logo svg {
  width: 100%;
  height: 100%;
  fill: var(--color-text);
}

/* Bullets de navegación */
.bullets {
  position: absolute;
  right: var(--header-padding);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing-sm) * 1.2);
}

.bullet {
  width: var(--bullet-size);
  height: var(--bullet-size);
  border-radius: 50%;
  background-color: transparent;
  border: 1.5px solid var(--color-text);
  opacity: 0.35;
  transition: var(--transition-fast);
}

.bullet.active {
  background-color: var(--color-text);
  opacity: 1;
}

/* Instagram link */
.instagram {
  position: absolute;
  bottom: var(--header-padding);
  right: var(--header-padding);
  width: var(--instagram-size);
  height: var(--instagram-size);
  color: var(--color-text);
  transition: var(--transition-fast);
}

.instagram:hover {
  opacity: 0.6;
  transform: scale(1.05);
}

.instagram svg {
  width: 100%;
  height: 100%;
}

/* ==================== CONTENEDOR PRINCIPAL ==================== */
.main {
  width: 100%;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
}

/* ==================== SECCIONES BASE ==================== */
.section {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  overflow: hidden;
  background-color: var(--color-bg);
}

.section__content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: var(--header-padding);
  z-index: var(--z-content);
}

/* ==================== MÁSCARA DIAGONAL (TRANSICIÓN) ==================== */
.section__mask {
  position: absolute;
  top: 0;
  left: -20%;
  width: 140%;
  height: 100%;
  background-color: var(--color-bg);
  transform: translateX(-100%) skewX(-12deg);
  z-index: var(--z-mask);
  pointer-events: none;
  transition: transform var(--transition-duration) var(--transition-easing);
}

/* Estados de transición */
.section.mask-enter .section__mask {
  transform: translateX(100%) skewX(-12deg);
}

.section.mask-active .section__mask {
  transform: translateX(0%) skewX(-12deg);
}

.section.mask-exit .section__mask {
  transform: translateX(-100%) skewX(-12deg);
}

/* ==================== ANIMACIÓN DE CONTENIDO ==================== */
.section .intro__content,
.section .project__info,
.section .project__image {
  opacity: 0;
  transform: translateY(40px);
  transition: 
    opacity 0.8s ease,
    transform 0.8s var(--transition-easing);
}

.section .project__image {
  transform: translateY(40px) scale(0.98);
  transition-delay: 0.15s;
}

/* Estado visible */
.section.is-visible .intro__content,
.section.is-visible .project__info {
  opacity: 1;
  transform: translateY(0);
}

.section.is-visible .project__image {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ==================== SECCIÓN INTRO ==================== */
.section--intro .section__content {
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding-bottom: calc(var(--header-padding) * 2.5);
}

.intro__content {
  max-width: 650px;
}

.intro__title {
  font-size: var(--font-size-hero);
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: var(--spacing-md);
  letter-spacing: -0.01em;
}

.intro__subtitle {
  font-size: var(--font-size-body);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
}

.intro__location {
  font-size: var(--font-size-small);
  font-weight: 400;
  opacity: 0.6;
}

/* ==================== SECCIÓN PROYECTO ==================== */
.section--project .section__content {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: var(--spacing-lg);
  align-items: center;
  padding-top: calc(var(--logo-size) + var(--header-padding) + var(--spacing-md));
}

.project__info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.project__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project__label {
  font-size: var(--font-size-label);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0.45;
  font-weight: 400;
}

.project__value {
  font-size: var(--font-size-body);
  font-weight: 600;
}

.project__value--name {
  font-size: var(--font-size-project-name);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.project__value--location {
  line-height: 1.5;
}

.project__image {
  position: relative;
  width: 100%;
  height: 70vh;
  max-height: 700px;
  overflow: hidden;
}

.project__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==================== RESPONSIVE - TABLET ==================== */
@media (max-width: 1024px) {
  :root {
    --header-padding: 2rem;
    --logo-size: 50px;
    --instagram-size: 26px;
  }
  
  .section--project .section__content {
    grid-template-columns: minmax(180px, 240px) 1fr;
    gap: var(--spacing-md);
  }
  
  .project__image {
    height: 60vh;
    max-height: 550px;
  }
}

/* ==================== RESPONSIVE - MOBILE ==================== */
@media (max-width: 768px) {
  :root {
    --header-padding: 1.5rem;
    --logo-size: 42px;
    --bullet-size: 7px;
    --instagram-size: 24px;
    --font-size-project-name: clamp(2rem, 10vw, 3rem);
  }
  
  /* Sección Intro */
  .section--intro .section__content {
    justify-content: center;
    padding-top: calc(var(--logo-size) + var(--header-padding) * 2);
    padding-bottom: calc(var(--header-padding) * 2);
  }
  
  .intro__content {
    max-width: 100%;
  }
  
  /* Sección Proyecto - Layout vertical */
  .section--project .section__content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: calc(var(--logo-size) + var(--header-padding) + var(--spacing-sm));
    gap: var(--spacing-md);
  }
  
  .project__image {
    order: 1;
    width: calc(100% + var(--header-padding) * 2);
    margin-left: calc(var(--header-padding) * -1);
    margin-right: calc(var(--header-padding) * -1);
    height: 45vh;
    max-height: 380px;
  }
  
  .project__info {
    order: 2;
    width: 100%;
    gap: var(--spacing-sm);
  }
  
  .project__row {
    flex-direction: row;
    align-items: baseline;
    gap: var(--spacing-sm);
  }
  
  .project__label {
    min-width: 70px;
  }
  
  /* Instagram en mobile - mover abajo izquierda */
  .instagram {
    right: auto;
    left: var(--header-padding);
  }
  
  /* Bullets más juntos */
  .bullets {
    gap: var(--spacing-sm);
  }
  
  /* Máscara más pronunciada en mobile */
  .section__mask {
    left: -30%;
    width: 160%;
    transform: translateX(-100%) skewX(-8deg);
  }
  
  .section.mask-enter .section__mask {
    transform: translateX(100%) skewX(-8deg);
  }
  
  .section.mask-active .section__mask {
    transform: translateX(0%) skewX(-8deg);
  }
  
  .section.mask-exit .section__mask {
    transform: translateX(-100%) skewX(-8deg);
  }
}

/* ==================== RESPONSIVE - MOBILE PEQUEÑO ==================== */
@media (max-width: 374px) {
  :root {
    --header-padding: 1.25rem;
    --logo-size: 38px;
  }
  
  .project__label {
    min-width: 60px;
    font-size: 0.6rem;
  }
  
  .project__image {
    height: 40vh;
    max-height: 320px;
  }
}

/* ==================== ANIMACIÓN INICIAL (PRIMERA CARGA) ==================== */
.section[data-section="0"].is-visible .intro__content {
  animation: fadeInUp 1s ease 0.3s both;
}

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

/* ==================== MEJORAS DE ACCESIBILIDAD ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* Focus visible para navegación por teclado */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 4px;
}

/* ==================== UTILIDADES ==================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
