/*
  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); }
}
