:root {
  --charcoal: #1c1b1a;
  --cream: #f6f0e8;
  --mango: #f6831f;
  --blue: #3d63ff;
  --coral: #ff6f61;
  --sage: #93a67e;
  --accent: var(--blue);
  --display: "Rubik", "Arial Black", sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
  --g: clamp(16px, 3vw, 44px);
  --fg: var(--charcoal); --dim: rgba(28, 27, 26, 0.56); --acc: var(--mango); --acc2: var(--blue); --bgc: var(--cream);
}
body[data-theme="light"], body[data-theme="realm"] { --fg: var(--charcoal); --dim: rgba(28, 27, 26, 0.56); --acc: var(--mango); --acc2: var(--blue); --bgc: var(--cream); }
body[data-theme="blue"] { --fg: var(--cream); --dim: rgba(246, 240, 232, 0.72); --acc: var(--mango); --acc2: var(--cream); --bgc: var(--blue); }
body[data-theme="mango"] { --fg: var(--charcoal); --dim: rgba(28, 27, 26, 0.62); --acc: var(--cream); --acc2: var(--blue); --bgc: var(--mango); }
body[data-theme="dark"] { --fg: var(--cream); --dim: rgba(246, 240, 232, 0.6); --acc: var(--mango); --acc2: var(--coral); --bgc: var(--charcoal); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--cream); scroll-behavior: smooth; }
html.locked, html.locked body { overflow: hidden; }
body { background: var(--cream); color: var(--fg); font-family: var(--sans); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow-x: hidden; transition: color 0.5s; }
body:not(.ready) { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--mango); color: var(--charcoal); }
svg use { pointer-events: none; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
main { position: relative; z-index: 2; transition: opacity 0.4s; }
body.diving main, body.in-realm main, body.diving .rail, body.in-realm .rail { opacity: 0; pointer-events: none; }

/* ---------- type ---------- */
.display { font-family: var(--display); font-weight: 900; letter-spacing: -0.035em; line-height: 0.9; text-transform: lowercase; }
.display em, .serif em, h2 em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; text-transform: none; color: var(--acc2); }
.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.dim { color: var(--dim); }
.serif { font-family: var(--serif); }
.h2 { font-size: clamp(34px, 4.2vw, 64px); }
.label { color: var(--acc); margin-bottom: 14px; }
body.glitching .display, body.glitching #wd-title { animation: jit 0.16s steps(3) 1; }
@keyframes jit { 0% { transform: translate(4px, 0) skewX(-8deg); clip-path: inset(10% 0 40% 0); } 50% { transform: translate(-4px, 0); clip-path: inset(50% 0 5% 0); } 100% { transform: none; clip-path: none; } }

.btn { display: inline-flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none; padding: 12px 20px; border-radius: 99px; border: 2px solid var(--fg); color: var(--fg); transition: background 0.2s, color 0.2s, transform 0.2s; }
.btn svg { width: 14px; height: 14px; color: var(--mango); transition: transform 0.6s; }
.btn:hover svg { transform: rotate(180deg); }
.btn.solid { background: var(--fg); color: var(--bgc); }
.btn.solid:hover { transform: translateY(-2px) rotate(-1deg); }
.link { color: var(--fg); border-bottom: 2px solid var(--acc); padding-bottom: 2px; }
.link:hover { color: var(--acc); }

/* scribbles (draw on) */
.scribble { display: block; overflow: visible; pointer-events: none; }
.scribble path { fill: none; stroke: var(--mango); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s cubic-bezier(0.6, 0, 0.2, 1) 0.2s; }
.scribble.drawn path { stroke-dashoffset: 0; }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; z-index: 100; background: var(--cream); color: var(--charcoal); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; transition: clip-path 0.9s cubic-bezier(0.7, 0, 0.2, 1), visibility 0.9s; clip-path: circle(150% at 50% 50%); }
body.ready #loader { clip-path: circle(0% at 50% 50%); visibility: hidden; }
.ld-ast { width: 46px; height: 46px; color: var(--mango); animation: spin 2.2s linear infinite; }
.ld-word { font-family: var(--display); font-weight: 900; font-size: 44px; letter-spacing: -0.04em; }
.ld-track { width: 200px; height: 14px; border: 2px solid var(--charcoal); border-radius: 99px; padding: 2px; overflow: hidden; }
#ld-bar { display: block; height: 100%; width: 100%; background: var(--blue); border-radius: 99px; transform-origin: left; transform: scaleX(0.04); transition: transform 0.3s; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cursor ---------- */
#cursor { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; display: none; }
body.has-cursor #cursor { display: block; }
#cursor::before { content: ""; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--mango); transition: transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1); }
#cursor span { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); font: 800 13px var(--display); color: var(--charcoal); white-space: nowrap; opacity: 0; transition: opacity 0.2s; }
#cursor.big::before { transform: scale(5.4); }
#cursor.big span { opacity: 1; }

/* ---------- HUD ---------- */
.hud { position: fixed; top: 0; left: 0; right: 0; z-index: 50; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 18px var(--g); color: var(--fg); transition: color 0.5s; }
.logo { font-family: var(--display); font-weight: 900; font-size: 24px; letter-spacing: -0.04em; text-decoration: none; display: inline-flex; align-items: flex-start; gap: 2px; justify-self: start; }
.logo svg { width: 13px; height: 13px; color: var(--mango); margin-top: 3px; animation: spin 6s linear infinite; }
.hud-mid { text-align: center; }
.hud-mid .clock { color: var(--dim); }
#close-btn { display: none; font-size: 13px; padding: 6px 10px; }
#close-btn:hover { color: var(--blue); }
body.in-realm .hud-mid .clock { display: none; }
body.in-realm #close-btn { display: inline-block; }
.hud-nav { display: flex; gap: 22px; align-items: center; justify-self: end; }
.hud-nav a { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.talk i { width: 7px; height: 7px; border-radius: 50%; background: var(--mango); display: inline-block; animation: blink 1.4s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.hud-nav a:hover, #menu-btn:hover { color: var(--acc); }
#menu-btn b { font-weight: 400; }

.rail { position: fixed; right: var(--g); top: 50%; transform: translateY(-50%); z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; color: var(--fg); transition: opacity 0.4s, color 0.5s; }
#rail-label { writing-mode: vertical-rl; color: var(--dim); }
.rail-track { width: 2px; height: 110px; background: color-mix(in srgb, var(--fg) 20%, transparent); position: relative; overflow: hidden; border-radius: 2px; }
#rail-fill { position: absolute; inset: 0; background: var(--mango); transform-origin: top; transform: scaleY(0); }

/* ---------- menu ---------- */
#menu { position: fixed; inset: 0; z-index: 60; background: var(--mango); color: var(--charcoal); display: flex; flex-direction: column; justify-content: center; padding: 0 var(--g); animation: drop 0.5s cubic-bezier(0.7, 0, 0.2, 1); }
#menu[hidden] { display: none; }
@keyframes drop { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
#menu nav { display: flex; flex-direction: column; }
#menu nav a { font-family: var(--display); font-weight: 900; font-size: clamp(54px, 11vw, 150px); line-height: 0.92; letter-spacing: -0.05em; text-decoration: none; display: flex; align-items: baseline; gap: 18px; transition: transform 0.3s, color 0.2s; }
#menu nav a em { font-family: var(--serif); font-size: 0.32em; letter-spacing: 0; color: var(--cream); }
#menu nav a:hover { transform: translateX(14px); color: var(--cream); }
.menu-foot { display: flex; gap: 26px; margin-top: 40px; flex-wrap: wrap; }
.menu-foot a, .menu-foot button { text-decoration: none; font: inherit; }
.menu-foot a:hover, .menu-foot button:hover { color: var(--cream); }

/* ---------- sections ---------- */
.sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }

/* hero */
#home { height: 200vh; }
.hero-left { position: absolute; left: var(--g); top: 50%; transform: translateY(-50%); max-width: 46vw; }
.hero-left .display { font-size: clamp(44px, 5.4vw, 96px); margin: 14px 0 0; }
.s-under { width: min(420px, 34vw); height: 34px; margin: 4px 0 0 4px; }
.lead { font-size: clamp(22px, 2.2vw, 34px); line-height: 1.1; margin-top: 10px; }
.lead em { color: var(--mango); }
.hero-right { position: absolute; right: calc(var(--g) + 34px); top: 50%; transform: translateY(-50%); max-width: 280px; line-height: 1.75; }
.hero-foot { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); }
.bob { display: inline-block; animation: bob 1.4s ease-in-out infinite; color: var(--mango); }
@keyframes bob { 50% { transform: translateY(4px); } }
.sticker { position: absolute; width: 118px; height: 118px; }
.sticker svg { width: 100%; height: 100%; overflow: visible; }
.award { left: var(--g); bottom: 30px; transform: rotate(-8deg); transition: transform 0.3s; }
.award:hover { transform: rotate(0) scale(1.06); }
.award circle { fill: var(--blue); }
.award text { font: 500 9.6px var(--mono); letter-spacing: 0.12em; fill: var(--cream); }
.award .spin { transform-origin: 60px 60px; animation: spin 14s linear infinite; }
.award .play { fill: var(--mango); }

/* work */
#work { height: calc(100vh + 12 * 42vh); }
.work-panel { position: absolute; left: var(--g); top: clamp(86px, 13vh, 130px); width: min(340px, 28vw); }
.s-loop { position: absolute; left: 118px; top: -16px; width: 170px; height: 70px; }
.s-loop path { stroke: var(--blue); stroke-width: 5; }
.work-list { list-style: none; margin-top: 22px; }
.work-list li { display: flex; gap: 12px; padding: 3px 0; color: var(--dim); cursor: pointer; font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; transition: color 0.2s, padding 0.25s; }
.work-list li:hover { color: var(--fg); }
.work-list li.on { color: var(--fg); padding-left: 10px; }
.work-list li.on .n::before { content: "✱ "; color: var(--mango); }
.work-detail { position: absolute; left: var(--g); bottom: clamp(26px, 6vh, 60px); width: min(420px, 34vw); }
.work-detail h3 { font-size: clamp(34px, 3.6vw, 58px); margin: 6px 0 8px; text-transform: none; }
.work-detail .btn { margin-top: 16px; }
.hint { margin-top: 10px; font-size: 10.5px; }

/* about */
#about { height: 330vh; }
.about-panel { position: absolute; left: var(--g); bottom: clamp(30px, 9vh, 90px); width: min(560px, 44vw); display: grid; grid-template-columns: 16px 1fr; column-gap: 20px; }
.about-rail { grid-row: span 2; display: flex; flex-direction: column; align-items: center; font-size: 9px; color: var(--acc); }
.about-rail i { flex: 1; width: 0; border-left: 2px dashed currentColor; margin: 4px 0; }
.slides { position: relative; min-height: 290px; }
.slide { position: absolute; left: 0; bottom: 0; right: 0; opacity: 0; transform: translateY(18px); transition: opacity 0.5s, transform 0.5s; pointer-events: none; }
.slide.on { opacity: 1; transform: none; pointer-events: auto; }
.slide .h2 { margin-bottom: 16px; }
.body { font-size: 12.5px; line-height: 1.8; letter-spacing: 0.06em; }
.ticks { list-style: none; }
.ticks li::before { content: "✱ "; color: var(--acc); }
.about-foot { display: flex; gap: 24px; align-items: center; margin-top: 22px; }

/* clients */
#clients { height: 260vh; }
.clients-panel { position: absolute; left: var(--g); bottom: clamp(30px, 8vh, 80px); width: min(520px, 42vw); padding: 26px 28px; background: var(--cream); border: 2px solid var(--charcoal); border-radius: 22px; box-shadow: 8px 8px 0 var(--charcoal); }
.clients-panel .label { color: var(--mango); }
.clients-panel em { color: var(--blue); }
.client-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 18px; }
.client-list li { border: 1.5px solid var(--charcoal); border-radius: 99px; padding: 3px 10px; font-size: 10.5px; }
.client-list li:nth-child(4n+1) { background: var(--mango); }
.client-list li:nth-child(4n+3) { background: var(--sage); }

/* contact */
#contact { height: 170vh; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 var(--g); gap: 16px; }
.huge { font-size: clamp(50px, 8.6vw, 150px); max-width: 11ch; }
.huge em { color: var(--mango); }
.s-zig { width: min(360px, 60vw); height: 30px; margin-top: 2px; }
.s-zig path { stroke: var(--coral); stroke-width: 6; }
.btn.big { font-size: clamp(12px, 1.4vw, 16px); padding: 16px 28px; text-transform: lowercase; letter-spacing: 0.04em; background: var(--mango); border-color: var(--mango); color: var(--charcoal); }
.socials { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.socials a, .socials button { text-decoration: none; font: inherit; }
.socials a:hover, .socials button:hover { color: var(--mango); }
.foot { position: absolute; bottom: 22px; left: 0; right: 0; }
.stamp { position: absolute; right: clamp(20px, 9vw, 160px); top: 20%; width: clamp(96px, 11vw, 160px); aspect-ratio: 1; animation: wob 6s ease-in-out infinite; }
.stamp svg { width: 100%; height: 100%; }
.stamp .blob { fill: var(--coral); stroke: var(--cream); stroke-width: 5; }
.stamp text { font: 800 40px "Noto Sans Sinhala", var(--display); fill: var(--cream); }
.stamp i { position: absolute; width: 8px; height: 26px; border-radius: 8px; }
.stamp .b1 { left: -4%; top: 6%; background: var(--blue); transform: rotate(-40deg); }
.stamp .b2 { left: 12%; top: -8%; background: var(--mango); transform: rotate(-12deg); }
.stamp .b3 { right: -2%; top: 2%; background: var(--blue); transform: rotate(35deg); }
@keyframes wob { 50% { transform: rotate(8deg) scale(1.04); } }

/* ---------- realm HUD ---------- */
#realm-ui { position: fixed; inset: 0; z-index: 40; pointer-events: none; color: var(--charcoal); }
#realm-ui[hidden] { display: none; }
.realm-info { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1.1fr 1.6fr 0.9fr 1.3fr; gap: 28px; padding: 70px var(--g) 30px; background: linear-gradient(to top, rgba(246, 240, 232, 0.96) 55%, rgba(246, 240, 232, 0)); pointer-events: auto; animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.ri-col > .mono:first-child { margin-bottom: 8px; }
#r-title { font-size: clamp(28px, 2.8vw, 46px); text-transform: none; }
#r-meta { margin-top: 6px; color: var(--accent); }
#r-info { font-size: 11.5px; line-height: 1.75; letter-spacing: 0.06em; }
#r-role { list-style: none; }
#r-role li::before { content: "✱ "; color: var(--accent); }
.side { display: flex; flex-direction: column; gap: 12px; }
#r-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
#r-thumbs button { width: 44px; height: 32px; border-radius: 6px; overflow: hidden; border: 2px solid transparent; background: var(--charcoal); color: var(--mango); opacity: 0.55; transition: opacity 0.2s, border-color 0.2s, transform 0.2s; }
#r-thumbs button img { width: 100%; height: 100%; object-fit: cover; display: block; }
#r-thumbs button.on { opacity: 1; border-color: var(--accent); transform: translateY(-3px); }
#r-thumbs button:hover { opacity: 1; }
.r-ctrl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.r-ctrl > button:not(.btn) { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--charcoal); font-size: 14px; }
.r-ctrl > button:not(.btn):hover { background: var(--charcoal); color: var(--cream); }
#r-video { padding: 8px 14px; }
#r-video[hidden] { display: none; }
.realm-hint { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); font-size: 10px; }

/* ---------- story ---------- */
#story { position: fixed; inset: 0; z-index: 70; background: var(--cream); color: var(--charcoal); overflow-y: auto; animation: drop 0.6s cubic-bezier(0.7, 0, 0.2, 1); }
#story[hidden] { display: none; }
#story-close { position: fixed; top: 22px; right: var(--g); z-index: 2; background: var(--charcoal); color: var(--cream); padding: 8px 14px; border-radius: 99px; }
.story-in { max-width: 1100px; margin: 0 auto; padding: 100px var(--g) 80px; }
.huge-ish { font-size: clamp(54px, 8vw, 120px); margin: 10px 0 24px; }
.huge-ish em { color: var(--mango); }
.story-lead { font-size: clamp(18px, 1.7vw, 23px); max-width: 820px; line-height: 1.5; }
.story-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; margin-top: 54px; }
.story-grid .mono.dim { margin: 26px 0 12px; }
.story-grid .mono.dim:first-child { margin-top: 0; }
.log { list-style: none; }
.log li { display: grid; grid-template-columns: 130px 1fr; column-gap: 14px; padding: 12px 0; border-bottom: 2px dashed rgba(28, 27, 26, 0.18); }
.log span { font: 400 11.5px var(--mono); color: rgba(28, 27, 26, 0.56); grid-row: span 2; padding-top: 3px; }
.log b { font-family: var(--display); font-weight: 800; font-size: 17px; letter-spacing: -0.01em; line-height: 1.2; }
.log i { font-style: normal; font: 500 11px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--blue); }
.log li.now span { color: var(--mango); }
.edu { list-style: none; display: grid; gap: 12px; }
.edu li { display: flex; flex-direction: column; }
.edu b { font-family: var(--display); font-weight: 800; font-size: 16px; line-height: 1.25; }
.edu span { color: rgba(28, 27, 26, 0.6); font-size: 14px; }
.award-line { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.award-line svg { width: 18px; height: 18px; flex: none; color: var(--mango); }
.pills { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.pills li { border: 1.5px solid var(--charcoal); border-radius: 99px; padding: 5px 13px; font-size: 13.5px; }
.pills li:nth-child(5n+1) { background: var(--mango); }
.pills li:nth-child(5n+3) { background: var(--sage); }
.pills li:nth-child(5n+4) { background: var(--blue); color: var(--cream); border-color: var(--blue); }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 80; background: rgba(28, 27, 26, 0.92); display: flex; align-items: center; justify-content: center; padding: var(--g); }
#modal[hidden] { display: none; }
.modal-frame { width: min(1100px, 100%); aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; border: 3px solid var(--mango); background: #000; }
.modal-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
#modal-close { position: absolute; top: 20px; right: var(--g); color: var(--cream); }

body.no-gl { background: var(--cream); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hud-mid .clock { display: none; }
  .rail { display: none; }
  .hero-left { top: 15%; transform: none; max-width: none; right: var(--g); }
  .s-under { width: 70vw; }
  .hero-right { display: none; top: auto; bottom: 150px; transform: none; left: auto; right: var(--g); max-width: 60vw; text-align: right; font-size: 10.5px; }
  .award { width: 92px; height: 92px; bottom: 26px; }
  .hero-foot { left: auto; right: var(--g); transform: none; }
  .work-panel { width: auto; right: var(--g); top: 74px; }
  .s-loop, .work-list { display: none; }
  .work-detail { width: auto; left: 0; right: 0; bottom: 0; padding: 70px var(--g) 26px; background: linear-gradient(to top, var(--cream) 60%, rgba(246, 240, 232, 0)); }
  .hint { display: none; }
  .about-panel { width: auto; right: var(--g); bottom: 26px; }
  .slides { min-height: 270px; }
  .clients-panel { width: auto; right: var(--g); bottom: 18px; padding: 18px; }
  .clients-panel .body, .client-list { display: none; }
  .stamp { top: 12%; right: 6%; }
  .realm-info { grid-template-columns: 1fr; gap: 10px; padding: 50px var(--g) 18px; }
  .ri-col.wide { display: none; }
  .realm-hint, body.in-realm .talk { display: none; }
  .story-grid { grid-template-columns: 1fr; }
  .log li { grid-template-columns: 1fr; }
  .log span { grid-row: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ld-ast, .logo svg, .award .spin, .stamp, .bob, .talk i { animation: none; }
  body.glitching .display, body.glitching #wd-title { animation: none; }
}
