/* Space Grotesk self-hosted (variable, 300-700) — no third-party requests */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin.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-latin-ext.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;
}

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

:root {
  --bg: #0b0b0b;
  --surface: rgba(255,255,255,0.04);
  --border: rgba(238,235,228,0.1);
  --border-h: rgba(201,241,53,0.45);
  --text: #eeebe4;
  --muted: rgba(238,235,228,0.6);
  --accent: #c9f135;
  --green: #4ade80;
  --red: #f87171;
  --mono: 'SF Mono','Fira Code','Consolas',monospace;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --r: 8px;
}

html { scroll-behavior: smooth; }
/* Subtle first-party background texture: a faint technical dot-grid drawn by
   the browser (CSS pattern, not an image — CSP blocks data: URIs). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(238, 235, 228, 0.045) 1px, transparent 1.6px),
    radial-gradient(rgba(201, 241, 53, 0.035) 1px, transparent 1.6px);
  background-size: 27px 27px, 27px 27px;
  background-position: 0 0, 13.5px 13.5px;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.65;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(238,235,228,0.3); }
a:hover { text-decoration-color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* NAV */
nav { position: fixed; top: 0; left: 0; right: 0; z-index: 100; transition: background 0.3s, border-bottom 0.3s; }
nav.on { background: rgba(11,11,11,0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav-wrap { max-width: 1080px; margin: 0 auto; padding: 0 28px; display: flex; justify-content: space-between; align-items: center; height: 56px; }
.nlogo { font-family: var(--display); font-weight: 800; font-size: 1rem; letter-spacing: -0.5px; color: var(--text); text-decoration: none; }
.nlinks { display: flex; gap: 2px; list-style: none; }
.nlinks a { color: var(--muted); font-size: 0.82rem; padding: 5px 11px; border-radius: 6px; transition: color 0.15s, background 0.15s; text-decoration: none; }
.nlinks a:hover, .nlinks a.active { color: var(--text); background: var(--surface); }
@media(max-width:640px) { .nlinks { display: none; } }
.hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; width: 32px; height: 32px; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media(max-width:640px) { .hamburger { display: flex; } }
.mobile-menu { display: none; position: fixed; top: 56px; left: 0; right: 0; background: rgba(11,11,11,0.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); list-style: none; padding: 8px 0; z-index: 99; }
.mobile-menu.open { display: block; }
.mobile-menu a { display: block; padding: 12px 28px; color: var(--muted); font-size: 0.9rem; text-decoration: none; transition: color 0.15s; }
.mobile-menu a:hover, .mobile-menu a.active { color: var(--text); }

/* CONTAINER */
.c { max-width: 1080px; margin: 0 auto; padding: 0 28px; }

/* HERO */
.hero {
  min-height: 100vh; padding: 100px 0 80px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center;
  position: relative;
}
.hero-grid { display: grid; grid-template-columns: 250px 1fr 250px; gap: 56px; align-items: center; }
@media(max-width:1000px) {
  .hero-grid { grid-template-columns: 1fr 210px; gap: 40px; }
  .hero-side { display: none; }
}
@media(max-width:780px) {
  .hero { min-height: auto; padding: 110px 0 64px; }
  .hero-grid { grid-template-columns: 1fr; gap: 48px; justify-items: center; }
  .hero-main { order: 1; }
  .hero-cube { order: 2; }
  .hero-side { order: 3; display: block; width: 100%; max-width: 420px; }
  .scroll-hint { display: none; }
}

/* ---- self-solving cube, monochrome + live-lit (pure CSS/JS, no deps) ---- */
/* Face colour is set per-frame in JS (Lambert shading); CSS just adds the bevel. */
.hero-cube { display: flex; align-items: center; justify-content: center; perspective: 1150px; min-height: 240px; }
.cube-spin { position: relative; width: 210px; height: 210px; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-18deg); }
.cube { position: absolute; inset: 0; transform-style: preserve-3d; }
.cubie { position: absolute; top: 50%; left: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px; transform-style: preserve-3d; }
.face { position: absolute; width: 68px; height: 68px; border-radius: 8px; background: #242424; border: 2px solid #040404; box-shadow: inset 0 1px 0 rgba(255,255,255,.10), inset 0 -8px 14px rgba(0,0,0,.32); backface-visibility: hidden; }
@media (max-width: 780px) { .hero-cube { min-height: 210px; margin: 4px 0; } }
.hero-loc { font-family: var(--mono); font-size: 0.71rem; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 20px; }
.hero h1 { font-family: var(--display); font-size: clamp(3.5rem, 8.5vw, 7rem); font-weight: 800; letter-spacing: -3px; line-height: 0.95; margin-bottom: 28px; }
.hero-sub { font-size: 1.08rem; color: var(--muted); max-width: 460px; margin-bottom: 38px; line-height: 1.72; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

/* hero aside */
.hs-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 26px; }
.hs-label { font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); margin-bottom: 13px; }
.hs-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; gap: 10px; }
.hs-row:last-child { border-bottom: none; }
.hs-key { color: var(--muted); font-size: 0.84rem; flex-shrink: 0; }
.hs-val { font-family: var(--mono); font-size: 0.82rem; text-align: right; }
.hs-div { height: 1px; background: var(--border); margin: 16px 0; }

/* scroll hint */
.scroll-hint { position: absolute; bottom: 32px; left: 28px; font-family: var(--mono); font-size: 0.66rem; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; animation: scrollpulse 3s ease-in-out infinite; pointer-events: none; user-select: none; }
@keyframes scrollpulse { 0%,100%{opacity:0.28;} 50%{opacity:0.6;} }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; padding: 10px 22px; border-radius: var(--r); font-size: 0.88rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: opacity 0.15s, background 0.15s, border-color 0.15s; text-decoration: none !important; }
.btn-p { background: var(--accent); color: #0b0b0b; border-color: var(--accent); }
.btn-p:hover { opacity: 0.85; }
.btn-g { background: transparent; color: var(--text); border-color: var(--border); }
.btn-g:hover { border-color: var(--border-h); background: var(--surface); }

/* TICKER */
.ticker { border-bottom: 1px solid var(--border); padding: 11px 0; overflow: hidden; user-select: none; }
.ticker-track { display: flex; white-space: nowrap; animation: ticker 32s linear infinite; }
.ticker-track:hover { animation-play-state: paused; }
.ticker-item { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.5px; padding: 0 28px; }
.ticker-item span { color: var(--accent); margin-right: 6px; }
@keyframes ticker { from{transform:translateX(0);} to{transform:translateX(-50%);} }

/* SECTIONS */
section { padding: 88px 0; border-bottom: 1px solid var(--border); }
section:last-child { border-bottom: none; }
.slabel { font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); font-weight: 400; margin-bottom: 10px; }
.stitle { font-family: var(--display); font-size: clamp(1.8rem, 3.8vw, 2.6rem); font-weight: 800; letter-spacing: -1px; line-height: 1.1; margin-bottom: 14px; }
.sdesc { color: var(--muted); font-size: 0.95rem; max-width: 520px; margin-bottom: 38px; line-height: 1.7; }

/* CARD */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 24px; transition: border-color 0.2s; }
.card:hover { border-color: var(--border-h); }
.card-head { font-family: var(--mono); font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 18px; }

/* ABOUT */
.bio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media(max-width:520px) { .bio-grid { grid-template-columns: 1fr; } }
.bio-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; transition: border-color 0.2s; }
.bio-item:hover { border-color: var(--border-h); }
.bi-label { font-family: var(--mono); font-size: 0.64rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.bi-val { font-size: 0.93rem; font-weight: 500; line-height: 1.5; }
.bio-grid > .bio-item:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* SKILLS */
.skills-list { display: flex; flex-direction: column; gap: 0; }
.skill-row { display: flex; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--border); gap: 24px; font-size: 0.87rem; }
.skill-row:last-child { border-bottom: none; }
.skill-cat { font-family: var(--mono); font-size: 0.73rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; width: 130px; flex-shrink: 0; }
.skill-items { color: var(--text); line-height: 1.6; }

/* PROJECTS */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 14px; }
.proj-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 24px; transition: border-color 0.2s; display: flex; flex-direction: column; }
.proj-card:hover { border-color: var(--border-h); }
.proj-card.featured { grid-column: 1 / -1; border-left: 3px solid var(--accent); }
.proj-year { font-family: var(--mono); font-size: 0.63rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.proj-title { font-family: var(--display); font-size: 1.05rem; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 10px; line-height: 1.25; }
.proj-desc { font-size: 0.87rem; color: var(--muted); line-height: 1.65; flex: 1; margin-bottom: 16px; }
.proj-outcome { font-family: var(--mono); font-size: 0.71rem; color: var(--accent); margin-bottom: 16px; }
.proj-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.proj-tag { font-family: var(--mono); font-size: 0.67rem; color: var(--muted); background: rgba(238,235,228,0.05); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; }
.proj-link { display: inline-block; margin-top: 16px; font-size: 0.84rem; font-weight: 600; text-decoration: none; }
.proj-link:hover { text-decoration: underline; text-decoration-color: var(--accent); }

/* LAB / SERVER */
.cgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; }
.cgrid-narrow { max-width: 520px; }
.specs { list-style: none; }
.spec { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.87rem; gap: 16px; }
.spec:last-child { border-bottom: none; }
.sk { color: var(--muted); flex-shrink: 0; }
.sv { font-family: var(--mono); font-size: 0.81rem; font-weight: 500; text-align: right; }
.svc { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.svc:last-child { border-bottom: none; padding-bottom: 0; }
.svc-name { flex: 1; font-weight: 500; }
.svc-desc { color: var(--muted); font-size: 0.79rem; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.dot.down { background: var(--red); }

/* terminal block */
.term { background: #070707; border: 1px solid var(--border); border-radius: var(--r); padding: 20px 22px; font-family: var(--mono); font-size: 0.79rem; line-height: 2; overflow-x: auto; }
.term-prompt { color: var(--muted); margin-bottom: 8px; white-space: nowrap; }
.term-prompt b { color: var(--accent); font-weight: 500; }
.term-row { display: flex; gap: 18px; white-space: nowrap; }
.term-k { color: var(--muted); width: 84px; flex-shrink: 0; }
.term-v { color: var(--text); }

/* live status */
.lab-checked { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); margin-top: 14px; }
.lab-checked b { color: var(--green); font-weight: 500; }

/* contact */
.contact-note { color: var(--muted); font-size: 0.85rem; margin-top: 16px; line-height: 1.6; }

/* WRITE-UP PAGES */
.wu { max-width: 720px; margin: 0 auto; padding: 120px 28px 72px; }
.wu-back { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); text-decoration: none; letter-spacing: 0.5px; }
.wu-back:hover { color: var(--text); }
.wu h1 { font-family: var(--display); font-size: clamp(1.9rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -1.2px; line-height: 1.1; margin: 18px 0 14px; }
.wu-meta { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.5px; padding-bottom: 28px; border-bottom: 1px solid var(--border); margin-bottom: 36px; }
.wu-meta span { color: var(--accent); }
.wu h2 { font-family: var(--display); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.4px; margin: 44px 0 14px; }
.wu p { color: rgba(238,235,228,0.82); font-size: 0.95rem; line-height: 1.75; margin-bottom: 16px; }
.wu ul, .wu ol { margin: 0 0 16px 22px; color: rgba(238,235,228,0.82); font-size: 0.95rem; line-height: 1.75; }
.wu li { margin-bottom: 6px; }
.wu li::marker { color: var(--accent); }
.wu pre { background: #070707; border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; overflow-x: auto; margin-bottom: 16px; }
.wu pre code { font-family: var(--mono); font-size: 0.78rem; line-height: 1.7; color: var(--text); background: none; border: none; padding: 0; }
.wu code { font-family: var(--mono); font-size: 0.82em; background: rgba(238,235,228,0.06); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.wu .note { font-size: 0.84rem; color: var(--muted); border-left: 2px solid var(--border-h); padding: 4px 0 4px 16px; margin-bottom: 16px; line-height: 1.7; }
.wu-tl { list-style: none; margin: 0 0 16px 0; }
.wu-tl li { display: flex; gap: 20px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; margin: 0; }
.wu-tl li:last-child { border-bottom: none; }
.wu-tl .tld { font-family: var(--mono); font-size: 0.75rem; color: var(--accent); width: 96px; flex-shrink: 0; padding-top: 2px; }
.wu-tl .tlt { color: rgba(238,235,228,0.82); line-height: 1.6; }
.wu-next { margin-top: 52px; padding-top: 24px; border-top: 1px solid var(--border); }

/* 404 */
.err-wrap { min-height: 100vh; display: flex; align-items: center; }
.err-wrap .term { width: 100%; max-width: 560px; }

/* FOOTER */
footer { padding: 34px 0; border-top: 1px solid var(--border); }
footer .wrap { max-width: 960px; margin: 0 auto; padding: 0 28px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
footer p { color: var(--muted); font-size: 0.79rem; }
footer a { color: var(--muted); }

.skip { position: absolute; left: -9999px; top: 4px; z-index: 9999; background: var(--bg); color: var(--accent); border: 1px solid var(--accent); border-radius: var(--r); padding: 8px 16px; font-size: 0.85rem; text-decoration: none; }
.skip:focus { left: 4px; }

@media(prefers-reduced-motion:reduce) {
  .ticker-track { animation: none; }
  .scroll-hint { animation: none; opacity: 0.45; }
}
