:root {
  --bg: #0b0d12;
  --surface: #10131a;
  --fg: #e9ebf1;
  --text: #c3c7d2;
  --muted: #868c9c;
  --line: #222632;
  --accent: #8ab4ff;
  --panel-w: 360px;
  --drawer-w: 440px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

/* Invisible box the cube is centred in; it shrinks when the drawer opens. */
#stage {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--panel-w);
  right: 0;
  pointer-events: none;
  transition: right 0.5s var(--ease), bottom 0.5s var(--ease);
}
body.drawer-open #stage { right: var(--drawer-w); }

/* ---------- side panel ---------- */

.panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 32px 28px 24px;
  overflow-y: auto;
  background: linear-gradient(90deg, rgba(11, 13, 18, 0.96) 78%, rgba(11, 13, 18, 0));
}

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 99px; }
.view-switch button {
  padding: 4px 12px;
  border: 0;
  border-radius: 99px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.view-switch button:hover { color: var(--fg); }
.view-switch button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.1); color: var(--fg); }
.no-webgl .view-switch { display: none; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--fg); }
.brand svg { width: 34px; height: 32px; color: var(--accent); transition: color 0.4s; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; }
.tagline { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.sections ul { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 2px; }
.sections a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.sections a:hover { color: var(--fg); background: rgba(255, 255, 255, 0.04); }
.sections a[aria-current] { color: var(--fg); background: rgba(255, 255, 255, 0.07); }
.dot { width: 10px; height: 10px; flex: none; border-radius: 3px; background: var(--accent); }
.num { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.5; }

.info .kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}
.info h2 { margin: 0 0 12px; font-size: 36px; line-height: 1.1; letter-spacing: -0.01em; }
.info .blurb, .info .intro { margin: 0 0 20px; color: var(--text); font-size: 15px; line-height: 1.6; }

.projects { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.projects a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.projects .t { display: block; font-size: 15px; font-weight: 600; transition: color 0.2s; }
.projects .m { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.projects a:hover .t { color: var(--accent); }

.hint { margin: auto 0 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  text-align: center;
}

/* ---------- project drawer ---------- */

#drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--drawer-w), 100vw);
  padding: 24px 32px 40px;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.5s var(--ease);
}
body.drawer-open #drawer { transform: none; }

#drawer .close {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  margin: 0 -12px 0 12px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
#drawer .close:hover { border-color: var(--muted); }
#drawer .kicker { margin: 8px 0 10px; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
#drawer h3 { margin: 0 0 14px; font-size: 28px; line-height: 1.15; outline: none; }
.media img { display: block; width: 100%; margin-bottom: 20px; border-radius: 10px; }
.summary { margin: 0 0 16px; color: #d5d8e0; font-size: 17px; line-height: 1.55; }
.body p { margin: 0 0 14px; color: var(--text); line-height: 1.65; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0; padding: 0; list-style: none; }
.tags li { padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.btn.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.pager a { color: var(--muted); text-decoration: none; }
.pager a:hover { color: var(--fg); }
.pager a:last-child { text-align: right; }

/* ---------- tooltip ---------- */

#tip {
  position: fixed;
  z-index: 10;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(16, 19, 26, 0.94);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(14px, 16px);
}
#tip[hidden] { display: none; }

.noscript { position: fixed; inset: auto 0 0; margin: 0; padding: 16px; text-align: center; color: var(--muted); }

/* Without WebGL the panel is the page. */
.no-webgl #scene, .no-webgl .hint { display: none; }
.no-webgl .panel { background: none; width: min(640px, 100%); }
html:has(body.no-webgl), body.no-webgl { overflow: auto; }

/* ---------- phones and narrow windows ---------- */

@media (max-width: 820px) {
  .panel { display: contents; }

  .brand-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 14px 16px 10px;
    background: linear-gradient(rgba(11, 13, 18, 0.96) 75%, rgba(11, 13, 18, 0));
  }
  .tagline, .num, .hint { display: none; }
  .sections ul {
    display: flex;
    gap: 6px;
    margin: 12px -16px 0;
    padding: 0 16px 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sections a { padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 14px; white-space: nowrap; }
  .sections a[aria-current] { border-color: var(--accent); }

  .info {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 36vh;
    overflow-y: auto;
    padding: 28px 16px 20px;
    background: linear-gradient(rgba(11, 13, 18, 0), rgba(11, 13, 18, 0.96) 24px);
  }
  .info h2 { font-size: 28px; }

  #stage { left: 0; right: 0; top: var(--header-h, 110px); bottom: 36vh; }
  body.drawer-open #stage { right: 0; bottom: 62vh; }

  #drawer {
    top: auto;
    left: 0;
    width: 100%;
    height: 62vh;
    padding: 20px 20px 32px;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  #drawer .close { margin-right: -4px; }

  .no-webgl .info { position: static; max-height: none; padding: calc(var(--header-h, 110px) + 8px) 16px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
