@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=IBM+Plex+Mono:wght@400;500&family=KaTeX_Main:wght@400&family=Patrick+Hand&display=swap");

:root {
  --bg: #0f1115;
  --ink: #e8eef7;
  --muted: #8b9bb4;
  --line: #3d4f6f;
  --blue: #58c4dd;
  --blue-dim: #3a8ea3;
  --yellow: #ffe66d;
  --panel: rgba(18, 22, 30, 0.92);
  --soft: rgba(88, 196, 221, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Patrick Hand", "Comic Sans MS", cursive;
  font-size: 17px;
  text-transform: lowercase;
  -webkit-font-smoothing: antialiased;
}

body * {
  text-transform: lowercase;
}

#canvas-root {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#canvas-root canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-title {
  margin: 0;
  font-family: "Caveat", cursive;
  font-size: clamp(2.8rem, 8vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--blue);
}

.boot-sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 18px;
  pointer-events: none;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hint.is-on {
  opacity: 1;
}

.equation {
  position: fixed;
  left: 18px;
  top: 18px;
  bottom: auto;
  z-index: 22;
  width: min(300px, calc(100vw - 36px));
  padding: 10px 12px;
  border: 1px solid rgba(88, 196, 221, 0.35);
  background: rgba(15, 17, 21, 0.88);
  backdrop-filter: blur(8px);
  color: var(--ink);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.equation.is-on {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.equation .eq-label {
  margin: 0 0 6px;
  color: var(--blue);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.equation .eq-math {
  margin: 0;
  font-family: "Times New Roman", "KaTeX_Main", serif;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #d7e7f5;
  line-height: 1.45;
}

.equation .eq-math * {
  text-transform: none;
}

.eq-controls {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.eq-controls label {
  display: grid;
  grid-template-columns: 18px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: none;
}

.eq-controls label span,
.eq-controls label output {
  text-transform: none;
  color: var(--blue);
}

.eq-controls output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.eq-controls input[type="range"] {
  width: 100%;
  accent-color: #58c4dd;
  cursor: pointer;
}

.equation .eq-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
}

.space-tab {
  pointer-events: auto;
  border: 1.5px solid rgba(88, 196, 221, 0.55);
  background: rgba(20, 28, 40, 0.88);
  color: var(--ink);
  font: inherit;
  font-family: "Caveat", cursive;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(88, 196, 221, 0.08), 0 8px 24px rgba(0, 0, 0, 0.35);
  transform: rotate(-2deg);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease, opacity 0.25s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.space-tab:hover,
.space-tab:focus-visible {
  transform: rotate(2deg) scale(1.05);
  background: var(--blue);
  color: #0f1115;
  border-color: var(--blue);
}

.space-tab.is-active {
  background: var(--blue);
  color: #0f1115;
  border-color: var(--blue);
  transform: rotate(0deg);
  box-shadow: 0 0 24px rgba(88, 196, 221, 0.35);
}

.space-tab.is-neighbor {
  border-color: var(--yellow);
  color: var(--yellow);
  opacity: 1;
  z-index: 2;
}

.space-tab.is-dim {
  opacity: 0.35;
}

.labels {
  display: none;
}

/* Compact bottom card — leaves most of the 3D view (and tabs) free */
.panel {
  position: fixed;
  left: 18px;
  right: auto;
  top: auto;
  bottom: 18px;
  z-index: 21;
  width: min(380px, calc(100vw - 36px));
  max-height: min(52vh, 480px);
  padding: 18px 16px 14px;
  border: 1px solid rgba(88, 196, 221, 0.35);
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  overflow: auto;
  overscroll-behavior: contain;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.panel[data-section="projects"] {
  width: min(320px, calc(100vw - 36px));
  max-height: min(48vh, 440px);
  padding: 14px 12px 12px;
}

.panel[data-section="projects"] h2 {
  font-size: 1.7rem;
  margin-bottom: 10px;
}

.panel[data-section="projects"] .proj h3 {
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.panel[data-section="projects"] .proj p {
  font-size: 0.85rem;
}

.panel[data-section="projects"] .mini-anim {
  aspect-ratio: 2.8 / 1;
  margin-bottom: 4px;
}

.panel[data-section="projects"] .proj-list {
  gap: 8px;
}

.panel[data-section="projects"] .proj {
  padding: 8px;
}

.panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.panel-close:hover {
  color: var(--blue);
}

.panel-body .kicker {
  margin: 0 0 4px;
  color: var(--blue);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
}

.panel-body h2 {
  margin: 0 0 14px;
  font-family: "Caveat", cursive;
  font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 700;
  line-height: 1;
  transform: rotate(-1deg);
  color: var(--ink);
}

.panel-body p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.4;
}

.panel-body strong {
  color: var(--ink);
}

.bits {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.bits li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(88, 196, 221, 0.15);
}

.bits li span:first-child {
  color: var(--muted);
}

.jobs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.jobs li {
  padding-left: 12px;
  border-left: 2px solid var(--blue);
}

.job-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.job-meta em {
  font-style: normal;
  border: 1px solid var(--yellow);
  color: var(--yellow);
  padding: 0 7px;
  font-family: "Caveat", cursive;
  font-weight: 700;
  transform: rotate(-3deg);
}

.jobs h3 {
  margin: 4px 0;
  font-family: "Caveat", cursive;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.jobs p {
  margin: 0;
  font-size: 0.92rem;
}

.proj-list {
  display: grid;
  gap: 12px;
}

.proj {
  display: block;
  padding: 12px;
  border: 1px solid rgba(88, 196, 221, 0.3);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.proj:hover,
.proj:focus-visible {
  transform: rotate(-1deg) scale(1.01);
  border-color: var(--blue);
}

.proj h3 {
  margin: 0 0 8px;
  font-family: "Caveat", cursive;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue);
}

.mini-anim {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2.4 / 1;
  border: 1px solid rgba(88, 196, 221, 0.25);
  background: #151922;
  margin-bottom: 8px;
}

.proj p {
  margin: 0;
  font-size: 0.95rem;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid rgba(88, 196, 221, 0.4);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: rotate(-1deg);
  border-color: var(--blue);
  color: var(--blue);
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #0f1115;
}

.btn.primary:hover {
  color: #0f1115;
  filter: brightness(1.08);
}

@media (max-width: 720px) {
  .panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 42vh;
    transform: translateY(18px);
  }

  .panel[data-section="projects"] {
    width: auto;
    max-height: 40vh;
  }

  .panel.is-open {
    transform: translateY(0);
  }

  .hint {
    display: none;
  }

  .equation {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot,
  .panel,
  .space-tab,
  .proj,
  .equation {
    transition: none;
  }
}
