/* PH pills, toggle chips, checkboxes, radios and switches. Status pills moved here from ph-table.css (same class names). Values from Studio (phstudio-app.css: .pill, .tag, .filter-toggle, .fchip, .rv-rt, .check, .pm-sw). Needs only ph-tokens.css.
   Status pill (a dot comes with it; add ph-pill--plain for no dot; colours: none = neutral, --ok, --warn, --bad, --info, --teal, --sun):
     <span class="ph-pill ph-pill--ok">Done</span>
     <span class="ph-pill ph-pill--warn ph-pill--plain">At risk</span>
     <span class="ph-pill ph-pill--teal">Removable<button class="ph-pill__x" type="button" aria-label="Remove"><svg viewBox="0 0 24 24"><path d="M6 6l12 12M18 6L6 18"/></svg></button></span>
   Toggle chip (a button; aria-pressed="true" / class is-on = selected; ph-pill--role = the larger role tile, set its colour with style="--c:#0E7C86"):
     <button class="ph-pill ph-pill--chip" type="button" aria-pressed="false">Overdue</button>
     <button class="ph-pill ph-pill--chip ph-pill--dot is-on" type="button" aria-pressed="true">Mine</button>
   Checkbox / radio (the input stays real, so forms, labels and the keyboard work; indeterminate is set by script: input.indeterminate = true):
     <label class="ph-check"><input type="checkbox"><span class="ph-check__box"></span><span class="ph-check__text">Send me a copy</span></label>
     <label class="ph-radio"><input type="radio" name="n"><span class="ph-radio__dot"></span><span class="ph-radio__text">Weekly</span></label>
   Switch:
     <label class="ph-switch"><input type="checkbox" role="switch"><span class="ph-switch__track"></span><span class="ph-switch__text">Email alerts</span></label>
   Add disabled to the input (and class is-disabled on the label if you want the label greyed too: it is done for you in modern browsers). Studio uses one font weight: 400. */
.ph-pill, .ph-check, .ph-radio, .ph-switch, .ph-pill *, .ph-check *, .ph-radio *, .ph-switch * { box-sizing: border-box; font-weight: 400; }

/* status pills, for any cell (moved from ph-table.css, unchanged) */
.ph-pill, :where(#ss) .pill, :where(#ss) .tag { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border-radius: var(--ph-r-pill); background: var(--paper-alt); color: var(--ink-muted); font-family: var(--font); font-size: 12px; white-space: nowrap; }
.ph-pill[hidden] { display: none; }
.ph-pill::before, :where(#ss) .pill::before, :where(#ss) .tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.ph-pill--ok, :where(#ss) .pill.is-good { background: var(--ph-ok-tint); color: var(--ph-ok); }
.ph-pill--warn { background: var(--ph-warn-tint); color: var(--ph-warn); }
.ph-pill--bad, :where(#ss) .pill.is-urgent { background: var(--ph-bad-tint); color: var(--ph-bad); }
.ph-pill--info { background: var(--ph-info-tint); color: var(--ph-info); }
.ph-pill--plain::before, :where(#ss) .pill::before, :where(#ss) .tag::before { display: none; }
/* new colours */
.ph-pill--teal, :where(#ss) .pill.is-high, :where(#ss) .tag.is-acc { background: var(--acc-tint); color: var(--acc-ink); }
.ph-pill--sun { background: var(--spot); color: var(--on-spot); }
/* small: a tag (Studio .tag) */
.ph-pill--sm, :where(#ss) .tag { height: 20px; padding: 0 8px; font-size: 10.5px; }
/* Studio aliases: #ss .pill (.is-good, .is-urgent, .is-high) and #ss .tag (.is-acc) are written by Studio scripts. They share the rules above, without the dot, until Studio writes ph-pill. */

/* removable: the small round x (Studio .fchip button) */
.ph-pill__x { width: 16px; height: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; margin: 0 -5px 0 0; padding: 0; border: 0; border-radius: 50%; background: rgba(127, 127, 127, .25); color: inherit; cursor: pointer; transition: background-color var(--ph-ease); }
.ph-pill__x:hover { background: rgba(127, 127, 127, .45); }
.ph-pill__x:focus-visible { outline: none; box-shadow: var(--ph-ring); }
.ph-pill__x svg { width: 8px; height: 8px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* toggle chips (Studio .filter-toggle: 12px text, 14px corners, border; on = solid teal) */
.ph-pill--chip { height: 28px; padding: 0 12px; border: 1px solid var(--border); background: var(--card); color: var(--ink-faint); cursor: pointer; transition: border-color var(--ph-ease), background-color var(--ph-ease), color var(--ph-ease); }
.ph-pill--chip::before { display: none; }
.ph-pill--chip.ph-pill--dot::before { display: block; }
.ph-pill--chip:hover { border-color: var(--acc); color: var(--acc); }
.ph-pill--chip:focus-visible { outline: none; box-shadow: var(--ph-ring); }
.ph-pill--chip.is-on, .ph-pill--chip[aria-pressed="true"], .ph-pill--chip[aria-checked="true"] { border-color: var(--acc); background: var(--acc); color: var(--card); }
.ph-pill--chip:disabled, .ph-pill--chip.is-disabled { opacity: .5; cursor: not-allowed; }
.ph-pill--chip:disabled:hover { border-color: var(--border); color: var(--ink-faint); }

/* role chip: the larger tile (Studio .rv-rt: 1.5px border, 12px corners, fills with its own colour when chosen) */
.ph-pill--role { --c: var(--acc); height: auto; min-height: 40px; padding: 8px 16px; border-width: 1.5px; border-radius: 12px; font-size: 13px; color: var(--ink-muted); }
.ph-pill--role:hover { border-color: var(--c); color: var(--ink-muted); }
.ph-pill--role.is-on, .ph-pill--role[aria-pressed="true"], .ph-pill--role[aria-checked="true"] { border-color: var(--c); background: var(--c); color: var(--card); }

/* checkbox and radio: the real input is laid over the drawn box, invisible */
.ph-check, .ph-radio { position: relative; display: inline-flex; align-items: center; gap: 10px; font-family: var(--font); font-size: 13.5px; line-height: 1.35; color: var(--ink); cursor: pointer; }
.ph-check input, .ph-radio input { position: absolute; left: 0; top: 50%; width: 16px; height: 16px; margin: -8px 0 0; opacity: 0; cursor: inherit; }
.ph-check__box, .ph-radio__dot { position: relative; width: 16px; height: 16px; flex: none; border: 1.5px solid var(--ink-faint); background: var(--card); transition: background-color var(--ph-ease), border-color var(--ph-ease), box-shadow var(--ph-ease); }
.ph-check__box { border-radius: 4px; }
.ph-radio__dot { border-radius: 50%; }
.ph-check:hover .ph-check__box, .ph-radio:hover .ph-radio__dot { border-color: var(--acc); }
.ph-check input:focus-visible + .ph-check__box, .ph-radio input:focus-visible + .ph-radio__dot { border-color: var(--acc); box-shadow: var(--ph-ring); }
/* tick */
.ph-check__box::after { content: ''; position: absolute; left: 4px; top: 0; width: 4px; height: 9px; border: solid var(--card); border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform var(--ph-ease); }
.ph-check input:checked + .ph-check__box { background: var(--acc-ink); border-color: var(--acc-ink); }
.ph-check input:checked + .ph-check__box::after { transform: rotate(45deg) scale(1); }
/* indeterminate: a bar */
.ph-check input:indeterminate + .ph-check__box, .ph-check input[aria-checked="mixed"] + .ph-check__box { background: var(--acc-ink); border-color: var(--acc-ink); }
.ph-check input:indeterminate + .ph-check__box::after, .ph-check input[aria-checked="mixed"] + .ph-check__box::after { left: 2px; top: 5px; width: 8px; height: 0; border-width: 0 0 2px; transform: none; }
/* radio dot */
.ph-radio__dot::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--acc-ink); transform: scale(0); transition: transform var(--ph-ease); }
.ph-radio input:checked + .ph-radio__dot { border-color: var(--acc-ink); }
.ph-radio input:checked + .ph-radio__dot::after { transform: scale(1); }
/* disabled */
.ph-check input:disabled, .ph-radio input:disabled { cursor: not-allowed; }
.ph-check:has(input:disabled), .ph-radio:has(input:disabled), .ph-check.is-disabled, .ph-radio.is-disabled { cursor: not-allowed; color: var(--ink-muted); opacity: .55; }
.ph-check:has(input:disabled):hover .ph-check__box, .ph-radio:has(input:disabled):hover .ph-radio__dot { border-color: var(--ink-faint); }
.ph-check:has(input:checked:disabled):hover .ph-check__box, .ph-check:has(input:indeterminate:disabled):hover .ph-check__box { border-color: var(--acc-ink); }
.ph-radio:has(input:checked:disabled):hover .ph-radio__dot { border-color: var(--acc-ink); }

/* switch (Studio .pm-sw, the last switch rule: 42 x 24, 18px knob, teal when on) */
.ph-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-family: var(--font); font-size: 13.5px; line-height: 1.35; color: var(--ink); cursor: pointer; }
.ph-switch input { position: absolute; left: 0; top: 50%; width: 42px; height: 24px; margin: -12px 0 0; opacity: 0; cursor: inherit; }
.ph-switch__track { position: relative; width: 42px; height: 24px; flex: none; border-radius: 12px; background: var(--sc9d3d6); background: color-mix(in srgb, var(--ink-faint) 40%, var(--paper-alt)); transition: background-color .15s; }
.ph-switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.ph-switch input:checked + .ph-switch__track { background: var(--acc); }
.ph-switch input:checked + .ph-switch__track::after { transform: translateX(18px); }
.ph-switch input:focus-visible + .ph-switch__track { box-shadow: var(--ph-ring); }
.ph-switch input:disabled { cursor: not-allowed; }
.ph-switch:has(input:disabled), .ph-switch.is-disabled { cursor: not-allowed; color: var(--ink-muted); }
.ph-switch:has(input:disabled) .ph-switch__track, .ph-switch.is-disabled .ph-switch__track { opacity: .55; }

@media (max-width: 600px) {
  .ph-check, .ph-radio, .ph-switch { min-height: 32px; }
  .ph-pill--chip { height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .ph-pill__x, .ph-pill--chip, .ph-check__box, .ph-check__box::after, .ph-radio__dot, .ph-radio__dot::after, .ph-switch__track, .ph-switch__track::after { transition: none; }
}
