/*
 * Square Footage Calculator — stylesheet
 * System font stack, CSS custom properties, mobile-first, print-friendly.
 * Light, clean, trustworthy by default; dark mode via [data-theme="dark"]
 * or prefers-color-scheme, toggle stored in localStorage.
 */

:root {
  --bg-0: #ffffff;
  --bg-1: #f6f8fa;
  --bg-2: #eef1f5;
  --line: #dbe0e6;
  --fg: #1a2028;
  --fg-muted: #566072;
  --accent: #0b6e4f;
  --accent-fg: #ffffff;
  --ok: #157a45;
  --warn: #a15c00;
  --danger: #b3261e;
  --radius: 10px;
  --focus-ring: 0 0 0 3px rgba(11, 110, 79, 0.35);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter",
    Helvetica, Arial, sans-serif;
  --font-tabular: "Segoe UI", Arial, sans-serif;
  --shadow-1: 0 1px 2px rgba(20, 30, 40, 0.06), 0 1px 1px rgba(20, 30, 40, 0.04);
}

[data-theme="dark"] {
  --bg-0: #0d1117;
  --bg-1: #131a22;
  --bg-2: #1a2330;
  --line: #2a3644;
  --fg: #e7ecf2;
  --fg-muted: #9aa7b7;
  --accent: #3ddc97;
  --accent-fg: #05261a;
  --ok: #3ddc97;
  --warn: #f5b656;
  --danger: #ff8a80;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-0: #0d1117;
    --bg-1: #131a22;
    --bg-2: #1a2330;
    --line: #2a3644;
    --fg: #e7ecf2;
    --fg-muted: #9aa7b7;
    --accent: #3ddc97;
    --accent-fg: #05261a;
    --ok: #3ddc97;
    --warn: #f5b656;
    --danger: #ff8a80;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.55;
  font-numeric-spacing: tabular-nums;
  -webkit-font-smoothing: antialiased;
  transition: background-color 150ms ease, color 150ms ease;
}

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

a {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.6rem 1rem;
  z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

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

.header-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.theme-toggle:hover {
  border-color: var(--accent);
}
.theme-toggle:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.content-column {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

main {
  padding-top: 1.75rem;
  padding-bottom: 2rem;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.2;
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}

.lede {
  color: var(--fg-muted);
  font-size: 1.02rem;
  margin: 0 0 1.5rem;
  max-width: 60ch;
}

h2 {
  font-size: 1.3rem;
  margin: 2.2rem 0 0.8rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
}

p {
  margin: 0 0 1rem;
}

/* --- Calculator card --- */

.calculator {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-1);
}

.calc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-muted);
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.unit-toggle button {
  border: none;
  background: var(--bg-2);
  color: var(--fg);
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.unit-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

input[type="number"],
input[type="text"] {
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-0);
  color: var(--fg);
  width: 100%;
}

input[type="number"] {
  max-width: 9rem;
}

.waste-field input {
  max-width: 6rem;
}

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

table.rooms {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

table.rooms caption {
  text-align: left;
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

table.rooms th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg-muted);
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

table.rooms td {
  padding: 0.4rem 0.5rem;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.room-name-input {
  min-width: 9rem;
}

.l-toggle-btn,
.remove-room-btn {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.l-toggle-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.remove-room-btn {
  color: var(--danger);
}
.l-toggle-btn:hover,
.remove-room-btn:hover {
  border-color: var(--accent);
}

.l-extra-row td {
  background: var(--bg-2);
  padding: 0.6rem 0.5rem;
}

.l-extra-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.room-area-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.btn {
  font: inherit;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
}
.btn:hover {
  border-color: var(--accent);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover {
  filter: brightness(1.05);
}

/* Reserve space for results so nothing shifts when values change */
.results {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  min-height: 108px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
}

.result-stat dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg-muted);
}
.result-stat dd {
  margin: 0.15rem 0 0;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 1.75rem;
}

.copy-feedback {
  font-size: 0.85rem;
  color: var(--ok);
  min-height: 1.2rem;
  margin-top: 0.5rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.78rem;
  min-height: 1rem;
}

/* --- Ad slots --- */

.ad-slot {
  box-sizing: border-box;
  margin: 1.75rem auto;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: 300px;
  height: 250px;
  max-width: 100%;
  background: var(--bg-1);
}

@media (min-width: 760px) {
  .ad-slot {
    width: 728px;
    height: 90px;
  }
}

/* --- Content sections --- */

.content-section {
  margin-top: 2rem;
}

.example-box {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}

.faq-item {
  border-bottom: 1px solid var(--line);
  padding: 1rem 0;
}
.faq-item:last-child {
  border-bottom: none;
}
.faq-item h3 {
  margin-top: 0;
}

footer.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2.5rem;
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

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

@media (max-width: 480px) {
  .results {
    grid-template-columns: 1fr;
  }
  .calc-toolbar {
    align-items: stretch;
  }
}

/* --- Site nav + footer links (added for About/Privacy/Contact/404 pages) --- */
/* Appended block; does not alter any rule above. */

.header-inner {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.9rem;
  order: 3;
  flex-basis: 100%;
}

@media (min-width: 640px) {
  .site-nav {
    order: 2;
    flex-basis: auto;
    margin-right: auto;
    margin-left: 1.5rem;
  }
}

.site-nav a {
  color: var(--fg-muted);
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent);
}
.site-nav a[aria-current="page"] {
  font-weight: 600;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.footer-links a {
  color: var(--fg-muted);
}
.footer-links a:hover {
  color: var(--accent);
}

/* Simple content page styling for About/Privacy/Contact (no calculator card) */
.page-section {
  margin-top: 0.5rem;
}
.page-section h2 {
  margin-top: 2rem;
}
.page-section ul {
  margin: 0 0 1rem;
  padding-left: 1.3rem;
}
.page-section li {
  margin-bottom: 0.4rem;
}

.not-found {
  text-align: center;
  padding: 2rem 0;
}
.not-found .btn-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.5rem;
}

@media print {
  header.site-header,
  .calc-toolbar,
  .rooms-table-wrap,
  .calc-actions,
  .ad-slot,
  footer.site-footer,
  .theme-toggle {
    display: none !important;
  }
  .results {
    border: 1px solid #000;
    box-shadow: none;
  }
  body {
    background: #fff;
    color: #000;
  }
}
