/* =========================================================
   Srimal Ruwange — Creative Developer
   Cosmic / cinematic dark theme
   ========================================================= */

:root {
  --bg:        #07060a;
  --bg-soft:   #0c0a10;
  --ink:       #f4ede4;   /* warm white */
  --muted:     #8c8479;
  --line:      rgba(244, 237, 228, 0.12);
  --copper:    #ff5e2b;
  --copper-2:  #e8722e;
  --ember:     #c0341a;
  --gold:      #f0b429;

  --maxw: 1480px;
  --pad:  clamp(20px, 5vw, 80px);

  --f-display: "Space Grotesk", system-ui, sans-serif;
  --f-body:    "Inter", system-ui, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-weight: 300;
  line-height: 1.5;
  overflow-x: hidden;
  cursor: none;
}

@media (hover: none) { body { cursor: auto; } }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { background: var(--copper); color: #0a0708; }

/* ---- Lenis ---- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

/* =========================================================
   WebGL canvas + grain
   ========================================================= */
.gl-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  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.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 6s steps(6) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-5%, 8%); }
  40% { transform: translate(7%, -4%); }
  60% { transform: translate(-3%, 5%); }
  80% { transform: translate(4%, -6%); }
}

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

/* =========================================================
   Preloader
   ========================================================= */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.preloader__inner { width: min(320px, 70vw); text-align: center; }
.preloader__name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(48px, 12vw, 90px);
  letter-spacing: 0.04em;
  margin-bottom: 28px;
  background: linear-gradient(120deg, var(--ink), var(--copper));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.preloader__bar {
  height: 2px;
  width: 100%;
  background: var(--line);
  overflow: hidden;
}
.preloader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--copper);
}
.preloader__count {
  margin-top: 16px;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.preloader__pct { opacity: 0.5; }

/* =========================================================
   Custom cursor
   ========================================================= */
.cursor { position: fixed; inset: 0; z-index: 9000; pointer-events: none; }
.cursor__dot, .cursor__ring {
  position: absolute; top: 0; left: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.cursor__dot {
  width: 6px; height: 6px;
  background: var(--copper);
}
.cursor__ring {
  width: 38px; height: 38px;
  border: 1px solid rgba(244, 237, 228, 0.4);
  transition: width .35s var(--ease), height .35s var(--ease),
              background .35s var(--ease), border-color .35s var(--ease);
}
.cursor--hover .cursor__ring {
  width: 64px; height: 64px;
  border-color: var(--copper);
  background: rgba(255, 94, 43, 0.08);
}
.cursor--view .cursor__ring {
  width: 96px; height: 96px;
  background: var(--copper);
  border-color: var(--copper);
}
.cursor__ring::after {
  content: "VIEW";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em;
  color: #0a0708; opacity: 0;
  transition: opacity .3s var(--ease);
}
.cursor--view .cursor__ring::after { opacity: 1; }
@media (hover: none) { .cursor { display: none; } }

/* =========================================================
   Nav
   ========================================================= */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(18px, 2.4vw, 30px) var(--pad);
  mix-blend-mode: difference;
}
.nav__brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-display); font-weight: 600;
  font-size: 16px; letter-spacing: 0.01em;
}
.nav__brand-mark { color: var(--copper); animation: spin 12s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.nav__links { display: flex; align-items: center; gap: clamp(18px, 2.4vw, 40px); }
.nav__links a {
  font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.04em;
  position: relative; overflow: hidden; padding: 2px 0;
}
.nav__links a span { display: inline-block; transition: transform .4s var(--ease); }
.nav__links a::after {
  content: attr(data-hover);
  position: absolute; left: 0; top: 100%;
}
.nav__links a:not(.nav__cta)::before {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform .4s var(--ease);
}
.nav__links a:not(.nav__cta):hover::before { transform: scaleX(1); transform-origin: left; }
.nav__cta {
  border: 1px solid currentColor; border-radius: 100px;
  padding: 8px 18px !important;
}
.nav__burger { display: none; }

/* mobile menu */
.menu {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg-soft);
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--pad);
  clip-path: inset(0 0 100% 0);
  pointer-events: none;
}
.menu.open { pointer-events: auto; }
.menu__links { display: flex; flex-direction: column; gap: 8px; }
.menu__links a {
  font-family: var(--f-display); font-weight: 600;
  font-size: clamp(40px, 13vw, 72px); line-height: 1.05;
}
.menu__foot { margin-top: 48px; display: flex; flex-direction: column; gap: 14px; }
.menu__cta {
  display: inline-flex; align-self: flex-start;
  font-family: var(--f-display); font-weight: 500; font-size: 20px;
  padding: 12px 26px; border: 1px solid var(--line); border-radius: 100px;
}
.menu__domain { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }

/* =========================================================
   Hero
   ========================================================= */
.hero {
  position: relative;
  min-height: 100svh;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(7,6,10,0.92) 0%, rgba(7,6,10,0.45) 32%, transparent 60%);
}
.hero__meta {
  position: absolute;
  top: clamp(96px, 16vh, 180px);
  font-family: var(--f-mono);
  font-size: 12px; letter-spacing: 0.05em;
  color: var(--muted);
  display: flex; flex-direction: column; gap: 6px;
}
.hero__meta--left { left: var(--pad); }
.hero__meta--right { right: var(--pad); text-align: right; }
.hero__meta .line { overflow: hidden; }
.line--avail { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.hero__meta--right .line--avail { justify-content: flex-end; }
.line--avail i {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 12px #4ade80; animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.hero__title { margin-bottom: clamp(28px, 6vh, 70px); }
.display {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(64px, 16.5vw, 280px);
  line-height: 0.86;
  letter-spacing: -0.03em;
}
.display__line { display: block; overflow: hidden; }
.display__word { display: inline-block; will-change: transform; }
.display em {
  font-style: italic; font-weight: 400; color: var(--copper);
}
.hero__sub {
  max-width: 46ch;
  margin-top: clamp(20px, 3vh, 34px);
  font-size: clamp(15px, 1.4vw, 19px);
  color: rgba(244, 237, 228, 0.78);
  font-weight: 300;
}
.hero__scroll {
  position: absolute;
  right: var(--pad);
  bottom: clamp(28px, 5vh, 56px);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
}
.hero__scroll-line {
  width: 1px; height: 56px; background: var(--line); position: relative; overflow: hidden;
}
.hero__scroll-line::after {
  content: ""; position: absolute; top: -50%; left: 0;
  width: 100%; height: 50%; background: var(--copper);
  animation: scrollLine 1.8s var(--ease-io) infinite;
}
@keyframes scrollLine { to { top: 100%; } }

/* =========================================================
   Marquee
   ========================================================= */
.marquee {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  padding: clamp(16px, 2vw, 26px) 0;
  background: rgba(7, 6, 10, 0.4);
}
.marquee__track { display: flex; width: max-content; }
.marquee__group {
  display: flex; align-items: center; gap: 40px; padding-right: 40px;
  font-family: var(--f-display); font-weight: 500;
  font-size: clamp(28px, 4vw, 56px);
  white-space: nowrap;
}
.marquee__group i { color: var(--copper); font-style: normal; font-size: 0.5em; }
.marquee__group span:nth-child(even) { color: transparent; -webkit-text-stroke: 1px var(--muted); }

/* =========================================================
   Section heads
   ========================================================= */
.section-head {
  display: flex; align-items: baseline; gap: 16px;
  padding: clamp(70px, 12vh, 150px) var(--pad) clamp(28px, 5vh, 60px);
  border-bottom: 1px solid var(--line);
}
.section-head__idx { font-family: var(--f-mono); color: var(--copper); font-size: 14px; }
.section-head__label {
  font-family: var(--f-display); font-weight: 500;
  font-size: clamp(13px, 1.3vw, 16px); letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted);
}

/* =========================================================
   About
   ========================================================= */
.about { padding-bottom: clamp(40px, 8vh, 100px); }
.about__grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(30px, 6vw, 90px);
  padding: clamp(40px, 7vh, 90px) var(--pad) 0;
  align-items: start;
}
.about__portrait { position: relative; }
.about__portrait-frame {
  position: relative;
  border: 1px solid var(--line);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  will-change: transform;
}
.about__portrait-frame img {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(0.2) contrast(1.05);
  transition: transform .8s var(--ease), filter .8s var(--ease);
}
.about__portrait:hover .about__portrait-frame img { transform: scale(1.05); filter: grayscale(0); }
.about__portrait-glow {
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 120%, rgba(255,94,43,0.45), transparent 60%);
  mix-blend-mode: screen; pointer-events: none;
}
.about__portrait-tag {
  position: absolute; bottom: 14px; left: 14px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em;
  background: rgba(7,6,10,0.7); backdrop-filter: blur(6px);
  padding: 6px 10px; border: 1px solid var(--line);
}
.about__lead {
  font-family: var(--f-display); font-weight: 400;
  font-size: clamp(28px, 4.2vw, 64px); line-height: 1.1; letter-spacing: -0.02em;
  margin: 0;
}
.about__lead em { font-style: italic; color: var(--copper); }
.about__body { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }
.about__text {
  max-width: 52ch; color: rgba(244,237,228,0.72);
  font-size: clamp(15px, 1.15vw, 17px); margin: 0;
}
.about__stats {
  display: flex; flex-wrap: wrap; gap: clamp(24px, 5vw, 72px);
  margin: clamp(48px, 8vh, 96px) var(--pad) 0;
  padding-top: clamp(28px, 4vh, 44px);
  border-top: 1px solid var(--line);
}
.stat__num {
  display: block; font-family: var(--f-display); font-weight: 600;
  font-size: clamp(40px, 5vw, 72px); line-height: 1; letter-spacing: -0.02em;
}
.stat__label {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--muted); margin-top: 8px; display: block;
}

/* =========================================================
   Work
   ========================================================= */
.work { position: relative; }
.work__list { padding: 0 var(--pad); }
.project {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: clamp(22px, 3vw, 38px) 0;
  border-bottom: 1px solid var(--line);
  transition: padding-left .5s var(--ease);
}
.project:hover { padding-left: clamp(10px, 1.5vw, 24px); }
.project__media { display: none; }
.project__info { display: flex; align-items: baseline; gap: clamp(14px, 2vw, 28px); flex-wrap: wrap; }
.project__idx { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.project__title {
  font-family: var(--f-display); font-weight: 500;
  font-size: clamp(28px, 4.4vw, 64px); line-height: 1; letter-spacing: -0.02em;
  transition: color .4s var(--ease), transform .5s var(--ease);
}
.project:hover .project__title { color: var(--copper); }
.project__cat {
  font-family: var(--f-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.03em;
}
.project__year { font-family: var(--f-mono); font-size: 13px; color: var(--muted); justify-self: end; }
.project__idx { align-self: center; }

/* floating preview */
.work__preview {
  position: fixed;
  top: 0; left: 0;
  width: 320px; height: 220px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  will-change: transform, opacity;
  overflow: hidden;
  border-radius: 6px;
}
.work__preview-inner { width: 100%; height: 100%; transition: background .3s; }
@media (hover: none) { .work__preview { display: none; } }

/* =========================================================
   Capabilities
   ========================================================= */
.caps { padding-bottom: clamp(40px, 8vh, 90px); }
.caps__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  margin-top: 1px;
}
.cap {
  background: var(--bg);
  padding: clamp(34px, 5vw, 70px) var(--pad);
  transition: background .5s var(--ease);
  position: relative;
}
.cap:hover { background: var(--bg-soft); }
.cap__no { font-family: var(--f-mono); font-size: 13px; color: var(--copper); }
.cap__title {
  font-family: var(--f-display); font-weight: 500;
  font-size: clamp(26px, 3vw, 44px); margin: 18px 0 16px; letter-spacing: -0.02em;
}
.cap p { color: rgba(244,237,228,0.66); max-width: 42ch; font-size: clamp(14px,1.1vw,16px); }

/* =========================================================
   Contact
   ========================================================= */
.contact {
  padding: clamp(80px, 16vh, 200px) var(--pad) clamp(30px, 5vh, 50px);
  text-align: center;
  position: relative;
}
.contact__eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: clamp(28px, 5vh, 50px);
}
.contact__eyebrow i { width: 7px; height: 7px; border-radius: 50%; background: var(--copper); box-shadow: 0 0 12px var(--copper); }
.contact__title {
  font-family: var(--f-display); font-weight: 600;
  font-size: clamp(46px, 11vw, 180px); line-height: 0.9; letter-spacing: -0.03em;
}
.contact__title em { font-style: italic; font-weight: 400; color: var(--copper); }
.contact__btn {
  display: inline-flex; align-items: center; gap: 14px;
  margin-top: clamp(34px, 6vh, 64px);
  padding: 18px 36px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-family: var(--f-display); font-weight: 500;
  font-size: clamp(16px, 1.6vw, 22px);
  letter-spacing: -0.01em;
  position: relative; overflow: hidden;
  transition: color .4s var(--ease), border-color .4s var(--ease);
}
.contact__btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--copper);
  transform: translateY(101%);
  transition: transform .5s var(--ease);
}
.contact__btn:hover { color: #0a0708; border-color: var(--copper); }
.contact__btn:hover::before { transform: translateY(0); }
.contact__btn-icon { transition: transform .4s var(--ease); }
.contact__btn:hover .contact__btn-icon { transform: translate(3px, -3px); }

.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 30px;
  margin-top: clamp(70px, 14vh, 160px);
  padding-top: clamp(28px, 4vh, 40px);
  border-top: 1px solid var(--line);
  text-align: left;
}
.footer__col { display: flex; flex-direction: column; gap: 8px; }
.footer__col--end { text-align: right; align-items: flex-end; }
.footer__h { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.footer__col a { font-size: 15px; transition: color .3s; }
.footer__col a:hover { color: var(--copper); }
.footer__clock { font-family: var(--f-mono); font-size: 15px; }
.footer__copy { font-family: var(--f-mono); font-size: 11px; color: var(--muted); margin-top: 14px; }

/* =========================================================
   Reveal defaults (pre-JS state)
   ========================================================= */
[data-reveal] { will-change: transform, opacity; }
.display__word, [data-hero-word] { transform: translateY(110%); }
.no-js [data-reveal], .no-js .display__word { transform: none; opacity: 1; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
  .nav__links { display: none; }
  .nav__burger {
    display: flex; flex-direction: column; gap: 5px;
    background: none; border: none; cursor: pointer; padding: 6px;
  }
  .nav__burger span { width: 26px; height: 2px; background: var(--ink); transition: transform .4s var(--ease), opacity .3s; }
  .nav.open .nav__burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav.open .nav__burger span:nth-child(2) { transform: translateY(-0px) rotate(-45deg); }
  .about__grid { grid-template-columns: 1fr; }
  .about__portrait { max-width: 340px; }
  .caps__grid { grid-template-columns: 1fr; }
  .project { grid-template-columns: 40px 1fr; }
  .project__year { display: none; }
  .hero__meta--right { display: none; }
}

@media (max-width: 560px) {
  .hero__scroll { display: none; }
  .footer { flex-direction: column; }
  .footer__col--end { text-align: left; align-items: flex-start; }
  .about__stats { gap: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .display__word, [data-hero-word], [data-reveal] { transform: none !important; opacity: 1 !important; }
}
