/* Outdoor theme: hunter green, ember orange and stone grays on a topographic
   map, with woodland camo on the header, card edges and footer. The art is
   in this folder (topo-*.svg, camo.svg), served from the site itself as the
   Content-Security-Policy requires. */

:root {
  --hunter: #355e3b;
  --hunter-dark: #24412a;
  --hunter-tint: #e6ede3;
  --ember: #e8772e;
  --ember-strong: #c4561a;
  --ember-tint: #fbeadf;
  --bg: #f4f3ef;
  --surface: #fffdf8;
  --surface-sunk: #f1efe8;
  --text: #232421;
  --muted: #6b6a63;
  --border: #d9d6cd;
  --heading: #355e3b;
  --button-text: #ffffff;
  --error: #a8321f;
  --shadow: 0 1px 2px rgb(35 36 33 / 6%), 0 10px 28px rgb(35 36 33 / 8%);
  --topo: url("topo-light.svg");
  --font: "Avenir Next", Avenir, "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hunter: #4f7d55;
    --hunter-dark: #3d6543;
    --hunter-tint: #223024;
    --ember: #f08a3c;
    --ember-strong: #f08a3c;
    --ember-tint: #3a2a1d;
    --bg: #141a15;
    --surface: #1d241e;
    --surface-sunk: #171d18;
    --text: #ebe8df;
    --muted: #a4a399;
    --border: #343d35;
    --heading: #9cc4a0;
    --error: #f0907f;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px rgb(0 0 0 / 30%);
    --topo: url("topo-dark.svg");
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg) var(--topo) center / cover fixed;
  color: var(--text);
  font: 16px/1.55 var(--font);
}

/* The app renders into #app; it fills the window so the footer sits at the bottom. */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header: a camo band with the mark and wordmark ---------- */

.site-header {
  background:
    linear-gradient(rgb(16 26 17 / 55%), rgb(16 26 17 / 55%)),
    url("camo.svg") 0 0 / 240px;
  border-bottom: 4px solid var(--ember);
  color: #ffffff;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  flex: none;
}

.brand-sun {
  fill: var(--ember);
}

.brand-peak {
  fill: #f2efe6;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 78%);
}

/* ---------- Page and cards ---------- */

main {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  flex: 1;
}

section {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.6rem 1.25rem 1.25rem;
  margin: 0 0 1.25rem;
}

/* A thin strip of camo along the top of each card. */
section::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: url("camo.svg") 0 0 / 120px;
}

h2 {
  margin: 0 0 0.75rem;
  color: var(--heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

h2::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 0.4rem;
  border-radius: 2px;
  background: var(--ember);
}

h3 {
  margin: 1.25rem 0 0.35rem;
  color: var(--heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

p {
  margin: 0.5rem 0;
}

/* ---------- Forms and buttons ---------- */

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

input:not([type="checkbox"]) {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-sunk);
  color: var(--text);
  font: inherit;
}

input:not([type="checkbox"]):focus {
  border-color: var(--hunter);
  outline: none;
  box-shadow: 0 0 0 3px rgb(232 119 46 / 35%);
}

input[type="checkbox"] {
  accent-color: var(--hunter);
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.2rem;
}

button {
  padding: 0.6rem 1rem;
  border: 2px solid var(--hunter);
  border-radius: 8px;
  background: var(--hunter);
  color: var(--button-text);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--hunter-dark);
  border-color: var(--hunter-dark);
}

button.secondary {
  background: transparent;
  color: var(--heading);
}

button.secondary:hover:not(:disabled) {
  background: var(--hunter-tint);
  color: var(--heading);
}

button.ghost {
  background: transparent;
  border-color: rgb(255 255 255 / 70%);
  color: #ffffff;
  padding: 0.4rem 0.8rem;
}

button.ghost:hover:not(:disabled) {
  background: rgb(255 255 255 / 14%);
  border-color: #ffffff;
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Lists shown as rows of cards ---------- */

ul.rows {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

ul.rows > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  margin: 0.45rem 0;
  border: 1px solid var(--border);
  border-left: 4px solid var(--hunter);
  border-radius: 8px;
  background: var(--surface-sunk);
  font-weight: 600;
}

ul.rows > li button {
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
}

/* ---------- Details ---------- */

pre,
code {
  font-family: var(--mono);
  font-size: 0.85rem;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
}

.recovery-key {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  /* Wrap at the hyphens between groups, never inside one. */
  overflow-wrap: anywhere;
  background: var(--ember-tint);
  border: 2px dashed var(--ember);
  border-radius: 10px;
  padding: 0.9rem;
}

.check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0.9rem 0;
}

details {
  margin-top: 1rem;
}

summary {
  cursor: pointer;
  color: var(--heading);
  font-weight: 600;
}

.error {
  color: var(--error);
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

.banner {
  background: var(--ember-tint);
  border-left: 4px solid var(--ember);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}

/* ---------- Footer: a camo strip ---------- */

.site-footer {
  height: 1.25rem;
  border-top: 3px solid var(--ember);
  background: url("camo.svg") 0 0 / 160px;
}

/* ---------- Links, header navigation ---------- */

a {
  color: var(--heading);
  text-underline-offset: 3px;
}

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

.site-nav {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem 0.65rem;
  display: flex;
  gap: 1.25rem;
}

.site-nav a {
  color: rgb(255 255 255 / 85%);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-bottom: 0.2rem;
  border-bottom: 3px solid transparent;
}

.site-nav a.active,
.site-nav a:hover {
  color: #ffffff;
  border-bottom-color: var(--ember);
}

.small {
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.loading {
  color: var(--muted);
  padding: 1rem 0;
}

.refresh {
  text-align: center;
}

/* ---------- Home: vehicle cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.9rem;
}

.vehicle-card {
  display: block;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--hunter);
  border-radius: 10px;
  background: var(--surface-sunk);
  color: var(--text);
  text-decoration: none;
}

.vehicle-card:hover {
  border-color: var(--ember);
}

.vehicle-card-head {
  font-size: 1.1rem;
  color: var(--heading);
}

.mileage {
  margin: 0.5rem 0;
  font-weight: 600;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.stat {
  font-size: 0.8rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--hunter-tint);
  color: var(--heading);
}

.stat-warn {
  background: var(--ember-tint);
  color: var(--ember-strong);
}

.stat-alert {
  background: var(--error);
  color: #ffffff;
}

/* ---------- Badges, chips, statuses ---------- */

.badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--hunter-tint);
  color: var(--heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.badge-warn {
  background: var(--ember-tint);
  color: var(--ember-strong);
}

.record-header .badge:first-child {
  margin-left: 0;
}

ul.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0.4rem 0;
}

ul.chips li {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--hunter-tint);
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 600;
}

.status {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-green {
  background: var(--hunter-tint);
  color: var(--heading);
}

.status-yellow {
  background: #f6e7b4;
  color: #6b5200;
}

.status-red {
  background: var(--error);
  color: #ffffff;
}

/* ---------- Vehicle bar: name, switcher, section tabs ---------- */

.vehicle-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem 0.6rem;
  margin: 0 0 1.25rem;
}

.vehicle-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.vehicle-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--heading);
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.tabs a {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--heading);
}

.tabs a.active {
  background: var(--hunter);
  color: #ffffff;
}

select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-sunk);
  color: var(--text);
  font: inherit;
}

/* ---------- Records ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.filters input[type="search"] {
  flex: 1 1 100%;
}

/* A select is as wide as its longest option; keep it inside the card. */
.filters select {
  max-width: 100%;
  min-width: 0;
}

.check.inline {
  margin: 0;
  align-items: center;
}

ul.record-rows > li,
ul.review-rows > li {
  padding: 0;
}

.record-row,
ul.review-rows > li > a {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  text-decoration: none;
}

ul.review-rows > li > a {
  display: block;
  font-weight: 400;
}

.record-date {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.record-meta {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .record-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

/* ---------- Record detail ---------- */

dl.facts {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.35rem 1rem;
  margin: 0.75rem 0;
}

dl.facts dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

dl.facts dd {
  margin: 0;
}

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

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

table.data th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

table.data .num {
  text-align: right;
  white-space: nowrap;
}

.job {
  border-left: 3px solid var(--ember);
  padding: 0.25rem 0 0.25rem 0.8rem;
  margin: 0.6rem 0;
}

.job .badge {
  margin-left: 0;
}

.document img {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.record-body {
  margin-top: 1.25rem;
}

.garage-vehicle + .garage-vehicle {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding-top: 0.25rem;
}

/* ---------- Markdown (history.md, record notes) ---------- */

.markdown h3 {
  font-size: 1.15rem;
  color: var(--heading);
  margin: 1rem 0 0.4rem;
  text-transform: none;
  letter-spacing: 0;
}

.markdown h4 {
  margin: 1.4rem 0 0.4rem;
}

.markdown h5 {
  margin: 1rem 0 0.3rem;
  font-size: 0.95rem;
}

ul.md-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0.4rem 0;
}

ul.md-list li {
  margin: 0.3rem 0;
}

ul.md-list li.nested {
  margin-left: 1.25rem;
  list-style: circle;
}

/* ---------- Charts (M6, M11) ---------- */

.chart {
  margin: 0.75rem 0 0.25rem;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--muted);
  font-size: 12px;
  font-family: var(--font);
}

.chart .threshold {
  stroke: var(--error);
  stroke-width: 1.5;
}

.chart .threshold-label {
  fill: var(--error);
  font-weight: 700;
}

.chart .series {
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .point {
  stroke-width: 2;
  stroke: var(--surface);
  cursor: pointer;
}

.s-line {
  stroke: var(--border);
}

.s-estimate {
  stroke: var(--ember);
}

.point.kind-service {
  fill: var(--hunter);
}

.point.kind-repair {
  fill: var(--ember);
}

.point.kind-inspection,
.point.kind-other,
.point.kind-parts {
  fill: #7c8470;
}

.point.kind-odometer {
  fill: #9a9a92;
}

/* Readings you entered are hollow. */
.point.owner {
  fill: var(--surface);
  stroke: var(--hunter);
}

.s-1 {
  stroke: var(--hunter);
  fill: var(--hunter);
}

.s-2 {
  stroke: var(--ember);
  fill: var(--ember);
}

.s-3 {
  stroke: #7c8470;
  fill: #7c8470;
}

.s-4 {
  stroke: #b0894a;
  fill: #b0894a;
}

.s-5 {
  stroke: #9a9a92;
  fill: #9a9a92;
}

.legend {
  color: var(--muted);
}

.legend .key {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  margin: 0 0.25rem 0 0.6rem;
  vertical-align: -0.05rem;
  background: var(--muted);
}

.legend .key.kind-service,
.legend .key.s-1 {
  background: var(--hunter);
}

.legend .key.kind-repair,
.legend .key.s-2 {
  background: var(--ember);
}

.legend .key.kind-inspection,
.legend .key.s-3 {
  background: #7c8470;
}

.legend .key.s-4 {
  background: #b0894a;
}

.legend .key.owner {
  background: transparent;
  border: 2px solid var(--hunter);
}

.legend .key-line {
  display: inline-block;
  width: 1.4rem;
  border-top: 3px dashed var(--ember);
  margin: 0 0.25rem 0 0.6rem;
  vertical-align: middle;
}

/* ---------- What's due ---------- */

ul.due-rows > li {
  display: block;
}

.due-main {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

ul.due-rows > li.due-overdue {
  border-left-color: var(--error);
}

ul.due-rows > li.due-due-soon {
  border-left-color: var(--ember);
}

ul.due-rows > li.due-no-history,
ul.due-rows > li.due-no-interval {
  border-left-color: var(--border);
}

ul.due-rows .small {
  font-weight: 400;
  margin-top: 0.2rem;
}

.projection {
  color: var(--ember-strong);
  font-weight: 600;
}

.due-status-overdue {
  background: var(--error);
  color: #ffffff;
}

.due-status-due-soon {
  background: var(--ember-tint);
  color: var(--ember-strong);
}

.due-status-ok {
  background: var(--hunter-tint);
  color: var(--heading);
}

.due-status-no-history,
.due-status-no-interval {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ---------- Actions and forms ---------- */

.inline-action {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
}

ul.review-rows > li {
  display: flex;
  align-items: center;
  padding-right: 0.85rem;
}

ul.review-rows > li > a {
  flex: 1;
}

button.danger {
  border-color: var(--error);
  color: var(--error);
}

button.danger:hover:not(:disabled) {
  background: var(--error);
  color: #ffffff;
}

.garage-actions,
.add-vehicle {
  margin: 0.5rem 0 0.75rem;
}

.add-vehicle {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

form.stacked {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.field input,
.field select {
  font-weight: 400;
}

/* Line paths take their color's stroke only; the color classes also set fill for markers. */
.chart path.series {
  fill: none;
}

/* In a stacked form the general input rule's 14rem flex size would become a height. */
.field input,
.field select {
  flex: none;
}

.garage-vehicle h3 {
  font-size: 1.1rem;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- Record editing (M3) ---------- */

a.button-link,
label.button-link {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border: 2px solid var(--hunter);
  border-radius: 8px;
  background: var(--hunter);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

a.button-link:hover,
label.button-link:hover {
  background: var(--hunter-dark);
  border-color: var(--hunter-dark);
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.record-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.5rem 0.75rem;
}

textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-sunk);
  color: var(--text);
  font: inherit;
}

fieldset.group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem 0.8rem;
  margin: 0;
}

fieldset.group legend {
  color: var(--heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0 0.3rem;
}

.group-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.45rem 0.6rem;
  align-items: end;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 0.6rem;
}

button.small-button {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  justify-self: start;
}

.services-picker .checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0 0.75rem;
}

.services-picker .check {
  margin: 0.3rem 0;
  font-size: 0.92rem;
}

/* ---------- Capture (M4) ---------- */

.capture-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

/* The file input is hidden inside its label, which looks like a button. */
.file-button {
  position: relative;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

a.button-link.secondary-link,
label.button-link.secondary-link {
  background: transparent;
  color: var(--heading);
}

.capture-link {
  margin: 0.4rem 0 0;
}
