/* ============================================================
   SAM SHAPLEY // 8-BIT WARP TERMINAL
   Monochrome futuristic theme — blacks, whites, pixels
   ============================================================ */

:root {
  --bg: #050505;
  --bg-soft: #0d0d0f;
  --panel: #111114;
  --fg: #f4f4f4;
  --dim: #9a9a9a;
  --faint: #4a4a4a;
  --line: #2a2a2e;
  --white: #ffffff;
  --black: #000000;
  --px: 4px;
  --edge: 14px; /* chamfer size for pixel corners */
  --font-display: 'Press Start 2P', monospace;
  --font-body: 'VT323', 'Courier New', monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  cursor: crosshair;
  -webkit-font-smoothing: none;
  text-rendering: optimizeLegibility;
}

/* Persistent starfield sits behind everything */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  background:
    radial-gradient(circle at 50% 40%, #101015 0%, #050505 60%, #000 100%);
}

/* Scanline + vignette overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.045) 0px,
      rgba(255,255,255,0.045) 1px,
      transparent 2px,
      transparent 4px
    );
  mix-blend-mode: overlay;
  animation: flicker 6s infinite steps(60);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 899;
  pointer-events: none;
  box-shadow: inset 0 0 220px 40px rgba(0,0,0,0.9);
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.7; }
  98% { opacity: 0.95; }
  99% { opacity: 0.6; }
}

/* ---------- layout ---------- */
.wrap {
  position: relative;
  z-index: 2;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 500;
  backdrop-filter: blur(4px);
  background: linear-gradient(to bottom, rgba(5,5,5,0.92), rgba(5,5,5,0.55));
  border-bottom: 2px solid var(--line);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  max-width: 980px;
  margin: 0 auto;
}
.brand {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--white);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand .chip {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  background: var(--white);
  color: var(--black);
  font-size: 12px;
  box-shadow: 4px 4px 0 #000, 4px 4px 0 1px var(--faint);
}
.nav-links {
  display: flex;
  gap: 8px;
  list-style: none;
}
.nav-links a {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 10px 12px;
  border: 2px solid transparent;
  transition: none;
  position: relative;
}
.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--black);
  background: var(--white);
  outline: none;
}
.nav-links a[aria-current="page"] {
  color: var(--black);
  background: var(--white);
  border-color: var(--white);
}
.nav-links a[aria-current="page"]::before { content: "> "; color: var(--faint); }
.nav-links a[aria-current="page"]:hover,
.nav-links a[aria-current="page"]:focus-visible {
  color: var(--black);
  background: var(--white);
}

/* ---------- sound toggle ---------- */
.sound-toggle {
  font-family: var(--font-display);
  font-size: 9px;
  background: transparent;
  color: var(--dim);
  border: 2px solid var(--line);
  padding: 8px 10px;
  cursor: pointer;
}
.sound-toggle:hover { color: var(--black); background: var(--white); border-color: var(--white); }

/* ---------- headings ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.35; color: var(--white); }
h1 { font-size: clamp(26px, 6vw, 54px); letter-spacing: 2px; }
h2 { font-size: clamp(16px, 3.5vw, 22px); margin-bottom: 18px; }
h3 { font-size: 13px; }
h4 { font-size: 11px; color: var(--dim); }

section { margin: 64px 0; }

/* ---------- hero ---------- */
.hero {
  min-height: calc(100vh - 74px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0 80px;
}
.hero .kicker {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 3px;
  margin-bottom: 22px;
}
.hero h1 { margin-bottom: 24px; }
.hero .tagline {
  font-size: 26px;
  color: var(--fg);
  max-width: 40ch;
  min-height: 3em;
  margin-bottom: 34px;
}
.cursor-blink::after {
  content: "\2588";
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
  color: var(--white);
}
@keyframes blink { 50% { opacity: 0; } }

.readout {
  font-size: 18px;
  color: var(--faint);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-top: 10px;
}
.readout span b { color: var(--dim); font-weight: normal; }

/* ---------- buttons ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.btn {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--black);
  background: var(--white);
  text-decoration: none;
  padding: 14px 18px;
  border: 2px solid var(--white);
  box-shadow: 6px 6px 0 var(--faint);
  transition: transform .04s linear, box-shadow .04s linear;
  display: inline-block;
}
.btn:hover { transform: translate(3px,3px); box-shadow: 3px 3px 0 var(--faint); }
.btn:active { transform: translate(6px,6px); box-shadow: 0 0 0 var(--faint); }
.btn.ghost { background: transparent; color: var(--white); box-shadow: 6px 6px 0 var(--line); }
.btn.ghost:hover { background: var(--white); color: var(--black); }

/* ---------- glitch text ---------- */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  clip-path: inset(0 0 0 0);
  opacity: 0;
  pointer-events: none;
}
.glitch:hover::before {
  opacity: 0.9;
  color: var(--white);
  transform: translate(-3px, -1px);
  animation: glitchTop .35s steps(2) infinite;
  clip-path: inset(0 0 55% 0);
}
.glitch:hover::after {
  opacity: 0.9;
  color: var(--dim);
  transform: translate(3px, 1px);
  animation: glitchBot .35s steps(2) infinite;
  clip-path: inset(55% 0 0 0);
}
@keyframes glitchTop { 0%{transform:translate(-3px,-1px)} 50%{transform:translate(2px,1px)} 100%{transform:translate(-2px,-2px)} }
@keyframes glitchBot { 0%{transform:translate(3px,1px)} 50%{transform:translate(-2px,-1px)} 100%{transform:translate(2px,2px)} }

/* ---------- cards ---------- */
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr; }

.card {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 22px;
  clip-path: polygon(
    0 var(--edge), var(--edge) 0,
    100% 0, 100% calc(100% - var(--edge)),
    calc(100% - var(--edge)) 100%, 0 100%
  );
  transition: transform .06s linear, background .06s linear, color .06s linear;
}
.card::after {
  content: "";
  position: absolute;
  right: 8px; bottom: 8px;
  width: 8px; height: 8px;
  background: var(--faint);
}
.card:hover {
  transform: translate(-2px,-2px);
  background: var(--bg-soft);
  border-color: var(--dim);
}
.card:hover::after { background: var(--white); }

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.entry-title { font-family: var(--font-display); font-size: 12px; color: var(--white); }
.entry-meta { font-size: 18px; color: var(--dim); white-space: nowrap; }
.entry-role { font-size: 20px; color: var(--fg); margin: 4px 0 10px; }
.entry-role .tag { color: var(--faint); }
.entry-body { font-size: 20px; color: var(--dim); }
.entry-body a { color: var(--white); text-decoration: none; border-bottom: 2px solid var(--faint); }
.entry-body a:hover { background: var(--white); color: var(--black); border-color: var(--white); }

.thesis { border-left: 2px solid var(--line); padding-left: 14px; margin: 14px 0; }
.thesis b { color: var(--fg); font-size: 19px; }

/* ---------- projects ---------- */
.proj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.proj {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  clip-path: polygon(
    0 0, calc(100% - var(--edge)) 0, 100% var(--edge),
    100% 100%, var(--edge) 100%, 0 calc(100% - var(--edge))
  );
  transition: transform .06s linear, background .06s linear, color .06s linear;
}
.proj .yr { font-family: var(--font-display); font-size: 9px; color: var(--faint); }
.proj .name { font-family: var(--font-display); font-size: 13px; color: var(--white); }
.proj .desc { font-size: 19px; color: var(--dim); }
.proj .go { margin-top: auto; font-family: var(--font-display); font-size: 9px; color: var(--faint); }
.proj:hover { background: var(--white); color: var(--black); transform: translate(-3px,-3px); box-shadow: 6px 6px 0 var(--faint); }
.proj:hover .yr, .proj:hover .name, .proj:hover .desc, .proj:hover .go { color: var(--black); }

.section-label {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 2px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-label .dot { color: var(--faint); }

.year-band {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--faint);
  margin: 34px 0 14px;
}

/* ---------- footer ---------- */
.site-footer {
  position: relative;
  z-index: 2;
  border-top: 2px solid var(--line);
  margin-top: 60px;
  padding: 28px 24px 48px;
  text-align: center;
  color: var(--faint);
  font-size: 18px;
}
.site-footer .k { color: var(--dim); }

/* ---------- warp intro overlay ---------- */
#warp {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: grid;
  place-items: center;
  /* failsafe: reveal even if JS fails */
  animation: warpFailsafe 0.6s linear 4.5s forwards;
}
#warp canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.boot {
  position: relative;
  z-index: 2;
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--white);
  text-align: left;
  width: min(560px, 86vw);
  min-height: 160px;
  padding: 16px;
  text-shadow: 0 0 6px rgba(255,255,255,0.35);
}
.boot .line { white-space: pre-wrap; }
.boot .line .ok { color: var(--dim); }
.skip {
  position: absolute;
  bottom: 24px; right: 28px;
  z-index: 3;
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--faint);
  border: 2px solid var(--line);
  background: transparent;
  padding: 8px 10px;
  cursor: pointer;
}
.skip:hover { color: #000; background: #fff; }
#warp.done { opacity: 0; visibility: hidden; transition: opacity .5s ease; }
@keyframes warpFailsafe { to { opacity: 0; visibility: hidden; } }
.no-warp #warp { display: none !important; }

/* cursor follower */
#cursor-dot {
  position: fixed;
  top: 0; left: 0;
  width: 10px; height: 10px;
  background: var(--white);
  z-index: 950;
  pointer-events: none;
  mix-blend-mode: difference;
  transform: translate(-50%, -50%);
  will-change: transform;
}

/* reveal-on-load for content */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .5s ease, transform .5s ease; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  body { font-size: 20px; }
  .proj-grid { grid-template-columns: 1fr; }
  .nav-inner { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .brand { font-size: 12px; }
  .nav-links a { font-size: 9px; padding: 8px; }
  .hero { min-height: auto; padding-top: 30px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, body::after { animation: none !important; scroll-behavior: auto; }
  #warp { display: none !important; }
  .reveal { opacity: 1; transform: none; }
}
