/* GWA grade sheet. One cacheable stylesheet. No remote fonts or images. */

:root {
  --desk: #efeae3;
  --sheet: #fbf9f6;
  --ink: #1c1915;
  --bronze: #7c4a28;
  --bronze-deep: #5c3818;
  --muted: #4a433c;
  --rule: #ddd4c8;
  --danger: #6e2c24;
  --danger-bg: #f8ece8;
  --on-accent: #fffaf6;
  --on-ink: #f7f4ef;
  --on-ink-soft: #e4dcd2;
  --placeholder: #5e564e;
  --serif: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
  --radius-control: 10px;
  --shadow: 0 12px 32px rgba(28, 25, 21, 0.06);
  --shadow-result: 0 18px 40px rgba(28, 25, 21, 0.16);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: clip;
  border-top: 4px solid var(--bronze);
}

.wrap {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

img,
svg {
  max-width: 100%;
}

::selection {
  background: var(--bronze);
  color: var(--on-accent);
}

a {
  color: var(--bronze-deep);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--ink);
}

.skip {
  position: absolute;
  left: 12px;
  top: 0;
  transform: translateY(-130%);
  background: var(--ink);
  color: var(--on-ink);
  padding: 10px 14px;
  z-index: 8;
  text-decoration: none;
  border-radius: 8px;
}

.skip:focus {
  transform: none;
  top: 12px;
  color: var(--on-ink);
}

.mast {
  border-bottom: 1px solid var(--rule);
}

.mast-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  min-height: 68px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand,
.footer-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name,
.footer-mark span {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand-sub {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bronze-deep);
  line-height: 1.2;
}

.mast-side {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.92rem;
}

.desk {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  padding-top: 22px;
}

.intro,
.desk-work,
.desk-result {
  min-width: 0;
}

.intro {
  order: 1;
}

h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.05rem, 4vw, 3.35rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.lede {
  margin: 0;
  max-width: 38rem;
  font-size: 1.05rem;
  line-height: 1.45;
}

.desk-result {
  order: 2;
  background: var(--ink);
  color: var(--on-ink);
  border-radius: var(--radius);
  border-top: 4px solid var(--bronze);
  box-shadow: var(--shadow-result);
  padding: 16px 16px 14px;
}

.kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-ink-soft);
}

.figure {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.7rem, 12vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  color: var(--on-ink);
  overflow-wrap: anywhere;
}

.figure.is-fresh {
  animation: figure-in 200ms ease;
}

@keyframes figure-in {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.figure-note,
.band {
  margin: 8px 0 0;
  max-width: 36rem;
}

.figure-note {
  color: var(--on-ink-soft);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.band {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.35;
  color: var(--on-ink);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  max-width: 100%;
}

.check input {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 2px solid currentColor;
  border-radius: 5px;
  background: transparent;
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
}

.check input:checked {
  background: var(--bronze);
  border-color: var(--bronze);
}

.check input:checked::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid var(--on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
  margin: 12px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(247, 244, 239, 0.22);
}

.stats div {
  margin: 0;
  min-width: 0;
}

.stats dt {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-ink-soft);
  line-height: 1.25;
}

.stats dd {
  margin: 3px 0 0;
  font-size: 1.05rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--on-ink);
  overflow-wrap: anywhere;
}

.desk-work {
  order: 3;
  background: transparent;
  padding: 0;
}

.noscript {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--bronze);
  border-radius: var(--radius-control);
  background: var(--sheet);
  font-size: 0.95rem;
}

.scale {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
  min-width: 0;
}

.scale legend {
  padding: 0;
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.scale-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--ink);
  border-radius: var(--radius-control);
  background: var(--sheet);
  min-width: 0;
}

.scale label {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 52px;
  padding: 8px 10px;
  cursor: pointer;
}

.scale label + label {
  border-left: 1px solid var(--ink);
}

.scale label:first-child {
  border-radius: 9px 0 0 9px;
}

.scale label:last-child {
  border-radius: 0 9px 9px 0;
}

.scale input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.scale-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
}

.scale-hint {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.scale label:has(input:checked) {
  background: var(--bronze);
  color: var(--on-accent);
}

.scale label:has(input:checked) .scale-hint {
  color: #f6e4d4;
}

.scale label:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  z-index: 1;
}

.scale input:focus,
.scale input:focus-visible {
  outline: none;
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.sheet caption {
  caption-side: top;
  text-align: left;
  padding: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.sheet th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--ink);
}

.sheet th:nth-child(4) {
  text-align: right;
}

.sheet th:nth-child(1),
.sheet td:nth-child(1) { width: 32%; }
.sheet th:nth-child(2),
.sheet td:nth-child(2) { width: 17%; }
.sheet th:nth-child(3),
.sheet td:nth-child(3) { width: 15%; }
.sheet th:nth-child(4),
.sheet td:nth-child(4) { width: 18%; }
.sheet th:nth-child(5),
.sheet td:nth-child(5) { width: 18%; }

.opt {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.sheet td {
  vertical-align: top;
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--rule);
}

.cell-label {
  display: none;
}

.sheet input {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 8px 2px;
  font-variant-numeric: tabular-nums;
}

.sheet input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.sheet input[aria-invalid="true"] {
  border-bottom-color: var(--danger);
  background: var(--danger-bg);
  border-radius: 6px 6px 0 0;
  padding-left: 6px;
  padding-right: 6px;
}

.field-error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.field-error:empty {
  display: none;
}

.product {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.product-value {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  overflow-wrap: anywhere;
}

.sheet tr.ok td:first-child {
  box-shadow: inset 3px 0 0 var(--bronze);
}

.sheet tr.bad td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.sheet tr.is-entering {
  animation: row-in 180ms ease;
}

@keyframes row-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.remove {
  width: 100%;
}

.add {
  background: var(--bronze);
  border-color: var(--bronze-deep);
  color: var(--on-accent);
}

.add:hover:not(:disabled) {
  background: var(--bronze-deep);
}

button:hover:not(:disabled):not(.add) {
  background: rgba(124, 74, 40, 0.08);
}

#reset[data-armed="true"] {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-accent);
}

#reset[data-armed="true"]:hover {
  background: #5a221c;
}

button:disabled,
.add:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: transparent;
  border-color: var(--rule);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.sheet-status,
.save-note,
.reset-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 42rem;
}

.reset-hint {
  color: var(--danger);
}

.prose {
  margin-top: 42px;
  padding-bottom: 8px;
}

.note {
  padding: 26px 0 8px;
  border-top: 1px solid var(--rule);
}

.note h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.note h3 {
  margin: 1.15rem 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.note p,
.note li {
  max-width: 68ch;
  margin: 0.5rem 0;
}

.note ol {
  margin: 0.35rem 0 0.7rem;
  padding-left: 1.25rem;
}

.example {
  width: 100%;
  max-width: 40rem;
  border-collapse: collapse;
  margin: 0.7rem 0 0.35rem;
  table-layout: fixed;
}

.example th,
.example td {
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: bottom;
  padding: 8px 8px 8px 0;
  font-variant-numeric: tabular-nums;
}

.example thead th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.example .num {
  text-align: right;
}

.example tfoot th,
.example tfoot td {
  border-bottom: 0;
  border-top: 1px solid var(--ink);
  font-weight: 600;
}

.example col.c1 { width: 40%; }
.example col.c2 { width: 18%; }
.example col.c3 { width: 16%; }
.example col.c4 { width: 26%; }

.example caption {
  caption-side: bottom;
  text-align: left;
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-footer {
  border-top: 1px solid var(--ink);
  margin-top: 28px;
  padding: 22px 0 40px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: flex-start;
}

.footer-mark .mark {
  width: 28px;
  height: 28px;
}

.footer-copy {
  flex: 1 1 240px;
  min-width: 0;
}

.footer-copy p {
  margin: 0.25rem 0;
  max-width: 46rem;
}

.missing {
  padding-top: 28px;
  padding-bottom: 72px;
}

.missing p {
  max-width: 42rem;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.desk-result :focus-visible {
  outline-color: var(--on-ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 719px) {
  .scale-name {
    font-size: 0.82rem;
  }

  .scale label {
    padding: 8px 8px;
  }

  .sheet,
  .sheet tbody {
    display: block;
    width: 100%;
  }

  .sheet {
    position: relative;
  }

  .sheet thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .sheet caption {
    display: block;
  }

  .sheet tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
    width: 100%;
    margin: 0 0 10px;
    padding: 12px;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(28, 25, 21, 0.04);
  }

  .sheet tr.ok,
  .sheet tr.bad {
    box-shadow: inset 3px 0 0 var(--bronze), 0 8px 20px rgba(28, 25, 21, 0.04);
  }

  .sheet tr.bad {
    box-shadow: inset 3px 0 0 var(--danger), 0 8px 20px rgba(28, 25, 21, 0.04);
  }

  .sheet tr.ok td:first-child,
  .sheet tr.bad td:first-child {
    box-shadow: none;
  }

  .sheet td:nth-child(n),
  .sheet th:nth-child(n) {
    width: auto;
    max-width: none;
  }

  .sheet td {
    display: block;
    min-width: 0;
    border-bottom: 0;
    padding: 0;
  }

  .sheet td[data-col="subject"],
  .sheet td[data-col="product"],
  .sheet td[data-col="remove"] {
    grid-column: 1 / -1;
  }

  .cell-label {
    display: block;
    margin-bottom: 2px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .sheet td.product {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding-top: 2px;
    text-align: left;
  }

  .product .cell-label {
    margin: 0;
  }

  .product-value {
    min-height: 0;
    line-height: 1.3;
    font-weight: 600;
  }

  .sheet input {
    background: #fff;
    border: 1px solid var(--rule);
    border-bottom: 1.5px solid var(--ink);
    border-radius: 8px;
    padding: 8px 10px;
  }

  .sheet input[aria-invalid="true"] {
    border-color: var(--danger);
    border-radius: 8px;
  }

  .add {
    flex: 1 1 160px;
  }

  .example {
    font-size: 0.92rem;
  }
}

@media (min-width: 720px) and (max-width: 1099px) {
  .wrap {
    padding-left: 28px;
    padding-right: 28px;
  }

  .desk-result {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.85fr);
    gap: 8px 28px;
    align-items: center;
    padding: 22px 26px;
  }

  .stats {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    margin: 0;
    padding: 4px 0 4px 26px;
    border-top: 0;
    border-left: 1px solid rgba(247, 244, 239, 0.22);
  }

  .stats div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
  }

  .stats dd {
    margin: 0;
    font-size: 1.25rem;
    text-align: right;
  }

  .desk-work {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px 18px;
  }

  .figure {
    font-size: clamp(3rem, 6vw, 4rem);
  }
}

@media (min-width: 1100px) {
  .wrap {
    padding-left: 36px;
    padding-right: 36px;
  }

  .desk {
    display: grid;
    grid-template-columns: minmax(0, 1.48fr) minmax(300px, 0.74fr);
    grid-template-areas:
      "intro result"
      "work result";
    column-gap: 32px;
    row-gap: 18px;
    align-items: start;
    padding-top: 32px;
  }

  .intro {
    grid-area: intro;
    order: 0;
  }

  .desk-work {
    grid-area: work;
    order: 0;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px 20px;
  }

  .desk-result {
    grid-area: result;
    order: 0;
    align-self: start;
    position: sticky;
    top: 18px;
    display: block;
    height: fit-content;
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 22px 22px 16px;
  }

  .figure {
    font-size: clamp(3.1rem, 4vw, 4.35rem);
  }

  .stats {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 16px 0 0;
    padding: 2px 0 0;
    border-top: 1px solid rgba(247, 244, 239, 0.22);
  }

  .stats div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(247, 244, 239, 0.14);
  }

  .stats dd {
    margin: 0;
    font-size: 1.15rem;
    text-align: right;
  }

  .note {
    display: grid;
    grid-template-columns: 13.5rem minmax(0, 66ch);
    gap: 4px 36px;
    align-items: start;
  }

  .note h2 {
    margin: 0;
    position: static;
  }

  .footer-inner {
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #241f1b;
    --rule: #1c1915;
    --on-ink-soft: #fffaf6;
    --placeholder: #3a342f;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    border-top: 0;
  }

  .desk {
    display: block;
  }

  .desk-result,
  .desk-work {
    background: #fff;
    color: #000;
    box-shadow: none;
    border: 1px solid #000;
  }

  .figure,
  .kicker,
  .band,
  .figure-note,
  .stats,
  .stats dt,
  .stats dd {
    color: #000;
  }

  .add,
  .remove,
  .check,
  .skip,
  .mast-side {
    display: none;
  }
}
