/* Welly components (DESIGN.md §4), reimplemented for server-rendered Twig.
   Class prefix wl-; variants are data-* attributes. Tokens only. */

/* The type sizes from tokens.css (rem) times the member's text size (docs/plans/wcag/01-text-size.md):
   the text-size buttons set data-text-size on <html> before first paint. Keep the rem values the same
   as tokens.css. */
:root { --text-scale: 1;
  --text-xs: calc(.75rem * var(--text-scale)); --text-sm: calc(.875rem * var(--text-scale)); --text-md: calc(1rem * var(--text-scale));
  --text-lg: calc(1.125rem * var(--text-scale)); --text-xl: calc(1.375rem * var(--text-scale)); --text-2xl: calc(1.75rem * var(--text-scale));
  --text-3xl: calc(2.25rem * var(--text-scale)); --text-4xl: calc(3rem * var(--text-scale)); --text-5xl: calc(4rem * var(--text-scale)); }
:root[data-text-size="1"] { --text-scale: 1.125; }
:root[data-text-size="2"] { --text-scale: 1.25; }
:root[data-text-size="3"] { --text-scale: 1.5; }


/* the hidden attribute always wins over a component's display value */
[hidden] { display: none !important; }

/* Icon: Lucide outline via the sprite in partials/icons.html.twig */
.wl-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.wl-icon { flex: none; display: inline-block; vertical-align: middle; width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.wl-icon[data-size="16"] { width: 16px; height: 16px; }
.wl-icon[data-size="18"] { width: 18px; height: 18px; }
.wl-icon[data-size="24"] { width: 24px; height: 24px; }

/* Button */
.wl-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h-md); padding: 0 var(--space-5); border: 1px solid transparent;
  border-radius: var(--radius-control); font: var(--type-label); cursor: pointer; white-space: nowrap;
  text-decoration: none; user-select: none;
  transition: var(--transition-color), transform var(--dur-fast) var(--ease-standard); }
.wl-btn:hover { text-decoration: none; }
.wl-btn:active { transform: scale(var(--press-scale)); }
.wl-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wl-btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; }
.wl-btn[data-size="sm"] { min-height: var(--control-h-sm); padding: 0 var(--space-3); }
.wl-btn[data-size="lg"] { min-height: var(--control-h-lg); padding: 0 var(--space-6); font-size: var(--text-md); }
.wl-btn[data-full="true"] { width: 100%; }
.wl-btn[data-variant="primary"] { background: var(--accent); color: var(--text-on-accent); }
.wl-btn[data-variant="primary"]:hover:not([disabled]) { background: var(--accent-hover); color: var(--text-on-accent); }
.wl-btn[data-variant="primary"]:active { background: var(--accent-active); }
.wl-btn[data-variant="secondary"] { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.wl-btn[data-variant="ghost"] { background: transparent; color: var(--text-primary); }
.wl-btn[data-variant="secondary"]:hover:not([disabled]),
.wl-btn[data-variant="ghost"]:hover:not([disabled]) { background: var(--surface-sunken); color: var(--text-primary); }

/* IconButton: square, accessible name required */
.wl-ibtn { display: inline-grid; place-items: center; width: var(--control-h-md); height: var(--control-h-md);
  padding: 0; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent;
  color: var(--text-primary); cursor: pointer;
  transition: var(--transition-color), transform var(--dur-fast) var(--ease-standard); }
.wl-ibtn:hover { background: var(--surface-sunken); color: var(--text-primary); text-decoration: none; }
.wl-ibtn:active { transform: scale(var(--press-scale)); }
.wl-ibtn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wl-ibtn[data-variant="outline"] { border-color: var(--border-strong); }

/* Input */
.wl-field { display: flex; flex-direction: column; gap: var(--space-2); }
.wl-field > label { font: var(--type-label); color: var(--text-primary); }
.wl-field .wl-hint { font: var(--type-caption); color: var(--text-secondary); }
.wl-field[data-invalid="true"] .wl-hint { color: var(--danger-fg); }
.wl-inwrap { position: relative; display: flex; align-items: center; }
.wl-inwrap > .wl-adorn { position: absolute; left: var(--space-3); display: grid; color: var(--text-muted); pointer-events: none; }
.wl-input { width: 100%; min-height: var(--control-h-md); padding: 0 var(--space-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-control); background: var(--surface-card); color: var(--text-primary); font: var(--type-body);
  transition: var(--transition-color), box-shadow var(--dur-fast); }
.wl-inwrap > .wl-adorn + .wl-input { padding-left: var(--space-10); }
.wl-input::placeholder { color: var(--text-muted); }
.wl-input:hover { border-color: var(--text-muted); }
.wl-input:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--focus-ring); }
.wl-field[data-invalid="true"] .wl-input { border-color: var(--danger); }
/* Select: native select styled like Input, with a chevron in place of the browser arrow */
.wl-select { appearance: none; -webkit-appearance: none; padding-right: var(--space-10); cursor: pointer; }
.wl-select:disabled { cursor: not-allowed; opacity: .6; background: var(--surface-sunken); }
.wl-select-chevron { position: absolute; right: var(--space-3); display: grid; color: var(--text-secondary); pointer-events: none; }

/* Checkbox: gold-filled square */
.wl-check { position: relative; display: inline-flex; align-items: flex-start; gap: var(--space-3); min-height: var(--space-6);
  font: var(--type-body-sm); color: var(--text-primary); cursor: pointer; }
.wl-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.wl-check .box { flex: none; display: grid; place-items: center; width: var(--space-5); height: var(--space-5);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-card);
  transition: var(--transition-color); }
.wl-check:hover .box { border-color: var(--text-muted); }
.wl-check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.wl-check input:focus-visible + .box { box-shadow: var(--focus-ring); }
.wl-check .box svg { display: none; width: 14px; height: 14px; fill: none; stroke: var(--text-on-accent);
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.wl-check input:checked + .box svg { display: block; }

/* Radio / RadioGroup; data-card="true" renders each option as a bordered card */
.wl-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.wl-fieldset-legend { padding: 0; margin-bottom: var(--space-2); font: var(--type-label); color: var(--text-primary); }
.wl-fieldset .wl-hint { margin-top: var(--space-2); font: var(--type-caption); color: var(--text-secondary); }
.wl-fieldset[data-invalid="true"] .wl-hint { color: var(--danger-fg); }
.wl-radios { display: grid; gap: var(--space-3); }
.wl-radio { position: relative; display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch-min);
  font: var(--type-body); color: var(--text-primary); cursor: pointer; }
.wl-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.wl-radio .dot { flex: none; width: 22px; height: 22px; border: 1.5px solid var(--border-strong); border-radius: 50%;
  background: var(--surface-card); transition: var(--transition-color); }
.wl-radio:hover .dot { border-color: var(--text-muted); }
.wl-radio input:checked + .dot { border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface-card); }
.wl-radio input:focus-visible + .dot { box-shadow: inset 0 0 0 4px var(--surface-card), var(--focus-ring); }
.wl-radio[data-card="true"] { padding: var(--space-3) var(--space-4); border: 1px solid var(--border-strong);
  border-radius: var(--radius-card); background: var(--surface-card); }
.wl-radio[data-card="true"]:hover { border-color: var(--text-muted); }
.wl-radio[data-card="true"]:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.wl-radio[data-card="true"]:has(input:checked) .dot { box-shadow: inset 0 0 0 4px var(--accent-soft); }
@media (min-width: 600px) {
  .wl-radios { grid-template-columns: repeat(2, 1fr); }
}

/* Tabs: underline variant with the gold indicator (DESIGN.md §4). Tabs may be links (?tab=...)
   that the page script switches in place; the strip scrolls sideways when it outgrows the screen. */
.wl-tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto; scrollbar-width: none; }
.wl-tabs::-webkit-scrollbar { display: none; }
.wl-tab { position: relative; flex: none; display: inline-flex; align-items: center; min-height: var(--control-h-md);
  padding: 0 var(--space-1); border: 0; background: none; color: var(--text-secondary); font: var(--type-label);
  text-decoration: none; white-space: nowrap; cursor: pointer; transition: var(--transition-color); }
.wl-tab:hover { color: var(--text-primary); text-decoration: none; }
.wl-tab[aria-selected="true"] { color: var(--text-primary); }
.wl-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); }
.wl-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }

/* ThemeToggle: segmented light/dark */
.wl-theme { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); background: var(--surface-sunken); }
.wl-theme button { display: inline-grid; place-items: center; min-height: 30px; padding: 0 var(--space-3); border: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font: var(--type-label);
  cursor: pointer; transition: var(--transition-color); }
.wl-theme button[aria-pressed="true"] { background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.wl-theme button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* TextSize: smaller/larger text in the theme toggle's look. Actions, not states: no pressed look;
   the button at the end of the scale is aria-disabled (still focusable, so focus is not lost). */
.wl-textsize button:hover:not([aria-disabled="true"]) { color: var(--text-primary); }
.wl-textsize button[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }

/* Card: flat, 1px border, no shadow */
.wl-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--surface-card); color: var(--text-primary); }
.wl-card[data-padding="md"] { padding: var(--space-5); }
.wl-card[data-padding="lg"] { padding: var(--space-8); }
.wl-card[data-tone="sunken"] { background: var(--surface-sunken); }
.wl-card[data-tone="inverse"] { background: var(--surface-inverse); color: var(--text-inverse); border-color: transparent; }

/* Badge: small uppercase status label, 2px radius, never pill */
.wl-badge { display: inline-flex; align-items: center; height: var(--space-5); padding: 0 var(--space-2);
  border-radius: var(--radius-badge); font: var(--type-eyebrow); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; white-space: nowrap; background: var(--surface-sunken); color: var(--text-secondary); }
.wl-badge[data-tone="accent"] { background: var(--accent-soft); color: var(--accent-soft-fg); }
.wl-badge[data-tone="inverse"] { background: var(--surface-inverse); color: var(--text-inverse); }
.wl-badge[data-tone="info"] { background: var(--info-soft); color: var(--info-fg); }

/* a link or span styled as a button that cannot be used */
.wl-btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* Inline status message (error on a form) */
.wl-alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control); font: var(--type-body-sm); }
.wl-alert[data-tone="danger"] { background: var(--danger-soft); color: var(--danger-fg); }
.wl-alert[data-tone="success"] { background: var(--success-soft); color: var(--success-fg); }

/* SkipLink: first on the page, shown when it has focus (WCAG 2.4.1) */
.wl-skip { position: absolute; left: var(--space-4); top: calc(var(--space-4) * -4); z-index: 100; padding: var(--space-2) var(--space-4);
  background: var(--surface-inverse); color: var(--text-inverse); border-radius: var(--radius-control); font: var(--type-label); }
.wl-skip:focus { top: calc(var(--space-4) + env(safe-area-inset-top)); color: var(--text-inverse); }

.wl-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Dialog (DESIGN.md §4): centred, flat-bordered with the floating-layer shadow; a sheet from the
   bottom on phones. The app's first dialog is the session warning. */
.wl-dlg { width: calc(100% - 2 * var(--gutter-mobile)); max-width: calc(var(--space-24) * 5); margin: auto; padding: 0;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); color: var(--text-primary);
  box-shadow: var(--shadow-lg); }
.wl-dlg::backdrop { background: var(--surface-overlay); }
.wl-dlg-body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); }
.wl-dlg-body h2 { margin: 0; font: var(--type-h3); }
.wl-dlg-body p { margin: 0; font: var(--type-body); color: var(--text-secondary); }
@media (max-width: 699px) {
  .wl-dlg { width: 100%; max-width: none; margin: auto 0 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; border-bottom: 0; }
  .wl-dlg-body { padding: var(--space-6) var(--gutter-mobile) max(var(--space-6), env(safe-area-inset-bottom)); }
}

/* the sandbox's band at the top of every page (docs/plans/resellerapi/) */
.wl-sandbox-band { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin: 0;
  padding: var(--space-2) var(--space-4); background: var(--warning-soft); color: var(--warning-fg);
  border-bottom: 1px solid var(--warning); font: var(--type-body-sm); text-align: center; }
.wl-sandbox-band .wl-icon { flex: none; }
