/* ============================================================
   rvp.dev — styles
   Layers: tokens → fonts → reset/base → background → utilities
   → nav → hero → sections → cards → buttons → contact → footer
   → keyframes → media queries → reduced-motion (last, wins)
   ============================================================ */

/* ── Tokens ── */
:root {
  --bg: #090b14;
  --surface: #111729;
  --surface-2: #0f1424;
  --border: #22304a;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --text: #dbe7ff;
  --muted: #92a7c9;
  --radius: 14px;
  --container: 1080px;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --glow: rgba(56, 189, 248, 0.5);
  --font-sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

/* ── Fonts (self-hosted, latin subsets) ── */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/space-grotesk-var.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-400.woff2') format('woff2');
}

/* ── Reset / base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 10% -10%, rgba(56, 189, 248, 0.13), transparent 42%),
    radial-gradient(circle at 90% 0%, rgba(34, 197, 94, 0.09), transparent 36%),
    linear-gradient(180deg, #090b14 0%, #070a12 100%);
}

img,
svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: rgba(56, 189, 248, 0.28);
  color: #eaf4ff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Background: grid + noise (fixed, zero-JS) ── */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 100% 72% at 50% 0%, black 28%, transparent 75%);
  mask-image: radial-gradient(ellipse 100% 72% at 50% 0%, black 28%, transparent 75%);
}

.bg-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Cursor spotlight (JS updates --mx/--my only) ── */
#spotlight {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    650px circle at var(--mx, 50%) var(--my, -20%),
    rgba(56, 189, 248, 0.07),
    transparent 45%
  );
}

@media (pointer: coarse) {
  #spotlight {
    display: none;
  }
}

/* ── Utilities ── */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 28px;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 100;
  background: var(--accent);
  color: #071224;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.2s var(--ease-out-expo);
}

.skip-link:focus {
  top: 12px;
}

/* Scroll reveal — .in-view added by IntersectionObserver */
[data-reveal] {
  opacity: 0;
  translate: 0 24px;
  transition:
    opacity 0.7s var(--ease-out-expo),
    translate 0.7s var(--ease-out-expo);
  transition-delay: calc(var(--i, 0) * 80ms);
}

[data-reveal].in-view {
  opacity: 1;
  translate: 0 0;
}

/* ── Nav ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  transition: border-color 0.4s, background-color 0.4s;
}

.site-nav.scrolled {
  border-bottom-color: rgba(34, 48, 74, 0.7);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}

.nav-brand img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.nav-brand b {
  color: var(--accent);
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-github {
  display: inline-flex;
  color: var(--muted);
  transition: color 0.2s;
}

.nav-github:hover {
  color: var(--text);
}

/* ── Hero ── */
.hero {
  position: relative;
  z-index: 1;
  padding: 110px 0 100px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 56px;
  align-items: center;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Load-in stagger: children carry --i */
.hero [data-rise] {
  animation: rise 0.9s var(--ease-out-expo) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  padding: 5px 15px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  background: rgba(56, 189, 248, 0.08);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.hero-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.9);
  animation: pulse 2.4s ease-in-out infinite;
}

.hero h1 {
  font-size: clamp(2.4rem, 5.2vw, 3.7rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  text-wrap: balance;
}

.hero h1 .accent {
  background: linear-gradient(120deg, var(--accent), #67e8f9 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 1.12rem;
  color: var(--muted);
  max-width: 480px;
  font-weight: 400;
  text-wrap: pretty;
}

.hero-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ── Terminal card ── */
.terminal {
  border-radius: var(--radius);
  border: 1px solid rgba(34, 48, 74, 0.9);
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow:
    0 1px 0 rgba(148, 163, 184, 0.06) inset,
    0 30px 70px rgba(2, 6, 16, 0.6),
    0 0 60px rgba(56, 189, 248, 0.06);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.9;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border-bottom: 1px solid rgba(34, 48, 74, 0.7);
  background: rgba(9, 12, 22, 0.5);
}

.terminal-bar i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #2b3a55;
}

.terminal-bar i:nth-child(1) { background: #fb7185; }
.terminal-bar i:nth-child(2) { background: #fbbf24; }
.terminal-bar i:nth-child(3) { background: #4ade80; }

.terminal-bar span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.terminal-body {
  padding: 18px 18px 22px;
  color: var(--muted);
}

.terminal-body .prompt { color: var(--accent-2); }
.terminal-body .cmd { color: var(--text); }
.terminal-body .ok { color: var(--accent-2); }
.terminal-body .dim { color: #5b6d8f; }
.terminal-body .hl { color: var(--accent); }

/* Typing effect: width animates in ch steps; caret = border-right */
.type-line .cmd {
  display: inline-block;
  vertical-align: bottom;
  white-space: nowrap;
  overflow: hidden;
  max-width: 49ch;
  border-right: 2px solid var(--accent);
  animation:
    typing 2.4s steps(49) 0.9s both,
    caret 0.9s step-end 6 3.3s;
}

.terminal-out {
  opacity: 0;
  animation: fade-in 0.5s ease 3.4s both;
}

/* ── Sections ── */
main {
  position: relative;
  z-index: 1;
}

section {
  padding: 88px 0;
}

section + section {
  border-top: 1px solid rgba(34, 48, 74, 0.45);
}

.section-head {
  margin-bottom: 44px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-label::before {
  content: '// ';
  color: #48627f;
}

.section-title {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* ── Cards: glow border (two-layer background trick).
      JS sets --cx/--cy per card; defaults keep glow off-card. ── */
.card {
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--surface), var(--surface-2)) padding-box,
    radial-gradient(
      260px circle at var(--cx, -200px) var(--cy, -200px),
      var(--glow),
      var(--border) 65%
    ) border-box;
  transition:
    transform 0.35s var(--ease-out-expo),
    box-shadow 0.35s var(--ease-out-expo);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 44px rgba(3, 8, 20, 0.55), 0 0 40px rgba(56, 189, 248, 0.07);
}

/* ── Projects ── */
.project-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  min-height: 320px; /* reserve space: cards render via JS (CLS guard) */
}

.project-card {
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Featured: rotating conic border (progressive enhancement).
   @property must live at the sheet's top level; unsupporting browsers
   ignore it and the @supports guard keeps the static glow border. */
@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@supports (background: conic-gradient(from 0deg, red, blue)) {
  .project-card.featured {
    background:
      linear-gradient(180deg, var(--surface), var(--surface-2)) padding-box,
      conic-gradient(
        from var(--angle),
        var(--border) 0%,
        var(--border) 68%,
        rgba(56, 189, 248, 0.9) 82%,
        rgba(103, 232, 249, 0.5) 88%,
        var(--border) 100%
      ) border-box;
    animation: spin-border 7s linear infinite;
  }

  .project-card.featured:hover {
    animation-play-state: paused;
  }
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.project-icon {
  width: 56px;
  height: 56px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.project-icon svg {
  width: 34px;
  height: 34px;
}

.project-icon img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.project-icon--env {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.3);
}

.project-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.26);
  color: var(--accent);
  white-space: nowrap;
}

.project-card h3 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.project-desc {
  font-size: 0.95rem;
  color: var(--muted);
  flex-grow: 1;
}

.project-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--muted);
}

.project-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── About (bento) ── */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.about-card {
  padding: 26px;
}

.about-card.wide {
  grid-column: span 2;
}

.about-card h3 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
}

.about-card p {
  font-size: 0.95rem;
  color: var(--muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition:
    transform 0.25s var(--ease-out-expo),
    box-shadow 0.25s,
    color 0.2s,
    border-color 0.2s,
    background-color 0.2s;
  will-change: transform;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #67e8f9);
  color: #071224;
  box-shadow: 0 8px 30px rgba(56, 189, 248, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 12px 34px rgba(56, 189, 248, 0.3);
}

.btn-ghost {
  background: rgba(8, 14, 26, 0.55);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: #33538a;
}

/* ── Contact ── */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  max-width: 720px;
}

.contact-card {
  padding: 24px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: var(--text);
}

.contact-card .contact-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.contact-card .contact-meta {
  min-width: 0;
}

.contact-card .contact-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.contact-card .contact-value {
  display: block;
  font-size: 0.92rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 7px 13px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.copy-btn:hover {
  color: var(--text);
  border-color: #33538a;
}

.copy-btn.copied {
  color: var(--accent-2);
  border-color: rgba(34, 197, 94, 0.4);
}

/* ── Footer ── */
footer {
  border-top: 1px solid rgba(34, 48, 74, 0.45);
  padding: 36px 0;
  color: var(--muted);
  font-size: 0.8rem;
}

footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

footer .mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #5b6d8f;
}

/* ── 404 page ── */
.error-page {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 40px 24px;
}

.error-page .code {
  font-family: var(--font-mono);
  font-size: clamp(4rem, 14vw, 8rem);
  font-weight: 400;
  line-height: 1;
  background: linear-gradient(120deg, var(--accent), #67e8f9 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.error-page p {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* ── Keyframes ── */
@keyframes rise {
  from {
    opacity: 0;
    translate: 0 22px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

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

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.72);
    opacity: 0.6;
  }
}

@keyframes typing {
  from { max-width: 0; }
  to { max-width: 49ch; }
}

@keyframes caret {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: transparent; }
}

@keyframes spin-border {
  to { --angle: 360deg; }
}

/* ── Responsive ── */
@media (max-width: 920px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    padding: 80px 0 72px;
  }

  .terminal {
    max-width: min(560px, 100%);
  }
}

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

  .project-grid {
    min-height: 560px;
  }
}

@media (max-width: 600px) {
  section {
    padding: 64px 0;
  }

  .about-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .about-card.wide {
    grid-column: span 1;
  }

  .nav-links {
    gap: 18px;
  }

  .nav-links .hide-sm {
    display: none;
  }

  /* narrow screens: let the command wrap naturally, no typewriter clip */
  .terminal {
    font-size: 0.72rem;
  }

  .type-line .cmd {
    white-space: normal;
    max-width: none;
    border-right: none;
    animation: none;
  }

  .terminal-out {
    animation-delay: 0.9s;
  }

  footer .container {
    justify-content: center;
    text-align: center;
  }
}

/* ── Reduced motion: static, fully readable page ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  [data-reveal] {
    opacity: 1;
    translate: 0 0;
  }

  .hero [data-rise] {
    animation: none;
  }

  .type-line .cmd {
    max-width: none;
    border-right: none;
    animation: none;
  }

  .terminal-out {
    opacity: 1;
    animation: none;
  }

  #spotlight {
    display: none;
  }
}
