/* Screenourish shared components. Requires tokens.css. Every interactive component defines
 * default, hover, focus-visible, active, disabled, loading and error states (design.md rule).
 * Pill shapes (radius-xl) are for actions and navigation; radius-md for containers; radius-sm for inputs.
 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-family-primary);
  font-size: var(--font-size-lg);
  line-height: var(--line-height-base);
  font-weight: var(--font-weight-base);
  color: rgb(var(--text-primary));
  background: rgb(var(--surface-base));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.container-page { width: 100%; max-width: var(--container-max); margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }

/* ---- focus: never hidden ---- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgb(var(--focus-ring));
  outline-offset: 2px;
}
.skip-link { position: absolute; left: 12px; top: -64px; z-index: 100; padding: 10px 16px; border-radius: var(--radius-xl);
  background: rgb(var(--action-bg)); color: rgb(var(--action-text)); font-weight: var(--font-weight-semibold); }
.skip-link:focus { top: 12px; }

/* ---- brand lockup: lime play-triangle + SCREEN(heavy)OURISH(light) ---- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: rgb(var(--text-primary)); text-decoration: none; }
.brand-mark { display: inline-block; flex: none; width: 1.15em; height: 1.3em; background: rgb(var(--brand-lime));
  clip-path: polygon(0 0, 100% 50%, 0 100%); }
.wordmark { font-size: 1.25rem; letter-spacing: -0.045em; line-height: 1; text-transform: uppercase; }
.wordmark b { font-weight: var(--font-weight-heavy); }
.wordmark span { font-weight: var(--font-weight-light); }
.brand-lg .wordmark { font-size: 1.75rem; }

/* ---- buttons ---- */
.btn { --btn-bg: transparent; --btn-fg: rgb(var(--text-primary)); --btn-bd: rgb(var(--border-strong));
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 22px;
  border: 1px solid var(--btn-bd); border-radius: var(--radius-xl); background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--motion-duration-fast) var(--motion-ease), border-color var(--motion-duration-fast) var(--motion-ease),
    color var(--motion-duration-fast) var(--motion-ease), transform var(--motion-duration-instant) var(--motion-ease); }
.btn:hover { --btn-bg: rgb(var(--surface-muted)); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; pointer-events: none; }
.btn[aria-busy="true"], .btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after, .btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent; animation: so-spin 700ms linear infinite; }
.btn.is-error { --btn-bd: rgb(var(--state-danger-text)); }
.btn-primary { --btn-bg: rgb(var(--action-bg)); --btn-fg: rgb(var(--action-text)); --btn-bd: transparent; }
.btn-primary:hover { --btn-bg: rgb(var(--action-bg-hover)); }
.btn-accent { --btn-bg: rgb(var(--accent-bg)); --btn-fg: rgb(var(--accent-text)); --btn-bd: transparent; }
.btn-accent:hover { --btn-bg: rgb(var(--accent-bg-hover)); }
.btn-accent:active { --btn-bg: rgb(var(--accent-bg-active)); }
.btn-ghost { --btn-bd: transparent; }
.btn-danger { --btn-fg: rgb(var(--state-danger-text)); --btn-bd: rgb(var(--state-danger-text)); }
.btn-danger:hover { --btn-bg: rgb(var(--state-danger-bg)); }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: var(--font-size-sm); }
.btn-lg { min-height: 52px; padding: 0 32px; font-size: var(--font-size-xl); }
.btn-icon { min-width: 44px; padding: 0; }
.btn-icon.btn-sm { min-width: 36px; }
@keyframes so-spin { to { transform: rotate(360deg); } }

/* ---- form fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: rgb(var(--text-primary)); }
.field-hint { font-size: var(--font-size-xs); color: rgb(var(--text-muted)); }
.field-error { font-size: var(--font-size-xs); color: rgb(var(--state-danger-text)); }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 14px; font: inherit; font-size: var(--font-size-md); color: rgb(var(--text-primary));
  background: rgb(var(--surface-base)); border: 1px solid rgb(var(--border-strong)); border-radius: var(--radius-sm);
  transition: border-color var(--motion-duration-fast) var(--motion-ease), background-color var(--motion-duration-fast) var(--motion-ease); }
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: rgb(var(--text-muted)); }
.input:hover, .select:hover, .textarea:hover { border-color: rgb(var(--text-secondary)); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline-offset: 0; border-color: rgb(var(--focus-ring)); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; background: rgb(var(--surface-muted)); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: rgb(var(--state-danger-text)); }
.input-pill { border-radius: var(--radius-xl); padding-inline: 20px; }
.check { width: 18px; height: 18px; accent-color: rgb(var(--action-bg)); }

/* ---- surfaces ---- */
.card { background: rgb(var(--surface-raised)); border: 1px solid rgb(var(--border-default)); border-radius: var(--radius-md); }
.card-pad { padding: var(--space-10); }
.card-muted { background: rgb(var(--surface-subtle)); border-color: transparent; }
.card-link { display: block; color: inherit; text-decoration: none;
  transition: border-color var(--motion-duration-fast) var(--motion-ease), transform var(--motion-duration-fast) var(--motion-ease); }
.card-link:hover { border-color: rgb(var(--border-strong)); }
.card-link:active { transform: translateY(1px); }
.divider { height: 1px; background: rgb(var(--border-default)); border: 0; }

/* ---- badges / chips ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-xl); font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold); background: rgb(var(--surface-muted)); color: rgb(var(--text-secondary)); }
.badge-ok { background: rgb(var(--state-success-bg)); color: rgb(var(--state-success-text)); }
.badge-warn { background: rgb(var(--state-warning-bg)); color: rgb(var(--state-warning-text)); }
.badge-bad { background: rgb(var(--state-danger-bg)); color: rgb(var(--state-danger-text)); }
.badge-brand { background: rgb(var(--brand-lime)); color: rgb(var(--brand-forest)); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 16px; border: 1px solid rgb(var(--border-strong)); border-radius: var(--radius-xl);
  background: transparent; color: rgb(var(--text-primary)); font: inherit; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); cursor: pointer;
  transition: background-color var(--motion-duration-fast) var(--motion-ease), border-color var(--motion-duration-fast) var(--motion-ease); }
.chip:hover { background: rgb(var(--surface-muted)); }
.chip[aria-pressed="true"], .chip.is-active { background: rgb(var(--action-bg)); color: rgb(var(--action-text)); border-color: transparent; }

/* ---- tabs (pill nav) ---- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius-xl); background: transparent;
  color: rgb(var(--text-secondary)); font: inherit; font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); white-space: nowrap; cursor: pointer;
  transition: background-color var(--motion-duration-fast) var(--motion-ease), color var(--motion-duration-fast) var(--motion-ease); }
.tab:hover { background: rgb(var(--surface-muted)); color: rgb(var(--text-primary)); }
.tab[aria-selected="true"], .tab.active { background: rgb(var(--brand-lime)); color: rgb(var(--brand-forest)); }
:root[data-theme="dark"] .tab[aria-selected="true"], :root[data-theme="dark"] .tab.active { color: rgb(12 26 24); }

/* ---- header ---- */
.site-header { position: sticky; top: 0; z-index: 40; background: rgb(var(--surface-base) / 0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgb(var(--border-default)); }
.site-header-inner { display: flex; align-items: center; gap: 16px; min-height: var(--header-height); }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgb(var(--surface-overlay) / 0.6); backdrop-filter: blur(4px); }
.modal-backdrop.hidden { display: none; }
.modal { width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; background: rgb(var(--surface-raised));
  border: 1px solid rgb(var(--border-default)); border-radius: var(--radius-md); box-shadow: var(--shadow-overlay); }
.modal-lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid rgb(var(--border-default)); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid rgb(var(--border-default)); }

/* ---- feedback ---- */
.alert { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: var(--font-size-sm);
  background: rgb(var(--state-info-bg)); color: rgb(var(--state-info-text)); }
.alert-ok { background: rgb(var(--state-success-bg)); color: rgb(var(--state-success-text)); }
.alert-warn { background: rgb(var(--state-warning-bg)); color: rgb(var(--state-warning-text)); }
.alert-bad { background: rgb(var(--state-danger-bg)); color: rgb(var(--state-danger-text)); }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: var(--radius-md); background: rgb(var(--surface-inverse)); color: rgb(var(--text-inverse)); font-size: var(--font-size-sm);
  box-shadow: var(--shadow-overlay); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; text-align: center; color: rgb(var(--text-secondary)); }
.empty-title { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); color: rgb(var(--text-primary)); }
.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, rgb(var(--surface-muted)) 25%, rgb(var(--surface-strong)) 50%, rgb(var(--surface-muted)) 75%);
  background-size: 200% 100%; animation: so-shimmer 1.4s linear infinite; }
@keyframes so-shimmer { to { background-position: -200% 0; } }

/* ---- prose helpers ---- */
.link { color: rgb(var(--text-link)); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { text-decoration-thickness: 2px; }
.text-balance { text-wrap: balance; }
.measure { max-width: 68ch; }
.code { font-family: var(--font-family-mono); font-size: var(--font-size-sm); background: rgb(var(--surface-muted)); border-radius: var(--radius-sm); padding: 2px 6px; }
.pre { font-family: var(--font-family-mono); font-size: var(--font-size-sm); line-height: 1.6; background: rgb(var(--surface-inverse)); color: rgb(var(--text-inverse));
  border-radius: var(--radius-md); padding: 16px 20px; overflow: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* screen player picker: chips, suggestion lists and design cards */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: rgb(var(--surface-muted)); border: 1px solid rgb(var(--border-default)); font-size: 0.875rem; color: rgb(var(--text-primary)); }
.chip button { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px; color: rgb(var(--text-secondary)); }
.chip button:hover { background: rgb(var(--border-default)); }
.suggest { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 30; max-height: 16rem; overflow: auto; padding: 4px; list-style: none; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
.suggest button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 0.875rem; color: rgb(var(--text-primary)); }
.suggest button:hover, .suggest button[aria-selected="true"] { background: rgb(var(--surface-muted)); }
.suggest .sub { display: block; font-size: 0.75rem; color: rgb(var(--text-muted)); }
.design-card { display: flex; flex-direction: column; gap: 8px; padding: 8px; text-align: left; border-radius: var(--radius-md); background: rgb(var(--surface-raised)); border: 2px solid rgb(var(--border-default)); cursor: pointer; }
.design-card:hover { border-color: rgb(var(--text-muted)); }
.design-card[aria-checked="true"] { border-color: rgb(var(--action-bg)); background: rgb(var(--surface-muted)); }
.design-card .dt { position: relative; aspect-ratio: 16 / 10; border-radius: 6px; overflow: hidden; background: #10201d; }
.design-card .dt i { position: absolute; display: block; border-radius: 2px; }
.design-card .dn { font-size: 0.875rem; font-weight: 600; color: rgb(var(--text-primary)); }
.design-card .dd { font-size: 0.75rem; color: rgb(var(--text-muted)); line-height: 1.3; }

