/* Plotting on Ordinals' own: art/arcade.css has the rest. */

:root {
  --bead: #5ce1e6;
  --gone: #ff7a7a;
  --pt: #8fd0ff;
  --d1: #f6c85f;
  --d2: #8ee07a;
  --d3: #5ce1e6;
  --d4: #b59cff;
  --d5: #ff9ad5;
}

html,
body {
  overflow: auto;
}

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px 2rem;
  line-height: 1.45;
}

h1 {
  margin: 0.2rem 0 0.3rem;
  font-size: 1.6rem;
  color: var(--accent);
}

.lede {
  margin: 0 0 0.8rem;
  color: var(--dim);
  max-width: 52rem;
}

a {
  color: var(--accent);
}

var {
  font-style: italic;
}

sup {
  font-size: 0.72em;
  line-height: 0;
}

code,
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.acc {
  color: var(--accent);
}

.dim {
  color: var(--dim);
  font-size: 0.9rem;
}

/* ---- picking x ---- */

.controls {
  margin-bottom: 0.7rem;
}

.pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.pick label {
  font-weight: 700;
}

#ord {
  flex: 1 1 12rem;
  min-width: 0;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: rgb(0 0 0 / 22%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
}

#ord:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.error {
  min-height: 1.2em;
  margin: 0.25rem 0 0.2rem;
  color: var(--gone);
  font-size: 0.9rem;
}

.error:empty {
  min-height: 0;
  margin: 0.15rem 0;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.seg {
  display: inline-flex;
}

.seg button {
  border-radius: 0;
}

.seg button:first-child {
  border-radius: 10px 0 0 10px;
}

.seg button:last-child {
  border-radius: 0 10px 10px 0;
}

.seg button + button {
  margin-left: -1px;
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  font-size: inherit;
}

/* ---- the ruler ---- */

figure {
  margin: 0 0 0.8rem;
  padding: 0.6rem;
  border-radius: 14px;
  background: rgb(0 0 0 / 18%);
  border: 1px solid var(--line);
}

.fig-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.3rem;
}

.weight {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  flex: 1 1 16rem;
  min-width: 0;
}

.weight output {
  color: var(--accent);
  min-width: 8.5em;
  font-variant-numeric: tabular-nums;
}

.weight input {
  flex: 1 1 8rem;
  min-width: 6rem;
  accent-color: var(--accent);
}

.zoom button {
  min-width: 2.4rem;
}

#ruler {
  display: block;
  width: 100%;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

#ruler:active {
  cursor: grabbing;
}

figcaption {
  margin: 0.2rem 0.3rem 0;
  min-height: 1.5em;
  font-variant-numeric: tabular-nums;
}

svg text {
  fill: var(--dim);
  font-family: inherit;
}

svg .lab {
  fill: var(--ink);
}

svg .lab.tower {
  fill: var(--accent);
  font-weight: 700;
}

svg .small {
  font-size: 12px;
  fill: var(--dim);
}

.axis {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.tk {
  stroke: var(--ink);
  stroke-width: 1;
}

.tk.tower {
  stroke: var(--accent);
  stroke-width: 2;
}

.tk.hi {
  stroke: var(--bead);
  stroke-width: 2.5;
  opacity: 1 !important;
}

.xline {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
  opacity: 0.8;
}

.xline.solid {
  stroke-dasharray: none;
  stroke-width: 2.5;
}

.xmark {
  fill: var(--accent);
}

svg .xlab {
  fill: var(--accent);
  font-weight: 700;
}

.bead {
  fill: var(--bead);
}

.gap {
  stroke: var(--gone);
  stroke-width: 2;
  marker: none;
}

svg .gaplab {
  fill: var(--gone);
}

/* ---- the steps ---- */

.card {
  width: auto;
  padding: 0.8rem 1rem;
}

.card h2 {
  font-size: 1.1rem;
  margin: 0 0 0.4rem;
}

.card.wide {
  margin-bottom: 0.8rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  counter-increment: step;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgb(0 0 0 / 14%);
  min-width: 0;
}

.steps h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
}

.steps h3::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.45em;
  height: 1.45em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: var(--accent);
  color: #2b2410;
  font-size: 0.85em;
}

.steps p {
  margin: 0.3rem 0;
  overflow-wrap: anywhere;
}

.big {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

#tree {
  display: block;
  width: 100%;
  max-height: 15rem;
}

.edge {
  stroke: var(--dim);
  stroke-width: 2;
}

.node {
  stroke: var(--night);
  stroke-width: 2;
  cursor: default;
}

.node.d0 {
  fill: var(--accent);
}
.node.d1 {
  fill: var(--d2);
}
.node.d2 {
  fill: var(--d3);
}
.node.d3 {
  fill: var(--d4);
}
.node.d4,
.node.d5 {
  fill: var(--d5);
}

.node.hi {
  stroke: var(--ink);
  stroke-width: 3;
}

.parens {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.parens .p {
  display: inline-block;
  min-width: 0.62em;
  text-align: center;
  border-radius: 4px;
}

.parens .p.hi {
  background: rgb(92 225 230 / 28%);
}

.parens .p.gone {
  color: var(--gone);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: 0.75;
}

#bits {
  letter-spacing: 0.04em;
}

#parens-strings {
  letter-spacing: 0.14em;
  font-size: 0.95rem;
}

/* ---- the sequence and the plot ---- */

.cols {
  display: grid;
  align-items: start;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

#seq-ruler {
  display: block;
  width: 100%;
  margin: 0.3rem 0;
}

#seq {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

#seq th {
  text-align: right;
  font-weight: 600;
  color: var(--dim);
  padding: 0.15rem 0.4rem;
}

#seq td {
  padding: 0.15rem 0.4rem;
  border-top: 1px solid var(--line);
  text-align: right;
}

#seq td:first-child,
#seq td.o {
  text-align: left;
}

#seq tr.lim td {
  border-top: 2px solid var(--accent);
}

.fns {
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

#plot {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  touch-action: manipulation;
}

.grid {
  stroke: var(--line);
  stroke-width: 1;
}

.diag {
  stroke: var(--dim);
  stroke-dasharray: 2 5;
  opacity: 0.6;
}

.pt {
  fill: var(--pt);
  opacity: 0.85;
}

.sel,
.hov {
  fill: none;
  stroke: var(--accent);
  stroke-dasharray: 3 4;
}

.hov {
  stroke: var(--bead);
}

.sel-dot {
  fill: var(--accent);
  stroke: var(--night);
  stroke-width: 2;
}

.hov-dot {
  fill: var(--bead);
  stroke: var(--night);
  stroke-width: 2;
}

.foot {
  max-width: 56rem;
}

@media (max-width: 860px) {
  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .cols {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .steps {
    grid-template-columns: 1fr;
  }
  .weight output {
    min-width: 0;
  }
}
