/*
 * The base sheet: reset, type voices, letterhead, buttons, blanks, the pad and the flag.
 * Shared by the sign-in page and the app, because it is the one stylesheet the server hands
 * out before sign-in. The app adds its parts in app.css. Tokens: /vendor/tokens.css (the
 * brand's generated tokens, "The Closing Table"). No colour here that is not a token.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--av-space-6);
  scrollbar-color: var(--av-ink-3) var(--av-band-soft);
}

body {
  margin: 0;
  background: var(--av-paper);
  color: var(--av-ink);
  font-family: var(--av-font-doc);
  font-size: var(--av-text-body);
  line-height: var(--av-leading-body);
  font-variant-numeric: lining-nums;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--av-ink);
  caret-color: var(--av-pen);
  overflow-wrap: break-word;
}

::selection {
  background: var(--av-pad);
  color: var(--av-ink);
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure,
table,
pre {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  text-wrap: balance;
}

p,
dd,
li,
td {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 0.12em;
}

/* Focus is where your pen is. */
:focus-visible {
  outline: var(--av-line-focus) solid var(--av-pen);
  outline-offset: 2px;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  border-radius: var(--av-radius);
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}

/* ---- Type voices ------------------------------------------------------ */

.label {
  font-family: var(--av-font-label);
  font-size: var(--av-text-label);
  font-stretch: var(--av-label-stretch);
  font-weight: var(--av-label-weight);
  letter-spacing: var(--av-label-tracking);
  line-height: 1.25;
  text-transform: uppercase;
}

.fine {
  font-size: var(--av-text-fine);
  line-height: var(--av-leading-fine);
  color: var(--av-ink-2);
}

.figures {
  font-variant-numeric: lining-nums tabular-nums;
}

.wrap {
  width: 100%;
  max-width: var(--av-sheet);
  margin-inline: auto;
  padding-inline: var(--av-gutter);
}

.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;
}

.skip {
  display: inline-flex;
  align-items: center;
  min-height: var(--av-target);
  position: absolute;
  left: var(--av-gutter);
  top: -4rem;
  z-index: 10;
  padding: var(--av-space-2) var(--av-space-4);
  background: var(--av-ink);
  color: var(--av-paper);
  font-weight: 700;
}

.skip:focus {
  top: var(--av-space-2);
}

/* ---- Letterhead: the typed name, the app, plain links ---------------- */

.letterhead {
  border-bottom: var(--av-line-heavy) solid var(--av-rule);
}

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--av-space-2) var(--av-space-5);
  min-height: 4.25rem;
  padding-block: var(--av-space-3);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  min-height: var(--av-target);
  font-size: var(--av-text-wordmark);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  padding-right: var(--av-space-5);
  border-right: var(--av-line-hair) solid var(--av-rule);
}

.wordmark .kind {
  font-weight: 400;
}

.app {
  font-family: var(--av-font-label);
  font-size: var(--av-text-small);
  font-stretch: 92%;
  font-weight: 500;
  white-space: nowrap;
}

/* ---- The opening of a sheet: the RE: line and its deck ---------------- */

.intro {
  padding-block: var(--av-space-6) var(--av-space-5);
}

.intro h1 {
  font-size: var(--av-text-display);
  line-height: var(--av-leading-display);
  letter-spacing: -0.012em;
}

.deck {
  margin-top: var(--av-space-3);
  max-width: 74ch;
  font-size: var(--av-text-lead);
  line-height: var(--av-leading-lead);
}

/* ---- Buttons: a typed instruction at the foot of a form ---------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--av-space-2);
  text-align: left;
  min-height: 3rem;
  padding: 0 var(--av-space-5);
  border: var(--av-line-control) solid var(--av-ink);
  background: var(--av-ink);
  color: var(--av-paper);
  font-family: var(--av-font-doc);
  font-size: var(--av-text-body);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--av-motion-quick) linear,
    color var(--av-motion-quick) linear;
}

.button:hover {
  background: var(--av-paper);
  color: var(--av-ink);
}

.button:active {
  background: var(--av-band);
  color: var(--av-ink);
}

.button[disabled],
.button[aria-disabled='true'] {
  background: transparent;
  color: var(--av-pad-ink-2);
  border-style: dashed;
  cursor: not-allowed;
}

.button.quiet {
  background: transparent;
  color: var(--av-ink);
}

.button.quiet:hover {
  background: var(--av-ink);
  color: var(--av-paper);
}

.button.quiet:active {
  background: var(--av-band);
  color: var(--av-ink);
}

/* On paper (not the pad) a blocked button keeps ink-2: pad-ink-2 belongs to yellow. */
.button.quiet[disabled] {
  color: var(--av-ink-2);
}

/* ---- The pad: yellow is yours to fill in ------------------------------- */

.pad {
  background: var(--av-pad);
  border-block: var(--av-line-control) solid var(--av-ink);
}

.pad .row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--av-space-4);
  padding-block: var(--av-space-4) var(--av-space-5);
}

.pad .field {
  flex: 1 1 18rem;
}

.pad .button {
  margin-top: 1.3rem;
  min-height: var(--av-target);
}

/* ---- The flag: a sign-here tab pointing at where you act ---------------- */

.flag {
  --notch: 0.85rem;
  --shape: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%);
  --paper-shape: polygon(0 0, calc(100% - var(--notch) + 0.6px) 0, calc(100% - 2px) 50%, calc(100% - var(--notch) + 0.6px) 100%, 0 100%);
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 2.5rem;
  margin-top: 1.4rem;
  padding: 0 calc(var(--notch) + var(--av-space-3)) 0 var(--av-space-3);
  background: var(--av-ink);
  color: var(--av-ink);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  clip-path: var(--shape);
  isolation: isolate;
}

.flag::before {
  content: '';
  position: absolute;
  inset: var(--av-line-control);
  z-index: -1;
  background: var(--av-paper);
  clip-path: var(--paper-shape);
}

/* When the blanks sit under the flag, it points down at them. */
.flag.points-down,
.pad .row > .flag {
  --notch: 0.6rem;
  --shape: polygon(0 0, 100% 0, 100% calc(100% - var(--notch)), 1.6rem calc(100% - var(--notch)), 1rem 100%, 0.4rem calc(100% - var(--notch)), 0 calc(100% - var(--notch)));
  --paper-shape: polygon(0 0, 100% 0, 100% calc(100% - var(--notch) + 0.6px), calc(1.6rem - 1.5px) calc(100% - var(--notch) + 0.6px), 1rem calc(100% - 2.5px), calc(0.4rem + 1.5px) calc(100% - var(--notch) + 0.6px), 0 calc(100% - var(--notch) + 0.6px));
  flex-basis: auto;
  min-height: calc(2.5rem + var(--notch));
  margin: 0 100% calc(-1 * var(--av-space-2)) 0;
  padding: 0 var(--av-space-3) var(--notch);
}

/* ---- Blanks --------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.field > label,
.field > .label {
  color: var(--av-ink);
}

.blank {
  width: 100%;
  min-height: var(--av-target);
  padding: 0 var(--av-space-3);
  border: var(--av-line-control) solid var(--av-ink);
  background: var(--av-paper);
  font-family: var(--av-font-doc);
  font-size: var(--av-text-body);
  line-height: 1.2;
  font-variant-numeric: lining-nums tabular-nums;
}

.blank::placeholder {
  color: var(--av-ink-3);
  opacity: 1;
}

.blank:hover {
  background-color: var(--av-band-soft);
}

.blank:hover::placeholder {
  color: var(--av-ink-2);
}

.blank:focus-visible {
  background-color: var(--av-paper);
  outline-offset: 1px;
}

select.blank {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.2 6 6.6 11 1.2' fill='none' stroke='%23111214' stroke-width='1.8' stroke-linecap='square'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 0.75rem 0.5rem;
  text-overflow: ellipsis;
  cursor: pointer;
}

select.blank option {
  color: var(--av-ink);
}

.blank[aria-invalid='true'] {
  border-color: var(--av-correct);
  border-width: var(--av-line-heavy);
}

.field .hint,
.pad .hint {
  font-size: var(--av-text-fine);
  line-height: 1.4;
  color: var(--av-pad-ink-2);
}

.error {
  display: flex;
  gap: 0.4em;
  font-size: var(--av-text-fine);
  font-weight: 700;
  line-height: 1.4;
  color: var(--av-correct);
}

/* An empty error stays in the accessibility tree as a live region and takes no room. */
.error:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.error::before {
  content: '';
  flex: none;
  width: 1em;
  height: 1em;
  margin-top: 0.2em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.2 15.2 14.4H.8Z' fill='none' stroke='%23a8201a' stroke-width='1.6' stroke-linejoin='round'/%3E%3Cpath d='M8 6v4.2M8 12.1v.4' stroke='%23a8201a' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* ---- Tick boxes and bubbles -------------------------------------------------- */

:root {
  --tick: 1.5rem;
}

.tickbox {
  display: inline-grid;
  grid-template-columns: var(--tick) auto;
  column-gap: var(--av-space-2);
  align-items: center;
  min-height: var(--av-target);
  cursor: pointer;
}

.tickbox input {
  appearance: none;
  width: var(--tick);
  height: var(--tick);
  margin: 0;
  border: var(--av-line-control) solid var(--av-ink);
  background: var(--av-paper);
  cursor: pointer;
}

.tickbox input[type='radio'] {
  border-radius: 50%;
}

/* The reader's own choice: a drawn pen-blue tick. */
.tickbox input:checked {
  background: var(--av-paper)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 13.5C6.2 15.6 8.2 18.2 9.8 20.6 12.4 13.4 16.2 7.2 21 3' fill='none' stroke='%231f3fbf' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 88% no-repeat;
}

/* A choice the page made before anyone touched it is filled in ink, not ticked in pen. */
fieldset:not([data-touched]) .tickbox input.preset:checked {
  padding: 0.3rem;
  background: var(--av-ink) content-box;
}

@media (pointer: coarse) {
  :root {
    --tick: 1.75rem;
  }
}

/* ---- Sign-in page ------------------------------------------------------------ */

.foot {
  padding-block: var(--av-space-5) var(--av-space-8);
}

.foot .fine {
  max-width: 74ch;
}

@media (max-width: 39.99rem) {
  .bar {
    column-gap: var(--av-space-3);
    min-height: 0;
  }
  .wordmark {
    font-size: 1.25rem;
    border-right: 0;
    padding-right: 0;
  }
  .intro {
    padding-block: var(--av-space-5) var(--av-space-4);
  }
  .pad .button {
    flex: 1 1 100%;
    margin-top: 0;
  }
}

@media (forced-colors: active) {
  select.blank,
  .tickbox input {
    appearance: auto;
    background-image: none;
  }
  .error::before {
    display: none;
  }
  .flag {
    clip-path: none;
    border: var(--av-line-control) solid CanvasText;
    padding-right: var(--av-space-3);
  }
  .flag::before {
    display: none;
  }
}

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