/* Veto Chain: "legislative redline" theme. Dark oxblood paper, brass, red stamps, teal ink. */
:root {
  --ink: #140d0e;
  --ink-2: #1c1314;
  --sheet: #231819;
  --sheet-2: #2c1f20;
  --rule: #4a3436;
  --paper: #f3e9dc;        /* body text, 14:1 on --ink */
  --dim: #c4b2a3;          /* secondary text, 8:1 on --ink */
  --brass: #e2b65a;        /* A / proposer */
  --veto: #ff5a47;         /* B / veto */
  --ratify: #7bd88f;       /* B accepts */
  --teal: #52d6c8;         /* C / rewrite */
  --focus: #9fd3ff;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--paper); font-family: var(--sans); line-height: 1.55;
  background-color: var(--ink);
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 32px),
    radial-gradient(900px 500px at 100% 0%, rgba(255,90,71,.10), transparent 60%),
    radial-gradient(700px 500px at 0% 30%, rgba(226,182,90,.07), transparent 60%);
}
a { color: var(--brass); }
code, kbd { font-family: var(--mono); font-size: .86em; }
code { background: rgba(243,233,220,.07); padding: .1em .35em; border-radius: 4px; }
kbd { border: 1px solid var(--rule); border-bottom-width: 2px; padding: 0 .3em; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 20; background: var(--brass); color: #1b1206; padding: 8px 12px; }
.skip-link:focus { left: 8px; }
.hint { color: var(--dim); font-size: .85rem; }

/* masthead */
.masthead {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px clamp(16px, 4vw, 44px); padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(20,13,14,.86); backdrop-filter: blur(8px); border-bottom: 3px double var(--rule);
}
.wordmark { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-weight: 800; letter-spacing: .22em; font-size: .95rem; }
.wordmark em { color: var(--veto); font-style: normal; margin: 0 .1em; }
.links { width: 44px; height: 22px; color: var(--brass); }
.auth { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.auth-status { font-family: var(--mono); font-size: .8rem; color: var(--ratify); }
.connect-slot:empty { display: none; }

main { max-width: 1120px; margin: 0 auto; padding: clamp(16px, 4vw, 44px); }

/* intro */
.intro { margin: 6px 0 26px; }
.docket { font-family: var(--mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin: 0 0 10px; }
.intro h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(2rem, 6vw, 3.6rem); line-height: 1.05; margin: 0 0 18px; letter-spacing: -.01em; }
.strike { text-decoration: line-through; text-decoration-color: var(--veto); text-decoration-thickness: .12em; }
.collapse-word { color: var(--veto); display: inline-block; transform: rotate(-2deg); }
.roles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.roles li { padding: 10px 12px; border-left: 4px solid var(--c); background: var(--ink-2); font-size: .93rem; }
.roles b { font-family: var(--mono); color: var(--c); margin-right: 4px; }
.role-a { --c: var(--brass); } .role-b { --c: var(--veto); } .role-c { --c: var(--teal); }

/* form */
.motion { background: var(--sheet); border: 1px solid var(--rule); padding: clamp(16px, 3vw, 26px); box-shadow: 8px 8px 0 rgba(0,0,0,.35); }
.field-label { display: block; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
textarea {
  width: 100%; min-height: 90px; resize: vertical; font: inherit; font-family: var(--serif); font-size: 1.15rem; color: var(--paper);
  background: var(--ink); border: 1px solid var(--rule); border-radius: 0; padding: 14px 16px;
  background-image: repeating-linear-gradient(transparent 0 31px, rgba(226,182,90,.08) 31px 32px);
  line-height: 32px;
}
textarea::placeholder { color: #a08f82; }
textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(226,182,90,.25); }
.field-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.count { white-space: nowrap; font-family: var(--mono); }
.samples { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.sample { font: inherit; font-size: .85rem; color: var(--paper); background: transparent; border: 1px dashed var(--rule); padding: 6px 12px; cursor: pointer; }
.sample:hover { border-color: var(--brass); border-style: solid; }

fieldset { border: 0; padding: 0; margin: 18px 0 0; }
legend { font-family: var(--mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); padding: 0; margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
legend .hint { text-transform: none; letter-spacing: 0; font-family: var(--sans); }
.bench { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.bench legend { grid-column: 1 / -1; }
.seat { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--ink-2); border-top: 3px solid var(--c); font-size: .9rem; }
.seat b { font-family: var(--mono); color: var(--c); }
.seat-a { --c: var(--brass); } .seat-b { --c: var(--veto); } .seat-c { --c: var(--teal); }
select { font: inherit; font-size: .9rem; color: var(--paper); background: var(--ink); border: 1px solid var(--rule); padding: 8px; width: 100%; }
.round-pick { display: flex; gap: 8px; }
.round-pick label { position: relative; }
.round-pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.round-pick span { display: grid; place-items: center; width: 52px; height: 44px; font-family: var(--mono); font-weight: 800; font-size: 1.1rem; border: 1px solid var(--rule); background: var(--ink); }
.round-pick input:checked + span { background: var(--brass); color: #1b1206; border-color: var(--brass); }
.round-pick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.rounds .hint { margin: 8px 0 0; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.notice { min-height: 1.4em; margin: 10px 0 0; font-size: .92rem; color: var(--brass); }
.notice.error { color: #ff9a8d; }

/* buttons */
.btn { font: inherit; font-weight: 800; cursor: pointer; border: 1px solid transparent; border-radius: 0; padding: 11px 18px; min-height: 44px; letter-spacing: .02em; transition: transform .08s, background .2s, border-color .2s; }
.btn:active { transform: translate(1px,1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-brass { background: var(--brass); color: #1b1206; box-shadow: 3px 3px 0 #000; }
.btn-veto { background: var(--veto); color: #1d0503; box-shadow: 3px 3px 0 #000; }
.btn-line { background: transparent; color: var(--paper); border-color: var(--rule); }
.btn-line:hover:not(:disabled) { border-color: var(--paper); }
.btn-big { flex: 1 1 240px; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .12em; }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: .82rem; }

/* record */
.record { margin-top: 34px; scroll-margin-top: 80px; }
.record-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 3px double var(--rule); padding-bottom: 10px; }
.record-head h2 { font-family: var(--serif); font-size: 1.7rem; margin: 0; }
.record-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.record-grid { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 28px; margin-top: 22px; align-items: start; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 34px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; border-left: 3px dashed var(--rule); }
.step { position: relative; margin-bottom: 18px; animation: drop .35s ease both; --c: var(--rule); }
.step[data-role="A"] { --c: var(--brass); }
.step[data-role="B"] { --c: var(--veto); }
.step[data-role="B"][data-verdict="accept"] { --c: var(--ratify); }
.step[data-role="C"] { --c: var(--teal); }
.step[data-state="error"] { --c: #8f7f78; }
.node { position: absolute; left: -34px; top: 14px; width: 25px; height: 15px; border: 3px solid var(--c); border-radius: 8px; background: var(--ink); }
.step[data-state="loading"] .node { animation: blink 1s ease-in-out infinite; }
.round-mark { list-style: none; margin: 26px 0 12px -34px; font-family: var(--mono); font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 10px; }
.round-mark::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.round-mark:first-child { margin-top: 0; }

.slip { background: var(--sheet); border: 1px solid var(--rule); border-left: 5px solid var(--c); padding: 14px 16px; position: relative; overflow: hidden; }
.slip-head { display: flex; align-items: center; gap: 12px; }
.seal { flex: none; width: 34px; height: 34px; display: grid; place-items: center; font-family: var(--mono); font-weight: 900; color: var(--ink); background: var(--c); border-radius: 50%; }
.slip-who { flex: 1; min-width: 0; }
.slip-title { margin: 0; font-family: var(--mono); font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--c); }
.slip-model { font-size: .82rem; color: var(--dim); overflow-wrap: anywhere; }
.slip-time { font-family: var(--mono); font-size: .75rem; color: var(--dim); }
.slip-body { margin-top: 10px; }
.text { font-family: var(--serif); font-size: 1.08rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.text:empty, .rule:empty, .drift:empty, .err:empty, .stamp:empty { display: none; }
.step[data-role="B"] .text { font-family: var(--sans); font-size: 1rem; }
.rule { margin: 10px 0 0; padding: 8px 10px; font-family: var(--mono); font-size: .86rem; background: rgba(255,90,71,.1); border: 1px dashed var(--veto); }
.rule::before { content: "NEW RULE · "; color: var(--veto); font-weight: 800; }
.drift { margin: 8px 0 0; font-family: var(--mono); font-size: .78rem; color: var(--dim); }
.err { margin: 0; color: #ffb0a6; }
.stamp {
  position: absolute; right: 14px; top: 42px; margin: 0; pointer-events: none;
  font-family: var(--mono); font-weight: 900; font-size: 1.35rem; letter-spacing: .14em; color: var(--c);
  border: 3px solid var(--c); padding: 2px 10px; transform: rotate(-9deg); opacity: .85; mix-blend-mode: screen;
  animation: stamp .3s cubic-bezier(.2,1.6,.4,1) both;
}
.step[data-role="B"] .slip-body { padding-right: 130px; }
.slip-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 8px; border-top: 1px dotted var(--rule); }
.endpoint { flex: 1; font-family: var(--mono); font-size: .68rem; color: var(--dim); overflow-wrap: anywhere; }
.typing { display: none; gap: 6px; padding: 6px 0; }
.step[data-state="loading"] .typing { display: flex; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }

/* verdict banner (last item) */
.outcome { list-style: none; margin: 24px 0 0 -34px; padding: 18px 20px; border: 3px double var(--oc); background: var(--ink-2); --oc: var(--brass); }
.outcome[data-kind="ratified"] { --oc: var(--ratify); }
.outcome[data-kind="collapsed"] { --oc: var(--veto); }
.outcome[data-kind="stopped"], .outcome[data-kind="error"] { --oc: #8f7f78; }
.outcome h3 { margin: 0 0 6px; font-family: var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--oc); font-size: 1.15rem; }
.outcome p { margin: 0; color: var(--paper); }

/* ledger */
.ledger { position: sticky; top: 84px; background: var(--ink-2); border: 1px solid var(--rule); padding: 16px; }
.ledger h3 { margin: 0; font-family: var(--serif); font-size: 1.25rem; }
.ledger .hint { margin: 2px 0 10px; }
.ledger-list { margin: 0 0 14px; padding-left: 22px; font-family: var(--mono); font-size: .82rem; }
.ledger-list li { margin-bottom: 8px; }
.ledger-list li::marker { color: var(--veto); font-weight: 800; }
.ledger-list:empty::before { content: "No vetoes yet."; color: var(--dim); margin-left: -22px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.meter-label { grid-column: 1 / -1; font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.meter-track { height: 10px; background: var(--ink); border: 1px solid var(--rule); }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--brass), var(--veto)); transition: width .8s ease; }
.meter-value { font-family: var(--mono); font-weight: 800; }
.status-line { margin: 14px 0 0; font-family: var(--mono); font-size: .82rem; color: var(--brass); }

/* colophon */
.colophon { max-width: 1120px; margin: 30px auto 0; padding: 20px clamp(16px, 4vw, 44px) max(30px, env(safe-area-inset-bottom)); border-top: 3px double var(--rule); color: var(--dim); font-size: .88rem; }
.colophon p { margin: 0 0 10px; }
.badge { display: inline-block; padding: 6px 12px; border: 1px solid var(--rule); color: var(--paper); text-decoration: none; font-family: var(--mono); font-size: .82rem; }
.badge b { color: var(--brass); }
.badge:hover { border-color: var(--brass); }

@keyframes blink { 50% { opacity: .35; } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes stamp { from { opacity: 0; transform: rotate(-9deg) scale(1.8); } }

@media (max-width: 860px) {
  .record-grid { grid-template-columns: 1fr; }
  .ledger { position: static; order: -1; }
}
@media (max-width: 600px) {
  .roles, .bench { grid-template-columns: 1fr; }
  .field-meta { flex-direction: column; gap: 2px; }
  .step[data-role="B"] .slip-body { padding-right: 0; }
  .stamp { position: static; display: inline-block; margin: 0 0 8px; font-size: 1.05rem; }
  .wordmark span { letter-spacing: .12em; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
