/**
 * Homebrew & Fermentation Lab - Craftsman Paper Theme
 * Palette: #faf8f2 paper, #253d32 ink, #b56842 terracotta
 * Monospace numbers, precision ruler ticks, workshop print stylesheet.
 */

:root {
  --paper: #faf8f2;
  --paper-card: #fdfbf7;
  --paper-soft: #f4eee1;
  --paper-tint: #ece3d2;
  --ink: #253d32;
  --ink-muted: #56655c;
  --ink-light: #7c8b82;
  --line: #dcd3c4;
  --line-dark: #b8ad9a;
  --terracotta: #b56842;
  --terracotta-dark: #964e2b;
  --terracotta-light: #f7ede8;
  --amber: #c48229;
  --amber-soft: #fbf3e6;
  --foam: #fffdfa;
  --serif: Georgia, Cambria, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 25px;
}

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

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

h1 {
  font-size: clamp(34px, 4.2vw, 56px);
}

h2 {
  font-size: clamp(24px, 3vw, 36px);
}

h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

em {
  font-style: italic;
  color: var(--terracotta);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

/* Monospace numeric figures */
.mono, .stat-value, .spec-table td, input, select {
  font-family: var(--mono);
  font-feature-settings: "tnum" 1;
}

/* Precision Ruler Ticks */
.ruler-ticks {
  height: 14px;
  width: 100%;
  background-image: 
    repeating-linear-gradient(90deg, var(--line-dark) 0px, var(--line-dark) 1px, transparent 1px, transparent 12px),
    repeating-linear-gradient(90deg, var(--terracotta) 0px, var(--terracotta) 1.5px, transparent 1.5px, transparent 48px);
  background-size: 100% 8px, 100% 14px;
  background-position: bottom left;
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--line-dark);
  margin-block: 10px 20px;
  opacity: 0.85;
}

.wrap {
  width: min(1200px, calc(100% - 48px));
  margin-inline: auto;
}

.skip {
  position: absolute;
  top: -100px;
  left: 20px;
  background: var(--terracotta);
  color: #fff;
  padding: 10px 16px;
  z-index: 999;
  font-weight: 600;
}

.skip:focus {
  top: 10px;
}

/* Hub Header Strip */
.header {
  border-bottom: 1px solid var(--line);
  background: var(--paper-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header > .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand svg {
  flex-shrink: 0;
}

.brand span {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: block;
  line-height: 1.2;
}

.brand small {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--terracotta);
  font-family: var(--sans);
  font-weight: 700;
}

nav#navigation {
  display: flex;
  gap: 24px;
  align-items: center;
}

nav#navigation a {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  transition: color 0.15s ease;
  position: relative;
}

nav#navigation a:hover,
nav#navigation a.active {
  color: var(--ink);
}

nav#navigation a.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: var(--terracotta);
}

.nav-cta {
  background: var(--ink);
  color: var(--paper) !important;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600 !important;
  transition: background 0.2s ease !important;
}

.nav-cta:hover {
  background: var(--terracotta) !important;
}

/* Features Band */
.features {
  background: var(--paper-soft);
  border-bottom: 1px solid var(--line);
  padding-block: 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.features > .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.features span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.features strong {
  color: var(--ink);
}

/* Hero Section */
.hero {
  padding-block: clamp(40px, 6vw, 72px);
  border-bottom: 1px solid var(--line);
  background: radial-gradient(circle at 85% 20%, rgba(197, 155, 39, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 10% 80%, rgba(181, 104, 66, 0.06) 0%, transparent 50%),
              var(--paper);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin-bottom: 14px;
}

.eyebrow::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 2px;
  background: var(--terracotta);
}

.hero p.lead {
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 780px;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--terracotta);
  color: #fff;
  border: 1px solid var(--terracotta-dark);
  padding: 12px 24px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--terracotta-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-dark);
  padding: 12px 24px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  border-color: var(--ink);
  background: var(--paper-soft);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 3px;
}

/* Tool Grid Cards */
.section {
  padding-block: clamp(48px, 6vw, 80px);
}

.section-header {
  margin-bottom: 32px;
}

.section-header h2 {
  margin-bottom: 8px;
}

.section-header p {
  color: var(--ink-muted);
  font-size: 16px;
  max-width: 680px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.tool-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tool-card:hover {
  border-color: var(--terracotta);
  box-shadow: 0 10px 24px rgba(37, 61, 50, 0.06);
  transform: translateY(-3px);
}

.tool-number {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--terracotta);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tool-card h3 {
  font-size: 22px;
  margin-bottom: 12px;
}

.tool-card p {
  color: var(--ink-muted);
  font-size: 14.5px;
  flex-grow: 1;
  margin-bottom: 20px;
}

.tool-formula {
  background: var(--paper-soft);
  border-left: 2px solid var(--terracotta);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tool-link {
  font-weight: 600;
  color: var(--terracotta);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-card:hover .tool-link {
  color: var(--terracotta-dark);
}

/* Preset Chips Strip */
.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  align-items: center;
}

.preset-strip-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-right: 4px;
}

.preset-chip {
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink);
  transition: all 0.15s ease;
}

.preset-chip:hover {
  background: var(--paper-soft);
  border-color: var(--line-dark);
}

.preset-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Calculator Layout (Form + Results) */
.calculator {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 0;
  background: var(--paper-card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(37, 61, 50, 0.04);
  margin-bottom: 40px;
}

@media (max-width: 900px) {
  .calculator {
    grid-template-columns: 1fr;
  }
}

.form-side {
  padding: 32px;
  border-right: 1px solid var(--line);
}

@media (max-width: 900px) {
  .form-side {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

.result-side {
  padding: 32px;
  background: var(--paper-soft);
  display: flex;
  flex-direction: column;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-grid.single-col {
  grid-template-columns: 1fr;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.form-group label small {
  font-weight: 400;
  color: var(--ink-muted);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap:focus-within {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 2px var(--terracotta-light);
}

.input-wrap input,
.input-wrap select {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  font-size: 15px;
  outline: none;
}

.input-unit {
  padding-right: 12px;
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 500;
  user-select: none;
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}

.unit-btn {
  background: var(--paper);
  border: none;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.unit-btn.active {
  background: var(--ink);
  color: var(--paper);
}

.form-hint {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
}

/* Results Display */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.result-header h3 {
  margin: 0;
  font-size: 20px;
}

.result-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--terracotta);
}

.stat-callout {
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin-bottom: 20px;
  position: relative;
}

.stat-callout.highlight {
  border-left: 4px solid var(--terracotta);
}

.stat-value {
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 4px;
}

.stat-value small {
  font-size: 18px;
  font-weight: 400;
  color: var(--ink-muted);
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
}

/* Spec Data Table */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: 20px;
}

.spec-table tr {
  border-bottom: 1px solid var(--line);
}

.spec-table th,
.spec-table td {
  padding: 8px 6px;
  text-align: left;
}

.spec-table th {
  color: var(--ink-muted);
  font-weight: 500;
}

.spec-table td {
  font-weight: 600;
  text-align: right;
  color: var(--ink);
}

/* Diagram Container */
.diagram-container {
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}

.diagram-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.diagram-container svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Action Bar */
.action-bar {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* LocalStorage Stash Box */
.stash-box {
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 16px;
  margin-top: 20px;
}

.stash-box h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stash-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 180px;
  overflow-y: auto;
}

.stash-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 12.5px;
  border-bottom: 1px dotted var(--line);
}

.stash-item:last-child {
  border-bottom: none;
}

.stash-meta {
  display: flex;
  flex-direction: column;
}

.stash-name {
  font-weight: 600;
  color: var(--ink);
}

.stash-detail {
  font-size: 11px;
  color: var(--ink-muted);
}

.stash-delete {
  background: none;
  border: none;
  color: var(--terracotta);
  font-size: 16px;
  padding: 2px 6px;
  opacity: 0.7;
}

.stash-delete:hover {
  opacity: 1;
}

.stash-empty {
  font-size: 12px;
  color: var(--ink-muted);
  font-style: italic;
  padding-block: 8px;
}

/* Notice Box */
.notice-box {
  padding: 14px 18px;
  background: var(--paper-tint);
  border-left: 3px solid var(--terracotta);
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 20px;
}

/* Notes & Articles */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.note-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.note-card:hover {
  border-color: var(--terracotta);
}

.note-card h3 {
  font-size: 19px;
  margin-bottom: 10px;
}

.note-card p {
  color: var(--ink-muted);
  font-size: 14px;
  flex-grow: 1;
}

.note-meta {
  font-size: 12px;
  color: var(--terracotta);
  font-weight: 600;
  margin-top: 14px;
}

.article-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  padding-block: 40px;
}

@media (max-width: 800px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
}

.article-sidebar {
  border-right: 1px solid var(--line);
  padding-right: 24px;
}

@media (max-width: 800px) {
  .article-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 24px;
  }
}

.article-sidebar h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.article-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.article-sidebar li {
  margin-bottom: 10px;
}

.article-sidebar a {
  font-size: 14px;
  color: var(--ink-muted);
}

.article-sidebar a.active,
.article-sidebar a:hover {
  color: var(--terracotta);
  font-weight: 600;
}

.article-content h1 {
  margin-bottom: 14px;
}

.article-lead {
  font-size: 18px;
  color: var(--ink-muted);
  line-height: 1.6;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}

.article-content h2 {
  font-size: 24px;
  margin-top: 36px;
  margin-bottom: 14px;
}

.article-content p {
  font-size: 15.5px;
  margin-bottom: 18px;
}

.article-content code {
  display: block;
  background: var(--paper-soft);
  border-left: 3px solid var(--terracotta);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 13px;
  margin-block: 16px;
  overflow-x: auto;
}

/* Footer */
.footer {
  border-top: 1px solid var(--line);
  background: var(--paper-card);
  padding-block: 48px 32px;
  margin-top: 60px;
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 36px;
}

@media (max-width: 800px) {
  .footer-top {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 500px) {
  .footer-top {
    grid-template-columns: 1fr;
  }
}

.footer-col h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--terracotta);
  margin-bottom: 14px;
}

.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-col li {
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--ink-muted);
}

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

.footer-bottom {
  border-top: 1px solid var(--line);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-muted);
}

/* @media print: Professional Brew-Day Clipboard Sheet */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }

  .header,
  .footer,
  .skip,
  .features,
  .hero-actions,
  .preset-strip,
  .action-bar,
  .stash-box,
  nav#navigation,
  .unit-toggle {
    display: none !important;
  }

  .wrap {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .calculator {
    border: 1pt solid #000 !important;
    box-shadow: none !important;
    grid-template-columns: 1fr 1fr !important;
    page-break-inside: avoid;
  }

  .form-side,
  .result-side {
    background: #fff !important;
    padding: 16pt !important;
    border: none !important;
  }

  .form-side {
    border-right: 1pt solid #ccc !important;
  }

  .stat-callout {
    border: 1pt solid #000 !important;
    background: #f8f8f8 !important;
  }

  .stat-value {
    color: #000 !important;
  }

  .diagram-container {
    border: 1pt solid #ccc !important;
    background: #fff !important;
  }

  .ruler-ticks {
    display: none !important;
  }

  h1 {
    font-size: 20pt !important;
  }

  h2 {
    font-size: 16pt !important;
  }

  h3 {
    font-size: 13pt !important;
  }
}
