@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/martian-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
}

:root {
  --spruce: #102326;
  --bone: #e8e2d4;
  --stone: #b9c2b9;
  --lichen: #7f978f;
  --rule: #1f3a3b;
  --amber: #f0b44c;
  /* Fast start, long soft settle: a CSS stand-in for a critically damped spring. */
  --settle: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--spruce);
  color: var(--stone);
  font-family: "Martian Mono", ui-monospace, monospace;
  font-size: 15px;
  font-stretch: 87.5%;
  font-weight: 350;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 4rem 1.5rem;
}

/* Spotlight: one large soft amber pool. Static at the optical centre by
   default; script.js moves it with the pointer via --mx/--my (transform only). */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 70rem;
  height: 70rem;
  margin: -35rem 0 0 -35rem;
  background: radial-gradient(closest-side,
    rgb(240 180 76 / 0.1),
    rgb(240 180 76 / 0.04) 40%,
    rgb(240 180 76 / 0.01) 70%,
    transparent);
  transform: translate3d(var(--mx, 50vw), var(--my, 45vh), 0);
  pointer-events: none;
  will-change: transform;
}
/* Film grain over everything, static so it costs nothing per frame.
   Self-hosted SVG: the CSP allows images from 'self' only, not data: URIs. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: url("/grain.svg") 0 0 / 160px 160px;
  opacity: 0.09;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 2;
}

/* Phosphor texture above the grain: faint scanlines and a soft tube vignette. */
html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgb(0 0 0 / 0.14) 2px 3px),
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgb(0 0 0 / 0.22));
}

main { position: relative; z-index: 1; width: 100%; max-width: 22rem; }

::selection { background: rgb(240 180 76 / 0.25); }

/* Header */
.mark {
  color: var(--bone);
  font-size: 2.5rem;
  font-stretch: 112.5%;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 1.75rem -0.04em;
  text-shadow: 0 0 2.5rem rgb(240 180 76 / 0.12);
  position: relative;
  width: max-content;
}
.mark .dot { color: var(--lichen); }

/* Block cursor. Rests after the final dot; script.js walks it in while typing. */
.mark::after {
  content: "";
  position: absolute;
  left: 100%;
  bottom: 0.04em;
  /* Offset from the resting spot via transform, so typing causes no layout shift. */
  transform: translateX(var(--caret-dx, 0px));
  width: 0.5em;
  height: 0.78em;
  margin-left: 0.06em;
  background: var(--amber);
  box-shadow: 0 0 1.25rem rgb(240 180 76 / 0.35);
  /* Blinks for ~4s after load, then holds still (WCAG 2.2.2). */
  animation: blink 1.1s steps(1, end) 0.7s 4;
}
.mark.is-typing::after { animation: none; }
.mark.is-typing .ch:not(.on) { visibility: hidden; }
@keyframes blink { 50% { opacity: 0; } }

h1 {
  color: var(--bone);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.tagline { color: var(--lichen); font-size: 0.85rem; margin-top: 0.25rem; }

/* Decode overlay: the real text stays in place (transparent) for layout,
   selection and screen readers; scrambled glyphs sit on top, aria-hidden. */
.tagline, .title, .desc { position: relative; }
.is-scrambling { -webkit-text-fill-color: transparent; }
.scramble {
  position: absolute;
  inset: 0;
  -webkit-text-fill-color: currentColor;
  pointer-events: none;
  hyphens: none;
}
.scramble .u { opacity: 0.45; }
.title .scramble .u { color: var(--amber); opacity: 0.8; }

/* Projects: each row becomes a glass card on hover. The card bleeds into the
   gutter with a negative margin so icons and text stay on the same column. */
.projects { list-style: none; margin-top: 3.5rem; }
.projects li + li { margin-top: 0.15rem; }

.projects a {
  --gx: 50%;
  --gy: 50%;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 0.85rem;
  margin: 0 -0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
/* Tilt and lift only when script.js runs (fine pointer, motion allowed). */
.js-spotlight .projects a {
  transform:
    perspective(800px)
    translate3d(0, calc(var(--lift, 0) * -2px), 0)
    rotateX(calc(var(--rx, 0) * 1deg))
    rotateY(calc(var(--ry, 0) * 1deg));
}

/* Glass surface with a pointer-tracked inner light. */
.projects a::before,
.projects a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--settle);
  z-index: -1;
}
.projects a::before {
  background:
    radial-gradient(16rem circle at var(--gx) var(--gy), rgb(240 180 76 / 0.09), transparent 65%),
    linear-gradient(rgb(232 226 212 / 0.035), rgb(232 226 212 / 0.015));
  box-shadow:
    inset 0 1px 0 rgb(232 226 212 / 0.06),
    0 1rem 2rem -1rem rgb(4 12 13 / 0.7);
}
/* Border glow: same light source, masked down to a 1px ring. */
.projects a::after {
  padding: 1px;
  background:
    radial-gradient(11rem circle at var(--gx) var(--gy), rgb(240 180 76 / 0.6), transparent 70%),
    linear-gradient(rgb(232 226 212 / 0.07), rgb(232 226 212 / 0.07));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.icon {
  grid-row: 1;
  align-self: center;
  border-radius: 4px;
  transition: transform 0.45s var(--settle);
}
.title, .desc { grid-column: 2; }

.title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--stone);
  transition: color 0.2s;
}
.desc { display: block; color: var(--lichen); font-size: 0.8rem; margin-top: 0.15rem; transition: color 0.2s; }

.ext {
  width: 0.7rem;
  height: 0.7rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 0.2s, transform 0.35s var(--settle);
}

.projects a:hover::before, .projects a:hover::after,
.projects a:focus-visible::before, .projects a:focus-visible::after { opacity: 1; }
.projects a:hover .title, .projects a:focus-visible .title { color: var(--bone); }
.projects a:hover .desc, .projects a:focus-visible .desc { color: var(--stone); }
.projects a:hover .icon, .projects a:focus-visible .icon { transform: scale(1.12); }
.projects a:hover .ext, .projects a:focus-visible .ext { opacity: 1; transform: translate(2px, -2px); color: var(--amber); }

/* Touch: no hover, so the card answers the press itself, instantly. */
@media (hover: none) {
  .projects a:active::before, .projects a:active::after { opacity: 1; transition-duration: 0.08s; }
  .projects a:active .title { color: var(--bone); }
  .projects a:active .icon { transform: scale(1.12); }
}

/* Socials */
footer {
  display: flex;
  gap: 1.25rem;
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--lichen);
  text-decoration: none;
  transition: color 0.2s;
}
footer svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
  transition: transform 0.45s var(--settle);
}
footer a:hover, footer a:focus-visible { color: var(--bone); }
footer a:hover svg, footer a:focus-visible svg { transform: scale(1.18); }

a:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }
.projects a:focus-visible { outline-offset: 2px; border-radius: 12px; }

/* One entrance: header, projects and footer rise in sequence and come into
   focus. Stagger index lives here, not in style="" attributes (CSP). */
header { --i: 0; }
.projects li:nth-child(1) { --i: 1; }
.projects li:nth-child(2) { --i: 2; }
.projects li:nth-child(3) { --i: 3; }
footer { --i: 4; }
header, .projects li, footer {
  animation: rise 0.8s var(--settle) both;
  animation-delay: calc(var(--i) * 80ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); filter: blur(6px); }
}
body::before { animation: glow-in 1.4s ease-out both; }
@keyframes glow-in { from { opacity: 0; } }

@media (prefers-reduced-transparency: reduce) {
  body::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  header, .projects li, footer, body::before, .mark::after { animation: none; }
  .icon, .ext, footer svg, .projects a::before, .projects a::after { transition: none; }
  .projects a:hover .icon, .projects a:focus-visible .icon,
  footer a:hover svg, footer a:focus-visible svg { transform: none; }
}
