/* Clock pop-up (js/views/event-clock.js, flag ptp_clock).
   Scoped under .clk. Tokens only. One compact row per clock device.
   The view sizes to its content and the modal body scrolls.
   The disclosure mark matches .dm2-caret (0.5rem box, 2px border). */

.clk {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-ui);
}
/* The event toolbar's sticky top is the page header. Inside the pop-up that
   offset covers the empty title. Keep the bar in normal flow. */
/* The modal body is a column-flex item. min-width:auto would keep it as wide
   as the nowrap row and the modal would clip the right edge. */
.modal-body.clk-pop { min-width: 0; max-width: 100%; }
.clk-pop > .event-toolbar {
  position: static;
  top: auto;
  width: auto;
  max-width: 100%;
  margin: 0;
}
.clk-head { padding: 12px 16px 10px; border-bottom: 1px solid var(--border); flex: none; }
.clk-head-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.clk-title { margin: 0; font-size: 15px; font-weight: 600; }
.clk-count, .clk-worst, .clk-muted {
  font-size: 12px;
  color: var(--text-2);
}
.clk-worst { font-family: var(--font-mono); }
.clk-body {
  min-width: 0;
  max-width: 100%;
  padding: 12px 16px 24px;
  /* The list cannot query itself. This container lets a narrow body drop
     the wide tracks and wrap each device onto two lines. */
  container-type: inline-size;
  container-name: clk;
}
.clk-body > * + * { margin-top: 14px; }
.clk-list {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  /* ch is this mono face, so 17ch holds a 16-hex EUI-64 and 15ch holds an
     IPv4 address. Tracks are fixed (or max-content of a short label) so a
     node UUID cannot stretch the row past the list. The status track is the
     only flexible one. 8rem still clears the "locked primary" badge and the
     word UNCALIBRATED; 9rem plus 17ch, 15ch, and 9ch does not fit the 732px
     list inside the 800px modal. A node UUID is shortened in the view.
     Served-by is the last 6 hex digits inside the metrics cluster. */
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  grid-template-columns:
    1.25rem
    0.7rem
    max-content
    17ch
    15ch
    minmax(8rem, 1fr)
    max-content
    9ch;
  column-gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
}
.clk-dev {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  min-width: 0;
  border-bottom: 1px solid var(--border-subtle);
}
.clk-dev:last-child { border-bottom: 0; }
.clk-dev-toggle {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.clk-dev-toggle:hover { background: var(--bg-raised); }
.clk-line2 { display: contents; }
.clk-metrics {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  white-space: nowrap;
}
.clk-metrics .clk-slot:empty { display: none; }
.clk-caret {
  box-sizing: content-box;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  justify-self: center;
}
.clk-dev.is-open .clk-caret { transform: rotate(45deg); }
.clk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  justify-self: center;
}
.clk-dot.is-ok { background: var(--ok); }
.clk-dot.is-warn { background: var(--warn); }
.clk-dot.is-danger { background: var(--danger); }
.clk-dot.is-neutral { background: var(--text-muted); }
.clk-role { font-family: var(--font-ui); font-weight: 600; white-space: nowrap; }
.clk-slot { min-width: min-content; }
/* No word-break and no overflow-wrap:anywhere. A track may not shrink below
   the longest whole word, and a glyph may not break onto its own line. */
.clk-slot-id,
.clk-slot-a,
.clk-slot-c,
.clk-slot-d,
.clk-slot-e,
.clk-slot-age {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.clk-slot-id { min-width: max-content; }
.clk-slot-a {
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}
.clk-slot-b {
  font-family: var(--font-ui);
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  min-width: min-content;
}
.clk-slot-b .badge,
.clk-slot-b .badge-label { white-space: nowrap; }
.clk-slot-age,
.clk-num { font-variant-numeric: tabular-nums; }
.clk-slot-age { text-align: right; }
.clk-dev-body { grid-column: 1 / -1; padding: 2px 12px 10px 36px; min-width: 0; }
.clk-dev-body[hidden] { display: none; }
.clk-footnote { margin: 0; }
/* The wide tracks need about 730px. Below that the row wraps onto a second
   line instead of squeezing a column to nothing. 720px is under the 732px
   list in the 800px modal, so 1280×800 stays on one line. */
@container clk (max-width: 720px) {
  .clk-list, .clk-dev, .clk-dev-toggle, .clk-metrics, .clk-line2 { max-width: 100%; }
  .clk-list { display: block; width: 100%; }
  .clk-dev { display: block; width: 100%; min-width: 0; }
  .clk-dev-toggle {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: 1.25rem 0.7rem max-content max-content;
    grid-template-areas:
      "caret dot role id"
      "line2 line2 line2 line2";
    grid-column: auto;
    column-gap: 8px;
    row-gap: 2px;
    min-height: 44px;
  }
  .clk-caret { grid-area: caret; }
  .clk-dot { grid-area: dot; }
  .clk-role { grid-area: role; }
  .clk-slot-id {
    grid-area: id;
    justify-self: start;
    min-width: max-content;
    white-space: nowrap;
  }
  .clk-line2 {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    grid-area: line2;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .clk-line2 .clk-slot,
  .clk-line2 .clk-metrics {
    flex: 0 0 auto;
    min-width: max-content;
    max-width: none;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
  }
  .clk-slot:empty { display: none; }
  .clk-slot-age { text-align: left; }
}
.clk-node, .clk-alarms {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clk-h3 { margin: 0; font-size: 13px; font-weight: 600; }
.clk-meta, .clk-servo, .clk-standing, .clk-count {
  margin: 0;
  font-size: 12px;
  color: var(--text-2);
}
.clk-meta { display: flex; flex-wrap: wrap; gap: 10px; }
.clk-servo { font-family: var(--font-mono); color: var(--text-1); }
.clk-id, .clk-domain-key { font-family: var(--font-mono); }
.clk-domain-key { margin: 0; color: var(--text-muted); font-size: 12px; }
.clk-gms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 10px;
  min-width: 0;
}
.clk-gm, .clk-bridge {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
  padding: 10px 12px;
}
.clk-gm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clk-kicker {
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.clk-fields {
  display: grid;
  grid-template-columns: minmax(8ch, 14ch) minmax(0, 1fr);
  gap: 3px 10px;
  margin: 8px 0 0;
}
.clk-fields dt { color: var(--text-muted); font-size: 11px; }
.clk-fields dd { margin: 0; font-family: var(--font-mono); font-size: 12px; min-width: 0; overflow-wrap: anywhere; }
.clk-notes { margin: 0; padding-left: 18px; color: var(--text-1); font-size: 12.5px; }
.clk-verdict { margin: 8px 0 0; font-size: 13px; color: var(--text-1); }
.clk-alarm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.clk-alarm {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  background: var(--bg-card);
}
.clk-alarm.is-critical { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.clk-alarm.is-warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.clk-alarm-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-family: var(--font-mono); font-size: 12px; }
.clk-sev { text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; color: var(--text-2); }
.clk-alarm.is-critical .clk-sev { color: var(--danger); }
.clk-alarm.is-warn .clk-sev { color: var(--warn); }
.clk-alarm-detail { margin: 4px 0 0; font-size: 12px; color: var(--text-2); }
.m-clock-mount { min-width: 0; min-height: 0; }
