/* Stud Stash - Night Sort (v0.2 identity)
   The sorting room after dark: a committed warm-charcoal base (brown ink,
   never navy) with the actual colors of the hobby, brick red and stud
   yellow, saved for the moments that matter: the primary action, the brand
   brick, the match meter. The v0.1 ledger DNA stays: hairline and dashed
   rules, monospace counts, stamped badges, serif headings. System font
   stacks only, no webfont downloads. Tokens + shell + forms + buttons live
   here; lists, feed, and widgets live in components.css. */

:root {
  color-scheme: dark;

  --bg-deep: #17130f;
  --bg: #211c17;
  --panel: #2a241d;
  --panel-raised: #342c23;
  --ink: #f2e9d8;
  --ink-soft: #b6a98f;
  --line: #493e2f;
  --line-soft: #382f24;

  --red: #e2503c;
  --red-deep: #b93a29;
  --yellow: #f5c84c;
  --yellow-deep: #e0ac2e;
  --on-yellow: #241c10;
  --green: #8fce7c;
  --green-deep: #4f8f41;

  --danger: #ef8570;
  --danger-bg: #40211a;

  --badge-build-bg: #24391e;
  --badge-build-fg: #a9dd97;
  --badge-almost-bg: #41341a;
  --badge-almost-fg: #eec987;
  --badge-example-bg: #37302a;
  --badge-example-fg: #cdbb94;

  --font-head: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 8px 20px rgba(0, 0, 0, 0.3);
  --max-width: 640px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-deep);
  /* A whisper of a stud grid on the room's walls; visible mostly in the
     desktop margins, never load-bearing. */
  background-image: radial-gradient(circle at 4px 4px, rgba(242, 233, 216, 0.025) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 700;
  margin: 0 0 var(--sp-1);
  letter-spacing: 0.01em;
}

h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 var(--sp-2); }

.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
}

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

::selection {
  background: var(--yellow);
  color: var(--on-yellow);
}

/* ---------- shell / layout ---------- */

.app-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line-soft);
}

.app-header {
  padding: var(--sp-5) var(--sp-4) var(--sp-3);
  background: var(--bg);
  position: relative;
}

/* The header sits on a row of studs: the one piece of pure decoration in
   the whole app, and the thing that says "brick product" before any copy. */
.app-header::after {
  content: "";
  display: block;
  height: 12px;
  margin-top: var(--sp-3);
  background-image: radial-gradient(circle at 8px 6px, var(--line) 4px, transparent 4.5px);
  background-size: 22px 12px;
  background-repeat: repeat-x;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.brand-mark svg {
  display: block;
  width: 40px;
  height: 40px;
}

.brand-text h1 {
  font-size: 1.5rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.brand-tag {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-style: italic;
}

.app-main {
  flex: 1;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-7) + 64px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.view[hidden] { display: none; }

.view-head {
  border-bottom: 1px dashed var(--line);
  padding-bottom: var(--sp-3);
}

.view-sub {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ---------- cards ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 0; }

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.section-head h3 { margin: 0; }

/* ---------- forms ---------- */

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: var(--sp-3) 0 var(--sp-1);
}

.field-label:first-child { margin-top: 0; }

.field-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.field-row > * { flex: 1 1 140px; }

input[type="text"],
input[type="search"],
input[type="number"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-raised);
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-soft);
  opacity: 0.7;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
  min-height: 5rem;
  font-family: var(--font-body);
}

input[type="number"] {
  font-family: var(--font-mono);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.06s ease, background-color 0.12s ease, border-color 0.12s ease;
}

/* Press feel: a brick clunking down onto a plate, 2px and no bounce. */
.btn:active { transform: translateY(2px); }

.btn-primary {
  background: var(--yellow);
  color: var(--on-yellow);
  border-color: var(--yellow-deep);
  box-shadow: 0 2px 0 var(--yellow-deep);
}

.btn-primary:hover { background: var(--yellow-deep); }
.btn-primary:active { box-shadow: 0 0 0 var(--yellow-deep); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover { border-color: var(--ink-soft); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: var(--danger-bg);
}

.btn-small {
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.85rem;
}

.btn-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-bg);
}
