/* ============================================
   IVO LÓPEZ — Portafolio interactivo
   Estética editorial · alto contraste · tipográfica
   ============================================ */

:root {
  /* Paleta */
  --ink: #0a0a0a;
  --ink-soft: #1a1a1a;
  --paper: #f4f1ec;       /* off-white cálido tipo papel */
  --paper-pure: #ffffff;
  --rule: #e5e0d8;
  --muted: #6b6660;

  /* Acentos (heredados del CV original, refinados) */
  --accent-magenta: #ff2d6f;
  --accent-orange:  #ff5722;
  --accent-purple:  #7a3cff;
  --accent-green:   #1fbf6b;
  --accent-blue:    #2196f3;

  /* Tipografía */
  --font-display: "Instrument Serif", "Times New Roman", serif;
  --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Escala (clamp para fluidez) */
  --fs-display: clamp(4rem, 14vw, 13rem);
  --fs-title:   clamp(2.5rem, 6.5vw, 6rem);
  --fs-large:   clamp(1.5rem, 2.5vw, 2.25rem);
  --fs-body:    clamp(1rem, 1.05vw, 1.125rem);
  --fs-small:   0.875rem;
  --fs-eyebrow: 0.75rem;

  /* Espaciado */
  --pad-x: clamp(1.5rem, 6vw, 6rem);
  --pad-section: clamp(5rem, 12vw, 10rem);
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; }
em { font-style: italic; font-family: var(--font-display); font-weight: 400; }

::selection { background: var(--ink); color: var(--paper); }

/* ---------- NAV ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem var(--pad-x);
  background: rgba(244, 241, 236, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.nav.is-scrolled { border-bottom-color: var(--rule); }

.nav__brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.nav__icon {
  width: 2em;
  height: auto;
  flex-shrink: 0;
  /* desplazamiento óptico mínimo para que la punta del lápiz quede alineada con la base de la tipografía */
  transform: translateY(-0.05em);
}
.nav__brand-text { display: inline-block; }
.nav__dot { color: var(--accent-magenta); }

.nav__list {
  display: flex;
  gap: 2rem;
  align-items: center;
  font-size: var(--fs-small);
  font-weight: 500;
}
.nav__list a {
  position: relative;
  padding: 0.25rem 0;
  transition: color 0.2s ease;
}
.nav__list a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}
.nav__list a:hover::after { transform: scaleX(1); transform-origin: left; }

.nav__cta {
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1.1rem !important;
  border-radius: 999px;
}
.nav__cta::after { display: none; }
.nav__cta:hover { background: var(--accent-magenta); }

@media (max-width: 640px) {
  .nav__list li:not(:last-child) { display: none; }
}

/* ---------- HERO ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--pad-section) var(--pad-x) 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.hero__inner { width: 100%; max-width: 1600px; margin: 0 auto; }

.hero__eyebrow {
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2rem;
  opacity: 0;
  animation: heroFade 0.7s ease 0.1s forwards;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-display);
  line-height: 0.86;
  letter-spacing: -0.035em;
  margin-bottom: 1.5rem;
}
.hero__name {
  display: inline-block;
  opacity: 0;
  transform: translateY(40px);
  animation: heroNameIn 1s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

.hero__role {
  font-size: var(--fs-large);
  font-weight: 300;
  color: var(--ink-soft);
  margin-bottom: 3.5rem;
  max-width: 50ch;
  opacity: 0;
  animation: heroFade 0.8s ease 1.1s forwards;
}

/* Conceptos en cascada — flujo horizontal, fluido */
.hero__keywords {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: baseline;
  font-family: var(--font-display);
  font-style: italic;
  list-style: none;
}
.kw {
  font-size: clamp(2rem, 6vw, 5.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  opacity: 0;
  transform: translateY(30px);
  /* Dos animaciones encadenadas: entrada (forwards) + onda continua (infinite) */
  animation:
    kwReveal 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards,
    kwWave 5s ease-in-out infinite;
  position: relative;
  transition: transform 0.4s ease, color 0.4s ease;
}
.kw:not(:last-child)::after {
  content: "·";
  display: inline-block;
  margin-left: clamp(1rem, 3vw, 2.5rem);
  color: var(--muted);
  font-style: normal;
  font-family: var(--font-sans);
  opacity: 0.4;
}
.kw:hover { transform: translateY(-8px) !important; opacity: 1 !important; }

/* Delays separados por animación:
   1ª valor = delay para kwReveal (cascada de entrada)
   2ª valor = delay para kwWave (onda perpetua: entra después de la cascada + 2s)
   Cada palabra arranca su onda en un momento distinto → efecto de ola */
.kw--1 { color: var(--accent-magenta); animation-delay: 1.5s,  4.5s; }
.kw--2 { color: var(--accent-orange);  animation-delay: 1.75s, 5s;   }
.kw--3 { color: var(--accent-purple);  animation-delay: 2s,    5.5s; }
.kw--4 { color: var(--accent-green);   animation-delay: 2.25s, 6s;   }
.kw--5 { color: var(--accent-blue);    animation-delay: 2.5s,  6.5s; }

@keyframes heroFade {
  to { opacity: 1; }
}
@keyframes heroNameIn {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes kwReveal {
  to { opacity: 1; transform: translateY(0); }
}
/* Onda perpetua: cada palabra baja a 25% de opacidad y vuelve, con leve flotación.
   El desfase entre palabras crea un efecto de ola que recorre el grupo. */
@keyframes kwWave {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50%      { opacity: 0.25; transform: translateY(-10px); }
}

.hero__scroll {
  position: absolute;
  bottom: 2rem;
  right: var(--pad-x);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  animation: heroFade 0.8s ease 2.8s forwards;
}
.hero__scroll svg { transition: transform 0.3s ease; }
.hero__scroll:hover svg { transform: translateY(4px); }

/* ---------- SECTION SHARED ---------- */
.section__eyebrow {
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.section__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-title);
  line-height: 0.95;
  letter-spacing: -0.025em;
  max-width: 18ch;
}

/* ---------- AGENCIES ---------- */
.agencies {
  padding: var(--pad-section) var(--pad-x);
  background: var(--ink);
  color: var(--paper);
  position: relative;
}
.agencies__intro { max-width: 1600px; margin: 0 auto 5rem; }
.agencies__intro .section__eyebrow { color: rgba(244, 241, 236, 0.6); }

.agencies__wall {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 6rem);
}
@media (max-width: 760px) { .agencies__wall { grid-template-columns: 1fr; } }

.agencies__col {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.agency, .brand {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  opacity: 0.4;
  transition: opacity 0.4s ease, transform 0.4s ease, color 0.4s ease;
  cursor: default;
}
.agency:hover, .brand:hover {
  opacity: 1;
  transform: translateX(0.5rem);
  color: var(--accent-magenta);
}
/* "Encendido" aleatorio en móvil (replica el hover de desktop).
   Se activa desde JS solo en dispositivos sin hover. */
.agency.is-lit, .brand.is-lit {
  opacity: 1 !important;
  color: var(--accent-magenta) !important;
  transform: translateX(0.5rem) !important;
}
.agencies__col--brands { gap: 0.1rem; }
.agencies__col--brands .brand {
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ---------- TIMELINE ---------- */
.timeline {
  padding: var(--pad-section) var(--pad-x);
  background: var(--paper);
}
.timeline__intro { max-width: 1600px; margin: 0 auto 5rem; }

.timeline__list {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  padding-left: 2rem;
  border-left: 1px solid var(--rule);
}
.tl-item {
  position: relative;
  padding: 2rem 0 2.5rem 2rem;
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.tl-item.is-visible { opacity: 1; transform: translateY(0); }
.tl-item::before {
  content: "";
  position: absolute;
  left: -2.4rem;
  top: 2.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  transition: background 0.3s ease, transform 0.3s ease;
}
.tl-item:hover::before { background: var(--accent-magenta); transform: scale(1.5); }
.tl-item--current::before { background: var(--accent-magenta); box-shadow: 0 0 0 6px rgba(255, 45, 111, 0.15); }

.tl-item__year {
  font-size: var(--fs-small);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 0.5rem;
}
.tl-item__company {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.5rem;
}
.tl-item__role {
  font-size: var(--fs-large);
  font-weight: 300;
  margin-bottom: 0.75rem;
}
.tl-item__brands {
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- PORTFOLIO ---------- */
.portfolio {
  padding: var(--pad-section) 0;
  background: var(--paper-pure);
  overflow: hidden;
}
.portfolio__intro {
  max-width: 1600px;
  margin: 0 auto 4rem;
  padding: 0 var(--pad-x);
}

.portfolio__nav {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.portfolio__nav a {
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--muted);
  transition: all 0.25s ease;
}
.portfolio__nav a:hover {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

/* ---------- SHELF (estantería horizontal) ---------- */
.portfolio__shelves {
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 6vw, 5rem);
}
.shelf { scroll-margin-top: 100px; } /* offset para anchors con nav fijo */

.shelf__header {
  max-width: 1600px;
  margin: 0 auto 1.5rem;
  padding: 0 var(--pad-x);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.shelf__heading {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.shelf__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}
.shelf__count {
  font-size: var(--fs-small);
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.shelf__hint {
  font-size: var(--fs-small);
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-display);
  max-width: 32ch;
}

.shelf__controls {
  display: flex;
  gap: 0.5rem;
}
.shelf__arrow {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}
.shelf__arrow:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.shelf__arrow:disabled { opacity: 0.3; cursor: not-allowed; }
@media (max-width: 760px) { .shelf__controls { display: none; } } /* en móvil basta el swipe */

.shelf__track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-padding-left: var(--pad-x);
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 var(--pad-x) 1rem;
  height: clamp(320px, 56vh, 560px);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.shelf__track::-webkit-scrollbar { display: none; }
.shelf__track.is-grabbing { cursor: grabbing; scroll-behavior: auto; }
.shelf__track.is-grabbing * { pointer-events: none; }

/* Piezas dentro del shelf */
.piece {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  cursor: pointer;
  height: 100%;
  flex: 0 0 auto;
  scroll-snap-align: start;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.piece.is-visible { opacity: 1; transform: translateY(0); }

/* Aspect-ratios → controlan el ancho (height fijo del shelf) */
.piece--wide { aspect-ratio: 16 / 9; }
.piece--lg   { aspect-ratio: 4 / 3;  }
.piece--md   { aspect-ratio: 1 / 1;  }
.piece--sm   { aspect-ratio: 3 / 4;  }
.piece--tall { aspect-ratio: 2 / 3;  }

.piece img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease, filter 0.4s ease;
  pointer-events: none;
}
.piece:hover img { transform: scale(1.04); }

.piece__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 1.25rem;
  background: linear-gradient(to top, rgba(10,10,10,0.85) 0%, rgba(10,10,10,0) 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  color: var(--paper);
  pointer-events: none;
}
.piece:hover .piece__overlay { opacity: 1; }
.piece__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.1;
  font-weight: 400;
}
.piece__cat {
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  opacity: 0.8;
}

/* Indicador "→ desliza" para hint visual */
.shelf__hint-swipe {
  display: none;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 var(--pad-x);
  margin-top: -0.5rem;
}
@media (max-width: 760px) {
  .shelf__hint-swipe { display: block; }
  .shelf__track { height: clamp(280px, 50vh, 420px); }
}

/* ---------- ABOUT ---------- */
.about {
  padding: var(--pad-section) var(--pad-x);
  background: var(--paper);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 6vw, 6rem);
  max-width: 1600px;
  margin: 0 auto;
}
@media (max-width: 900px) { .about { grid-template-columns: 1fr; } }

.about__lead {
  font-size: var(--fs-large);
  font-weight: 300;
  line-height: 1.4;
  margin-top: 2rem;
  max-width: 32ch;
}

.skills-group { margin-bottom: 2.5rem; }
.skills-group__title {
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.skills-group ul { display: flex; flex-direction: column; gap: 0.35rem; }
.skills-group ul li {
  font-size: var(--fs-body);
  font-weight: 400;
}
.skills-group__inline {
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 0.4rem 1rem !important;
}

/* ---------- CONTACT ---------- */
.contact {
  padding: var(--pad-section) var(--pad-x);
  background: var(--ink);
  color: var(--paper);
  text-align: center;
}
.contact__eyebrow { color: rgba(244, 241, 236, 0.6); }
.contact__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-display);
  line-height: 0.88;
  letter-spacing: -0.035em;
  margin-bottom: 3rem;
}
.contact__methods {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.contact__link {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  position: relative;
  padding-bottom: 0.25rem;
}
.contact__link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 0.4s ease;
}
.contact__link:hover { color: var(--accent-magenta); }
.contact__link:hover::after { transform: scaleX(0); transform-origin: right; }

/* ---------- LIGHTBOX ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }

.lightbox__figure {
  max-width: 92vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.lightbox__img {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
}
.lightbox__caption {
  color: var(--paper);
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.lightbox__close,
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(244, 241, 236, 0.1);
  color: var(--paper);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.lightbox__close { top: 1.5rem; right: 1.5rem; transform: none; width: 48px; height: 48px; font-size: 1.75rem; }
.lightbox__nav--prev { left: 1.5rem; }
.lightbox__nav--next { right: 1.5rem; }
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(244, 241, 236, 0.2); }

/* ---------- FOOTER ---------- */
.footer {
  padding: 2rem var(--pad-x);
  text-align: center;
  font-size: var(--fs-small);
  color: var(--muted);
  background: var(--ink);
  border-top: 1px solid rgba(244, 241, 236, 0.08);
}

/* ---------- ANIMACIONES DE ENTRADA (genéricas) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
