/* ==========================================================================
   bhaskar.com.np — app.css
   Dependency-free. Dark by default, light via prefers-color-scheme or the
   toggle ([data-theme]). Motion respects prefers-reduced-motion.
   ========================================================================== */

/* ---------- Self-hosted Space Grotesk (variable, 300–700) — no third-party origins ---------- */
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('../fonts/space-grotesk-3.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('../fonts/space-grotesk-2.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('../fonts/space-grotesk-1.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }

/* ---------- Tokens ---------- */
:root {
  --bg: #171a19;
  --bg-elev: #1f2322;
  --fg: #ededed;
  --fg-strong: #ffffff;
  --muted: #6f7573;
  --muted-2: #a3a8a6;
  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.07);
  --green: #419d78;
  --yellow: #e0a458;
  --red: #d9594c;
  --blue: #53a2be;
  --purple: #8f79c9;
  --gray: #9a9a9a;
  --accent: var(--yellow);
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --dur: 0.7s;
  --stagger: 55ms;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-col: 58%;           /* left column for text on wide screens */
  color-scheme: dark;
}

/* Light palette — by system preference (unless the user pinned dark) or by toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5f2; --bg-elev: #ffffff;
    --fg: #1d201f; --fg-strong: #0f1211;
    --muted: #7a7f7c; --muted-2: #565b58;
    --line: rgba(0, 0, 0, 0.14); --line-soft: rgba(0, 0, 0, 0.06);
    --green: #2f8763; --yellow: #b8792b; --red: #c8483b; --blue: #3b87a5; --purple: #6a55a8; --gray: #6a6a6a;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f5f2; --bg-elev: #ffffff;
  --fg: #1d201f; --fg-strong: #0f1211;
  --muted: #7a7f7c; --muted-2: #565b58;
  --line: rgba(0, 0, 0, 0.14); --line-soft: rgba(0, 0, 0, 0.06);
  --green: #2f8763; --yellow: #b8792b; --red: #c8483b; --blue: #3b87a5; --purple: #6a55a8; --gray: #6a6a6a;
  color-scheme: light;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.75;
  color: var(--fg);
  background-color: var(--bg);
  overflow: hidden;
  transition: background-color 0.5s var(--ease-io), color 0.5s var(--ease-io);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
p, dl, dd { margin: 0; }
svg { display: block; }
img { max-width: 100%; height: auto; }
strong { font-weight: 700; color: var(--fg-strong); }

:focus-visible { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -100px; left: 16px; z-index: 100;
  padding: 8px 14px; background: var(--bg-elev); color: var(--fg-strong);
  border: 1px solid var(--line); border-radius: 4px;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Layout ---------- */
.wrapper { position: relative; height: 100%; min-height: 500px; overflow: hidden; }
.wrapper.portrait-active { cursor: grab; }
.wrapper.portrait-active:active { cursor: grabbing; }

canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stars { z-index: 0; }
#portrait { z-index: 1; opacity: 0; transition: opacity 1.2s var(--ease-io), filter 0.5s var(--ease-io); }
.wrapper.portrait-active #portrait { opacity: 1; }
.wrapper.menu-open #portrait { opacity: 0; }
/* light ground: lift contrast so the photo reads clearly */
:root[data-theme="light"] #portrait { filter: contrast(1.12) saturate(1.06); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) #portrait { filter: contrast(1.12) saturate(1.06); } }
@media (max-width: 991px) { #portrait { display: none; } }

.container { position: relative; z-index: 2; width: 90%; max-width: 1000px; height: 100%; margin: 0 auto; }
#main { position: absolute; inset: 0; }

/* ---------- Top bar ---------- */
.topbar { position: absolute; top: 0; left: 0; right: 0; height: 98px; z-index: 5; }

#signature {
  position: absolute; top: 34px; left: 50%;
  transform: translateX(-50%);
  display: block;
  font-weight: 700; font-size: 22px; line-height: 28px; letter-spacing: 0.02em;
  color: var(--fg-strong);
  opacity: 1;
  clip-path: inset(0 0 0 0);
  transition: opacity 0.6s var(--ease), clip-path 1.1s var(--ease) 0.15s, transform 0.6s var(--ease), letter-spacing 0.6s var(--ease);
}
#signature span { position: relative; display: inline-block; }
#signature span::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 2px; height: 3px;
  background: var(--accent); opacity: 0.6;
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.9s var(--ease) 0.6s;
}
#signature:not(.loading) span::after { transform: scaleX(1); }
#signature.loading { opacity: 0; clip-path: inset(0 100% 0 0); }
#signature:hover { transform: translateX(-50%) scale(1.04); letter-spacing: 0.06em; }

.controls { position: absolute; top: 33px; right: 0; display: flex; align-items: center; gap: 18px; }
.icon-btn {
  width: 32px; height: 32px; padding: 5px; border-radius: 50%;
  color: var(--fg); opacity: 0.75;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.icon-btn:hover { opacity: 1; background-color: var(--line-soft); }
.icon-btn svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.loading, #burger.loading { opacity: 0; transform: translateY(-8px); pointer-events: none; }
@media (max-width: 599px) {
  #signature { left: 47%; font-size: 19px; }
  .controls { gap: 10px; }
  #identity .dot:nth-child(2) { left: 21px; }
  #identity .dot:nth-child(3) { left: 42px; }
  #identity .dot:nth-child(4) { left: 63px; }
  #identity .dot:nth-child(5) { left: 84px; }
}

/* Theme toggle: sun ↔ moon morph */
#theme-toggle .sun-core { fill: currentColor; stroke: none; transform-origin: center; transition: transform var(--dur) var(--ease), opacity 0.4s var(--ease); }
#theme-toggle .sun-rays { transform-origin: center; transition: transform var(--dur) var(--ease), opacity 0.4s var(--ease); }
#theme-toggle .moon { fill: currentColor; stroke: none; transform-origin: center; opacity: 0; transform: rotate(-60deg) scale(0.6); transition: transform var(--dur) var(--ease), opacity 0.4s var(--ease); }
:root[data-theme="light"] #theme-toggle .sun-core,
:root[data-theme="light"] #theme-toggle .sun-rays { opacity: 0; transform: scale(0.3) rotate(90deg); }
:root[data-theme="light"] #theme-toggle .moon { opacity: 1; transform: rotate(0) scale(1); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) #theme-toggle .sun-core,
  :root:not([data-theme="dark"]) #theme-toggle .sun-rays { opacity: 0; transform: scale(0.3) rotate(90deg); }
  :root:not([data-theme="dark"]) #theme-toggle .moon { opacity: 1; transform: rotate(0) scale(1); }
}

/* Audio toggle */
#audio-toggle .speaker { fill: currentColor; stroke: none; }
#audio-toggle .wave { opacity: 0.35; transition: opacity 0.4s var(--ease); }
#audio-toggle[aria-pressed="true"] .wave { opacity: 1; animation: wavePulse 1.4s var(--ease-io) infinite; }
#audio-toggle[aria-pressed="true"] .wave-2 { animation-delay: 0.2s; }
@keyframes wavePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Burger ↔ close */
#burger { position: relative; width: 28px; height: 28px; }
#burger span { position: absolute; left: 4px; right: 0; height: 2px; background: var(--fg-strong); border-radius: 2px; transition: all var(--dur) var(--ease); }
#burger span:nth-child(1) { top: 6px; left: 14px; }
#burger span:nth-child(2) { top: 13px; left: 4px; }
#burger span:nth-child(3) { top: 20px; left: 8px; }
.wrapper:not(.menu-open) #burger:hover span:nth-child(1) { left: 4px; }
.wrapper:not(.menu-open) #burger:hover span:nth-child(3) { left: 14px; }
.menu-open #burger span:nth-child(2) { left: 28px; opacity: 0; }
.menu-open #burger span:nth-child(1), .menu-open #burger span:nth-child(3) { top: 13px; left: 4px; }
.menu-open #burger span:nth-child(1) { transform: rotate(-45deg); }
.menu-open #burger span:nth-child(3) { transform: rotate(45deg); }

/* ---------- Identity (the five dots) ---------- */
#identity {
  position: fixed; top: 49px; left: max(5vw, calc(50vw - 500px));
  width: 0; height: 0; z-index: 6;
  transition: top 1.4s var(--ease), left 1.4s var(--ease);
}
#identity.loading { top: 50vh; left: 50vw; }
#identity .dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; transition: all var(--dur) var(--ease); }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }
.dot-blue { background: var(--blue); }
.dot-purple { background: var(--purple); }

/* rest: a neat row */
#identity .dot:nth-child(1) { top: 0; left: 0; }
#identity .dot:nth-child(2) { top: 0; left: 26px; }
#identity .dot:nth-child(3) { top: 0; left: 52px; }
#identity .dot:nth-child(4) { top: 0; left: 78px; }
#identity .dot:nth-child(5) { top: 0; left: 104px; }

/* working / loading: orbit as a cluster */
#identity.working .dot, #identity.loading .dot { animation: orbit 1.4s var(--ease-io) infinite; }
#identity.working .dot:nth-child(1), #identity.loading .dot:nth-child(1) { top: -12px; left: -12px; animation-delay: 0s; }
#identity.working .dot:nth-child(2), #identity.loading .dot:nth-child(2) { top: 12px; left: -12px; animation-delay: -0.28s; }
#identity.working .dot:nth-child(3), #identity.loading .dot:nth-child(3) { top: -12px; left: 12px; animation-delay: -0.56s; }
#identity.working .dot:nth-child(4), #identity.loading .dot:nth-child(4) { top: 12px; left: 12px; animation-delay: -0.84s; }
#identity.working .dot:nth-child(5), #identity.loading .dot:nth-child(5) { top: 0; left: 0; animation-delay: -1.12s; }
@keyframes orbit {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(24px, 0) scale(1.15); }
  50%  { transform: translate(24px, 24px) scale(1); }
  75%  { transform: translate(0, 24px) scale(0.85); }
  100% { transform: translate(0, 0) scale(1); }
}
#identity.robot .dot { animation: bob 1.4s var(--ease-io) infinite; }
#identity.robot .dot:nth-child(2) { animation-delay: 0.12s; }
#identity.robot .dot:nth-child(3) { animation-delay: 0.24s; }
#identity.robot .dot:nth-child(4) { animation-delay: 0.36s; }
#identity.robot .dot:nth-child(5) { animation-delay: 0.48s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

#identity .dot a { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; visibility: hidden; text-align: center; }
#identity .dot a span {
  font-weight: 700; font-size: 21px; line-height: 1.1; letter-spacing: -0.01em; color: #fff; padding: 0 12px;
  opacity: 0; transform: translateY(10px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

/* menu open: dots bloom into balls */
.menu-open #identity { top: 50vh; left: 50vw; }
.menu-open #identity .dot { animation: none; cursor: pointer; }
.menu-open #identity .dot:nth-child(1) { width: 168px; height: 168px; top: -178px; left: -252px; }
.menu-open #identity .dot:nth-child(2) { width: 105px; height: 105px; top: 12px; left: -196px; }
.menu-open #identity .dot:nth-child(3) { width: 126px; height: 126px; top: -199px; left: -63px; }
.menu-open #identity .dot:nth-child(4) { width: 210px; height: 210px; top: -52px; left: 0; }
.menu-open #identity .dot:nth-child(5) { width: 140px; height: 140px; top: 130px; left: -160px; }
.menu-open #identity .dot:hover { transform: scale(0.94); }
.menu-open #identity .dot a { visibility: visible; }
.menu-open #identity .dot a span { opacity: 1; transform: translateY(0); transition-delay: 0.4s; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
@media (max-width: 599px) {
  .menu-open #identity .dot:nth-child(1) { width: 120px; height: 120px; top: -190px; left: -140px; }
  .menu-open #identity .dot:nth-child(2) { width: 90px; height: 90px; top: -50px; left: -125px; }
  .menu-open #identity .dot:nth-child(3) { width: 100px; height: 100px; top: -180px; left: 0; }
  .menu-open #identity .dot:nth-child(4) { width: 150px; height: 150px; top: -70px; left: -10px; }
  .menu-open #identity .dot:nth-child(5) { width: 110px; height: 110px; top: 100px; left: -70px; }
  #identity .dot a span { font-size: 15px; }
}

/* ---------- Templates (pages) ---------- */
.template { position: absolute; inset: 0; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.template[hidden] { display: none; }
.menu-open .template { opacity: 0; transform: translateY(112px); pointer-events: none; }

.template main {
  position: absolute; top: 150px; left: 0; bottom: 84px;
  width: 100%;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  padding-right: 8px; padding-bottom: 64px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
          mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
}
.template main::-webkit-scrollbar { width: 6px; }
.template main::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.template footer { position: absolute; left: 0; bottom: 28px; }
/* wide screens: text lives in the left column, the portrait owns the right */
@media (min-width: 992px) {
  .template main, .template footer { width: var(--text-col); }
}
@media (max-width: 599px) { .template main { top: 110px; } }

/* Static portrait (small screens, where the canvas is off) */
.portrait-static {
  display: none;
  width: 92px; height: 92px; object-fit: cover; border-radius: 50%;
  background: var(--bg-elev); border: 2px solid var(--line);
  margin-bottom: 18px;
}
@media (max-width: 991px) { .portrait-static { display: block; } }

/* Section titles */
h1, .h1 {
  margin: 0 0 24px;
  font-family: var(--font);
  font-size: 46px; font-weight: 700; line-height: 1.12; letter-spacing: -0.02em;
  color: var(--fg-strong);
}
h1 > span, .h1 > span { display: block; }
h1 .eyebrow {
  font-size: 12px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
h3 {
  margin: 26px 0 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent);
}
@media (max-width: 599px) {
  h1, .h1 { font-size: 30px; margin-bottom: 18px; }
  h1 .eyebrow { font-size: 11px; margin-bottom: 10px; }
}
.lede { font-size: 17px; font-weight: 500; line-height: 1.6; color: var(--fg-strong); }
.small { font-size: 12.5px; line-height: 1.7; color: var(--muted-2); }
.small.alt { font-size: 11.5px; }
.template main > p, .template main > ol, .template main > ul, .template main > dl, .template main > .form { margin-bottom: 18px; }
.contact span { display: block; color: var(--muted-2); }
.contact .link.small { display: inline-block; margin-top: 2px; }

/* mark: the coloured highlight behind key words */
mark { position: relative; display: inline-block; padding: 0; color: inherit; background: transparent; }
mark::before {
  content: ''; position: absolute; z-index: -1; left: -2px; right: -2px; top: 52%; bottom: 3px;
  background: var(--accent); opacity: 0.55;
  transform: scaleX(0); transform-origin: left center;
  transition: transform 0.9s var(--ease) 0.5s;
}
.template.current mark::before { transform: scaleX(1); }

/* Links */
a.link:not(.small) { position: relative; display: inline-block; font-weight: 700; color: var(--fg-strong); }
a.link:not(.small)::before {
  content: ''; position: absolute; z-index: -1; left: 0; bottom: 0; width: 21px; height: 2px;
  background: var(--accent);
  transition: width var(--dur) var(--ease);
}
a.link:not(.small):hover::before { width: 100%; }
a.link.small { position: relative; display: inline-block; color: var(--muted-2); transition: color var(--dur) var(--ease); }
a.link.small::before { content: ''; position: absolute; z-index: -1; left: 0; right: 0; bottom: 2px; height: 7px; background: var(--line-soft); transition: all var(--dur) var(--ease); }
a.link.small:hover { color: var(--fg-strong); }
a.link.small:hover::before { bottom: -3px; height: 2px; background: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 6px 32px; }
.template footer .links { gap: 4px 20px; }
@media (max-width: 599px) {
  .template main .links { flex-direction: column; gap: 12px; }
  .template footer .links { flex-direction: row; }
}

/* Accent overrides */
.color-green, a.link.color-green { --accent: var(--green); }
.color-yellow, a.link.color-yellow { --accent: var(--yellow); }
.color-red, a.link.color-red { --accent: var(--red); }
.color-blue, a.link.color-blue { --accent: var(--blue); }
.color-purple, a.link.color-purple { --accent: var(--purple); }
.color-grayscale { --accent: var(--gray); }

/* Lists */
.list.blocks > li { position: relative; display: block; line-height: 1.6; }
.list.blocks > li > span, .list.blocks > li > a > span { display: inline-block; vertical-align: top; }
.list.blocks > li > span:first-child, .list.blocks > li > a > span:first-child { width: 150px; color: var(--muted); padding: 6px 0; font-size: 13px; }
.list.blocks > li > span:not(:first-child), .list.blocks > li > a > span:not(:first-child) { width: calc(100% - 150px); padding: 6px 0; }
.list.blocks > li.next > span { color: var(--accent); }
.list.blocks > li.progress > span, .list.blocks > li.archived > span { color: var(--muted); }
.list.blocks > li.archived em { font-style: normal; color: var(--muted); }
.list.blocks > li.entry { border-top: 1px solid var(--line-soft); }
.list.blocks > li.entry:first-child { border-top: 0; }
.list.blocks > li a { display: block; transition: color var(--dur) var(--ease); }
.list.blocks > li svg {
  position: absolute; top: 8px; left: 118px; width: 22px; height: 22px; fill: var(--muted);
  transition: fill var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.list.blocks:hover > li > a > span { color: var(--muted); }
.list.blocks > li > a:hover > span { color: var(--fg-strong) !important; }
.list.blocks > li > a:hover svg { fill: var(--accent); transform: rotate(-20deg); }
@media (max-width: 669px) {
  .list.blocks > li > span, .list.blocks > li > a > span { display: block; width: auto; }
  .list.blocks > li > span:first-child, .list.blocks > li > a > span:first-child { padding: 8px 0 0; }
  .list.blocks > li > span:not(:first-child), .list.blocks > li > a > span:not(:first-child) { width: auto; padding: 0 0 8px; }
  .list.blocks > li.listItem { padding-left: 32px; }
  .list.blocks > li.listItem svg { left: 0; top: 10px; }
}

/* Arrow lists (secret intro) */
.list.arrows > li { position: relative; padding: 4px 0 4px 26px; }
.list.arrows > li::before { content: '➵'; position: absolute; left: 0; top: 4px; color: var(--accent); }

/* FAQ */
.faq dt { font-weight: 700; color: var(--fg-strong); margin-top: 10px; }
.faq dd { color: var(--fg); margin-bottom: 6px; }

/* Form */
.field { position: relative; max-width: 360px; border-bottom: 2px solid transparent; }
.field textarea, .field input {
  display: block; width: 100%; padding: 6px 0; margin: 0;
  background: transparent; border: 0; outline: 0; resize: none;
  font: inherit; color: var(--fg-strong); caret-color: var(--accent);
}
.field textarea::placeholder, .field input::placeholder { color: var(--muted); }
.form-contact .field { margin-bottom: 14px; }
.form-contact .field input { height: 40px; }
.field .effect { position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--line); }
.field .effect i { position: absolute; top: 0; bottom: 0; left: 0; right: 100%; transition: right var(--dur) var(--ease); }
.field .effect i:nth-child(1) { background: var(--blue); }
.field .effect i:nth-child(2) { background: var(--red); }
.field .effect i:nth-child(3) { background: var(--yellow); }
.field .effect i:nth-child(4) { background: var(--green); }
.field.filled .effect i:nth-child(1), .field textarea:focus ~ .effect i:nth-child(1), .field input:focus ~ .effect i:nth-child(1) { right: 0; }
.field.filled .effect i:nth-child(2), .field textarea:focus ~ .effect i:nth-child(2), .field input:focus ~ .effect i:nth-child(2) { right: 25%; }
.field.filled .effect i:nth-child(3), .field textarea:focus ~ .effect i:nth-child(3), .field input:focus ~ .effect i:nth-child(3) { right: 50%; }
.field.filled .effect i:nth-child(4), .field textarea:focus ~ .effect i:nth-child(4), .field input:focus ~ .effect i:nth-child(4) { right: 75%; }
.field.filled.validated .effect i:nth-child(2) { right: 5%; }
.field.filled.validated .effect i:nth-child(3) { right: 10%; }
.field.filled.validated .effect i:nth-child(4) { right: 15%; }
.form-actions { align-items: baseline; margin-top: 6px; }
.form .copy { opacity: 0.85; }
.form .submit { margin-top: 21px; opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.form.validated .submit { opacity: 1; transform: none; pointer-events: auto; }
.form .small { position: relative; margin-top: 14px; min-height: 44px; }
.form .status { position: absolute; top: 0; left: 0; opacity: 0; transform: translateY(8px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); pointer-events: none; }
.form .status.current { opacity: 1; transform: none; }
.form .status span { display: block; }
.form.done .field, .form.done .submit { display: none; }
.form.done .form-actions { margin-top: 0; }

/* ---------- Page reveal / leave ---------- */
.template.current main > *, .template.current footer > * {
  animation: rise var(--dur) var(--ease) both;
  animation-delay: calc(var(--i, 0) * var(--stagger) + 120ms);
}
.template.current .list.blocks > li { animation: riseSoft 0.6s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms + 300ms); }
.template.leaving main > *, .template.leaving footer > * { animation: sink 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); }
@keyframes rise { from { opacity: 0; transform: translateY(46px) rotate(2.5deg); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes riseSoft { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes sink { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-46px) rotate(-2.5deg); filter: blur(2px); } }

/* ---------- Motion extras ---------- */
/* pointer spotlight: a soft accent glow that follows the cursor */
#spotlight {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%);
  opacity: 0; transition: opacity 1.2s var(--ease-io);
}
.wrapper.has-pointer #spotlight { opacity: 1; }
.menu-open #spotlight { opacity: 0.6; }

/* route progress: thin accent line across the top while a page changes */
#route-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 50; pointer-events: none;
  background: var(--accent); transform: scaleX(0); transform-origin: left; opacity: 0;
}
.wrapper.routing #route-progress { animation: routeProgress 1.1s var(--ease-io) both; }
@keyframes routeProgress {
  0% { opacity: 1; transform: scaleX(0); transform-origin: left; }
  55% { opacity: 1; transform: scaleX(1); transform-origin: left; }
  56% { transform-origin: right; }
  100% { opacity: 0; transform: scaleX(0); transform-origin: right; }
}

/* magnetic hover targets ease back when the pointer leaves */
.icon-btn, #burger, .menu-open #identity .dot { transition-property: translate, opacity, transform, background-color, width, height, top, left; }
.magnet { will-change: translate; }

/* open menu: balls drift gently */
.menu-open #identity .dot { animation: floatBall 7s ease-in-out infinite; }
.menu-open #identity .dot:nth-child(2) { animation-delay: -1.5s; }
.menu-open #identity .dot:nth-child(3) { animation-delay: -3s; }
.menu-open #identity .dot:nth-child(4) { animation-delay: -4.5s; }
.menu-open #identity .dot:nth-child(5) { animation-delay: -6s; }
@keyframes floatBall { 0%, 100% { margin-top: -5px; } 50% { margin-top: -13px; } }

/* scroll reveal for long pages: items below the fold wait for the viewport */
.template.current main > .wait { animation: none; opacity: 0; transform: translateY(26px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.template.current main > .wait.in { opacity: 1; transform: none; }

/* theme switch: circular wipe (View Transitions API; ignored elsewhere) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: themeWipe 0.7s var(--ease-io); }
@keyframes themeWipe {
  from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 50%)); }
  to { clip-path: circle(160vmax at var(--vt-x, 50%) var(--vt-y, 50%)); }
}

/* ---------- Print: the about page prints as a clean résumé ---------- */
@media print {
  body { overflow: visible; background: #fff; color: #111; font-size: 11pt; }
  canvas, #spotlight, #route-progress, .topbar, .skip-link, audio, .template footer, .portrait-static { display: none !important; }
  .wrapper, .container, #main, .template { position: static; height: auto; width: auto; max-width: none; }
  .template { display: none; }
  .template[data-template="about"] { display: block !important; }
  .template main { position: static; width: 100%; overflow: visible; padding: 0; -webkit-mask-image: none; mask-image: none; }
  .template main > *, .template main > .wait { animation: none !important; opacity: 1 !important; transform: none !important; }
  h1, .h1 { font-size: 22pt; color: #111; }
  h3 { color: #333; }
  mark::before { display: none; }
  a { color: #111; }
  a.link::before { display: none; }
  .list.blocks > li.entry { break-inside: avoid; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  #stars, #portrait, #spotlight { display: none; }
  .portrait-static { display: block; }
  .template.current main > .wait { opacity: 1; transform: none; }
  ::view-transition-new(root) { animation: none; }
}
