/* Hallmark · shape: app screen · genre: editorial · theme: Grid (by request)
 * nav: top bar, the wordmark left, the voter's name and sign out right · signature: the option in the lead, its name and vote count set large on the ultramarine · states: loading, empty, error, full
 * axes: light/grotesk-sans/cool · posture: full-palette · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H5 E4 S4 R4 V4 · weakest: P, a ballot is a ballot; the lead band argues that the count is the news and the list is the record */
/* Hallmark · waive 39b · the code input is 71px of display type over a hairline · Grid sets a control on a field as poster type, and the six digits are the gate's one job */
@import url("./tokens.css");
@import url("./base.css");

:root {
  --bar-height: 64px;
  --text-poster: 4.5rem;
  --text-leader: 4rem;
  --text-figure: 9rem;
  --text-pin: 3.5rem;
  --color-mark-deep: oklch(50% 0.2 29);
  --hair-on-field: color-mix(in oklab, var(--color-field-ink) 60%, transparent);
}

/* Shared controls */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-height: 44px; padding: 0 var(--space-lg); border: 0; border-radius: 0; font: 500 var(--text-md)/1 var(--font-body); white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.btn--primary { background: var(--color-ink); color: var(--color-paper); }
.btn--primary:hover { background: var(--color-ink-2); }
.btn--quiet { background: var(--color-paper-2); color: var(--color-ink); }
.btn--quiet:hover { background: var(--color-paper-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; color: currentColor; font: 500 var(--text-sm)/1.2 var(--font-body); text-decoration: underline var(--rule-hair); text-underline-offset: 0.32em; white-space: nowrap; cursor: pointer; transition: color var(--dur-short) var(--ease-out); }
.link:hover { color: var(--color-mark); }
.link:active { transform: translateY(1px); }
.link:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.link:disabled { opacity: 0.55; cursor: not-allowed; }

.field { background: var(--color-field); color: var(--color-field-ink); --color-focus: var(--color-field-ink); }
.field .link:hover { color: var(--color-field-ink); text-decoration-thickness: 2px; }
.field ::selection { background: var(--color-field-ink); color: var(--color-field); }

.help { min-height: 1lh; font-size: var(--text-sm); color: var(--color-muted); }
.field .help { color: var(--color-field-ink); }

.wordmark { display: inline-grid; grid-template-columns: auto auto; column-gap: var(--space-xs); align-items: center; font: var(--display-weight) var(--text-md)/0.92 var(--font-display); letter-spacing: -0.01em; color: var(--color-ink); text-decoration: none; }
.wordmark::before { content: ""; grid-row: 1 / span 2; align-self: stretch; aspect-ratio: 1; background: var(--color-mark); }
.wordmark > span { grid-column: 2; }
.wordmark > span + span { font-weight: 400; }
.wordmark:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 4px; }

.skip { position: absolute; left: var(--space-md); top: calc(-1 * var(--space-3xl)); z-index: var(--z-toast); padding: var(--space-xs) var(--space-md); background: var(--color-ink); color: var(--color-paper); }
.skip:focus-visible { top: var(--space-md); }

/* Which screen: the Worker marks the document signed in or not */

html[data-auth="in"] .gate { display: none; }
html:not([data-auth="in"]) .app { display: none; }

/* The gate: the photograph on paper, the code on the ultramarine */

.gate {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: [bleed-start] minmax(0, 1fr) repeat(12, minmax(0, calc((min(100%, var(--container)) - 2 * var(--gutter) - 11 * var(--gap-columns)) / 12))) minmax(0, 1fr) [bleed-end];
  grid-template-rows: var(--bar-height) minmax(0, 1fr);
  column-gap: var(--gap-columns);
}
.gate__top { grid-column: 2 / 8; grid-row: 1; display: flex; align-items: center; }
.gate__photo { grid-column: 2 / 8; grid-row: 2; align-self: center; aspect-ratio: 4 / 3; margin: 0 0 var(--bar-height); }
.gate__photo > img { object-position: 50% 60%; }
.gate__field { grid-column: 8 / bleed-end; grid-row: 1 / -1; display: grid; grid-template-columns: subgrid; align-content: center; padding-block: var(--space-3xl); }
.gate__body { grid-column: 2 / 7; display: grid; gap: var(--space-lg); }
.gate__body h1 { font-size: var(--text-poster); line-height: 0.92; letter-spacing: -0.045em; max-width: 9ch; }
.gate__body .lead { max-width: 32ch; }

.pin { display: grid; justify-items: start; gap: var(--space-xs); margin-top: var(--space-lg); }
.pin label { font: 500 var(--text-sm)/1.3 var(--font-body); }
.pin input { width: 100%; max-width: 7.2em; min-height: 44px; padding: 0 0 var(--space-xs); border: 0; border-bottom: var(--rule-hair) solid var(--hair-on-field); border-radius: 0; background: transparent; color: var(--color-field-ink); font: var(--display-weight) var(--text-pin)/1.1 var(--font-display); letter-spacing: 0.18em; font-variant-numeric: tabular-nums; outline: 2px solid transparent; outline-offset: 2px; }
.pin input:hover { border-bottom-color: var(--color-field-ink); }
.pin input:focus-visible { outline-color: var(--color-focus); }
.pin input[aria-invalid="true"] { border-bottom-color: var(--color-field-ink); border-bottom-style: dashed; }
.pin .btn { margin-top: var(--space-sm); }

/* The app shell */

.bar { position: sticky; top: 0; z-index: var(--z-sticky-nav); background: var(--color-paper); }
.bar__in { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); min-height: var(--bar-height); }
.bar__me { display: flex; align-items: center; gap: var(--space-lg); min-width: 0; }
.bar__who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); color: var(--color-muted); }
.bar__who b { font-weight: 500; color: var(--color-ink); }

.band { padding-block: var(--space-2xl); }
.band__in { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-xl); align-items: end; }
.band__text { grid-column: 1 / span 8; display: grid; gap: var(--space-md); min-width: 0; }
.band__text h1 { font-size: var(--text-leader); line-height: 0.95; letter-spacing: -0.04em; max-width: 16ch; }
.band__text .lead { max-width: 48ch; }
.band__action { margin-top: var(--space-xs); }
.band__figure { grid-column: 9 / -1; display: grid; gap: var(--space-xs); justify-items: start; }
.band__figure .figure { font: var(--display-weight) var(--text-figure)/0.8 var(--font-display); letter-spacing: -0.05em; }
.band__caption { font: 500 var(--text-sm)/1.4 var(--font-body); max-width: 28ch; }

.nameform { grid-column: 9 / -1; display: grid; justify-items: start; gap: var(--space-xs); }
.nameform label { font: 500 var(--text-sm)/1.3 var(--font-body); }
.nameform input { width: 100%; min-height: 44px; padding: 0 0 var(--space-xs); border: 0; border-bottom: var(--rule-hair) solid var(--hair-on-field); border-radius: 0; background: transparent; color: var(--color-field-ink); font: var(--display-weight) var(--text-3xl)/1.15 var(--font-display); letter-spacing: -0.02em; outline: 2px solid transparent; outline-offset: 2px; }
.nameform input:hover { border-bottom-color: var(--color-field-ink); }
.nameform input:focus-visible { outline-color: var(--color-focus); }
.nameform input[aria-invalid="true"] { border-bottom-style: dashed; border-bottom-color: var(--color-field-ink); }
.nameform__actions { display: flex; align-items: center; gap: var(--space-lg); margin-top: var(--space-xs); }

/* Loading shapes */

.skel { display: block; background: color-mix(in oklab, currentColor 14%, transparent); }
.skel--head { width: min(100%, 12ch); height: 0.9em; }
.skel--line { width: min(100%, 30ch); height: 1em; }
.skel--count { width: 2.5rem; height: 2rem; }
.skel--title { width: min(100%, 22rem); height: 1.5rem; }
.skel--btn { width: 7.5rem; height: 44px; }
.opt--skel { align-items: center; color: var(--color-ink); }

/* The board: the ballot and the add form */

.board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-2xl); align-items: start; padding-block: var(--space-2xl) var(--space-3xl); }
.ballot { grid-column: 1 / span 8; min-width: 0; }
.ballot__head { display: grid; gap: var(--space-xs); }
.ballot__head h2, .add h2 { font-size: var(--text-2xl); max-width: 24ch; }
.ballot__sub { color: var(--color-muted); }
.ballot__jump { display: none; justify-self: start; }

.status { min-height: 1lh; margin-top: var(--space-md); font-size: var(--text-sm); color: var(--color-ink-2); }
.status.is-error { color: var(--color-error); }

.opts { list-style: none; margin: var(--space-xs) 0 0; padding: 0; }
.opt { display: grid; grid-template-columns: 4rem minmax(0, 1fr) auto; column-gap: var(--space-lg); align-items: start; padding-block: var(--space-lg); border-top: var(--rule-hair) solid var(--color-rule); }
.opt:last-child { border-bottom: var(--rule-hair) solid var(--color-rule); }
.opt__count { font: var(--display-weight) var(--text-3xl)/1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.opt__body { display: grid; gap: var(--space-xs); min-width: 0; }
.opt__body h3 { font-size: var(--text-xl); line-height: 1.1; letter-spacing: -0.025em; }
.opt__desc { white-space: pre-line; max-width: 60ch; color: var(--color-ink-2); }
.opt__meta { display: flex; flex-wrap: wrap; column-gap: var(--space-lg); row-gap: var(--space-2xs); margin: var(--space-2xs) 0 0; font-size: var(--text-sm); }
.opt__meta > div { display: flex; gap: var(--space-xs); min-width: 0; }
.opt__meta dt { color: var(--color-muted); }
.opt__meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.opt__meta a { text-underline-offset: 0.24em; transition: color var(--dur-short) var(--ease-out); }
.opt__meta a:hover { color: var(--color-mark); }
.opt__voters { font-size: var(--text-sm); color: var(--color-muted); }
.opt__act { display: grid; justify-items: end; gap: var(--space-2xs); }
.opt__act .link { color: var(--color-muted); }
.opt__act .link:hover { color: var(--color-mark); }
.opt__act .link.is-confirming { color: var(--color-error); }

.vote { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-width: 7.5rem; min-height: 44px; padding: 0 var(--space-md); border: 0; border-radius: 0; background: var(--color-paper-2); color: var(--color-ink); font: 500 var(--text-md)/1 var(--font-body); white-space: nowrap; cursor: pointer; transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.vote svg { width: 20px; height: 20px; flex-shrink: 0; }
.vote .vote__on { display: none; }
.vote:hover { background: var(--color-paper-3); }
.vote[aria-pressed="true"] { background: var(--color-mark); color: var(--color-mark-ink); }
.vote[aria-pressed="true"]:hover { background: var(--color-mark-deep); }
.vote[aria-pressed="true"] .vote__on { display: block; }
.vote[aria-pressed="true"] .vote__off { display: none; }
.vote:active { transform: translateY(1px); }
.vote:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.vote:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.vote[aria-busy="true"] { cursor: progress; }

.empty, .failed { display: grid; gap: var(--space-xs); justify-items: start; margin-top: var(--space-md); padding: var(--space-xl) var(--space-lg); background: var(--color-paper-2); }
.empty__head, .failed__head { font: var(--display-weight) var(--text-xl)/1.1 var(--font-display); letter-spacing: -0.025em; }
.failed .btn { margin-top: var(--space-sm); background: var(--color-paper); }
.failed .btn:hover { background: var(--color-paper-3); }

.add { grid-column: 9 / -1; position: sticky; top: calc(var(--bar-height) + var(--space-lg)); display: grid; gap: var(--space-lg); padding: var(--space-xl) var(--space-lg); background: var(--color-paper-2); }
.add__need { color: var(--color-ink-2); }
.addform { display: grid; gap: var(--space-lg); }
.addform .help { margin-top: calc(-1 * var(--space-xs)); }
.addform .help.is-error { color: var(--color-error); }
.addform .btn { justify-self: start; }

.fld { display: grid; gap: var(--space-2xs); }
.fld label { font: 500 var(--text-sm)/1.3 var(--font-body); color: var(--color-ink-2); }
.opt-tag { font-weight: 400; color: var(--color-muted); }
.fld input, .fld textarea { width: 100%; min-height: 44px; padding: var(--space-xs) 0; border: 0; border-bottom: var(--rule-hair) solid var(--color-muted); border-radius: 0; background: transparent; color: var(--color-ink); font: 400 var(--text-md)/1.4 var(--font-body); outline: 2px solid transparent; outline-offset: 2px; transition: border-color var(--dur-short) var(--ease-out); }
.fld textarea { min-height: 6rem; resize: vertical; }
.fld input::placeholder { color: var(--color-muted); }
.fld input:hover, .fld textarea:hover { border-bottom-color: var(--color-ink); }
.fld input:focus-visible, .fld textarea:focus-visible { outline-color: var(--color-focus); border-bottom-color: var(--color-ink-2); }
.fld input[aria-invalid="true"], .fld textarea[aria-invalid="true"] { border-bottom-color: var(--color-error); }
.fld input:disabled, .fld textarea:disabled { opacity: 0.55; cursor: not-allowed; }

/* Narrow screens */

@media (max-width: 60rem) {
  :root { --text-poster: 3.25rem; --text-leader: 2.75rem; --text-figure: 6rem; --text-pin: 2.75rem; }
  .gate { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; min-height: 0; }
  .gate__top { grid-column: 1; grid-row: auto; min-height: var(--bar-height); padding-inline: var(--gutter); }
  .gate__photo { grid-column: 1; grid-row: auto; margin: 0 var(--gutter) var(--space-xl); }
  .gate__field { grid-column: 1; grid-row: auto; grid-template-columns: minmax(0, 1fr); padding: var(--space-2xl) var(--gutter) var(--space-3xl); }
  .gate__body { grid-column: 1; }
  .band__text, .band__figure, .nameform { grid-column: 1 / -1; }
  .ballot, .add { grid-column: 1 / -1; }
  .add { position: static; }
  .ballot__jump { display: inline-flex; }
}

@media (max-width: 40rem) {
  .bar__as { display: none; }
  .bar__me { gap: var(--space-md); }
  .opt { grid-template-columns: 3rem minmax(0, 1fr); row-gap: var(--space-md); column-gap: var(--space-md); }
  .opt__act { grid-column: 2; display: flex; align-items: center; justify-content: space-between; }
  .add { padding: var(--space-lg) var(--space-md); }
}
