:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  --page: #030303;
  --ink: #e1e1e1;
  --muted: #999999;
  --intro: #c3c3c3;
  --trace: #494949;
  --glass: #1c1c1c;
  --phosphor: #e2e2e2;
  --roll: #fff;
  --raster: #00000055;
  --glow: #ffffff44;
  --echo: #ffffff22;
  background: var(--page);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 4vh 3vw;
  padding: 4svh 3vw;
  background: var(--page);
}

.site { width: 100%; --depth: 0; }
.screen-surface {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 16% / 18%;
  background: var(--glass);
  color: var(--phosphor);
  -webkit-user-select: none;
  user-select: none;
}
.project-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  filter: grayscale(1) contrast(1.25) brightness(.85);
  transition: opacity 850ms ease-out;
}
.screen-surface.has-video .project-video {
  opacity: .21;
  transition-duration: 2200ms;
  transition-timing-function: ease-in-out;
}
/* The desktop renderer samples this same video beneath the CRT's text and noise. */
.screen-surface.is-rendered .project-video { opacity: 0; transition: none; }
.screen-content {
  position: relative;
  z-index: 1;
  min-height: 86vh;
  min-height: 86svh;
  padding: 8vh 6%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1.6fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 3vw, 56px);
}
main, .projection { grid-area: 1 / 2; width: 100%; max-width: 440px; min-width: 0; margin: auto; }
main {
  text-align: center;
  transform: perspective(900px) translateZ(calc(var(--depth) * -180px));
  opacity: calc(1 - var(--depth) * .8);
}
h1 { margin: 0 0 10px; font-size: 24px; font-weight: 500; letter-spacing: -.02em; }
.blurb { margin: 0 0 34px; color: var(--intro); font-size: 15px; line-height: 1.5; }
.projects { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.project-trigger {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: baseline;
  gap: 18px;
  border: 0;
  padding: 10px 0;
  color: inherit;
  background: transparent;
  font: 15px/1.5 Arial, Helvetica, sans-serif;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.project-name { text-underline-offset: 5px; text-decoration-thickness: 1px; }
.project-trigger:hover .project-name,
.project-trigger:focus-visible .project-name,
.project-trigger[aria-expanded="true"] .project-name { text-decoration: underline; }
.subtitle { color: var(--muted); text-align: right; font-size: 13px; }
a:focus, button:focus { outline: none; }

.projection {
  position: relative;
  z-index: 1;
  transform: perspective(900px) translateZ(calc((1 - var(--depth)) * 60px));
  opacity: clamp(0, calc((var(--depth) - .18) / .82), 1);
}
/* Measure both planes at rest before painting their depth into the CRT texture. */
.screen-content.is-measuring > :is(main, .projection) { transform: none; }
.project-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.project-title { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 400; }
.project-link { display: inline-block; min-height: 44px; color: inherit; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }
.project-close { min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); font: 13px/1.5 Arial, Helvetica, sans-serif; cursor: pointer; }
.project-close:hover { color: var(--phosphor); }
.project-close:focus-visible { text-decoration: underline; text-underline-offset: 5px; }
.project-description { margin: 0; font-size: 16px; line-height: 1.7; }
/* Reserve each word's final space while its letters are revealed. */
.typing-word { display: inline-block; text-decoration: inherit; }
.screen-surface:not(.is-rendered) .screen-content { text-shadow: 0 0 1.8px var(--glow), 1.25px 0 1px var(--echo); }
.screen-surface:not(.is-rendered)::before,
.screen-surface:not(.is-rendered)::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.screen-surface:not(.is-rendered)::before {
  z-index: 0;
  background: linear-gradient(177deg, transparent 38%, var(--roll) 49%, transparent 62%);
  opacity: .085;
  animation: crt-roll 4.6s linear infinite;
}
.screen-surface:not(.is-rendered)::after {
  background-image: repeating-linear-gradient(transparent 0 2px, var(--raster) 2px 3px), var(--grain-image);
  background-size: auto, 96px 96px;
  opacity: .48;
  animation: crt-grain .31s steps(2, end) infinite;
}
.site[data-effects-paused="true"] .screen-surface::before,
.site[data-effects-paused="true"] .screen-surface::after { animation-play-state: paused; }
.screen-surface.is-rendered { border-radius: 0; background: transparent; overflow: visible; }
.screen-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.screen-shadow { display: none; }
.screen-surface:not(.is-rendered) .screen-shadow {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow: inset 0 0 16px 8px var(--page),
    inset 0 0 clamp(48px, 8vw, 130px) clamp(12px, 2vw, 32px) var(--page);
  pointer-events: none;
}
/* Keep real text and native controls accessible above their painted counterparts. */
.is-rendered .screen-content,
.is-rendered .screen-content :is(h1, p, span, a, button) { color: transparent; text-decoration-color: transparent; text-shadow: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
@keyframes crt-roll { from { transform: translateY(100%); } to { transform: translateY(-100%); } }
@keyframes crt-grain {
  0% { background-position: 0 0; }
  25% { background-position: 19px -31px; }
  50% { background-position: -23px 11px; }
  75% { background-position: 43px 29px; }
  100% { background-position: -13px -47px; }
}

@media (max-width: 900px) {
  .screen-content { grid-template-columns: minmax(0, 1fr); gap: 32px; align-content: center; padding: 64px 10%; }
  main, .projection { grid-area: 1 / 1; margin: 0 auto; }
}
@media (max-width: 520px) {
  body { padding: 20px 12px; }
  .screen-content { min-height: calc(100svh - 40px); padding: 48px 24px; }
  h1 { font-size: 22px; }
  .blurb { font-size: 14px; margin-bottom: 28px; }
  .project-trigger { grid-template-columns: 64px minmax(0, 1fr); gap: 14px; font-size: 14px; }
  .subtitle { font-size: 12px; }
  .project-description { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .project-video { opacity: 0 !important; transition: none; }
  .screen-surface::before { opacity: 0 !important; animation: none !important; }
  .screen-surface::after { animation: none !important; }
}
