/*
 * Direction: Sign
 *
 * One idea: a status is set like real signage, at poster scale and in a condensed sign face,
 * so it reads from across the room, and the three things that are signs (what someone is
 * doing, what they need, why they bumped you) are the only things set in that face. Red and
 * yellow signs bleed edge to edge on a phone, like a hanger on a door. Everything is square,
 * because signs are.
 *
 * Type: Barlow Condensed (OFL, OFL-barlow.txt) for signs only, a face drawn from Californian
 * road and plate lettering; Atkinson Hyperlegible Next (OFL, OFL.txt) for every other word.
 */

@font-face {
  font-family: 'Barlow Condensed';
  src: url('barlow-condensed-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Barlow Condensed';
  src: url('barlow-condensed-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Atkinson Next';
  src: url('atkinson-next-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Atkinson Next';
  src: url('atkinson-next-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f5f6f8;
  --surface: #ffffff;
  --ink: #15181c;
  --muted: #535a63;
  --rule: #cfd4db;
  --line: #8a929c;
  --soon: #1c4ea6;
  --need: #ffd21f;
  --need-ink: #15181c;
  --quiet: #b1221a;
  --quiet-ink: #ffffff;
  --focus: #1c4ea6;

  --sign-face: 'Barlow Condensed', 'Arial Narrow', sans-serif-condensed, sans-serif;
  --sign: clamp(3.25rem, 16vw, 7rem);
  --sign-small: clamp(1.875rem, 8.5vw, 3rem);

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.25rem;
  --space-7: 3.5rem;

  --tap: 2.75rem;
  --key: 3.5rem;
  --bleed: 1rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15181c;
    --surface: #1e2227;
    --ink: #eef0f3;
    --muted: #a7afb9;
    --rule: #363c44;
    --line: #6c747e;
    --soon: #93b6ff;
    --focus: #93b6ff;
  }
}

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

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

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

input {
  caret-color: var(--soon);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Atkinson Next', system-ui, sans-serif;
  font-size: var(--step-0);
  line-height: 1.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.page {
  max-width: 68rem;
  margin: 0 auto;
  /* Room at the bottom for the pinned keys. */
  padding: var(--space-3) var(--bleed) calc(var(--key) + var(--space-7));
}

/* --- Top line: small, because the signs are the page ----------------------------------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
}

.top h1 {
  font-size: var(--step-0);
  line-height: 1.5;
}

.sync {
  color: var(--muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

/* --- A bump is addressed to you, so it sits above both people, not inside Alex ---------- */

.bumped {
  margin: var(--space-3) calc(-1 * var(--bleed)) 0;
  padding: var(--space-3) var(--bleed) var(--space-4);
  background: var(--ink);
  color: var(--paper);
}

.bumped .reason {
  display: block;
  font-family: var(--sign-face);
  font-weight: 600;
  font-size: var(--sign-small);
  line-height: 1;
}

.bumped span {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--step--1);
}

/* --- The two people --------------------------------------------------------------------- */

.person {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--rule);
}

.who-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.who {
  font-size: var(--step-1);
  line-height: 1.3;
}

.looked {
  color: var(--muted);
  font-size: var(--step--1);
}

/* On a phone the Bump key lives in the strip at the bottom, under the thumb. */
.bump-desk {
  display: none;
  margin-left: auto;
}

.sign {
  margin-top: var(--space-2);
  font-family: var(--sign-face);
  font-weight: 700;
  font-size: var(--sign);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.sign.is-empty {
  font-family: inherit;
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1.2;
  color: var(--muted);
}

.sign.is-stale {
  color: var(--muted);
}

.meta {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--step--1);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.row > p {
  margin-top: 0;
  min-width: 0;
}

.row > form {
  flex: none;
}

/* A need: the yellow sign, edge to edge. */
.need {
  margin: var(--space-4) calc(-1 * var(--bleed)) 0;
  padding: var(--space-3) var(--bleed) var(--space-4);
  background: var(--need);
  color: var(--need-ink);
}

.need-text {
  font-family: var(--sign-face);
  font-weight: 600;
  font-size: var(--sign-small);
  line-height: 1;
  overflow-wrap: anywhere;
}

.need .row {
  margin-top: var(--space-3);
}

.need-meta {
  font-size: var(--step--1);
}

.need button.small {
  border-color: var(--need-ink);
  color: var(--need-ink);
  background: transparent;
}

.need button.small.solid {
  background: var(--need-ink);
  color: var(--need);
}

.need :focus-visible {
  outline-color: var(--need-ink);
}

/* Busy, don't interrupt: the red hanger, edge to edge. */
.quiet-sign {
  margin: var(--space-2) calc(-1 * var(--bleed)) 0;
  padding: var(--space-4) var(--bleed) var(--space-5);
  background: var(--quiet);
  color: var(--quiet-ink);
}

.quiet-sign .sign {
  margin-top: 0;
}

.quiet-sign .meta {
  color: inherit;
  font-weight: 700;
  font-size: var(--step-0);
}

.quiet-sign .row {
  margin-top: var(--space-3);
}

.quiet-sign button.small {
  background: transparent;
  border-color: var(--quiet-ink);
  color: var(--quiet-ink);
}

.quiet-sign :focus-visible {
  outline-color: var(--quiet-ink);
}

.next-line {
  margin-top: var(--space-4);
  font-size: var(--step-1);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.next-when {
  color: var(--soon);
  font-weight: 700;
}

.next-text {
  font-weight: 700;
}

.sent {
  margin-top: var(--space-3);
}

/* --- Earlier -------------------------------------------------------------------------------- */

.earlier {
  padding-top: var(--space-2);
  color: var(--muted);
}

.earlier summary {
  display: block;
  padding: 0.7rem 0;
  list-style: none;
  cursor: pointer;
}

.earlier summary::-webkit-details-marker {
  display: none;
}

.summary-label {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.earlier ol {
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.earlier li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: var(--space-3);
}

.earlier b {
  margin-right: var(--space-1);
}

.earlier time {
  font-variant-numeric: tabular-nums;
}

.earlier span {
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* --- Posting -------------------------------------------------------------------------------- */

.compose {
  padding-top: var(--space-6);
}

.compose h2 {
  font-size: var(--step-2);
  line-height: 1.2;
}

.compose h3 {
  font-size: var(--step-1);
  line-height: 1.3;
}

.compose-form {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.need-form,
.bump-form {
  margin-top: var(--space-6);
}

.field-label,
legend {
  font-weight: 700;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
  margin-bottom: var(--space-2);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.presets.lengths {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.presets.lengths button {
  padding: 0 var(--space-2);
}

/* One choice of five, drawn as one bar. */
.segmented {
  display: flex;
  border: 2px solid var(--ink);
  background: var(--surface);
}

.segmented label {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--space-1);
  font-size: var(--step--1);
  white-space: nowrap;
  cursor: pointer;
}

.segmented label:not(:first-of-type) {
  border-left: 1px solid var(--rule);
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segmented input:checked + label {
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

.segmented input:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: -5px;
}

.field-row {
  display: flex;
  gap: var(--space-2);
}

input[type='text'] {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: max(1rem, 16px);
}

input[type='text']::placeholder {
  color: var(--muted);
  opacity: 1;
}

input[type='text']:focus-visible {
  border-color: var(--ink);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 120ms ease-out,
    border-color 120ms ease-out;
}

button:hover {
  border-color: var(--ink);
}

button.preset {
  border-color: var(--surface);
}

button.preset:hover {
  border-color: var(--ink);
}

button.need-preset {
  background: var(--need);
  border-color: var(--need);
  color: var(--need-ink);
}

button.need-preset:hover {
  border-color: var(--need-ink);
}

button.solid {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

button.small {
  font-size: var(--step--1);
  padding: 0 var(--space-3);
}

button.plain {
  border: 0;
  padding: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

/* --- This device ---------------------------------------------------------------------------- */

.device {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
  color: var(--muted);
}

.device summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.device p {
  max-width: 40rem;
}

.device form + form {
  margin-top: var(--space-4);
}

.device button.plain {
  min-height: var(--tap);
  color: var(--ink);
}

/* --- The keys: one ink strip, two keys, under the thumb -------------------------------------- */

.keys {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}

.keys form {
  display: contents;
}

.key {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--key);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.keys > a.key {
  border-left: 1px solid var(--paper);
}

.key:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.key:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: -6px;
}

/* --- Wider screens: side by side; the Bump key goes back beside the name ----------------- */

@media (min-width: 52rem) {
  .page {
    padding: var(--space-5) var(--space-6) var(--space-7);
  }

  .bumped,
  .need,
  .quiet-sign {
    margin-left: 0;
    margin-right: 0;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-7);
  }

  /* Half the width each, so the sign is sized to its column, not the window. */
  .person {
    --sign: clamp(3.5rem, 7vw, 5.5rem);
    --sign-small: clamp(1.875rem, 3vw, 2.5rem);
    padding-top: var(--space-6);
  }

  .earlier {
    grid-column: 1 / -1;
  }

  .bump-desk {
    display: block;
  }

  .keys {
    display: none;
  }

  .compose-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-7);
    align-items: start;
  }

  .need-form {
    margin-top: var(--space-4);
  }
}

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