/* =========================================================================
   Portafolis Marta Vila — styles
   Editorial · two-tone (paper + vermell) · Fraunces / Inter
   ========================================================================= */

:root {
  /* palette */
  --bg:        #f4f2ee;
  --bg-deep:   #eae6df;
  --ink:       #1a1613;
  --prose:     #262019;
  --ink-2:     #463f37;
  --muted:     #6c6357;
  --red:       #c5331e;
  --red-deep:  #8c2113;
  --red-ink:   #a82a16;
  --paper:     #faf8f4;
  --cream-line: rgba(26, 22, 19, 0.14);
  --hairline:  rgba(26, 22, 19, 0.12);

  /* type */
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans:  "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* metrics */
  --measure: 63ch;
  --pad-x: clamp(1.25rem, 5vw, 6rem);
  --shell: 1280px;

  /* z-index scale (semantic) */
  --z-progress: 60;
  --z-header:   70;
  --z-subnav:   80;
  --z-menu:     90;

  /* motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  background: var(--bg);
  color: var(--prose);
  font-family: var(--sans);
  font-size: clamp(1.02rem, 0.98rem + 0.28vw, 1.18rem);
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }

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

.skip-link {
  position: fixed; top: 0.6rem; left: 0.6rem;
  background: var(--ink); color: var(--paper);
  padding: 0.6rem 1rem; border-radius: 8px;
  transform: translateY(-150%); transition: transform 0.2s var(--ease-out);
  z-index: 100; font-size: 0.9rem;
}
.skip-link:focus { transform: translateY(0); }

:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }

/* ====================== Scroll progress ============================ */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: var(--z-progress); pointer-events: none;
  background: transparent;
}
.scroll-progress__bar {
  display: block; height: 100%; width: 100%;
  background: var(--red);
  transform: scaleX(0); transform-origin: 0 50%;
}

/* ====================== Header ===================================== */
.site-header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: var(--z-header);
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(1rem, 2.2vw, 1.6rem) var(--pad-x);
  color: var(--paper);
  background: linear-gradient(180deg, rgba(20,15,12,0.58) 0%, rgba(20,15,12,0.28) 55%, rgba(20,15,12,0) 100%);
  transition: color 0.4s ease, background-color 0.4s ease, padding 0.4s ease;
}
.site-header.is-solid {
  color: var(--ink);
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  padding-top: clamp(0.7rem, 1.4vw, 1rem);
  padding-bottom: clamp(0.7rem, 1.4vw, 1rem);
}

.wordmark { display: inline-flex; align-items: center; gap: 0.6rem; }
.wordmark__mark {
  font-family: var(--serif); font-weight: 500;
  font-size: 1.15rem; letter-spacing: 0.02em;
  border: 1.5px solid currentColor; border-radius: 50%;
  width: 2.3rem; height: 2.3rem;
  display: inline-grid; place-items: center;
  line-height: 1;
}
.wordmark__name {
  font-family: var(--serif); font-weight: 500;
  font-size: 1.12rem; letter-spacing: 0.01em;
}

.nav { display: block; }
.nav__list { list-style: none; display: flex; align-items: center; gap: clamp(1.2rem, 2.4vw, 2.4rem); }
.nav__item { position: relative; }
.nav__link {
  font-size: 0.92rem; font-weight: 500; letter-spacing: 0.01em;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0; cursor: pointer;
}
.nav__link .nav__chev { transition: transform 0.3s var(--ease-out); }
.nav__item.has-sub:hover .nav__chev,
.nav__item.has-sub:focus-within .nav__chev { transform: rotate(180deg); }
.nav__link--soon { opacity: 0.55; cursor: default; }
.soon-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red); margin-left: 0.5rem;
}

/* dropdown */
.subnav {
  position: absolute; top: calc(100% + 0.6rem); right: 0;
  min-width: 290px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 4px;
  padding: 0.5rem; z-index: var(--z-subnav);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out), visibility 0.28s;
}
.nav__item.has-sub:hover .subnav,
.nav__item.has-sub:focus-within .subnav { opacity: 1; visibility: visible; transform: translateY(0); }
.subnav__link {
  display: flex; align-items: baseline; gap: 0.7rem;
  padding: 0.75rem 0.85rem; border-radius: 9px;
  font-size: 0.96rem; transition: background 0.2s ease, color 0.2s ease;
}
.subnav__link:hover { background: var(--bg-deep); color: var(--red-ink); }
.subnav__num { font-family: var(--serif); font-size: 0.8rem; color: var(--red); font-weight: 500; }

/* mobile menu toggle */
.menu-toggle { display: none; }

/* ====================== Mobile menu =============================== */
.mobile-menu {
  position: fixed; inset: 0; z-index: var(--z-menu);
  background: var(--ink); color: var(--paper);
  padding: clamp(5rem, 14vh, 8rem) var(--pad-x) 3rem;
  display: flex; flex-direction: column; justify-content: center;
  transform: translateY(-100%);
  transition: transform 0.6s var(--ease-out-soft);
  visibility: hidden;
}
.mobile-menu.is-open { transform: translateY(0); visibility: visible; }
.mobile-menu nav { display: flex; flex-direction: column; gap: 0.3rem; }
.mobile-menu__label {
  font-family: var(--serif); font-size: 0.95rem; color: var(--red);
  margin-bottom: 1rem; letter-spacing: 0.04em; text-transform: uppercase;
}
.mobile-menu a {
  font-family: var(--serif); font-size: clamp(1.7rem, 7vw, 2.6rem);
  font-weight: 400; padding: 0.55rem 0;
  display: flex; align-items: baseline; gap: 0.9rem;
  border-bottom: 1px solid rgba(250,248,244,0.14);
}
.mobile-menu__num { font-size: 0.9rem; color: var(--red); }
.mobile-menu__soon { margin-top: 1.6rem; color: rgba(250,248,244,0.6); font-size: 0.95rem; }

/* ====================== Hero ====================================== */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--pad-x);
  padding-bottom: clamp(3.5rem, 9vh, 7rem);
  overflow: hidden;
  color: var(--paper);
}
.hero__media { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.hero__img {
  position: absolute; inset: -4% 0; width: 100%; height: 108%;
  object-fit: cover; object-position: 50% 58%;
  will-change: transform;
}
.hero__scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,15,12,0.46) 0%, rgba(20,15,12,0.12) 30%, rgba(20,15,12,0.18) 55%, rgba(20,15,12,0.82) 100%);
}
.hero__inner { position: relative; z-index: 1; max-width: var(--shell); width: 100%; margin: 0 auto; }
.hero__eyebrow {
  font-size: 0.98rem; letter-spacing: 0.005em;
  font-weight: 500; margin-bottom: clamp(1rem, 2.5vw, 1.6rem);
  color: color-mix(in oklab, var(--paper) 88%, var(--red) 26%);
  display: inline-flex; align-items: center; gap: 0.6rem;
}
.hero__eyebrow::before {
  content: ""; width: 1.8rem; height: 1px; background: var(--red);
}
.hero__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.7rem, 8.4vw, 5.6rem);
  line-height: 1.0; letter-spacing: -0.015em;
  text-wrap: balance;
}
.hero__title .line { display: block; overflow: hidden; }
.hero__title .line__inner { display: block; }
.hero__title .line:last-child .line__inner { color: color-mix(in oklab, var(--paper) 78%, var(--red) 60%); font-style: italic; }

.hero__scroll {
  position: absolute; right: var(--pad-x); bottom: clamp(3.5rem, 9vh, 7rem);
  z-index: 1; display: inline-flex; flex-direction: column; align-items: center; gap: 0.8rem;
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
  writing-mode: vertical-rl;
}
.hero__scroll-line { width: 1px; height: 64px; background: currentColor; transform-origin: top; overflow: hidden; position: relative; }
.hero__scroll-line::after {
  content: ""; position: absolute; inset: 0; background: var(--red);
  animation: scrollline 2.2s var(--ease-out) infinite;
}
@keyframes scrollline {
  0% { transform: scaleY(0); transform-origin: top; }
  45% { transform: scaleY(1); transform-origin: top; }
  46% { transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ====================== Shared section frame ====================== */
.section-title, .chapter__title {
  font-family: var(--serif); font-weight: 400;
  letter-spacing: -0.012em; line-height: 1.04; text-wrap: balance;
  color: var(--ink);
}

/* ====================== Punt de partida =========================== */
.start {
  max-width: var(--shell); margin: 0 auto;
  padding: clamp(5rem, 14vh, 11rem) var(--pad-x) clamp(3rem, 7vh, 5rem);
}
.start__grid {
  display: grid; grid-template-columns: 1.5fr 0.9fr; gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}
.section-title { font-size: clamp(2.3rem, 6.4vw, 4.6rem); }
.start__lead {
  margin-top: clamp(1.4rem, 3vw, 2.2rem);
  max-width: 46ch; font-size: clamp(1.1rem, 1.02rem + 0.4vw, 1.34rem);
  color: var(--ink-2); line-height: 1.6; text-wrap: pretty;
}
.portrait { justify-self: end; max-width: 300px; width: 100%; }
.portrait__frame {
  overflow: hidden; border-radius: 3px;
  border: 1px solid var(--hairline);
  background: var(--bg-deep);
}
.portrait__frame img { width: 100%; aspect-ratio: 364 / 485; object-fit: cover; }
.portrait figcaption {
  margin-top: 0.9rem; font-family: var(--serif); font-size: 1.1rem; color: var(--ink);
  display: flex; flex-direction: column; line-height: 1.3;
}
.portrait figcaption span { font-family: var(--sans); font-size: 0.82rem; color: var(--muted); margin-top: 0.25rem; letter-spacing: 0.01em; }

/* index list */
.index {
  list-style: none; max-width: var(--shell); margin: clamp(3rem, 7vh, 5rem) auto 0;
  border-top: 1px solid var(--cream-line);
}
.index__item { border-bottom: 1px solid var(--cream-line); }
.index__item a {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(1.3rem, 3.2vw, 2.3rem) 0.4rem;
  transition: padding-left 0.4s var(--ease-out), color 0.3s ease;
}
.index__item a:hover { padding-left: 1.4rem; color: var(--red-ink); }
.index__num { font-family: var(--serif); font-size: 0.9rem; color: var(--red); font-weight: 500; }
.index__title { font-family: var(--serif); font-size: clamp(1.5rem, 3.6vw, 2.6rem); font-weight: 400; letter-spacing: -0.01em; }
.index__arrow { font-size: 1.4rem; opacity: 0.4; transition: transform 0.4s var(--ease-out), opacity 0.3s ease; }
.index__item a:hover .index__arrow { opacity: 1; transform: translateX(8px); }

/* ====================== Chapters ================================== */
.chapter {
  max-width: var(--shell); margin: 0 auto;
  padding: clamp(4.5rem, 12vh, 9rem) var(--pad-x);
}
.chapter__head {
  display: grid; gap: 0.8rem; margin-bottom: clamp(2.4rem, 5vw, 4rem);
  border-bottom: 1px solid var(--cream-line); padding-bottom: clamp(1.6rem, 3vw, 2.4rem);
}
.chapter__title { font-size: clamp(2rem, 5.6vw, 4rem); }

.prose { max-width: var(--measure); margin: 0 auto; }
.prose p {
  font-size: clamp(1.06rem, 1rem + 0.34vw, 1.28rem);
  line-height: 1.68; color: var(--prose);
  text-align: justify; text-justify: inter-word;
  hyphens: auto; -webkit-hyphens: auto;
}
.prose p + p { margin-top: 1.4em; }

/* figures */
.figure { margin: clamp(2.6rem, 6vw, 4.5rem) auto; }
.figure__frame {
  overflow: hidden; border-radius: 3px;
  border: 1px solid var(--hairline);
}
.figure__frame img { width: 100%; }
.figure figcaption {
  margin-top: 1rem; font-size: 0.88rem; color: var(--muted);
  text-align: center; font-style: italic; max-width: 52ch; margin-inline: auto;
}
.figure--classe { max-width: 440px; }
.figure--draw {
  max-width: 600px;
}
.figure--draw .figure__frame {
  background: #e9eef9; padding: 0;
  border-color: rgba(40,55,95,0.22);
}
.figure--draw .figure__frame img { aspect-ratio: 678 / 952; object-fit: cover; }

/* ====================== Quote band =============================== */
.quote-band {
  background: var(--red); color: var(--paper);
  padding: clamp(5rem, 14vh, 9rem) var(--pad-x);
  position: relative; overflow: hidden;
}
.quote-band::before {
  content: "“"; position: absolute; top: -0.18em; left: 0.1em;
  font-family: var(--serif); font-size: clamp(12rem, 30vw, 26rem);
  line-height: 1; color: color-mix(in oklab, var(--paper) 12%, transparent);
  pointer-events: none;
}
.quote { max-width: 19ch; margin: 0 auto; text-align: center; position: relative; }
.quote p {
  font-family: var(--serif); font-weight: 400; font-style: italic;
  font-size: clamp(1.9rem, 5.4vw, 3.7rem); line-height: 1.16;
  letter-spacing: -0.01em; text-wrap: balance;
}

/* ====================== Footer =================================== */
.site-footer {
  background: var(--ink); color: var(--paper);
  padding: clamp(2.5rem, 6vh, 4rem) var(--pad-x);
}
.site-footer__top { max-width: var(--shell); margin: 0 auto; }
.site-footer__big {
  font-family: var(--serif); font-weight: 400; font-style: italic;
  font-size: clamp(2.6rem, 9vw, 6rem); line-height: 1.02; letter-spacing: -0.015em;
}
.site-footer__meta {
  max-width: var(--shell); margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  color: rgba(250,248,244,0.78); font-size: 0.92rem;
}
.site-footer__meta .wordmark__mark { width: 2.1rem; height: 2.1rem; font-size: 1rem; }
.site-footer__soon { margin-left: auto; color: var(--red); font-weight: 500; }

/* ====================== Reveal base (JS-driven) ================== */
/* Content is fully visible by default; JS sets hidden start-states only
   when it will actually animate, so no-JS / headless renders stay visible. */
.word, .char { display: inline-block; }
.split-line { display: block; overflow: hidden; }

/* ====================== Responsive =============================== */
@media (max-width: 860px) {
  .nav { display: none; }
  .menu-toggle {
    display: inline-flex; flex-direction: column; gap: 6px;
    background: none; border: 0; cursor: pointer; padding: 0.4rem; color: inherit;
  }
  .menu-toggle span { width: 28px; height: 2px; background: currentColor; transition: transform 0.4s var(--ease-out), opacity 0.3s ease; }
  .menu-toggle.is-open span:first-child { transform: translateY(8px) rotate(45deg); }
  .menu-toggle.is-open span:last-child { transform: translateY(-0px) rotate(-45deg); }

  .start__grid { grid-template-columns: 1fr; align-items: start; }
  .portrait { justify-self: start; order: -1; max-width: 240px; }
  .start__lead { max-width: none; }
}

/* Mobile hero: show the full photo (everyone visible) with the title below it */
@media (max-width: 700px) {
  .hero {
    min-height: auto; display: block; overflow: visible;
    padding: 0 0 clamp(2rem, 8vw, 3.5rem);
    color: var(--ink);
  }
  .hero__media {
    position: relative; inset: auto;
    width: 100%; aspect-ratio: 1300 / 731;
  }
  .hero__img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-position: 50% 50%; transform: none !important;
  }
  .hero__scrim { display: none; }
  .hero__scroll { display: none; }
  .hero__inner { margin-top: clamp(1.4rem, 6vw, 2.2rem); padding-inline: var(--pad-x); }
  .hero__eyebrow { color: var(--red-ink); }
  .hero__eyebrow::before { background: var(--red); }
  .hero__title { color: var(--ink); }
  .hero__title .line:last-child .line__inner { color: var(--red-ink); }
}

@media (max-width: 560px) {
  .wordmark__name { display: none; }
  .figure--classe { max-width: 320px; }
}

/* ====================== Reduced motion ========================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .soon-dot, .hero__scroll-line::after { animation: none !important; }
}
