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

:root {
  --bg: #0b0b0b;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --border: #242424;
  --border-hover: #333;
  --text: #e2dbd0;
  --muted: #5a5550;
  --accent: #f0a020;
  --accent-dim: rgba(240, 160, 32, 0.12);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.15);
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 16px;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: 'Inter', system-ui, sans-serif;
}

/* ── light mode ── */
body.light {
  --bg: #f5f2ed;
  --surface: #ffffff;
  --surface-2: #f0ece6;
  --border: #e0d9d0;
  --border-hover: #c8bfb4;
  --text: #1a1612;
  --muted: #8a7f74;
  --accent: #c47f00;
  --accent-dim: rgba(196, 127, 0, 0.1);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.12);
}

body.light .grain { opacity: 0.025; }
body.light .spotlight { background: radial-gradient(ellipse at center, rgba(196,127,0,0.06) 0%, transparent 70%); }
body.light .terminal { background: #faf8f5; box-shadow: 0 0 0 1px rgba(0,0,0,0.04), 0 24px 80px rgba(0,0,0,0.1); }
body.light .terminal-bar { background: #f0ece6; }
body.light .terminal-body { color: #5a4f44; }
body.light .t-output { color: #8a7f74; }
body.light .mouse-body { border-color: #bbb; background: #ddd; }
body.light .mouse-btn { background: #e8e8e8; }
body.light .mouse-btn.active { background: #d0d0d0; }
body.light .mouse-scroll::before { background: #bbb; }
body.light .envelope-body { background: #f0e8d8; }
body.light .envelope-flap { background: #e4d8c4; }
body.light .envelope-letter { background: #fff; }
body.light .glitch-text { color: var(--text); }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── grain overlay ── */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.038;
}

/* ── spotlight ── */
.spotlight {
  position: fixed;
  top: -40vh;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  height: 80vh;
  background: radial-gradient(ellipse at center, rgba(240,160,32,0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── nav ── */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.3s;
}
nav.scrolled { border-bottom-color: var(--border); }

.logo {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo .accent { color: var(--accent); }
.cursor-blink {
  color: var(--accent);
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface); }
.icon-sun  { display: none; }
.icon-moon { display: block; }
body.light .icon-sun  { display: block; }
body.light .icon-moon { display: none; }

.nav-github {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-github:hover { color: var(--text); }

/* ── hero ── */
.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 120px 24px 80px;
  gap: 48px;
}

/* ── terminal ── */
.terminal {
  width: 100%;
  max-width: 600px;
  background: #0f0f0f;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03), 0 24px 80px rgba(0,0,0,0.6), 0 0 60px rgba(240,160,32,0.04);
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s 0.2s ease forwards;
}
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #131313;
  border-bottom: 1px solid var(--border);
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #ffbd2e; }
.dot-green  { background: #28c840; }

.terminal-title {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.terminal-body {
  padding: 20px 24px 24px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.8;
  color: #c8c0b4;
  min-height: 160px;
}
.t-line { display: block; }
.t-prompt { color: var(--green); }
.t-cmd    { color: var(--text); }
.t-output { color: var(--muted); padding-left: 0; }
.t-output.highlight { color: var(--accent); font-style: italic; }
.t-cursor {
  display: inline-block;
  color: var(--accent);
  animation: blink 1.1s step-end infinite;
  font-size: 13px;
}

/* ── hero sub ── */
.hero-sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.hero-sub.visible { opacity: 1; }

.hero-tagline {
  font-size: 15px;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--green-dim);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}
.status-pill:hover { background: rgba(74, 222, 128, 0.22); border-color: rgba(74, 222, 128, 0.4); }
.status-pill strong { color: #fff; }

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  position: relative;
  flex-shrink: 0;
}
.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0.4;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(1); opacity: 0.4; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

/* ── section label ── */
.section-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

/* ── projects ── */
.projects {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 24px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* ── card base ── */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: border-color 0.25s, transform 0.15s ease, box-shadow 0.25s;
  will-change: transform;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.card:hover { border-color: var(--border-hover); box-shadow: 0 8px 40px rgba(0,0,0,0.4); }

.card-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted);
}
.card-badge-wip {
  background: var(--green-dim);
  border-color: rgba(74,222,128,0.25);
  color: var(--green);
}

.card-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  transition: color 0.2s;
}
.card:hover .card-content h3 { color: #fff; }

.card-content p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 16px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tags span {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--muted);
}

.card-arrow {
  position: absolute;
  bottom: 24px;
  right: 24px;
  font-size: 18px;
  color: var(--muted);
  transition: color 0.2s, transform 0.2s;
}
.card:hover .card-arrow { color: var(--text); transform: translate(2px, -2px); }
.card-arrow-dim { opacity: 0.3; }

/* ── card icons ── */
.card-icon {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 56px;
}

/* envelope */
.envelope {
  position: relative;
  width: 54px;
  height: 38px;
}
.envelope-body {
  position: absolute;
  inset: 0;
  background: #f1ebde;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
}
.envelope-letter {
  width: 70%;
  height: 60%;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.35s ease;
}
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: #e8dfd2;
  clip-path: polygon(0 0, 50% 55%, 100% 0);
  z-index: 1;
  transform-origin: top;
  transition: transform 0.35s ease;
}
.card-letterhome:hover .envelope-flap { transform: rotateX(180deg); }
.card-letterhome:hover .envelope-letter { transform: translateY(-10px); }

/* mouse */
.mouse-icon { position: relative; display: flex; align-items: center; }
.mouse-body {
  width: 30px;
  height: 46px;
  border: 2px solid #666;
  border-radius: 15px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 1px;
  background: #333;
}
.mouse-btn {
  background: #222;
  transition: background 0.15s;
}
.mouse-btn.active { background: #444; }
.mouse-scroll {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 4px;
}
.mouse-scroll::before {
  content: '';
  width: 3px;
  height: 8px;
  background: #555;
  border-radius: 2px;
}
.click-ripple {
  position: absolute;
  left: -4px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
}
.card-clickguard:hover .click-ripple {
  animation: ripple 0.8s ease-out forwards;
}
.card-clickguard:hover .mouse-btn-left {
  animation: clickFlash 0.15s 0.1s ease both, clickFlash 0.15s 0.25s ease both;
  background: #777;
}
@keyframes clickFlash {
  0%   { background: #fff; }
  100% { background: #444; }
}
@keyframes ripple {
  0%   { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* glitch 404 */
.glitch-text {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  position: relative;
  letter-spacing: -1px;
}
.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}
.card-404:hover .glitch-text::before {
  color: #f87171;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  animation: glitch-top 0.4s steps(1) infinite;
  opacity: 1;
}
.card-404:hover .glitch-text::after {
  color: #60a5fa;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  animation: glitch-bot 0.4s steps(1) 0.05s infinite;
  opacity: 1;
}
@keyframes glitch-top {
  0%   { transform: translate(0); }
  25%  { transform: translate(-3px, -1px); }
  50%  { transform: translate(2px, 0); }
  75%  { transform: translate(-1px, 1px); }
  100% { transform: translate(0); }
}
@keyframes glitch-bot {
  0%   { transform: translate(0); }
  25%  { transform: translate(3px, 1px); }
  50%  { transform: translate(-2px, 0); }
  75%  { transform: translate(1px, -1px); }
  100% { transform: translate(0); }
}

/* wip */
.wip-icon {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wip-maple { font-size: 32px; line-height: 1; }
.wip-bar-wrap {
  width: 80px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.wip-bar {
  height: 100%;
  width: 45%;
  background: linear-gradient(90deg, var(--green), #86efac);
  border-radius: 2px;
  animation: progress 3s ease-in-out infinite alternate;
}
@keyframes progress {
  0%   { width: 30%; }
  100% { width: 65%; }
}

/* card-specific accents */
.card-letterhome::before { background: radial-gradient(ellipse at top left, rgba(240,235,222,0.06), transparent 60%); }
.card-letterhome:hover::before { opacity: 1; }
.card-clickguard::before { background: radial-gradient(ellipse at top left, rgba(240,160,32,0.06), transparent 60%); }
.card-clickguard:hover::before { opacity: 1; }
.card-404::before { background: radial-gradient(ellipse at top left, rgba(96,165,250,0.06), transparent 60%); }
.card-404:hover::before { opacity: 1; }
.card-wip { opacity: 0.75; cursor: default; }
.card-wip:hover { border-color: rgba(74,222,128,0.25); opacity: 1; }

/* scroll reveal */
.card {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease, border-color 0.25s, box-shadow 0.25s;
}
.card.revealed {
  opacity: 1;
  transform: translateY(0);
}
.card:nth-child(1) { transition-delay: 0s; }
.card:nth-child(2) { transition-delay: 0.08s; }
.card:nth-child(3) { transition-delay: 0.16s; }
.card:nth-child(4) { transition-delay: 0.24s; }

/* ── more section ── */
.more {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 100px;
}
.more-text {
  font-size: 15px;
  color: var(--muted);
  max-width: 400px;
}
.more-text a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-hover);
  transition: color 0.2s;
}
.more-text a:hover { color: var(--accent); }

/* ── footer ── */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
footer a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--text); }
.footer-sep { opacity: 0.4; }

/* ── responsive ── */
@media (max-width: 680px) {
  nav { padding: 16px 20px; }
  .hero { padding: 100px 16px 60px; gap: 36px; }
  .cards { grid-template-columns: 1fr; }
  .projects { padding: 60px 16px; }
  .more { padding: 0 16px 60px; }
  .terminal-body { font-size: 12px; padding: 16px; }
}
