:root {
  --bg: #f6f6f7;
  --white: #fff;
  --soft-surface: #eeeff2;
  --ink: #000;
  --muted: #6b6b72;
  --line: #e3e3e8;
  --accent: #0048ff;
  --accent-ink: #fff;
  --max: 1120px;
  --gutter: clamp(16px, 4vw, 32px);
  --radius: 18px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* iOS sheet curve as fallback; spring via linear() where supported */
  --ease-ios: cubic-bezier(.32, .72, 0, 1);
  --ease-spring: var(--ease-ios);
  --ease-press: cubic-bezier(.2, 0, 0, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ease-spring: linear(0, .009, .035 2.1%, .141 4.4%, .281 6.7%, .723 12.9%, .938 16.7%, 1.017 20.5%, 1.043 24.1%, 1.035 28.4%, 1.007 38.1%, .998 46.7%, 1);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  position: relative; margin: 0; overflow-x: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, svg { display: block; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* Blue glow behind the header */
.glow {
  position: absolute; z-index: -1; inset: 0 0 auto; height: 560px; pointer-events: none;
  background:
    radial-gradient(55% 70% at 72% -12%, rgba(0, 72, 255, .34), transparent 70%),
    radial-gradient(45% 60% at 20% -25%, rgba(120, 186, 255, .5), transparent 72%),
    radial-gradient(30% 40% at 95% 10%, rgba(176, 140, 255, .25), transparent 70%);
  filter: blur(24px);
}

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

/* Top bar: avatar · tabs · language */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  max-width: var(--max); margin: 0 auto; padding: 18px var(--gutter);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .lang { justify-self: end; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--accent); color: var(--white); font-weight: 600; font-size: 14px; text-decoration: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .7);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.tabs {
  position: relative; display: flex; align-items: center; gap: 2px; padding: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--white) 55%, transparent);
  backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 40, 140, .06);
  max-width: calc(100vw - 2 * var(--gutter)); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative; z-index: 1; flex: none;
  padding: 7px 15px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: #57575e; text-decoration: none; white-space: nowrap;
  transition: color .25s var(--ease-ios);
}
.tabs a:hover, .tabs a[aria-current] { color: var(--ink); }
.tabs__pill {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0;
  border-radius: 999px; background: var(--white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 6px 14px rgba(0, 0, 0, .05);
  view-transition-name: tab-pill;
}
.tabs__divider { flex: none; width: 1px; height: 18px; margin: 0 6px; background: var(--line); }

/* Language switch: one pill that slides */
.lang {
  position: relative; isolation: isolate;
  display: inline-flex; gap: 2px; padding: 3px; border: 0; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600;
  border-radius: 999px; background: color-mix(in srgb, var(--white) 55%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.lang span { width: 30px; padding: 2px 0; text-align: center; color: var(--muted); transition: color .3s var(--ease-ios); }
.lang::before {
  content: ""; position: absolute; z-index: -1; top: 3px; left: 3px;
  width: 30px; height: calc(100% - 6px); border-radius: 999px;
  background: var(--white); box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  transition: transform .5s var(--ease-spring);
}
html[lang="en"] .lang::before { transform: translateX(32px); }
html[lang="es"] .lang [data-lang="es"],
html[lang="en"] .lang [data-lang="en"] { color: var(--ink); }

/* Buttons */
.btn {
  display: inline-block; text-decoration: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border: 0; border-radius: 12px;
}
.btn--ink { background: var(--ink); color: var(--white); }
.btn--soft { background: color-mix(in srgb, var(--white) 70%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04); }
.btn--soft:hover { background: var(--white); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }

/* Intro (shared by Projects / Experiments / About) */
.intro { padding: 28px 0 56px; }
.intro__name { font-size: clamp(34px, 4.6vw, 46px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; margin-bottom: 12px; }
.intro__bio { max-width: 40ch; font-size: 17px; color: var(--muted); margin-bottom: 22px; }
.intro__ctas { display: flex; flex-wrap: wrap; gap: 8px; }

/* Project frames: soft tinted backdrop with the work rising from the bottom */
.frame {
  --tint-a: #7fa6ff; --tint-b: #b6d0ff;
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 3; border-radius: var(--radius);
  padding: 7% 7% 0; display: flex; align-items: flex-end;
  background:
    radial-gradient(70% 80% at 0% 0%, color-mix(in srgb, var(--tint-a) 55%, white), transparent 70%),
    radial-gradient(70% 80% at 100% 100%, color-mix(in srgb, var(--tint-b) 65%, white), transparent 70%),
    #eef1f8;
}
.frame--santi { --tint-a: #ff6b6b; --tint-b: #ffb199; }
.frame--chicha { --tint-a: #0048ff; --tint-b: #8fd3ff; }
.frame__inner {
  width: 100%; height: 100%; overflow: hidden;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -2px 0 rgba(255, 255, 255, .6), 0 18px 40px rgba(0, 0, 0, .18);
  background: var(--white);
}
.frame__inner img { width: 100%; height: 100%; object-fit: cover; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }

/* Projects grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 44px 24px; padding-bottom: 96px; }
.card { display: block; text-decoration: none; }
.card__meta { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-top: 14px; font-size: 15px; }
.card__title { font-size: 15px; font-weight: 500; }
.card__client { color: var(--muted); white-space: nowrap; }

/* Experiments: masonry */
.masonry { columns: 3 240px; column-gap: 20px; padding-bottom: 96px; }
.masonry figure { break-inside: avoid; margin: 0 0 26px; }
.masonry .zoom, .masonry .ph { display: block; overflow: hidden; border-radius: 16px; aspect-ratio: var(--ratio, 4 / 5); }
.masonry img { width: 100%; height: 100%; object-fit: cover; }
.masonry .zoom img { transition: transform .6s cubic-bezier(.22, 1, .36, 1); }
.masonry .zoom:hover img { transform: scale(1.03); }
.masonry figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); }
.ph { background: linear-gradient(160deg, #dfe6f7, #b9c9f2); }
.ph--b { background: linear-gradient(200deg, #e9e3f8, #c4b5ef); }
.ph--c { background: linear-gradient(160deg, #dbeef7, #9fd0ec); }

/* About */
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: start; padding-bottom: 72px; }
.carousel { position: relative; aspect-ratio: 1 / 1.04; border-radius: 22px; overflow: hidden; }
.carousel__slide { position: absolute; inset: 0; opacity: 0; transition: opacity .7s var(--ease-ios), transform 1.2s var(--ease-ios); transform: scale(1.03); }
.carousel__slide.is-active { opacity: 1; transform: none; }
.carousel__slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel__dots {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.carousel__dots button {
  width: 7px; height: 7px; padding: 0; border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .6); transition: width .45s var(--ease-spring), background-color .3s ease;
}
.carousel__dots button[aria-current="true"] { width: 20px; background: var(--white); }
.carousel__caption { margin-top: 10px; text-align: center; font-size: 14px; color: var(--muted); }
.about-copy__title { font-size: clamp(24px, 2.8vw, 32px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.22; margin-bottom: 26px; }
.soft { color: var(--muted); }
.about-copy p { color: var(--muted); font-size: 17px; line-height: 1.65; margin-bottom: 18px; max-width: 52ch; }
.about-copy .btn { margin-top: 8px; }

.block { padding: 64px 0; border-top: 1px solid var(--line); }
.block__title { font-size: clamp(24px, 2.8vw, 30px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px; border-radius: 12px;
  background: var(--white); font-size: 14px; font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.chip i { width: 30px; height: 30px; border-radius: 8px; background: var(--c, linear-gradient(140deg, #7fa6ff, #0048ff)); }
.values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.value { padding: 26px; border-radius: var(--radius); background: var(--soft-surface); }
.value h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 8px; }
.value p { color: var(--muted); }
.value:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* Case study */
.cs-nav { position: sticky; top: 16px; z-index: 20; display: flex; justify-content: center; padding: 0 var(--gutter); margin-top: 18px; }
.cs-nav .lang { position: absolute; right: var(--gutter); top: 50%; transform: translateY(-50%); }
@media (max-width: 860px) { .cs-nav { flex-direction: column; align-items: center; gap: 10px; } .cs-nav .lang { position: static; transform: none; align-self: flex-end; order: -1; } }
.cs-head { padding: 72px 0 28px; }
.cs-kicker { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.cs-title { font-size: clamp(32px, 4.4vw, 50px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; margin-bottom: 16px; max-width: 22ch; }
.cs-lede { font-size: 18px; color: var(--muted); max-width: 68ch; }
.cs-cover { aspect-ratio: 16 / 9; padding: 5% 7% 0; margin-bottom: 36px; }
.cs-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin: 0 0 24px; }
.cs-meta dt { font-weight: 600; margin-bottom: 2px; }
.cs-meta dd { margin: 0; color: var(--muted); }
.cs-section { padding: 64px 0; border-top: 1px solid var(--line); }
.cs-label { color: var(--accent); font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.cs-h2 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 600; letter-spacing: -0.03em; margin-bottom: 16px; }
.cs-body p { color: var(--muted); font-size: 17px; line-height: 1.7; margin-bottom: 16px; max-width: 72ch; }
.cs-body strong { color: var(--ink); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
.stat { padding: 22px; border-radius: 16px; background: var(--soft-surface); }
.stat__value { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; color: var(--accent); margin-bottom: 8px; }
.stat__label { font-weight: 600; }
.stat__note { font-size: 14px; color: var(--muted); }

.gallery { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 16px; margin-top: 32px; }
.gallery figure { margin: 0; aspect-ratio: var(--ratio, 4 / 5); border-radius: 16px; overflow: hidden; background: var(--soft-surface); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

.pager { display: flex; justify-content: space-between; gap: 16px; padding: 32px 0; border-top: 1px solid var(--line); }
.pager a { text-decoration: none; font-weight: 600; }
.pager small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }
.pager__next { text-align: right; margin-left: auto; }

.closing {
  margin: 24px 0 72px; padding: clamp(56px, 10vw, 112px) var(--gutter);
  border-radius: 24px; text-align: center; overflow: hidden; position: relative;
  background:
    radial-gradient(60% 90% at 50% 120%, rgba(0, 72, 255, .28), transparent 70%),
    var(--white);
}
.closing__title { font-size: clamp(30px, 4.6vw, 48px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; margin-bottom: 12px; }
.closing__text { color: var(--muted); margin-bottom: 26px; }

/* CV */
.cv-head { padding: 0 0 56px; max-width: 760px; }
.cv-head__role { font-size: clamp(24px, 2.8vw, 30px); font-weight: 600; letter-spacing: -0.03em; margin-bottom: 6px; }
.cv-head__tagline { font-weight: 600; font-size: 15px; margin-bottom: 14px; }
.cv-head__summary { color: var(--muted); font-size: 17px; line-height: 1.65; margin-bottom: 22px; }
.cv-head__row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.cv-head__place { color: var(--muted); font-size: 14px; }
.stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0; }
.xp { list-style: none; margin: 0; padding: 0; }
.xp__item { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 16px; padding: 22px 0; }
.xp__item + .xp__item { border-top: 1px solid var(--line); }
.xp__mark {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--c); color: var(--white); font-size: 12px; font-weight: 700; letter-spacing: 0;
}
.xp__title { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 2px; }
.xp__at { color: var(--muted); font-weight: 500; }
.xp__meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.xp__desc { color: var(--muted); max-width: 75ch; }
.tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tool { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: var(--soft-surface); }
.tool__name { font-weight: 600; }
.tool__use { font-size: 14px; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pills li { padding: 8px 14px; border-radius: 12px; background: var(--white); font-size: 14px; font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.rows li { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; padding: 12px 0; }
.rows li + li { border-top: 1px solid var(--line); }
.rows__date { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Zoomable images */
.zoom { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 16px; }

/* Footer */
.footer { border-top: 1px solid var(--line); padding: 48px 0 56px; }
.footer__grid { display: grid; grid-template-columns: 2fr 1fr 1.2fr; gap: 32px; }
.footer__brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; letter-spacing: -0.02em; margin-bottom: 12px; }
.footer__brand .avatar { width: 30px; height: 30px; font-size: 11px; box-shadow: none; }
.footer__bio { color: var(--muted); max-width: 38ch; margin-bottom: 14px; }
.footer__small { font-size: 13px; color: var(--muted); }
.footer h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.footer__links li + li { margin-top: 8px; }
.footer__links a { color: var(--muted); text-decoration: none; }
.footer__links a:hover { color: var(--ink); }
.copy {
  display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--muted);
}
.copy:hover { color: var(--ink); }
.copy__state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft-surface); color: var(--ink); transition: background-color .3s ease, color .3s ease; }
.copy.is-copied .copy__state { background: var(--accent); color: var(--white); }
.socials { display: flex; gap: 12px; margin-top: 14px; }
.socials svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.socials .fill { fill: var(--muted); stroke: none; }
.socials a:hover svg { stroke: var(--ink); }

/* Lightbox */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; }
.lightbox[open] { display: grid; place-items: center; cursor: zoom-out; }
.lightbox::backdrop { background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(28px) saturate(1.5); -webkit-backdrop-filter: blur(28px) saturate(1.5); }
.lightbox img { display: block; max-width: min(94vw, 1800px); max-height: 92dvh; width: auto; height: auto; object-fit: contain; border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .22); will-change: transform; }
.lightbox__close {
  position: fixed; top: 16px; right: 16px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  font: inherit; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink);
  background: color-mix(in srgb, var(--white) 80%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
}
.lightbox-open { overflow: hidden; }

/* ───────── Motion ───────── */
@media (prefers-reduced-motion: no-preference) {
  .btn, .card, .lang, .tabs a, .copy { transition: transform .45s var(--ease-spring), background-color .2s ease, color .25s ease; }
  .btn:active, .lang:active, .tabs a:active { transform: scale(.94); transition-duration: .12s; transition-timing-function: var(--ease-press); }
  .card:active { transform: scale(.985); transition-duration: .15s; transition-timing-function: var(--ease-press); }
  .frame__inner { transition: transform .8s var(--ease-spring); }
  .card:hover .frame__inner { transform: translateY(-8px); }
  .tabs__pill { transition: transform .55s var(--ease-spring), width .55s var(--ease-spring); }

  .intro > *, .cs-head > *, .about-grid > * {
    animation: blur-in .9s var(--ease-ios) both;
    animation-delay: calc(var(--i, 0) * 70ms + 60ms);
  }
  .intro > :nth-child(2), .cs-head > :nth-child(2), .about-grid > :nth-child(2) { --i: 1; }
  .intro > :nth-child(3), .cs-head > :nth-child(3) { --i: 2; }
  @keyframes blur-in { from { opacity: 0; transform: translateY(16px) scale(.985); filter: blur(8px); } }

  .reveal-ready [data-reveal] {
    opacity: 0; transform: translateY(28px) scale(.97); filter: blur(6px);
    transition: opacity .9s var(--ease-ios), transform 1s var(--ease-spring), filter .9s var(--ease-ios);
    transition-delay: calc(var(--i, 0) * 60ms);
  }
  .reveal-ready [data-reveal].is-in { opacity: 1; transform: none; filter: none; }

  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: vt-out .35s var(--ease-ios) both; }
  ::view-transition-new(root) { animation: vt-in .55s var(--ease-ios) both; }
  ::view-transition-group(*) { animation-duration: .6s; animation-timing-function: var(--ease-ios); }
  ::view-transition-group(tab-pill) { animation-timing-function: var(--ease-spring); animation-duration: .6s; }
  @keyframes vt-out { to { opacity: 0; transform: scale(.985); filter: blur(4px); } }
  @keyframes vt-in { from { opacity: 0; transform: scale(1.01); filter: blur(4px); } }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ───────── Responsive ───────── */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; gap: 36px; }
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .cs-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: 1fr; }
  .stats--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .footer__grid > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr; row-gap: 14px; }
  .topbar .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .tabs a { padding: 7px 11px; font-size: 13px; }
  .values { grid-template-columns: 1fr; }
  .rows li { grid-template-columns: 1fr; gap: 2px; }
  .gallery { grid-template-columns: repeat(var(--cols-m, 1), minmax(0, 1fr)); gap: 10px; }
  .cs-head { padding-top: 48px; }
  .frame { padding: 6% 6% 0; }
}
