/* ---------- Masthead flotante ---------- */
.masthead {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 50;
  width: min(var(--wrap), calc(100% - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  font-family: var(--font-body);
  font-size: 1.0625rem; /* Geist 17px */
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 16px;
}

.masthead__brand {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.masthead__brand::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--accent);
  flex: none;
  transform: translateY(-1px);
}

.masthead__name {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.masthead__meta {
  color: var(--muted);
  white-space: nowrap;
}

.masthead__nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.6vw, 24px);
}

.masthead__nav a {
  position: relative;
  padding: 4px 0;
  font-size: inherit;
  font-weight: 500;
  color: var(--ink-2);
}

.masthead__nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transition: right 0.3s var(--ease);
}

.masthead__nav a:hover::after {
  right: 0;
}

.masthead__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.masthead__tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule-strong);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
}

.lang__item {
  padding: 0.5em 0.6em;
  line-height: 1;
  color: var(--muted);
  transition:
    background 0.2s var(--ease),
    color 0.2s var(--ease);
}

.lang__item + .lang__item {
  border-left: 1px solid var(--rule-strong);
}

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

.lang__item.is-active {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Progress ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 60;
  height: 2px;
  pointer-events: none;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* ---------- Side rail ---------- */
.rail {
  position: fixed;
  left: 22px;
  top: 50%;
  z-index: 40;
  display: none;
  flex-direction: column;
  gap: 14px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.rail.is-visible {
  opacity: 1;
}

.rail a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.rail a::before {
  content: "";
  width: 14px;
  height: 1px;
  background: var(--rule-strong);
  transition:
    width 0.2s var(--ease),
    background 0.2s var(--ease);
}

.rail a:hover,
.rail a[aria-current="true"] {
  color: var(--accent);
}

.rail a:hover::before,
.rail a[aria-current="true"]::before {
  width: 28px;
  background: var(--accent);
}

@media (min-width: 1440px) {
  .rail {
    display: flex;
  }
}

/* ---------- Cover ---------- */
.cover {
  padding-top: clamp(96px, 9vw, 128px);
}

.cover__grid {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: start;
}

.cover__name {
  font-size: clamp(2.8rem, 7.2vw, 5.75rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  font-weight: 500;
}

.cover__name span {
  display: block;
}

.cover__surname {
  color: var(--accent);
}

.cover__role {
  margin-top: 28px;
  max-width: 54ch;
  font-size: clamp(1.02rem, 1.4vw, 1.2rem);
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink-2);
}

.cover__thesis {
  margin-top: 20px;
  max-width: 32ch;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.cover__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
}

.cover__ficha {
  margin-top: 6px;
  border-top: 1px solid var(--ink);
  padding-top: 6px;
}

.ficha__row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.ficha__row dt {
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.ficha__row dd {
  font-size: 0.8125rem;
  line-height: 1.5;
}

.cover__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-top: clamp(48px, 7vw, 88px);
  padding: 14px 0;
  border-top: 1px solid var(--ink);
}

/* ---------- Index ---------- */
.index {
  padding: clamp(56px, 7vw, 80px) 0;
  border-top: 1px solid var(--ink);
}

.index__head {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 32px;
  align-items: baseline;
  margin-bottom: 32px;
}

.index__head h2 {
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.index__list {
  margin-left: calc(var(--rail) + 32px);
  border-top: 1px solid var(--rule);
}

.index__item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 24px;
  gap: 16px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
  transition:
    color 0.2s var(--ease),
    padding 0.3s var(--ease);
}

.index__item:hover {
  color: var(--accent);
  padding-left: 8px;
}

.index__num {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.index__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.index__desc {
  display: block;
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  letter-spacing: 0;
  color: var(--muted);
}

.index__arrow {
  justify-self: end;
  font-family: var(--font-mono);
  color: var(--muted);
  transition: transform 0.2s var(--ease);
}

.index__item:hover .index__arrow {
  transform: translateX(3px);
  color: var(--accent);
}

/* ---------- Chapters ---------- */
.chapter {
  padding: clamp(56px, 7vw, 80px) 0;
  border-top: 1px solid var(--ink);
  scroll-margin-top: 112px;
}

.chapter__head {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-bottom: clamp(28px, 4vw, 44px);
}

.chapter__label {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chapter__num {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.chapter__head h2 {
  max-width: 20ch;
  font-size: clamp(2rem, 3.8vw, 3rem);
  letter-spacing: -0.03em;
}

.chapter__body {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.chapter__aside {
  position: sticky;
  top: 24px;
  padding-top: 4px;
}

.chapter__aside::before {
  content: "";
  display: block;
  width: 32px;
  height: 1px;
  margin-bottom: 12px;
  background: var(--rule-strong);
}

.chapter__aside p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  line-height: 1.7;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Prose ---------- */
.prose p {
  max-width: var(--measure);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink-2);
}

.prose p:first-of-type {
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--ink);
}

.prose strong {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Experience ---------- */
.job {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 32px;
  padding: 28px 0;
  border-top: 1px solid var(--rule);
}

.job:first-child {
  padding-top: 0;
  border-top: 0;
}

.job__dates {
  padding-top: 5px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.job__role {
  margin-bottom: 2px;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.job__company {
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.job__list li {
  position: relative;
  margin-bottom: 9px;
  padding-left: 18px;
  font-size: 0.9875rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.job__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  background: var(--accent);
}

/* ---------- Cases ---------- */
.case {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 32px;
  padding: 36px 0;
  border-top: 1px solid var(--rule);
}

.case__meta {
  padding-top: 4px;
}

.case__index {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.case__category {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.case h3 {
  margin-bottom: 10px;
  font-size: clamp(1.5rem, 2.2vw, 1.9rem);
  line-height: 1.1;
}

.case__summary {
  max-width: 66ch;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink-2);
}

.case__built {
  display: grid;
  gap: 5px;
  margin-top: 16px;
}

.case__built li {
  position: relative;
  padding-left: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.case__built li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 4px;
  height: 4px;
  background: var(--rule-strong);
}

.case__stack {
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.case__link,
.case__note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  border-bottom: 1px solid currentColor;
}

.case__note {
  color: var(--muted);
  border-bottom-color: var(--rule-strong);
}

.case__link:hover {
  color: var(--accent-ink);
}

.cases__more {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.cases__more a {
  color: var(--accent);
  border-bottom: 1px solid currentColor;
}

.cases__more a:hover {
  color: var(--accent-ink);
}

/* ---------- Stack ---------- */
.stack {
  border-top: 1px solid var(--rule);
}

.stack__row {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.stack__row dt {
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stack__row dd {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ---------- Education ---------- */
.edu {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 32px;
  padding: 22px 0;
  border-top: 1px solid var(--rule);
}

.edu:first-child {
  padding-top: 0;
  border-top: 0;
}

.edu__meta {
  padding-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.edu h3 {
  margin-bottom: 3px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.edu p {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-2);
}

/* ---------- Contact ---------- */
.contact {
  padding: clamp(64px, 8vw, 96px) 0;
  border-top: 1px solid var(--ink);
  scroll-margin-top: 112px;
}

.contact__title {
  font-size: clamp(3rem, 7vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.contact__title span {
  color: var(--accent);
}

.contact__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 64px);
  margin-top: 36px;
}

.contact__intro {
  max-width: 42ch;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.contact__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.contact__list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
  transition: color 0.2s var(--ease);
}

.contact__list a:hover {
  color: var(--accent);
}

.contact__list .label {
  color: var(--muted);
}

.contact__list strong {
  font-weight: 500;
}

/* ---------- Colophon ---------- */
.colophon {
  padding: 20px 0 40px;
  border-top: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.colophon__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}

/* ---------- One authored motion moment ---------- */
@media (prefers-reduced-motion: no-preference) {
  .cover__name span,
  .cover__role,
  .cover__thesis,
  .cover__actions,
  .cover__ficha,
  .cover__foot {
    animation: rise 0.9s var(--ease) both;
  }

  .cover__name span:nth-child(2) {
    animation-delay: 0.08s;
  }

  .cover__role {
    animation-delay: 0.16s;
  }

  .cover__thesis {
    animation-delay: 0.22s;
  }

  .cover__ficha {
    animation-delay: 0.18s;
  }

  .cover__actions {
    animation-delay: 0.3s;
  }

  .cover__foot {
    animation: fade 0.9s var(--ease) 0.36s both;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(14px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes fade {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .masthead__nav {
    display: none;
  }

  .masthead__meta {
    display: none;
  }
}

@media (max-width: 820px) {
  .cover__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cover__ficha {
    margin-top: 36px;
  }

  .index__head,
  .chapter__head,
  .chapter__body {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .chapter__label {
    position: static;
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
  }

  .index__list {
    margin-left: 0;
  }

  .chapter__aside {
    position: static;
    display: flex;
    align-items: baseline;
    gap: 12px;
  }

  .chapter__aside::before {
    width: 20px;
    margin: 0;
  }

  .job,
  .case,
  .edu,
  .stack__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .job:first-child,
  .edu:first-child {
    padding-top: 22px;
    border-top: 1px solid var(--rule);
  }

  .contact__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .cover__foot,
  .colophon__row {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 640px) {
  .masthead {
    top: 12px;
    width: calc(100% - 24px);
    border-radius: 14px;
  }

  .masthead__inner {
    gap: 12px;
    padding: 9px 12px;
  }

  .masthead__actions .btn {
    padding: 0.7em 0.85em;
    font-size: 0.625rem;
  }

  .masthead__actions .btn--ghost {
    display: none;
  }

  .cover__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cover__actions .btn {
    width: 100%;
  }

  .index__item {
    grid-template-columns: 30px minmax(0, 1fr) 16px;
    gap: 10px;
  }

  .index__title {
    font-size: 1.3rem;
  }

  .contact__list a {
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 420px) {
  .masthead__actions {
    display: none;
  }
}
