@import url("tokens.css");

/* Three role tokens. The brand colours never change; only what a role points to. */
:root {
  --q-mine: var(--c-earth);
  --q-ref: var(--c-moss);
  --q-err: var(--c-copper);
  --font-q: "General Sans", "DejaVu Sans", "Noto Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --q-mine: var(--c-peach);
    --q-ref: var(--c-sky);
    --q-err: var(--c-brick);
  }
}
[data-theme="dark"] {
  --q-mine: var(--c-peach);
  --q-ref: var(--c-sky);
  --q-err: var(--c-brick);
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-q);
  -webkit-text-size-adjust: 100%;
}
.page { max-width: 1280px; margin: 0 auto; padding: 24px 32px 72px; }
.print-only { display: none; }

.head { margin-bottom: 20px; }
.wordmark { display: block; width: 160px; height: auto; }
h1, h2, h3, th { font-family: var(--font-display); }
h1 { font-size: 40px; line-height: 1.1; font-weight: 700; margin: 20px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.lede { font-size: 17px; max-width: 46em; }
.notice { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 6px 0; }
.small { font-size: 13px; color: var(--ink-soft); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); }
.grid > section { min-width: 0; padding: 20px 0; border-top: 1px solid var(--ink); }
.grid > .plot { border-top: 0; padding-top: 0; }
.end { padding-top: 20px; border-top: 1px solid var(--ink); }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 60fr) minmax(0, 40fr); }
  .grid > .plot { padding: 0 24px 20px 0; border-right: 1px solid var(--ink); }
  .grid > .vowels { padding: 0 0 20px 24px; border-top: 0; }
  .grid > .wide { grid-column: 1 / -1; }
}

/* the chart */
#chart { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; outline: none; }
@media screen { #chart:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; } }
#chart * { vector-effect: non-scaling-stroke; }
#chart text { font-family: var(--font-q); fill: var(--ink-soft); font-size: 11px; }
#chart .frame { fill: none; stroke: var(--ink); stroke-width: 1; }
#chart .tick { stroke: var(--ink); stroke-width: 1; }
#chart .edge { font-size: 12px; letter-spacing: 0.04em; }
#chart .ref { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
#chart .ref.emph { fill: var(--q-ref); stroke: var(--q-ref); }
#chart .ref-label { fill: var(--ink-soft); font-size: 15px; }
#chart .ref-label.emph { fill: var(--q-ref); }
#chart .dot { fill: var(--q-mine); }
#chart .ell { fill: none; stroke: var(--q-mine); stroke-width: 1.5; }
#chart .box { fill: none; stroke: var(--q-err); stroke-width: 1; stroke-dasharray: 6 3; }
#chart .med { fill: var(--q-mine); }
#chart .mine-label { fill: var(--q-mine); font-size: 13px; }
#chart .mine-label.snap { font-weight: 700; }
/* a halo in the ground colour keeps a label legible where it crosses a line or a mark */
#chart .ref-label, #chart .mine-label { paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
#chart.narrow .mine-label { font-size: 11px; }
#chart.narrow .ref-label { font-size: 13px; }
#chart .quad-mine { fill: none; stroke: var(--q-mine); stroke-width: 2; }
#chart .quad-ref { fill: none; stroke: var(--q-ref); stroke-width: 1; stroke-dasharray: 1 3; }
#chart .cursor { fill: none; stroke: var(--q-err); stroke-width: 1.5; }

.legend { font-size: 14px; margin: 10px 0 0; }
.legend button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer; }
.legend button:disabled { text-decoration: none; cursor: text; color: inherit; }
.legend button[aria-pressed="true"] { font-weight: 700; }
.hint { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--ink); }
#readout { font-variant-numeric: tabular-nums; }

/* tables */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 700; font-size: 12px; padding: 4px 6px 4px 0; border-bottom: 1px solid var(--ink); white-space: nowrap; }
td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--ink-soft); vertical-align: baseline; white-space: nowrap; }
.num { text-align: right; }
td.sym { font-size: 15px; }
.sd { display: block; font-size: 11px; color: var(--ink-soft); line-height: 1.2; }
#vowels th, #vowels td { padding-right: 5px; }
#vowels th:last-child, #vowels td:last-child { padding-right: 0; }
#vowels th .sd { font-weight: 400; }
#vowels button { padding: 2px 7px; }
.sym-inline { display: none; }
tr.msg td { border-bottom: 1px solid var(--ink-soft); padding: 0 0 6px; color: var(--ink); white-space: normal; font-size: 13px; }
tr.msg td:empty { display: none; }
tr.has-msg td { border-bottom: 0; }
tr.none td { color: var(--ink-soft); }
#vowels td:first-child { color: var(--ink-soft); }

button {
  font: inherit; font-size: 13px; color: var(--ink); background: transparent;
  border: 1px solid var(--ink); padding: 2px 10px; cursor: pointer;
}
/* screen only, so a pointer still resting on a button never prints inverted on the sheet */
@media screen {
  button:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
  button:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
}
button:disabled { color: var(--ink-soft); border-color: var(--ink-soft); cursor: not-allowed; }
#print { font-size: 15px; padding: 4px 18px; }

/* the informant sheet */
.particulars { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: baseline; margin-bottom: 14px; }
.particulars p { margin: 0; }
.particulars input {
  font: inherit; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--ink);
  padding: 2px 0; margin-left: 6px; width: 16em; max-width: 60vw;
}
.crow { font-size: 15px; font-weight: 400; line-height: 1.5; letter-spacing: normal; color: var(--ink); margin: 0 0 6px; }
.crow label { margin-left: 14px; white-space: nowrap; }
.crow .yn { white-space: nowrap; }
.crow input { accent-color: var(--ink); margin: 0 4px 0 0; vertical-align: -1px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark { filter: invert(1) hue-rotate(180deg); }
}
[data-theme="dark"] .wordmark { filter: invert(1) hue-rotate(180deg); }

@media (max-width: 600px) {
  .page { padding: 16px 16px 56px; }
  h1 { font-size: 32px; margin-top: 16px; }
  .lede { font-size: 16px; }
  .crow label { margin-left: 10px; }
  /* No keyboard to speak of: the digit column goes, the symbol rides beside the word. */
  #vowels { font-size: 12px; }
  #vowels .key, #vowels .symcol { display: none; }
  #vowels th, #vowels td { padding-right: 4px; }
  #vowels th:last-child, #vowels td:last-child { padding-right: 0; }
  #vowels button { font-size: 12px; padding: 2px 5px; }
  .sym-inline { display: inline; margin-left: 4px; font-size: 14px; color: var(--ink-soft); }
  #takes, #tested { font-size: 12px; }
  #takes th, #tested th { white-space: normal; vertical-align: bottom; }
  #takes th, #takes td, #tested th, #tested td { padding-right: 4px; }
  .crow .yn label:first-child { margin-left: 0; }
  .crow .yn { display: block; margin-top: 2px; }
}

/* the sheet */
@page { margin: 14mm; }
@media print {
  :root, :root:not([data-theme="light"]), [data-theme="dark"] {
    --bg: #FCF0DD; --ink: #1A1A1A; --ink-soft: #5B5B5B;
    --q-mine: var(--c-earth); --q-ref: var(--c-moss); --q-err: var(--c-copper);
    color-scheme: light;
  }
  html, body { background: #fff; }
  body { font-size: 9pt; line-height: 1.35; }
  .page { max-width: none; padding: 0; }
  .screen-only, .hint, tr.msg, .notice { display: none !important; }
  .print-only { display: block; }
  .head { position: relative; margin: 0 0 3mm; }
  .wordmark { position: absolute; top: 0; right: 0; width: 30mm; filter: none !important; }
  .sheet-head h1 { font-size: 17pt; margin: 0 0 1mm; }
  .sheet-head p { margin: 0 0 0.5mm; }
  .fill { display: inline-block; min-width: 55mm; border-bottom: 0.75pt solid var(--ink); margin-right: 6mm; }
  .grid { display: block; }
  .grid > section, .grid > .plot, .grid > .vowels { padding: 2.5mm 0; border: 0; border-top: 0.75pt solid var(--ink); }
  .grid > .plot { border-top: 0; padding-top: 0; }
  #chart { width: 100%; height: auto; }
  #chart .dot { fill: var(--ink); }
  #chart .ref-label, #chart .mine-label { stroke: #fff; }
  .legend { font-size: 8.5pt; margin-top: 1.5mm; }
  .legend button { text-decoration: none; font-weight: inherit; }
  :focus-visible { outline: none; }
  .scroll { overflow: visible; }
  table { font-size: 8pt; }
  th { font-size: 8pt; padding: 1mm 2mm 1mm 0; }
  td { padding: 0.8mm 2mm 0.8mm 0; border-bottom: 0.75pt solid var(--ink-soft); }
  td.sym { font-size: 9pt; }
  #vowels th, #vowels td { padding-right: 4mm; }
  #vowels th:last-child, #vowels td:last-child { padding-right: 0; }
  tr.has-msg td { border-bottom: 0.75pt solid var(--ink-soft); }
  .sd { display: inline; font-size: inherit; color: inherit; }
  h2 { font-size: 10pt; margin-bottom: 1.5mm; }
  h3 { font-size: 9pt; }
  .small { font-size: 7.5pt; margin: 1mm 0 0; }
  tr { break-inside: avoid; }
  .footing p { margin: 0 0 0.6mm; }
  .footing { break-inside: avoid; }
  .classification { break-inside: avoid; }
  .crow { font-size: 9pt; margin: 0 0 1mm; }
}
