/* Union Pots log.
 *
 * A small, flat system following unionpots.nyc:
 *   colour  ink = content · muted = secondary info (dates, counts, labels)
 *           accent = only things you can press (links, primary button)
 *           danger = errors and destructive actions
 *   type    serif (Spectral) for the brand, page titles and section headings;
 *           sans for everything else, piece numbers included
 *   boxes   form fields, and at most one card per page (the next step)
 */

:root {
  --bg: #faf8f5;
  --field: #fff;
  --line: #e4ddd3;
  --hover: #f2eee8;
  --ink: #1f1b18;
  --muted: #7a716a;
  --accent: #7a3f2e;
  --accent-ink: #faf8f5;
  --danger: #a3322a;

  --serif: "Spectral", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --radius: 8px;
  --tap: 44px;
  --gutter: 1rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 6rem;
}

/* --- type --- */

h1, h2, .brand { font-family: var(--serif); font-weight: 400; color: var(--ink); }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 0.25rem; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.count { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); margin-left: 0.35rem; }

/* --- page chrome --- */

.banner {
  background: var(--danger);
  color: var(--accent-ink);
  padding: 0.3rem var(--gutter);
  text-align: center;
  font-size: 0.8rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 640px;
  margin: 0 auto;
  padding: 0.75rem var(--gutter);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.25rem; text-decoration: none; }
.nav-link { text-decoration: none; font-weight: 500; padding: 0.5rem 0; }

/* Page sections are separated by space; home groups also get a rule. */
section { margin-top: 2.5rem; }
.group { margin-top: 0; padding: 1.25rem 0 1.5rem; border-top: 1px solid var(--line); }
.group:first-child { border-top: 0; padding-top: 0; }

/* --- piece rows --- */

.rows { margin: 0; }
.row {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: baseline;
  column-gap: 0.75rem;
  min-height: var(--tap);
  padding: 0.6rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.row:hover { background: var(--hover); }
.row-two { grid-template-columns: 1fr auto; }
.pid { font-weight: 600; }
.row-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main .name + .ago { margin-left: 0.5rem; }
.ago, .row-end { font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); margin: 0; }

/* --- piece page --- */

.status { margin: 0; }
.part-of { margin: 0.1rem 0 0; }

/* The next-step card: the page's one box, with its button as the bottom edge. */
.next-step {
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.next-step-body { padding: 1rem; }
.next-step-button {
  display: block;
  width: 100%;
  min-height: 52px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.next-step-button:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }

/* History reads left to right: Thrown › Trimmed › Queued for bisque. */
.history { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; row-gap: 0.75rem; }
.history li { display: flex; }
.history li + li::before { content: "›"; color: var(--muted); padding: 0 0.6rem; }
.history-step { display: flex; flex-direction: column; }
.history-step .date { font-size: 0.875rem; color: var(--muted); }

.save-status { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); margin-left: 0.5rem; }
.save-status[data-state="error"] { color: var(--danger); }

/* --- forms --- */

.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.875rem; color: var(--muted); }
.field > input, .field > select, .field > textarea { font-size: 1rem; color: var(--ink); }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  min-height: var(--tap);
  width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus, .button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Buttons: primary is filled; everything else is a quiet outline. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--hover); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.block { display: flex; width: 100%; }
.buttons { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 2rem; }

/* Pills: tap to toggle. Used for "also apply to" pieces and "started by". */
.pills { border: 0; padding: 0; margin: 0; }
.pills legend { padding: 0; margin-bottom: 0.5rem; font-size: 0.875rem; color: var(--muted); }
.pill-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.pill-custom { display: inline-flex; align-items: center; gap: 0.5rem; }
.pill-custom input[type="number"] { width: 5.5rem; min-height: 40px; border-radius: 999px; text-align: center; }
.pill-custom input[type="radio"]:checked ~ input[type="number"] { border-color: var(--accent); outline: 1px solid var(--accent); }
.pill input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill input:disabled + span { opacity: 0.4; cursor: default; }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Disclosures ("Advanced", "Backfill…") are plain text, not boxes. */
details.disclosure { margin-top: 2.5rem; }
details.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--tap);
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "›"; display: inline-block; transition: transform 0.15s; }
details.disclosure[open] > summary::before { transform: rotate(90deg); }
details.disclosure .hint { color: var(--muted); font-size: 0.875rem; margin: -0.25rem 0 0.75rem; }

/* Height / width / depth inputs. */
.dims { display: flex; flex-direction: column; gap: 0.5rem; }
.dims-head, .dims-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 0.5rem;
  align-items: center;
}
.dims-head { font-size: 0.8rem; color: var(--muted); }
.dims-label + .dims-inputs { margin-top: 0.25rem; }
.dims-label { font-size: 0.875rem; }
.dims-inputs input[inputmode] { text-align: center; }
.dims-inputs [data-depth]:disabled { visibility: hidden; }
.dims-hint { font-size: 0.8rem; color: var(--muted); margin: 0; }
.pill-small span { min-height: var(--tap); padding: 0 0.75rem; font-size: 0.875rem; }
.field-short input { max-width: 8rem; }
.field-short input[type="date"] { max-width: 12rem; }
details.disclosure.inline { margin-top: 0; }
.next-step-body { display: flex; flex-direction: column; gap: 1rem; }

/* A small link beside a field label, e.g. "edit clays". */
.legend-link { margin-left: 0.5rem; font-size: 0.875rem; }
.pill-custom input[name="new_clay"] { width: 9rem; min-height: 40px; border-radius: 999px; padding: 0 1rem; }

.glaze-list { gap: 0.5rem; }

/* --- misc pages --- */

.page-form { margin-top: 1.5rem; }
.stack > details.disclosure { margin-top: 0; }
.stack > details.disclosure + details.disclosure { margin-top: -0.75rem; }
.follow { margin-top: 0.75rem; }


.created-ids { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin: 1rem 0 0; }
.created-ids a { font-family: var(--serif); font-size: 3.5rem; line-height: 1.1; color: var(--ink); text-decoration: none; }

.login { max-width: 360px; margin: 18vh auto 0; }
.login h1 { margin-bottom: 1.5rem; }
