/* =========================================================================
   PeopleWill — components
   Reusable UI. Never depends on anything in pages/.
   A page needing a variant adds a modifier HERE, not an override there.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Accent map

   Components carry data-accent="<key>" and CSS resolves the key to a token.
   This exists so no component needs an inline style attribute: the strict CSP
   in index.html sets style-src 'self' with no 'unsafe-inline', which blocks
   style="..." outright. Keeping accents in CSS keeps that policy enforceable.
   --------------------------------------------------------------------------- */

[data-accent="environment"] {
  --pw-accent-color: var(--pw-topic-environment);
}
[data-accent="health"] {
  --pw-accent-color: var(--pw-topic-health);
}
[data-accent="education"] {
  --pw-accent-color: var(--pw-topic-education);
}
[data-accent="work"] {
  --pw-accent-color: var(--pw-topic-work);
}
[data-accent="economy"] {
  --pw-accent-color: var(--pw-topic-economy);
}
[data-accent="technology-ai"] {
  --pw-accent-color: var(--pw-topic-technology-ai);
}
[data-accent="rights"] {
  --pw-accent-color: var(--pw-topic-rights);
}
[data-accent="government"] {
  --pw-accent-color: var(--pw-topic-government);
}
[data-accent="mobility"] {
  --pw-accent-color: var(--pw-topic-mobility);
}
[data-accent="housing"] {
  --pw-accent-color: var(--pw-topic-housing);
}
[data-accent="science"] {
  --pw-accent-color: var(--pw-topic-science);
}
[data-accent="peace-security"] {
  --pw-accent-color: var(--pw-topic-peace-security);
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.pw-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pw-space-2);
  min-block-size: var(--pw-target-min);
  padding: var(--pw-space-2) var(--pw-space-5);
  border: 1px solid transparent;
  border-radius: var(--pw-radius-full);
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    background-color var(--pw-duration-fast) var(--pw-ease-out),
    border-color var(--pw-duration-fast) var(--pw-ease-out),
    color var(--pw-duration-fast) var(--pw-ease-out);
}

.pw-button:disabled,
.pw-button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.pw-button--primary {
  background: var(--pw-primary);
  color: var(--pw-primary-contrast);
}

.pw-button--primary:hover:not(:disabled) {
  background: var(--pw-primary-hover);
  color: var(--pw-primary-contrast);
}

.pw-button--secondary {
  background: var(--pw-surface);
  border-color: var(--pw-border-strong);
  color: var(--pw-text);
}

.pw-button--secondary:hover:not(:disabled) {
  background: var(--pw-bg-subtle);
  border-color: var(--pw-primary);
  color: var(--pw-primary);
}

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

.pw-button--ghost:hover:not(:disabled) {
  background: var(--pw-primary-tint);
}

.pw-button--large {
  min-block-size: 52px;
  padding-inline: var(--pw-space-6);
  font-size: var(--pw-text-lg);
}

.pw-button--block {
  inline-size: 100%;
}

/* An icon-only control still needs a 44px target and an accessible name. */
.pw-icon-button {
  display: inline-grid;
  place-items: center;
  inline-size: var(--pw-target-min);
  block-size: var(--pw-target-min);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--pw-radius-full);
  background: transparent;
  color: var(--pw-text-secondary);
}

.pw-icon-button:hover {
  background: var(--pw-bg-subtle);
  color: var(--pw-text);
}

/* ---------------------------------------------------------------------------
   Form controls
   Interactive borders use --pw-border-strong (WCAG 1.4.11, 3:1).
   --------------------------------------------------------------------------- */

.pw-label {
  display: block;
  margin-block-end: var(--pw-space-2);
  font-size: var(--pw-text-sm);
  font-weight: var(--pw-weight-medium);
  color: var(--pw-text-secondary);
}

.pw-input,
.pw-textarea,
.pw-select {
  inline-size: 100%;
  min-block-size: var(--pw-target-min);
  padding: var(--pw-space-2) var(--pw-space-3);
  border: 1px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-md);
  background: var(--pw-surface);
  color: var(--pw-text);
  font-size: var(--pw-text-base);
}

.pw-input::placeholder,
.pw-textarea::placeholder {
  color: var(--pw-text-muted);
}

.pw-input:focus,
.pw-textarea:focus,
.pw-select:focus {
  border-color: var(--pw-primary);
}

.pw-textarea {
  min-block-size: 8rem;
  resize: vertical;
  line-height: var(--pw-leading-normal);
}

.pw-field-hint {
  margin-block-start: var(--pw-space-2);
  color: var(--pw-text-muted);
  font-size: var(--pw-text-sm);
}

.pw-field-error {
  margin-block-start: var(--pw-space-2);
  color: var(--pw-danger);
  font-size: var(--pw-text-sm);
  font-weight: var(--pw-weight-medium);
}

/* ---------------------------------------------------------------------------
   Chips
   --------------------------------------------------------------------------- */

.pw-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  padding: 2px var(--pw-space-2);
  border-radius: var(--pw-radius-full);
  background: var(--pw-surface-sunken);
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-xs);
  font-weight: var(--pw-weight-medium);
  white-space: nowrap;
}

.pw-chip .pw-icon {
  inline-size: 0.95em;
  block-size: 0.95em;
}

.pw-chip--topic {
  background: color-mix(in srgb, var(--pw-accent-color) 12%, transparent);
  color: var(--pw-accent-color);
}

.pw-chip--yours {
  background: var(--pw-primary-tint);
  color: var(--pw-primary);
}

/* ---------------------------------------------------------------------------
   Status badge — colour is never the only signal; the label is always text.
   --------------------------------------------------------------------------- */

.pw-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  padding: 2px var(--pw-space-2);
  border-radius: var(--pw-radius-full);
  font-size: var(--pw-text-xs);
  font-weight: var(--pw-weight-semibold);
  letter-spacing: var(--pw-tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
}

.pw-status-badge .pw-icon {
  inline-size: 0.95em;
  block-size: 0.95em;
}

.pw-status-badge[data-status="new"] {
  background: var(--pw-status-new-bg);
  color: var(--pw-status-new-fg);
}
.pw-status-badge[data-status="growing"] {
  background: var(--pw-status-growing-bg);
  color: var(--pw-status-growing-fg);
}
.pw-status-badge[data-status="community"] {
  background: var(--pw-status-community-bg);
  color: var(--pw-status-community-fg);
}
.pw-status-badge[data-status="review"] {
  background: var(--pw-status-review-bg);
  color: var(--pw-status-review-fg);
}
.pw-status-badge[data-status="planned"] {
  background: var(--pw-status-planned-bg);
  color: var(--pw-status-planned-fg);
}
.pw-status-badge[data-status="progress"] {
  background: var(--pw-status-progress-bg);
  color: var(--pw-status-progress-fg);
}
.pw-status-badge[data-status="impact"] {
  background: var(--pw-status-impact-bg);
  color: var(--pw-status-impact-fg);
}
.pw-status-badge[data-status="closed"] {
  background: var(--pw-status-closed-bg);
  color: var(--pw-status-closed-fg);
}

/* ---------------------------------------------------------------------------
   Ranking markers — the rule of three (PRD §18.1)

   Active and queued are the same idea from either side of the cap. The queue
   position is never hidden: a supporter must see that support is what moves a
   request up, or the cap reads as arbitrary scarcity rather than focus.
   --------------------------------------------------------------------------- */

.pw-slot {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  padding: 2px var(--pw-space-2);
  border-radius: var(--pw-radius-full);
  background: var(--pw-primary);
  color: var(--pw-primary-contrast);
  font-size: var(--pw-text-2xs);
  font-weight: var(--pw-weight-bold);
  letter-spacing: var(--pw-tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
}

.pw-slot__icon {
  inline-size: 0.9em;
  block-size: 0.9em;
}

.pw-qpos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 30px;
  min-block-size: 22px;
  padding: 2px var(--pw-space-2);
  border-radius: var(--pw-radius-full);
  background: var(--pw-surface-sunken);
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-xs);
  font-weight: var(--pw-weight-bold);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   Request card
   --------------------------------------------------------------------------- */

.pw-request-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-3);
  padding: var(--pw-space-4);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  background: var(--pw-surface);
  box-shadow: var(--pw-shadow-sm);
  transition:
    border-color var(--pw-duration-fast) var(--pw-ease-out),
    box-shadow var(--pw-duration-fast) var(--pw-ease-out);
}

.pw-request-card:hover {
  border-color: var(--pw-border-strong);
  box-shadow: var(--pw-shadow-md);
}

/* Focus lands on the inner link; show the ring around the whole card. */
.pw-request-card:focus-within {
  outline: var(--pw-focus-width) solid var(--pw-focus-color);
  outline-offset: var(--pw-focus-offset);
}

.pw-request-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-2);
}

.pw-request-card__title {
  font-size: var(--pw-text-lg);
}

/* Stretched link: full-card hit area, one tab stop, one accessible name. */
.pw-request-card__link {
  color: inherit;
  text-decoration: none;
}

.pw-request-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.pw-request-card__link:focus-visible {
  outline: none;
}

.pw-request-card__summary {
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-sm);
}

.pw-request-card__stats {
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-1);
  margin-block-start: auto;
}

.pw-request-card__supporters {
  font-size: var(--pw-text-sm);
  color: var(--pw-text-secondary);
}

.pw-request-card__supporters strong {
  color: var(--pw-text);
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-bold);
}

/* Actions sit above the stretched link so the button stays clickable. */
.pw-request-card__actions {
  position: relative;
  z-index: 1;
}

.pw-request-card__support {
  inline-size: 100%;
}

.pw-request-card__support[aria-pressed="true"] {
  border-color: var(--pw-success);
  color: var(--pw-success);
}

.pw-request-card--compact {
  padding: var(--pw-space-3);
}

.pw-request-teaser {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--pw-space-3);
  padding: var(--pw-space-3);
  border-radius: var(--pw-radius-md);
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  color: inherit;
  text-decoration: none;
  font-size: var(--pw-text-sm);
}

.pw-request-teaser:hover {
  border-color: var(--pw-primary);
  color: var(--pw-text);
}

.pw-request-teaser__title {
  font-weight: var(--pw-weight-medium);
}

.pw-request-teaser__count {
  flex: none;
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-xs);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Flag list — distinct countries represented, not one flag per supporter.
   --------------------------------------------------------------------------- */

.pw-flag-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--pw-space-1);
  font-size: var(--pw-text-sm);
}

.pw-flag-list__flags {
  display: inline-flex;
  gap: 2px;
  font-size: var(--pw-text-base);
  line-height: 1;
}

.pw-flag-list__more {
  color: var(--pw-text-muted);
  font-size: var(--pw-text-xs);
}

/* ---------------------------------------------------------------------------
   Topic card and tile
   --------------------------------------------------------------------------- */

.pw-topic-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pw-space-2);
  padding: var(--pw-space-4) var(--pw-space-3);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  background: var(--pw-surface);
  color: var(--pw-text);
  text-align: center;
  text-decoration: none;
  transition: border-color var(--pw-duration-fast) var(--pw-ease-out);
}

.pw-topic-card:hover {
  border-color: var(--pw-accent-color);
  color: var(--pw-text);
}

.pw-topic-card__icon {
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: var(--pw-radius-full);
  background: color-mix(in srgb, var(--pw-accent-color) 14%, transparent);
  color: var(--pw-accent-color);
}

.pw-topic-card__icon .pw-icon {
  inline-size: 24px;
  block-size: 24px;
}

.pw-topic-card__name {
  font-size: var(--pw-text-sm);
  font-weight: var(--pw-weight-semibold);
}

.pw-topic-card__description {
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-xs);
}

.pw-topic-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pw-space-2);
  min-block-size: 104px;
  padding: var(--pw-space-3);
  border: 2px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-lg);
  background: var(--pw-surface);
  color: var(--pw-text);
  text-align: center;
  transition:
    border-color var(--pw-duration-fast) var(--pw-ease-out),
    background-color var(--pw-duration-fast) var(--pw-ease-out);
}

.pw-topic-tile:hover {
  border-color: var(--pw-accent-color);
}

.pw-topic-tile[aria-pressed="true"] {
  border-color: var(--pw-accent-color);
  background: color-mix(in srgb, var(--pw-accent-color) 10%, transparent);
}

.pw-topic-tile__icon {
  color: var(--pw-accent-color);
}

.pw-topic-tile__icon .pw-icon {
  inline-size: 28px;
  block-size: 28px;
}

.pw-topic-tile__name {
  font-size: var(--pw-text-sm);
  font-weight: var(--pw-weight-medium);
  line-height: var(--pw-leading-snug);
}

/* The check is the non-colour signal for selection. */
.pw-topic-tile__check {
  position: absolute;
  inset-block-start: var(--pw-space-2);
  inset-inline-end: var(--pw-space-2);
  display: grid;
  place-items: center;
  inline-size: 20px;
  block-size: 20px;
  border-radius: var(--pw-radius-full);
  background: var(--pw-accent-color);
  color: var(--pw-bg);
  opacity: 0;
  transition: opacity var(--pw-duration-fast) var(--pw-ease-out);
}

.pw-topic-tile__check .pw-icon {
  inline-size: 14px;
  block-size: 14px;
}

.pw-topic-tile[aria-pressed="true"] .pw-topic-tile__check {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Country select
   --------------------------------------------------------------------------- */

.pw-country-select__field {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-country-select__searchIcon {
  position: absolute;
  inset-inline-start: var(--pw-space-3);
  color: var(--pw-text-muted);
  pointer-events: none;
}

.pw-country-select__search {
  padding-inline-start: calc(var(--pw-space-3) * 2 + 1.25em);
}

.pw-country-select__status {
  margin-block-start: var(--pw-space-2);
  color: var(--pw-text-muted);
  font-size: var(--pw-text-xs);
}

.pw-country-select__list {
  max-block-size: 46svh;
  margin-block-start: var(--pw-space-2);
  overflow-y: auto;
  border: 1px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-md);
  background: var(--pw-surface);
  overscroll-behavior: contain;
}

.pw-country-select__row {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  min-block-size: var(--pw-target-min);
  padding: var(--pw-space-2) var(--pw-space-3);
  border-block-end: 1px solid var(--pw-border-subtle);
  cursor: pointer;
}

.pw-country-select__row:last-child {
  border-block-end: none;
}

.pw-country-select__row:hover {
  background: var(--pw-bg-subtle);
}

.pw-country-select__row[aria-selected="true"] {
  background: var(--pw-primary-tint);
  color: var(--pw-primary);
  font-weight: var(--pw-weight-semibold);
}

.pw-country-select__flag {
  font-size: var(--pw-text-lg);
  line-height: 1;
}

.pw-country-select__name {
  flex: 1;
}

.pw-country-select__check {
  color: var(--pw-primary);
}

.pw-country-select__empty {
  padding: var(--pw-space-5) var(--pw-space-3);
  color: var(--pw-text-muted);
  text-align: center;
  font-size: var(--pw-text-sm);
}

/* ---------------------------------------------------------------------------
   Option grid — age range, gender, auth provider
   --------------------------------------------------------------------------- */

.pw-option-grid {
  display: grid;
  gap: var(--pw-space-3);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
}

.pw-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--pw-space-2);
  min-block-size: var(--pw-target-min);
  padding: var(--pw-space-3);
  border: 2px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-md);
  background: var(--pw-surface);
  color: var(--pw-text);
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-medium);
}

.pw-option:hover {
  border-color: var(--pw-primary);
}

.pw-option[aria-checked="true"],
.pw-option[aria-pressed="true"] {
  border-color: var(--pw-primary);
  background: var(--pw-primary-tint);
  color: var(--pw-primary);
}

.pw-option--stacked {
  flex-direction: column;
  gap: var(--pw-space-2);
  min-block-size: 96px;
}

.pw-option--stacked .pw-icon {
  inline-size: 26px;
  block-size: 26px;
}

/* ---------------------------------------------------------------------------
   Avatar picker
   --------------------------------------------------------------------------- */

.pw-avatar-picker__grid {
  display: grid;
  gap: var(--pw-space-3);
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
}

.pw-avatar-option {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-inline-size: var(--pw-target-min);
  border: 2px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-full);
  background: color-mix(in srgb, var(--pw-accent-color) 12%, var(--pw-surface));
  color: var(--pw-accent-color);
}

.pw-avatar-option:hover {
  border-color: var(--pw-accent-color);
}

.pw-avatar-option[aria-checked="true"] {
  border-color: var(--pw-accent-color);
  border-width: 3px;
}

.pw-avatar-option .pw-icon {
  inline-size: 26px;
  block-size: 26px;
}

.pw-avatar-option__check {
  position: absolute;
  inset-block-end: -2px;
  inset-inline-end: -2px;
  inline-size: 18px !important;
  block-size: 18px !important;
  padding: 2px;
  border-radius: var(--pw-radius-full);
  background: var(--pw-accent-color);
  color: var(--pw-bg);
}

.pw-avatar-picker__uploadRow {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  margin-block-start: var(--pw-space-4);
}

.pw-avatar-picker__image {
  inline-size: 56px;
  block-size: 56px;
  border-radius: var(--pw-radius-full);
  object-fit: cover;
  border: 2px solid var(--pw-border-strong);
}

.pw-avatar-picker__note {
  margin-block-start: var(--pw-space-2);
  color: var(--pw-text-muted);
  font-size: var(--pw-text-xs);
}

.pw-avatar-picker__error:not(:empty) {
  margin-block-start: var(--pw-space-2);
  color: var(--pw-danger);
  font-size: var(--pw-text-sm);
  font-weight: var(--pw-weight-medium);
}

/* ---------------------------------------------------------------------------
   Wizard stepper
   --------------------------------------------------------------------------- */

.pw-stepper__summary {
  color: var(--pw-text-muted);
  font-size: var(--pw-text-xs);
  font-weight: var(--pw-weight-medium);
  letter-spacing: var(--pw-tracking-wide);
  text-transform: uppercase;
}

.pw-stepper__list {
  display: flex;
  gap: var(--pw-space-1);
  margin-block-start: var(--pw-space-2);
}

.pw-stepper__step {
  flex: 1;
}

.pw-stepper__marker {
  display: block;
  block-size: 4px;
  border-radius: var(--pw-radius-full);
  background: var(--pw-border);
  transition: background-color var(--pw-duration-base) var(--pw-ease-out);
}

.pw-stepper__step[data-state="done"] .pw-stepper__marker,
.pw-stepper__step[data-state="current"] .pw-stepper__marker {
  background: var(--pw-primary);
}

/* Labels are for assistive tech and wide screens; the bar carries it on mobile. */
.pw-stepper__label {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Demo-data notice — required, never dismissible
   --------------------------------------------------------------------------- */

.pw-demo-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--pw-space-2);
  padding: var(--pw-space-3) var(--pw-space-4);
  border: 1px solid color-mix(in srgb, var(--pw-accent) 40%, transparent);
  border-radius: var(--pw-radius-md);
  background: var(--pw-accent-tint);
  color: var(--pw-text);
  font-size: var(--pw-text-sm);
}

.pw-demo-notice__icon {
  flex: none;
  margin-block-start: 2px;
  color: var(--pw-accent);
}

.pw-demo-tag {
  display: inline-block;
  padding: 1px var(--pw-space-2);
  border-radius: var(--pw-radius-full);
  background: var(--pw-accent-tint);
  color: var(--pw-accent);
  font-size: var(--pw-text-2xs);
  font-weight: var(--pw-weight-semibold);
  letter-spacing: var(--pw-tracking-wide);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------------
   Loading, empty, error
   --------------------------------------------------------------------------- */

.pw-loading__skeletons {
  display: grid;
  gap: var(--pw-space-3);
}

.pw-skeleton {
  block-size: 120px;
  border-radius: var(--pw-radius-lg);
  background: linear-gradient(
    90deg,
    var(--pw-surface-sunken) 25%,
    var(--pw-bg-subtle) 50%,
    var(--pw-surface-sunken) 75%
  );
  background-size: 200% 100%;
  animation: pw-shimmer var(--pw-duration-slow) linear infinite;
}

@keyframes pw-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.pw-empty-state,
.pw-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pw-space-3);
  padding: var(--pw-space-7) var(--pw-space-4);
  border: 1px dashed var(--pw-border-strong);
  border-radius: var(--pw-radius-lg);
  text-align: center;
}

.pw-empty-state__icon {
  inline-size: 32px;
  block-size: 32px;
  color: var(--pw-text-muted);
}

.pw-empty-state__title,
.pw-error-state__title {
  font-weight: var(--pw-weight-semibold);
}

.pw-empty-state__body,
.pw-error-state__body {
  max-inline-size: 44ch;
  color: var(--pw-text-secondary);
  font-size: var(--pw-text-sm);
}

/* ---------------------------------------------------------------------------
   Language and theme controls
   --------------------------------------------------------------------------- */

/* The language control is a globe button with a menu under it — see
   js/components/language-menu.js for why it is not a <select>.

   The wrapper is sized like the button it contains, so the empty placeholder in
   index.html occupies exactly the space the real control takes and the header
   does not jump when JavaScript mounts it. */
.pw-language {
  position: relative;
  inline-size: var(--pw-target-min);
  block-size: var(--pw-target-min);
}

.pw-language__menu {
  display: flex;
  flex-direction: column;
  position: absolute;
  inset-block-start: calc(100% + var(--pw-space-1));
  /* Anchored to the end edge: the control sits at the end of the header, so a
     menu growing the other way is the only one that stays on a 320px screen. */
  inset-inline-end: 0;
  z-index: 30;
  min-inline-size: 12rem;
  padding: var(--pw-space-1);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-md);
  background: var(--pw-surface);
  box-shadow: var(--pw-shadow-md);
}

/* `hidden` is how the menu closes, and the `display: flex` above would override
   it — the attribute's UA style is only `display: none` at the lowest priority,
   so closing has to be said again here. */
.pw-language__menu[hidden] {
  display: none;
}

.pw-language__item {
  display: flex;
  align-items: center;
  gap: var(--pw-space-2);
  inline-size: 100%;
  min-block-size: var(--pw-target-min);
  padding-inline: var(--pw-space-2);
  border: 0;
  border-radius: var(--pw-radius-sm);
  background: transparent;
  color: var(--pw-text);
  font-size: var(--pw-text-sm);
  text-align: start;
  white-space: nowrap;
}

.pw-language__item:hover {
  background: var(--pw-bg-subtle);
}

.pw-language__item[aria-checked="true"] {
  font-weight: var(--pw-weight-medium);
  color: var(--pw-primary);
}

/* Reserved whether or not the tick is there, so the language names line up
   instead of shifting sideways as the selection moves. */
.pw-language__check {
  display: inline-grid;
  place-items: center;
  inline-size: 1rem;
  flex: none;
}

.pw-language__check .pw-icon {
  inline-size: 1rem;
  block-size: 1rem;
}
