:root {
  --bg: #0a0a08;
  --bg-raised: #131311;
  --bg-surface: #1a1a17;
  --ink: #e8e2d6;
  --muted: #a8a090;
  --accent: #c8a050;
  --accent-dim: rgba(200, 160, 80, 0.25);
  --accent-glow: rgba(200, 160, 80, 0.15);
  --accent-2: #70efde;
  --line: #2a2a24;
  --line-strong: #3e3e36;

  --theme: #c8a050;
  --theme-dim: rgba(200, 160, 80, 0.25);
  --theme-glow: rgba(200, 160, 80, 0.12);
  --theme-subtle: rgba(200, 160, 80, 0.06);

  --face-home: #364038;
  --face-projects: #2a3a3e;
  --face-about: #403830;
  --face-socials: #3c3040;
  --face-now: #2a3640;
  --face-contact: #403232;
  --stripe-home: #6aaa6e;
  --stripe-projects: #5a9aba;
  --stripe-about: #ba9a5a;
  --stripe-socials: #aa6a9a;
  --stripe-now: #6a9aaa;
  --stripe-contact: #9a6a6a;
}

body[data-face="home"]    { --theme: #6aaa6e; --theme-dim: rgba(106,170,110,0.25); --theme-glow: rgba(106,170,110,0.12); --theme-subtle: rgba(106,170,110,0.06); }
body[data-face="projects"]{ --theme: #5a9aba; --theme-dim: rgba(90,154,186,0.25);  --theme-glow: rgba(90,154,186,0.12);  --theme-subtle: rgba(90,154,186,0.06); }
body[data-face="about"]   { --theme: #ba9a5a; --theme-dim: rgba(186,154,90,0.25);  --theme-glow: rgba(186,154,90,0.12);  --theme-subtle: rgba(186,154,90,0.06); }
body[data-face="socials"] { --theme: #aa6a9a; --theme-dim: rgba(170,106,154,0.25); --theme-glow: rgba(170,106,154,0.12); --theme-subtle: rgba(170,106,154,0.06); }
body[data-face="now"]     { --theme: #6a9aaa; --theme-dim: rgba(106,154,170,0.25); --theme-glow: rgba(106,154,170,0.12); --theme-subtle: rgba(106,154,170,0.06); }
body[data-face="contact"] { --theme: #9a6a6a; --theme-dim: rgba(154,106,106,0.25); --theme-glow: rgba(154,106,106,0.12); --theme-subtle: rgba(154,106,106,0.06); }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Space Mono", monospace;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><line x1="8" y1="0" x2="8" y2="6" stroke="%23c8a050" stroke-width="0.8"/><line x1="8" y1="10" x2="8" y2="16" stroke="%23c8a050" stroke-width="0.8"/><line x1="0" y1="8" x2="6" y2="8" stroke="%23c8a050" stroke-width="0.8"/><line x1="10" y1="8" x2="16" y2="8" stroke="%23c8a050" stroke-width="0.8"/></svg>') 8 8, crosshair;
}

#starfield { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.grid-floor {
  position: fixed; bottom: 0; left: -25%; width: 150%; height: 55vh;
  background:
    repeating-linear-gradient(90deg, var(--theme-dim) 0px, var(--theme-dim) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(0deg, var(--theme-dim) 0px, var(--theme-dim) 1px, transparent 1px, transparent 40px);
  transform-origin: center bottom;
  transform: perspective(600px) rotateX(70deg);
  mask-image: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%);
  opacity: 0.5; z-index: 1; pointer-events: none;
  transition: background 400ms ease;
}

.orb {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 1;
  animation: orb-drift 20s ease-in-out infinite;
  transition: background 600ms ease;
}
.orb-1 { width: 700px; height: 700px; top: -200px; left: -150px; background: radial-gradient(circle, var(--theme) 0%, transparent 65%); opacity: 0.14; filter: blur(60px); }
.orb-2 { width: 600px; height: 600px; bottom: -150px; right: -150px; background: radial-gradient(circle, var(--accent-2) 0%, transparent 65%); opacity: 0.1; filter: blur(60px); animation-delay: -10s; animation-direction: reverse; }

.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background: repeating-linear-gradient(0deg, transparent 0px, transparent 2px, rgba(0,0,0,0.06) 2px, rgba(0,0,0,0.06) 4px);
}

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle, var(--theme-dim) 1px, transparent 1px);
  background-size: 28px 28px; opacity: 0.45;
  animation: dot-breathe 6s ease-in-out infinite;
}

body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 25%, rgba(0,0,0,0.5) 65%, rgba(0,0,0,0.8) 100%);
}

.pixel-scene, .scene-stars, .scene-city, .scene-grid { display: none; }

/* ─── Topbar ─── */
.topbar {
  position: sticky; top: 0; z-index: 12;
  display: flex; gap: 1rem; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(10,10,8,0.9);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--theme-subtle), 0 4px 30px var(--theme-subtle);
}

.topbar::before {
  content: ""; display: block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--theme-dim);
  box-shadow: 16px 0 0 var(--theme-dim), 32px 0 0 var(--theme-dim);
  flex-shrink: 0;
  transition: background 400ms ease, box-shadow 400ms ease;
}

.logo {
  color: var(--accent); text-decoration: none; font-family: "Press Start 2P", cursive;
  font-size: 0.86rem; letter-spacing: 0.05em;
  text-shadow: 0 0 15px var(--accent-glow), 0 0 40px rgba(200,160,80,0.06);
}
.logo::after { content: "_"; display: inline-block; color: var(--accent); animation: cursor-blink 1s step-end infinite; margin-left: 0.1em; }

.face-icon { opacity: 0.5; font-size: 0.85em; }
.face-link, .card, a, button, .face-nav button { cursor: pointer; }

/* ─── Nav ─── */
.face-nav { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: flex-end; }

.face-nav button {
  position: relative; border: none; background: transparent; color: var(--muted);
  padding: 0.4rem 0.3rem; font-family: "Space Mono", monospace; font-size: 0.75rem;
  font-weight: 700; letter-spacing: 0.06em; line-height: 1; cursor: pointer;
  box-shadow: none; transition: color 160ms ease, text-shadow 200ms ease;
}
.face-nav button::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--theme); transform: scaleX(0); transform-origin: center;
  transition: transform 160ms ease, background 400ms ease;
}
.face-nav button:hover, .face-nav button:focus-visible { color: var(--ink); text-shadow: 0 0 10px var(--theme-glow); outline: none; }
.face-nav button:hover::after, .face-nav button:focus-visible::after { transform: scaleX(1); }
.face-nav button.active { color: var(--theme); text-shadow: 0 0 14px var(--theme-glow); }
.face-nav button.active::after { transform: scaleX(1); }
.face-nav button.active::before {
  content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; background: var(--theme); border-radius: 50%;
  box-shadow: 0 0 8px var(--theme);
  transition: background 400ms ease, box-shadow 400ms ease;
}

/* ─── Main ─── */
main { position: relative; z-index: 4; width: 100%; margin: 0 auto; padding: 0; }
main::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 999;
  filter: url(#noise); opacity: 0.03; background: rgba(255,255,255,0.5);
}

/* ─── Hero ─── */
.hero {
  min-height: calc(100vh - 50px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 0.4rem; position: relative; z-index: 4; padding: 1rem;
}

.hud-corner { position: absolute; width: 30px; height: 30px; pointer-events: none; z-index: 5; opacity: 0.4; transition: border-color 400ms ease; }
.hud-tl { top: 0.5rem; left: 1rem; border-top: 2px solid var(--theme); border-left: 2px solid var(--theme); }
.hud-tr { top: 0.5rem; right: 1rem; border-top: 2px solid var(--theme); border-right: 2px solid var(--theme); }
.hud-bl { bottom: 0.5rem; left: 1rem; border-bottom: 2px solid var(--theme); border-left: 2px solid var(--theme); }
.hud-br { bottom: 0.5rem; right: 1rem; border-bottom: 2px solid var(--theme); border-right: 2px solid var(--theme); }

.hero-kicker {
  margin: 0; color: var(--accent); font-size: 0.9rem; letter-spacing: 0.2em;
  font-weight: 700; font-family: "Press Start 2P", cursive;
  text-shadow: 0 0 20px var(--accent-glow);
}

h1, h2, h3 { margin: 0; font-family: "Press Start 2P", cursive; line-height: 1.45; }
h1 {
  font-size: clamp(0.85rem, 2.5vw, 1.2rem); color: var(--muted);
  text-shadow: 0 0 30px var(--theme-glow);
  min-height: 1.5em; margin-bottom: 0.5rem;
}

/* ─── Cube viewport ─── */
.cube-viewport {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}

.hud-readout {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-family: "Space Mono", monospace; font-size: 0.6rem; font-weight: 700;
  color: var(--theme); opacity: 0.5; letter-spacing: 0.05em; line-height: 1.8;
  white-space: nowrap; transition: color 400ms ease;
}
.hud-left { right: calc(50% + 300px); text-align: right; }
.hud-right { left: calc(50% + 300px); text-align: left; }
.hud-line { padding: 0.1rem 0; }

/* ─── Cube — BIGGER ─── */
.cube-shell {
  --size: clamp(300px, 45vw, 420px);
  width: calc(var(--size) + 40px); height: calc(var(--size) + 40px);
  position: relative; display: grid; place-items: center;
  perspective: 1200px; transform-style: preserve-3d;
  touch-action: none; user-select: none; cursor: grab;
}
.cube-shell.dragging { cursor: grabbing; }

.cube-glow {
  position: absolute;
  width: calc(var(--size) + 220px); height: calc(var(--size) + 220px);
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--theme-dim) 0%, var(--theme-glow) 30%, var(--theme-subtle) 55%, transparent 75%);
  filter: blur(25px);
  animation: glow-pulse 5s ease-in-out infinite;
  transition: background 600ms ease;
}

.cube-reflection {
  width: 400px; height: 60px; margin-top: -15px;
  background: radial-gradient(ellipse at center, var(--theme-dim) 0%, var(--theme-glow) 30%, var(--theme-subtle) 55%, transparent 75%);
  filter: blur(20px); opacity: 0.8; transition: background 400ms ease;
}

.cube {
  position: relative; width: var(--size); height: var(--size);
  transform-style: preserve-3d; will-change: transform;
}

/* ─── Faces ─── */
.face {
  position: absolute; inset: 0;
  display: flex; align-items: stretch; justify-content: stretch;
  border: 1px solid rgba(255,255,255,0.12); border-top: 3px solid var(--line-strong);
  color: var(--ink); overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -2px 8px rgba(0,0,0,0.3),
    0 0 0 1px rgba(0,0,0,0.6),
    4px 4px 0 rgba(0,0,0,0.5),
    0 0 30px rgba(0,0,0,0.4);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

/* Ensure all face children also hide their backfaces */
.face *, .face::before, .face::after {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Face crosshatch + gradient + edge glow */
.face::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 8px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 8px),
    linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.2) 100%);
  z-index: 0;
}

/* Inner edge highlight on faces */
.face::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  border: 1px solid rgba(255,255,255,0.05);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(0,0,0,0.2);
}

.face-front  { transform: translateZ(calc(var(--size)/2)); background: linear-gradient(145deg, #3a4a3c 0%, var(--face-home) 40%, #2a352c 100%); border-top-color: var(--stripe-home); }
.face-right  { transform: rotateY(90deg) translateZ(calc(var(--size)/2)); background: linear-gradient(145deg, #344a50 0%, var(--face-projects) 40%, #1e2e34 100%); border-top-color: var(--stripe-projects); }
.face-back   { transform: rotateY(180deg) translateZ(calc(var(--size)/2)); background: linear-gradient(145deg, #4a4234 0%, var(--face-about) 40%, #302a22 100%); border-top-color: var(--stripe-about); }
.face-left   { transform: rotateY(-90deg) translateZ(calc(var(--size)/2)); background: linear-gradient(145deg, #46344a 0%, var(--face-socials) 40%, #2c2030 100%); border-top-color: var(--stripe-socials); }
.face-top    { transform: rotateX(90deg) translateZ(calc(var(--size)/2)); background: linear-gradient(145deg, #344050 0%, var(--face-now) 40%, #1e2a34 100%); border-top-color: var(--stripe-now); }
.face-bottom { transform: rotateX(-90deg) translateZ(calc(var(--size)/2)); background: linear-gradient(145deg, #4a3636 0%, var(--face-contact) 40%, #302222 100%); border-top-color: var(--stripe-contact); }

/* ─── Face content ─── */
.face-content {
  position: relative; z-index: 1; width: 100%; height: 100%;
  display: flex; flex-direction: column;
  padding: 0.8rem; overflow: hidden;
}

.face-label {
  font-family: "Space Mono", monospace; font-size: 0.55rem; font-weight: 700;
  letter-spacing: 0.12em; color: var(--muted); opacity: 0.7;
  margin-bottom: 0.6rem; text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 0.4rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.face-body {
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.5rem;
}

.face-title {
  font-family: "Press Start 2P", cursive; font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: var(--ink); margin: 0; line-height: 1.3;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.face-text {
  font-family: "Space Mono", monospace; font-size: clamp(0.58rem, 1.2vw, 0.7rem);
  color: var(--muted); line-height: 1.6; margin: 0;
}

.face-dim { opacity: 0.5; }

.face-hint {
  font-family: "Space Mono", monospace; font-size: 0.55rem;
  color: var(--accent); opacity: 0.5; margin: 0; margin-top: auto;
  letter-spacing: 0.05em;
}

/* ─── Face links (projects, socials, contact) ─── */
.face-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.6rem; margin: 0 -0.2rem;
  border: 1px solid rgba(255,255,255,0.06);
  border-left: 2px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.15);
  color: var(--ink); text-decoration: none;
  font-family: "Space Mono", monospace; font-size: clamp(0.55rem, 1.1vw, 0.68rem);
  font-weight: 700; letter-spacing: 0.04em;
  transition: border-color 160ms ease, background 160ms ease;
  cursor: pointer;
}

.face-link:hover {
  border-color: rgba(255,255,255,0.15);
  border-left-color: var(--accent);
  background: rgba(255,255,255,0.04);
}

.face-link-icon { opacity: 0.4; font-size: 0.9em; }
.face-link-arrow { margin-left: auto; opacity: 0.3; font-size: 0.85em; transition: opacity 160ms ease; }
.face-link:hover .face-link-arrow { opacity: 0.7; }

.hint {
  font-size: 0.75rem; color: var(--theme); letter-spacing: 0.06em; opacity: 0.5;
  text-shadow: 0 0 10px var(--theme-glow); transition: color 400ms ease;
  margin-top: 0.3rem;
}

/* ─── Statusbar ─── */
.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 12;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 1.2rem;
  border-top: 1px solid var(--line);
  background: rgba(10,10,8,0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-family: "Space Mono", monospace; font-size: 0.58rem;
  color: var(--muted); letter-spacing: 0.04em;
  box-shadow: 0 -2px 20px var(--theme-subtle);
  transition: box-shadow 400ms ease;
}
.status-left, .status-center, .status-right { flex: 1; }
.status-left { text-align: left; }
.status-center { text-align: center; opacity: 0.5; }
.status-right { text-align: right; opacity: 0.5; }
.status-dot { color: #6aaa6e; animation: cursor-blink 2s step-end infinite; margin-right: 0.3em; }

/* ─── TSLA Ticker ─── */
.tsla-up { color: #6aaa6e; }
.tsla-down { color: #9a6a6a; }

/* ─── Doing Widget ─── */
.doing-widget {
  border-left: 2px solid var(--stripe-now);
  padding-left: 0.5rem;
  font-size: clamp(0.52rem, 1vw, 0.62rem) !important;
  color: var(--ink) !important;
  opacity: 0.8;
  margin-top: 0.3rem;
}

/* ─── Keyframes ─── */
@keyframes dot-breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.25; } }
@keyframes glow-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(0.97); } }
@keyframes cursor-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes face-ring-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.15; } }
@keyframes orb-drift { 0%, 100% { transform: translate(0,0); } 25% { transform: translate(40px,-50px); } 50% { transform: translate(-25px,-60px); } 75% { transform: translate(-50px,-20px); } }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .face-nav { gap: 0.3rem; }
  .hud-readout { display: none; }
  .status-center { display: none; }
  .cube-shell { --size: clamp(260px, 70vw, 340px); }
}

@media (max-width: 480px) {
  .topbar { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .topbar::before { display: none; }
  .face-nav { width: 100%; justify-content: flex-start; }
  .hero-kicker { font-size: 0.75rem; }
  h1 { font-size: 0.75rem; }
  .hud-corner { display: none; }
  .status-right { display: none; }
  .cube-shell { --size: clamp(240px, 80vw, 300px); }
  .face-text { font-size: 0.55rem; }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .orb { animation: none !important; }
  #starfield { display: none; }
}
