/* ============================================================
   The Alcohol Care Question Book — shared stylesheet
   Cream paper, midnight blue, copper accents. No external fonts.
   ============================================================ */

:root {
  --bg: #faf6ef;
  --text: #1e2a3a;
  --muted: #3a4a5a;
  --accent: #a0522d;
  --accent-dark: #7a3b1e;
  --border: #d8cfc0;
  --white: #fff;
  --focus: #1e2a3a;
  --measure: 68ch;
  --max-width: 1140px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  overflow-wrap: break-word;
  word-break: break-word;
}

a:hover,
a:focus-visible {
  color: var(--accent-dark);
  text-decoration-thickness: 0.12em;
}

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

/* ---------- Shared shell ---------- */

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

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem;
}

.brand {
  font-size: 1.35rem;
  font-weight: bold;
  letter-spacing: 0.02em;
  margin-right: auto;
}

.brand a {
  text-decoration: none;
  color: var(--text);
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.site-nav a {
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.outermain {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.footer-nav a {
  color: var(--muted);
  text-decoration: underline;
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: var(--accent-dark);
}

/* ---------- Home page ---------- */

.page.home {
  padding: 2rem 0 3rem;
}

.home-inner {
  max-width: var(--measure);
  margin: 0 auto;
}

.home-inner h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 1.1;
  margin: 0 0 1.5rem;
  letter-spacing: -0.02em;
}

.lede {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 2.5rem;
  max-width: 65ch;
}

.chapter {
  margin: 0 0 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.chapter h2 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 1rem;
  color: var(--text);
}

.chapter p {
  margin: 0 0 1rem;
  max-width: var(--measure);
}

.task {
  font-style: italic;
  color: var(--muted);
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  margin: 1.5rem 0;
}

.chapter a {
  font-weight: bold;
  display: inline-block;
  margin-right: 1.5rem;
  margin-bottom: 0.5rem;
}

.closing {
  font-size: 0.9rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  margin-top: 3rem;
}

.source-notes {
  margin-top: 2rem;
  font-size: 0.9rem;
}

.source-notes h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

.source-notes ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.source-notes li {
  margin-bottom: 0.5rem;
}

.source-notes a {
  color: var(--muted);
}

/* ---------- Tool page ---------- */

.page.tool {
  padding: 2rem 0 3rem;
}

.tool-page h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}

.tool-intro {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: var(--measure);
  margin: 0 0 2rem;
}

#worksheet-form {
  max-width: var(--measure);
  margin: 0 0 2rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin: 0 0 1.5rem;
}

legend {
  font-weight: bold;
  padding: 0 0.5rem;
  font-size: 1.1rem;
}

.field-group {
  margin-bottom: 1.5rem;
}

.field-group label,
.label-text {
  display: block;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

select,
input[type="checkbox"] {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 4px;
}

select {
  width: 100%;
  max-width: 30rem;
}

select:focus,
input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.checkbox-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.checkbox-list label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: normal;
}

.field-help {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}

.tool-actions button {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 1.2rem;
  background: var(--text);
  color: var(--bg);
  border: 2px solid var(--text);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tool-actions button:hover,
.tool-actions button:focus-visible {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--white);
}

.tool-actions button:disabled {
  background: var(--border);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.form-help-text {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 1rem;
}

#results {
  max-width: var(--measure);
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
}

#results h2 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

#results ul {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

#results li {
  margin-bottom: 0.5rem;
}

#status {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 1rem 0;
}

.noscript-note {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 4px;
  font-size: 0.95rem;
}

/* ---------- Article pages ---------- */

.page.article {
  padding: 2rem 0 3rem;
}

.article-header {
  max-width: var(--measure);
  margin: 0 auto 2rem;
}

.article-header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}

.article-body {
  max-width: var(--measure);
  margin: 0 auto;
}

.article-body p {
  margin: 0 0 1.5rem;
}

.article-figure {
  margin: 2rem 0;
}

.article-figure img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.media-caption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ---------- Professional review aside ---------- */

.professional-review {
  max-width: var(--measure);
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--white);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
}

.professional-review h2 {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}

.professional-review p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---------- Directory (if used) ---------- */

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

.program-row {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
}

.program-title {
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
}

.program-meta {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.program-summary {
  font-size: 1rem;
  margin: 0;
}

/* ---------- Tables ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--bg);
  font-weight: bold;
}

/* ---------- Utility ---------- */

.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;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  body {
    font-size: 17px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav ul {
    gap: 0.75rem;
  }

  .home-inner h1 {
    font-size: 2.5rem;
  }

  .chapter h2 {
    font-size: 1.6rem;
  }

  .tool-actions {
    flex-direction: column;
  }

  .tool-actions button {
    width: 100%;
  }

  .checkbox-list {
    grid-template-columns: 1fr;
  }
}

/* ---------- Reduced motion ---------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  body {
    background: var(--white);
    color: var(--text);
  }

  .site-header,
  .site-footer,
  .tool-actions,
  .noscript-note {
    display: none;
  }

  .page {
    padding: 0;
  }
}
