/* AFT scorecard.
 *
 * The visual model is the scorecard a grader fills in, not a marketing page:
 * an identification strip, five numbered event rows, and a total ruled off at
 * the bottom the way a real column totals. Army black-and-gold on gray-green
 * form stock. System fonts only -- the page makes no third-party requests.
 */

:root {
  --paper: #e7eae4;
  --panel: #f6f8f4;
  --ink: #131b19;
  --mute: #5c665f;
  --rule: #c5ccc0;
  --rule-strong: #8e9a90;
  --gold: #ffcc01;
  --gold-deep: #a97f00;
  --under: #9e3f27;
  --pass: #2e5b42;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas,
    monospace;

  --gutter: clamp(1rem, 4vw, 3rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  /* Tabular figures everywhere: this is an instrument, and digits must not
   * reflow as values change. */
  font-variant-numeric: tabular-nums;
}

.sheet {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--gutter) var(--gutter) 4rem;
}

/* ---- label vernacular -------------------------------------------------- */

/* Small caps mono labels are the form's voice. Used for every field label,
 * column head, and unit, and nowhere else. */
.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

/* ---- masthead ---------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--ink);
}

.masthead h1 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.masthead .expand {
  font-weight: 400;
  color: var(--mute);
  letter-spacing: 0.01em;
}

.masthead #edition {
  margin-left: auto;
}

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

/* Every typed or pressed control shares one skin; the rules below vary only
 * width, size and alignment. */
.field input,
.scale button,
.event .entry input {
  padding: 0.4rem 0.5rem;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
}

/* ---- identification strip ---------------------------------------------- */

.ident {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  align-items: flex-end;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field input[type="number"] {
  width: 5rem;
  font-size: 1.25rem;
}

/* Two-state scale selector. No default is preselected: a scoring tool that
 * guesses this would return a confidently wrong number. */
.scale {
  display: flex;
}

.scale button {
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.scale button:first-child {
  border-radius: 2px 0 0 2px;
}

.scale button:last-child {
  border-radius: 0 2px 2px 0;
  border-left: none;
}

.scale button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--gold);
  border-color: var(--ink);
}

.ident .note {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--mute);
}

/* ---- event rows -------------------------------------------------------- */

/* Numbered because the AFT is administered in this order with fixed rest
 * intervals -- the sequence is real information, not decoration. */
.events {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto auto;
  grid-template-areas:
    "seq name input points"
    ".   track track track"
    ".   gap   gap   gap";
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.event .seq {
  grid-area: seq;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--rule-strong);
}

.event .name {
  grid-area: name;
}

.event .name strong {
  display: block;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.event .name .detail {
  display: block;
  font-size: 0.8125rem;
  color: var(--mute);
}

.event .entry {
  grid-area: input;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* Timed events take a minute and a second field. The label sits above its own
 * box so the pair reads as one measurement rather than two questions. */
.event .entry .pair {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0.25rem;
}

.event .entry input {
  width: 4rem;
  font-size: 1.125rem;
  text-align: right;
}

.event .entry .pair input {
  width: 3.25rem;
}

/* Spinners steal width from a field this narrow and invite mouse-driven entry
 * where typing is faster. The numeric keyboard on mobile is the point, not the
 * arrows. */
.event .entry input::-webkit-outer-spin-button,
.event .entry input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.event .entry input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.event .entry input[aria-invalid="true"] {
  border-color: var(--under);
  background: #fbf0ed;
}

/* The scored value. Large mono is the page's typographic centrepiece -- the
 * personality comes from the numerals, not from a display face. */
.event .points {
  grid-area: points;
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  min-width: 4.25rem;
  text-align: right;
  letter-spacing: -0.03em;
}

.event .points .unit {
  /* Sizing only; the form voice comes from `.label` on the same element. */
  font-size: 0.6875rem;
}

.event[data-state="under"] .points {
  color: var(--under);
}

.event[data-state="pass"] .points {
  color: var(--pass);
}

.event[data-state="max"] .points {
  color: var(--gold-deep);
}

.event[data-state="empty"] .points {
  color: var(--rule-strong);
}

/* ---- the scale track: the signature element ---------------------------- */

/* Positioned by POINTS, not by raw result, so the 60-point pass line sits at a
 * constant 60% on every event. That makes the five tracks directly comparable
 * and shows at a glance which event is holding the total down. */
.track-wrap {
  grid-area: track;
  margin-top: 0.875rem;
}

.track {
  display: block;
  position: relative;
  height: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.track .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--gold);
  transition: width 220ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.event[data-state="under"] .fill {
  background: #e6c9c0;
}

/* The 60-point standard, drawn as a hard notch through the track. */
.track .passline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 60%;
  width: 2px;
  background: var(--ink);
}

.scalebar {
  display: block;
  position: relative;
  height: 1.25rem;
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--mute);
}

.scalebar span {
  position: absolute;
  white-space: nowrap;
  transform: translateX(-50%);
}

.scalebar span:first-child {
  left: 0;
  transform: none;
}

.scalebar span:last-child {
  left: 100%;
  transform: translateX(-100%);
}

.scalebar .at-pass {
  left: 60%;
  color: var(--ink);
  font-weight: 700;
}

.event .gap {
  grid-area: gap;
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--mute);
  min-height: 1.25rem;
}

.event .gap b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 700;
}

/* ---- total ------------------------------------------------------------- */

/* Ruled off at the bottom, the way a scorecard totals its column. */
.total {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--ink);
}

.total .sum {
  font-family: var(--mono);
  font-size: clamp(3rem, 12vw, 5rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.total .sum .of {
  font-size: 0.3em;
  font-weight: 600;
  color: var(--mute);
  letter-spacing: 0;
}

.verdict {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.verdict[data-verdict="pass"] {
  color: var(--pass);
}

.verdict[data-verdict="fail"] {
  color: var(--under);
}

.verdict[data-verdict="partial"] {
  color: var(--mute);
  border-style: dashed;
}

/* ---- footer ------------------------------------------------------------ */

.colophon {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8125rem;
  color: var(--mute);
}

.colophon p {
  margin: 0 0 0.5rem;
  max-width: 44rem;
}

.colophon a {
  color: var(--ink);
}

/* ---- states ------------------------------------------------------------ */

.banner {
  padding: 0.75rem 1rem;
  margin: 1.25rem 0 0;
  background: var(--panel);
  border-left: 3px solid var(--gold);
  font-size: 0.9375rem;
}

.banner.error {
  border-left-color: var(--under);
  color: var(--under);
}

/* ---- quality floor ----------------------------------------------------- */

/* Inputs are bold dark mono so entered results read as data. Placeholders must
 * therefore be unmistakably NOT data -- otherwise an untouched form looks like a
 * filled-in one, which on a scoring tool is the worst thing the page could imply. */
::placeholder {
  color: var(--rule-strong);
  font-weight: 400;
  opacity: 1;
}

:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 34rem) {
  .event {
    grid-template-columns: 2rem 1fr;
    grid-template-areas:
      "seq name"
      ".   input"
      ".   points"
      ".   track"
      ".   gap";
  }

  .event .points {
    text-align: left;
    font-size: 1.75rem;
  }
}
