/* Sounding Line: style.css
   Concept: a surveyed lake floor. Paper, fine contour lines and cards that
   stack like field notes. Six color tokens, all in the hue 348 family. */

:root {
  --paper: #faf4f6;   /* page background */
  --card: #f1e4e7;    /* raised surfaces: stacked cards, the Dice Lab */
  --ink: #34141a;     /* body text and headings */
  --muted: #6d464d;   /* captions, labels, control borders */
  --accent: #a71b37;  /* actions, links, focus rings, graphics */
  --line: #ceabb2;    /* hairlines and contour lines (decorative only) */

  --font: "Gill Sans", "Gill Sans MT", Optima, "Segoe UI", sans-serif;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --wrap: 72rem;
  --radius: 4px;
}

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

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

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  line-height: 1.6;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 400;
  line-height: 1.12;
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(2.3rem, 1.3rem + 4vw, 4.4rem);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.7rem);
}

h3 {
  font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.55rem);
  font-weight: 700;
  line-height: 1.25;
}

p {
  margin: 0 0 1.05em;
}

img,
svg {
  max-width: 100%;
}

figure {
  margin: 0;
}

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

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

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

/* Skip link and screen-reader helper */

.skip-link {
  position: absolute;
  top: -10rem;
  left: var(--gutter);
  z-index: 50;
  padding: 0.7rem 1.1rem;
  background: var(--accent);
  color: var(--paper);
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:hover,
.skip-link:focus {
  color: var(--paper);
}

.skip-link:focus {
  top: 0.75rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout helpers */

.wrap {
  width: min(100%, var(--wrap));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.eyebrow {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead {
  font-size: clamp(1.15rem, 1.02rem + 0.5vw, 1.4rem);
  line-height: 1.5;
  max-width: 34em;
}

.section {
  padding-block: clamp(3.25rem, 7vw, 5.75rem);
}

.section--rule {
  border-top: 1px solid var(--line);
}

.page-head {
  padding-block: clamp(2.75rem, 6vw, 4.75rem) clamp(1.75rem, 3vw, 2.75rem);
}

.section-head {
  max-width: 46rem;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.section-head p:last-child {
  margin-bottom: 0;
}

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

.note {
  margin: 2.5rem 0 0;
  padding: 1.25rem 1.4rem;
  background: var(--card);
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  font-size: 0.98rem;
}

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

/* Header and navigation */

.site-header {
  border-bottom: 1px solid var(--line);
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

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

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

.brand-mark path,
.brand-mark line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark circle {
  fill: var(--ink);
}

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

.nav-list a {
  display: inline-block;
  padding: 0.2rem 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--paper);
}

.nav-list a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-list a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.65rem 1.3rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--paper);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

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

.btn-ghost {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--muted);
}

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

/* Home: hero and contour art */

.hero {
  padding-block: clamp(2.75rem, 7vw, 6rem);
}

.hero-grid {
  display: grid;
  gap: 2.75rem;
  align-items: center;
}

.hero-art figcaption {
  margin-top: 0.75rem;
  max-width: 42ch;
  font-size: 0.92rem;
  color: var(--muted);
}

.contours {
  display: block;
  width: 100%;
  height: auto;
}

.contours ellipse {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.6;
}

.contours .deep {
  stroke: var(--accent);
  stroke-width: 2.2;
}

.contours .sounding {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 5 6;
}

.contours .weight {
  fill: var(--ink);
}

.contours .rule {
  stroke: var(--muted);
  stroke-width: 1;
}

.contours text {
  font-family: var(--font);
  font-size: 16px;
  fill: var(--muted);
}

/* Home: stacked cards */

.stack {
  display: grid;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stack-card {
  display: grid;
  gap: 1.25rem;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: var(--radius);
}

.card-side {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-no {
  font-size: clamp(2.2rem, 1.6rem + 2vw, 3.2rem);
  line-height: 1;
  color: var(--accent);
}

.glyph {
  width: 3.25rem;
  height: 3.25rem;
  flex: none;
}

.glyph .g-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph .g-rule {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.glyph .g-soft {
  fill: var(--line);
}

.glyph .g-ink {
  fill: var(--ink);
}

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

.card-link {
  font-weight: 700;
}

@media (min-width: 46rem) {
  .stack {
    gap: 0;
    padding-bottom: 6vh;
  }

  .stack-card {
    position: sticky;
    grid-template-columns: 9.5rem 1fr;
    gap: 2.25rem;
    min-height: 19rem;
    align-items: start;
    box-shadow: 0 -1px 0 var(--line);
  }

  .stack-card .card-side {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
  }

  /* Each card locks a little lower than the one before it, so the
     title edges of earlier cards stay visible as the stack builds. */
  .stack-card:nth-child(1) { top: 2.5rem; z-index: 1; }
  .stack-card:nth-child(2) { top: 3.75rem; z-index: 2; }
  .stack-card:nth-child(3) { top: 5rem; z-index: 3; }
  .stack-card:nth-child(4) { top: 6.25rem; z-index: 4; }
  .stack-card:nth-child(5) { top: 7.5rem; z-index: 5; }
}

.principles {
  display: grid;
  gap: 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.principle {
  padding-top: 1.1rem;
  border-top: 3px solid var(--accent);
}

.band {
  background: var(--card);
  border-block: 1px solid var(--line);
}

.band .actions {
  margin-top: 1.25rem;
}

/* Guide */

.toc-title {
  margin: 1.75rem 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: inline-block;
  padding: 0.45rem 0.95rem;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--muted);
  border-radius: 999px;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.toc a:hover {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

.article {
  max-width: 46rem;
}

.article section {
  margin-top: 2.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 1.5rem;
}

.article h3 {
  margin-top: 1.9rem;
}

.article ol,
.article ul {
  margin: 0 0 1.2rem;
  padding-left: 1.3rem;
}

.article li {
  margin-bottom: 0.5rem;
}

/* Dice Lab */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.data-table caption {
  margin-bottom: 0.6rem;
  text-align: left;
  font-weight: 700;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.45rem;
  text-align: right;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.data-table th[scope="row"] {
  text-align: left;
}

.data-table thead th {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.reference-wrap {
  max-width: 40rem;
}

.lab {
  display: grid;
  gap: 1.75rem;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lab-controls {
  display: grid;
  gap: 1.1rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.lab-controls legend {
  margin-bottom: 0.6rem;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

select {
  min-height: 2.9rem;
  padding: 0.45rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--muted);
  border-radius: var(--radius);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.dice-zone {
  display: grid;
  gap: 1rem;
}

.dice-faces {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 3vw, 1.5rem);
  min-height: 8rem;
  padding: 0.5rem 0;
}

.die {
  display: block;
  width: clamp(4.5rem, 16vw, 7rem);
  height: auto;
  overflow: visible;
}

.die .die-body {
  fill: var(--paper);
  stroke: var(--muted);
  stroke-width: 3;
}

.die .pip {
  fill: var(--ink);
  opacity: 0;
}

.die .pip.on {
  opacity: 1;
}

.die.is-rolling .die-body {
  stroke: var(--accent);
  stroke-width: 6;
}

.die.is-rolling {
  transform-origin: 50% 50%;
  animation: tumble 420ms cubic-bezier(0.2, 0.7, 0.25, 1);
}

@keyframes tumble {
  0% {
    transform: rotate(0deg) scale(1);
  }
  35% {
    transform: rotate(-16deg) scale(1.08);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

.status {
  margin: 0;
  min-height: 3.2rem;
  padding: 0.85rem 1.1rem;
  background: var(--paper);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.status:last-child {
  margin-bottom: 0;
}

.tally {
  display: grid;
  gap: 1.5rem;
  min-width: 0;
  overflow-x: auto;
}

.tally h3 {
  margin: 0;
}

.chart-wrap figcaption {
  margin-top: 0.75rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.tally-chart {
  display: block;
  width: 100%;
  max-width: 40rem;
  height: auto;
  margin-inline: auto;
}

.tally-chart .baseline {
  stroke: var(--muted);
  stroke-width: 1.5;
}

.tally-chart .bar {
  fill: var(--accent);
}

.tally-chart .expected {
  stroke: var(--ink);
  stroke-width: 3;
}

.tally-chart .tick-label,
.tally-chart .count-label {
  font-family: var(--font);
  text-anchor: middle;
  fill: var(--ink);
}

.tally-chart .tick-label {
  font-size: 14px;
}

.tally-chart .count-label {
  font-size: 13px;
  font-weight: 700;
}

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

.stats div {
  padding: 0.9rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stats dt {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 0.25rem 0 0;
  font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem);
  font-variant-numeric: tabular-nums;
}

.stats dd,
.stats dt {
  overflow-wrap: anywhere;
}

/* Contact */

.contact-mail {
  display: inline-block;
  margin: 0.5rem 0 1.25rem;
  font-size: clamp(1.4rem, 1rem + 2vw, 2.4rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* Footer */

.site-footer {
  padding-block: 2.75rem;
  background: var(--paper);
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--muted);
}

.footer-grid {
  display: grid;
  gap: 1.1rem;
}

.footer-grid p {
  max-width: 56ch;
  margin: 0;
}

.footer-brand {
  font-size: 1.25rem;
  color: var(--ink);
}

.site-footer a {
  color: var(--accent);
}

.footer-grid .nav-list {
  font-size: 0.95rem;
}

/* Progressive enhancement: the lab needs JavaScript; the reference text does not. */

.no-js .js-only {
  display: none;
}

.js .no-js-only {
  display: none;
}

/* Page-level layout */

@media (min-width: 46rem) {
  .principles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem;
  }

  .footer-grid .nav-list {
    grid-column: 1 / -1;
  }
}

@media (min-width: 60rem) {
  .hero-grid {
    grid-template-columns: 1.08fr 0.92fr;
    gap: 3.5rem;
  }
}

/* Reduced motion: each motion has a static version. */

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

  .die.is-rolling {
    animation: none;
  }

  .die.is-rolling .die-body {
    stroke: var(--accent);
    stroke-width: 6;
  }

  .btn,
  .toc a {
    transition: none;
  }
}

/* Supporting text rules */

.section-note {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.article h2 {
  margin-top: 2.25rem;
}

.article section h2 {
  margin-top: 0;
}

.about-links {
  margin-top: 2.25rem;
}
