/*
 * Templ atoms (templates/atoms/), copied from the Figma Atoms/<Name> sets. Styled only with tokens.css variables.
 * Literals are values Figma has no variable for: control and atom sizes, icon sizes, stroke widths (1 px, 1.5 px,
 * 2 px, 3 px and the 2 px focus ring), badge, dot and caret sizes and placement, and SVG shape geometry.
 *
 * Shared rules (Figma Atoms page):
 * - Hover and Pressed lay state-hover / state-pressed over the fill, drawn as a background image over the
 *   background color. The tokens already carry the layer opacity in their alpha.
 * - Focus is a 2 px focus-ring outline: outside on buttons, the toggle track and a selected radio; inside on
 *   fields, the checkbox box and an unselected radio, where it covers the border.
 * - Disabled is opacity-disabled on the whole atom.
 * - Every :hover, :active and :focus rule also matches [data-force-state='hover' | 'pressed' | 'focus'], which
 *   the dev gallery sets to show a state without inline style.
 */

/* ---------- Button (Figma Atoms/Button) ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  border: 0;
  border-radius: var(--radius-full);
  background-color: transparent;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button--primary {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
}

.button--secondary {
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.button--ghost {
  background-color: transparent;
  color: var(--color-text);
}

.button--danger {
  background-color: var(--color-danger);
  color: var(--color-on-danger);
}

/* Heights and icon sizes have no Figma variable: Sm 36 px with a 16 px icon, Md 44 px and Lg 52 px with 20 px. */
.button--sm {
  height: 36px;
  padding-inline: var(--space-md);
  font: var(--text-body-body-s-semibold);
  letter-spacing: var(--text-body-body-s-semibold-tracking);
}

.button--sm .icon {
  width: 16px;
  height: 16px;
}

.button--md {
  height: 44px;
  padding-inline: var(--space-lg);
  font: var(--text-body-body-semibold);
  letter-spacing: var(--text-body-body-semibold-tracking);
}

.button--lg {
  height: 52px;
  padding-inline: var(--space-xl);
  font: var(--text-body-body-l-medium);
  letter-spacing: var(--text-body-body-l-medium-tracking);
}

.button--md .icon,
.button--lg .icon {
  width: 20px;
  height: 20px;
}

.button:hover:not(:disabled, [aria-disabled='true']),
.button[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

.button:active:not(:disabled, [aria-disabled='true']),
.button[data-force-state='pressed'] {
  background-image: linear-gradient(var(--color-state-pressed), var(--color-state-pressed));
}

.button:focus-visible,
.button[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 0;
}

/* Disabled fades the button; Loading keeps full color and shows the spinner. */
.button:disabled:not([aria-busy='true']),
.button[aria-disabled='true']:not([aria-busy='true']) {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.button[aria-busy='true'] {
  cursor: progress;
}

/* ---------- Icon Button (Figma Atoms/Icon Button) ---------- */

.icon-button {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background-color: transparent;
  color: var(--color-text);
  cursor: pointer;
}

.icon-button--secondary {
  background-color: var(--color-surface-2);
  color: var(--color-text);
}

.icon-button--ghost {
  background-color: transparent;
  color: var(--color-text);
}

.icon-button--primary {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
}

/* 36 and 44 px squares with a 20 px icon; no Figma variables for these. */
.icon-button--sm {
  width: 36px;
  height: 36px;
}

.icon-button--md {
  width: 44px;
  height: 44px;
}

.icon-button .icon {
  width: 20px;
  height: 20px;
}

/* "Show badge": an 8 px secondary dot, 4 px from the right and 6 px (Sm) or 9 px (Md) from the top, as placed in
 * Figma. */
.icon-button__badge {
  position: absolute;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-secondary);
}

.icon-button--sm .icon-button__badge {
  top: 6px;
}

.icon-button--md .icon-button__badge {
  top: 9px;
}

.icon-button:hover:not(:disabled),
.icon-button[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

.icon-button:active:not(:disabled),
.icon-button[data-force-state='pressed'] {
  background-image: linear-gradient(var(--color-state-pressed), var(--color-state-pressed));
}

.icon-button:focus-visible,
.icon-button[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 0;
}

.icon-button:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

/* ---------- Text Field, Textarea, Select (Figma Atoms/Text Field, Atoms/Textarea, Atoms/Select) ---------- */

.text-field,
.textarea,
.select {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.text-field--disabled,
.textarea--disabled,
.select--disabled {
  opacity: var(--opacity-disabled);
}

.text-field__label,
.textarea__label,
.select__label {
  color: var(--color-text);
  font: var(--text-body-body-s-medium);
  letter-spacing: var(--text-body-body-s-medium-tracking);
}

.text-field__box,
.select__box {
  position: relative;
  display: flex;
}

/* The control is the bordered box: 1 px border-strong, surface-1, radius-md. Text Field and Select are 44 px
 * tall, Textarea 120 px; no Figma variables for these. */
.text-field__input,
.textarea__input,
.select__input {
  width: 100%;
  margin: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-1);
  color: var(--color-text);
  font: var(--text-body-body);
  letter-spacing: var(--text-body-body-tracking);
}

.text-field__input,
.select__input {
  height: 44px;
  padding: 0 var(--space-md);
}

.textarea__input {
  display: block;
  height: 120px;
  padding: var(--space-sm) var(--space-md);
  /* Figma draws a fixed 120 px field with no resize handle. */
  resize: none;
}

/* Leading icon: 20 px, text-muted, with an xs gap before the text. */
.text-field__input--icon,
.select__input--icon {
  padding-left: calc(var(--space-md) + 20px + var(--space-xs));
}

.text-field__icon,
.select__icon,
.select__caret {
  position: absolute;
  top: 50%;
  display: flex;
  color: var(--color-text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.text-field__icon,
.select__icon {
  left: var(--space-md);
}

.text-field__icon .icon,
.select__icon .icon,
.select__caret .icon {
  width: 20px;
  height: 20px;
}

.text-field__input::placeholder,
.textarea__input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.text-field__input:hover:not(:disabled, :focus),
.text-field__input[data-force-state='hover'],
.select__input:hover:not(:disabled, :focus),
.select__input[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

/* Error: a 2 px danger border, drawn as the 1 px border plus a 1 px inset shadow so the text doesn't move. */
.text-field__input[aria-invalid='true'],
.textarea__input[aria-invalid='true'] {
  border-color: var(--color-danger);
  box-shadow: inset 0 0 0 1px var(--color-danger);
}

/* Focus: a 2 px focus-ring border inside the field, in place of the border (and of an error border). Text
 * controls match :focus-visible on any focus, but a select doesn't, so fields use :focus. */
.text-field__input:focus,
.text-field__input[data-force-state='focus'],
.textarea__input:focus,
.textarea__input[data-force-state='focus'],
.select__input:focus,
.select__input[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

.text-field__input:disabled,
.textarea__input:disabled,
.select__input:disabled {
  background-color: var(--color-surface-2);
  cursor: not-allowed;
}

/* Select: a native select with the system menu, the caret drawn over its right edge. */
.select__input {
  padding-right: calc(var(--space-md) + 20px + var(--space-xs));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  appearance: none;
  cursor: pointer;
}

.select__caret {
  right: var(--space-md);
}

/* Helper (Body/Caption, text-muted) and error (Body/Caption Medium, danger, with a 16 px warning icon). */
.text-field__message,
.textarea__message {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  color: var(--color-text-muted);
  font: var(--text-body-caption);
  letter-spacing: var(--text-body-caption-tracking);
}

.text-field__message--error,
.textarea__message--error {
  color: var(--color-danger);
  font: var(--text-body-caption-medium);
  letter-spacing: var(--text-body-caption-medium-tracking);
}

.text-field__message .icon,
.textarea__message .icon {
  width: 16px;
  height: 16px;
}

/* ---------- Search Field (Figma Atoms/Search Field) ---------- */

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

/* 44 and 52 px pills with a 1 px border-strong border and 20 px icons; no Figma variables for these. */
.search-field__input {
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 calc(var(--space-md) + 20px + var(--space-xs));
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background-color: var(--color-surface-1);
  color: var(--color-text);
  font: var(--text-body-body);
  letter-spacing: var(--text-body-body-tracking);
  appearance: none;
}

.search-field--lg .search-field__input {
  height: 52px;
  font: var(--text-body-body-l);
  letter-spacing: var(--text-body-body-l-tracking);
}

/* The atom draws its own clear button. */
.search-field__input::-webkit-search-cancel-button,
.search-field__input::-webkit-search-decoration {
  appearance: none;
}

.search-field__input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.search-field__input:focus,
.search-field__input[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

.search-field__icon {
  position: absolute;
  left: var(--space-md);
  display: flex;
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-field__icon .icon,
.search-field__clear .icon {
  width: 20px;
  height: 20px;
}

/* The clear button: a 20 px icon at the field's right padding, in a 44 px target (12 px around the icon). */
.search-field__clear {
  position: absolute;
  right: calc(var(--space-md) - 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* Hidden until atoms.js runs, then only while the field is filled. */
.search-field__clear[hidden],
.search-field__input:placeholder-shown ~ .search-field__clear {
  display: none;
}

/* ---------- Checkbox, Radio, Toggle (Figma Atoms/Checkbox, Atoms/Radio, Atoms/Toggle) ---------- */

/* A 44 px row around the control, an sm gap, and a Body/Body label. */
.checkbox,
.radio,
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 44px;
  min-height: 44px;
  color: var(--color-text);
  font: var(--text-body-body);
  letter-spacing: var(--text-body-body-tracking);
  cursor: pointer;
}

.checkbox--disabled,
.radio--disabled,
.toggle--disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.checkbox__control,
.radio__control,
.toggle__control {
  position: relative;
  display: inline-flex;
  flex: none;
}

.checkbox__input,
.radio__input,
.toggle__input {
  margin: 0;
  border: 1.5px solid var(--color-border-strong);
  appearance: none;
  cursor: inherit;
}

/* Checkbox: a 24 px box, radius-sm. Off is surface-1 with the border; On and Mixed fill control-on. */
.checkbox__input {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-1);
}

.checkbox__input:checked,
.checkbox__input:indeterminate,
.checkbox__input[data-mixed] {
  border-color: transparent;
  background-color: var(--color-control-on);
}

/* The 16 px on-control mark. Mixed draws the minus from data-mixed, so it shows without JS. */
.checkbox__mark {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--color-on-control);
  pointer-events: none;
}

.checkbox__mark .icon {
  width: 16px;
  height: 16px;
}

.checkbox__input:checked ~ .checkbox__mark--check,
.checkbox__input:indeterminate ~ .checkbox__mark--mixed,
.checkbox__input[data-mixed]:not(:checked) ~ .checkbox__mark--mixed {
  display: flex;
}

/* Radio: a 24 px circle. Off is surface-1 with the border; On fills control-on with a 10 px on-control dot. */
.radio__input {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-1);
}

.radio__input:checked {
  border-color: transparent;
  background-color: var(--color-control-on);
}

.radio__dot {
  position: absolute;
  top: 7px;
  left: 7px;
  display: none;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background-color: var(--color-on-control);
  pointer-events: none;
}

.radio__input:checked ~ .radio__dot {
  display: block;
}

.checkbox:hover .checkbox__input:not(:disabled),
.checkbox__input[data-force-state='hover'],
.radio:hover .radio__input:not(:disabled),
.radio__input[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

/* Focus is drawn inside the box, in place of the border; a selected radio draws it outside, as in Figma. */
.checkbox__input:focus-visible,
.checkbox__input[data-force-state='focus'],
.radio__input:focus-visible,
.radio__input[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

.radio__input:checked:focus-visible,
.radio__input:checked[data-force-state='focus'] {
  outline-offset: 0;
}

/* Toggle: a 44 × 24 track and a 16 px thumb. Off is surface-2 with the border and a text-muted thumb 4 px inside
 * the border; On fills control-on with an on-control thumb 4 px from the right. */
.toggle__input {
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
}

.toggle__input:checked {
  border-color: transparent;
  background-color: var(--color-control-on);
}

.toggle__thumb {
  position: absolute;
  top: 4px;
  left: calc(1.5px + var(--space-2xs));
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background-color: var(--color-text-muted);
  pointer-events: none;
}

.toggle__input:checked ~ .toggle__thumb {
  left: calc(44px - 16px - var(--space-2xs));
  background-color: var(--color-on-control);
}

.toggle__input:focus-visible,
.toggle__input[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 0;
}

/* ---------- Platform Mark (Figma Atoms/Platform Mark) ---------- */

/* A neutral monogram in a radius-sm square: 24, 32 and 40 px (no Figma variables for these). Sm and Md use
 * Mono/Mono-S Medium, Lg uses Mono/Mono. */
.platform-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-inverse);
  color: var(--color-text-inverse);
  font: var(--text-mono-mono-s-medium);
  letter-spacing: var(--text-mono-mono-s-medium-tracking);
  white-space: nowrap;
}

.platform-mark--sm {
  width: 24px;
  height: 24px;
}

.platform-mark--md {
  width: 32px;
  height: 32px;
}

.platform-mark--lg {
  width: 40px;
  height: 40px;
  font: var(--text-mono-mono);
  letter-spacing: var(--text-mono-mono-tracking);
}

/* On an inverted surface (a selected Chip): text-inverse fill and a text monogram. */
.platform-mark--inverse {
  background-color: var(--color-text-inverse);
  color: var(--color-text);
}

/* ---------- Chip (Figma Atoms/Chip) ---------- */

/* A 32 px pill with a 16 px icon and an xs gap, in Body/Body-S Medium. Off is surface-2; On is inverted
 * (surface-inverse), so selection never spends the accent. Platform chips start with the Sm mark, 2xs from the
 * edge. */
.chip {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-xs);
  height: 32px;
  padding-inline: var(--space-sm);
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
  color: var(--color-text);
  font: var(--text-body-body-s-medium);
  letter-spacing: var(--text-body-body-s-medium-tracking);
  white-space: nowrap;
}

.chip--platform {
  padding-left: var(--space-2xs);
}

.chip__icon {
  display: flex;
  color: var(--color-text-muted);
}

.chip__icon .icon {
  width: 16px;
  height: 16px;
}

.chip--selected,
.chip:has(> .chip__input:checked) {
  background-color: var(--color-surface-inverse);
  color: var(--color-text-inverse);
}

.chip--selected .chip__icon,
.chip:has(> .chip__input:checked) .chip__icon {
  color: var(--color-text-inverse);
}

/* A toggle chip's mark inverts while checked; a static chip renders platform-mark--inverse. */
.chip:has(> .chip__input:checked) .platform-mark {
  background-color: var(--color-text-inverse);
  color: var(--color-text);
}

/* A Filter chip shows its check only when selected. */
.chip--filter .chip__icon {
  display: none;
}

.chip--filter.chip--selected .chip__icon,
.chip--filter:has(> .chip__input:checked) .chip__icon {
  display: flex;
}

/* A toggle chip's hit area grows to 44 px tall with invisible padding (Figma: "the visual size stays compact"). */
.chip--toggle {
  cursor: pointer;
}

.chip--toggle::after {
  position: absolute;
  inset: -6px 0;
  content: '';
}

/* Focus: a 2 px focus-ring stroke inside the pill, shown when its checkbox has keyboard focus. */
.chip:has(> .chip__input:focus-visible),
.chip:has(> .chip__input[data-force-state='focus']) {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

/* ---------- Badge (Figma Atoms/Badge) ---------- */

/* A 24 px read-only label in Body/Caption Medium with a 14 px icon. Accent is a solid accent fill with on-accent
 * text; the other tones are a subtle tint with text in the tone's hue. */
.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-2xs);
  height: 24px;
  padding-inline: var(--space-xs);
  border-radius: var(--radius-full);
  font: var(--text-body-caption-medium);
  letter-spacing: var(--text-body-caption-medium-tracking);
  white-space: nowrap;
}

.badge .icon {
  width: 14px;
  height: 14px;
}

.badge--neutral {
  background-color: var(--color-surface-2);
  color: var(--color-text-muted);
}

.badge--accent {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
}

.badge--secondary {
  background-color: var(--color-secondary-subtle);
  color: var(--color-secondary);
}

.badge--success {
  background-color: var(--color-success-subtle);
  color: var(--color-success);
}

.badge--warning {
  background-color: var(--color-warning-subtle);
  color: var(--color-warning);
}

.badge--danger {
  background-color: var(--color-danger-subtle);
  color: var(--color-danger);
}

/* ---------- Avatar (Figma Atoms/Avatar) ---------- */

/* Initials on surface-2 in 24, 32, 40, 56 and 96 px circles. Text styles: XS and Sm Body/Caption Medium, Md
 * Body/Body-S SemiBold, Lg Body/Body SemiBold, XL Heading/H2. */
.avatar {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
  color: var(--color-text);
  white-space: nowrap;
}

.avatar--xs {
  width: 24px;
  height: 24px;
  font: var(--text-body-caption-medium);
  letter-spacing: var(--text-body-caption-medium-tracking);
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font: var(--text-body-caption-medium);
  letter-spacing: var(--text-body-caption-medium-tracking);
}

.avatar--md {
  width: 40px;
  height: 40px;
  font: var(--text-body-body-s-semibold);
  letter-spacing: var(--text-body-body-s-semibold-tracking);
}

.avatar--lg {
  width: 56px;
  height: 56px;
  font: var(--text-body-body-semibold);
  letter-spacing: var(--text-body-body-semibold-tracking);
}

.avatar--xl {
  width: 96px;
  height: 96px;
  font: var(--text-heading-h2);
  letter-spacing: var(--text-heading-h2-tracking);
}

/* Offline: a hollow text-muted ring with a surface-1 cutout around it, at the bottom right. Dot, ring and cutout
 * as in Figma: XS 8 px with a 1.5 px ring, Sm 10, Md 12 and Lg 14 px with 2 px, XL 20 px with 3 px set 4 px in;
 * the cutout is 2 px (XL 3 px). */
.avatar__status {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-text-muted);
  border-radius: var(--radius-full);
  background-color: var(--color-surface-1);
  box-shadow: 0 0 0 2px var(--color-surface-1);
}

.avatar--xs .avatar__status {
  width: 8px;
  height: 8px;
  border-width: 1.5px;
}

.avatar--sm .avatar__status {
  width: 10px;
  height: 10px;
}

.avatar--lg .avatar__status {
  width: 14px;
  height: 14px;
}

.avatar--xl .avatar__status {
  right: var(--space-2xs);
  bottom: var(--space-2xs);
  width: 20px;
  height: 20px;
  border-width: 3px;
  box-shadow: 0 0 0 3px var(--color-surface-1);
}

/* ---------- Divider (Figma Atoms/Divider) ---------- */

/* A 1 px rule in color/border. Horizontal fills its container; Vertical stretches to its flex row, at least the
 * 40 px Figma draws. */
.divider {
  flex: none;
  margin: 0;
  border: 0;
  background-color: var(--color-border);
}

.divider--horizontal {
  width: 100%;
  height: 1px;
}

.divider--vertical {
  align-self: stretch;
  width: 1px;
  height: auto;
  min-height: 40px;
}

/* ---------- Tooltip (Figma Atoms/Tooltip) ---------- */

/* An inverse bubble (surface-inverse, text-inverse, Body/Body-S Medium, xs × sm padding, radius-sm) with
 * Elevation/Float and a 12 × 6 px caret pointing at the trigger. The bubble's caret area bridges the gap to the
 * trigger, so the pointer can move onto the bubble without it closing. */
.tooltip {
  position: relative;
  display: inline-flex;
}

.tooltip__bubble {
  position: absolute;
  left: 50%;
  z-index: 1;
  display: flex;
  visibility: hidden;
  transform: translateX(-50%);
}

.tooltip--top .tooltip__bubble {
  bottom: 100%;
  padding-bottom: 6px;
}

.tooltip--bottom .tooltip__bubble {
  top: 100%;
  padding-top: 6px;
}

.tooltip__text {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-inverse);
  box-shadow: var(--elevation-float);
  color: var(--color-text-inverse);
  font: var(--text-body-body-s-medium);
  letter-spacing: var(--text-body-body-s-medium-tracking);
  white-space: nowrap;
}

.tooltip__bubble::after {
  position: absolute;
  left: 50%;
  width: 0;
  height: 0;
  border-inline: 6px solid transparent;
  content: '';
  transform: translateX(-50%);
}

.tooltip--top .tooltip__bubble::after {
  bottom: 0;
  border-top: 6px solid var(--color-surface-inverse);
}

.tooltip--bottom .tooltip__bubble::after {
  top: 0;
  border-bottom: 6px solid var(--color-surface-inverse);
}

.tooltip:hover .tooltip__bubble,
.tooltip[data-force-state='hover'] .tooltip__bubble,
.tooltip:focus-within .tooltip__bubble,
.tooltip[data-force-state='focus'] .tooltip__bubble {
  visibility: visible;
}

/* Escape hides it until the next hover or focus (static/js/atoms.js). */
.tooltip[data-tooltip-dismissed] .tooltip__bubble {
  visibility: hidden;
}

/* ---------- Skeleton (Figma Atoms/Skeleton) ---------- */

/* A surface-2 placeholder. The Figma default sizes: Line 200 × 12 px, Block 240 × 120 px, Circle 40 px. Pass a
 * class to size it like the real layout. */
.skeleton {
  display: block;
  flex: none;
  background-color: var(--color-surface-2);
}

.skeleton--line {
  width: 200px;
  height: 12px;
  border-radius: var(--radius-full);
}

.skeleton--block {
  width: 240px;
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton--circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

/* ---------- Game Tile (Figma Atoms/Game Tile) ---------- */

/* A 64 px radius-lg tile that clips its shapes. Each pattern has its own fill, and each shape a fill class. */
.game-tile {
  display: block;
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  clip-path: inset(0 round var(--radius-lg));
}

.game-tile--orbit,
.game-tile--dots,
.game-tile--blocks {
  background-color: var(--color-surface-2);
}

.game-tile--stack,
.game-tile--rings {
  background-color: var(--color-secondary-subtle);
}

.game-tile--arc {
  background-color: var(--color-border);
}

.game-tile__shape--surface-1 {
  fill: var(--color-surface-1);
}

.game-tile__shape--surface-2 {
  fill: var(--color-surface-2);
}

.game-tile__shape--border {
  fill: var(--color-border);
}

.game-tile__shape--border-strong {
  fill: var(--color-border-strong);
}

.game-tile__shape--text-muted {
  fill: var(--color-text-muted);
}

.game-tile__shape--secondary {
  fill: var(--color-secondary);
}

.game-tile__shape--secondary-subtle {
  fill: var(--color-secondary-subtle);
}

/* ---------- Slot (Figma Atoms/Slot) ---------- */

/* One 32 px seat with a 16 px icon. Filled is surface-inverse; Open is a 1.5 px dashed border-strong ring with a
 * text-muted plus; You is the accent. */
.slot {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
}

.slot .icon {
  width: 16px;
  height: 16px;
}

.slot--filled {
  background-color: var(--color-surface-inverse);
  color: var(--color-text-inverse);
}

.slot--open {
  border: 1.5px dashed var(--color-border-strong);
  color: var(--color-text-muted);
}

.slot--you {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
}

/* ---------- Spinner (Figma Atoms/Spinner) ---------- */

/* Phosphor circle-notch in currentColor, 24 px by default (the icon's size). Figma says "rotate in code" and gives
 * no duration; one turn a second matches @playmayte/ui's Spinner. Inside a Button it takes the button's icon size
 * and text color. */
.spinner {
  display: inline-flex;
  flex: none;
  animation: spinner-turn 1s linear infinite;
}

@keyframes spinner-turn {
  to {
    transform: rotate(1turn);
  }
}

/* ---------- Progress (Figma Atoms/Progress) ---------- */

/* A native <progress>: an 8 px surface-2 track and a secondary bar, both fully rounded. It fills its container
 * (Figma draws 240 px). */
.progress {
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
  color: var(--color-secondary);
  appearance: none;
}

.progress::-webkit-progress-bar {
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
}

.progress::-webkit-progress-value {
  border-radius: var(--radius-full);
  background-color: var(--color-secondary);
}

.progress::-moz-progress-bar {
  border-radius: var(--radius-full);
  background-color: var(--color-secondary);
}

/* ---------- Logo (Figma Atoms/Logo) ---------- */

/* The mark and favicon are Figma's SVG exports (static/img/brand/), drawn in color/brand-* fills that are the same
 * in Light and Dark. Full is the 32 px mark, an xs gap and the "playmayte" wordmark in Heading/H3, text color. The
 * image sizes come from the width and height attributes (Mark 32 px and up, Favicon under 32 px). */
.logo {
  flex: none;
}

.logo--mark,
.logo--favicon,
.logo__mark {
  display: block;
}

.logo--full {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-text);
}

.logo__wordmark {
  font: var(--text-heading-h3);
  letter-spacing: var(--text-heading-h3-tracking);
  white-space: nowrap;
}

/* ---------- Nav Item (Figma Atoms/Nav Item) ---------- */

/* A destination link. Default is text-muted, Hover is text over state-hover, Active is text over surface-1
 * (Expanded, Rail) or a surface-2 indicator (Tab): tonal, with no accent and no border. Sizes have no Figma
 * variable: Expanded 216 × 44 px with a 20 px icon, Rail a 48 px circle with a 20 px icon, Tab 72 × 56 px with a
 * 56 × 32 px indicator and a 24 px icon. */
.nav-item {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  color: var(--color-text-muted);
  text-decoration: none;
}

.nav-item:hover,
.nav-item[data-force-state='hover'],
.nav-item--active {
  color: var(--color-text);
}

/* Expanded: Body Medium, SemiBold when Active; the label fills the row and the badge sits at the end. */
.nav-item--expanded {
  gap: var(--space-sm);
  width: 216px;
  height: 44px;
  padding-inline: var(--space-md);
  border-radius: var(--radius-full);
  font: var(--text-body-body-medium);
  letter-spacing: var(--text-body-body-medium-tracking);
}

.nav-item--expanded.nav-item--active {
  font: var(--text-body-body-semibold);
  letter-spacing: var(--text-body-body-semibold-tracking);
}

.nav-item--expanded .nav-item__label {
  flex: 1 1 0;
  min-width: 0;
}

/* Rail: the label is visually hidden and stays the accessible name. */
.nav-item--rail {
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
}

.nav-item--expanded .icon,
.nav-item--rail .icon {
  width: 20px;
  height: 20px;
}

.nav-item--expanded.nav-item--active,
.nav-item--rail.nav-item--active {
  background-color: var(--color-surface-1);
}

.nav-item--expanded:hover,
.nav-item--expanded[data-force-state='hover'],
.nav-item--rail:hover,
.nav-item--rail[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

/* Tab: the icon in a pill indicator over a Caption label, Caption Medium when Active. */
.nav-item--tab {
  flex-direction: column;
  justify-content: center;
  gap: var(--space-2xs);
  width: 72px;
  height: 56px;
  font: var(--text-body-caption);
  letter-spacing: var(--text-body-caption-tracking);
  white-space: nowrap;
}

.nav-item--tab.nav-item--active {
  font: var(--text-body-caption-medium);
  letter-spacing: var(--text-body-caption-medium-tracking);
}

.nav-item__indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 32px;
  border-radius: var(--radius-full);
}

.nav-item--active .nav-item__indicator {
  background-color: var(--color-surface-2);
}

.nav-item--tab:hover .nav-item__indicator,
.nav-item--tab[data-force-state='hover'] .nav-item__indicator {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

/* Focus: a 2 px focus-ring stroke inside Expanded (pill) and Tab (square), outside the Rail circle. */
.nav-item:focus-visible,
.nav-item[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

.nav-item--rail:focus-visible,
.nav-item--rail[data-force-state='focus'] {
  outline-offset: 0;
}

/* ---------- Tab (Figma Atoms/Tab) ---------- */

/* A 36 px segment of a Tab Bar (no Figma variable for the height): Body/Body-S SemiBold, md padding, radius-full.
 * Off is text-muted on the track; Selected raises to surface-1 with text color. Hover layers state-hover over the
 * fill. */
.tab {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding-inline: var(--space-md);
  border-radius: var(--radius-full);
  background-color: transparent;
  color: var(--color-text-muted);
  font: var(--text-body-body-s-semibold);
  letter-spacing: var(--text-body-body-s-semibold-tracking);
  text-decoration: none;
  white-space: nowrap;
}

.tab--selected {
  background-color: var(--color-surface-1);
  color: var(--color-text);
}

.tab:hover,
.tab[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

.tab:focus-visible,
.tab[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

/* ---------- Link (Figma Atoms/Link) ---------- */

/* Body/Body-S SemiBold in accent-text with a 16 px trailing icon and a 2xs gap. Standalone links underline on
 * hover; Inline links (inside running text) underline at rest too. Focus is a 2 px focus-ring stroke inside a
 * radius-sm box. */
.link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  border-radius: var(--radius-sm);
  color: var(--color-accent-text);
  font: var(--text-body-body-s-semibold);
  letter-spacing: var(--text-body-body-s-semibold-tracking);
  text-decoration: none;
}

/* Inline: flows and wraps with the running text at its size and line height, keeping the SemiBold weight, the
 * accent-text color and the underline. */
.link--inline {
  display: inline;
  font-size: inherit;
  line-height: inherit;
}

.link .icon {
  width: 16px;
  height: 16px;
}

.link--inline .link__label,
.link:hover .link__label,
.link[data-force-state='hover'] .link__label {
  text-decoration: underline;
}

.link:focus-visible,
.link[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

/* ---------- Theme Toggle (Figma Atoms/Theme Toggle) ---------- */

/* A 44 px circle with a 20 px text-color icon (no Figma variables for these sizes); Hover is state-hover. */
.theme-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background-color: transparent;
  color: var(--color-text);
  cursor: pointer;
}

.theme-toggle__icon {
  display: inline-flex;
}

.theme-toggle .icon {
  width: 20px;
  height: 20px;
}

.theme-toggle:hover,
.theme-toggle[data-force-state='hover'] {
  background-image: linear-gradient(var(--color-state-hover), var(--color-state-hover));
}

.theme-toggle:focus-visible,
.theme-toggle[data-force-state='focus'] {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}

/* The icon names the theme a click switches to, as in Figma: the moon in Light, the sun in Dark. */
.theme-toggle[aria-pressed='false'] .theme-toggle__icon--sun,
.theme-toggle[aria-pressed='true'] .theme-toggle__icon--moon {
  display: none;
}

/* No stored choice and a dark system: show the sun before theme.js runs, and without JS, as tokens.css does. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle__icon--moon {
    display: none;
  }
  :root:not([data-theme]) .theme-toggle__icon--sun {
    display: inline-flex;
  }
}

/* Touch: Tab and Link grow their hit area to at least 44 × 44 px with an invisible layer centred on them; the visual
 * size stays the same. Inline links are left out: the layer would cover neighbouring lines, and WCAG 2.5.8 exempts
 * links in a sentence. */
.tab::after,
.link:not(.link--inline)::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
  content: '';
}

/* Forced colors (Windows High Contrast) drop background colors, so On would look like Off. Draw the checkbox,
 * radio and toggle with system colors instead: Highlight for On, CanvasText for borders and the Off thumb, Canvas
 * for the radio dot and the On thumb, and HighlightText for the checkbox mark. A selected chip, a selected Tab, an
 * active Nav Item (its indicator, in the Tab layout) and Slot You are Highlight with HighlightText; Slot Filled
 * gets a CanvasText border. The Divider and the Progress track draw in CanvasText with a Highlight bar, and the
 * Tooltip bubble gets a transparent outline the system draws as its edge. */
@media (forced-colors: active) {
  .checkbox__input,
  .radio__input,
  .toggle__input,
  .checkbox__mark,
  .radio__dot,
  .toggle__thumb {
    forced-color-adjust: none;
  }

  .checkbox__input,
  .radio__input,
  .toggle__input {
    border-color: CanvasText;
    background-color: Canvas;
  }

  .checkbox__input:checked,
  .checkbox__input:indeterminate,
  .checkbox__input[data-mixed],
  .radio__input:checked,
  .toggle__input:checked {
    border-color: Highlight;
    background-color: Highlight;
  }

  .checkbox__mark {
    color: HighlightText;
  }

  .radio__dot,
  .toggle__input:checked ~ .toggle__thumb {
    background-color: Canvas;
  }

  .toggle__thumb {
    background-color: CanvasText;
  }

  .chip--selected,
  .chip:has(> .chip__input:checked) {
    forced-color-adjust: none;
    background-color: Highlight;
    color: HighlightText;
  }

  .chip--selected .chip__icon,
  .chip:has(> .chip__input:checked) .chip__icon {
    color: HighlightText;
  }

  .divider {
    forced-color-adjust: none;
    background-color: CanvasText;
  }

  .progress {
    forced-color-adjust: none;
    border: 1px solid CanvasText;
    background-color: Canvas;
  }

  .progress::-webkit-progress-bar {
    background-color: Canvas;
  }

  .progress::-webkit-progress-value {
    background-color: Highlight;
  }

  .progress::-moz-progress-bar {
    background-color: Highlight;
  }

  .slot--filled {
    border: 1px solid CanvasText;
  }

  .tab--selected,
  .nav-item--expanded.nav-item--active,
  .nav-item--rail.nav-item--active,
  .nav-item--active .nav-item__indicator {
    forced-color-adjust: none;
    background-color: Highlight;
    color: HighlightText;
  }

  .slot--you {
    forced-color-adjust: none;
    background-color: Highlight;
    color: HighlightText;
  }

  .tooltip__text {
    outline: 1px solid transparent;
  }

  .checkbox__input:focus-visible,
  .checkbox__input[data-force-state='focus'],
  .radio__input:focus-visible,
  .radio__input[data-force-state='focus'],
  .toggle__input:focus-visible,
  .toggle__input[data-force-state='focus'] {
    outline-color: CanvasText;
  }
}
