/* Reveo Diktofon — the four surfaces: the list, one recording, devices, login.
 *
 * app.css holds the shell and the shared primitives and must load first; every
 * colour, face and radius here comes from reveo-tokens.css through it. Split
 * off because one stylesheet for the whole product had grown past the point
 * where you can find a rule by scrolling. */

.filters {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 170px 140px 140px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.filters .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.filters label {
  font-size: var(--t-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-3);
}
.filters .actions {
  align-self: end;
  padding-bottom: 1px;
}

/* ── The list ────────────────────────────────────────────────────────────── */

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  /* `clip`, NOT `hidden`. `overflow: hidden` makes this element a scroll
   * container, and a sticky descendant then resolves its offset against THIS
   * box instead of the viewport — the column header rendered 56px down, on top
   * of the first row, with the page not scrolled at all. `clip` still rounds
   * the corners and is not a scrollport. */
  overflow: clip;
}

.list-head,
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px 76px 150px 168px;
  gap: 12px;
  padding: 10px 14px;
  align-items: start;
}

.list-head {
  font-size: var(--t-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
}

.row {
  position: relative;
  border-bottom: 1px solid var(--line);
  color: inherit;
  /* The border-left is the hover affordance, so the hit target and the
   * highlight are the same rectangle. */
  border-left: 3px solid transparent;
  padding-left: 11px;
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease);
}
.row:last-child {
  border-bottom: none;
}
.row:hover {
  background: var(--surface-hover);
  border-left-color: var(--brand);
}

/* The whole row opens the recording, but the row is NOT an <a>: it now holds a
 * «Hozir yuklash» button, and interactive content nested inside a link is
 * invalid markup that leaves a screen reader announcing one control containing
 * another. So the filename is the real link and an ::after overlay gives it the
 * row's rectangle; the button sits above the overlay on its own layer. */
.row-link {
  /* `block`, because the filename is now an <a> and `text-overflow: ellipsis`
   * does nothing on an inline box — a long name overflowed its column instead
   * of being trimmed. */
  display: block;
  color: inherit;
  font-weight: inherit;
}
.row-link:hover {
  text-decoration: none;
}
/* **Whatever contains a `.row-link` MUST be `position: relative`.** This
 * overlay is absolute, so with no positioned ancestor it does not shrink to
 * nothing — it grows to the initial containing block and covers the whole
 * viewport, swallowing every click on the rail and the topbar and sending them
 * to this recording. It is invisible, it throws nothing, and it looks correct
 * in a screenshot. `.row` below carries the `position: relative` that makes it
 * safe here; the dashboard's `.db-rec` in app.css shipped without one, and the
 * landing page's navigation was entirely dead until it was found in a
 * browser. */
.row-link::after {
  content: '';
  position: absolute;
  inset: 0;
}
.row:focus-within {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* A row whose audio has not crossed yet. The tint is what makes the
 * manifest-first list readable at a glance: these rows are real and clickable,
 * and they are also not the same thing as a recording you can play. */
.row-ondevice {
  background: var(--amber-soft);
}
.row-ondevice:hover {
  background: var(--amber-soft);
  border-left-color: var(--amber);
}

.row-name {
  font-family: var(--font-m);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-snippet {
  color: var(--ink-2);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-snippet mark {
  background: var(--brand-soft-2);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}
/* One DOM for both layouts. `display: contents` lets the meta cells sit in the
 * row's own grid columns on a wide screen, and the same element becomes a
 * wrapping flex line on a phone — so there is no second markup path to keep in
 * step with the first. */
.row-meta {
  display: contents;
}

.row-when {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.row-dur {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.row-device {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The state cell carries the chip AND, mid-transfer, the bar. Stacked rather
 * than side by side so a row that starts uploading does not shove the chip out
 * of the column it shares with every other row. */
.row-state {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.row-progress {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-small);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.row-progress .progress {
  flex: 1;
  min-width: 46px;
}

/* Above the row-link overlay, or the click opens the recording instead of
 * asking the Mac for it. */
.row-fetch {
  position: relative;
  z-index: 1;
  align-self: start;
}

/* The whole-shift bar: what is being held back, and the switch for it.
 *
 * Above the list rather than in `.filters`, on purpose. It is not a query:
 * the server was never asked to leave those rows out, and the filter grid is
 * already five columns wide at 1024px with no room for a sixth. Here it sits
 * against the thing it changes, and it only appears when there is something to
 * say: no row is ever hidden without this line on screen. */
.shift-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}
.shift-bar .spacer {
  margin-left: auto;
}

.shift-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-small);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.shift-toggle:hover {
  color: var(--ink);
}
.shift-check {
  accent-color: var(--brand);
  cursor: pointer;
  margin: 0;
}


/* ── Detail ──────────────────────────────────────────────────────────────── */

.detail-head {
  margin-bottom: 14px;
}
.detail-head h1 {
  font-family: var(--font-m);
  font-size: 17px;
  font-weight: 600;
  margin: 4px 0 8px;
  word-break: break-all;
}
.backlink {
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.player {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.player audio {
  width: 100%;
  display: block;
}
.player-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin-top: 9px;
  color: var(--ink-2);
  font-size: var(--t-small);
}

/* The waiting room: a recording that is listed and not yet here. It sits where
 * the player sits, because that is where somebody looks to hear it, and it
 * answers the question they arrived with. */
.awaiting {
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.awaiting h2 {
  font-size: var(--t-h2);
  font-weight: 600;
  margin: 0 0 4px;
}
.awaiting p {
  margin: 0 0 12px;
  color: var(--ink-2);
  max-width: 62ch;
}
.awaiting .progress {
  margin-bottom: 8px;
}
.awaiting-figures {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--ink-3);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
}
.fact {
  background: var(--surface);
  padding: 9px 12px;
}
.fact dt {
  font-size: var(--t-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.fact dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Suhbat's `.card`, declaration for declaration. The shadow went and the header
 * tint went with it: the header is a header because of the rule under it, and a
 * second surface colour behind the heading was Diktofon saying the same thing
 * twice in a box that Suhbat says once. Two products that ship the same :root
 * block token for token still read as two products when the box around a list
 * is drawn differently in each, and this box is on every page of both. */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
/* Centred and not baseline-aligned, which is the one place this parts from
 * `.card > header`: Suhbat's header carries a hint span beside the heading and
 * ours carries buttons, and a button sitting on a heading's baseline hangs. */
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: var(--t-h2);
  font-weight: 600;
  margin: 0;
}
.panel-head .spacer {
  margin-left: auto;
}
.panel-body {
  padding: 4px 0;
}

.turn {
  display: grid;
  grid-template-columns: 26px 62px minmax(0, 1fr);
  gap: 10px;
  padding: 6px 14px;
  align-items: start;
}
.turn:hover {
  background: var(--surface-hover);
}
.turn-speaker {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--on-brand);
  background: var(--ink-4);
}
/* Three hues, because a fourth speaker on a handheld recording is rare and
 * cycling is honest about that. All three are tokens; none is invented here. */
.turn-speaker[data-speaker='A'] {
  background: var(--brand);
}
.turn-speaker[data-speaker='B'] {
  background: var(--violet);
}
.turn-speaker[data-speaker='C'] {
  background: var(--tg);
}
.turn-time {
  background: none;
  border: none;
  padding: 2px 0 0;
  cursor: pointer;
  text-align: left;
  color: var(--ink-3);
  font-family: var(--font-m);
  font-size: 12px;
}
.turn-time:hover {
  color: var(--brand-ink);
  text-decoration: underline;
}
.turn-text {
  padding-top: 1px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.turn-current {
  background: var(--brand-soft);
}

/* ── Fragments ───────────────────────────────────────────────────────────── */

/* A log, not a transcript. Built to the shape of Suhbat's arrivals screen,
 * because a shift's worth of speech is read the same way a shift's worth of
 * comings and goings is: one row per event, WHEN on the left, WHAT in the
 * middle, HOW LONG on the right, scanned down a column rather than read
 * through.
 *
 * No zebra striping and no row hover, deliberately. Neither carries
 * information here, since the rows are not clickable as rows and only the play
 * button in each one is, and a highlight that follows the pointer down a list
 * of two hundred rows competes with the one highlight that does mean
 * something: the fragment the playhead is actually inside. */
.frag {
  display: grid;
  grid-template-columns: minmax(170px, 210px) minmax(0, 1fr) 150px;
  gap: 12px;
  padding: 10px 14px;
  align-items: start;
}
/* Between rows only. A border on the first one would draw a second line
 * directly under the panel head's own. */
.frag + .frag {
  border-top: 1px solid var(--line);
}

.frag-when {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

/* The play control. It is the only thing in the row that does anything, so it
 * is the only thing that gets a hover and a focus ring. */
.frag-play {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: start;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 2px 7px 2px 5px;
  margin-left: -6px;
  cursor: pointer;
  color: var(--ink-2);
  font-family: var(--font-m);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  transition:
    color 0.14s var(--ease),
    background 0.14s var(--ease),
    border-color 0.14s var(--ease);
}
.frag-play:hover {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-color: var(--brand-soft-2);
}
.frag-play:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
/* Drawn with borders rather than set as a glyph: ▶ is a different size and a
 * different baseline in every font this page might fall back to, and it picks
 * up an emoji presentation on some of them. */
.frag-play-mark {
  width: 0;
  height: 0;
  flex: none;
  border-left: 7px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.frag-play:active .frag-play-mark {
  transform: scale(0.88);
}

.frag-who {
  font-size: var(--t-small);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frag-text {
  padding-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Right-aligned, because it is a magnitude compared down the column and not a
 * label read left to right. */
.frag-dur {
  padding-top: 3px;
  text-align: right;
  color: var(--ink-3);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}

/* The one highlight in this list that carries information: the fragment the
 * playhead is inside. It is the reason the rows have no hover of their own. */
.frag-current {
  background: var(--brand-soft);
}

/* ── Devices ─────────────────────────────────────────────────────────────── */

.dev-list .dev-row {
  display: grid;
  /* The action column is a FIXED width, not `auto`. A revoked device has no
   * button, and an auto column collapsing to zero lets the 1fr grow — which
   * slid every other column right and made one row in the list look
   * misaligned with the rest. */
  grid-template-columns: minmax(0, 1fr) 190px 130px 110px 100px;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.dev-list .dev-row:last-child {
  border-bottom: none;
}
.dev-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dev-sub {
  color: var(--ink-3);
  font-size: var(--t-small);
}

.token-box {
  margin-bottom: 14px;
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.token-box h2 {
  margin: 0 0 4px;
  font-size: var(--t-h2);
  color: var(--amber);
}
.token-value {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.token-value code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-m);
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  overflow-x: auto;
  white-space: nowrap;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Login ───────────────────────────────────────────────────────────────── */

.auth {
  max-width: 400px;
  margin: 8vh auto 0;
  padding: 0 16px;
}
.auth .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.auth h1 {
  font-size: var(--t-lede);
  font-weight: 600;
  margin: 0 0 6px;
}
.auth .lede {
  color: var(--ink-2);
  margin: 0 0 18px;
}
.auth .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.auth .field label {
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--ink-2);
}
.auth .btn {
  width: 100%;
  justify-content: center;
}
.auth .foot {
  margin-top: 14px;
  color: var(--ink-3);
  font-size: var(--t-small);
  text-align: center;
}

/* ── Responsive: the surfaces ────────────────────────────────────────────── */

@media (max-width: 900px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .filters .field:first-child {
    grid-column: 1 / -1;
  }
  .dev-list .dev-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
  }
}

/* The fragment log stops being three columns before the recordings list stops
 * being five, because the middle column here holds sentences and not a
 * filename: at 860px the text column is already down to a few words a line
 * while the «how long» column sits half empty beside it. */
@media (max-width: 860px) {
  .frag {
    /* One content column, plus a shrink-to-fit one for the length. The length
     * is the only thing that reads better on the right, so it stays there and
     * joins the start time on a single meta line above the text, which is
     * what the two explicit rows below are for. The order in the markup is
     * unchanged; only where the cells land is. */
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    padding: 11px 14px;
  }
  .frag-when {
    grid-row: 1;
    grid-column: 1;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .frag-dur {
    grid-row: 1;
    grid-column: 2;
    padding-top: 0;
  }
  .frag-text {
    grid-row: 2;
    grid-column: 1 / -1;
    padding-top: 0;
  }
}

@media (max-width: 720px) {
  /* The table stops being a table. Five columns at 375px is five columns of one
   * word each; stacked, the filename stays readable and everything else becomes
   * one wrapping meta line. */
  .list-head {
    display: none;
  }
  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 12px 11px;
  }
  .row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
    align-items: center;
    color: var(--ink-2);
    font-size: var(--t-small);
  }
  .row-meta > * {
    min-width: 0;
  }
  .row-state {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1 0 100%;
  }
  .turn {
    grid-template-columns: 24px minmax(0, 1fr);
    row-gap: 2px;
  }
  .turn-time,
  .turn-text {
    grid-column: 2;
  }
  .facts {
    grid-template-columns: 1fr 1fr;
  }
}
