/* ===== Themes ===== */
:root, [data-theme="fox"] {
  --bg: #0b0d12; --bg2: #121620; --card: rgba(20, 25, 36, .72);
  --text: #e6e9ef; --muted: #8b93a5; --line: rgba(255,255,255,.09);
  --fox-1: #ff8a2a; --fox-2: #e8590c; --fox-3: #9a3412;
  --accent: #ff8a2a; --glow: #22e6ff; --cream: #fff1e0; --ink: #1a0f08;
}
[data-theme="matrix"] {
  --bg: #020804; --bg2: #06140a; --card: rgba(4, 22, 10, .72);
  --text: #d1ffd9; --muted: #5fa56f; --line: rgba(80,255,120,.15);
  --fox-1: #3dff7a; --fox-2: #12b64a; --fox-3: #0a6b2c;
  --accent: #3dff7a; --glow: #eaffef; --cream: #c8ffd5; --ink: #02130a;
}
[data-theme="polar"] {
  --bg: #0a1220; --bg2: #101c32; --card: rgba(18, 32, 56, .72);
  --text: #eaf3ff; --muted: #8fa6c4; --line: rgba(160,200,255,.14);
  --fox-1: #ffffff; --fox-2: #b9d2ee; --fox-3: #6f8fb5;
  --accent: #7cc4ff; --glow: #7cc4ff; --cream: #ffffff; --ink: #0a1830;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background .5s, color .5s;
  overflow-x: hidden;
}
code, .term, .eyebrow, .tag, .status, .brand, .theme-btn, .num, .prompt, time {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
}
code { background: rgba(255,255,255,.07); padding: .1em .4em; border-radius: 5px; font-size: .9em; color: var(--accent); }
a { color: var(--accent); }
.accent { color: var(--accent); }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; }
.scanlines {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .35;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
}
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #000; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ===== Nav ===== */
.nav {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand-fox { width: 30px; height: 30px; }
.nav nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.nav nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: .92rem; transition: .2s; }
.nav nav a:hover { color: var(--text); background: rgba(255,255,255,.07); }
.theme-btn {
  background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-size: .85rem; transition: .2s;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Layout ===== */
main > section { max-width: 1180px; margin: 0 auto; padding: 96px clamp(16px, 4vw, 40px) 24px; }
h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); line-height: 1.1; margin: .3em 0; letter-spacing: -.02em; }
h2 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); margin: 0 0 .4em; }
h3 { margin: 0 0 .4em; font-size: 1.2rem; }
.num { color: var(--accent); font-size: .6em; vertical-align: middle; margin-right: .3em; opacity: .9; }
.sub { color: var(--muted); margin-top: -.2em; }
.tiny { color: var(--muted); font-size: .8rem; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.fox-species { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px;
  backdrop-filter: blur(8px); transition: transform .25s, border-color .25s, box-shadow .25s;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 40px -16px var(--accent); }

/* ===== Hero ===== */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; min-height: calc(100vh - 60px); padding-top: 40px !important; }
.eyebrow { color: var(--accent); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 var(--accent)} 70%{box-shadow:0 0 0 10px transparent} 100%{box-shadow:0 0 0 0 transparent} }
.typed-wrap { color: var(--accent); }
.caret { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lead { font-size: 1.15rem; color: #c7ccd8; max-width: 60ch; }
.lead p { margin: 0 0 .6em; }
[data-theme="matrix"] .lead { color: #aef0bb; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0; }
.btn {
  display: inline-block; text-decoration: none; color: var(--text); border: 1px solid var(--line);
  padding: 11px 20px; border-radius: 12px; font-weight: 600; cursor: pointer; background: transparent; font-size: 1rem;
  transition: .2s; font-family: inherit;
}
.btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.btn.primary { background: linear-gradient(135deg, var(--fox-1), var(--fox-2)); color: #140a02; border: 0; }
[data-theme="polar"] .btn.primary { color: #06101f; }
.btn.small { padding: 6px 14px; font-size: .85rem; }

.hero-stats { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 0; margin: 32px 0 8px; }
.hero-stats li { border-left: 2px solid var(--accent); padding-left: 12px; }
.hero-stats b { display: block; font-size: 1.7rem; font-family: ui-monospace, Menlo, Consolas, monospace; }
.hero-stats span { color: var(--muted); font-size: .8rem; line-height: 1.2; display: block; }

.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; opacity: .8; }
.glitch::before { color: var(--glow); animation: glitch1 4s infinite steps(1); clip-path: inset(0 0 55% 0); }
.glitch::after { color: var(--fox-2); animation: glitch2 4s infinite steps(1); clip-path: inset(55% 0 0 0); }
@keyframes glitch1 { 0%,92%,100%{transform:none;opacity:0} 93%{transform:translate(-3px,0);opacity:.8} 95%{transform:translate(3px,1px);opacity:.8} 97%{transform:none;opacity:0} }
@keyframes glitch2 { 0%,92%,100%{transform:none;opacity:0} 94%{transform:translate(3px,0);opacity:.8} 96%{transform:translate(-3px,-1px);opacity:.8} 98%{transform:none;opacity:0} }

.hero-art { text-align: center; }
.fox-wrap { position: relative; max-width: 420px; margin: 0 auto; cursor: pointer; }
#fox { width: 100%; height: auto; filter: drop-shadow(0 20px 50px color-mix(in srgb, var(--fox-1) 35%, transparent)); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-12px) rotate(-1deg); } }
#fox .circuit { stroke: var(--glow); stroke-width: 2; fill: none; stroke-linecap: round; stroke-dasharray: 90; animation: dash 3s linear infinite; }
#fox .circuit circle { fill: var(--glow); stroke: none; }
@keyframes dash { from { stroke-dashoffset: 180; } to { stroke-dashoffset: 0; } }
#fox .ear { transform-origin: center; }
#fox.wiggle .ear { animation: ear .4s 2; }
@keyframes ear { 50% { transform: rotate(6deg); } }
.hint { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.bubble {
  position: absolute; top: -6px; right: -4px; max-width: 220px; background: var(--text); color: #11151d;
  padding: 10px 14px; border-radius: 16px 16px 4px 16px; font-size: .9rem; line-height: 1.35; text-align: left;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: transform .25s, opacity .25s;
}
.bubble.pop { animation: pop .3s; }
@keyframes pop { from { transform: scale(.85); opacity: .3; } }

/* ===== About ===== */
.card p { margin: .5em 0; color: #c7ccd8; }
[data-theme="matrix"] .card p { color: #aef0bb; }
.timeline { margin-top: 36px; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; position: relative; }
.tl-item { border-top: 2px solid var(--accent); padding-top: 12px; position: relative; }
.tl-item::before { content: ""; position: absolute; top: -7px; left: 0; width: 12px; height: 12px; background: var(--accent); border-radius: 50%; }
.tl-item time { color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; }
.tl-item p { margin: .3em 0; color: var(--muted); font-size: .95rem; }

/* ===== Skills ===== */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px 40px; margin: 28px 0; }
.skill span { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92rem; }
.bar { height: 10px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--fox-2), var(--fox-1), var(--glow)); transition: width 1.4s cubic-bezier(.2,.8,.2,1); }
.in .bar i { width: calc(var(--v) * 1%); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips span { border: 1px solid var(--line); background: var(--card); padding: 6px 14px; border-radius: 99px; font-size: .88rem; transition: .2s; cursor: default; }
.chips span:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-3px) rotate(-2deg); }

/* ===== Projects ===== */
.project { position: relative; }
.tag { color: var(--glow); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.status { position: absolute; top: 20px; right: 20px; font-size: .72rem; padding: 3px 10px; border-radius: 99px; border: 1px solid; }
.status.ok { color: #4ade80; } .status.wip { color: #fbbf24; } .status.idea { color: #a78bfa; }

/* ===== Foxes ===== */
.species { text-align: center; cursor: pointer; }
.species p { font-size: .9rem; }
.swatch {
  width: 86px; height: 86px; margin: 0 auto 12px; background: linear-gradient(135deg, var(--c1), var(--c2));
  clip-path: polygon(50% 100%, 0 30%, 8% 0, 32% 24%, 68% 24%, 92% 0, 100% 30%);
  transition: transform .3s;
}
.species:hover .swatch { transform: scale(1.15) rotate(-6deg); }
.fact-box { margin-top: 24px; }
.fact-head { display: flex; justify-content: space-between; align-items: center; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); }
#fact { font-size: 1.1rem; min-height: 3.3em; margin-bottom: 0; color: var(--text); }

/* ===== Terminal ===== */
.term { background: #05070b; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px -30px #000; font-size: .92rem; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: #0e121a; color: var(--muted); }
.term-bar i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f56; }
.term-bar i:nth-child(2) { background: #ffbd2e; } .term-bar i:nth-child(3) { background: #27c93f; }
.term-bar span { margin-left: 10px; font-size: .8rem; }
.term-body { padding: 14px 16px 4px; height: 340px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; color: #d5dae6; }
.term-body .cmd { color: #fff; } .term-body .ok { color: #4ade80; } .term-body .acc { color: var(--accent); } .term-body .dim { color: var(--muted); } .term-body .err { color: #f87171; }
.term-input { display: flex; gap: 8px; padding: 6px 16px 14px; align-items: center; }
.prompt { color: var(--accent); white-space: nowrap; }
.term-input input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff; font: inherit; caret-color: var(--accent); }

/* ===== Contact / Footer ===== */
.contact { text-align: center; }
footer { text-align: center; padding: 60px 16px 40px; color: var(--muted); }
footer p { margin: .3em 0; }

/* ===== Reveal ===== */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .8s, transform .8s; }
.reveal.in { opacity: 1; transform: none; }

/* ===== Legal ===== */
.legal { max-width: 720px; margin: 0 auto; padding: 60px 20px; }

/* ===== Fox rain (Konami) ===== */
.rain { position: fixed; top: -50px; z-index: 200; pointer-events: none; font-size: 28px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; text-align: left; min-height: auto; }
  .hero-art { order: -1; }
  .fox-wrap { max-width: 260px; }
  .nav nav { display: none; }
  .theme-btn { margin-left: auto; }
}
@media (max-width: 520px) { .hero-stats { grid-template-columns: repeat(2, 1fr); } .bubble { right: -10px; top: -16px; max-width: 170px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .bar i { width: calc(var(--v) * 1%); }
}
