@font-face {
  font-family: "STIX Two Text";
  src: url("./muscle-reader-stix.woff") format("woff");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

/* Cormorant Garamond (display) is served by Google Fonts, linked in each page head after this sheet. */

:root {
  color-scheme: light;
  --paper: #faf5ed;
  --ink: #382b31;
  --quiet: #69535b;
  --rose: #eed7d2;
  --plum: #6d3e4c;
  --sage: #e4e8db;
  --rule: #b5a39a;
  --display: "Cormorant Garamond", "STIX Two Text", Georgia, serif;
  --reading: "STIX Two Text", Georgia, serif;
  font-family: var(--reading);
  font-size: 18px;
  line-height: 1.62;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }

body { margin: 0; }

body, main, section, aside, div { min-width: 0; }

main { max-width: 70ch; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.16;
  text-wrap: balance;
  overflow-wrap: break-word;
}

h1 { font-size: clamp(2.45rem, 4.7vw, 3.65rem); letter-spacing: -0.035em; margin: 0.4em 0; }
h2 { font-size: clamp(1.8rem, 2.7vw, 2.4rem); margin: 0 0 0.75em; letter-spacing: -0.018em; }
h3, h4 { font-size: 1.45rem; margin: 1.7em 0 0.55em; }
p { margin: 0 0 1.05em; }
p, li, dt, dd { overflow-wrap: break-word; }
ul { padding-left: 1.2em; margin: 0 0 1.2em; }
li { padding-left: 0.15em; margin-bottom: 0.45em; }
em { font-style: italic; }

a {
  color: var(--plum);
  font-size: inherit;
  min-height: 44px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  overflow-wrap: anywhere;
}

a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--plum); outline-offset: 4px; }

img { display: block; max-width: 100%; height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  border: 1px solid var(--plum);
  background: transparent;
  border-radius: 0.3rem;
  padding: 0.65rem 1rem;
  min-height: 48px;
  cursor: pointer;
  line-height: 1.3;
  text-align: center;
}

button:hover:not(:disabled) { background: var(--rose); }
button:disabled { color: var(--quiet); cursor: default; border-color: var(--rule); }

label, legend { font-size: 1rem; }
label { display: block; }

select, textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid #8a7279;
  background: #fffdfa;
  border-radius: 0.25rem;
  min-height: 48px;
  padding: 0.6rem;
}

select { margin: 0.3rem 0 1rem; }
textarea { resize: vertical; line-height: 1.45; }
fieldset { padding: 0; border: 0; margin: 0.3rem 0 0; min-width: 0; }
legend { padding: 0; margin-bottom: 0.35rem; }
input[type="checkbox"] { width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin: 0; accent-color: var(--plum); flex-shrink: 0; }
[hidden] { display: none !important; }

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

[data-role="skip"] {
  position: fixed;
  z-index: 10;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.5rem 1rem;
  background: #fffdfa;
  transform: translateY(-180%);
}

[data-role="skip"]:focus { transform: none; }

[data-role="opening"] {
  max-width: 1140px;
  margin: 0 auto;
  padding: 4.5rem 2rem 3.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 2.7rem;
  align-items: center;
}

[data-role="guide-label"] {
  display: inline-block;
  margin-bottom: 1rem;
  border: 1px solid var(--plum);
  border-radius: 2rem;
  padding: 0.4rem 0.9rem;
  font-size: 1rem;
  color: var(--plum);
}

[data-role="lead"] { font-size: 1.2rem; line-height: 1.5; max-width: 42ch; }

[data-role="opening-copy"] > p:not([data-role]) { max-width: 43ch; }

[data-role="start-link"] {
  gap: 1.1rem;
  min-height: 50px;
  border-bottom: 1px solid var(--plum);
  text-decoration: none;
  margin-top: 0.3rem;
}

[data-role="start-link"] span { font-size: 1.45rem; }

[data-role="paper-collage"] {
  position: relative;
  isolation: isolate;
  min-height: 27rem;
  margin: 0;
  padding: 1.5rem;
  background: #f1e7dc;
  border-radius: 45% 45% 1.1rem 1.1rem;
}

[data-role="paper-layer"] {
  position: absolute;
  inset: 13% 17% 25% 9%;
  background: #fffdfa;
  border: 1px solid #d9c8bb;
  transform: rotate(-7deg);
  box-shadow: 0.3rem 0.5rem 0 #dec4b9;
}

[data-role="paper-oval"] {
  position: absolute;
  inset: 17% 11% 29% 26%;
  border: 0.45rem solid #fff6ee;
  border-radius: 50%;
  background: var(--rose);
  transform: rotate(8deg);
}

[data-role="paper-fold"] {
  position: absolute;
  inset: 42% 14% 24% 13%;
  background: var(--sage);
  transform: rotate(5deg);
  clip-path: polygon(0 3%, 13% 0, 24% 4%, 38% 1%, 50% 4%, 66% 0, 84% 4%, 100% 1%, 97% 100%, 83% 96%, 68% 100%, 51% 97%, 35% 100%, 17% 96%, 0 100%);
  border-bottom: 0.3rem solid #bbc1af;
}

[data-role="paper-collage"] img {
  position: absolute;
  inset: 8% 5% auto;
  width: 90%;
  height: 64%;
  object-fit: cover;
  border-radius: 45% 45% 0.2rem 0.2rem;
  color: transparent;
}

[data-role="paper-collage"] figcaption {
  position: relative;
  margin-top: 17rem;
  padding: 0.45rem;
  background: #f1e7dc;
  border-radius: 0.35rem;
  text-align: center;
  font-size: 1rem;
  line-height: 1.45;
}

[data-role="paper-collage"] figcaption em { display: block; padding-top: 0.3rem; }

[data-role="reading-layout"] {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 2rem 0;
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 4rem;
  align-items: start;
  border-top: 1px solid var(--rule);
}

[data-role="contents-rail"] { position: sticky; top: 1.3rem; }
[data-role="contents-rail"] h2 { font-size: 1.3rem; margin-bottom: 0.9rem; }
[data-role="contents-rail"] ul { list-style: none; padding: 0; margin: 0; }
[data-role="contents-rail"] li { margin: 0; padding: 0; border-top: 1px solid #d2c4bc; }
[data-role="contents-rail"] li:last-child { border-bottom: 1px solid #d2c4bc; }
[data-role="contents-rail"] a { width: 100%; padding: 0.45rem 0; text-decoration: none; }
[data-role="contents-rail"] a:hover { text-decoration: underline; }
[data-role="rail-note"] { color: var(--quiet); margin-top: 1.3rem; font-style: italic; }

[data-role="field-note"] { padding: 1rem 0 3rem; margin-bottom: 2rem; }
[data-role="field-note"] + [data-role="field-note"] { border-top: 1px solid var(--rule); padding-top: 3rem; }
[data-role="section-label"] { font-size: 1rem; color: var(--quiet); margin-bottom: 0.5rem; }
[data-role="scenario"] { border-left: 3px solid var(--plum); padding-left: 1rem; margin-bottom: 1.5rem; }
[data-role="lookup-link"] { padding: 0.3rem 0; }

[data-role="worksheet"] {
  margin: 2rem 0 0;
  padding: 1.6rem;
  border: 1px solid #ac929b;
  border-radius: 1rem 1rem 0.2rem 0.2rem;
  background: var(--rose);
}

[data-role="worksheet"] > h3 { margin-top: 0; }
[data-role="worksheet-choices"] { margin: 1.2rem 0 1.8rem; }
[data-role="worksheet-choices"] fieldset label { display: flex; align-items: center; gap: 0.65rem; min-height: 48px; padding: 0.3rem 0.1rem; cursor: pointer; }
[data-role="question-output"] { background: #fffdfa; padding: 1.2rem; border-top: 3px solid var(--plum); }
[data-role="question-output"] h3 { margin-top: 0; }
[data-role="question-output"] li { margin-bottom: 0.8rem; }
[data-role="worksheet-actions"] { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 1.4rem; }
[data-question-action="copy"] { background: var(--plum); color: #fffdfa; }
[data-question-action="copy"]:hover:not(:disabled) { background: #51333e; }
[data-question-action="copy"]:disabled { background: #e8ddd6; color: var(--quiet); }
[data-question-status] { margin: 0.8rem 0 0; min-height: 1.6em; }
[data-copy-fallback] { margin-top: 1rem; }
[data-copy-fallback] label { margin-bottom: 0.5rem; }

[data-role="claim-checks"] { margin: 1.5rem 0 2rem; }
[data-role="claim-checks"] dt { font-size: 1.15rem; font-weight: 600; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
[data-role="claim-checks"] dd { margin: 0.55rem 0 1.4rem; }
[data-role="claim-checks"] dd p:last-child { margin-bottom: 0; }
[data-role="urgent-note"] { background: var(--sage); border-left: 3px solid #59664f; padding: 1.1rem 1.3rem; margin-top: 2rem; }
[data-role="urgent-note"] h3 { margin-top: 0; }
[data-role="urgent-note"] p:last-child { margin-bottom: 0; }

[data-role="reading-list"] { list-style: none; padding: 0; margin-top: 1.5rem; }
[data-role="reading-entry"] { padding: 0.8rem 0 1.1rem; border-top: 1px solid var(--rule); }
[data-role="reading-entry"] h4 { font-family: var(--reading); font-size: 1.05rem; font-weight: 600; margin: 0 0 0.3rem; line-height: 1.4; }
[data-role="reading-entry"] a { padding: 0.2rem 0; }
[data-role="reading-entry"] p { margin-bottom: 0; }

[data-role="closing"] { max-width: 1140px; padding: 2rem 2rem 3rem; margin: 0 auto; border-top: 1px solid var(--rule); }
[data-role="closing"] p { max-width: 65ch; }
[data-role="closing"] > div { display: flex; gap: 1.6rem; flex-wrap: wrap; }
[data-role="missing-path"] main { margin: 0 auto; padding: 5rem 1.3rem 4rem; }

@media (max-width: 900px) {
  [data-role="opening"] { gap: 1.5rem; padding-top: 3rem; }
  [data-role="paper-collage"] { min-height: 24rem; padding: 1rem; }
  [data-role="paper-collage"] figcaption { margin-top: 15rem; }
  [data-role="reading-layout"] { grid-template-columns: 11rem minmax(0, 1fr); gap: 2rem; }
}

@media (max-width: 700px) {
  :root { font-size: 18px; }
  h1 { font-size: clamp(2.25rem, 10.9vw, 3.2rem); }
  [data-role="opening"] { display: block; padding: 2rem 1.2rem 2rem; }
  [data-role="lead"] { font-size: 1.12rem; }
  [data-role="paper-collage"] { margin: 2rem auto 0; max-width: 23rem; min-height: 23rem; }
  [data-role="paper-collage"] figcaption { margin-top: 14rem; }
  [data-role="reading-layout"] { display: block; padding: 1.5rem 1.2rem 0; }
  [data-role="contents-rail"] { position: static; margin-bottom: 3rem; }
  [data-role="contents-rail"] nav { background: #f0e8df; padding: 1.1rem 1.2rem; border-radius: 0.4rem; }
  [data-role="contents-rail"] a { min-height: 48px; }
  [data-role="rail-note"] { margin-bottom: 0; }
  [data-role="field-note"] { padding-bottom: 2rem; }
  [data-role="field-note"] + [data-role="field-note"] { padding-top: 2.3rem; }
  [data-role="worksheet"] { padding: 1rem; }
  [data-role="question-output"] { padding: 1rem; }
  [data-role="worksheet-actions"] { display: grid; gap: 0.6rem; }
  [data-role="worksheet-actions"] button { width: 100%; }
  [data-role="urgent-note"] { padding: 1rem; }
  [data-role="closing"] { padding: 1.5rem 1.2rem 2.5rem; }
  [data-role="closing"] > div { display: grid; gap: 0.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

@media print {
  :root { background: white; color: black; font-size: 16px; }
  body { background: white; }
  [data-role="opening"], [data-role="reading-layout"], [data-role="closing"] { display: block; max-width: none; padding: 0; margin: 0; border: 0; }
  [data-role="contents-rail"], [data-role="paper-collage"], [data-role="skip"], [data-role="worksheet-choices"], [data-role="worksheet-actions"], [data-copy-fallback], [data-question-status] { display: none !important; }
  main { max-width: none; }
  h1, h2, h3, h4 { break-after: avoid; }
  a { color: black; min-height: 0; display: inline; }
  [data-role="field-note"] { padding: 1rem 0; margin: 0; }
  [data-role="worksheet"], [data-role="question-output"], [data-role="urgent-note"] { background: white; border: 1px solid #999; }
  body[data-print="worksheet"] > * { display: none; }
  body[data-print="worksheet"] > [data-role="reading-layout"], body[data-print="worksheet"] main, body[data-print="worksheet"] #cost-notes, body[data-print="worksheet"] #cost-worksheet { display: block; }
  body[data-print="worksheet"] main > section:not(#cost-notes), body[data-print="worksheet"] #cost-notes > :not(#cost-worksheet), body[data-print="worksheet"] #cost-worksheet > :not([data-role="question-output"]) { display: none !important; }
  body[data-print="worksheet"] #cost-notes { border: 0; padding: 0; }
  body[data-print="worksheet"] #cost-worksheet { margin: 0; padding: 0; border: 0; }
}
