/* ============================================================
   Randika Pathirana — portfolio
   ============================================================ */

:root {
  --bg: #0A0508;
  --bg-2: #120810;
  --card: rgba(255, 245, 240, 0.032);
  --card-2: rgba(255, 245, 240, 0.055);
  --line: rgba(255, 240, 232, 0.11);
  --line-2: rgba(255, 240, 232, 0.2);
  --crimson: #D31E33;
  --flame: #FF5B45;
  --ember: #FFA24B;
  --bone: #FBF3ED;
  --dim: rgba(251, 243, 237, 0.68);
  --dim-2: rgba(251, 243, 237, 0.46);

  --grad: linear-gradient(120deg, var(--crimson), var(--ember));
  --sans: "Archivo", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --r: 20px;
  --r-lg: 28px;
  --gutter: clamp(1.1rem, 4vw, 4rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--bone);
  font-family: var(--sans); font-size: clamp(1rem, 0.97rem + 0.15vw, 1.06rem);
  line-height: 1.6; font-weight: 400; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
body.no-scroll, body.loading { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--crimson); color: #fff; }

svg.i { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.035em; line-height: 1.02; }
p { margin: 0; }

.wrap { width: min(1240px, 100%); margin-inline: auto; padding-inline: var(--gutter); position: relative; z-index: 2; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--bone); color: var(--bg); padding: 0.7rem 1rem; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- background ---------- */

.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.4; }
.aurora span:nth-child(1) { width: 44vw; height: 44vw; left: -10vw; top: 6vh; background: #8C1424; animation: d1 28s var(--ease) infinite alternate; }
.aurora span:nth-child(2) { width: 34vw; height: 34vw; right: -8vw; top: 50vh; background: #58101F; animation: d2 34s var(--ease) infinite alternate; }
.aurora span:nth-child(3) { width: 24vw; height: 24vw; left: 45vw; bottom: -6vh; background: #A5501B; opacity: 0.2; animation: d1 40s var(--ease) infinite alternate-reverse; }
@keyframes d1 { to { transform: translate3d(8vw, -6vh, 0) scale(1.2); } }
@keyframes d2 { to { transform: translate3d(-10vw, 8vh, 0) scale(0.85); } }

.grain {
  position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 700ms steps(4) infinite;
}
@keyframes grain { 0% { transform: translate(0,0); } 25% { transform: translate(-4%,3%); } 50% { transform: translate(3%,-4%); } 75% { transform: translate(-3%,-3%); } 100% { transform: translate(4%,4%); } }

.spot { position: fixed; z-index: 2; pointer-events: none; width: 40rem; height: 40rem; margin: -20rem 0 0 -20rem; background: radial-gradient(circle, rgba(255,162,75,0.08), transparent 62%); opacity: 0; transition: opacity 0.6s; }
body[data-pointer="fine"] .spot { opacity: 1; }
main, .foot { position: relative; z-index: 3; }

/* ---------- nav ---------- */

#progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--grad); z-index: 60; transition: width 0.12s linear; }

.masthead { position: fixed; inset: auto 0 1.4rem 0; z-index: 50; display: flex; justify-content: center; pointer-events: none; }
.nav {
  display: flex; gap: 0.15rem; align-items: center; pointer-events: auto;
  background: rgba(14, 6, 11, 0.72); backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem;
}
.nav a { font-size: 0.82rem; color: var(--dim); padding: 0.5rem 0.95rem; border-radius: 999px; transition: color 0.3s, background 0.3s; }
.nav a:hover { color: var(--bone); }
.nav a[aria-current="true"] { color: #fff; background: rgba(255, 240, 232, 0.1); }

.nav-toggle { display: none; }
@media (max-width: 780px) {
  .masthead { inset: auto 0 1rem 0; }
  .nav { gap: 0; overflow-x: auto; max-width: calc(100vw - 2rem); scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 0.5rem 0.75rem; font-size: 0.78rem; white-space: nowrap; }
}

/* ---------- hero ---------- */

.hero { position: relative; height: 320vh; }
.hero-stage { position: sticky; top: 0; height: 100dvh; overflow: hidden; }
#film { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.hero-stage::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(100deg, var(--bg) 6%, rgba(10,5,8,0.82) 36%, rgba(10,5,8,0) 66%),
    linear-gradient(to bottom, rgba(10,5,8,0.6) 0%, rgba(10,5,8,0) 24%, rgba(10,5,8,0) 66%, var(--bg) 99%);
}

.hero-type { position: relative; z-index: 2; height: 100%; width: min(1240px,100%); margin-inline: auto; padding-inline: var(--gutter); display: grid; align-content: center; }
.hero-copy { max-width: 54%; }

.badge {
  display: inline-flex; align-items: center; gap: 0.55rem; margin-bottom: 1.6rem;
  border: 1px solid var(--line-2); border-radius: 999px; padding: 0.42rem 0.95rem;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em; color: var(--dim);
  background: var(--card);
}
.badge i { width: 7px; height: 7px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 0 rgba(74,222,128,0.5); animation: ping 2.4s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }

.hero-name { font-size: clamp(3rem, 8.4vw, 8rem); font-weight: 800; letter-spacing: -0.05em; }
.hero-name .line { display: block; overflow: hidden; padding-bottom: 0.04em; }
.hero-name .line > span { display: block; transform: translateY(105%); }
.ready .hero-name .line > span { animation: rise 1s var(--ease) forwards; }
.ready .hero-name .l2 > span { animation-delay: 0.1s; }
@keyframes rise { to { transform: none; } }
.hero-name .l2 > span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.hero-role { margin-top: 1.3rem; font-size: clamp(1.05rem, 1.7vw, 1.35rem); color: var(--bone); font-weight: 500; }
.hero-line { margin-top: 0.7rem; max-width: 44ch; color: var(--dim); }

.hero-cta { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 2.1rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.55rem; border-radius: 999px;
  padding: 0.85rem 1.4rem; font-size: 0.9rem; font-weight: 500;
  border: 1px solid var(--line-2); color: var(--bone); background: var(--card);
  transition: transform 0.3s var(--ease), background 0.3s, border-color 0.3s, color 0.3s;
}
.btn:hover { transform: translateY(-2px); background: var(--card-2); border-color: var(--line-2); }
.btn.primary { background: var(--grad); border-color: transparent; color: #250309; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }

.scroll-cue { position: absolute; left: var(--gutter); bottom: 1.8rem; z-index: 3; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.2em; color: var(--dim-2); display: flex; align-items: center; gap: 0.7rem; }
.scroll-cue::after { content: ""; width: 3rem; height: 1px; background: linear-gradient(90deg, var(--ember), transparent); animation: cue 2.4s ease-in-out infinite; }
@keyframes cue { 0%,100% { transform: scaleX(0.4); transform-origin: left; } 50% { transform: scaleX(1); transform-origin: left; } }

@media (max-width: 900px) {
  .hero { height: 280vh; }
  #film { top: auto; bottom: 0; height: 64dvh; }
  .hero-stage::after { background: linear-gradient(to bottom, var(--bg) 22%, rgba(10,5,8,0.45) 36%, rgba(10,5,8,0) 54%, rgba(10,5,8,0) 78%, var(--bg) 99%); }
  .hero-type { align-content: start; padding-top: 4.5rem; }
  .hero-copy { max-width: 100%; }
  .hero-cta, .scroll-cue { display: none; }
}

/* ---------- marquee ---------- */

.marquee { overflow: hidden; border-block: 1px solid var(--line); padding: 1.5rem 0; background: var(--bg-2); }
.marquee-track { display: flex; gap: 3rem; width: max-content; animation: slide 32s linear infinite; }
.marquee span { display: inline-flex; align-items: center; gap: 3rem; font-size: clamp(1.6rem, 4vw, 3rem); font-weight: 700; letter-spacing: -0.03em; color: transparent; -webkit-text-stroke: 1px var(--line-2); white-space: nowrap; }
.marquee span::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--crimson); -webkit-text-stroke: 0; flex: none; }
.marquee span:nth-child(even) { color: var(--bone); -webkit-text-stroke: 0; }
@keyframes slide { to { transform: translateX(-50%); } }

/* ---------- sections ---------- */

.band { padding-block: clamp(4.5rem, 10vh, 8rem); position: relative; }
.band-head { margin-bottom: clamp(2rem, 5vh, 3.4rem); display: grid; gap: 0.9rem; }
.kicker { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.14em; color: var(--ember); }
.band-head h2 { font-size: clamp(2.1rem, 5.6vw, 4rem); font-weight: 700; max-width: 18ch; }
.band-head h2 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.band-head .sub { color: var(--dim); max-width: 52ch; }

/* bento */

.bento { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.cell {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: clamp(1.3rem, 2.4vw, 1.9rem); position: relative; overflow: hidden;
  transition: border-color 0.4s, background 0.4s, transform 0.4s var(--ease);
}
.cell:hover { border-color: var(--line-2); background: var(--card-2); }
.cell-xl { grid-column: span 2; grid-row: span 2; }
.cell-w { grid-column: span 2; }
.cell h3 { font-size: 1.25rem; margin-bottom: 0.6rem; }
.cell p { color: var(--dim); font-size: 0.95rem; }
.cell .big { font-size: clamp(2.6rem, 5vw, 3.6rem); font-weight: 800; letter-spacing: -0.05em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; line-height: 1; }
.cell .cap { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--dim-2); margin-top: 0.6rem; display: block; }
.cell.photo { padding: 0; min-height: 260px; }
.cell.photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.cell.lede p { color: var(--bone); font-size: clamp(1.05rem, 1.5vw, 1.25rem); line-height: 1.5; }
.cell.lede p + p { color: var(--dim); font-size: 0.98rem; margin-top: 0.9rem; }
.cell .ico { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); color: var(--ember); font-size: 1.2rem; margin-bottom: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; list-style: none; padding: 0; }
.chips li { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.65rem; }

@media (max-width: 900px) { .bento { grid-template-columns: repeat(2, 1fr); } .cell-xl { grid-column: span 2; grid-row: auto; } }
@media (max-width: 560px) { .bento { grid-template-columns: 1fr; } .cell-xl, .cell-w { grid-column: span 1; } }

/* stacking work cards */

.work-stack { display: grid; gap: 2rem; }
.work-card {
  position: sticky; top: calc(8vh + var(--i) * 14px);
  background: linear-gradient(160deg, var(--bg-2), var(--bg));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: clamp(1.6rem, 3.5vw, 3rem);
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: clamp(1.4rem, 3vw, 3rem);
  overflow: hidden;
}
.work-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(80% 60% at 90% 0%, rgba(211,30,51,0.14), transparent 70%); pointer-events: none; }
.work-top { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.2rem; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; color: var(--dim-2); }
.work-top .num { color: transparent; background: var(--grad); -webkit-background-clip: text; background-clip: text; font-size: 0.95rem; font-weight: 700; }
.work-top .cat { border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.65rem; color: var(--dim); }
.work-card h3 { font-size: clamp(1.5rem, 3.2vw, 2.4rem); margin-bottom: 0.9rem; }
.work-card p { color: var(--dim); }
.work-side { display: grid; align-content: start; gap: 1.1rem; padding-top: 0.4rem; }
.work-impact { border-left: 2px solid var(--crimson); padding-left: 1rem; font-size: 0.92rem; color: var(--dim); }
@media (max-width: 860px) { .work-card { grid-template-columns: 1fr; position: static; } }

/* inventions */

.filings { display: grid; gap: 12px; }
.filing {
  display: grid; grid-template-columns: 3rem minmax(0,1fr) auto; gap: 1.2rem; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r); padding: 1.15rem 1.4rem; background: var(--card);
  transition: background 0.35s, border-color 0.35s, transform 0.35s var(--ease);
}
.filing:hover { background: var(--card-2); border-color: var(--line-2); transform: translateX(5px); }
.filing .n { font-family: var(--mono); font-size: 0.8rem; color: var(--dim-2); }
.filing h3 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.filing p { font-size: 0.88rem; color: var(--dim-2); }
.filing .meta { display: grid; justify-items: end; gap: 0.4rem; font-family: var(--mono); font-size: 0.7rem; color: var(--dim-2); text-align: right; }
.pill { border: 1px solid var(--line-2); border-radius: 999px; padding: 0.22rem 0.65rem; color: var(--dim); white-space: nowrap; }
.pill[data-grant="true"] { border-color: var(--ember); color: var(--ember); background: rgba(255,162,75,0.1); }
@media (max-width: 700px) { .filing { grid-template-columns: 2rem minmax(0,1fr); } .filing .meta { grid-column: 2; justify-items: start; text-align: left; } }

/* research */

.papers { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.paper { border: 1px solid var(--line); border-radius: var(--r); padding: 1.4rem; background: var(--card); transition: background 0.35s, border-color 0.35s, transform 0.35s var(--ease); }
.paper:hover { background: var(--card-2); border-color: var(--line-2); transform: translateY(-3px); }
.paper .yr { font-family: var(--mono); font-size: 0.72rem; color: var(--ember); }
.paper h3 { font-size: 1.02rem; font-weight: 600; line-height: 1.3; margin: 0.5rem 0 0.6rem; letter-spacing: -0.02em; }
.paper .venue { font-size: 0.83rem; color: var(--dim-2); }
.venues { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.6rem; list-style: none; padding: 0; }
.venues li { font-family: var(--mono); font-size: 0.72rem; color: var(--dim-2); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.8rem; }

/* experience */

.roles { display: grid; }
.role {
  display: grid; grid-template-columns: 8rem minmax(0,1fr) auto; gap: 1.5rem; align-items: baseline;
  padding: 1.5rem 0.6rem; border-top: 1px solid var(--line); transition: background 0.35s, padding-left 0.35s var(--ease);
}
.role:last-child { border-bottom: 1px solid var(--line); }
.role:hover { background: var(--card); padding-left: 1.2rem; }
.role .yr { font-family: var(--mono); font-size: 0.76rem; color: var(--dim-2); }
.role h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }
.role .org { font-size: 0.86rem; color: var(--ember); }
.role p { font-size: 0.92rem; color: var(--dim); margin-top: 0.5rem; max-width: 62ch; }
.role .now { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.68rem; color: #4ADE80; border: 1px solid rgba(74,222,128,0.35); border-radius: 999px; padding: 0.18rem 0.55rem; }
@media (max-width: 760px) { .role { grid-template-columns: 1fr; gap: 0.35rem; } }

/* skills */

.skill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.skill { border: 1px solid var(--line); border-radius: var(--r); padding: 1.4rem; background: var(--card); }
.skill h3 { display: flex; align-items: center; gap: 0.55rem; font-size: 1rem; margin-bottom: 1rem; }
.skill h3 svg { color: var(--ember); }
.skill ul { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
.skill li { font-size: 0.79rem; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 0.24rem 0.6rem; transition: color 0.3s, border-color 0.3s; }
.skill li:hover { color: var(--bone); border-color: var(--line-2); }

/* recognition */

.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.award { border: 1px solid var(--line); border-radius: var(--r); padding: 1.5rem; background: var(--card); position: relative; overflow: hidden; transition: transform 0.35s var(--ease), border-color 0.35s; }
.award:hover { transform: translateY(-3px); border-color: var(--line-2); }
.award .ico { color: var(--ember); font-size: 1.4rem; margin-bottom: 0.9rem; }
.award h3 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.award .org { font-size: 0.84rem; color: var(--dim-2); }
.award .yr { font-family: var(--mono); font-size: 0.72rem; color: var(--ember); }
.award p { font-size: 0.87rem; color: var(--dim); margin-top: 0.6rem; }

/* contact */

.cta { text-align: center; padding-block: clamp(5rem, 14vh, 10rem); }
.cta h2 { font-size: clamp(2.4rem, 8vw, 6rem); font-weight: 800; letter-spacing: -0.05em; max-width: 16ch; margin-inline: auto; }
.cta p { color: var(--dim); max-width: 46ch; margin: 1.4rem auto 0; }
.cta .btns { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; margin-top: 2.2rem; }
.contact-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 3.5rem; text-align: left; }
.contact-rows a, .contact-rows .static { display: flex; align-items: center; gap: 0.8rem; border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.3rem; background: var(--card); transition: background 0.35s, border-color 0.35s, transform 0.35s var(--ease); }
.contact-rows a:hover { background: var(--card-2); border-color: var(--line-2); transform: translateY(-3px); }
.contact-rows .ico { color: var(--ember); font-size: 1.2rem; }
.contact-rows .k { display: block; font-family: var(--mono); font-size: 0.68rem; color: var(--dim-2); }
.contact-rows .v { display: block; font-size: 0.92rem; overflow-wrap: anywhere; }

.foot { border-top: 1px solid var(--line); padding: 2rem var(--gutter) 6rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; font-family: var(--mono); font-size: 0.72rem; color: var(--dim-2); }
.foot a:hover { color: var(--ember); }

/* reveals + loader */

.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.stagger > * { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.stagger.in > * { opacity: 1; transform: none; }

#boot { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: grid; place-items: center; align-content: center; gap: 1.2rem; transition: opacity 0.7s var(--ease), visibility 0.7s; }
#boot[data-done="true"] { opacity: 0; visibility: hidden; }
#boot .n { font-size: clamp(3rem, 12vw, 7rem); font-weight: 800; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
#boot .bar { width: min(240px, 60vw); height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
#boot .bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width 0.25s linear; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .reveal, .stagger > * { opacity: 1; transform: none; }
  .hero-name .line > span { transform: none; }
  .aurora, .grain, .spot { display: none; }
  .work-card { position: static; }
}

@media print {
  .masthead, .hero, #progress, #boot, .aurora, .grain, .spot, .marquee, .scroll-cue { display: none !important; }
  body { background: #fff; color: #000; }
  .work-card { position: static; page-break-inside: avoid; }
}
