:root {
  --bg: #f5f4ef;
  --ink: #1a1a1a;
  --accent: #e2572b;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
}

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

/* No rounded corners anywhere: no rounded tap highlight on touch */
* {
  -webkit-tap-highlight-color: transparent;
}

/* shapes drawn as boxes rather than glyphs: squares and triangles stay
   sharp, circles are the only round shape */
.shape-circle {
  border-radius: 50%;
}

.shape-up {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.shape-down {
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  touch-action: manipulation; /* taps go straight to the spider, no double-tap zoom */
  -webkit-user-select: none; /* a long press doesn't select the name or the bug */
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none; /* no rubber-band bounce on phones */
}

.scene {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* loading intro (intro.js): the name resolves out of digits, then the dot
   of the "i" moves to the middle and becomes the spider's body */
.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease;
}

html:not(.intro) .intro-screen {
  display: none;
}

.intro-screen.done {
  opacity: 0;
  pointer-events: none;
}

.intro-name {
  font-size: clamp(44px, 7vw, 104px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: pre;
  text-align: left; /* pinned left: the "i" never moves as later letters settle */
  transition: opacity 0.3s ease;
}

.intro-name.gone {
  opacity: 0;
}

.intro-dot {
  position: fixed;
  left: 0;
  top: 0;
  background: var(--ink);
  opacity: 0;
  transition: background-color 0.25s ease;
}

.intro-dot.lifted {
  background: var(--accent);
}

/* the spider (spider.js): strings and shapes, the body orange */
.graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.graph .link {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
}

.graph .spider-target {
  fill: var(--accent);
}

.graph .node-shape {
  fill: var(--ink);
  stroke: none;
}

.graph rect.node-shape {
  shape-rendering: crispEdges;
}

.graph .root .node-shape {
  fill: var(--accent);
}

/* the cockroach's shield, wings and abdomen: outlines filled with the page
   colour, so what's underneath is hidden; the abdomen's seams are dashed */
.graph .shell {
  fill: var(--bg);
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linejoin: miter;
}

.graph .seam {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

/* lines stay 1px however much a bug is scaled down */
.graph .link,
.graph .shell,
.graph .seam {
  vector-effect: non-scaling-stroke;
}

/* the bug switch: a shape in the top right corner (app.js) */
.bug-switch {
  all: unset;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.bug-switch svg {
  width: 20px;
  height: 20px;
  overflow: visible;
}

.bug-switch .switch-shape {
  fill: var(--ink);
}

.bug-switch rect.switch-shape {
  shape-rendering: crispEdges;
}

.bug-switch:hover .switch-shape {
  fill: var(--accent);
}

.bug-switch:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -6px;
}

/* it waits for the intro to finish */
html.intro .bug-switch {
  opacity: 0;
  pointer-events: none;
}

html.intro.revealed .bug-switch {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.5s ease 0.25s;
}
