/* ==========================================================================
   Gravel Calculators - global stylesheet
   Plain CSS3, no frameworks, no external fonts or dependencies.
   Palette: warm stone neutrals + slate ink + amber accent.
   ========================================================================== */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #26221f;
  --ink-soft: #57534e;
  --ink-faint: #79716b;
  --line: #e7e2dc;
  --line-strong: #d6cfc7;
  --accent: #b45309;
  --accent-dark: #92400e;
  --accent-soft: #fdf1e2;
  --ok: #166534;
  --ok-soft: #ecfdf3;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --footer-bg: #211d1a;
  --footer-ink: #d6d3d1;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(38, 34, 31, 0.06), 0 4px 14px rgba(38, 34, 31, 0.05);
  --shadow-lift: 0 2px 4px rgba(38, 34, 31, 0.07), 0 10px 26px rgba(38, 34, 31, 0.09);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, Menlo, monospace;
}

/* ---------- Reset & base ---------- */

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

img, svg { max-width: 100%; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; color: var(--ink); }

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); letter-spacing: -0.01em; margin-top: 2.5rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

a { color: var(--accent-dark); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.section { padding: 1.5rem 0 2rem; }

.section-intro { max-width: 46rem; color: var(--ink-soft); }

.eyebrow {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-bottom: 0.35rem;
}

/* ---------- Header / navigation ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand svg { flex: 0 0 auto; }

.nav-toggle {
  display: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

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

.site-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
}
.site-nav a:hover { color: var(--ink); background: var(--bg); }

/* ---------- Hero + calculator ---------- */

.hero {
  background: linear-gradient(180deg, #f1ede7 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: 2.25rem 0 2.5rem;
}

.hero-lede {
  max-width: 44rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.calc-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-top: 1.5rem;
  overflow: hidden;
}

.calc-card form { padding: 1.5rem; }

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1.25rem;
}

legend {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  padding: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}
.field .unit-hint { font-weight: 400; color: var(--ink-faint); }

input[type="number"], select {
  width: 100%;
  min-height: 46px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.18); }

/* Shape / unit segmented controls */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.segmented label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  background: var(--surface);
}

.segmented input { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }

.segmented label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 46px;
  padding: 0.6rem 1.4rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; color: #fff; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
.btn-secondary:hover { color: var(--ink); border-color: var(--ink-faint); background: var(--bg); }

/* Results */
.calc-results {
  border-top: 1px solid var(--line);
  background: var(--ok-soft);
  padding: 1.5rem;
}

.calc-results[data-state="empty"] { background: transparent; color: var(--ink-faint); }
.calc-results[data-state="error"] { background: var(--danger-soft); color: var(--danger); }
.calc-results[data-state="error"] p { margin: 0; font-weight: 600; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin: 0 0 1rem;
}

.result-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem;
}

.result-tile.primary { border-color: var(--accent); box-shadow: var(--shadow); }

.result-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.15rem;
}

.result-value { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em; }
.result-tile.primary .result-value { color: var(--accent-dark); }
.result-sub { font-size: 0.82rem; color: var(--ink-faint); }

.results-formula {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 0 0 1rem;
  overflow-x: auto;
}

.results-note { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 1rem; }

.results-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.copy-feedback { font-size: 0.88rem; color: var(--ok); font-weight: 600; align-self: center; }

/* ---------- Tool / guide cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: box-shadow 120ms ease, transform 120ms ease;
}

a.tool-card:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
  color: inherit;
}

.tool-card h3 { margin-bottom: 0.3rem; }
a.tool-card h3 { color: var(--accent-dark); }
.tool-card p { font-size: 0.92rem; color: var(--ink-soft); margin: 0; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.45rem;
}

.badge-planned { background: var(--bg); color: var(--ink-faint); border: 1px solid var(--line-strong); }
.badge-tool { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #f3d9b8; }
.badge-guide { background: #eef4ff; color: #1e40af; border: 1px solid #d7e3fb; }

/* ---------- Content blocks ---------- */

.prose { max-width: 46rem; }

.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 0.35rem; }

.note-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  max-width: 46rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 0.94rem;
}

.data-table caption {
  text-align: left;
  font-size: 0.88rem;
  color: var(--ink-faint);
  padding-bottom: 0.5rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table thead th { background: var(--bg); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td:first-child { font-weight: 700; }

.table-wrap { overflow-x: auto; }

/* Diagram */
.figure {
  margin: 1.25rem 0;
  max-width: 460px;
}
.figure figcaption { font-size: 0.85rem; color: var(--ink-faint); margin-top: 0.4rem; }

/* ---------- FAQ ---------- */

.faq { max-width: 46rem; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.7rem;
}

.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.85rem 1.1rem;
  list-style-position: outside;
}

.faq details[open] summary { border-bottom: 1px solid var(--line); }
.faq details p { padding: 0.2rem 1.1rem 0.9rem; margin: 0; color: var(--ink-soft); }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--footer-bg);
  color: var(--footer-ink);
  margin-top: 3rem;
  padding: 2.5rem 0 1.75rem;
  font-size: 0.92rem;
}

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

.site-footer h2 { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: #a8a29e; margin: 0 0 0.75rem; }

.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.4rem; }
.site-footer a { color: var(--footer-ink); text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }

.footer-brand { display: flex; align-items: center; gap: 0.5rem; color: #fff; font-weight: 800; font-size: 1.05rem; margin-bottom: 0.6rem; }

.footer-disclaimer {
  border-top: 1px solid #38322e;
  margin-top: 2rem;
  padding-top: 1.25rem;
  font-size: 0.84rem;
  color: #a8a29e;
}

/* ---------- Breadcrumbs (pattern for child pages) ---------- */

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--ink-faint);
  padding: 0.9rem 0 0;
}
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "\203A"; margin-right: 0.35rem; color: var(--line-strong); }
.breadcrumbs a { color: var(--ink-soft); }

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

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

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }

  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lift);
  }

  .site-nav.nav-open { display: block; }

  .site-nav ul { flex-direction: column; padding: 0.5rem 1rem 1rem; }
  .site-nav a { padding: 0.7rem 0.5rem; font-size: 1rem; }

  .calc-card form { padding: 1.1rem; }
  .calc-results { padding: 1.1rem; }
  .result-value { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .field-row { grid-template-columns: 1fr; }
}

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

@media print {
  .site-header, .site-footer, .calc-actions, .results-actions, .skip-link, .nav-toggle { display: none !important; }
  body { background: #fff; }
  .calc-card, .calc-results { border: 1px solid #999; box-shadow: none; }
}
