:root {
  --bg: #f5f2ec;
  --bg-hover: #ebe7df;
  --text: #111111;
  --text-muted: #666666;
  --text-light: #999999;
  --border: #e5e5e5;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 17, 17, 0.35) transparent;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

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

::selection {
  background: var(--text);
  color: var(--bg);
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(17, 17, 17, 0.28);
  border-radius: 6px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 17, 17, 0.5);
}

:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 3px;
}

/* Loader */
.loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--bg);
  opacity: 1;
  transition: opacity 0.7s var(--ease), visibility 0.7s var(--ease);
}

.loader.done {
  opacity: 0;
  visibility: hidden;
}

.loader-mark {
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 4vw, 2.4rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  opacity: 0;
  animation: loaderFade 1s var(--ease) forwards;
}

@keyframes loaderFade {
  to { opacity: 1; }
}

/* Grain */
.grain {
  position: fixed;
  inset: -60px;
  z-index: 90;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 1.4s steps(4) infinite;
}

@keyframes grainShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(0, 0); }
}

/* Custom cursor */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3000;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.cursor-dot {
  width: 7px;
  height: 7px;
  background: var(--text);
}

.cursor-ring {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(17, 17, 17, 0.35);
  transition: width 0.3s var(--ease), height 0.3s var(--ease),
    border-color 0.3s var(--ease), opacity 0.35s var(--ease);
}

.cursor-dot.on,
.cursor-ring.on {
  opacity: 1;
}

.cursor-ring.grow {
  width: 72px;
  height: 72px;
  border-color: rgba(17, 17, 17, 0.12);
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 4vw;
  position: sticky;
  top: 0;
  background: rgba(245, 242, 236, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}

.site-header.scrolled {
  border-color: var(--border);
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.logo::after {
  content: '·';
  color: var(--text-muted);
}

.main-nav {
  display: flex;
  gap: 2rem;
}

.main-nav a {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.25s var(--ease);
  position: relative;
}

.main-nav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text);
  transition: width 0.25s var(--ease);
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
}

.main-nav a:hover::after,
.main-nav a.active::after {
  width: 100%;
}

/* Hero */
.hero {
  text-align: center;
  padding: 10vh 4vw 4vh;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Hero slider */
.hero-slider {
  position: relative;
  height: min(86vh, 760px);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
}

.hero-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.6s ease;
  will-change: opacity, transform;
}

.hero-slide.active {
  opacity: 1;
  animation: kenburns 16s ease-out forwards;
}

@keyframes kenburns {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.45));
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero-content h1 {
  color: #ffffff;
  text-shadow: 0 2px 32px rgba(0, 0, 0, 0.4);
}

.hero-content .hero-subtitle {
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.5);
}

/* Marquee */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 0;
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 24s linear infinite;
}

.marquee:hover .marquee-track {
  animation-play-state: paused;
}

.marquee-track span {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.marquee-track em {
  font-style: normal;
  color: var(--text-muted);
}

@keyframes marquee {
  to { transform: translateX(-50%); }
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 4vh 4vw 3vh;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--text);
  color: var(--text);
}

.filter-btn.active {
  background: var(--text);
  color: var(--bg);
}

/* Projects */
.projects-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 0 10vh;
}

.project-card {
  opacity: 0;
  transform: translateY(42px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

.project-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.project-card,
.project-card--featured,
.project-card--featured:nth-child(4) {
  width: 100%;
  align-self: stretch;
}

.project-card.hidden {
  display: none;
}

.project-card a {
  display: block;
}

.project-image {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: min(92vh, 940px);
  background: var(--bg-hover);
  transform: translate3d(0, var(--parallax-y, 0), 0);
  transition: transform 0.2s linear;
  will-change: transform;
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: saturate(0.9) contrast(1.02);
  transition: transform 1.15s var(--ease), filter 0.7s ease;
}

.project-card:hover .project-image img {
  transform: scale(1.05);
  filter: saturate(1) contrast(1.04);
}

.project-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 1.1rem 4vw 0;
  gap: 1rem;
}

.project-info h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.6vw, 1.8rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: letter-spacing 0.5s var(--ease), font-style 0.3s var(--ease);
}

.project-card a:hover .project-info h2 {
  letter-spacing: 0.005em;
  font-style: italic;
}

.project-info span {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  transition: color 0.3s var(--ease);
}

.project-card a:hover .project-info span {
  color: var(--text);
}

/* Reveal transitions */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1s var(--ease), transform 1.1s var(--ease);
}

.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

.reveal-media {
  opacity: 0;
  transform: scale(1.045);
  clip-path: inset(0 0 8% 0);
  filter: blur(10px);
  transition: opacity 1.2s var(--ease), transform 1.3s var(--ease),
    clip-path 1.2s var(--ease), filter 1.1s ease;
}

.reveal-media.in-view {
  opacity: 1;
  transform: scale(1);
  clip-path: inset(0 0 0 0);
  filter: blur(0);
}

/* Footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2.5rem 4vw;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer-tagline {
  color: var(--text-light);
}

.social-links {
  display: flex;
  gap: 1.5rem;
}

.social-links a {
  position: relative;
  transition: color 0.25s var(--ease);
}

.social-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text);
  transition: width 0.25s var(--ease);
}

.social-links a:hover {
  color: var(--text);
}

.social-links a:hover::after {
  width: 100%;
}

/* About */
.about-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4rem;
  align-items: start;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10vh 4vw 10vh;
}

@media (min-width: 768px) {
  .about-section {
    grid-template-columns: 1fr 1fr;
  }
}

.about-portrait {
  overflow: hidden;
}

.about-portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.about-content h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  margin-bottom: 2rem;
}

.about-content p {
  margin-bottom: 1.25rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.clients {
  margin-top: 3rem;
}

.clients h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.clients ul {
  list-style: none;
  display: grid;
  gap: 0.5rem;
  color: var(--text-muted);
}

/* Contact */
.contact-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 10vh 4vw 10vh;
}

.contact-intro {
  text-align: center;
  margin-bottom: 4rem;
}

.contact-intro h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  margin-bottom: 0.75rem;
}

.contact-intro p {
  color: var(--text-muted);
}

.contact-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 4rem;
}

.contact-details a {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  transition: color 0.25s var(--ease), font-style 0.3s var(--ease);
}

.contact-details a:hover {
  color: var(--text-muted);
  font-style: italic;
}

.contact-form {
  display: grid;
  gap: 1.5rem;
}

.contact-form label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: -0.8rem;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 1rem 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.25s var(--ease);
}

.contact-form input:focus,
.contact-form textarea:focus {
  border-color: var(--text);
}

.contact-form textarea {
  resize: vertical;
  min-height: 120px;
}

.contact-form button {
  justify-self: center;
  margin-top: 1rem;
  padding: 1rem 2.5rem;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.contact-form button:hover {
  background: transparent;
  color: var(--text);
}

/* Project page */
.project-page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 9vh 4vw 10vh;
}

.project-header {
  text-align: center;
  margin-bottom: 4rem;
}

.project-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  font-weight: 300;
  line-height: 1.02;
  margin-bottom: 1.2rem;
}

.project-meta-row {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-light);
  flex-wrap: wrap;
}

.project-hero-image {
  margin-bottom: 5rem;
}

.project-hero-image img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  object-position: center;
}

.project-description {
  max-width: 680px;
  margin: 0 auto 6rem;
  text-align: center;
}

.project-description p {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 300;
  margin-bottom: 1.25rem;
}

.project-description .project-client {
  margin-top: 2rem;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text);
  letter-spacing: 0.03em;
}

/* Gallery editorial */
.project-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

.project-gallery figure {
  overflow: hidden;
  background: var(--bg-hover);
}

.project-gallery img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  transition: transform 1.4s var(--ease), filter 0.7s ease;
  filter: saturate(0.92);
}

.project-gallery figure:hover img {
  transform: scale(1.035);
  filter: saturate(1);
}

@media (min-width: 760px) {
  .project-gallery {
    grid-template-columns: repeat(12, 1fr);
    gap: 3rem 2.5rem;
  }

  .project-gallery figure:nth-child(1) {
    grid-column: 1 / -1;
  }

  .project-gallery figure:nth-child(1) img {
    aspect-ratio: 16 / 9;
  }

  .project-gallery figure:nth-child(even) {
    grid-column: 1 / 7;
  }

  .project-gallery figure:nth-child(odd) {
    grid-column: 7 / 13;
    transform: translateY(-3rem);
  }

  .project-gallery figure:nth-child(1) {
    transform: none;
  }
}

.project-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-top: 6rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.project-nav a {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.25s var(--ease), letter-spacing 0.4s var(--ease);
}

.project-nav a:hover {
  color: var(--text);
  letter-spacing: 0.12em;
}

.project-nav .nav-prev {
  justify-self: start;
}

.project-nav .nav-center {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.04em;
  justify-self: center;
}

.project-nav .nav-next {
  justify-self: end;
  text-align: right;
}

/* Responsive */
@media (max-width: 768px) {
  html {
    -webkit-tap-highlight-color: transparent;
  }

  .site-header {
    flex-direction: column;
    gap: 0.8rem;
    padding: 1.1rem calc(4vw + env(safe-area-inset-left)) 1rem calc(4vw + env(safe-area-inset-right));
  }

  .logo {
    font-size: 1.5rem;
  }

  .main-nav {
    gap: 1.4rem;
  }

  .hero h1 {
    font-size: clamp(2.1rem, 11vw, 3.4rem);
  }

  .hero-slider {
    height: 100svh;
  }

  /* Filtros: fila deslizable, sin salto de línea */
  .filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1.4rem;
    margin: 0;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex: 0 0 auto;
  }

  .marquee-track {
    animation-duration: 16s;
  }

  .marquee-track span {
    font-size: 1.5rem;
  }

  .projects-grid {
    gap: 0;
    padding: 0;
  }

  .project-card {
    height: 100svh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    transform: none;
  }

  .project-card.is-visible {
    opacity: 1;
    transform: none;
  }

  .project-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: none;
  }

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

  .project-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    margin: 0;
    padding: 6vw 5vw;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: #fff;
    flex-direction: column;
    gap: 0.5rem;
  }

  .project-info h2,
  .project-info span {
    color: #fff;
  }

  .project-card--featured,
  .project-card--featured:nth-child(4) {
    width: 100vw;
    align-self: stretch;
  }

  .project-info h2 {
    font-size: 1.45rem;
  }

  .project-info span {
    font-size: 0.68rem;
  }

  .project-page {
    padding: 7vh calc(2.5vw + env(safe-area-inset-left)) 8vh calc(2.5vw + env(safe-area-inset-right));
  }

  .project-gallery {
    gap: 1.6rem;
  }

  .project-nav {
    grid-template-columns: 1fr auto;
    gap: 0.8rem 1rem;
  }

  .project-nav .nav-prev {
    justify-self: start;
  }

  .project-nav .nav-next {
    justify-self: end;
  }

  .project-nav .nav-center {
    display: block;
    grid-column: 1 / -1;
    justify-self: center;
    order: 3;
    font-size: 0.95rem;
    margin-top: 0.4rem;
  }

  .site-footer {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding-left: calc(4vw + env(safe-area-inset-left));
    padding-right: calc(4vw + env(safe-area-inset-right));
    padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
  }

  .footer-left {
    flex-direction: column;
    gap: 0.25rem;
  }

  .project-meta-row {
    gap: 1rem;
  }

  /* Deslizar con el pulgar dejando "chicle" al final */
  .projects-grid,
  .filters {
    overscroll-behavior-y: contain;
  }
}

.preview-mode .reveal,
.preview-mode .reveal-media,
.preview-mode .project-card {
  opacity: 1;
  transform: none;
  clip-path: none;
  filter: none;
  transition: none;
}

.preview-mode .loader {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .loader-mark,
  .marquee-track,
  .hero-slide.active,
  .grain {
    animation: none;
  }

  .grain {
    transform: none;
  }

  .project-card,
  .reveal,
  .reveal-media {
    opacity: 1;
    transform: none;
    clip-path: none;
    filter: none;
    transition: none;
  }

  .project-image,
  .project-image img,
  .main-nav a::after,
  .social-links a::after,
  .project-info h2 {
    transform: none;
    animation: none;
    transition: none;
  }
}