/* Devapriyan Sampath — portfolio. Hand-written, no framework, no build step. */

:root {
  --bg:        #080b12;
  --bg-alt:    #0b0f1a;
  --surface:   #111827;
  --surface-2: #161f33;
  --border:    #212c46;
  --border-lit:#31406b;

  --text:      #eaeff9;
  --text-dim:  #99a5c0;
  --text-mute: #67748f;

  --primary:   #39d6d0;
  --primary-d: #0f9d97;
  --violet:    #a78bfa;
  --amber:     #f5b445;

  --radius: 12px;
  --radius-lg: 18px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --nav-h: 60px;

  /* Written by effects.js on pointer move; the defaults keep everything flat
     when JavaScript is off, on touch, or under reduced-motion. */
  --rx: 0deg;
  --ry: 0deg;
  --gx: 50%;
  --gy: 0%;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 18px); }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap { width: min(1180px, 100% - 3rem); margin-inline: auto; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-2); padding: .1rem .36rem;
  border-radius: 5px; color: var(--violet);
}
em { font-style: normal; color: var(--primary); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--primary); color: #04201f; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

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

/* ── Nav ──────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100; height: var(--nav-h);
  border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
}
.nav.scrolled {
  background: rgba(8,11,18,.78);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom-color: var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); }
.nav-brand {
  color: var(--text); font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; gap: .55rem; letter-spacing: -.01em;
}
.nav-brand:hover { text-decoration: none; color: var(--primary); }
.mark {
  color: var(--primary);
  filter: drop-shadow(0 0 14px rgba(57,214,208,.7));
  animation: markPulse 5s ease-in-out infinite;
}
@keyframes markPulse {
  0%, 100% { opacity: 1; transform: rotate(0deg); }
  50%      { opacity: .72; transform: rotate(180deg); }
}
.nav-links { display: flex; gap: 1.6rem; font-size: .87rem; }
.nav-links a { color: var(--text-dim); position: relative; padding: .2rem 0; }
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -2px; height: 1.5px;
  background: var(--primary); transition: right .28s cubic-bezier(.2,.7,.3,1);
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a:hover::after, .nav-links a.active::after { right: 0; }
.nav-links a.active { color: var(--primary); }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: min(92vh, 860px);
  display: flex; align-items: center;
  padding: 4rem 0 5rem;
  margin-top: calc(var(--nav-h) * -1);
  padding-top: calc(var(--nav-h) + 4rem);
  overflow: hidden;
}
#scene {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; z-index: 0;
}
/* Keeps the cloud from competing with the headline: dark at the left where
   the text sits, clear at the right where the geometry is worth seeing. */
.hero-veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(100deg, var(--bg) 4%, rgba(8,11,18,.86) 34%, rgba(8,11,18,.30) 62%, rgba(8,11,18,.55) 100%),
    radial-gradient(1100px 520px at 12% 8%, rgba(57,214,208,.11), transparent 62%),
    linear-gradient(to bottom, transparent 72%, var(--bg) 100%);
}
.hero-inner { position: relative; z-index: 2; }

.hero-kicker {
  font-family: var(--mono); font-size: .76rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--primary); margin: 0 0 1.1rem;
  display: flex; align-items: center; gap: .7rem;
}
.hero-kicker::before {
  content: ""; width: 34px; height: 1px; background: var(--primary); opacity: .7;
}
.hero-title {
  margin: 0 0 1.4rem; font-size: clamp(2.1rem, 5.6vw, 3.9rem);
  line-height: 1.08; letter-spacing: -.035em; font-weight: 800;
  text-wrap: balance;
}
.hero-title em {
  background: linear-gradient(100deg, var(--primary), var(--violet));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-sub {
  margin: 0 0 2.2rem; max-width: 58ch; color: var(--text-dim); font-size: 1.02rem;
}
.hero-sub strong { color: var(--text); font-weight: 600; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: .7rem 1.5rem; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s, color .18s, background .18s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  color: #04201f;
  box-shadow: 0 8px 24px -12px rgba(57,214,208,.8);
}
.btn-primary:hover { box-shadow: 0 14px 32px -12px rgba(57,214,208,.9); }
.btn-ghost {
  border-color: var(--border-lit); color: var(--text-dim);
  background: rgba(17,24,39,.5); backdrop-filter: blur(6px);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.hero-stats { display: flex; gap: 3.2rem; margin: 3.2rem 0 0; padding: 0; flex-wrap: wrap; }
.hero-stats div { margin: 0; }
.hero-stats dt {
  font-family: var(--mono); font-size: 2.2rem; font-weight: 600;
  letter-spacing: -.04em; line-height: 1;
  background: linear-gradient(160deg, var(--primary), var(--primary-d));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-stats dd {
  margin: .4rem 0 0; font-size: .78rem; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .07em;
}
.scene-caption {
  position: absolute; right: 0; bottom: -2.4rem; margin: 0;
  font-family: var(--mono); font-size: .68rem; color: var(--text-mute);
  letter-spacing: .04em;
}

/* ── Sections ─────────────────────────────────────────────── */
.section { padding: 5rem 0; position: relative; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-title {
  font-size: clamp(1.55rem, 3vw, 2.1rem); margin: 0 0 .85rem;
  letter-spacing: -.025em; font-weight: 700;
}
.section-lead { margin: 0 0 2.2rem; color: var(--text-dim); max-width: 70ch; font-size: .95rem; }

/* ── Scroll reveal ────────────────────────────────────────── */
/* Only applied once JS confirms it can drive it — otherwise content that
   never receives .in would stay invisible forever.
 *
 * Elements that also tilt cannot take a `transform` here: there is one
 * transform property, so whichever rule wins silently erases the other. The
 * first version of this did exactly that and the tilt never applied at all.
 * Those elements get `--reveal-y` instead, which their own transform folds in. */
.reveal-on .reveal {
  opacity: 0;
  transition: opacity .6s cubic-bezier(.2,.7,.3,1) var(--delay, 0ms),
              transform .6s cubic-bezier(.2,.7,.3,1) var(--delay, 0ms);
}
.reveal-on .reveal.in { opacity: 1; }
.reveal-on .reveal:not(.tilt3d) { transform: translate3d(0, 22px, 0); }
.reveal-on .reveal.in:not(.tilt3d) { transform: none; }
.reveal-on .tilt3d.reveal { --reveal-y: 22px; }
.reveal-on .tilt3d.reveal.in { --reveal-y: 0px; }

/* ── Filters ──────────────────────────────────────────────── */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.filter {
  font: inherit; font-size: .83rem; cursor: pointer;
  padding: .45rem 1rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); transition: all .2s;
}
.filter:hover { border-color: var(--border-lit); color: var(--text); transform: translateY(-1px); }
.filter[aria-selected="true"] {
  background: rgba(57,214,208,.14); border-color: var(--primary); color: var(--primary);
  box-shadow: 0 4px 16px -8px rgba(57,214,208,.7);
}
.filter .count { font-family: var(--mono); opacity: .6; margin-left: .4rem; font-size: .9em; }

/* ── Project cards ────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1.6rem; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  /* perspective lives in the card's own transform so no wrapper is needed and
     the grid keeps its normal layout behaviour. */
  transform: perspective(1100px) rotateX(var(--rx)) rotateY(var(--ry))
             translate3d(0, var(--reveal-y, 0px), 0);
  transform-style: preserve-3d;
  transition: transform .35s cubic-bezier(.2,.7,.3,1),
              border-color .3s, box-shadow .35s;
  will-change: transform;
}
.card[hidden] { display: none; }
.tilt-on .card:hover {
  border-color: var(--border-lit);
  box-shadow: 0 28px 60px -28px rgba(0,0,0,.95), 0 0 0 1px rgba(57,214,208,.09);
  transition: transform .08s linear, border-color .3s, box-shadow .35s;
}
/* The glare: a soft highlight that follows the cursor across the surface. */
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(420px circle at var(--gx) var(--gy),
              rgba(57,214,208,.13), transparent 45%);
  opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 3;
}
.tilt-on .card:hover::after { opacity: 1; }

.card-shot {
  display: block; position: relative; aspect-ratio: 16 / 10;
  background: var(--surface-2); overflow: hidden;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-shot img {
  width: 100%; height: 100%; object-fit: cover; object-position: top center;
  display: block; transition: transform .6s cubic-bezier(.2,.7,.3,1), opacity .35s;
  opacity: .9;
}
.card:hover .card-shot img { transform: scale(1.05); opacity: 1; }
.card-shot::after {
  content: "Open the live demo →";
  position: absolute; inset: auto 0 0 0; padding: .85rem 1.15rem;
  background: linear-gradient(transparent, rgba(8,11,18,.96));
  font-size: .82rem; font-weight: 600; color: var(--primary);
  opacity: 0; transform: translateY(6px); transition: opacity .28s, transform .28s;
}
.card:hover .card-shot::after { opacity: 1; transform: none; }

.card-body {
  padding: 1.3rem 1.4rem 1.45rem; display: flex; flex-direction: column; flex: 1;
  transform: translateZ(24px);   /* lifts the text off the card face */
}
.card-kind {
  font-family: var(--mono); font-size: .65rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-mute); margin-bottom: .4rem;
}
.card-name { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.card-name a { color: var(--text); }
.card-name a:hover { color: var(--primary); text-decoration: none; }
.card-tagline { margin: .3rem 0 .9rem; font-size: .86rem; color: var(--primary); }
.card-summary { margin: 0 0 .95rem; font-size: .87rem; color: var(--text-dim); }

.card-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem;
  margin-bottom: 1rem; padding: .85rem 0; border-block: 1px solid var(--border);
}
.card-metrics div { min-width: 0; }
.metric-val {
  font-family: var(--mono); font-size: .98rem; font-weight: 600; color: var(--primary);
  display: block; line-height: 1.2;
}
.metric-lab {
  font-size: .67rem; color: var(--text-mute); text-transform: uppercase;
  letter-spacing: .05em; display: block; margin-top: .2rem;
}

.card-note { margin: 0 0 .85rem; font-size: .82rem; color: var(--text-dim); }
.card-note strong { color: var(--text); font-weight: 600; }
.card-note.bug { color: var(--text-mute); }
.card-note.bug strong { color: var(--amber); }

.card-stack { display: flex; gap: .35rem; flex-wrap: wrap; margin: 0 0 1.1rem; }
.tag {
  font-family: var(--mono); font-size: .66rem; padding: .2rem .55rem;
  border-radius: 5px; background: var(--surface-2); color: var(--text-mute);
  border: 1px solid transparent; transition: border-color .2s, color .2s;
}
.card:hover .tag { border-color: var(--border); color: var(--text-dim); }

.card-links { display: flex; gap: .6rem; margin-top: auto; }
.card-links a {
  flex: 1; text-align: center; font-size: .82rem; font-weight: 600;
  padding: .55rem .8rem; border-radius: 9px; transition: all .2s;
}
.link-demo {
  background: rgba(57,214,208,.13); color: var(--primary);
  border: 1px solid rgba(57,214,208,.32);
}
.link-demo:hover {
  background: rgba(57,214,208,.24); text-decoration: none;
  box-shadow: 0 6px 18px -8px rgba(57,214,208,.7);
}
.link-src { border: 1px solid var(--border-lit); color: var(--text-dim); }
.link-src:hover { border-color: var(--text-dim); color: var(--text); text-decoration: none; }

/* ── Approach ─────────────────────────────────────────────── */
.approach { display: grid; grid-template-columns: repeat(auto-fit, minmax(345px, 1fr)); gap: 1.6rem; }
.approach article {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.6rem 1.6rem 1.4rem;
  transform: perspective(1100px) rotateX(var(--rx)) rotateY(var(--ry))
             translate3d(0, var(--reveal-y, 0px), 0);
  transition: transform .35s cubic-bezier(.2,.7,.3,1), border-color .3s, box-shadow .35s;
  overflow: hidden;
}
.approach article::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--violet));
}
.tilt-on .approach article:hover {
  border-color: var(--border-lit);
  box-shadow: 0 24px 50px -26px rgba(0,0,0,.9);
  transition: transform .08s linear, border-color .3s, box-shadow .35s;
}
.approach-num {
  position: absolute; top: .9rem; right: 1.2rem;
  font-family: var(--mono); font-size: 2.6rem; font-weight: 600;
  color: var(--surface-2); line-height: 1; letter-spacing: -.04em;
}
.approach h3 { margin: 0 0 .7rem; font-size: 1.04rem; font-weight: 700; position: relative; }
.approach p { margin: 0 0 .85rem; font-size: .88rem; color: var(--text-dim); position: relative; }
.approach p:last-child { margin-bottom: 0; }

/* ── Skills ───────────────────────────────────────────────── */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.1rem; }
.skill-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.35rem;
  transform: perspective(1100px) rotateX(var(--rx)) rotateY(var(--ry))
             translate3d(0, var(--reveal-y, 0px), 0);
  transition: transform .35s cubic-bezier(.2,.7,.3,1), border-color .3s;
}
.tilt-on .skill-group:hover {
  border-color: var(--border-lit);
  transition: transform .08s linear, border-color .3s;
}
.skill-group h3 {
  margin: 0 0 .8rem; font-size: .76rem; text-transform: uppercase;
  letter-spacing: .11em; color: var(--primary); font-family: var(--mono); font-weight: 600;
}
.skill-list { display: flex; gap: .4rem; flex-wrap: wrap; }
.skill {
  font-size: .79rem; padding: .3rem .68rem; border-radius: 7px;
  background: var(--surface-2); color: var(--text-dim);
  transition: color .2s, background .2s;
}
.skill-group:hover .skill { background: #1a2439; color: var(--text); }

/* ── Contact ──────────────────────────────────────────────── */
.contact { text-align: center; }
.contact .section-lead { margin-inline: auto; }
.contact-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem; max-width: 820px; margin-inline: auto;
}
.contact-card {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: 1.5rem 1.2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  transition: transform .25s cubic-bezier(.2,.7,.3,1), border-color .25s, box-shadow .25s;
}
.contact-card:hover {
  text-decoration: none; transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 20px 44px -24px rgba(57,214,208,.6);
}
.contact-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: .5rem;
  background: linear-gradient(140deg, rgba(57,214,208,.2), rgba(167,139,250,.14));
  border: 1px solid var(--border-lit);
  color: var(--primary); font-size: 1rem; font-weight: 700; font-family: var(--mono);
}
.contact-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-mute); font-family: var(--mono);
}
.contact-value { font-size: .87rem; font-weight: 500; word-break: break-all; }

/* ── Footer ───────────────────────────────────────────────── */
.foot {
  padding: 2.6rem 0 3.6rem; border-top: 1px solid var(--border);
  color: var(--text-mute); font-size: .84rem;
}
.foot p { margin: .35rem 0; max-width: 70ch; }
.foot-src { font-size: .8rem; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 860px) {
  .wrap { width: min(1180px, 100% - 1.8rem); }
  .nav-links { gap: 1rem; font-size: .8rem; }
  .nav-links a[href="#skills"], .nav-links a[href="#approach"] { display: none; }
  .hero { min-height: auto; padding-bottom: 3.5rem; }
  .hero-veil {
    /* On a narrow screen the text spans the full width, so the cloud has to
       recede everywhere rather than only on the left. */
    background:
      linear-gradient(180deg, rgba(8,11,18,.72) 0%, rgba(8,11,18,.90) 45%, var(--bg) 100%),
      radial-gradient(700px 400px at 50% 0%, rgba(57,214,208,.12), transparent 65%);
  }
  .hero-stats { gap: 1.9rem; }
  .hero-stats dt { font-size: 1.75rem; }
  .scene-caption { display: none; }
  .grid { grid-template-columns: 1fr; }
  .section { padding: 3.4rem 0; }
  .approach-num { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal-on .reveal { opacity: 1; transform: none; }
}
