/* The Warm House Journal — theme
   Parchment, rust and dark chestnut. Editorial serif headings, system stack.
   No gradients, no rounded-card grids, no external dependencies. */

:root {
  --paper: #f3e9d6;
  --paper-deep: #ece0c8;
  --paper-edge: #ddcdb0;
  --ink: #2c1d12;
  --ink-soft: #4a3423;
  --ink-mute: #5c4632;
  --rule: #b7a17f;
  --rust: #8f3c1b;
  --rust-deep: #732f14;
  --rust-wash: #f6e5d6;
  --chestnut: #3a2618;
  --focus: #12655a;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  /* subtle paper texture via tiny repeating half-transparent rules, no gradient */
  background-image:
    repeating-linear-gradient(0deg, rgba(58,38,24,0.018) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(58,38,24,0.014) 0 1px, transparent 1px 4px);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.62;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--chestnut);
  line-height: 1.16;
  margin: 0 0 0.6rem;
  font-weight: 700;
}

p { margin: 0 0 1rem; }

a { color: var(--rust-deep); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--rust); }

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--chestnut);
  color: #fff8ea;
  padding: 0.55rem 1rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  z-index: 50;
  transition: top 160ms ease;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- shared header ---------- */
.site-header {
  border-bottom: 1px solid var(--rule);
  background-color: var(--paper-deep);
}
.header-inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
}
.brand { margin: 0; font-size: 1.15rem; letter-spacing: 0.01em; }
.brand a {
  color: var(--chestnut);
  text-decoration: none;
  font-weight: 700;
}
.brand-mark { color: var(--rust); margin-right: 0.4rem; }
.site-nav ul, .footer-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.35rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}
.site-nav a:hover { color: var(--rust-deep); border-bottom-color: var(--rust); }

/* ---------- shared footer ---------- */
.site-footer {
  border-top: 3px double var(--rule);
  background-color: var(--paper-deep);
  margin-top: 3rem;
}
.footer-inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem 1.5rem;
}
.footer-brand {
  margin: 0;
  font-weight: 700;
  color: var(--chestnut);
}
.footer-nav a { color: var(--ink-soft); text-decoration: none; }
.footer-nav a:hover { color: var(--rust-deep); text-decoration: underline; }

/* ---------- page shells ---------- */
.page, .page.home { max-width: 76rem; margin: 0 auto; padding: 0 1.5rem; }

.kicker {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rust-deep);
  margin: 0 0 0.7rem;
  font-weight: 600;
}

.lede {
  font-size: 1.15rem;
  line-height: 1.58;
  color: var(--ink-soft);
  max-width: 44rem;
}

/* ---------- buttons ---------- */
.button {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.7rem 1.15rem;
  border: 1.5px solid var(--chestnut);
  background-color: var(--paper);
  color: var(--chestnut);
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
}
.button:hover { background-color: var(--rust-wash); }
.button--primary {
  background-color: var(--rust-deep);
  border-color: var(--rust-deep);
  color: #fff8ea;
}
.button--primary:hover { background-color: #5c2610; border-color: #5c2610; color: #fff8ea; }
.button--quiet {
  background-color: transparent;
  border-color: var(--rule);
  color: var(--ink-soft);
}
.button--quiet:hover { background-color: var(--paper-deep); }
.button[disabled], .button:disabled {
  cursor: not-allowed;
  opacity: 1;
  background-color: #e4d8c1;
  border-color: #9b8a70;
  color: #5b4a36;
}

.text-link {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--rust-deep);
}

/* ---------- home cover (asymmetric) ---------- */
.home-cover {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  gap: 2.25rem 3rem;
  padding: 2.75rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}
.home-cover h1 {
  font-size: clamp(1.9rem, 3.6vw, 3.05rem);
  letter-spacing: -0.008em;
  margin-bottom: 1rem;
}
.cover-copy { padding-top: 0.4rem; }
.cover-actions {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 1.35rem;
}

.cover-figure {
  margin: 0;
  border: 1px solid var(--rule);
  background-color: #fbf5e8;
  padding: 0.9rem 0.9rem 0.75rem;
}
.schematic { display: block; width: 100%; height: auto; }
.cover-figure figcaption {
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-mute);
  border-top: 1px solid var(--paper-edge);
  padding-top: 0.55rem;
  margin-top: 0.55rem;
}

/* ---------- home sections: rail + body ---------- */
.home-section {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.6fr);
  gap: 1.25rem 3rem;
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.home-section--ruled { background-color: rgba(236,224,200,0.45); }
.section-rail h2 { font-size: clamp(1.35rem, 2.2vw, 1.8rem); margin-bottom: 0; }
.section-body { min-width: 0; }
.section-actions { margin: 1.1rem 0 1.4rem; }

.spec-list { margin: 0; border-top: 1px solid var(--rule); }
.spec-list > div {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr);
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dotted var(--rule);
}
.spec-list dt {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.spec-list dd { margin: 0; }

/* guide list: ruled editorial index */
.guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--chestnut);
}
.guide-list li { border-bottom: 1px solid var(--rule); }
.guide-list a {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 0.15rem 1rem;
  padding: 1rem 0.4rem 1rem 0;
  text-decoration: none;
  color: var(--ink);
}
.guide-list a:hover { background-color: var(--rust-wash); }
.guide-list a:hover .guide-title { text-decoration: underline; text-underline-offset: 3px; }
.guide-num {
  grid-row: 1 / span 2;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--rust);
  padding-top: 0.2rem;
}
.guide-title { font-size: 1.18rem; font-weight: 700; color: var(--chestnut); }
.guide-note { font-size: 0.98rem; color: var(--ink-soft); line-height: 1.5; }

/* safety ruled columns */
.ruled-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 2.25rem;
}
.ruled-col h3 { font-size: 1.1rem; }
.ruled-col + .ruled-col {
  border-left: 1px solid var(--rule);
  padding-left: 2.25rem;
  margin-left: -0.05rem;
}
.source-links { margin: 0.4rem 0 1rem; padding-left: 1.1rem; }
.source-links li { margin-bottom: 0.35rem; }
.fine { font-size: 0.92rem; color: var(--ink-soft); }

/* colophon */
.home-colophon {
  padding: 2.5rem 0 1rem;
  max-width: 50rem;
}
.home-colophon h2 { font-size: 1.25rem; }
.home-colophon p { color: var(--ink-soft); }

/* ---------- article pages ---------- */
article.page.article { max-width: 76rem; margin: 0 auto; padding: 0 1.5rem; }
.article-header {
  padding: 2.5rem 0 1.6rem;
  border-bottom: 1px solid var(--rule);
  max-width: 52rem;
}
.article-header h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }
.article-body { max-width: 46rem; padding: 1.8rem 0 1rem; }
.article-body h2 { margin-top: 2rem; font-size: 1.5rem; }
.article-body h3 { margin-top: 1.4rem; font-size: 1.15rem; }
.article-body ul, .article-body ol { padding-left: 1.25rem; }
.article-body li { margin-bottom: 0.4rem; }
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.97rem;
}
.article-body caption {
  text-align: left;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
  padding-bottom: 0.4rem;
}
.article-body th, .article-body td {
  border: 1px solid var(--rule);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.article-body th { background-color: var(--paper-deep); color: var(--chestnut); }

/* source table */
.source-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 2rem;
  font-size: 0.92rem;
}
.source-table caption { text-align: left; font-style: italic; color: var(--ink-mute); padding-bottom: 0.4rem; }
.source-table th, .source-table td {
  border: 1px solid var(--rule);
  padding: 0.5rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.source-table th { background-color: var(--paper-deep); }

/* ---------- tool page ---------- */
.page--tool { max-width: 76rem; margin: 0 auto; padding: 0 1.5rem; }
.page-intro { padding: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--rule); max-width: 54rem; }
.page-intro h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }

.journal-panel {
  border: 1px solid var(--rule);
  background-color: #fbf5e8;
  padding: 1.35rem 1.4rem 1.6rem;
  margin: 1.6rem 0;
}
.journal-panel h2 { font-size: 1.4rem; border-bottom: 1px solid var(--paper-edge); padding-bottom: 0.45rem; }
.panel-note { font-family: var(--sans); font-size: 0.88rem; line-height: 1.5; color: var(--ink-mute); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rust-deep);
  font-weight: 600;
  padding: 0 0 0.5rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.5rem;
}
.field { margin: 0 0 1.15rem; min-width: 0; }
.field label {
  display: block;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
.hint {
  font-family: var(--sans);
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--ink-mute);
  margin: 0 0 0.4rem;
}
input[type="text"],
input[type="number"],
textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background-color: #fffdf6;
  border: 1.5px solid #8a7558;
  border-radius: 0;
  padding: 0.55rem 0.6rem;
}
textarea { resize: vertical; min-height: 6rem; }
input::placeholder { color: #6b5944; opacity: 1; }

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 0.9rem;
  margin: 0.4rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--paper-edge);
}

.status {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0;
}

.results {
  min-height: 5rem;
  border: 1px dashed var(--rule);
  background-color: #fffdf6;
  padding: 0.9rem 1rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.plain-list { padding-left: 1.15rem; margin: 0.4rem 0 0; }
.plain-list li { margin-bottom: 0.65rem; }

.notebox {
  border-left: 4px solid var(--rust);
  background-color: var(--rust-wash);
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
}
.notebox h2 { font-size: 1.15rem; }

/* disabled fieldset: keep text readable */
fieldset[disabled] { color: var(--ink-soft); }
fieldset[disabled] input, fieldset[disabled] textarea { background-color: #f1e7d3; }

/* ---------- responsive ---------- */
@media (max-width: 62rem) {
  .home-cover { grid-template-columns: minmax(0, 1fr); gap: 1.6rem; }
  .cover-figure { max-width: 30rem; }
  .home-section { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
  .section-rail h2 { margin-bottom: 0.3rem; }
}

@media (max-width: 44rem) {
  body { font-size: 1rem; }
  .header-inner { padding: 0.8rem 1rem; }
  .page, .page.home, .page--tool, article.page.article { padding: 0 1rem; }
  .home-cover { padding: 1.8rem 0 1.6rem; }
  .home-cover h1 { font-size: clamp(1.65rem, 7.2vw, 2.2rem); }
  .lede { font-size: 1.05rem; }
  .home-section { padding: 1.8rem 0; }
  .ruled-columns { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ruled-col + .ruled-col {
    border-left: 0;
    border-top: 1px solid var(--rule);
    padding-left: 0;
    padding-top: 1.1rem;
    margin-top: 1.1rem;
  }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .journal-panel { padding: 1rem 0.95rem 1.2rem; }
  .button { width: 100%; text-align: center; }
  .tool-actions { flex-direction: column; }
  .guide-list a { grid-template-columns: 2.2rem minmax(0, 1fr); }
  .spec-list > div { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
  .article-body table, .source-table { display: block; overflow-x: auto; }
  .footer-inner { padding: 1.2rem 1rem 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .skip-link { transition: none; }
}
