/* ============================================================
   Reset, base typography, layout primitives, shared components.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: auto; /* Lenis handles it */
}

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-weight: 400;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

/* ---- Focus visible — keyboard-only ring, never on mouse clicks ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 4px;
  border-radius: 4px;
}
.btn:focus-visible,
.hero__cta:focus-visible,
.contact__cta:focus-visible,
.theme-toggle:focus-visible,
.nav__hamburger:focus-visible,
.word-pill:focus-visible {
  outline-offset: 6px;
}
.project-tile:focus-visible {
  outline-offset: -4px;     /* sit inside the rounded card */
  border-radius: var(--radius-lg);
}

img, video { display: block; max-width: 100%; height: auto; }
/* SVG defaults to inline so it composes naturally inside flowing text;
   add `.block` if you want a block-level SVG. */
svg { display: inline-block; vertical-align: middle; max-width: 100%; }
svg.block { display: block; }

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

input, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6, p { margin: 0; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}

/* ---- Layout primitives ---- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--pad-x);
}

.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ---- Section spacing ---- */
.section { padding-block: var(--space-9); }
.section--lg { padding-block: var(--space-10); }
.section--sm { padding-block: var(--space-7); }

/* ---- Section label (small uppercase) ---- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
/* Decorative dot removed — was the only "system blue" in the design and added no signal. */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background-color var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              transform var(--dur) var(--ease-out);
}
.btn:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn .arrow { transition: transform var(--dur) var(--ease-out); }
.btn:hover .arrow { transform: translateX(4px); }

/* ---- Inline link ---- */
.ilink {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.ilink::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transition: right var(--dur) var(--ease-out);
}
.ilink:hover::after { right: 0; }

/* ---- Nav — blur lives on a ::before pseudo so the .nav element itself
   doesn't establish a containing block (which would trap the mobile drawer's
   `position: fixed; inset: 0` inside the tiny header strip). ---- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding: var(--space-4) var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.nav.is-scrolled { border-color: var(--line); }
.nav__brand {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
}
.nav__brand .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-2);
  transform: translateY(-2px);
}
.nav__links {
  display: flex;
  gap: var(--space-6);
  align-items: center;
  font-size: var(--fs-sm);
}
.nav__links a {
  position: relative;
  padding-block: 4px;
  color: var(--fg-soft);
  transition: color var(--dur) var(--ease-out);
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: 0;
  height: 1px;
  background: currentColor;
  transition: right var(--dur) var(--ease-out);
}
.nav__links a:hover { color: var(--fg); }
.nav__links a:hover::after { right: 0; }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover { transform: rotate(20deg); border-color: var(--fg); }
.theme-toggle .icon { width: 18px; height: 18px; color: var(--fg); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ---- Hamburger button (mobile only) ---- */
.nav__hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  position: relative;
  z-index: 60;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.nav__hamburger:hover { border-color: var(--fg); }
.nav__hamburger span {
  width: 16px;
  height: 1.5px;
  background: var(--fg);
  border-radius: 1px;
  transform-origin: center;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.nav__hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(3.25px) rotate(45deg); }
.nav__hamburger[aria-expanded="true"] span:nth-child(2) { transform: translateY(-3.25px) rotate(-45deg); }

@media (max-width: 720px) {
  .nav__hamburger { display: inline-flex; }
  .nav__links {
    position: fixed;
    inset: 0;
    z-index: 55;
    flex-direction: column;
    /* Frosted-glass drawer: tinted bg + heavy backdrop blur so the page
       beneath is obscured even on browsers/themes where the solid colour
       didn't appear to render. */
    background-color: color-mix(in srgb, var(--bg) 86%, transparent);
    -webkit-backdrop-filter: blur(28px) saturate(170%);
    backdrop-filter: blur(28px) saturate(170%);
    padding: 6rem var(--pad-x) var(--space-7);
    gap: var(--space-5);
    align-items: flex-start;
    font-size: clamp(2rem, 8vw, 3rem);
    font-family: var(--font-display);
    letter-spacing: -0.02em;
    /* Hide via transform + visibility only — NO opacity (opacity was making
       the drawer translucent so the bg "disappeared" during transition). */
    transform: translateY(-100%);
    visibility: hidden;
    transition: transform 0.5s var(--ease-out), visibility 0.5s;
    pointer-events: none;
  }
  .nav__links.is-open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }
  .nav__links a {
    color: var(--fg);
    padding-block: 6px;
    width: 100%;
    border-bottom: 1px solid var(--line);
  }
  .nav__links a::after { display: none; }
  .nav__links .theme-toggle {
    align-self: flex-start;
    margin-top: var(--space-4);
  }
}

/* ---- Footer ---- */
.footer {
  border-top: 1px solid var(--line);
  padding: var(--space-7) var(--pad-x) var(--space-5);
  margin-top: var(--space-9);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  justify-content: space-between;
  align-items: end;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.footer__brand {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--fg);
  line-height: 1;
}
.footer__col { display: flex; flex-direction: column; gap: var(--space-2); }
.footer__col--end { align-items: flex-end; text-align: right; }
.footer__col strong { color: var(--fg); font-weight: 500; }
.footer__row { display: flex; gap: var(--space-5); }
.footer__brand .stop { color: var(--accent-2); }
.footer__top {
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.footer__top svg { transition: transform var(--dur) var(--ease-out); }
.footer__top:hover svg { transform: translateY(-3px); }

/* ---- Reveal animations: hidden only when JS is loaded so non-JS fallback shows content. ---- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
}
[data-reveal-chars] > span {
  display: inline-block;
  overflow: hidden;
}
.js [data-reveal-chars] > span > span {
  display: inline-block;
  transform: translateY(110%);
}

/* ============================================================
   Intro loader — scramble-resolve. Each character cycles random
   glyphs and locks left-to-right onto "spandan", the orange dot
   pops in last, then the whole panel splits diagonally and clears.
   JS (theme.js) drives the glyph cycling, sets `.is-resolved` on
   each slot as it locks, and triggers `.is-out` for the wipe.
   ============================================================ */
.loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  display: grid;
  place-items: center;
  /* Two halves wipe in opposite directions for exit. */
  background: transparent;
}
.loader::before,
.loader::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  transition: transform 0.7s cubic-bezier(0.76, 0, 0.24, 1);
  z-index: 0;
}
.loader::before { clip-path: polygon(0 0, 100% 0, 0 100%); }
.loader::after  { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.loader.is-out::before { transform: translate(-100%, -100%); }
.loader.is-out::after  { transform: translate(100%, 100%); }

.loader__inner {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.6rem, 11vw, 8rem);
  letter-spacing: -0.025em;
  color: var(--fg);
  display: inline-flex;
  align-items: baseline;
  line-height: 1;
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}
.loader.is-out .loader__inner {
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
}
.loader__char {
  display: inline-block;
  width: 0.66em;
  text-align: center;
  color: var(--muted);
  position: relative;
  transition: color 0.25s var(--ease-out), transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateY(0);
}
.loader__char.is-resolved {
  color: var(--fg);
}
.loader__char.is-resolved::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.12em;
  height: 2px;
  background: var(--accent-2);
  transform: scaleX(0);
  transform-origin: left;
  animation: loader-underline 0.5s cubic-bezier(0.76, 0, 0.24, 1) forwards;
}
@keyframes loader-underline {
  0%   { transform: scaleX(0); transform-origin: left; }
  60%  { transform: scaleX(1); transform-origin: left; }
  61%  { transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}
.loader__char--dot {
  width: 0.32em;
  color: var(--accent-2);
  opacity: 0;
  transform: translateY(0.4em) scale(0.3);
  transition: opacity 0.2s var(--ease-out),
              transform 0.55s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.loader__char--dot.is-resolved {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.loader__char--dot.is-resolved::after { display: none; }

@media (prefers-reduced-motion: reduce) {
  .loader::before, .loader::after, .loader__inner { transition: none; }
  .loader::before { transform: translate(-100%, -100%); }
  .loader::after { transform: translate(100%, 100%); }
  .loader__char { transition: none; }
  .loader__char.is-resolved::after { animation: none; }
}

/* ---- Custom cursor (desktop only) — two layers:
     • .cursor      = sharp white dot that SMEARS in the direction of motion
                      (scales X / squishes Y based on velocity), uses
                      mix-blend-mode: difference for contrast on any bg.
     • .cursor-halo = large blurred peach/orange aura that LAGS behind with
                      stronger inertia. Shifts to neon-green when hovering an
                      interactive element. ---- */
.cursor {
  position: fixed;
  top: 0; left: 0;
  width: 12px; height: 12px;
  border-radius: 999px;       /* round at rest, pill when smeared */
  background: var(--fg);
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: difference;
  will-change: transform, width;
  transition: width 0.25s var(--ease-out), height 0.25s var(--ease-out);
}
.cursor.is-hover { width: 28px; height: 28px; }

.cursor-halo {
  position: fixed;
  top: 0; left: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--accent-2) 70%, transparent) 0%,
    color-mix(in srgb, var(--accent-2) 0%, transparent) 70%);
  pointer-events: none;
  z-index: 9998;
  opacity: 0.55;
  filter: blur(6px);
  will-change: transform, opacity;
  transition: opacity 0.35s var(--ease-out), background 0.35s var(--ease-out);
  mix-blend-mode: screen;
}
[data-theme="light"] .cursor-halo { mix-blend-mode: multiply; opacity: 0.45; }
.cursor-halo.is-hover {
  opacity: 0.85;
  background: radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--neon) 80%, transparent) 0%,
    color-mix(in srgb, var(--neon) 0%, transparent) 70%);
}

@media (pointer: coarse) {
  .cursor, .cursor-halo { display: none; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  [data-reveal-chars] > span > span { transform: none; }
}
