/* Tallybark: ticket-stub system. Every color is a token on :root (six in total). */
:root {
  --paper: #f2f1f9;
  --ticket: #fbfbfe;
  --ink: #1c153c;
  --indigo: #4633a3;
  --dusk: #4e4870;
  --mist: #e0dcf4;
  --font-head: Futura, "Avenir Next", "Century Gothic", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 16px;
  --radius: 4px;
  --perf: 2px dashed var(--indigo);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 6rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  line-height: 1.65;
  min-height: 100vh;
  overflow-wrap: break-word;
}

[hidden] {
  display: none !important;
}

[id] {
  scroll-margin-top: 6rem;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  color: var(--ink);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(2.2rem, 1.3rem + 3.8vw, 4.3rem);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.7rem, 1.25rem + 1.8vw, 2.6rem);
  font-weight: 700;
}

h3 {
  font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.6rem);
  font-weight: 700;
}

p {
  margin: 0 0 1em;
  max-width: 68ch;
}

a {
  color: var(--indigo);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--indigo);
  outline-offset: 3px;
  border-radius: 2px;
}

main:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ticket);
  color: var(--ink);
  border: 2px solid var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--gutter);
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header and navigation */
.site-header {
  background: var(--paper);
  border-bottom: var(--perf);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--indigo);
}

.brand-mark {
  width: 2.5rem;
  height: auto;
  flex: none;
}

.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.nav-list a {
  display: inline-block;
  padding: 0.3rem 0.5rem;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
}

.nav-list a:hover {
  background: var(--mist);
}

.nav-list a[aria-current="page"] {
  background: var(--ink);
  color: var(--ticket);
}

/* Brand mark and hero art (colors set through tokens) */
.mark-body {
  fill: var(--ink);
}

.mark-paper {
  fill: var(--paper);
}

.mark-perf {
  stroke: var(--paper);
  stroke-width: 1.2;
  stroke-dasharray: 2 2;
  fill: none;
}

.art-ticket {
  fill: var(--ticket);
  stroke: var(--ink);
  stroke-width: 3;
}

.art-band {
  fill: var(--mist);
}

.art-notch {
  fill: var(--paper);
}

.art-perf {
  stroke: var(--indigo);
  stroke-width: 3;
  stroke-dasharray: 8 8;
}

.art-tally {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}

.art-slash {
  stroke: var(--indigo);
  stroke-width: 4;
  stroke-linecap: round;
}

.art-word {
  fill: var(--ink);
  font-family: var(--font-head);
  font-weight: 700;
}

/* Hero */
.hero {
  display: grid;
  gap: 2rem;
  align-items: center;
  padding-block: clamp(2.5rem, 6vw, 5rem);
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  }
}

.eyebrow {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo);
  margin-bottom: 1rem;
}

.lead {
  font-size: clamp(1.08rem, 1rem + 0.4vw, 1.3rem);
}

.hero-art {
  width: 100%;
  max-width: 480px;
  height: auto;
  justify-self: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--indigo);
  border-radius: var(--radius);
  background: var(--indigo);
  color: var(--ticket);
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ticket);
}

.btn-ghost {
  background: var(--ticket);
  color: var(--indigo);
}

.btn-ghost:hover {
  background: var(--mist);
  border-color: var(--indigo);
  color: var(--ink);
}

/* Sections */
.section {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.section + .section {
  border-top: var(--perf);
}

.section-intro {
  color: var(--dusk);
}

.page-intro {
  padding-block: clamp(2.5rem, 5vw, 4rem) clamp(1.5rem, 3vw, 2.5rem);
}

.page-intro .lead {
  color: var(--ink);
}

/* Ticket stubs: perforated card, dashed tear line, notches, tear-off panel */
.ticket-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 960px) {
  .ticket-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ticket {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8.5rem, 11rem);
  margin: 0;
  background: var(--ticket);
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.ticket-main {
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.ticket-main > :last-child {
  margin-bottom: 0;
}

.ticket-kicker {
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo);
  margin-bottom: 0.5rem;
}

.ticket-stub {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--mist);
  border-left: var(--perf);
  text-align: center;
  transition: transform 0.2s ease;
}

.ticket-stub::before,
.ticket-stub::after {
  content: "";
  position: absolute;
  left: -0.7rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--paper);
}

.ticket-stub::before {
  top: -0.7rem;
}

.ticket-stub::after {
  bottom: -0.7rem;
}

.stub-label {
  margin: 0;
  max-width: none;
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dusk);
}

.stub-no {
  margin: 0;
  max-width: none;
  font-family: var(--font-head);
  font-size: clamp(2rem, 1.6rem + 1.5vw, 3rem);
  font-weight: 700;
  line-height: 1;
  color: var(--indigo);
}

.stub-link {
  font-weight: 700;
  color: var(--indigo);
}

.stub-link:hover {
  color: var(--ink);
}

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

  .ticket-stub {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    gap: 0.5rem 1rem;
    padding: 1rem 1.25rem;
    border-left: 0;
    border-top: var(--perf);
  }

  .ticket-stub::before {
    top: -0.7rem;
    left: -0.7rem;
    bottom: auto;
  }

  .ticket-stub::after {
    top: -0.7rem;
    left: auto;
    right: -0.7rem;
    bottom: auto;
  }
}

@media (min-width: 560px) and (prefers-reduced-motion: no-preference) {
  .ticket:hover .ticket-stub,
  .ticket:focus-within .ticket-stub {
    transform: translateX(6px);
  }
}

/* Index list (table of contents) */
.toc {
  list-style: none;
  counter-reset: toc;
  margin: 0 0 2rem;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-width: 48rem;
}

.toc li {
  counter-increment: toc;
  display: flex;
  gap: 0.75rem;
}

.toc li::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--indigo);
  min-width: 2.2rem;
}

.toc a {
  font-weight: 600;
  color: var(--ink);
}

/* Three steps */
.steps {
  list-style: none;
  counter-reset: st;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 800px) {
  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.steps li {
  counter-increment: st;
  position: relative;
  padding: 1.5rem 1.25rem 1.25rem;
  background: var(--ticket);
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.steps li::before {
  content: "0" counter(st);
  display: block;
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  color: var(--indigo);
  line-height: 1;
  margin-bottom: 0.75rem;
}

/* Notes and glossary */
.note-band {
  background: var(--ticket);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-block: 2rem;
}

.notice {
  padding: 0.75rem 1rem;
  background: var(--mist);
  border-left: 4px solid var(--ink);
}

.glossary {
  margin: 0;
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .glossary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 2.5rem;
  }
}

.glossary dt {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.glossary dd {
  margin: 0.2rem 0 0;
  max-width: 60ch;
}

.entry-stack {
  display: grid;
  gap: 2rem;
}

/* Rhythm Lab */
.seq-app {
  background: var(--ticket);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: clamp(1rem, 3vw, 2rem);
}

.seq-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: var(--perf);
}

.field {
  display: flex;
  flex: 1 1 14rem;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field label {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

.field input[type="range"] {
  width: 100%;
  min-height: 2rem;
  accent-color: var(--indigo);
}

.field output {
  font-weight: 600;
  color: var(--dusk);
}

.seq-status {
  min-height: 1.6em;
  margin: 1rem 0 0.5rem;
  font-weight: 700;
  color: var(--indigo);
}

.seq-grid {
  display: grid;
  gap: 1.1rem;
  margin-top: 0.5rem;
}

.seq-row {
  display: grid;
  gap: 0.5rem;
}

.seq-label {
  margin: 0;
  max-width: none;
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.seq-cells {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.4rem;
}

@media (min-width: 640px) {
  .seq-row {
    grid-template-columns: 7rem minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
  }
}

@media (min-width: 800px) {
  .seq-cells {
    grid-template-columns: repeat(16, minmax(0, 1fr));
    gap: 0.35rem;
  }
}

.step {
  appearance: none;
  width: 100%;
  min-width: 0;
  height: clamp(2.25rem, 1.6rem + 2vw, 3.25rem);
  padding: 0;
  border: 2px solid var(--indigo);
  border-radius: var(--radius);
  background: var(--ticket);
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.12s linear, color 0.12s linear, border-color 0.12s linear;
}

.step:hover {
  border-color: var(--ink);
}

.step[aria-pressed="true"] {
  background: var(--indigo);
  color: var(--ticket);
}

.step.is-current {
  background: var(--mist);
}

.step.is-current[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ticket);
}

.voice-list {
  margin: 0;
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .voice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 2.5rem;
  }
}

.voice-list dt {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--ink);
}

.voice-list dd {
  margin: 0.2rem 0 0;
  max-width: 60ch;
}

/* Questions (native details, works without JavaScript) */
.faq {
  display: grid;
  gap: 1rem;
}

.faq-item {
  background: var(--ticket);
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-head);
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
  font-weight: 700;
  color: var(--ink);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--indigo);
  border-radius: 50%;
  color: var(--indigo);
  font-size: 1.2rem;
  line-height: 1;
}

.faq-item[open] summary {
  border-bottom: var(--perf);
}

.faq-item[open] summary::after {
  content: "\2212";
  background: var(--mist);
}

.faq-body {
  padding: 1rem 1.25rem 1.25rem;
}

.faq-body p:last-child {
  margin-bottom: 0;
}

/* Contact */
.mail-address {
  font-family: var(--font-head);
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.9rem);
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.contact-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 960px) {
  .contact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Footer */
.site-footer {
  background: var(--paper);
  border-top: var(--perf);
  padding-block: 2rem;
  color: var(--dusk);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem 2rem;
}

.site-footer p {
  margin: 0;
  max-width: 60ch;
}

.site-footer a {
  color: var(--indigo);
  font-weight: 600;
}

/* Reduced motion: every transition and hover shift gets a static state */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }

  .ticket-stub {
    transform: none !important;
  }
}
