/* Quirewell: a chaptered reading press.
   Six colors, all defined on :root. Slab headings, system sans body. */

:root {
  color-scheme: light;
  --paper: #F1F8F7;
  --tint: #DEEDE9;
  --rule: #9FC6BC;
  --verdigris: #2A6F5E;
  --muted: #40645B;
  --ink: #14342C;
  --font-slab: Rockwell, Cambria, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 64rem;
  --measure: 42rem;
}

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

[hidden] {
  display: none !important;
}

html {
  background-color: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

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

h1,
h2,
h3 {
  margin: 0 0 0.6em;
  font-family: var(--font-slab);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 1.35rem + 3vw, 3.5rem);
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
}

h3 {
  margin-top: 1.6em;
  font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem);
}

p {
  margin: 0 0 1em;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

.measure ul li,
.measure ol li {
  margin-bottom: 0.5em;
}

a {
  color: var(--verdigris);
  text-underline-offset: 0.2em;
}

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

a:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -4rem;
  z-index: 10;
  padding: 10px 16px;
  background-color: var(--ink);
  color: var(--paper);
  font-weight: 700;
  text-decoration: none;
}

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

.skip-link:focus {
  top: 16px;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 16px;
}

/* Masthead and navigation */

.masthead {
  padding-top: 20px;
  border-bottom: 3px double var(--verdigris);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-bottom: 8px;
}

.imprint {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: 0;
}

.brand {
  font-family: var(--font-slab);
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.tagline {
  color: var(--muted);
  font-size: 0.95rem;
  font-style: italic;
}

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

.nav-list a {
  display: inline-block;
  padding: 10px 12px;
  border-bottom: 3px solid transparent;
  color: var(--ink);
  font-size: 0.95rem;
  text-decoration: none;
}

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

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

/* Main and the chapter frames */

main {
  padding-block: clamp(32px, 5vw, 56px) 40px;
}

.page-head {
  max-width: var(--measure);
  margin: 0 0 clamp(28px, 4vw, 44px);
}

.frame {
  position: relative;
  margin: 0 auto clamp(40px, 6vw, 64px);
  padding: clamp(20px, 4vw, 48px);
  background-color: var(--paper);
  border: 2px solid var(--verdigris);
  outline: 1px solid var(--rule);
  outline-offset: 6px;
}

.frame[id] {
  scroll-margin-top: 24px;
}

.running-head,
.running-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.running-head {
  margin-bottom: clamp(20px, 3vw, 32px);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.running-foot {
  align-items: baseline;
  margin-top: clamp(24px, 4vw, 40px);
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.running-foot a {
  color: var(--verdigris);
  text-decoration: none;
}

.chapter-numeral {
  margin: 0 0 8px;
  font-family: var(--font-slab);
  font-size: clamp(3rem, 2rem + 4vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--verdigris);
}

.chapter h2 {
  margin-bottom: 0.9em;
}

.measure {
  max-width: var(--measure);
}

.kicker {
  margin: 0 0 12px;
  color: var(--verdigris);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede {
  max-width: var(--measure);
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
}

.dek {
  max-width: var(--measure);
  padding-left: 16px;
  border-left: 3px solid var(--verdigris);
  color: var(--muted);
  font-family: var(--font-slab);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  font-style: italic;
  line-height: 1.5;
}

.dropcap::first-letter {
  float: left;
  margin: 6px 12px 0 0;
  font-family: var(--font-slab);
  font-size: 3.6em;
  font-weight: 700;
  line-height: 0.85;
  color: var(--verdigris);
}

.note {
  color: var(--muted);
  font-size: 0.95rem;
  font-style: italic;
}

.try {
  max-width: var(--measure);
  margin: 28px 0 0;
  padding: 16px 20px;
  border-left: 4px solid var(--verdigris);
  background-color: var(--tint);
}

.rules {
  padding-left: 0;
  list-style: none;
  counter-reset: rule;
}

.rules li {
  position: relative;
  margin-bottom: 0.9em;
  padding-left: 2.2em;
  counter-increment: rule;
}

.rules li::before {
  content: counter(rule) ".";
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--font-slab);
  font-weight: 700;
  color: var(--verdigris);
}

.example-card {
  max-width: var(--measure);
  margin: 0 0 1.2em;
  padding: 20px;
  border: 2px solid var(--verdigris);
  background-color: var(--tint);
}

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

.grades {
  margin: 0 0 1.4em;
}

.grades dt {
  margin-top: 12px;
  color: var(--ink);
  font-family: var(--font-slab);
  font-weight: 700;
}

.grades dd {
  max-width: var(--measure);
  margin: 2px 0 0;
}

/* Diagrams (inline SVG, colors from the palette) */

.diagram-figure {
  max-width: var(--measure);
  margin: 2em 0;
  padding: 16px;
  border: 1px solid var(--rule);
  background-color: var(--tint);
}

.diagram-figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.diagram text {
  font-family: var(--font-sans);
  font-size: 19px;
  fill: var(--ink);
}

.diagram .label-muted {
  fill: var(--muted);
}

.diagram .axis {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
}

.diagram .curve-plain {
  fill: none;
  stroke: var(--muted);
  stroke-width: 3;
  stroke-dasharray: 8 7;
  stroke-linecap: round;
}

.diagram .curve-kept {
  fill: none;
  stroke: var(--verdigris);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.diagram .point {
  fill: var(--verdigris);
}

.diagram .point-label {
  fill: var(--paper);
  font-size: 16px;
  font-weight: 700;
}

/* Title page */

.title-grid {
  display: grid;
  gap: 32px;
  align-items: center;
}

@media (min-width: 52rem) {
  .title-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  }
}

.title-art {
  margin: 0;
  text-align: center;
}

.title-art figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.quire {
  display: block;
  width: min(100%, 260px);
  height: auto;
  margin: 0 auto;
}

.quire .sheet {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
}

.quire .sheet-top {
  fill: var(--tint);
  stroke: var(--verdigris);
  stroke-width: 2.5;
}

.quire .sheet-line {
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.quire .ribbon {
  fill: var(--verdigris);
}

.ornament {
  display: block;
  width: 160px;
  max-width: 100%;
  height: 20px;
  margin: 0 0 24px;
}

.ornament .orn {
  fill: var(--verdigris);
}

.ornament .orn-line {
  stroke: var(--rule);
  stroke-width: 2;
}

/* Contents */

.contents-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents-list li {
  margin: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.contents-list li:last-child {
  border-bottom: 0;
}

.contents-list a {
  color: var(--ink);
  font-family: var(--font-slab);
  font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem);
  font-weight: 700;
  text-decoration: none;
}

.contents-list a:hover {
  color: var(--verdigris);
  text-decoration: underline;
}

.contents-list .num {
  display: inline-block;
  min-width: 2.6ch;
  color: var(--verdigris);
}

.contents-list p {
  max-width: var(--measure);
  margin: 6px 0 0 2.6ch;
  color: var(--muted);
  font-size: 0.97rem;
}

/* Buttons and actions */

.actions,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 10px 18px;
  border: 2px solid var(--verdigris);
  border-radius: 2px;
  background-color: var(--verdigris);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

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

.button-quiet {
  border-color: var(--ink);
  background-color: var(--paper);
  color: var(--ink);
}

/* Practice bench */

.drill,
.add-card {
  display: none;
}

.js .drill,
.js .add-card {
  display: block;
}

.js .static-deck {
  display: none;
}

.card-list {
  margin: 0;
}

.card-list dt {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-slab);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  font-weight: 700;
}

.card-list dd {
  max-width: var(--measure);
  margin: 6px 0 0;
}

.drill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-face {
  min-height: 11rem;
  padding: clamp(20px, 4vw, 36px);
  border: 2px solid var(--verdigris);
  background-color: var(--tint);
}

.card-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card-text {
  max-width: none;
  margin: 0;
  font-family: var(--font-slab);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  line-height: 1.35;
}

.card-answer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

#rate-panel {
  margin-top: 20px;
}

.rate-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px;
}

.rate-row .button {
  border-color: var(--verdigris);
  background-color: var(--tint);
  color: var(--ink);
}

.rate-row .button:hover {
  border-color: var(--ink);
  background-color: var(--ink);
  color: var(--paper);
}

.key {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid currentColor;
  font-size: 0.8em;
}

.status {
  min-height: 1.6em;
  margin: 16px 0 0;
  font-weight: 700;
}

.help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px 16px;
  margin: 24px 0 8px;
  padding: 0;
  list-style: none;
}

.stage-list li {
  padding-top: 10px;
  border-top: 3px solid var(--verdigris);
  font-size: 0.95rem;
}

.stage-count {
  display: block;
  font-family: var(--font-slab);
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem);
  font-weight: 700;
  line-height: 1.1;
}

.field {
  margin: 0 0 18px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  min-height: 6em;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background-color: var(--paper);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

textarea[aria-invalid="true"] {
  border-style: dashed;
}

/* Colophon */

.colophon {
  padding-block: 32px 40px;
  border-top: 3px double var(--verdigris);
  color: var(--muted);
  font-size: 0.92rem;
}

.colophon p {
  max-width: var(--measure);
  margin: 0 0 0.8em;
}

.colophon a {
  color: var(--verdigris);
}

.colophon-brand {
  color: var(--ink);
  font-family: var(--font-slab);
}

@media (max-width: 40rem) {
  .running-head,
  .running-foot {
    letter-spacing: 0.1em;
  }
}

/* Motion: the static version is the default; motion is added only when allowed. */

@keyframes card-reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

  .button {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
  }

  .card-answer:not([hidden]) {
    animation: card-reveal 220ms ease-out both;
  }
}

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

  .button {
    transition: none;
  }

  .card-answer:not([hidden]) {
    animation: none;
  }
}
