/* Staff Flashcards -- typography and palette mirror watermark.org.
 *
 * Values below were read off the live team page's computed styles rather
 * than eyeballed:
 *   person card name  -> Oswald 24px/28px, 400, uppercase, 0.5px tracking
 *   person card role  -> Lato 17px/20.4px, 400
 *   section heading   -> Oswald 22px, uppercase, 0.5px tracking
 *   page headline     -> DM Serif Display 64px/72px
 *   primary button    -> Lato 600 13px, uppercase, 1px tracking, square
 *   ink #28312F, muted #48565A, orange #DE7130, teal link #3998B3
 * The site is flat and square-cornered: no radius, no shadows on cards.
 */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --sunken: #f4f4f2;
  --ink: #28312f;
  --ink-soft: #48565a;
  --line: #dfe1e0;
  --accent: #de7130;          /* brand orange, primary buttons */
  --accent-ink: #ffffff;
  --link: #3998b3;            /* brand teal */
  --good: #2f7a55;
  --good-ink: #ffffff;        /* text on a --good fill */
  --good-soft: #eaf3ee;
  --bad: #b5432f;
  --bad-soft: #fbeeea;

  --display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --head: "Oswald", "Haettenschweiler", "Arial Narrow Bold", sans-serif;
  --body: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1e1d;
    --surface: #232928;
    --sunken: #1f2423;
    --ink: #f0efec;
    --ink-soft: #a7b2b3;
    --line: #333b3a;
    --accent: #e8834a;
    --accent-ink: #1a1e1d;
    --link: #6ec0d6;
    --good: #6fc79a;
    --good-ink: #12211a;
    --good-soft: #1e3a2d;
    --bad: #e8907c;
    --bad-soft: #3a2320;
  }
}

* { box-sizing: border-box; }

/* Author-level display rules below (flex/grid) would otherwise beat the
 * browser's [hidden] { display: none }, leaving hidden panels on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Shared heading treatment, straight off the site's card titles. */
.eyebrow, .hint-label, .missed-head, .field > label {
  font-family: var(--head);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-family: var(--head);
  font-size: 19px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .5px;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.lede {
  margin: 0 0 30px;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* ------------------------------- forms ------------------------------- */

.field { margin-bottom: 26px; }

.field > label {
  display: block;
  margin-bottom: 9px;
  font-size: 15px;
  color: var(--ink-soft);
}

.field-note {
  margin: 9px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

select {
  width: 100%;
  padding: 13px 14px;
  font-family: var(--body);
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  appearance: none;
}

.segmented { display: flex; gap: 6px; }

.segmented button {
  flex: 1;
  padding: 12px 0;
  font-family: var(--head);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}

.segmented button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.modes { display: grid; gap: 8px; }

.modes button {
  display: block;
  width: 100%;
  padding: 15px 16px;
  text-align: left;
  font-family: var(--body);
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}

.modes button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.modes strong {
  display: block;
  font-family: var(--head);
  font-size: 18px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.modes span { display: block; margin-top: 3px; font-size: 15px; color: var(--ink-soft); }

/* ------------------------------ buttons ------------------------------ */
/* Square, uppercase, letterspaced -- the site's .btn-primary. */

button.primary, button.secondary {
  padding: 16px 20px;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
}

button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.big { width: 100%; padding: 20px; font-size: 14px; }
button.good { background: var(--good); border-color: var(--good); color: var(--good-ink); }
button.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .4; cursor: default; }

.link-btn {
  padding: 4px;
  font-family: var(--body);
  font-size: 14px;
  color: var(--link);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

.actions { display: flex; gap: 10px; margin-top: 20px; }
.actions button { flex: 1; }
.actions.stack { flex-direction: column; }

/* ------------------------------ progress ----------------------------- */

.meter { margin-bottom: 20px; }

.meter-bar { height: 3px; background: var(--line); overflow: hidden; }

.meter-bar > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .25s ease;
}

.meter-text {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-family: var(--head);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-soft);
}

/* ------------------------------- photo ------------------------------- */
/* Square, like the person cards on the site. */

.photo-wrap { position: relative; }

#photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 0;
  background: var(--sunken);
}

.chip-review {
  position: absolute;
  top: 0;
  left: 0;
  padding: 6px 12px;
  font-family: var(--head);
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
}

/* ------------------------------- hints ------------------------------- */

.hints { margin-top: 20px; }
.hints:empty { display: none; }

.hint {
  margin-bottom: 8px;
  padding: 13px 15px;
  background: var(--sunken);
  border-left: 3px solid var(--accent);
}

.hint-label {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  color: var(--ink-soft);
}

.hint-value { font-size: 17px; line-height: 1.25; }

.shape {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 21px;
  letter-spacing: .2em;
}

/* ------------------------------ answer ------------------------------- */

.answer {
  margin-top: 20px;
  padding: 22px 16px;
  text-align: center;
  background: var(--sunken);
  border-top: 3px solid var(--accent);
}

/* The site sets staff names in Oswald, uppercase. */
.answer h2 {
  margin: 0 0 6px;
  font-family: var(--head);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink);
}

.answer p { margin: 0; font-size: 17px; line-height: 1.2; color: var(--ink-soft); }
.answer p + p { margin-top: 5px; font-size: 14px; }

/* ------------------------------ choices ------------------------------ */

.choices { display: grid; gap: 8px; margin-top: 20px; }

.choices button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  font-family: var(--head);
  font-size: 18px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}

.choices .num {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-family: var(--body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink-soft);
  background: var(--sunken);
}

.choices button.correct {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good);
}

.choices button.correct .num { background: var(--good); color: var(--good-ink); }

.choices button.wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
}

.choices button.wrong .num { background: var(--bad); color: #fff; }
.choices button:disabled { cursor: default; opacity: 1; }
.choices button:disabled:not(.correct):not(.wrong) { opacity: .45; }

/* ------------------------------ summary ------------------------------ */

.score { text-align: center; padding: 26px 0 10px; }

/* DM Serif Display is the site's headline face. */
#score-num {
  font-family: var(--display);
  font-size: 64px;
  line-height: 1.05;
  font-weight: 400;
  color: var(--ink);
}

#score-line { margin: 8px 0 0; font-size: 17px; color: var(--ink-soft); }

.missed-head {
  margin: 34px 0 14px;
  font-size: 16px;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.grid figure { margin: 0; }

.grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--sunken);
}

.grid figcaption { padding: 9px 0 0; }

.grid .n {
  font-family: var(--head);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.grid .t { margin-top: 3px; font-size: 14px; line-height: 1.25; color: var(--ink-soft); }

/* ------------------------------- misc -------------------------------- */

.keys {
  margin: 24px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
}

.keys kbd {
  padding: 1px 5px;
  font-family: var(--body);
  font-size: 12px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--surface);
}

.fineprint {
  margin: 22px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}

@media (hover: hover) {
  button.primary:hover, button.secondary:hover,
  .choices button:not(:disabled):hover,
  .modes button:hover, .segmented button:hover { filter: brightness(.96); }
}

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

/* Keep the whole card reachable without scrolling on short screens. */
@media (max-height: 780px) and (min-width: 480px) {
  #photo { max-width: 320px; margin: 0 auto; }
}

/* ------------------------------ phones ------------------------------- */
/* A full-width square photo plus a growing stack of hints pushed the
 * grading buttons off the bottom of the screen -- on a small phone, after
 * the very first hint. Two changes fix it: size the photo to the viewport
 * rather than the width, and let the action row stick to the bottom so it
 * is reachable no matter how many hints are open. */

@media (max-width: 560px) {
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 17px; }

  main { padding: 14px 16px 20px; }

  .meter { margin-bottom: 12px; }
  .meter-text { margin-top: 6px; font-size: 13px; }

  /* Square, but sized off the viewport height so hints have room.
   * dvh tracks the collapsing mobile browser chrome; vh is the fallback. */
  .photo-wrap { width: fit-content; max-width: 100%; margin-inline: auto; }

  #photo {
    height: min(40vh, calc(100vw - 32px));
    height: min(40dvh, calc(100vw - 32px));
    width: auto;
    max-width: 100%;
  }

  .hints { margin-top: 12px; }
  .hint { margin-bottom: 6px; padding: 9px 12px; }
  .hint-label { font-size: 12px; margin-bottom: 1px; }
  .hint-value { font-size: 16px; }
  .shape { font-size: 19px; gap: 12px; margin-top: 2px; }

  .answer { margin-top: 12px; padding: 14px 12px; }
  .answer h2 { font-size: 26px; }
  .answer p { font-size: 15px; }
  .answer p + p { font-size: 13px; }

  .choices { gap: 6px; margin-top: 12px; }
  .choices button { padding: 12px 14px; font-size: 17px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }

  /* The controls ride the bottom of the viewport while the card is taller
   * than the screen, and settle into place once you reach the end. */
  .actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 14px;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    box-shadow: 0 -10px 18px -10px rgba(0, 0, 0, .22);
  }

  .actions.stack { position: static; box-shadow: none; padding-bottom: 0; }

  button.primary, button.secondary { padding: 15px 14px; }
  button.big { padding: 17px; }

  /* Phones have no physical keyboard; the shortcut legend is dead weight. */
  .keys { display: none; }
}

/* Short but not narrow: a phone held sideways, or a short laptop window.
 * Same problem as above, reached by height rather than width, so it needs
 * its own query. Scoped above the phone breakpoint so the two never fight
 * over the photo size. */
@media (max-height: 620px) and (min-width: 561px) {
  .photo-wrap { width: fit-content; max-width: 100%; margin-inline: auto; }

  #photo {
    height: min(52vh, 300px);
    height: min(52dvh, 300px);
    width: auto;
    max-width: 100%;
  }

  .actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    box-shadow: 0 -10px 18px -10px rgba(0, 0, 0, .22);
  }

  .actions.stack { position: static; box-shadow: none; padding-bottom: 0; }

  .keys { display: none; }
}
