/* =========================================================
   Carlos Vergara · Psicólogo educacional
   Arquetipo: editorial de papel (carta). Sin dependencias.
   ========================================================= */

:root {
  --paper:      #f6f1e7;
  --paper-2:    #eee7d8;
  --sheet:      #fcfaf5;
  --ink:        #17150f;
  --ink-soft:   #3b372e;
  --ink-mute:   #6f695c;
  --accent:     #1f5c45;
  --accent-ink: #164634;
  --accent-wash:#dfe8df;
  --line:       rgba(23, 21, 15, 0.16);
  --line-strong:#17150f;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --wrap: 1180px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

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

html {
  overflow-x: clip;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.06rem, 0.98rem + 0.35vw, 1.22rem);
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* grano de papel muy sutil */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .09 0 0 0 0 .08 0 0 0 0 .06 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, .nav, .footer { position: relative; z-index: 1; }

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
em { font-style: italic; color: var(--accent); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

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

/* ---------- piezas comunes ---------- */
.kicker,
.section-label,
.audience-tag,
.credentials span,
.idx,
.way-label,
.cv dt,
.portrait figcaption,
.nav-role,
.pullquote figcaption {
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.kicker .sep { margin-inline: .5em; color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .95em 1.7em;
  font-family: var(--sans); font-size: .9rem; font-weight: 500; letter-spacing: .02em;
  text-decoration: none;
  color: var(--paper); background: var(--ink);
  border: 1px solid var(--ink); border-radius: 999px;
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}
.btn:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.btn-small { padding: .65em 1.2em; font-size: .82rem; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { color: var(--paper); }

.link-arrow {
  display: inline-flex; align-items: baseline; gap: .45em;
  font-family: var(--sans); font-size: .9rem; font-weight: 500;
  text-decoration: none; color: var(--ink);
  padding-bottom: .2em;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: color .25s var(--ease), background-size .35s var(--ease);
}
.link-arrow span { transition: transform .3s var(--ease); display: inline-block; }
.link-arrow:hover { color: var(--accent); }
.link-arrow:hover span { transform: translate(3px, 0); }
.link-arrow[href^="#carta"]:hover span { transform: translate(0, 3px); }

.fineprint { font-family: var(--sans); font-size: .82rem; line-height: 1.55; color: var(--ink-mute); max-width: 56ch; }

/* ---------- barra de lectura ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  padding: .9rem var(--gutter);
  background: rgba(246, 241, 231, .96);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), padding .3s var(--ease);
}
@supports (backdrop-filter: blur(10px)) {
  .nav { background: rgba(246, 241, 231, .78); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%); }
}
.nav.is-scrolled { border-bottom-color: var(--line); padding-block: .6rem; }
.nav-brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1.15; }
.nav-name { font-size: 1.2rem; font-weight: 500; letter-spacing: -.01em; }
.nav-role { font-size: .62rem; }
.nav-links { display: flex; gap: clamp(1rem, 2.4vw, 2.2rem); }
.nav-links a {
  font-family: var(--sans); font-size: .84rem; text-decoration: none; color: var(--ink-soft);
  padding-block: .3em;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  transition: background-size .35s var(--ease), color .25s var(--ease);
}
.nav-links a:hover, .nav-links a.is-current { color: var(--ink); background-size: 100% 1px; }

/* ---------- hero ---------- */
.hero { padding-block: clamp(2.5rem, 7vw, 6rem) 0; }
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: clamp(2rem, 6vw, 5.5rem); align-items: center;
}
.hero-title {
  margin-top: 1.4rem;
  font-size: clamp(2.7rem, 1.2rem + 6.2vw, 6rem);
  font-weight: 400; line-height: .98; letter-spacing: -.028em;
  text-wrap: balance; max-width: 12ch;
}
.hero-title em { display: block; font-weight: 300; }
.hero-deck {
  margin-top: 1.8rem; max-width: 46ch;
  font-size: clamp(1.12rem, 1rem + .55vw, 1.4rem); line-height: 1.5; color: var(--ink-soft);
}
.hero-actions { margin-top: 2.2rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1.6rem; }

.portrait { position: relative; justify-self: end; width: 100%; max-width: 370px; }
.portrait::before {
  content: ""; position: absolute; z-index: 0;
  inset: 1.4rem -1.1rem 2.6rem 1.1rem;
  background: var(--accent);
}
.portrait-frame {
  position: relative; z-index: 1;
  padding: .7rem .7rem 0; background: var(--sheet);
  box-shadow: 0 1px 0 rgba(23,21,15,.08), 0 26px 50px -28px rgba(23,21,15,.5);
}
.portrait-frame img { width: 100%; aspect-ratio: 1; object-fit: cover; filter: saturate(.94) contrast(1.02); }
.portrait figcaption {
  position: relative; z-index: 1;
  padding: .85rem .7rem 1rem; background: var(--sheet);
  box-shadow: 0 26px 50px -28px rgba(23,21,15,.5);
  letter-spacing: .1em; font-size: .66rem; line-height: 1.6;
}
.portrait figcaption strong {
  display: block; font-family: var(--serif); font-size: 1.05rem; font-weight: 500;
  letter-spacing: 0; text-transform: none; color: var(--ink);
}

.postmark {
  position: absolute; z-index: 2; left: -3.1rem; top: -2.6rem;
  width: 7.2rem; height: 7.2rem;
  color: var(--ink);
  transform: rotate(-12deg);
}
.postmark circle { fill: var(--paper); stroke: currentColor; stroke-width: 1; }
.postmark circle + circle { fill: none; stroke-dasharray: 2 2.5; }
.postmark text { font-family: var(--sans); font-size: 7.6px; font-weight: 600; letter-spacing: 1.75px; fill: currentColor; }
.postmark .postmark-mid { font-family: var(--serif); font-size: 21px; font-weight: 500; letter-spacing: 0; fill: var(--accent); }
.postmark .postmark-sub { font-size: 6.4px; letter-spacing: 2px; }

.credentials {
  margin-top: clamp(3rem, 7vw, 5.5rem);
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line);
}
.credentials li { padding: 1.1rem 1.2rem 1.15rem 0; font-size: 1.08rem; line-height: 1.3; }
.credentials li + li { padding-left: 1.2rem; border-left: 1px solid var(--line); }
.credentials span { display: block; margin-bottom: .3rem; font-size: .64rem; }

/* ---------- secciones ---------- */
.section { padding-block: clamp(4.5rem, 10vw, 8.5rem); }
.section-tint { background: var(--paper-2); }
.section-head { max-width: 62rem; margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.section-label { display: flex; align-items: baseline; gap: .9rem; }
.section-label .num { font-family: var(--serif); font-size: 1rem; font-style: italic; letter-spacing: 0; color: var(--accent); text-transform: none; }
.section-head h2, .contact h2 {
  margin-top: 1.2rem;
  font-size: clamp(2rem, 1.2rem + 3.1vw, 3.6rem);
  font-weight: 400; line-height: 1.06; letter-spacing: -.022em; text-wrap: balance;
}
.section-deck { margin-top: 1.4rem; max-width: 54ch; color: var(--ink-soft); }

/* ---------- la carta ---------- */
.letter-section { padding-block: clamp(4.5rem, 10vw, 8.5rem); }
.letter-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 8fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: start; }
.letter-grid > .section-label { position: sticky; top: 96px; flex-direction: column; gap: .5rem; }
.letter {
  position: relative;
  background: var(--sheet);
  padding: clamp(2rem, 6vw, 5rem) clamp(1.5rem, 6vw, 5.5rem);
  box-shadow: 0 1px 0 rgba(23,21,15,.06), 0 40px 70px -50px rgba(23,21,15,.55);
  font-size: clamp(1.15rem, 1rem + .6vw, 1.42rem); line-height: 1.62;
}
.letter::before {
  content: ""; position: absolute; left: clamp(.9rem, 3vw, 2.6rem); top: 0; bottom: 0;
  width: 1px; background: rgba(31, 92, 69, .28);
}
.letter p + p { margin-top: 1.25em; }
.letter-to { font-style: italic; font-size: 1.12em; color: var(--accent-ink); }
.dropcap::first-letter {
  float: left; margin: .08em .1em 0 0;
  font-size: 4.3em; line-height: .78; font-weight: 400; color: var(--accent);
}
.letter-ask { font-size: 1.28em; line-height: 1.3; font-style: italic; letter-spacing: -.01em; text-wrap: balance; }
.signature {
  margin-top: 1.6em !important;
  font-size: 2.3em; font-style: italic; font-weight: 300; line-height: 1; letter-spacing: -.02em; color: var(--accent);
}

/* ---------- para quién ---------- */
.audiences { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-strong); }
.audience { padding: 2rem 2rem 2.4rem 0; display: flex; flex-direction: column; gap: 1rem; }
.audience + .audience { padding-left: 2rem; border-left: 1px solid var(--line); }
.audience-tag { color: var(--accent); }
.audience h3 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 400; font-style: italic; line-height: 1.12; letter-spacing: -.015em; }
.audience > p:not(.audience-tag) { color: var(--ink-soft); font-size: 1.02rem; }
.audience ul { margin-block: .3rem .6rem; font-family: var(--sans); font-size: .86rem; line-height: 1.45; color: var(--ink-soft); }
.audience li { padding: .6rem 0 .6rem 1.2rem; border-top: 1px solid var(--line); position: relative; }
.audience li::before { content: ""; position: absolute; left: 0; top: 1.12em; width: .5rem; height: 1px; background: var(--accent); }
.audience .link-arrow { margin-top: auto; align-self: flex-start; }

/* ---------- método ---------- */
.method-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.method-grid .section-head { margin-bottom: 0; position: sticky; top: 110px; }
.steps li { display: grid; grid-template-columns: 3.2rem 1fr; gap: 1rem; padding-block: 1.6rem; border-top: 1px solid var(--line); }
.steps li:first-child { border-top-color: var(--line-strong); }
.steps li:last-child { border-bottom: 1px solid var(--line); }
.step-num { font-style: italic; font-size: 1.5rem; line-height: 1.2; color: var(--accent); }
.steps h3 { font-size: 1.38rem; font-weight: 500; line-height: 1.2; letter-spacing: -.01em; }
.steps p { margin-top: .45rem; color: var(--ink-soft); font-size: 1.02rem; }

/* ---------- diagnóstico ---------- */
.figures { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.figure { padding: 1.8rem 2rem 2rem 0; }
.figure + .figure { padding-left: 2rem; border-left: 1px solid var(--line); }
.figure-num { display: flex; align-items: baseline; gap: .6rem; font-size: clamp(4rem, 2rem + 7vw, 7.5rem); font-weight: 300; line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums lining-nums; }
.figure-num small { font-family: var(--sans); font-size: .8rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
.figure > p:last-child { margin-top: 1rem; max-width: 30ch; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.45; }

.pullquote { margin-block: clamp(3rem, 7vw, 5.5rem); text-align: center; }
.pullquote blockquote {
  font-size: clamp(1.9rem, 1rem + 4vw, 4rem); font-style: italic; font-weight: 300;
  line-height: 1.08; letter-spacing: -.025em; text-wrap: balance; color: var(--accent-ink);
  max-width: 20ch; margin-inline: auto;
}
.pullquote figcaption { margin-top: 1.4rem; }
.diagnostic-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.5rem 3rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }

/* ---------- índice de cartas ---------- */
.letters-index { border-top: 1px solid var(--line-strong); }
.letters-index li {
  display: grid; grid-template-columns: 5.5rem minmax(0, 7fr) minmax(0, 4fr); gap: 1.5rem; align-items: baseline;
  padding: 1.35rem .2rem; border-bottom: 1px solid var(--line);
  transition: padding-left .35s var(--ease), background-color .35s var(--ease);
}
.letters-index .idx { color: var(--accent); }
.letters-index .to { font-size: clamp(1.2rem, 1rem + .9vw, 1.7rem); font-style: italic; line-height: 1.2; letter-spacing: -.012em; transition: color .3s var(--ease); }
.letters-index .about { font-family: var(--sans); font-size: .86rem; color: var(--ink-mute); line-height: 1.4; }
@media (hover: hover) {
  .letters-index li:hover { padding-left: 1.1rem; background-color: rgba(252, 250, 245, .7); }
  .letters-index li:hover .to { color: var(--accent); }
}
.letters-note { margin-top: 1.6rem; }

.channels { margin-top: clamp(2.5rem, 5vw, 4rem); display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.channels a {
  display: flex; flex-direction: column; gap: .3rem; padding: 1.3rem 1.4rem 1.4rem;
  text-decoration: none; background: var(--sheet); border: 1px solid var(--line);
  transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
}
.channels strong { font-size: 1.4rem; font-weight: 500; letter-spacing: -.01em; }
.channels span { font-family: var(--sans); font-size: .82rem; color: var(--ink-mute); line-height: 1.4; }
.channels a:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 18px 30px -22px rgba(23,21,15,.5); }

/* ---------- sobre mí ---------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.about-grid .section-head { margin-bottom: 0; }
.about-body > p { font-size: clamp(1.12rem, 1rem + .45vw, 1.32rem); line-height: 1.58; color: var(--ink-soft); }
.about-body > p + p { margin-top: 1.2em; }
.cv { margin-top: 2.6rem; border-top: 1px solid var(--line-strong); }
.cv div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding-block: .95rem; border-bottom: 1px solid var(--line); align-items: baseline; }
.cv dd { font-size: 1.04rem; line-height: 1.4; }

/* ---------- contacto ---------- */
.contact { background: var(--accent-ink); color: var(--paper); padding-block: clamp(4.5rem, 10vw, 8rem); }
.contact .kicker { color: rgba(246, 241, 231, .65); }
.contact h2 { max-width: 16ch; font-size: clamp(2.4rem, 1.2rem + 5vw, 5rem); line-height: 1; }
.contact-deck { margin-top: 1.5rem; max-width: 46ch; color: rgba(246, 241, 231, .8); }
.contact-ways { margin-top: clamp(2.5rem, 5vw, 4rem); border-top: 1px solid rgba(246, 241, 231, .6); }
.way {
  display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr) auto; gap: 1.5rem; align-items: baseline;
  padding: 1.5rem .2rem; text-decoration: none;
  border-bottom: 1px solid rgba(246, 241, 231, .22);
  transition: padding .35s var(--ease), background-color .35s var(--ease);
}
.way-label { color: rgba(246, 241, 231, .65); }
.way-value { font-size: clamp(1.25rem, 1rem + 1.3vw, 2rem); font-style: italic; line-height: 1.15; letter-spacing: -.012em; overflow-wrap: anywhere; }
.way-go { font-family: var(--sans); font-size: 1.2rem; transition: transform .35s var(--ease); }
.way:hover { padding-inline: 1.1rem; background-color: rgba(246, 241, 231, .07); }
.way:hover .way-go { transform: translateX(6px); }
.contact :focus-visible { outline-color: var(--paper); }

/* ---------- footer ---------- */
.footer { background: var(--accent-ink); color: rgba(246, 241, 231, .7); padding-block: 0 2.2rem; font-family: var(--sans); font-size: .78rem; line-height: 1.6; }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 2rem; }
.footer strong { color: var(--paper); font-weight: 500; }

/* ---------- aparición al hacer scroll (solo si el JS cargó) ---------- */
.js .reveal { opacity: 0; transform: translateY(22px); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal.is-visible { opacity: 1; transform: none; }
.reveal[data-split] { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .nav-links { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-title { max-width: 14ch; }
  .portrait { justify-self: start; max-width: 300px; margin: 1.5rem 0 0 2.4rem; }
  .credentials { grid-template-columns: repeat(2, 1fr); }
  .credentials li:nth-child(3) { padding-left: 0; border-left: 0; }
  .credentials li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .letter-grid, .method-grid, .about-grid { grid-template-columns: 1fr; }
  .letter-grid > .section-label, .method-grid .section-head { position: static; }
  .letter-grid > .section-label { flex-direction: row; }
  .audiences, .figures, .channels { grid-template-columns: 1fr; }
  .audience, .audience + .audience, .figure, .figure + .figure { padding-inline: 0; border-left: 0; }
  .audience + .audience, .figure + .figure { border-top: 1px solid var(--line); }
  .figure > p:last-child { max-width: 44ch; }
}
@media (max-width: 640px) {
  .nav-role { display: none; }
  .hero-actions { gap: 1.1rem; }
  .portrait { max-width: 250px; }
  .postmark { width: 5.6rem; height: 5.6rem; left: -2.2rem; top: -2rem; }
  .letters-index li { grid-template-columns: 1fr; gap: .35rem; }
  .way { grid-template-columns: 1fr auto; gap: .3rem 1rem; }
  .way-label { grid-column: 1 / -1; }
  .cv div { grid-template-columns: 1fr; gap: .2rem; }
  .diagnostic-foot { flex-direction: column; align-items: flex-start; }
}
