/* Same tokens as nirmichalovitz.com: one neutral family (zinc), one accent (emerald), dark only. */
:root {
  color-scheme: dark;
  --bg: #0c0c0e;
  --surface: #17171a;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --line: #27272a;
  --accent: #34d399;
  --accent-fg: #052e1f;
  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
p,
ol,
ul,
dl,
dd {
  margin: 0;
}
ol,
ul {
  padding: 0;
  list-style: none;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  cursor: pointer;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
[hidden] {
  display: none !important;
}

.glow {
  position: absolute;
  inset: 0 0 auto 0;
  height: 44rem;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(50% 60% at 78% 0%, color-mix(in oklab, var(--accent) 11%, transparent), transparent 70%),
    radial-gradient(40% 50% at 10% 0%, color-mix(in oklab, var(--accent) 5%, transparent), transparent 70%);
}

.wrap {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 640px) {
  .wrap {
    padding: 0 1.5rem;
  }
}

.icon {
  width: 1rem;
  height: 1rem;
  flex: none;
}
.muted {
  color: var(--muted);
}
.ink {
  color: var(--text);
}
.accent {
  color: var(--accent);
}
.mono-xs {
  font-family: var(--mono);
  font-size: 0.75rem;
}
.mono-sm {
  font-family: var(--mono);
  font-size: 0.875rem;
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 200ms ease;
}
.intro {
  padding-top: 2.5rem;
}
@media (min-width: 768px) {
  .intro {
    padding-top: 3.5rem;
  }
}
h1 {
  font-size: 2.25rem;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.035em;
}
@media (min-width: 768px) {
  h1 {
    font-size: 3rem;
  }
}
.lead {
  margin-top: 1.25rem;
  max-width: 56ch;
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 1.25rem;
  border-radius: 9999px;
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition:
    transform 160ms var(--ease-out),
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease,
    opacity 200ms ease;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.btn-sm {
  height: 2.375rem;
  padding: 0 1rem;
  font-size: 0.875rem;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-ghost {
  border: 1px solid var(--line);
}
.btn .label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background: var(--accent);
    color: var(--accent-fg);
  }
  .btn-ghost:not(:disabled):hover {
    border-color: var(--muted);
  }
  .back:hover {
    color: var(--text);
  }
}

/* ---------- Panel ---------- */

main > section:last-child {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
}
@media (min-width: 768px) {
  main > section:last-child {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }
}
.tt {
  overflow: hidden;
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 768px) {
  .controls {
    padding: 1rem 1.5rem;
  }
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .actions {
    margin-left: auto;
  }
}
.speed {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.25rem;
}
.speed input {
  width: 6rem;
  accent-color: var(--accent);
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9999px;
}
.seg-btn {
  min-width: 2.5rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: 9999px;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  transition:
    background-color 200ms ease,
    color 200ms ease;
}
.seg-btn[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
}
@media (hover: hover) and (pointer: fine) {
  .seg-btn[aria-pressed='false']:hover {
    color: var(--text);
  }
}

.body {
  display: grid;
}
@media (min-width: 768px) {
  .body {
    grid-template-columns: minmax(0, 1fr) 19rem;
  }
}
.stage {
  min-width: 0;
  padding: 0.75rem;
}
@media (min-width: 640px) {
  .stage {
    padding: 1.25rem;
  }
}
@media (min-width: 768px) {
  .stage {
    padding: 1.5rem;
  }
}
#tt-svg {
  display: block;
  width: 100%;
  height: auto;
}
.status {
  margin-top: 0.75rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
}

.side {
  padding: 1.25rem;
  border-top: 1px solid var(--line);
}
@media (min-width: 768px) {
  .side {
    padding: 1.5rem;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}
.side h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.side .mono-sm {
  margin-top: 0.25rem;
}
.hint {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}
.path {
  display: grid;
  gap: 0.375rem;
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
}
.path li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}
.path .where {
  white-space: pre;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.stats dt {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--muted);
}
.stats dd {
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 1.125rem;
}
.log {
  display: grid;
  gap: 0.375rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.log li:first-child {
  color: var(--text);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.legend li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.legend-flag {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
}
.legend-turn {
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}
.legend-held {
  width: 18px;
  height: 2px;
  background: var(--accent);
}

.foot {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}
.foot a {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.25em;
  transition: text-decoration-color 200ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .foot a:hover {
    text-decoration-color: var(--accent);
  }
}

/* ---------- The bracket. Tokens glide between locks with a CSS transform. ---------- */

.tt-edge {
  stroke: #2c2c31;
  stroke-width: 2;
  transition: stroke 250ms ease;
}
.tt-edge[data-state='contending'] {
  stroke: #52525b;
}
.tt-edge[data-state='held'] {
  stroke: var(--accent);
}
.tt-lock rect.box {
  fill: var(--bg);
  stroke: #3f3f46;
  stroke-width: 1.5;
  transition: stroke 250ms ease;
}
.tt-lock[data-held='true'] rect.box {
  stroke: var(--accent);
}
.tt-lock .flag {
  fill: transparent;
  stroke: #52525b;
  transition:
    fill 200ms ease,
    stroke 200ms ease;
}
.tt-lock .flag[data-on='true'] {
  fill: var(--accent);
  stroke: var(--accent);
}
.tt-lock .turn {
  stroke: var(--text);
  stroke-width: 2;
  stroke-linecap: round;
  transition: transform 200ms var(--ease-out);
}
.tt-lock text,
.tt-cs text,
.tt-bits {
  font-family: var(--mono);
  font-size: 12px;
  fill: var(--muted);
}
.tt-cs rect {
  fill: var(--bg);
  stroke: #3f3f46;
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  transition: stroke 250ms ease;
}
.tt-cs[data-busy='true'] rect {
  stroke: var(--accent);
  stroke-dasharray: none;
}
.tt-token {
  cursor: pointer;
  transition:
    transform 320ms var(--ease-out),
    opacity 300ms ease;
}
.tt-token circle {
  fill: #27272a;
  stroke: #52525b;
  stroke-width: 1.5;
  transition:
    fill 200ms ease,
    stroke 200ms ease;
}
.tt-token text {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  fill: var(--text);
  pointer-events: none;
}
.tt-token[data-blocked='true'] circle {
  stroke-dasharray: 3 3;
}
.tt-token[data-inside='true'] circle {
  fill: var(--accent);
  stroke: var(--accent);
}
.tt-token[data-inside='true'] text {
  fill: var(--accent-fg);
}
.tt-token[data-done='true'] {
  opacity: 0.35;
}
.tt-token[data-selected='true'] circle {
  stroke: var(--text);
  stroke-width: 2.5;
}
.tt-token:focus-visible {
  outline: none;
}
.tt-token:focus-visible circle {
  stroke: var(--accent);
  stroke-width: 3;
}

@media (prefers-reduced-motion: reduce) {
  .tt-token,
  .tt-lock .turn,
  .btn {
    transition: none;
  }
  .btn:active {
    transform: none;
  }
}
/* ?still: every change lands instantly, so screenshots never catch a half-finished transition. */
.still .tt * {
  transition: none !important;
}
