/* Fit Test Timer. Built on the Amodo App design system (tokens.css, components.css).
   The large activity name and countdown are this app's own: the system has no
   answer for text read from across a room, so they scale with the window height. */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--weight-body) var(--text-body)/var(--leading-body) var(--font-body);
}
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 24px;
  flex-wrap: wrap;
}
.bar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bar-controls .inline { color: var(--color-muted); margin-left: 8px; }
#protocol { width: 300px; }
#setSize { width: 64px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; color: var(--color-muted); cursor: pointer; }
.check input { accent-color: var(--color-primary); }

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(380px, 1fr);
  gap: 16px;
  padding: 0 24px 24px;
}
.card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  padding: 16px 24px;
}

/* ---------- Stage: the running test ---------- */
.stage { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.stage-top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.now { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.activity {
  font: var(--weight-display) clamp(32px, 8vh, 72px)/1.15 var(--font-display);
  letter-spacing: var(--tracking-display);
}
.countdown {
  font: var(--weight-body) clamp(88px, 24vh, 260px)/1 var(--font-data);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
.stage.is-ending .countdown { color: var(--color-link); }
.stage.is-idle .countdown, .stage.is-done .countdown { color: var(--color-faint); }

.segments { display: flex; gap: 4px; height: 12px; }
.seg { background: var(--color-surface-sunken); border: 1px solid var(--color-border-soft); border-radius: var(--radius-pill); overflow: hidden; min-width: 8px; }
.seg i { display: block; height: 100%; width: 0; background: var(--color-ramp-3); }

.next-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.next, .total { display: flex; flex-direction: column; }
.total { align-items: flex-end; }
/* Same size as the current activity, so both read from across the room; the muted
   colour and the larger Now / Next labels tell them apart. */
.next-name { font: var(--weight-display) clamp(32px, 8vh, 72px)/1.15 var(--font-display); letter-spacing: var(--tracking-display); color: var(--color-muted); }
.next-name small { font: var(--weight-body) clamp(16px, 3.5vh, 28px) var(--font-data); color: var(--color-faint); margin-left: 16px; letter-spacing: 0; }
#nowEyebrow, #nextEyebrow { font-size: clamp(14px, 2.6vh, 22px); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.steps li {
  display: inline-flex; align-items: baseline; gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  font-size: var(--text-small);
}
.steps li span { font-family: var(--font-data); }
.steps li.done { color: var(--color-faint); text-decoration: line-through; }
.steps li.current { background: var(--color-selected); border-color: var(--color-current); color: var(--color-text); }

.actions { display: flex; align-items: center; gap: 8px; }
.btn.big { height: 44px; padding: 0 28px; font-size: var(--text-heading); }
#newSet { margin-left: auto; }

/* ---------- Side column ---------- */
.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.sw-head, .hist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sw-body { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sw-time { font: var(--weight-body) 40px/1.2 var(--font-data); font-variant-numeric: tabular-nums; }
.sw-buttons { display: flex; gap: 4px; }

.history { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-right: 12px; }
.hist-head { padding-right: 12px; }
.hist-buttons { display: flex; gap: 4px; }
.hist-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-right: 12px; }
table { width: 100%; border-collapse: collapse; }
th {
  position: sticky; top: 0;
  background: var(--color-surface-raised);
  text-align: left; font-weight: var(--weight-body); font-size: var(--text-small); color: var(--color-muted);
  padding: 6px 8px 6px 0; border-bottom: 1px solid var(--color-border);
}
td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--color-border-soft); vertical-align: middle; }
td.data { white-space: nowrap; }
td .date { color: var(--color-faint); font-size: var(--text-small); display: block; }
td.proto { font-size: var(--text-small); color: var(--color-muted); }
.ok { color: var(--color-success); }
.stopped { color: var(--color-danger); }
.running { color: var(--color-muted); }
td .note {
  width: 100%; min-width: 80px; border: 1px solid transparent; border-radius: var(--radius-control);
  background: transparent; color: var(--color-text); font: inherit; padding: 2px 6px;
}
td .note:hover { border-color: var(--color-border-soft); }
td .note:focus { outline: none; border-color: var(--color-focus); background: var(--color-surface-raised); }
td .note::placeholder { color: var(--color-faint); }
.empty { padding: 16px 0; }

/* ---------- Protocol editor ---------- */
dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  background: var(--color-surface-raised);
  color: var(--color-text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor code { font-family: var(--font-data); font-size: var(--text-data); }
.editor textarea { line-height: 1.6; max-height: 55vh; }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* Laptop and up: everything on one screen, only the history scrolls. */
@media (min-width: 1000px) {
  body { height: 100vh; overflow: hidden; }
}
/* Narrower: stack and let the page scroll. */
@media (max-width: 999px) {
  main { grid-template-columns: minmax(0, 1fr); padding: 0 16px 16px; }
  .bar { padding: 12px 16px; }
  .stage { min-height: 70vh; }
  .hist-scroll { max-height: 60vh; }
  #protocol { width: 100%; }
}
