/* Watchword: The Brady Office visual system. */

/* Licensed faces (Monotype); Colin supplies the files in public/fonts/. */
@font-face { font-family: "Quarto"; src: url("/fonts/quarto-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Quarto"; src: url("/fonts/quarto-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Benton Sans"; src: url("/fonts/benton-sans-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Benton Sans"; src: url("/fonts/benton-sans-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Benton Sans"; src: url("/fonts/benton-sans-semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

/* Fallbacks (SIL OFL), self-hosted so pages make no third-party requests. */
@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("/fonts/libre-franklin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("/fonts/libre-franklin-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("/fonts/libre-franklin-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --ink: #1a1917;
  --secondary: #4a4843;
  --panel: #eeede9;
  --privacy: #e6e3ec;
  --claret: #74393b;
  --page: #ffffff;
  --hairline: rgba(26, 25, 23, 0.12);
  --hairline-strong: rgba(26, 25, 23, 0.14);
  --field: rgba(26, 25, 23, 0.35);
  --field-quiet: rgba(26, 25, 23, 0.2);

  --serif: "Quarto", "Newsreader", Georgia, serif;
  --sans: "Benton Sans", "Libre Franklin", system-ui, sans-serif;

  --radius: 4px;
  --gutter: 24px;
}

/* The code screen: white on ink. Every color below follows the tokens. */
html.dark {
  --ink: #ffffff;
  --secondary: #a8a59d;
  --panel: #2a2926;
  --page: #1a1917;
  --hairline: rgba(255, 255, 255, 0.14);
  --hairline-strong: rgba(255, 255, 255, 0.18);
  color-scheme: dark;
}

/* The screens after the code (expired, verified): a softer ink on white. */
html.soft {
  --ink: #232323;
  --secondary: #606060;
  --hairline: rgba(0, 0, 0, 0.14);
}

/* Pages fade into each other, 500ms in all. */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 500ms; }

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--page);
}

/* No rubber-banding on a page that fits the screen (app.js sets .fits). */
html.fits,
html.fits body { overscroll-behavior: none; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/26px var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--secondary); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- Screen frame ---------- */

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  max-width: 440px;
  margin: 0 auto;
  padding:
    max(64px, calc(env(safe-area-inset-top) + 32px))
    max(var(--gutter), env(safe-area-inset-right))
    max(36px, calc(env(safe-area-inset-bottom) + 20px))
    max(var(--gutter), env(safe-area-inset-left));
}

.screen__main { padding-bottom: 40px; }

/* PIN screens: everything sits high, so it stays in view above the keypad. */
.screen--compact {
  padding-top: max(24px, calc(env(safe-area-inset-top) + 16px));
}

/* On a large screen the column sits near the top instead of filling the window. */
@media (min-width: 700px) and (min-height: 700px) {
  .screen { min-height: 0; padding-top: 112px; }
}

.eyebrow,
.label {
  margin: 0;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--secondary);
}

.display {
  margin: 32px 0 12px;
  font: 400 36px/41px var(--serif);
  letter-spacing: -0.005em;
}

.lead {
  margin: 0;
  font-size: 18px;
  line-height: 29px;
}

.sub {
  margin: 0;
  color: var(--secondary);
}

.holder {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.holder__badge { display: block; width: 29px; height: 30px; flex: none; }
.holder__name {
  margin: 0;
  font: 600 13px/18px var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.screen--compact .alert { margin-top: 16px; }
.screen--compact .field { margin-top: 22px; }
.screen--compact .field + .field { margin-top: 18px; }
.screen--compact .pin__input,
.screen--compact .pin__box { height: 64px; }

.foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  line-height: 20px;
  color: var(--secondary);
}
.foot p { margin: 0; }

.alert {
  margin: 24px 0 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 15px;
  line-height: 22px;
}

.textlink {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* ---------- Buttons and fields ---------- */

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 32px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font: 600 16px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.button:hover { background: #33312d; color: var(--page); }
.button:active { background: #000000; }

.field { margin-top: 40px; }
.field + .field { margin-top: 28px; }
.field .label { display: block; }

.text-input {
  display: block;
  width: 100%;
  height: 56px;
  margin-top: 10px;
  padding: 0 16px;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
  font: 400 20px/1 var(--sans);
  appearance: none;
}
.text-input:focus { outline: none; border: 1.5px solid var(--ink); padding: 0 15.5px; }

.form .button { margin-top: 16px; }

/* R1: one box per word. */
.words { min-width: 0; padding: 0; border: 0; }
.words legend { padding: 0; }
.words__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.text-input[aria-invalid="true"] { border-color: var(--claret); }

/* Suggestions under the boxes (app.js): up to three words, in the code's serif. */
.suggest { display: none; min-height: 44px; margin-top: 12px; }
.words.is-choosing .suggest { display: block; }
.suggest__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.suggest__list[hidden] { display: none; }
.suggest__option {
  height: 44px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--panel);
  font: 400 20px/42px var(--serif);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.suggest__option[aria-selected="true"] { border: 1.5px solid var(--ink); line-height: 41px; }
.suggest__option:active { background: #e3e2dd; }
@media (hover: hover) {
  .suggest__option:hover { border-color: var(--hairline-strong); }
  .suggest__option[aria-selected="true"]:hover { border-color: var(--ink); }
}

/* PIN: one real input. With script, it sits invisibly over four drawn boxes. */
.pin { position: relative; margin-top: 12px; }

.pin__input {
  display: block;
  width: 100%;
  height: 72px;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
  font: 400 28px/1 var(--sans);
  letter-spacing: 0.6em;
  text-align: center;
  -webkit-text-security: disc;
  appearance: none;
}

.pin__boxes { display: none; }

.js .pin__input {
  position: absolute;
  inset: 0;
  z-index: 1;
  height: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px; /* 16px or more keeps iOS from zooming */
  opacity: 0;
}

.js .pin__boxes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.pin__box {
  position: relative;
  height: 72px;
  border: 1px solid var(--field-quiet);
  border-radius: var(--radius);
}
.pin__box.is-filled { border-color: var(--field); }
.pin__box.is-filled::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--ink);
}
.pin.is-focused .pin__box.is-active { border: 1.5px solid var(--ink); }

/* ---------- Holder: the code ---------- */

.code {
  margin: 36px 0 28px;
  font: 400 72px/1.02 var(--serif);
  letter-spacing: -0.01em;
  text-align: center;
  overflow-wrap: anywhere;
}
.code__word { display: block; }

.timer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 32px;
}
.timer__bar {
  display: none;
  height: 5px;
  border-radius: 2px;
  background: var(--hairline);
  overflow: hidden;
}
.js .timer__bar { display: block; }
.timer__fill {
  width: 100%;
  height: 5px;
  background: var(--ink);
  transform-origin: left center;
}
.timer__text {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 32px 0 0;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--panel);
}
.facts div { display: flex; flex-direction: column; gap: 6px; }
.facts dt {
  font-size: 10px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--secondary);
}
.facts dd { margin: 0; }

/* ---------- Receiver: the result ---------- */

.result {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 28px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--panel);
}
.result--verified { background: var(--privacy); }
.result--verified .result__title { font-size: 32px; line-height: 1.1; }
.result--failed { background: var(--claret); color: #ffffff; }
.result--alone { margin-top: 32px; }
.after-result { margin: 12px 0 0; }
.result__title {
  margin: 0;
  font: 400 36px/1 var(--serif);
}
.result__title:focus { outline: none; }
.result__text {
  margin: 0;
  font-size: 16px;
  line-height: 26px;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  font-size: 15px;
  line-height: 22px;
}
.rows div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
}
.rows div:last-child { padding-bottom: 0; border-bottom: 0; }
.rows dt { color: var(--secondary); }
.rows dd { margin: 0; text-align: right; }

/* ---------- Preview index ---------- */

.index { margin: 40px 0 0; }
.index h2 { margin: 0 0 4px; }
.index h2:not(:first-child) { margin-top: 36px; }
.index ul { margin: 0; padding: 0; list-style: none; }
.index li { border-bottom: 1px solid var(--hairline); }
.index a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 64px;
  padding: 10px 0;
  text-decoration: none;
}
.index a:hover .index__name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.index__name { font: 400 22px/28px var(--serif); }
.index__when { font-size: 14px; line-height: 20px; color: var(--secondary); }

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