/* ============================================================
   RANDY GIL — portfolio
   dark, terminal-inflected payment-infrastructure aesthetic
   ============================================================ */

:root {
  --bg: #0a0a0b;
  --bg-soft: #111113;
  --ink: #e9e7e2;
  --ink-dim: #8a8a86;
  --ink-faint: #4a4a48;
  --accent: #c6f24e;
  --accent-dim: rgba(198, 242, 78, 0.14);
  --line: rgba(233, 231, 226, 0.1);
  --font-display: "Clash Display", "Space Grotesk", system-ui, sans-serif;
  --font-body: "Satoshi", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --pad: clamp(1.25rem, 4vw, 4rem);
}

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

html { scroll-behavior: auto; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

.mono { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.02em; }
.accent { color: var(--accent); font-style: normal; }

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

main { position: relative; z-index: 1; }

/* ============ GRAIN ============ */
.grain {
  position: fixed; inset: -50%;
  width: 200%; height: 200%;
  pointer-events: none;
  z-index: 90;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%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 8s steps(10) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -10%); }
  30% { transform: translate(3%, -15%); }
  50% { transform: translate(12%, 9%); }
  70% { transform: translate(9%, 4%); }
  90% { transform: translate(-1%, 7%); }
}

/* ============ PRELOADER ============ */
.preloader {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}
.preloader__inner {
  width: 100%;
  padding: var(--pad);
}
.preloader__line { color: var(--ink-dim); margin-bottom: 1rem; }
.preloader__prompt { color: var(--accent); }
.preloader__counter {
  font-size: clamp(4rem, 14vw, 10rem);
  line-height: 1;
  color: var(--ink);
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.preloader__bar {
  height: 1px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.preloader__bar span {
  position: absolute; inset: 0;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  display: block;
}

/* ============ CURSOR ============ */
.cursor, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 150;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.cursor {
  width: 6px; height: 6px;
  background: var(--accent);
}
.cursor-ring {
  width: 36px; height: 36px;
  border: 1px solid rgba(198, 242, 78, 0.4);
  transition: width 0.3s, height 0.3s, background 0.3s;
}
.cursor-ring.is-hover {
  width: 64px; height: 64px;
  background: rgba(198, 242, 78, 0.08);
}
@media (hover: none), (pointer: coarse) {
  .cursor, .cursor-ring { display: none; }
}

/* ============ NAV ============ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem var(--pad);
  mix-blend-mode: difference;
}
.nav__logo { font-size: 0.95rem; font-weight: 500; color: #fff; }
.nav__links { display: flex; gap: 2.2rem; }
.nav__link { color: #fff; opacity: 0.75; transition: opacity 0.25s; }
.nav__link:hover { opacity: 1; }
.nav__num { font-size: 0.65rem; vertical-align: super; margin-right: 0.15rem; }
.nav__cta {
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 99px;
  padding: 0.45rem 0.95rem;
  transition: border-color 0.25s;
}
.nav__cta:hover { border-color: #fff; }
.nav__cta-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198, 242, 78, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(198, 242, 78, 0); }
}
.nav__lang {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}
.nav__lang-btn {
  background: none;
  border: 0;
  padding: 0.2rem 0.15rem;
  color: #fff;
  opacity: 0.45;
  cursor: pointer;
  text-transform: lowercase;
  transition: opacity 0.25s;
}
.nav__lang-btn:hover { opacity: 0.85; }
.nav__lang-btn.is-active {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--accent);
}
.nav__lang-sep { color: #fff; opacity: 0.3; }
.nav__burger {
  display: none;
  background: none; border: 0;
  width: 40px; height: 40px;
  cursor: pointer;
  position: relative;
}
.nav__burger span {
  position: absolute;
  left: 8px; right: 8px;
  height: 1.5px;
  background: #fff;
  transition: transform 0.35s, top 0.35s;
}
.nav__burger span:nth-child(1) { top: 16px; }
.nav__burger span:nth-child(2) { top: 23px; }
.nav__burger[aria-expanded="true"] span:nth-child(1) { top: 19px; transform: rotate(45deg); }
.nav__burger[aria-expanded="true"] span:nth-child(2) { top: 19px; transform: rotate(-45deg); }

/* ============ MOBILE MENU ============ */
.menu {
  position: fixed; inset: 0;
  background: var(--bg-soft);
  z-index: 95;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3rem;
  padding: var(--pad);
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
}
.menu__links { display: flex; flex-direction: column; gap: 0.5rem; }
.menu__link {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 600;
  line-height: 1.15;
}
.menu__link .mono { font-size: 0.9rem; vertical-align: super; margin-right: 0.5rem; }
.menu__meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--ink-dim);
}

/* ============ HERO ============ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.hero__canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.hero__content {
  position: relative;
  z-index: 2;
  padding: 0 var(--pad) clamp(4rem, 9vh, 7rem);
}
.hero__eyebrow {
  color: var(--ink-dim);
  margin-bottom: clamp(1rem, 3vh, 2rem);
}
.hero__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(4.2rem, 16.5vw, 15rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.hero__title-line {
  display: block;
  overflow: hidden;
}
.hero__title-line > span { display: inline-block; }
.hero__title-line .char { display: inline-block; will-change: transform; }
.hero__title-line--offset { margin-left: clamp(2rem, 12vw, 14rem); }
.hero__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-top: clamp(1.5rem, 4vh, 3rem);
  flex-wrap: wrap;
}
.hero__sub {
  max-width: 34ch;
  font-size: clamp(1.05rem, 1.6vw, 1.4rem);
  line-height: 1.5;
  color: var(--ink);
}
.hero__sub strong { font-weight: 700; }
.hero__meta {
  display: flex;
  gap: 1.5rem;
  color: var(--ink-dim);
  flex-wrap: wrap;
}
.hero__scroll {
  position: absolute;
  right: var(--pad);
  top: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink-dim);
}
.hero__scroll-text { writing-mode: vertical-rl; letter-spacing: 0.25em; }
.hero__scroll-line {
  width: 1px; height: 56px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.hero__scroll-line::after {
  content: "";
  position: absolute;
  left: 0; top: -100%;
  width: 100%; height: 100%;
  background: var(--accent);
  animation: scrollLine 2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes scrollLine {
  0% { top: -100%; }
  60%, 100% { top: 100%; }
}

/* ============ SECTION HEAD ============ */
.section-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 var(--pad);
  margin-bottom: clamp(2rem, 5vh, 3.5rem);
}
.section-head__num { font-size: 0.7rem; }
.section-head__title {
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.25em;
}
.section-head__rule {
  flex: 1;
  height: 1px;
  background: var(--line);
  transform-origin: left;
}

/* ============ METRICS ============ */
.metrics {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.metrics__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.metric {
  padding: clamp(2rem, 5vw, 3.5rem) var(--pad);
  border-left: 1px solid var(--line);
}
.metric:first-child { border-left: 0; }
.metric__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 5.5vw, 5rem);
  line-height: 1;
  color: var(--accent);
  margin-bottom: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.metric__label { color: var(--ink-dim); line-height: 1.7; }

/* ============ ABOUT ============ */
.about { padding: clamp(5rem, 14vh, 10rem) 0; }
.about__grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: clamp(2.5rem, 6vw, 6rem);
  padding: 0 var(--pad);
  align-items: start;
}
.about__text {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.8vw, 2.4rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.about__text strong { color: var(--accent); font-weight: 600; }
.about__text .line { display: block; overflow: hidden; }
.about__card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.78rem;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}
.about__card-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}
.about__card-bar span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.about__card-bar span:first-child { background: #e0604f; }
.about__card-bar span:nth-child(2) { background: #e6b144; }
.about__card-bar span:nth-child(3) { background: #6fcf6f; }
.about__card-bar em {
  margin-left: auto;
  font-style: normal;
  color: var(--ink-faint);
  font-size: 0.7rem;
}
.about__card-code {
  padding: 1.4rem;
  line-height: 1.8;
  overflow-x: auto;
  color: var(--ink-dim);
}
.c-key { color: #c792ea; }
.c-var { color: #82aaff; }
.c-str { color: var(--accent); }
.c-num { color: #f78c6c; }
.caret { animation: blink 1.1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ============ WORK ============ */
.work { padding: clamp(4rem, 10vh, 8rem) 0; }
.work__heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5.2vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  padding: 0 var(--pad);
  margin-bottom: clamp(3rem, 8vh, 6rem);
  max-width: 22ch;
}
.work__heading .line { display: block; overflow: hidden; }
.work__list { border-top: 1px solid var(--line); }

.job { border-bottom: 1px solid var(--line); }
.job__head {
  display: grid;
  grid-template-columns: 8.5rem 1fr auto 2.5rem;
  align-items: baseline;
  gap: 1.5rem;
  padding: clamp(1.6rem, 4vh, 2.6rem) var(--pad);
  cursor: pointer;
  position: relative;
  isolation: isolate;
  transition: color 0.35s;
}
.job__head::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: -1;
}
.job__head:hover::before,
.job.is-open .job__head::before { transform: scaleY(1); }
.job__head:hover,
.job.is-open .job__head { color: var(--bg); }
.job__period { color: var(--ink-dim); transition: color 0.35s; }
.job__head:hover .job__period,
.job.is-open .job__head .job__period { color: rgba(10, 10, 11, 0.65); }
.job__company {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.7rem, 4.2vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.job__role { color: var(--ink-dim); transition: color 0.35s; }
.job__head:hover .job__role,
.job.is-open .job__head .job__role { color: rgba(10, 10, 11, 0.65); }
.job__arrow {
  font-size: 1.4rem;
  justify-self: end;
  transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.job.is-open .job__arrow { transform: rotate(135deg); }
.job__body {
  max-height: 0;
  overflow: hidden;
}
.job__body p {
  padding: clamp(1.5rem, 3vh, 2.2rem) var(--pad) 1.2rem;
  max-width: 62ch;
  color: var(--ink-dim);
  font-size: 1.02rem;
}
.job__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0 var(--pad) clamp(1.8rem, 4vh, 2.6rem);
}
.job__tags li {
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.35rem 0.9rem;
  font-size: 0.72rem;
  color: var(--ink-dim);
}

/* ============ STACK / MARQUEE ============ */
.stack {
  padding: clamp(4rem, 10vh, 8rem) 0;
  overflow: hidden;
}
.marquee {
  border-top: 1px solid var(--line);
  padding: clamp(1.2rem, 3vh, 2rem) 0;
  white-space: nowrap;
  overflow: hidden;
  touch-action: pan-y; /* horizontal swipes drag the track, vertical still scrolls the page */
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.marquee:active { cursor: grabbing; }
.marquee:last-child { border-bottom: 1px solid var(--line); }
.marquee__track {
  display: inline-flex;
  align-items: center;
  gap: 2.5rem;
  padding-right: 2.5rem;
  will-change: transform;
}
.marquee__track span {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.marquee--alt .marquee__track span {
  color: transparent;
  -webkit-text-stroke: 1px var(--ink-dim);
}
.marquee__track i {
  font-style: normal;
  color: var(--accent);
  font-size: 0.9rem;
}

/* ============ CONTACT ============ */
.contact {
  padding: clamp(5rem, 16vh, 12rem) 0 clamp(4rem, 10vh, 8rem);
  text-align: center;
}
.contact .section-head { margin-bottom: clamp(3rem, 8vh, 5rem); }
.contact__eyebrow { color: var(--ink-dim); margin-bottom: 1.5rem; }
.contact__big {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3rem, 11vw, 10rem);
  line-height: 1;
  letter-spacing: -0.02em;
  position: relative;
  transition: color 0.3s;
}
.contact__big .line { display: block; overflow: hidden; }
.contact__big::after {
  content: "";
  position: absolute;
  left: 0; bottom: -0.06em;
  width: 100%; height: 0.045em;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.6s cubic-bezier(0.65, 0, 0.35, 1);
}
.contact__big:hover::after { transform: scaleX(1); transform-origin: left; }
.contact__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(1rem, 3vw, 2.5rem);
  margin-top: clamp(3rem, 8vh, 5rem);
  padding: 0 var(--pad);
}
.contact__link {
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.8rem 1.4rem;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.contact__link:hover {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}
.contact__link:hover .accent { color: var(--bg); }

/* ============ FOOTER ============ */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.6rem var(--pad);
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
}
.footer__status { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ============ REVEAL PRIMITIVES ============ */
.reveal-line { overflow: hidden; }
.reveal-line > * { display: inline-block; }
[data-lines] .line { display: block; overflow: hidden; }
[data-lines] .line > .line-inner { display: block; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .metrics__grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(odd) { border-left: 0; }
  .metric:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .about__grid { grid-template-columns: 1fr; }
  .job__head {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "period arrow"
      "company arrow"
      "role arrow";
    gap: 0.4rem 1rem;
  }
  .job__period { grid-area: period; }
  .job__company { grid-area: company; }
  .job__role { grid-area: role; }
  .job__arrow { grid-area: arrow; align-self: center; }
}

@media (max-width: 760px) {
  .nav__links, .nav__cta { display: none; }
  .nav__burger { display: block; }
  .hero__scroll { display: none; }
  .hero__title-line--offset { margin-left: clamp(1.5rem, 8vw, 4rem); }
  .hero__bottom { flex-direction: column; align-items: flex-start; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .grain { animation: none; }
}
