/* ==========================================================================
   Santiago Pierrepont — Portfolio
   ========================================================================== */

:root {
  --bg: #F5F3EE;
  --bg-2: #ECEAE4;
  --ink: #222522;
  --ink-2: #4A4E48;
  --ink-3: #7A7E77;
  --line: color-mix(in oklab, var(--ink) 13%, transparent);
  --accent: #315A52;

  --serif: "Instrument Serif", "Iowan Old Style", "Times New Roman", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --max-w: 1280px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --gap: 14px;

  --ease: cubic-bezier(0.25, 1, 0.35, 1);
  --t-page: 820ms;
  --t-reveal: 880ms;
  --t-fast: 200ms;
}

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

html {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(34, 37, 34, 0.085) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: linear-gradient(
    to right,
    #000 0%,
    rgba(0, 0, 0, 0.5) clamp(10%, calc(50% - 500px), 24%),
    rgba(0, 0, 0, 0.5) clamp(76%, calc(50% + 500px), 90%),
    #000 100%
  );
  mask-image: linear-gradient(
    to right,
    #000 0%,
    rgba(0, 0, 0, 0.5) clamp(10%, calc(50% - 500px), 24%),
    rgba(0, 0, 0, 0.5) clamp(76%, calc(50% + 500px), 90%),
    #000 100%
  );
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}

p { font-size: 1rem; line-height: 1.72; color: var(--ink-2); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gutter); }

/* ──────── Barra superior ──────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 58px;
}

.brand { display: flex; align-items: baseline; gap: 0.55rem; }
.brand__mark { font-family: var(--serif); font-size: 1.55rem; line-height: 1; }
.brand__name { font-size: 0.86rem; color: var(--ink-3); }

.nav { display: flex; gap: 1.75rem; list-style: none; }
.nav button {
  font-size: 0.88rem; color: var(--ink-2);
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.nav button:hover { color: var(--ink); border-color: var(--ink); }

/* ──────── Escenario de vistas ──────── */
.stage { position: relative; width: 100%; overflow: hidden; min-height: calc(100vh - 58px); z-index: 1; }

.view {
  width: 100%;
  transition: transform var(--t-page) var(--ease), opacity var(--t-page) var(--ease);
  will-change: transform, opacity;
}
.view.is-inactive { display: none; }
.view.is-active { position: relative; opacity: 1; transform: translate3d(0,0,0); }
.view.in-transition { position: absolute; top: 0; left: 0; }
.view.from-right, .view.to-right { transform: translate3d(100%,0,0); opacity: 0; }
.view.from-left,  .view.to-left  { transform: translate3d(-35%,0,0); opacity: 0; }

/* Aparición progresiva de contenidos */
.reveal {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  transition: opacity var(--t-reveal) var(--ease), transform var(--t-reveal) var(--ease);
  transition-delay: var(--d, 0ms);
}
.reveal.is-in { opacity: 1; transform: translate3d(0,0,0); }

@media (prefers-reduced-motion: reduce) {
  .view, .reveal { transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ──────── Home ──────── */
.home-hero {
  min-height: calc(100vh - 58px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 0 2rem;
}
.home-hero .wrap { width: 100%; }

.intro { padding: 0 0 clamp(1.2rem, 2.5vw, 1.8rem); }
.intro h1 { font-size: clamp(2.4rem, 4.5vw, 3.8rem); }
.intro p { margin-top: 0.35rem; font-size: 1.05rem; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 0.65rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 1.55rem; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(1rem, 2vw, 1.75rem);
  padding-bottom: 0;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
}

.tile__img {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-2);
}
.tile__img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 1100ms var(--ease), filter var(--t-fast);
}
.tile:hover .tile__img img { transform: scale(1.035); }

.tile__meta {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0 0.25rem;
  padding-top: 0.9rem;
}
.tile__num { font-size: 0.82rem; color: var(--ink-3); padding-top: 0.3rem; font-variant-numeric: tabular-nums; }
.tile__title {
  font-family: var(--serif); font-size: 1.35rem; line-height: 1.15;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size 500ms var(--ease);
  justify-self: start;
}
.tile:hover .tile__title { background-size: 100% 1px; }
.tile__type { grid-column: 2; font-size: 0.84rem; color: var(--ink-3); margin-top: 0.3rem; }

/* ──────── Acerca de mí ──────── */
.about {
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: clamp(3.5rem, 6vw, 5rem) 0;
  position: relative;
  z-index: 2;
}

.about__grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}

.about h2 { font-size: clamp(2.1rem, 3.5vw, 2.75rem); margin-bottom: 0.8rem; line-height: 1.05; }
.about__photo { width: 100%; align-self: start; }
.about__photo img { width: 100%; height: auto; display: block; }
.about__text { max-width: 61ch; }
.about__text p { font-size: 0.92rem; line-height: 1.62; color: var(--ink-2); }
.about__text p + p { margin-top: 0.75rem; }

.cv {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  margin-top: clamp(3rem, 6vw, 4.5rem);
  padding-top: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
}

.cv h3 { font-size: 1.5rem; margin-bottom: 1.25rem; }

.job { padding: 1.1rem 0; border-top: 1px solid var(--line); }
.job:last-child { border-bottom: 1px solid var(--line); }
.job__head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: baseline; }
.job__role { font-size: 0.98rem; font-weight: 500; color: var(--ink); }
.job__where { color: var(--ink-3); font-weight: 400; }
.job__date { font-size: 0.84rem; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.job ul { list-style: none; margin-top: 0.45rem; }
.job li { font-size: 0.92rem; line-height: 1.6; color: var(--ink-2); padding-left: 1rem; position: relative; }
.job li + li { margin-top: 0.2rem; }
.job li::before { content: "–"; position: absolute; left: 0; color: var(--ink-3); }

.kv { display: grid; grid-template-columns: 9rem 1fr; gap: 0.25rem 1rem; padding: 0.8rem 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.kv:last-child { border-bottom: 1px solid var(--line); }
.kv dt { color: var(--ink-3); }
.kv dd { color: var(--ink); }
.cv__side h3 + dl { margin-bottom: 2.5rem; }

/* ──────── Contacto ──────── */
.contact { padding: clamp(3rem, 6vw, 4.5rem) 0 2.5rem; }
.contact__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: end; }
.contact h2 { font-size: clamp(2rem, 3.5vw, 2.6rem); margin-bottom: 1rem; }
.contact ul { list-style: none; }
.contact li { font-size: 0.98rem; padding: 0.2rem 0; color: var(--ink-2); }
.contact li a { color: var(--ink); border-bottom: 1px solid var(--line); transition: border-color var(--t-fast); }
.contact li a:hover { border-color: var(--ink); }
.contact__foot { text-align: right; font-size: 0.82rem; color: var(--ink-3); }

/* ──────── Vista de proyecto ──────── */
.pbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 0 0.85rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.pbar button { color: var(--ink-2); transition: color var(--t-fast); }
.pbar button:hover { color: var(--ink); }
.pbar__pager { display: flex; align-items: center; gap: 1.1rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.phead { padding: clamp(1.2rem, 2vw, 1.6rem) 0 clamp(0.9rem, 1.8vw, 1.25rem); }
.phead h1 {
  font-size: clamp(1.55rem, 2.5vw, 2.35rem);
  line-height: 1.08;
  max-width: none;
  white-space: nowrap;
}
@media (max-width: 1040px) {
  .phead h1 { white-space: normal; }
}

.pbody {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: clamp(1.5rem, 3vw, 2.75rem);
  padding-bottom: clamp(1.2rem, 2vw, 1.75rem);
  align-items: start;
}

.facts { font-size: 0.84rem; border-top: 1px solid var(--line); align-self: start; }
.facts div { padding: 0.42rem 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--ink-3); font-size: 0.76rem; margin-bottom: 0.08rem; }
.facts dd { color: var(--ink); line-height: 1.35; }

.pmemoria {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.25rem, 2.5vw, 2.5rem);
  align-items: start;
}
.pmemoria__col { display: flex; flex-direction: column; }
.pmemoria__head {
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}
.pmemoria__col p {
  font-size: 0.895rem;
  line-height: 1.58;
  color: var(--ink-2);
}

.ptext { max-width: 68ch; }
.ptext p + p { margin-top: 1.1rem; }

/* Galería en filas justificadas: cada lámina conserva su proporción y la fila comparte altura */
.gallery { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: var(--gap); align-items: stretch; }

.ph {
  flex: var(--r) 1 0;
  min-width: 0;
  display: flex; flex-direction: column;
  cursor: zoom-in;
}
.ph__img { aspect-ratio: var(--r); overflow: hidden; background: var(--bg-2); }
.ph__img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: opacity var(--t-fast);
}
.ph:hover .ph__img img { opacity: 0.88; }
.ph figcaption {
  font-size: 0.8rem; color: var(--ink-3);
  padding-top: 0.5rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Vista inicial del render general en proyecto */
.ph--hero {
  flex: 1 1 100%;
  width: 100%;
}
.ph--hero .ph__img {
  aspect-ratio: auto;
  height: clamp(230px, 35vh, 360px);
}
.ph--hero .ph__img img {
  object-position: center 55%;
}

/* ──────── Indicador de desplazamiento (leve pero sugerente) ──────── */
.scroll-cue-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: clamp(0.75rem, 1.8vw, 1.35rem) 0 clamp(0.35rem, 1vw, 0.65rem);
}

.scroll-cue {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.71rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  transition: color var(--t-fast);
}

.scroll-cue:hover {
  color: var(--ink);
}

.scroll-cue__track {
  display: block;
  width: 1px;
  height: 16px;
  background: var(--line-dark, #ccc);
  position: relative;
  overflow: hidden;
}

.scroll-cue__line {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--ink);
  animation: cueLineAnim 2.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.scroll-cue__arrow {
  display: block;
  color: inherit;
  animation: cueBounce 2.2s ease-in-out infinite;
}

@keyframes cueLineAnim {
  0% { transform: translateY(-100%); }
  45%, 100% { transform: translateY(100%); }
}

@keyframes cueBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-cue__line,
  .scroll-cue__arrow {
    animation: none;
  }
}

.stack { flex: var(--r) 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.stack .ph { flex: var(--g) 1 0; min-height: 0; }
.stack .ph__img { flex: 1; min-height: 0; aspect-ratio: auto; }

.next {
  display: block; width: 100%; text-align: left;
  margin-top: clamp(3.5rem, 7vw, 5.5rem);
  padding: 2rem 0 3.5rem;
  border-top: 1px solid var(--line);
}
.next span { display: block; font-size: 0.85rem; color: var(--ink-3); margin-bottom: 0.4rem; }
.next strong {
  font-family: var(--serif); font-weight: 400; font-size: clamp(1.9rem, 3.6vw, 2.8rem); line-height: 1.1;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size 600ms var(--ease);
}
.next:hover strong { background-size: 100% 1px; }

/* ──────── Visor ──────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 22, 20, 0.96);
  display: none; align-items: center; justify-content: center;
  padding: 4.5rem 5rem;
}
.lightbox.active { display: flex; animation: lbIn 320ms var(--ease); }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox figure { display: flex; flex-direction: column; align-items: center; max-width: 100%; max-height: 100%; }
.lightbox__frame { overflow: hidden; max-width: 100%; }
.lightbox img {
  max-width: 100%; max-height: calc(100vh - 11rem);
  object-fit: contain; display: block; user-select: none; cursor: zoom-in;
  transition: transform 260ms var(--ease);
}
.lightbox figcaption { margin-top: 0.9rem; color: #C9CCC5; font-size: 0.85rem; text-align: center; }

.lb-btn {
  position: absolute; color: #E8EAE5; font-size: 0.85rem;
  padding: 0.6rem 0.8rem; opacity: 0.75; transition: opacity var(--t-fast);
}
.lb-btn:hover { opacity: 1; }
.lb-close { top: 1rem; right: 1.25rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; }
.lb-count { position: absolute; top: 1.6rem; left: 1.5rem; color: #9DA19A; font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* ──────── Responsive ──────── */
@media (max-width: 980px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .pbody { grid-template-columns: 1fr; }
  .pmemoria { grid-template-columns: 1fr; }
  .cv { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .nav { gap: 1.1rem; }
  .brand__name { display: none; }
  .about__grid { grid-template-columns: 1fr; }
  .about__photo { max-width: 240px; }
  .contact__grid { grid-template-columns: 1fr; }
  .contact__foot { text-align: left; }
  .row { flex-direction: column; }
  .ph, .stack, .stack .ph { flex: none; }
  .stack .ph__img { aspect-ratio: var(--r); }
  .ph figcaption { white-space: normal; }
  .lightbox { padding: 3.5rem 0.75rem; }
  .lb-prev, .lb-next { top: auto; bottom: 0.75rem; transform: none; }
}

@media (max-width: 460px) {
  .tiles { grid-template-columns: 1fr; }
  .job__head { flex-direction: column; gap: 0.1rem; }
  .kv { grid-template-columns: 1fr; }
}
