/*
 * Direction: Timetable
 *
 * One idea: every fact on the board is a timed entry, and the time always sits in the same
 * narrow left column, in tabular figures, with one small word under it saying what the time
 * is (since, asked, bumped, next, until). The board reads like a railway timetable: run the
 * eye down the left column and the day is there. Clock times replace most "12 min ago"
 * phrases, so a stale status is obvious from its time alone, and the page's own clock sits at
 * the top as the reference. Type, colour and controls stay as they are today.
 *
 * Type: Atkinson Hyperlegible Next (OFL, OFL.txt).
 */

@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;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --sign: clamp(2rem, 1.1rem + 3.9vw, 3.25rem);

  --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;
  --when: 4.25rem;

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

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

.page {
  max-width: 68rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--tap) + 2 * var(--space-3) + var(--space-6));
}

/* --- Top line: the board's own clock ----------------------------------------------------- */

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--ink);
}

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

.clock {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.clock time {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.2;
}

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

/* Offline is the one time this line matters: it stops being quiet. */
.clock.is-offline span {
  color: var(--ink);
  font-weight: 700;
}

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

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

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

.who-block {
  min-width: 0;
}

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

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

.who-row form {
  flex: none;
}

.bump-reasons {
  margin: 0 0 var(--space-3);
}

.bump-reasons summary {
  display: block;
  width: fit-content;
  margin-left: auto;
  padding: 0.55rem var(--space-3);
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--step--1);
  line-height: 1.2;
  list-style: none;
  cursor: pointer;
}

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

.bump-reasons summary:hover,
.bump-reasons[open] summary {
  border-color: var(--ink);
}

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

.reasons {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* --- The timed entries: time on the left, always in the same column ----------------------- */

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

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

.when {
  display: grid;
  padding-top: 0.2em;
  line-height: 1.2;
}

.when time {
  font-size: var(--step-1);
  font-weight: 700;
}

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

.what {
  min-width: 0;
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  border-left: 1px solid var(--rule);
}

.status {
  font-size: var(--sign);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
}

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

.is-stale .status,
.is-stale .when time {
  color: var(--muted);
}

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

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

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

.row > form {
  flex: none;
}

/* A coloured entry fills the whole row, time column included. */
.is-need,
.is-bump,
.is-quiet {
  padding: var(--space-3) var(--space-3) var(--space-3) 0;
}

.is-need .when,
.is-bump .when,
.is-quiet .when {
  padding-left: var(--space-3);
}

.is-need .what,
.is-bump .what,
.is-quiet .what {
  border-left-color: currentColor;
}

.is-need {
  background: var(--need);
  color: var(--need-ink);
}

.is-need .when span,
.is-need .meta {
  color: inherit;
}

.need-text {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

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

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

/* The latest bump, in reverse ink for its first ten minutes. */
.is-bump {
  background: var(--ink);
  color: var(--paper);
}

.is-bump .when span,
.is-bump .meta {
  color: inherit;
}

.bump-reason {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.2;
}

/* Busy, don't interrupt: the red row, with the time it ends. */
.is-quiet {
  background: var(--quiet);
  color: var(--quiet-ink);
}

.is-quiet .when span,
.is-quiet .meta {
  color: inherit;
}

.is-quiet .meta {
  font-weight: 700;
}

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

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

/* A time that has not come yet is blue, as it is today. */
.is-next .when time {
  color: var(--soon);
}

.next-text {
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

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

/* --- Earlier: the same column -------------------------------------------------------------- */

.earlier {
  padding: var(--space-2) 0 0;
  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: var(--when) 1fr;
  gap: var(--space-3);
}

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

.earlier li span {
  color: var(--ink);
  padding-left: var(--space-3);
  border-left: 1px solid var(--rule);
  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 {
  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);
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: flex;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  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);
  font-variant-numeric: tabular-nums;
  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-4);
  border: 2px solid var(--line);
  border-radius: 999px;
  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,
.bar-link {
  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: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.2;
  text-decoration: none;
  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,
.bar-link.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);
}

/* --- Update bar (phones) ------------------------------------------------------------------- */

.update-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--rule);
}

.bar-link {
  width: 100%;
}

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

/* --- Wider screens: side by side, the time columns in line ------------------------------- */

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

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

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

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

  .update-bar {
    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;
  }
}
