/* Vintage computers: one stylesheet, light and dark from the system setting, phone first. */

:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe6da;
  --text: #22201c;
  --muted: #6b655a;
  --line: #d9d2c3;
  --accent: #8a4b12;        /* amber, darkened for contrast on cream */
  --accent-text: #fffdf8;
  --focus: #1f6feb;
  --owned-bg: #dcefdc; --owned-fg: #1f5a24;
  --ordered-bg: #fbe7c2; --ordered-fg: #7a4a00;
  --wanted-bg: #e3e4f5; --wanted-fg: #353b8a;
  --danger: #a3271b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #1e2024;
    --surface-2: #272a30;
    --text: #e9e6df;
    --muted: #a19b90;
    --line: #34373e;
    --accent: #f0a23b;      /* amber phosphor */
    --accent-text: #1a1206;
    --focus: #6ea8fe;
    --owned-bg: #1f3a22; --owned-fg: #a6e0a9;
    --ordered-bg: #3d2e12; --ordered-fg: #f6c66d;
    --wanted-bg: #262a4a; --wanted-fg: #b9bff5;
    --danger: #ff7b6b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; display: block; }
h1, h2 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0.2em 0 0.3em; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.85rem; font-weight: normal; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header.site, footer.site, main { max-width: 1120px; margin: 0 auto; padding-inline: 16px; }
header.site {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 14px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand-mark { color: var(--accent); font-family: var(--mono); }
header.site nav { display: flex; gap: 16px; }
header.site nav a { color: var(--text); text-decoration: none; font-weight: 500; }
header.site nav a:hover { color: var(--accent); }
main { padding-block: 8px 48px; }
footer.site {
  display: flex; justify-content: space-between; gap: 12px; padding-block: 24px 32px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem;
}
a.quiet { color: var(--muted); }

.intro p { margin-top: 0; max-width: 60ch; }

/* Status filter */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.filters a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.filters a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; font-size: 0.9em; }
.filters a[aria-current="page"] .count { color: inherit; opacity: 0.8; }
h2 .count { margin-left: 4px; }

.tag, .pn, .mono { font-family: var(--mono); }
.tag {
  font-size: 0.85em; padding: 1px 6px; border-radius: 5px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line);
}
.badge {
  display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  white-space: nowrap;
}
.badge-owned { background: var(--owned-bg); color: var(--owned-fg); }
.badge-ordered { background: var(--ordered-bg); color: var(--ordered-fg); }
.badge-wanted { background: var(--wanted-bg); color: var(--wanted-fg); }
.empty { color: var(--muted); font-style: italic; }

/* Inventory table: a table on wide screens, cards on a phone */
table { border-collapse: collapse; width: 100%; }
.inv, .parts {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; border-collapse: separate; border-spacing: 0;
}
.inv th, .inv td, .parts th, .parts td { padding: 10px 12px; text-align: left; vertical-align: middle; }
.inv thead th, .parts thead th {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  background: var(--surface-2); font-weight: 600;
}
.inv tbody tr + tr td, .parts tbody tr + tr td { border-top: 1px solid var(--line); }
.inv .num, .parts .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv .c-name a { font-weight: 600; color: var(--text); text-decoration: none; }
.inv .c-name a:hover { color: var(--accent); text-decoration: underline; }
.inv .c-thumb { width: 96px; padding-block: 6px; }
.inv .c-thumb img, .nophoto {
  width: 80px; height: 60px; object-fit: cover; border-radius: 6px; background: var(--surface-2);
}
.nophoto { display: block; border: 1px dashed var(--line); }
.inv .label { display: none; }
.inv td.c-arch { color: var(--muted); font-size: 0.92rem; }
.inv .c-project { display: none; }

@media (min-width: 1000px) {
  .inv .c-project { display: table-cell; }
  .inv td.c-project { color: var(--muted); font-size: 0.92rem; }
}
/* Same column widths in every project's table, so the groups line up. */
@media (min-width: 721px) {
  .inv { table-layout: fixed; }
  .inv th.c-thumb { width: 104px; }
  .inv th.c-tag { width: 104px; }
  .inv th.c-project { width: 150px; }
  .inv th.c-arch { width: 24%; }
  .inv th.c-status { width: 112px; }
  .inv th.c-parts, .inv th.c-photos { width: 76px; }
  .admin-list th.c-tag { width: 120px; }
}

@media (max-width: 720px) {
  .inv thead { display: none; }
  .inv, .inv tbody { display: block; }
  .inv tr {
    display: grid; grid-template-columns: 80px 1fr auto; grid-template-areas:
      "thumb name name" "thumb tag status" "thumb arch arch" "thumb counts counts";
    column-gap: 12px; row-gap: 2px; padding: 12px; align-items: center;
  }
  .admin-list tr { grid-template-areas: "name name name" "tag tag status" "counts counts counts"; }
  .inv tbody tr + tr { border-top: 1px solid var(--line); }
  .inv td { display: block; padding: 0; border: 0 !important; }
  .inv .c-thumb { grid-area: thumb; width: auto; align-self: start; }
  .inv .c-name { grid-area: name; }
  .inv .c-tag { grid-area: tag; }
  .inv .c-status { grid-area: status; justify-self: end; }
  .inv .c-arch { grid-area: arch; }
  .inv .c-parts, .inv .c-photos { grid-area: counts; text-align: left; font-size: 0.85rem; color: var(--muted); }
  .inv .c-photos { justify-self: end; }
  .inv .label { display: inline; }
  .inv .c-project { display: none !important; }
}

/* Item page */
.crumbs { margin: 16px 0 0; font-size: 0.9rem; color: var(--muted); }
.item-head .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.summary { font-size: 1.08rem; max-width: 65ch; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery figcaption { padding: 8px 12px; font-size: 0.92rem; color: var(--muted); }
.columns { display: grid; gap: 0 32px; }
@media (min-width: 760px) { .columns { grid-template-columns: 3fr 2fr; } }
.details { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.details > div { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; padding: 9px 12px; }
.details > div + div { border-top: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: 0.92rem; }
.details dd { margin: 0; }
@media (max-width: 420px) { .details > div { grid-template-columns: 1fr; gap: 0; } }
.needs { margin: 0; padding-left: 1.2em; }
.needs li { margin: 4px 0; }
.needs li::marker { color: var(--accent); }
.notes { white-space: pre-line; max-width: 70ch; }

/* Buttons and forms */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 6px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.danger { color: var(--danger); }
.button.danger:hover { border-color: var(--danger); }
.button.small { min-height: 34px; padding: 4px 10px; font-size: 0.88rem; }
.button[disabled] { opacity: 0.4; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.admin-head { display: grid; gap: 4px; }
.admin-head .actions { margin-bottom: 8px; }

fieldset {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 12px 16px 16px; margin: 0 0 16px;
}
legend { font-weight: 700; padding: 0 6px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 0.92rem; margin-top: 10px; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 0; white-space: nowrap; }
input, select, textarea {
  font: inherit; font-weight: normal; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 42px; width: 100%;
}
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--accent); }
input[type="file"] { padding: 8px; background: var(--surface); }
textarea { resize: vertical; }
.grid { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid .wide { grid-column: span 2; }
}
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.parts-edit td { padding: 4px 6px 4px 0; vertical-align: middle; }
.parts-edit th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.parts-edit td:first-child { width: 34%; }
.parts-edit td:last-child { width: 1%; }
@media (max-width: 560px) {
  .parts-edit thead { display: none; }
  .parts-edit, .parts-edit tbody, .parts-edit tr, .parts-edit td { display: block; width: auto !important; }
  .parts-edit tr { padding: 8px 0; border-top: 1px solid var(--line); }
  .parts-edit td { padding: 3px 0; }
}
.actions.sticky {
  position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%);
}
.notice {
  background: var(--owned-bg); color: var(--owned-fg); padding: 10px 14px; border-radius: 8px; font-weight: 600;
}
.errors {
  border: 1px solid var(--danger); color: var(--danger); border-radius: 8px; padding: 4px 14px; margin: 12px 0;
}
.admin-photos .upload {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 16px;
}
.admin-photos .upload .button { margin-top: 12px; }
.photo-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.photo-list li {
  display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.photo-list img { border-radius: 6px; width: 160px; height: 120px; object-fit: cover; }
.photo-list label { margin-top: 0; }
.photo-list .actions { margin-top: 8px; }
.photo-list .hint { margin: 6px 0 0; }
@media (max-width: 560px) {
  .photo-list li { grid-template-columns: 1fr; }
  .photo-list img { width: 100%; height: auto; aspect-ratio: 4 / 3; }
}
.danger-zone { margin-top: 40px; border-top: 1px solid var(--line); }
.danger-zone form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.danger-zone label { flex: 1 1 220px; }
