/* Challenge and Response, Form CR-1. Radius is 0 everywhere; the hole punch is the only circle. */

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 2rem 16px 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

.card {
  position: relative;
  max-width: 34rem;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
}
.punch {
  position: absolute;
  top: .9rem;
  left: .9rem;
  width: .85rem;
  height: .85rem;
  border-radius: 50%;
  background: var(--bg);
}

/* Header band */
.band {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .75rem 1rem .7rem 2.5rem;
  background: var(--c-moss);
  color: var(--c-cream);
  border-bottom: 3px solid var(--c-brick);
}
.band h1 {
  margin: 0;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.band .code {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.field {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: 1rem 1rem 0;
}
.label, .meta, h2 {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.title-out {
  flex: 1;
  min-width: 0;
  min-height: 1.5rem;
  border-bottom: 1px solid var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.screen { padding: 1rem; }

.instr, .caption, .msg, .look, .note {
  font-size: .82rem;
  margin: 0;
}
.instr { margin-bottom: .5rem; }
.msg:empty { display: none; }
#parse-msg { margin-top: .4rem; }

textarea, input {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--ink);
}
textarea {
  min-height: 13rem;
  resize: vertical;
  padding: .55rem .7rem;
  line-height: 1.55;
}
textarea::placeholder, input::placeholder { color: var(--ink-soft); opacity: 1; }

.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-top: .9rem;
}
button {
  font: inherit;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .6rem .9rem;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  cursor: pointer;
}
button.primary {
  color: var(--c-cream);
  background: var(--c-moss);
  border-color: var(--c-moss);
}
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
textarea:focus, input:focus { outline: 1px solid var(--ink); outline-offset: 2px; }
#sheet:focus { outline: none; }

/* On file */
.onfile {
  margin-top: 1.6rem;
  padding-top: .9rem;
  border-top: 1px solid var(--ink);
}
h2 { margin: 0 0 .5rem; }
.files { list-style: none; margin: 0 0 1rem; padding: 0; }
.files button {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  width: 100%;
  padding: .25rem 0;
  border: 0;
  font-size: .92rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
}
.files button::before {
  content: "";
  flex: none;
  width: .65rem;
  height: .65rem;
  border: 1.5px solid var(--ink);
  align-self: center;
}
.files button[aria-pressed="true"]::before { background: var(--ink); }
.files button[aria-pressed="true"] { font-weight: 700; }
.files .name { overflow-wrap: anywhere; }
.files .leader { flex: 1; min-width: 1.5rem; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
th {
  padding: .3rem .4rem;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: left;
  vertical-align: bottom;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink);
}
td {
  padding: .35rem .4rem;
  vertical-align: top;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
}
th.n, td.n { text-align: right; }
td.n { white-space: nowrap; }
td.item { overflow-wrap: anywhere; min-width: 5.5rem; }
td.runs { min-width: 6.5rem; }
td.runs .rev { white-space: nowrap; }
tfoot td { border-top: 3px double var(--ink); border-bottom: 0; }
.tally { white-space: nowrap; }
.tally i {
  display: inline-block;
  width: 2px;
  height: .85em;
  margin-right: 2px;
  vertical-align: -.08em;
  background: var(--c-brick);
}
.tally i:last-of-type { margin-right: .4rem; }
.table-wrap .caption { margin-top: .6rem; color: var(--ink-soft); }

/* Item rows: number, challenge, dot leader, response, seconds */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 1.8em minmax(0, 1fr);
  column-gap: .4rem;
  align-items: baseline;
}
.row .body { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .4rem; min-width: 0; }
.row .c { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.row .tail { flex: 1 1 auto; display: flex; align-items: baseline; gap: .4rem; min-width: 0; }
.row .r { min-width: 0; overflow-wrap: anywhere; text-align: right; }
.row .s { flex: none; min-width: 4em; text-align: right; white-space: nowrap; }
.leader {
  flex: 1 0 1.25rem;
  align-self: end;
  margin-bottom: .38em;
  border-bottom: 2px dotted currentColor;
}
.note { padding-left: calc(1.8em + .4rem); }

/* Run */
.done { margin-bottom: 1rem; }
.done .row { padding: .15rem 0; font-size: .92rem; }
.done .c { text-transform: uppercase; letter-spacing: .06em; }
.done .note { color: var(--ink-soft); font-size: .78rem; }
.meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: .35rem;
}
.bar {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  padding: .7rem .9rem .75rem;
  background: var(--c-mustard);
  color: #1A1A1A;
}
.bar .num { font-size: 1rem; font-weight: 700; }
.bar .challenge {
  min-width: 0;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: .04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
#answer {
  margin-top: .6rem;
  padding: .5rem .7rem;
  font-size: 1.25rem;
}
#cur-caption { margin-top: .4rem; color: var(--ink-soft); }
.look { margin-top: .3rem; font-weight: 700; }
.notes .note { padding-left: 0; margin-top: .25rem; }

/* Log sheet: #1A1A1A on --c-sky in both schemes */
.sheet {
  padding: 1.1rem 1rem 1.2rem;
  background: var(--c-sky);
  color: #1A1A1A;
}
.sheet p { margin: 0; }
.sheet .head .t { font-size: 1.1rem; font-weight: 800; }
.sheet .items {
  margin: .9rem 0;
  padding-top: .55rem;
  border-top: 1px solid #1A1A1A;
}
.sheet .items > li { padding: .15rem 0; }
.sheet .note { font-size: .85rem; }
.sheet .r, .sheet .note { white-space: pre-wrap; }
.sheet .foot {
  padding-top: .6rem;
  border-top: 1px solid #1A1A1A;
}
.sheet .foot .seat { white-space: pre; }

/* Colophon strip: cream ground and #1A1A1A text in both schemes, for the plum wordmark */
.colophon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem 1rem;
  background: var(--c-cream);
  color: #1A1A1A;
  border-top: 1px solid var(--ink);
  font-size: .72rem;
  letter-spacing: .04em;
}
.colophon img { display: block; height: 1.2rem; width: auto; }

@media (max-width: 480px) {
  body { padding-top: 16px; }
  .band { flex-direction: column; gap: .1rem; }
  .row { grid-template-columns: 1.6em minmax(0, 1fr); column-gap: .3rem; }
  .row .s { min-width: 3.4em; }
  .note { padding-left: calc(1.6em + .3rem); }

  /* The figures stack per item on a phone: one block per row, each figure under its column name. */
  #figures, #figures tbody, #figures tfoot, #figures tr, #figures td { display: block; }
  #figures thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #figures tr { padding: .45rem 0 .5rem; border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); }
  #figures tfoot tr { border-top: 3px double var(--ink); border-bottom: 0; }
  #figures td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .1rem 0; border: 0; text-align: right; min-width: 0; }
  #figures td::before {
    content: attr(data-label);
    flex: none;
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
    color: var(--ink-soft);
  }
  #figures td.item { display: block; text-align: left; font-weight: 700; padding-bottom: .2rem; }
  #figures td.item::before { content: none; }
  #figures td:empty { display: none; }
}

@media print {
  @page { size: A4; margin: 14mm 16mm; }
  body { padding: 0; background: #fff; color: #000; }
  .card { max-width: none; border: 0; box-shadow: none; background: #fff; }
  .band { background: #fff; color: #000; border-bottom: 1px solid #000; padding-top: .4rem; }
  .punch { top: .55rem; background: #fff; border: 1px solid #000; }
  .field .label { color: #000; }
  .title-out { border-bottom-color: #000; }
  .screen { padding: .6rem 0 0; }
  #write, #run, .buttons, .colophon { display: none !important; }
  .sheet { padding: 0; background: #fff; color: #000; }
  .sheet .items, .sheet .foot { border-top-color: #000; }
  .sheet .head, .sheet .items > li, .sheet .foot { break-inside: avoid; }
  .sheet .foot .seat { line-height: 2.5rem; }
}
