/*
  What your AIs can see (TO-37).

  Its own stylesheet, like tomo-connections.css, so it never collides with the branding pass on
  tomo-face.css. The section also carries .tomo-face, so every token below (and the dark palette
  under prefers-color-scheme) comes from tomo-face.css. Nothing here invents a colour.

  Connectors and the "what each AI can reach" summary are the kit's collapsible rows, styled in
  tomo-face.css; this sheet styles only what they hold. Hosts include it after tomo-face.css:
    <link rel="stylesheet" href="_content/Tomo.Face/tomo-visibility.css" />
*/

.tomo-visibility.tomo-face {
  box-sizing: border-box;
  width: 100%;
  height: auto;
  gap: var(--tomo-space-4);
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--tomo-space-8) var(--tomo-space-6);
  background: transparent;
}

.tomo-visibility__title {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* F1: a quiet subtitle under the title, then the setting. */
.tomo-visibility__lede {
  margin: var(--tomo-space-1) 0 0;
  font-size: 13px;
  color: var(--tomo-text-muted);
}

/* The connector rows' own instruction (TO-37), now under the setting rather than in the header. */
.tomo-visibility__gridlede {
  margin: 0 0 calc(var(--tomo-space-2) * -1);
  font-size: 13px;
  color: var(--tomo-text-secondary);
}

.tomo-visibility__failure {
  align-items: center;
}

.tomo-visibility__failure-text { flex: 1 1 auto; }

/* ---------- Rows: one collapsible row per connector ----------
   The row itself is the kit's (tomo-face.css). Open, it holds one hairline line per kind of AI:
   the name and hint on the left, the switch, lock or dash on the right, as the mock's minilist. */

.tomo-visibility__tiers {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--tomo-border-subtle);
}

.tomo-visibility__cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-height: var(--tomo-touch);
  padding: 4px 0;
  border-bottom: 1px solid var(--tomo-border-subtle);
  font-size: 13.5px;
}

.tomo-visibility__tiertext {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  min-width: 0;
}

.tomo-visibility__tiername {
  font-weight: 600;
  color: var(--tomo-text-primary);
}

.tomo-visibility__cell[data-tier="zenai"] .tomo-visibility__tiername { color: var(--tomo-sovereign); }

.tomo-visibility__tierhint {
  min-width: 0;
  color: var(--tomo-text-secondary);
}

.tomo-visibility__control {
  display: flex;
  flex: none;
  align-items: center;
  margin-left: auto;
}

.tomo-visibility__none { color: var(--tomo-text-muted); }

/* Partner AI before the tenant opts in (TE-98): your own AI's state, read-only, with a note. */
.tomo-visibility__follows { display: inline-flex; cursor: default; }

.tomo-switch.tomo-switch--readonly { opacity: 0.55; cursor: default; }

.tomo-visibility__follownote {
  flex-basis: 100%;
  font-size: 12px;
  line-height: 1.3;
  color: var(--tomo-text-muted);
}

/* ---------- Lock: the organisation's ceiling, no switch ---------- */

.tomo-visibility__lock {
  display: inline-flex;
  align-items: center;
  gap: var(--tomo-space-1);
  padding: 3px var(--tomo-space-2);
  border-radius: var(--tomo-radius-full);
  background: var(--tomo-surface-sunken);
  color: var(--tomo-text-muted);
  font-size: 12px;
  cursor: help;
}

.tomo-visibility__locktext { white-space: nowrap; }

/* ---------- Switch ---------- */

.tomo-switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--tomo-border-light);
  border-radius: var(--tomo-radius-full);
  background: var(--tomo-surface-sunken);
  cursor: pointer;
  transition: background var(--tomo-duration-fast) var(--tomo-ease-out),
              border-color var(--tomo-duration-fast) var(--tomo-ease-out);
}

.tomo-switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--tomo-surface-elevated);
  box-shadow: var(--tomo-shadow-sm);
  transition: transform var(--tomo-duration-fast) var(--tomo-ease-out);
}

.tomo-switch--on {
  border-color: transparent;
  background: var(--tomo-accent);
}

.tomo-switch--on .tomo-switch__knob {
  transform: translateX(16px);
  background: var(--tomo-text-inverse);
}

.tomo-switch:focus-visible {
  outline: 2px solid var(--tomo-accent);
  outline-offset: 2px;
}

/* aria-disabled, not disabled: a disabled button drops keyboard focus to <body>. */
.tomo-switch[aria-disabled="true"] { cursor: progress; }
.tomo-switch[aria-disabled="true"]:not(.tomo-switch--busy) { opacity: 0.6; }
.tomo-switch--busy { animation: tomo-pulse 1.1s ease-in-out infinite; }

/* ---------- Status line: what just happened ---------- */

.tomo-visibility__status {
  min-height: 1.4em;
  margin: 0;
  font-size: 13px;
  color: var(--tomo-text-secondary);
}

/* ---------- Your setting: Private | Public (TO-38) ----------
   The segments reuse the mode dial's .tomo-dial__segments / __segment from tomo-face.css. */

/* F1 (pitch #screen-f1): an uppercase field label, a compact two-option segment sized to its
   words (not stretched), and a muted line under it. */
.tomo-setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tomo-setting__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tomo-text-muted);
}

.tomo-setting__segments {
  align-self: flex-start;
  gap: 3px;
  margin-bottom: 0;
  border-radius: var(--tomo-radius-md);
  border-color: var(--tomo-border-light);
}

.tomo-setting__segment {
  flex: none;
  padding: 6px var(--tomo-space-4);
  border-radius: 8px;
}

/* F1 marks the selected option in the primary colour, whichever it is. */
.tomo-setting__segment--selected { color: var(--tomo-accent); }

.tomo-setting__segment:focus-visible {
  outline: 2px solid var(--tomo-accent);
  outline-offset: 2px;
}

/* aria-disabled, not disabled, while saving: a disabled button drops keyboard focus. */
.tomo-setting__segment[aria-disabled="true"] { cursor: progress; }
.tomo-setting__segment--busy { animation: tomo-pulse 1.1s ease-in-out infinite; }

.tomo-setting__line {
  margin: 0;
  max-width: 44rem;
  font-size: 13px;
  /* F1 draws this muted; secondary keeps the organisation's rule at readable contrast (AA). */
  color: var(--tomo-text-secondary);
}

.tomo-setting__failure { align-items: center; }
.tomo-setting__failure-text { flex: 1 1 auto; }

.tomo-setting__status {
  margin: 0;
  font-size: 13px;
  color: var(--tomo-text-secondary);
}

.tomo-setting__status:empty { display: none; }

.tomo-setting__skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--tomo-space-2);
}

.tomo-skel--segments { width: 10rem; height: 36px; border-radius: var(--tomo-radius-md); }
.tomo-skel--line { width: min(36rem, 100%); height: 12px; }

/* ---------- What each AI can reach: two collapsible rows (TO-38) ----------
   A group label, then the kit's rows; open, each lists what that AI can reach. */

.tomo-reach {
  display: flex;
  flex-direction: column;
  gap: var(--tomo-space-2);
}

.tomo-reach__group {
  margin: 0 0 0 2px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tomo-text-muted);
}

.tomo-reach__list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tomo-reach__item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--tomo-text-secondary);
}

.tomo-reach__icon {
  flex: none;
  margin-top: 2px;
  color: var(--tomo-accent);
}

/* ---------- Skeleton ---------- */

.tomo-skel {
  display: block;
  border-radius: var(--tomo-radius-sm);
  background: var(--tomo-border-light);
  animation: tomo-pulse 1.4s ease-in-out infinite;
}

.tomo-skel--name { width: min(12rem, 55%); height: 14px; }
.tomo-skel--sub { width: min(16rem, 70%); height: 10px; }

@media (prefers-reduced-motion: reduce) {
  .tomo-switch,
  .tomo-switch__knob { transition: none; }

  .tomo-switch--busy,
  .tomo-setting__segment--busy,
  .tomo-skel { animation: none; }
}

/* ---------- Phone ---------- */

@media (max-width: 40rem) {
  .tomo-visibility.tomo-face { padding: var(--tomo-space-5) var(--tomo-space-4); }
}

/* ---------- Tenant policy (TO-71) ----------
   Reuses the switch above and the tokens from tomo-face.css (light and dark), so nothing here
   invents a colour. One card per connector: name, Private switch with its line, the ceiling. */

.tomo-tenant-policy.tomo-face {
  box-sizing: border-box;
  width: 100%;
  height: auto;
  gap: var(--tomo-space-4);
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--tomo-space-8) var(--tomo-space-6);
  background: transparent;
}

.tomo-tenant-policy__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tomo-space-3);
}

.tomo-tenant-policy__title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--tomo-text-primary);
}

.tomo-tenant-policy__mock {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--tomo-warn-line);
  border-radius: var(--tomo-radius-sm);
  font-size: 11px;
  font-weight: 600;
  background: var(--tomo-warn-bg);
  color: var(--tomo-warn-ink);
}

.tomo-tenant-policy__lead,
.tomo-tenant-policy__empty {
  margin: 0;
  color: var(--tomo-text-secondary);
}

.tomo-tenant-policy__skeleton { display: grid; gap: var(--tomo-space-3); }

.tomo-tenant-policy__list {
  display: grid;
  gap: var(--tomo-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tomo-tenant-policy__row {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(14rem, 2fr) auto;
  grid-template-areas:
    "name private ceiling"
    "status status status";
  align-items: start;
  gap: var(--tomo-space-3) var(--tomo-space-5);
  padding: var(--tomo-space-4) var(--tomo-space-5);
  border: 1px solid var(--tomo-border-subtle);
  border-radius: var(--tomo-radius-lg);
  background: var(--tomo-surface-elevated);
}

.tomo-tenant-policy__name {
  grid-area: name;
  font-weight: 600;
  color: var(--tomo-text-primary);
  line-height: 24px;
}

.tomo-tenant-policy__private {
  grid-area: private;
  display: flex;
  align-items: flex-start;
  gap: var(--tomo-space-3);
}

.tomo-tenant-policy__private-text { display: grid; gap: 2px; }

.tomo-tenant-policy__private-label {
  font-weight: 500;
  color: var(--tomo-text-primary);
  line-height: 24px;
}

.tomo-tenant-policy__line {
  font-size: 13px;
  color: var(--tomo-text-secondary);
}

.tomo-tenant-policy__ceiling {
  grid-area: ceiling;
  display: flex;
  flex-wrap: wrap;
  gap: var(--tomo-space-2) var(--tomo-space-4);
  margin: 0;
  padding: 0;
  border: 0;
}

.tomo-tenant-policy__legend {
  width: 100%;
  padding: 0;
  margin-bottom: var(--tomo-space-1);
  font-size: 12px;
  font-weight: 600;
  color: var(--tomo-text-muted);
}

.tomo-tenant-policy__check {
  display: inline-flex;
  align-items: center;
  gap: var(--tomo-space-2);
  min-height: 24px;
  color: var(--tomo-text-primary);
  cursor: pointer;
}

.tomo-tenant-policy__check input { accent-color: var(--tomo-accent); width: 16px; height: 16px; margin: 0; }
.tomo-tenant-policy__check input:disabled { cursor: progress; }
.tomo-tenant-policy__check--locked,
.tomo-tenant-policy__check--locked input:disabled { cursor: default; }

.tomo-tenant-policy__locknote {
  width: 100%;
  font-size: 12px;
  color: var(--tomo-text-muted);
}

.tomo-tenant-policy__status {
  grid-area: status;
  min-height: 18px;
  font-size: 13px;
}

.tomo-tenant-policy__status:empty { display: none; }
.tomo-tenant-policy__saving { color: var(--tomo-text-muted); }
.tomo-tenant-policy__saved { color: var(--tomo-ok-ink); font-weight: 600; }
.tomo-tenant-policy__saved::before { content: "✓ "; }
.tomo-tenant-policy__error { color: var(--tomo-danger-ink); }

@media (max-width: 40rem) {
  .tomo-tenant-policy.tomo-face { padding: var(--tomo-space-5) var(--tomo-space-4); }

  .tomo-tenant-policy__row {
    grid-template-columns: 1fr;
    grid-template-areas: "name" "private" "ceiling" "status";
  }
}
