/* ==========================================================================
   Francisco Alfaro — portfolio
   Dark-first, cinematic, spec-sheet aesthetic. Light theme available.
   ========================================================================== */

:root {
  --bg: #050608;
  --bg-alt: #0b0d12;
  --text: #f4f5f7;
  --muted: #8b909c;
  --line: rgba(255, 255, 255, 0.12);
  --hover: rgba(255, 255, 255, 0.04);
  --accent: #3e6ae1;
  --accent-ink: #ffffff;
  --header-solid: rgba(5, 6, 8, 0.88);
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --pad: clamp(20px, 4vw, 56px);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f4f4f4;
  --text: #171a20;
  --muted: #5c5e62;
  --line: rgba(23, 26, 32, 0.14);
  --hover: rgba(23, 26, 32, 0.04);
  --header-solid: rgba(255, 255, 255, 0.9);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: opacity 0.28s ease;
}
body.leaving {
  opacity: 0;
}
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
  transition: background-color 0.4s ease, color 0.4s ease,
    border-color 0.4s ease !important;
}
img {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
::selection {
  background: var(--accent);
  color: #fff;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1;
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: var(--pad);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  z-index: 200;
}
.skip-link:focus {
  top: 12px;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
  border-bottom: 1px solid transparent;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.site-header.solid {
  background: var(--header-solid);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom-color: var(--line);
}
/* over the dark hero the header is always light-on-dark */
body.has-hero .site-header:not(.solid) {
  color: #fff;
}
.wordmark {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vw, 34px);
}
.nav a,
.theme-toggle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  position: relative;
  padding: 6px 0;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav a:hover::after,
.nav a[aria-current="page"]::after {
  transform: scaleX(1);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  display: block;
}
.theme-toggle .moon {
  display: none;
}
:root[data-theme="light"] .theme-toggle .sun {
  display: none;
}
:root[data-theme="light"] .theme-toggle .moon {
  display: block;
}
.menu-toggle {
  display: none;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  width: 34px;
  height: 34px;
  position: relative;
  z-index: 120;
}
.menu-toggle span {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.3s, top 0.3s;
}
.menu-toggle span:first-child {
  top: 12px;
}
.menu-toggle span:last-child {
  top: 20px;
}
.menu-open .menu-toggle span:first-child {
  top: 16px;
  transform: rotate(45deg);
}
.menu-open .menu-toggle span:last-child {
  top: 16px;
  transform: rotate(-45deg);
}
.progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1px;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

@media (max-width: 820px) {
  .menu-toggle {
    display: block;
  }
  .nav {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: var(--bg);
    color: var(--text);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    padding: 90px var(--pad) 40px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }
  .menu-open .nav {
    opacity: 1;
    visibility: visible;
  }
  .menu-open .site-header {
    color: var(--text);
  }
  .nav a,
  .nav .theme-toggle {
    font-family: var(--font-display);
    font-stretch: 125%;
    font-weight: 800;
    font-size: clamp(2rem, 9vw, 3rem);
    letter-spacing: -0.01em;
    padding: 4px 0;
  }
  .nav .theme-toggle {
    margin-top: 18px;
  }
  .nav .theme-toggle svg {
    width: 28px;
    height: 28px;
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 190px;
  padding: 13px 28px;
  border: 1px solid var(--text);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.btn:hover {
  background: var(--text);
  color: var(--bg);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.12);
  background: var(--accent);
  color: #fff;
}
.btn.light {
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
}
.btn.light:hover {
  background: #fff;
  color: #000;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: #020305;
  color: #fff;
  isolation: isolate;
}
.hero canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
}
.hero::before {
  /* soft horizon glow + vignette */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
      120% 60% at 50% 115%,
      rgba(62, 106, 225, 0.32),
      transparent 60%
    ),
    linear-gradient(to bottom, rgba(2, 3, 5, 0.5), transparent 30%, rgba(2, 3, 5, 0.6));
}
.hero-inner {
  padding-bottom: clamp(70px, 12vh, 130px);
}
.hero .kicker {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: clamp(18px, 3vh, 34px);
}
.hero h1 {
  font-size: clamp(2.5rem, 9.6vw, 9.5rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.03em;
}
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.06em;
}
.line > span {
  display: block;
  transform: translateY(105%);
  animation: rise 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(0.25s + var(--i, 0) * 0.14s);
}
@keyframes rise {
  to {
    transform: none;
  }
}
.hero h1 em {
  font-style: normal;
  -webkit-text-stroke: 1.5px #fff;
  color: transparent;
}
.telemetry {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.7);
  opacity: 0;
  animation: fade 1s 1.3s forwards;
}
.telemetry .wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-block: 16px;
  flex-wrap: wrap;
}
.telemetry .mono {
  color: inherit;
}
.scroll-cue::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 14px;
  margin-left: 10px;
  vertical-align: -3px;
  background: currentColor;
  animation: cue 1.8s ease-in-out infinite;
}
@keyframes cue {
  0%,
  100% {
    transform: scaleY(0.3);
    transform-origin: top;
  }
  50% {
    transform: scaleY(1);
  }
}
@keyframes fade {
  to {
    opacity: 1;
  }
}
@media (max-width: 560px) {
  .telemetry .hide-sm {
    display: none;
  }
}

/* ---------- Chapters (featured work) ---------- */
.chapter {
  min-height: 86vh;
  display: flex;
  align-items: center;
  padding-block: clamp(60px, 10vh, 120px);
  border-top: 1px solid var(--line);
}
.chapter:nth-of-type(even) {
  background: var(--bg-alt);
}
.chapter .wrap {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(30px, 6vw, 110px);
  align-items: center;
}
.chapter:nth-of-type(even) .wrap {
  grid-template-columns: 1fr 1.05fr;
}
.chapter:nth-of-type(even) .chapter-media {
  order: -1;
}
.chapter .idx {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 26px;
  display: block;
}
.chapter h2 {
  font-size: clamp(2rem, 5.2vw, 5rem);
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}
.chapter p {
  color: var(--muted);
  max-width: 46ch;
  margin: 0 0 34px;
  font-size: 1.05rem;
}
.chapter-media {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a0b10;
}
.chapter-media img {
  width: 100%;
  height: 112%;
  object-fit: cover;
  will-change: transform;
}
@media (max-width: 860px) {
  .chapter {
    min-height: 0;
  }
  .chapter .wrap,
  .chapter:nth-of-type(even) .wrap {
    grid-template-columns: 1fr;
  }
  .chapter:nth-of-type(even) .chapter-media {
    order: 0;
  }
  .chapter-media {
    aspect-ratio: 4 / 3;
  }
}

/* ---------- Index rows ---------- */
.index-block {
  padding-block: clamp(70px, 12vh, 140px) 0;
  border-top: 1px solid var(--line);
}
.index-block .mono {
  margin-bottom: 30px;
  display: block;
}
.rows a {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  align-items: baseline;
  gap: 20px;
  padding: clamp(20px, 3.2vw, 38px) 0;
  border-top: 1px solid var(--line);
  transition: padding 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s;
}
.rows a:last-child {
  border-bottom: 1px solid var(--line);
}
.rows a:hover {
  padding-left: 18px;
  background: var(--hover);
}
.rows .n {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.rows .t {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.6rem, 5vw, 4rem);
  letter-spacing: -0.03em;
  line-height: 1;
}
.rows .c {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}
.rows .ar {
  font-size: 1.6rem;
  transition: transform 0.3s;
}
.rows a:hover .ar {
  transform: translateX(8px);
}
@media (max-width: 560px) {
  .rows a {
    grid-template-columns: 34px 1fr auto;
  }
  .rows .c {
    display: none;
  }
}

.closing {
  padding-block: clamp(90px, 16vh, 190px);
  text-align: left;
}
.closing a.giant {
  display: inline-block;
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(2.4rem, 9vw, 9rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  position: relative;
}
.giant .arrow {
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.giant:hover .arrow {
  transform: translate(10px, -10px);
}
.closing .mono {
  display: block;
  margin-top: 28px;
}

/* ---------- Inner pages ---------- */
.page-top {
  padding-top: clamp(130px, 22vh, 220px);
  padding-bottom: clamp(30px, 6vh, 60px);
}
.page-top h1 {
  font-size: clamp(2.6rem, 10vw, 9rem);
  letter-spacing: -0.04em;
  margin: 22px 0 24px;
}
.page-top p {
  color: var(--muted);
  max-width: 56ch;
  margin: 0;
  font-size: 1.1rem;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding-block: 22px;
  border-top: 1px solid var(--line);
}
.search {
  flex: 1;
  min-width: 200px;
  max-width: 460px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 10px 0;
  border-radius: 0;
}
.search:focus {
  outline: 0;
  border-bottom-color: var(--text);
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-bottom: clamp(70px, 12vh, 140px);
}
@media (max-width: 1000px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 620px) {
  .grid {
    grid-template-columns: 1fr;
  }
}
.tile {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.3s;
}
.tile:hover {
  background: var(--hover);
}
.tile-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #0a0b10;
  border-bottom: 1px solid var(--line);
}
.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.4s;
  filter: saturate(0.85);
}
.tile:hover .tile-media img {
  transform: scale(1.06);
  filter: none;
}
.tile-media .fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: 4rem;
  color: rgba(255, 255, 255, 0.25);
}
.tile-body {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.tile-top {
  display: flex;
  justify-content: space-between;
}
.tile h3 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile .go {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tile .go span:last-child {
  transition: transform 0.3s;
  font-size: 1rem;
  color: var(--text);
}
.tile:hover .go span:last-child {
  transform: translate(4px, -4px);
}
.empty {
  display: none;
  padding: 60px 0;
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: clamp(30px, 6vw, 100px);
  padding-bottom: clamp(70px, 12vh, 140px);
  align-items: start;
}
.portrait {
  position: sticky;
  top: 100px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 0.6s, transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.portrait:hover img {
  filter: none;
  transform: scale(1.03);
}
.lede {
  font-size: clamp(1.4rem, 2.6vw, 2.2rem);
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
}
.about-copy p.body {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 58ch;
  margin: 0 0 40px;
}
.spec {
  margin: 0 0 44px;
  border-top: 1px solid var(--line);
}
.spec div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.spec dt,
.spec dd {
  margin: 0;
}
.spec dd {
  font-size: 0.98rem;
}
.spec dd a {
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s;
}
.spec dd a:hover {
  border-color: var(--text);
}
@media (max-width: 820px) {
  .about-grid {
    grid-template-columns: 1fr;
  }
  .portrait {
    position: static;
    max-width: 420px;
  }
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(30px, 6vw, 100px);
  padding-bottom: clamp(70px, 12vh, 140px);
}
.mail-giant {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: clamp(1.1rem, 2.4vw, 2.1rem);
  letter-spacing: -0.02em;
  word-break: break-all;
  display: inline-block;
  margin-bottom: 40px;
  border-bottom: 2px solid var(--text);
  padding-bottom: 6px;
}
.link-rows a {
  display: flex;
  justify-content: space-between;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  transition: padding 0.3s, background 0.3s;
}
.link-rows a:last-child {
  border-bottom: 1px solid var(--line);
}
.link-rows a:hover {
  padding-left: 14px;
  background: var(--hover);
}
form .f {
  display: grid;
  gap: 4px;
  margin-bottom: 26px;
}
form input,
form textarea {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  padding: 8px 0 12px;
  border-radius: 0;
}
form textarea {
  min-height: 120px;
  resize: vertical;
}
form input:focus,
form textarea:focus {
  outline: 0;
  border-bottom-color: var(--text);
}
@media (max-width: 820px) {
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-block: 26px;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-footer nav {
  display: flex;
  gap: 26px;
}
.site-footer a:hover {
  color: var(--text);
}

/* ---------- Reveal ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--d, 0ms);
}
.js .reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .js .reveal,
  .line > span {
    opacity: 1;
    transform: none;
  }
  .telemetry {
    opacity: 1;
  }
}

@media (max-width: 700px) {
  .hero h1 {
    font-size: 12.5vw;
  }
}
