/* MyHouseGrid base styles. Plain CSS, no framework. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2f0ea;
  --text: #1d2327;
  --muted: #5b6670;
  --border: #dedad0;
  --accent: #d97706;      /* amber, the "power" color */
  --accent-ink: #8a4b00;
  --link: #1f5f8b;
  --good: #2f7d4a;
  --warn: #a15c00;
  --warn-bg: #fff4e0;
  --bad: #a23a2a;
  --radius: 10px;
  --maxw: 1080px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191c;
    --surface: #1d2226;
    --surface-2: #252b30;
    --text: #e8e6e1;
    --muted: #a3acb3;
    --border: #343b41;
    --accent: #f59e0b;
    --accent-ink: #fbbf24;
    --link: #7cb8e4;
    --good: #5fbf7f;
    --warn: #f0b04a;
    --warn-bg: #2d2416;
    --bad: #e8806e;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
}

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

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 0.5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-top: 0.4em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 60px; gap: 16px;
}
.logo {
  font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.logo-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accent);
  display: inline-grid; place-items: center; color: #fff; font-size: 16px;
}
.logo span.dim { color: var(--muted); font-weight: 600; }

.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.nav a {
  display: block; padding: 8px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 550; font-size: 0.97rem;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent-ink); background: var(--surface-2); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer;
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0;
         background: var(--surface); border-bottom: 1px solid var(--border); }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; padding: 8px 16px 12px; }
  .nav a { padding: 12px; }
}

main { padding: 24px 0 56px; }

/* Hero */
.hero { padding: 32px 0 8px; }
.hero p.lede { font-size: 1.15rem; color: var(--muted); max-width: 680px; }

.btn {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  font-weight: 700; padding: 12px 18px; border-radius: 9px; border: 0; cursor: pointer; font: inherit;
  font-weight: 700;
}
.btn:hover { filter: brightness(0.95); }
.btn { margin: 0 6px 8px 0; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* Cards */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.card h2, .card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card .tag {
  display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--accent-ink); margin-bottom: 6px;
}
a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: var(--accent); }

.soon { color: var(--muted); font-size: 0.9rem; }

/* Callouts */
.note {
  background: var(--warn-bg); border-left: 4px solid var(--accent);
  padding: 12px 16px; border-radius: 6px; margin: 1em 0;
}
.note.safety { border-left-color: var(--bad); }
.note p:last-child { margin-bottom: 0; }

.todo {
  background: var(--surface-2); border: 1px dashed var(--muted); border-radius: 6px;
  padding: 8px 12px; color: var(--muted); font-size: 0.92rem;
}

/* Article */
.article-meta { color: var(--muted); font-size: 0.95rem; }
article ul li { margin-bottom: 0.3em; }

table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 650; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 0.92rem; padding: 24px 0 32px;
}
.site-footer a { color: var(--muted); }
.site-footer .cols { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* ---------- Calculator ---------- */
.calc { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.calc > *, .calc fieldset { min-width: 0; }
@media (min-width: 960px) {
  .calc { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
  .calc-results { position: sticky; top: 76px; }
}

.calc fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 14px 16px 16px; margin: 0 0 16px; }
.calc legend { font-weight: 750; padding: 0 6px; }

.app-group h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  margin: 14px 0 6px; }
.app-group:first-child h3 { margin-top: 4px; }

.app-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 8px 10px; border-radius: 8px; border: 1px solid transparent;
}
.app-row + .app-row { border-top-color: var(--border); border-top-left-radius: 0; border-top-right-radius: 0; }
.app-row.on { background: var(--surface-2); border-color: var(--border); border-radius: 8px; }
.app-row label.pick { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-weight: 550; }
.app-row label.pick input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--accent); }
.app-row .hint { display: block; font-weight: 400; font-size: 0.84rem; color: var(--muted); }
.app-row .defaults { font-size: 0.84rem; color: var(--muted); text-align: right; white-space: nowrap; }

.app-edit { grid-column: 1 / -1; display: none; gap: 10px; flex-wrap: wrap; padding-left: 28px; }
.app-row.on .app-edit { display: flex; }
.app-row.on .defaults { display: none; }

.field { display: flex; flex-direction: column; font-size: 0.82rem; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; width: 96px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.field.wide input, .field.wide select { width: 190px; }
.field.name input { width: 180px; }

.settings { display: flex; flex-wrap: wrap; gap: 14px 18px; }
.settings .field { font-size: 0.9rem; }
.settings .field input, .settings .field select { width: 150px; }
.settings .field small { margin-top: 3px; max-width: 210px; }

.calc-results .card { padding: 18px 18px 14px; }
.big-results { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stat .label { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 1.45rem; font-weight: 800; line-height: 1.2; }
.stat .sub { font-size: 0.84rem; color: var(--muted); }
.stat.wide { grid-column: 1 / -1; }
.stat.primary { background: var(--warn-bg); border: 1px solid var(--accent); }

.warnings { margin: 12px 0 0; padding: 0; list-style: none; }
.warnings li { font-size: 0.9rem; padding: 8px 10px; border-radius: 7px; background: var(--warn-bg);
  border-left: 3px solid var(--warn); margin-bottom: 6px; }
.warnings li.ok { border-left-color: var(--good); background: var(--surface-2); }

.empty { color: var(--muted); font-style: italic; }
.small { font-size: 0.88rem; color: var(--muted); }

.mini-results {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 6;
  background: var(--text); color: var(--bg); text-decoration: none;
  border-radius: 10px; padding: 10px 14px; font-weight: 650; font-size: 0.95rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}
.mini-results[hidden] { display: none; }
@media (min-width: 960px) { .mini-results { display: none !important; } }
@media (max-width: 959px) { .calc-results { scroll-margin-top: 70px; } body:has(.mini-results:not([hidden])) main { padding-bottom: 96px; } }
