/* Super minimalistic, per the brief's Visual direction.
   The canvas is the only large, high-contrast element; everything else is
   quiet, muted and secondary. No panels, no dashboard chrome. */

:root {
  --paper: #f5f4f1;
  --ink: #16161a;
  --muted: #8a877f;
  --rule: #ddd9d2;
  --measure: 62ch;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: clamp(1.5rem, 5vw, 5rem) clamp(1.25rem, 5vw, 5rem) 6rem;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.65 ui-sans-serif, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* --- header --------------------------------------------------------------- */

header { max-width: var(--measure); margin: 0 0 clamp(2rem, 4vw, 3.25rem); }

h1 {
  margin: 0 0 0.9rem;
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
}

.standfirst {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.7;
}

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

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

@media (max-width: 800px) {
  main { grid-template-columns: minmax(0, 1fr); }
}

/* --- canvas --------------------------------------------------------------- */

/* The stage hugs the artwork, so the controls line up with the canvas edges
   rather than with the column. */
.stage-inner { width: fit-content; max-width: 100%; }

.canvas {
  margin: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* Before there is anything to show, hold a quiet placeholder block. */
.canvas[data-state="loading"],
.canvas[data-state="empty"] {
  background: #e9e6e0;
  height: min(46vh, 420px);
  width: min(100%, 34rem);
}

/* Once there is an image, the canvas takes the artwork's own proportions and is
   capped by viewport height so the controls stay above the fold. */
.canvas img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(60vh, 760px);
  transition: opacity 260ms ease;
}

.canvas[data-state="loading"] img,
.canvas[data-state="empty"] img { display: none; }

.canvas[data-state="working"] img { opacity: 0.35; }

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.canvas[data-state="current"] .placeholder,
.canvas[data-state="preview"] .placeholder { display: none; }

/* a previewed merge is provisional until committed */
.canvas[data-state="preview"] { outline: 1px solid var(--ink); outline-offset: 6px; }

/* --- controls ------------------------------------------------------------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.75rem;
  margin-top: 1.5rem;
  min-height: 2.5rem;
}

.status {
  margin: 0;
  flex: 1 1 22ch;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.status b { color: var(--ink); font-weight: 400; }

.actions { display: flex; align-items: baseline; gap: 1.5rem; }

/* opt-in attribution: a rule to type on, not a form field */
.name-field {
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  padding: 0 0 1px;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  width: 12rem;
}

.name-field::placeholder { color: var(--muted); }
.name-field:focus { outline: none; border-bottom-color: var(--ink); }

/* controls are text, not buttons — no busy UI */
button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  letter-spacing: 0.02em;
  cursor: pointer;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 1px;
  transition: opacity 160ms ease;
}

button:hover:not(:disabled) { opacity: 0.55; }
button:disabled { color: var(--muted); border-bottom-color: var(--rule); cursor: default; }
button.link { border-bottom-color: var(--rule); color: var(--muted); }
button.quiet { border-bottom-color: transparent; color: var(--muted); }
button.quiet:hover { border-bottom-color: var(--rule); }

/* --- ledger --------------------------------------------------------------- */

.ledger h2 {
  margin: 0 0 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.count { float: right; letter-spacing: 0.06em; }

.ledger ol { list-style: none; margin: 0; padding: 0; }

.ledger li {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.ledger img {
  width: 2rem; height: 2rem;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--rule);
}

.entry { min-width: 0; font-size: 0.75rem; line-height: 1.5; }
.entry .who { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .meta { color: var(--muted); font-variant-numeric: tabular-nums; }

.ledger .note {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.65;
}

.ledger #more { margin-top: 1rem; }

.empty-note { color: var(--muted); font-size: 0.75rem; }
