:root {
  --bg: #fffdfc;
  --bg-card: #ffffff;
  --text: #1f1a1c;
  --muted: #6b6266;
  --line: #eadfe2;
  --accent: #e11d48;
  --accent-soft: #fff1f4;
  --code-bg: #2a2226;
  --code-text: #f6eef0;
  --radius: 12px;
  --max: 68rem;
}

/* The pages toggle `hidden`; it must win over every display rule below. */
[hidden] {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131a;
    --bg-card: #201a22;
    --text: #f4eef1;
    --muted: #a99ea4;
    --line: #362d33;
    --accent: #fb5a7f;
    --accent-soft: #2b1b21;
    --code-bg: #0f0c11;
    --code-text: #f4eef1;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    17px/1.6 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.top {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
}

.nav {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav a:hover {
  color: var(--text);
}

.nav-github {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: center;
  padding: 3rem 0 4rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.9rem;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

.lead {
  margin: 0 0 1.5rem;
  font-size: 1.15rem;
  color: var(--muted);
}

.cta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-primary img {
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  .btn-primary img {
    filter: none;
  }
}

.btn-secondary {
  border-color: var(--line);
  color: var(--text);
  background: var(--bg-card);
}

.notice {
  margin-top: 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.hero-demo {
  text-align: center;
}

.demo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0 0 1.25rem;
}

.demo-head .demo-label {
  margin: 0;
}

.demo-label {
  margin: 0 0 1rem;
  font-weight: 600;
}

/*
 * Sized to sit within the label's line, and kept in the layout while it is
 * not offered (visibility, not display), so showing it moves nothing.
 */
.reset {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.6;
  cursor: pointer;
}

.reset:not([data-offered]) {
  visibility: hidden;
}

.reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reset:disabled {
  opacity: 0.6;
  cursor: progress;
}

.demo-status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.demo-status.error {
  color: var(--accent);
}

.demo-hint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.demo-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 3rem;
}

.demo-slot appreciator-button {
  --appreciator-size: 3rem;
}

/* Room under the main demo for the thank-you message it shows when full. */
.demo-slot[data-demo-slot='hero'] {
  padding-bottom: 3em;
}

.section {
  padding: 2.5rem 0;
  border-top: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
}

.section > p {
  color: var(--muted);
  max-width: 48rem;
}

.code-block {
  position: relative;
  margin: 1.25rem 0;
}

/* Room at the end of each line, so the last characters scroll clear of Copy. */
.code-block pre {
  padding-right: 4.5rem;
}

pre {
  margin: 0;
  padding: 1rem 1.25rem;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

pre code {
  font-size: inherit;
}

.copy {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--code-text);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.copy:hover {
  background: rgba(255, 255, 255, 0.16);
}

.points {
  padding-left: 1.2rem;
  color: var(--muted);
}

.variants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.variant {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.variant pre {
  font-size: 0.8rem;
}

.variant-gold appreciator-button {
  --appreciator-size: 2.5rem;
  --appreciator-full: gold;
  --appreciator-clicked: orange;
}

.variant-mono appreciator-button {
  --appreciator-default: currentColor;
  --appreciator-hover: currentColor;
  --appreciator-clicked: currentColor;
  --appreciator-full: currentColor;
}

.variant-big appreciator-button {
  --appreciator-size: 3rem;
}

.section h3 {
  margin: 2rem 0 0.25rem;
  font-size: 1.2rem;
}

.positions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.position {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1rem;
}

.position .demo-slot {
  min-height: 5rem;
  align-items: center;
}

.position appreciator-button {
  --appreciator-size: 2rem;
}

.position figcaption code {
  font-size: 0.8rem;
  color: var(--muted);
}

.readonly-demo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12rem;
  gap: 1rem;
  align-items: stretch;
  margin: 1.25rem 0;
}

.readonly-demo .code-block {
  margin: 0;
}

.readonly-demo .position {
  justify-content: center;
}

@media (max-width: 640px) {
  .readonly-demo {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A prompt is prose: it wraps, and scrolls within its block when long. */
pre.prompt {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 24rem;
  overflow-y: auto;
  padding-right: 4.5rem;
}

.table-scroll {
  overflow-x: auto;
}

.events-table code {
  white-space: nowrap;
}

.events-demo {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  margin: 1.25rem 0;
}

.events-demo .code-block {
  margin: 0;
}

.event-log-card {
  margin: 0;
}

.event-log-card figcaption {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.event-log {
  margin: 0;
  padding-left: 1.2rem;
  min-height: 8rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: grid;
  gap: 0.2rem;
}

@media (max-width: 800px) {
  .events-demo {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* On a phone each event stacks: its name, when it fires, then its detail. */
@media (max-width: 640px) {
  .events-table thead {
    display: none;
  }

  .table.events-table tr {
    display: grid;
    gap: 0.2rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
  }

  .table.events-table td {
    padding: 0;
    border: 0;
  }

  .events-table td:last-child::before {
    content: 'Detail: ';
    color: var(--muted);
  }
}

.footnote {
  font-size: 0.95rem;
}

.steps {
  padding-left: 1.4rem;
  display: grid;
  gap: 0.75rem;
  max-width: 48rem;
}

.steps li::marker {
  color: var(--accent);
  font-weight: 700;
}

.posts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.post {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.1rem 1.2rem 0.9rem;
}

.post-meta,
.post-date {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.post-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.post-excerpt {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  flex: 1;
}

.post-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.post-foot .demo-slot appreciator-button {
  --appreciator-size: 1.1rem;
  font-size: 0.85rem;
}

.foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.foot p {
  margin: 0.25rem 0;
}

@media (max-width: 800px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

.board .lead {
  max-width: 44rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.table th,
.table td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .rank {
  width: 3rem;
  color: var(--muted);
}

.board-table tbody tr:first-child td {
  font-weight: 700;
}

.site-link {
  display: grid;
  gap: 0.1rem;
  text-decoration: none;
  min-width: 0;
}

.site-link > span:first-child {
  text-decoration: underline;
}

/* Always on a line of its own under the name, whether the name is a link or text. */
.owner-link {
  display: block;
  width: fit-content;
  margin-top: 0.35rem;
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.owner-link:hover {
  border-color: var(--accent);
}

/* The page's address, on its own line, wrapping anywhere rather than
   widening the table. */
.site-page {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  overflow-wrap: anywhere;
  max-width: 32rem;
}
