/* Light / dark switch (top right on every page) and the glitch between modes */
.theme-btn { position: fixed; top: max(16px, env(safe-area-inset-top, 0px)); right: max(18px, env(safe-area-inset-right, 0px)); z-index: 60;
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 6px 0 16px; border-radius: 99px; border: 0; cursor: pointer;
  font: 600 17px/1 'Darker Grotesque', system-ui, sans-serif; letter-spacing: .2px; white-space: nowrap; transition: filter .2s ease; }
.theme-btn:hover { filter: brightness(1.08); }
.theme-btn:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }
.tb-label { margin-top: -2px; }
/* the switch: a track with a round knob that carries the sun (off, light) or the moon (on, dark) */
.tb-track { position: relative; flex: none; width: 54px; height: 30px; border-radius: 99px; transition: background-color .25s ease; }
.tb-knob { position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  transition: transform .25s cubic-bezier(.3,1.4,.5,1), background-color .25s ease; box-shadow: 0 2px 5px rgba(0,0,0,.25); }
.theme-btn.on .tb-knob { transform: translateX(24px); }
.tb-knob svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
/* solid, high contrast (Niha: the old one was barely visible) */
html[data-ng="light"] .theme-btn { background: #06292e; color: #fdf3ec; box-shadow: 0 6px 18px rgba(6,41,46,.22); }
html[data-ng="light"] .tb-track { background: rgba(253,243,236,.22); }
html[data-ng="light"] .tb-knob { background: #fdf3ec; color: #c4603f; }
html[data-ng="light"] .theme-btn.on .tb-track { background: #e5ff00; }
html[data-ng="dark"] .theme-btn { background: #e5ff00; color: #06292e; box-shadow: 0 0 0 1px rgba(229,255,0,.4), 0 0 22px rgba(229,255,0,.35); }
html[data-ng="dark"] .tb-track { background: #06292e; }
html[data-ng="dark"] .tb-knob { background: #e5ff00; color: #06292e; }
html[data-ng="dark"] .theme-btn:not(.on) .tb-track { background: rgba(6,41,46,.35); }
html.m .tb-label { display: none; }   /* phones: just the switch, so it never sits on the headlines */
html.m .theme-btn { height: 36px; padding: 0 4px; font-size: 15px; top: max(12px, env(safe-area-inset-top, 0px)); right: 12px; }
html.m .tb-track { width: 46px; height: 28px; }
html.m .tb-knob { width: 22px; height: 22px; }
html.m .theme-btn.on .tb-knob { transform: translateX(18px); }
/* homepage on desktop: the switch sits in the bottom bar, right of the section tabs, and site.js centres the pair */
.theme-btn.in-bar { top: 0; left: 0; right: auto; height: 46px; padding: 0 8px 0 20px; gap: 12px; font: 600 25px/1 'Darker Grotesque', system-ui, sans-serif;
  letter-spacing: -0.25px; transform-origin: 0 0; z-index: 10; }
.theme-btn.in-bar .tb-label { margin-top: -5px; }
.theme-btn.in-bar .tb-track { width: 60px; height: 32px; }
.theme-btn.in-bar .tb-knob { width: 26px; height: 26px; }
.theme-btn.in-bar.on .tb-knob { transform: translateX(28px); }
.theme-btn.in-bar .tb-knob svg { width: 16px; height: 16px; }

/* switching modes: the game glitch (Niha: "bring back the game glitch"): the page tears into jittering slices with a
   colour split, lime / sky / pink bars flicker across with a little static, then the new mode tears back in */
html.glitch-out body { animation: g-tear .46s steps(1, end) both; }
html.glitch-in body { animation: g-tear .5s steps(1, end) reverse both; }
html.glitch-out::after, html.glitch-in::after { content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none; mix-blend-mode: hard-light;
  background:
    linear-gradient(transparent 0 11%, rgba(229,255,0,.85) 11% 14%, transparent 14% 37%, rgba(84,211,215,.8) 37% 41%, transparent 41% 63%, rgba(252,146,209,.8) 63% 66%, transparent 66% 82%, rgba(229,255,0,.7) 82% 83.5%, transparent 83.5%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 180px 180px;
  animation: g-bars .46s steps(1, end) both; }
html.glitch-in::after { animation: g-bars .5s steps(1, end) reverse both; }
@keyframes g-tear {
  0%   { transform: none; filter: none; clip-path: none; }
  10%  { transform: translateX(-14px); filter: drop-shadow(6px 0 0 rgba(252,146,209,.8)) drop-shadow(-6px 0 0 rgba(84,211,215,.8)); clip-path: inset(8% 0 62% 0); }
  20%  { transform: translateX(18px); filter: drop-shadow(-9px 0 0 rgba(229,255,0,.75)) drop-shadow(9px 0 0 rgba(84,211,215,.7)); clip-path: inset(40% 0 22% 0); }
  30%  { transform: translateX(-6px) skewX(-4deg); filter: hue-rotate(70deg) drop-shadow(10px 0 0 rgba(252,146,209,.8)); clip-path: inset(0 0 48% 0); }
  42%  { transform: translateX(24px); filter: drop-shadow(-12px 0 0 rgba(84,211,215,.85)) saturate(2); clip-path: inset(58% 0 6% 0); }
  54%  { transform: translateX(-20px) skewX(3deg); filter: hue-rotate(-60deg) drop-shadow(8px 0 0 rgba(229,255,0,.8)); clip-path: inset(18% 0 30% 0); }
  66%  { transform: translateX(10px); filter: invert(.85) hue-rotate(180deg); clip-path: inset(30% 0 52% 0); }
  78%  { transform: translateX(-28px); filter: drop-shadow(14px 0 0 rgba(252,146,209,.9)) brightness(1.3); clip-path: inset(70% 0 0 0); }
  90%  { transform: translateX(6px); filter: brightness(1.6) contrast(1.4); clip-path: inset(46% 0 46% 0); }
  100% { transform: none; filter: brightness(2); clip-path: inset(50% 0 50% 0); }
}
@keyframes g-bars {
  0%   { opacity: 0; transform: none; }
  10%  { opacity: .9; transform: translateY(-6%); }
  22%  { opacity: .4; transform: translateY(18%) scaleY(.6); }
  34%  { opacity: 1; transform: translateY(-22%); }
  46%  { opacity: .55; transform: translateY(9%) scaleY(1.4); }
  58%  { opacity: .95; transform: translateY(31%); }
  70%  { opacity: .6; transform: translateY(-12%) scaleY(.5); }
  82%  { opacity: 1; transform: translateY(4%); }
  100% { opacity: 1; transform: translateY(-30%) scaleY(2); }
}
@media (prefers-reduced-motion: reduce) { html.glitch-out::after, html.glitch-in::after, html.glitch-out body, html.glitch-in body { animation: none; } }

/* nothing fixed shows before the page has laid itself out (the tab row and hints used to flash in the corner) */
.ctabs, .more, .theme-btn { transition: opacity .35s ease; }
html:not(.ready) .ctabs, html:not(.ready) .more, html:not(.ready) .theme-btn { opacity: 0 !important; }

/* About photo: on hover the card straightens, lifts and tilts toward the cursor, with a soft glare (both modes) */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .me-photo .me-frame { transform: perspective(1000px) rotate(var(--r, -3deg)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--ty, 0px)) scale(var(--s, 1));
    transition: transform .6s cubic-bezier(.2,.8,.2,1), box-shadow .6s ease; will-change: transform; }
  .me-photo .me-frame img { transition: transform .8s cubic-bezier(.2,.8,.2,1); }
  .me-photo .me-frame::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .5s ease;
    background: radial-gradient(circle at var(--gx, 50%) var(--gy, 30%), rgba(255,255,255,.38), rgba(255,255,255,0) 55%); mix-blend-mode: soft-light; }
  .me-photo figcaption { transition: transform .6s cubic-bezier(.2,.8,.2,1); }
  .me-photo.hov .me-frame { --r: 0deg; --ty: -10px; --s: 1.035; transition: transform .25s ease-out, box-shadow .6s ease; }
  .me-photo.hov .me-frame img { transform: scale(1.06) translate(calc(var(--ry, 0deg) / 1deg * -0.6px), calc(var(--rx, 0deg) / 1deg * 0.6px)); }
  .me-photo.hov .me-frame::after { opacity: 1; }
  .me-photo.hov figcaption { transform: rotate(-1deg) translateY(4px); }
}

/* About me: "what i'm into" (from Niha's resume, cut down), a 3 x 2 grid under the story */
.into { margin-top: 44px; }
.into-k { margin: 0 0 22px; font: 400 34px/1 var(--serif, 'Fraunces', serif); font-variation-settings: "SOFT" 0, "WONK" 1; letter-spacing: -0.6px; }   /* lowercase serif, like the other headings */
.into ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px 40px; }
.into li { display: flex; flex-direction: column; gap: 8px; }
.into b { font: 400 25px/1.1 var(--serif, 'Fraunces', serif); font-variation-settings: "SOFT" 0, "WONK" 1; letter-spacing: -0.4px; }
.into span { font: 500 21px/23px var(--body, 'Darker Grotesque', sans-serif); text-wrap: pretty; }
html[data-ng="light"] .into-k { color: #7fb0e8; }
html[data-ng="light"] .into b { color: #0b7d70; }
html[data-ng="light"] .into span { color: #8a8f4a; }
html[data-ng="dark"] .into-k { color: #7fb0e8; }
html[data-ng="dark"] .into b { color: #fff; }
html[data-ng="dark"] .into span { color: #92c4cc; }
/* phones (393 wide frame units): tighter so the list clears the bottom menu */
.m-into { margin-top: 12px; }
.m-into .into-k { font-size: 17px; margin-bottom: 7px; }
.m-into ul { grid-template-columns: repeat(2, 1fr); gap: 8px 16px; }
.m-into li { gap: 1px; }
.m-into b { font-size: 13.5px; }
.m-into span { font-size: 11.5px; line-height: 12.5px; }

/* V6: after the opening glitch on a fresh visit, the switch pops in and pings twice so people notice it */
html.booting .theme-btn { opacity: 0 !important; }
html.tb-intro .theme-btn { animation: tb-pop .6s cubic-bezier(.3,1.6,.5,1) both, tb-ping 1s ease-out .6s 2; }
@keyframes tb-pop { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }
@keyframes tb-ping { 0% { outline: 0 solid rgba(229,255,0,.75); outline-offset: 0; } 100% { outline: 14px solid rgba(229,255,0,0); outline-offset: 4px; } }
html[data-ng="light"].tb-intro .theme-btn { animation-name: tb-pop, tb-ping-l; }
@keyframes tb-ping-l { 0% { outline: 0 solid rgba(6,41,46,.5); outline-offset: 0; } 100% { outline: 14px solid rgba(6,41,46,0); outline-offset: 4px; } }

/* V6: case pages switch modes with a soft fade (no glitch) */
html.mode-out body { opacity: 0 !important; transition: opacity .38s ease !important; }
html.mode-in body { opacity: 0 !important; }
html.mode-in.mode-in-go body { opacity: 1 !important; transition: opacity .55s ease !important; }
