/* ============================================
   Fernando Rueda Oliva — Portfolio
   Dark immersive system · Archivo / Space Grotesk
   ============================================ */

:root {
  --bg: #09090b;
  --bg-soft: #0f0f12;
  --surface: #131318;
  --border: rgba(255, 255, 255, 0.08);
  --fg: #f4f4f5;
  --fg-muted: #a1a1aa;
  --fg-faint: #52525b;
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, 0.14);
  --accent-2: #7dd3fc;
  --font-display: "Archivo", sans-serif;
  --font-body: "Space Grotesk", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --space-section: clamp(6rem, 14vw, 12rem);
}

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

html { scroll-behavior: auto; }
html, body { background: var(--bg); }

body {
  font-family: var(--font-body);
  color: var(--fg);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

/* ---------- Noise ---------- */
.noise {
  position: fixed; inset: -50%;
  width: 200%; height: 200%;
  pointer-events: none;
  z-index: 2000;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
}

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 2px; z-index: 1500;
  background: transparent;
}
.scroll-progress span {
  display: block; height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left;
  transform: scaleX(0);
}

/* ---------- Cursor ---------- */
.cursor, .cursor-ring {
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 3000;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.cursor {
  width: 8px; height: 8px;
  background: var(--accent);
}
.cursor-ring {
  width: 36px; height: 36px;
  border: 1px solid rgba(79, 124, 255, 0.5);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease;
}
.cursor-ring.is-hover {
  width: 64px; height: 64px;
  border-color: var(--accent-2);
}
@media (hover: none), (pointer: coarse) {
  .cursor, .cursor-ring { display: none; }
}

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.4rem clamp(1.2rem, 4vw, 3rem);
  mix-blend-mode: difference;
}
.nav__logo {
  font-family: var(--font-display);
  font-weight: 800; font-size: 1.4rem;
  color: #fff; text-decoration: none;
  letter-spacing: -0.02em;
}
.nav__logo span { color: var(--accent); }
.nav__links { display: flex; gap: clamp(1rem, 3vw, 2.4rem); }
.nav__links a {
  color: #fff; text-decoration: none;
  font-size: 0.85rem; letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 0.25s ease;
}
.nav__links a:hover { opacity: 1; }
.nav__cta {
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
}
@media (max-width: 640px) {
  .nav__links a:not(.nav__cta) { display: none; }
}

/* ---------- Shared section bits ---------- */
.section {
  padding: var(--space-section) clamp(1.2rem, 6vw, 6rem);
  position: relative;
}
.section__label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 1.4rem;
}
.section__title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin-bottom: 3rem;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 clamp(1.2rem, 6vw, 6rem);
  position: relative;
  overflow: hidden;
}
.hero__grid-bg {
  position: absolute; inset: -10%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 65% at 50% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 50% 45%, #000 20%, transparent 75%);
}
.hero__glow {
  position: absolute; border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
}
.hero__glow--a {
  width: 44vw; height: 44vw;
  top: -12vw; right: -10vw;
  background: rgba(79, 124, 255, 0.16);
}
.hero__glow--b {
  width: 32vw; height: 32vw;
  bottom: -14vw; left: -8vw;
  background: rgba(125, 211, 252, 0.1);
}
.hero__inner { position: relative; z-index: 2; }
.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-muted);
  display: flex; align-items: flex-start; gap: 0.6rem;
  margin-bottom: 2rem;
}
.hero__eyebrow .dot {
  flex-shrink: 0;
  margin-top: 0.5em; /* centre on the first line when the text wraps */
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 12px #4ade80;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.hero__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.4rem, 13.5vw, 12.5rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}
.hero__line { display: block; overflow: hidden; white-space: nowrap; }
.hero__line--outline {
  color: transparent;
  -webkit-text-stroke: 2px rgba(244, 244, 245, 0.85);
}
.hero__meta {
  display: flex; flex-wrap: wrap; gap: 1rem 3rem;
  margin-top: 2.6rem;
  align-items: baseline;
}
.hero__role {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  font-weight: 600;
  color: var(--accent-2);
}
.hero__tags {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-faint);
  letter-spacing: 0.12em;
}
.hero__scroll {
  position: absolute;
  bottom: 2.4rem; left: clamp(1.2rem, 6vw, 6rem);
  display: flex; align-items: center; gap: 0.9rem;
  z-index: 2;
}
.hero__scroll-label {
  font-family: var(--font-mono);
  font-size: 0.72rem; letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.hero__scroll-line {
  width: 64px; height: 1px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  display: block;
}
.hero__scroll-line span {
  display: block; height: 100%; width: 40%;
  background: var(--accent);
  animation: scrollhint 1.8s ease-in-out infinite;
}
@keyframes scrollhint {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}

/* ---------- About ---------- */
.about__statement {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.6vw, 3rem);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.015em;
  max-width: 26ch;
}
.about__statement .word {
  display: inline-block;
  opacity: 0.14;
}
.about__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin-top: 5rem;
}
.about__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  transition: border-color 0.3s ease, transform 0.3s ease;
}
@media (hover: hover) {
  .about__card:hover {
    border-color: rgba(79, 124, 255, 0.4);
    transform: translateY(-4px);
  }
}
.about__card--photo {
  padding: 0;
  overflow: hidden;
  grid-row: span 2;
  display: flex;
  flex-direction: column;
}
.about__card--photo img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  object-position: 68% 20%;
  filter: grayscale(0.6) contrast(1.05);
  transition: filter 0.5s ease, transform 0.5s ease;
  flex-grow: 1;
}
@media (hover: hover) {
  .about__card--photo:hover img {
    filter: grayscale(0) contrast(1);
    transform: scale(1.03);
  }
}
/* No hover to reveal colour on touch screens, so show it from the start */
@media (hover: none) {
  .about__card--photo img { filter: none; }
}
.about__photo-caption {
  padding: 0.9rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}
.about__card--currently h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 0.7rem;
  color: var(--accent-2);
}
.about__card--currently p { color: var(--fg-muted); }
.stat-card { text-align: left; }
.stat-card__num {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5rem);
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.03em;
}
.stat-card__label {
  display: block;
  margin-top: 0.7rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
}
@media (max-width: 820px) {
  .about__grid { grid-template-columns: 1fr; }
}

/* ---------- Experience (horizontal scroll) ---------- */
.experience { position: relative; }
.experience__pin {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
  padding: 6rem 0 4rem;
}
.experience__head {
  padding: 0 clamp(1.2rem, 6vw, 6rem);
}
.experience__track {
  display: flex;
  gap: 1.6rem;
  padding: 0 clamp(1.2rem, 6vw, 6rem);
  will-change: transform;
  width: max-content;
}
.exp-card {
  width: min(430px, 82vw);
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.4rem;
  display: flex; flex-direction: column;
  transition: border-color 0.3s ease;
}
.exp-card:hover { border-color: rgba(79, 124, 255, 0.45); }
.exp-card__period {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  margin-bottom: 1.2rem;
}
.exp-card__role {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.exp-card__company {
  color: var(--accent-2);
  font-size: 0.95rem;
  margin: 0.5rem 0 1.2rem;
}
.exp-card__desc {
  color: var(--fg-muted);
  font-size: 0.95rem;
  flex-grow: 1;
}
.exp-card__tags {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 0.45rem;
  margin-top: 1.5rem;
}
.exp-card__tags li {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
}
.exp-card--end {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  align-items: flex-start; justify-content: center;
}
.exp-card--end p {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.exp-card--end em { color: var(--accent); font-style: normal; }
.exp-card__link {
  margin-top: 1.6rem;
  color: var(--accent-2);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.experience__progress {
  margin: 3rem clamp(1.2rem, 6vw, 6rem) 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.experience__progress span {
  display: block; height: 100%; width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}
@media (max-width: 820px) {
  .experience__pin { min-height: 0; padding: var(--space-section) 0; }
  .experience__track {
    width: auto;
    flex-direction: column;
    overflow: visible;
  }
  .exp-card { width: 100%; }
}

/* ---------- Stack / marquee ---------- */
.stack { overflow: hidden; }
.marquee {
  overflow: hidden;
  white-space: nowrap;
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}
.stack__marquees { border-bottom: 1px solid var(--border); }
.marquee__row {
  display: inline-flex;
  gap: 3.5rem;
  padding-right: 3.5rem;
  will-change: transform;
}
.marquee__row span {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.5vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: transparent;
  -webkit-text-stroke: 1px rgba(244, 244, 245, 0.4);
  transition: color 0.3s ease;
}
.marquee--alt .marquee__row span {
  color: var(--fg);
  -webkit-text-stroke: 0;
}
.marquee__row span:hover { color: var(--accent); -webkit-text-stroke-color: var(--accent); }
.skills__legend {
  display: flex; align-items: flex-start; gap: 0.6rem;
  margin-top: 4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}
.skills__swatch {
  flex-shrink: 0;
  margin-top: 0.2em; /* centre on the first line when the text wraps */
  width: 26px; height: 14px;
  border: 1px solid rgba(79, 124, 255, 0.5);
  border-radius: 999px;
  background: var(--accent-soft);
}
.skills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  margin-top: 1.2rem;
}
.skills__group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.9rem;
}
.skills__group h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 1.1rem;
}
.skills__list {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.skills__list li {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.32rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
}
.skills__list .core {
  color: var(--fg);
  border-color: rgba(79, 124, 255, 0.5);
  background: var(--accent-soft);
}
.stack__principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin-top: 5rem;
}
.principle {
  border-left: 2px solid var(--accent);
  padding: 0.4rem 0 0.4rem 1.6rem;
}
.principle h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.principle p { color: var(--fg-muted); font-size: 0.95rem; }
@media (max-width: 820px) {
  .skills, .stack__principles { grid-template-columns: 1fr; }
}

/* ---------- Work ---------- */
.work__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
}
.work__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.9rem;
  text-decoration: none;
  color: var(--fg);
  display: flex; flex-direction: column;
  min-height: 210px;
  transition: transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}
a.work__card:hover {
  transform: translateY(-6px);
  border-color: rgba(79, 124, 255, 0.5);
  background: var(--accent-soft);
}
.work__card-kind {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.1rem;
}
.work__card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  flex-grow: 1;
}
.work__card-meta {
  margin-top: 1.2rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}
.work__card--cert { grid-column: span 2; }
.work__card--edu { grid-column: span 2; background: linear-gradient(135deg, var(--surface), rgba(79, 124, 255, 0.08)); }
@media (max-width: 1024px) {
  .work__grid { grid-template-columns: repeat(2, 1fr); }
  .work__card--cert, .work__card--edu { grid-column: span 1; }
}
@media (max-width: 640px) {
  .work__grid { grid-template-columns: 1fr; }
}

/* ---------- Contact ---------- */
.contact {
  min-height: 92vh;
  display: flex; flex-direction: column; justify-content: center;
  text-align: center;
  align-items: center;
}
.contact .section__label { margin-bottom: 2rem; }
.contact__title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 9vw, 8rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.98;
}
.contact__line { display: block; overflow: hidden; }
.contact__nowrap { white-space: nowrap; }
.contact__line em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 2px var(--accent);
}
.contact__mail {
  display: inline-block;
  margin-top: 3.4rem;
  font-family: var(--font-mono);
  font-size: clamp(0.95rem, 2.4vw, 1.5rem);
  color: var(--fg);
  text-decoration: none;
  padding: 1.1rem 2.6rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  will-change: transform;
}
.contact__mail:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
@media (max-width: 400px) {
  .contact__mail { font-size: 0.85rem; padding: 1rem 1.4rem; }
}
.contact__links {
  display: flex; gap: 2.4rem;
  margin-top: 3rem;
}
.contact__links a {
  color: var(--fg-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.contact__links a:hover {
  color: var(--accent-2);
  border-color: var(--accent-2);
}
.contact__footer {
  margin-top: 6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-faint);
  letter-spacing: 0.1em;
}

/* ---------- Reveal defaults (JS enhances) ---------- */
[data-reveal] { will-change: transform, opacity; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .noise, .hero__eyebrow .dot, .hero__scroll-line span { animation: none; }
  .about__statement .word { opacity: 1; }
}
