/* ============================================================
   Oswaldo Ortiz — personal site
   Dark, typographic, peach-accented. Mobile-first.
   ============================================================ */

:root {
  --bg: #0b0b0f;
  --bg-soft: #121218;
  --ink: #ededf0;
  --muted: #8a8a95;
  --line: rgba(237, 237, 240, 0.12);
  --accent: #ffa776;
  --accent-deep: #ff7a45;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --pad: clamp(1.25rem, 4vw, 4rem);
}

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

html { scroll-behavior: auto; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

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

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

em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.01em;
}

a { color: inherit; text-decoration: none; }

/* ---------- WebGL canvas + grain ---------- */

#webgl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100svh;
  z-index: 0;
  pointer-events: none;
}

.no-webgl .hero {
  background:
    radial-gradient(ellipse 60% 45% at 72% 80%, rgba(255, 122, 69, 0.14), transparent),
    radial-gradient(ellipse 70% 60% at 30% 30%, rgba(28, 30, 44, 0.9), transparent);
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.5;
  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%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%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); }
  20% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, -5%); }
  60% { transform: translate(-5%, -2%); }
  80% { transform: translate(4%, 4%); }
}

/* ---------- Cursor ---------- */

.cursor {
  position: fixed;
  top: 0; left: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  z-index: 100;
  pointer-events: none;
  mix-blend-mode: difference;
  transform: translate(-50%, -50%);
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cursor.is-active { opacity: 1; }

@media (hover: hover) and (pointer: fine) {
  .cursor { display: block; }
}

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem var(--pad);
  transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
  background: linear-gradient(to bottom, rgba(11, 11, 15, 0.85), transparent);
}

.nav.is-hidden { transform: translateY(-110%); }

.nav__logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.nav__links {
  display: flex;
  gap: clamp(1.25rem, 3vw, 2.5rem);
  font-size: 0.85rem;
  font-weight: 500;
}

.nav__links a {
  position: relative;
  padding: 0.25rem 0;
}

.nav__links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.nav__links a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav__meta {
  display: none;
  gap: 1rem;
  color: var(--muted);
}

@media (min-width: 700px) {
  .nav__meta { display: flex; }
}

/* ---------- Hero ---------- */

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

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 var(--pad) clamp(2rem, 5vh, 4rem);
  position: relative;
}

.hero__overline {
  color: var(--muted);
  margin-bottom: clamp(1rem, 2.5vh, 2rem);
}

.hero__overline .accent { font-size: 0.5rem; vertical-align: middle; }

.hero__title {
  font-size: clamp(2.6rem, 9.5vw, 8.5rem);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.hero__line {
  display: block;
  overflow: hidden;
}

.line-inner { display: block; will-change: transform; }

.hero__title em { letter-spacing: -0.01em; }

.hero__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-top: clamp(1.5rem, 4vh, 3rem);
}

.hero__sub {
  max-width: 32rem;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  line-height: 1.6;
}

.hero__scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  flex-shrink: 0;
}

.hero__scroll-line {
  width: 1px;
  height: 3rem;
  background: linear-gradient(to bottom, var(--accent), transparent);
  animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%, 100% { transform: scaleY(0.4); transform-origin: top; opacity: 0.4; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ---------- Marquee ---------- */

.marquee {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 0;
  background: rgba(11, 11, 15, 0.6);
  backdrop-filter: blur(6px);
}

.marquee__track {
  display: flex;
  width: max-content;
  will-change: transform;
}

.marquee__inner {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Sections ---------- */

.section {
  padding: clamp(5rem, 14vh, 10rem) var(--pad);
  position: relative;
  background: var(--bg);
}

.section__label {
  color: var(--accent);
  margin-bottom: clamp(2rem, 5vh, 4rem);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section__label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- About ---------- */

.about__body {
  max-width: 52rem;
}

.about__text {
  font-size: clamp(1.35rem, 2.8vw, 2.1rem);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.015em;
  margin-bottom: 1.5em;
}

.about__text--muted {
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
}

.stats {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: clamp(3rem, 8vh, 5rem);
}

@media (min-width: 900px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--bg);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: background 0.4s ease;
}

.stat:hover { background: var(--bg-soft); }

.stat__num {
  font-size: clamp(2.2rem, 4.5vw, 3.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat__label { color: var(--muted); }

/* ---------- Work ---------- */

.work__list {
  list-style: none;
  border-top: 1px solid var(--line);
}

.project { border-bottom: 1px solid var(--line); }

.project__head {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: clamp(0.75rem, 2.5vw, 2rem);
  padding: clamp(1.4rem, 3.5vw, 2.2rem) 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.project__index {
  color: var(--muted);
  transition: color 0.3s ease;
}

.project__title {
  font-size: clamp(1.4rem, 4vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
  transition: color 0.3s ease, transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
}

.project__role {
  color: var(--muted);
  display: none;
}

@media (min-width: 800px) {
  .project__head { grid-template-columns: 3rem 1fr auto 2rem; }
  .project__role { display: block; }
}

.project__toggle {
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--muted);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), color 0.3s ease;
  justify-self: end;
}

.project__head:hover .project__title,
.project__head[aria-expanded="true"] .project__title {
  color: var(--accent);
  transform: translateX(0.4rem);
}

.project__head:hover .project__index { color: var(--accent); }

.project__head[aria-expanded="true"] .project__toggle {
  transform: rotate(45deg);
  color: var(--accent);
}

.project__body {
  height: 0;
  overflow: hidden;
}

.project__body-inner {
  padding: 0 0 clamp(1.6rem, 4vw, 2.4rem);
  max-width: 46rem;
}

@media (min-width: 800px) {
  .project__body-inner { margin-left: calc(3rem + clamp(0.75rem, 2.5vw, 2rem)); }
}

.project__body-inner p {
  color: var(--muted);
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
  line-height: 1.65;
}

.project__tags {
  margin-top: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.06em;
}

/* ---------- Contact ---------- */

.contact {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.contact__title {
  font-size: clamp(2.6rem, 9vw, 7.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  margin-bottom: clamp(2rem, 6vh, 3.5rem);
}

.contact__avail {
  color: var(--muted);
  margin: -1rem 0 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.contact__avail .accent {
  font-size: 0.55rem;
  animation: availPulse 2.4s ease-in-out infinite;
}

@keyframes availPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .contact__avail .accent { animation: none; }
}

.contact__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.contact__email {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 2.2vw, 1.3rem);
  letter-spacing: 0.04em;
  padding: 1rem 1.6rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  transition: border-color 0.35s ease, background 0.35s ease, color 0.35s ease;
}

.contact__email:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.contact__arrow {
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.contact__email:hover .contact__arrow {
  transform: translate(0.2rem, -0.2rem);
}

/* ---------- Footer ---------- */

.footer {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  justify-content: space-between;
  padding: 1.5rem var(--pad) 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg);
}

/* ---------- Reveal defaults (JS enhances) ---------- */

[data-reveal] { opacity: 0; transform: translateY(2.5rem); }
[data-hero-fade] { opacity: 0; }

.no-js [data-reveal],
.no-js [data-hero-fade],
.reduced-motion [data-reveal],
.reduced-motion [data-hero-fade] {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal], [data-hero-fade] { opacity: 1; transform: none; }
  .grain, .hero__scroll-line { animation: none; }
}
