/* ==========================================================================
   Worksheets — fill in on screen, save locally, print cleanly
   ========================================================================== */

:root {
  --paper: #f2ede3;
  --paper-card: #fbf8f2;
  --sage: #dde3d7;
  --ink: #1a2b24;
  --ink-2: #45564c;
  --ink-3: #6d7b71;
  --forest: #1e3a31;
  --forest-deep: #132821;
  --clay: #be5f33;
  --clay-deep: #9c4a26;
  --clay-soft: #efd5c2;
  --teal: #008c74;
  --line: #dcd2c2;
  --line-soft: #e9e1d4;
  --display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --body: "Karla", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 4px;
  --radius-lg: 10px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shadow-sm: 0 1px 2px rgba(26, 43, 36, 0.06), 0 4px 14px -6px rgba(26, 43, 36, 0.14);
  --shadow-md: 0 2px 4px rgba(26, 43, 36, 0.05), 0 18px 40px -18px rgba(26, 43, 36, 0.28);
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.02rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--clay); outline-offset: 3px; border-radius: 2px; }
svg { display: block; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: -0.018em; line-height: 1.1; margin: 0; }

/* ---------- Sticky worksheet bar ---------- */

.sheet-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(242, 237, 227, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.sheet-bar-inner {
  max-width: 60rem;
  margin-inline: auto;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-right: auto;
}
.back-link:hover { color: var(--clay-deep); }
.back-link svg { flex: none; }

.sheet-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-card);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.sheet-btn:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.sheet-btn--primary { background: var(--forest); border-color: var(--forest); color: var(--paper-card); }
.sheet-btn--primary:hover { background: var(--forest-deep); border-color: var(--forest-deep); }
.sheet-btn--danger:hover { border-color: #a4341f; color: #8e2d1b; }

/* ---------- Progress ---------- */

.progress-strip { height: 3px; background: var(--line-soft); }
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--clay));
  transition: width 0.45s var(--ease);
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.save-state[data-show="true"] { opacity: 1; }

/* ---------- Sheet ---------- */

.sheet-wrap { max-width: 60rem; margin-inline: auto; padding: clamp(1.75rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) 5rem; }

.sheet {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.6rem, 5vw, 3.5rem);
  box-shadow: var(--shadow-md);
}

.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--clay-deep);
  margin: 0 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.kicker::before { content: ""; width: 1.6rem; height: 1px; background: currentColor; opacity: 0.5; }

.sheet h1 { font-size: clamp(2.1rem, 1.5rem + 3vw, 3.4rem); margin-bottom: 1rem; text-wrap: balance; }
.sheet .lead { font-size: clamp(1.05rem, 1rem + 0.35vw, 1.2rem); color: var(--ink-2); line-height: 1.65; max-width: 56ch; margin: 0 0 1.75rem; }

.notice {
  border-left: 2px solid var(--clay);
  background: rgba(239, 213, 194, 0.3);
  padding: 0.95rem 1.2rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.92rem;
  color: var(--ink-2);
  line-height: 1.6;
  margin-bottom: 2.25rem;
}
.notice strong { color: var(--ink); }
.notice a { color: var(--clay-deep); font-weight: 700; border-bottom: 1px solid rgba(190, 95, 51, 0.35); }

.privacy-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--ink-3);
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}
.privacy-line svg { color: var(--teal); flex: none; }

/* ---------- Steps ---------- */

.wk-step { margin-bottom: 2.1rem; }
.wk-step:last-of-type { margin-bottom: 0; }
.wk-step h2 {
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.55rem);
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin-bottom: 0.45rem;
}
.wk-step h2 .n {
  font-family: var(--body);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--clay-deep);
  background: var(--clay-soft);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  flex: none;
}
.prompt { font-size: 0.94rem; color: var(--ink-3); margin: 0 0 0.7rem; line-height: 1.6; max-width: 62ch; }

.wk-field {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  line-height: 1.7;
  resize: vertical;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  outline: none;
  font-size: 1rem;
}
.wk-field:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 140, 116, 0.14); }
.wk-field::placeholder { color: #9aa79e; }

.wk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.wk-small { display: grid; gap: 0.3rem; }
.wk-small label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }

.wk-list { margin: 0 0 0.9rem; padding-left: 1.3rem; color: var(--ink-2); line-height: 1.85; }
.wk-list li::marker { color: var(--clay); font-weight: 700; }
.wk-body { color: var(--ink-2); margin: 0 0 0.9rem; max-width: 62ch; }

.video-slot {
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--sage);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.5rem;
  color: var(--forest);
  margin-bottom: 1rem;
}
.video-slot p { margin: 0.5rem 0 0; font-size: 0.88rem; opacity: 0.8; }

/* ---------- Sheet footer ---------- */

.sheet-foot {
  margin-top: 2.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.sheet-foot .credit { font-size: 0.84rem; color: var(--ink-3); width: 100%; margin-top: 0.75rem; }
.sheet-foot .credit a { color: var(--clay-deep); font-weight: 600; }

.next-up {
  margin-top: 1.75rem;
  background: var(--forest-deep);
  color: rgba(251, 248, 242, 0.8);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  display: grid;
  gap: 0.6rem;
}
.next-up h3 { color: #fbf8f2; font-size: 1.2rem; }
.next-up p { margin: 0; font-size: 0.93rem; line-height: 1.6; }
.next-up a { color: var(--clay-soft); font-weight: 700; border-bottom: 1px solid rgba(239, 213, 194, 0.4); }

@media (max-width: 620px) {
  .wk-grid { grid-template-columns: 1fr; }
  .sheet-bar-inner { padding-inline: 1rem; }
  .back-link { width: 100%; margin-bottom: 0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Print: the filled-in sheet, nothing else ---------- */

@media print {
  body { background: #fff; font-size: 11.5pt; }
  .sheet-bar, .progress-strip, .sheet-foot, .next-up, .no-print { display: none !important; }
  .sheet-wrap { max-width: none; padding: 0; }
  .sheet { box-shadow: none; border: 0; border-radius: 0; padding: 0; background: #fff; }
  .sheet h1 { font-size: 24pt; }
  .wk-step { break-inside: avoid; margin-bottom: 1.1rem; }
  .wk-field {
    border: 1px solid #bbb;
    min-height: 3.5rem;
    /* Typed answers print; empty fields print as writable boxes */
    background: #fff;
  }
  .notice { background: none; border-left: 2px solid #999; }
  .privacy-line { display: none; }
  a { text-decoration: none; color: #000; }
}

/* ==========================================================================
   Legacy worksheet markup
   The nine worksheet pages still use the original print-sheet class names.
   These rules keep them rendering correctly on the new palette until each
   page is converted to the fillable .wk-* markup.
   ========================================================================== */

.wrap { max-width: 60rem; margin-inline: auto; padding: 2rem 1.4rem 4.5rem; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
.top .brand {
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--forest);
  text-decoration: none;
}
.top .nav { display: flex; gap: 1.25rem; }
.top .nav a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}
.top .nav a:hover { color: var(--clay-deep); border-bottom-color: var(--clay); }

/* Blank write-in areas on the print-only sheets */
.field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-height: 5.5rem;
  padding: 0.85rem 1rem;
  margin: 0.6rem 0 1.4rem;
  font-size: 0.92rem;
  color: var(--ink-3);
  line-height: 1.6;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.3rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--forest);
  color: var(--paper-card);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease);
}
.btn:hover { transform: translateY(-1px); background: var(--forest-deep); }
.btn.secondary {
  background: var(--paper-card);
  color: var(--ink);
  border-color: var(--line);
}
.btn.secondary:hover { background: #fff; border-color: var(--ink-3); }

.small { font-size: 0.85rem; color: var(--ink-3); margin-top: 2.5rem; }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .button-row .btn { width: 100%; justify-content: center; }
}

@media print {
  .top, .button-row { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .field { break-inside: avoid; min-height: 5rem; }
}

/* Placeholder for a value the practice owner still has to supply (license
   numbers). Deliberately loud so an unfilled one cannot ship unnoticed. */
.needs-value { background: var(--clay-soft); color: var(--clay-deep); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; padding: 0.05em 0.4em; border-radius: 3px; white-space: nowrap; }
.credit a { color: inherit; }
