/*
 * OneQode Design System - Recipe CSS
 *
 * Hand-authored CSS patterns that compose design tokens into stable class names.
 * Patterns are added as individual files (button.css, card.css, etc.) and
 * concatenated into build/css/recipes.css by scripts/build-tokens.mjs.
 *
 * See CLAUDE.md ("Adding a New Recipe") for the workflow.
 */

/*
 * Alert recipe
 *
 * An inline message band for form errors, confirmations, and notices. Tinted
 * fill plus a hairline border in the matching hue; text carries the intent
 * colour so any .oq-icon inside inherits it through currentColor.
 *
 * Usage:
 *   <div class="oq-alert oq-alert--error" role="alert">
 *     Incorrect email or password.
 *   </div>
 *
 *   <div class="oq-alert oq-alert--success" role="status">
 *     <span class="oq-icon oq-icon--sm"><svg …></svg></span>
 *     <div>
 *       <strong class="oq-alert__title">Email verified</strong>
 *       You can sign in now.
 *     </div>
 *   </div>
 *
 * Variants: .oq-alert--error .oq-alert--success .oq-alert--warning
 *           .oq-alert--info  .oq-alert--neutral
 *
 * Use role="alert" for errors that interrupt, role="status" for confirmations.
 */

.oq-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--component-alert-gap);
  padding: var(--component-alert-padding-y) var(--component-alert-padding-x);
  border: var(--border-width-sm) solid transparent;
  border-radius: var(--component-alert-radius);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
}

/* Icons and links inside an alert take the intent colour */
.oq-alert .oq-icon { color: currentColor; }
.oq-alert a {
  color: currentColor;
  text-decoration: underline;
}

.oq-alert__title {
  display: block;
  font-weight: var(--font-weight-semibold);
}

.oq-alert--error {
  background-color: var(--component-alert-error-bg);
  border-color: var(--component-alert-error-border);
  color: var(--component-alert-error-text);
}

.oq-alert--success {
  background-color: var(--component-alert-success-bg);
  border-color: var(--component-alert-success-border);
  color: var(--component-alert-success-text);
}

.oq-alert--warning {
  background-color: var(--component-alert-warning-bg);
  border-color: var(--component-alert-warning-border);
  color: var(--component-alert-warning-text);
}

.oq-alert--info {
  background-color: var(--component-alert-info-bg);
  border-color: var(--component-alert-info-border);
  color: var(--component-alert-info-text);
}

.oq-alert--neutral {
  background-color: var(--component-alert-neutral-bg);
  border-color: var(--component-alert-neutral-border);
  color: var(--component-alert-neutral-text);
}

/*
 * Button Group (Segmented Control) recipe
 *
 * A pill-shaped tab strip for switching between two or more named views.
 * Figma source: node 3830:32142 ("ButtonGroup") in OneQode 2026.
 *
 * Usage:
 *   <div class="oq-button-group" role="group" aria-label="View">
 *     <button class="oq-button-group__item oq-button-group__item--active"
 *             aria-pressed="true">Overview</button>
 *     <button class="oq-button-group__item"
 *             aria-pressed="false">Details</button>
 *   </div>
 *
 * - Use role="group" + aria-label on the container.
 * - Use aria-pressed="true" on the active item (works with native <button>).
 * - .oq-button-group__item--active and [aria-pressed="true"] are equivalent -
 *   either can drive the active appearance.
 */

/* Container */
.oq-button-group {
  display: inline-flex;
  flex-direction: row;
  align-items: stretch;
  gap: var(--spacing-1);
  padding: var(--spacing-1);
  border-radius: var(--radius-lg);
  background-color: var(--color-surface-bg);
  border: var(--border-width-sm) solid var(--color-border-default);
}

/* Segment (inactive default) */
.oq-button-group__item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-block: 0;
  padding-inline: var(--spacing-6);
  block-size: var(--spacing-8);
  border-radius: var(--radius-md);
  border: var(--border-width-sm) solid transparent;
  background-color: transparent;
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--font-size-12);
  line-height: var(--font-line-height-body);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--font-letter-spacing-mono);
  cursor: pointer;
  transition:
    background-color var(--motion-duration-fast) var(--motion-easing-standard),
    border-color var(--motion-duration-fast) var(--motion-easing-standard),
    color var(--motion-duration-fast) var(--motion-easing-standard);
}

/* Active segment - modifier class */
.oq-button-group__item--active,
.oq-button-group__item[aria-pressed="true"] {
  background-color: var(--color-surface-muted);
  border-color: var(--color-border-strong);
  color: var(--color-text-headings);
}

/* Hover - inactive segments only */
.oq-button-group__item:not(.oq-button-group__item--active):not([aria-pressed="true"]):hover {
  border-color: var(--color-border-strong);
  color: var(--color-text-headings);
}

/*
 * Button recipe
 *
 * A full-width-capable CTA button matching the OneQode Figma button spec.
 * Works on <button>, <a>, or <input type="submit">. No oq- prefix - the
 * website already uses .btn markup on 10+ components.
 *
 * Usage:
 *   <button class="btn btn--default">Get started</button>
 *   <a class="btn btn--outline" href="/contact">Contact us</a>
 *   <button class="btn btn--shade">Learn more</button>
 *   <button class="btn btn--accent">Deploy now</button>
 *   <button class="btn btn--ghost">See all</button>
 *
 * Variants: .btn--default  solid white CTA (on dark backgrounds)
 *           .btn--outline   hairline border, transparent fill
 *           .btn--shade     frosted-glass wash with backdrop blur
 *           .btn--accent    brand blue CTA
 *           .btn--ghost     text-only, no fill or border
 *
 * Disabled: add the disabled attribute or aria-disabled="true". All pointer
 * interactions are suppressed and hover styles do not apply.
 */

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  block-size: var(--component-button-height);
  min-inline-size: var(--component-button-min-width);
  padding: var(--component-button-padding-top)
           var(--component-button-padding-x)
           var(--component-button-padding-bottom)
           var(--component-button-padding-x);
  gap: var(--component-button-gap);
  border-radius: var(--component-button-radius);
  border: var(--border-width-sm) solid transparent;
  font-family: var(--font-sans);
  font-size: var(--font-size-16);
  font-weight: var(--component-button-font-weight);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--motion-duration-fast) var(--motion-easing-standard),
    border-color var(--motion-duration-fast) var(--motion-easing-standard),
    color var(--motion-duration-fast) var(--motion-easing-standard);

  /* Disabled state - all variants */
  &:disabled,
  &[aria-disabled="true"] {
    background-color: var(--component-button-disabled-bg);
    color: var(--component-button-disabled-text);
    border-color: var(--component-button-disabled-bg);
    cursor: not-allowed;
    pointer-events: none;
  }
}

/* Default variant - solid white CTA on dark backgrounds */
.btn--default {
  background-color: var(--component-button-default-bg);
  color: var(--component-button-default-text);
  border-color: var(--component-button-default-bg);

  &:not(:disabled):not([aria-disabled="true"]):hover {
    opacity: 0.9;
  }
}

/* Outline variant - hairline border, transparent fill */
.btn--outline {
  background-color: transparent;
  color: var(--component-button-outline-text);
  border-color: var(--component-button-outline-border);

  &:not(:disabled):not([aria-disabled="true"]):hover {
    border-color: var(--component-button-outline-border-hover);
  }
}

/* Shade variant - frosted-glass wash with backdrop blur */
.btn--shade {
  background-color: var(--component-button-shade-bg);
  color: var(--component-button-shade-text);
  backdrop-filter: blur(var(--component-button-shade-blur));

  &:not(:disabled):not([aria-disabled="true"]):hover {
    background-color: var(--component-button-shade-hover-bg);
  }
}

/* Accent variant - brand blue CTA */
.btn--accent {
  background-color: var(--component-button-accent-bg);
  color: var(--component-button-accent-text);
  border-color: var(--component-button-accent-bg);

  &:not(:disabled):not([aria-disabled="true"]):hover {
    background-color: var(--component-button-accent-hover-bg);
    border-color: var(--component-button-accent-hover-bg);
  }
}

/* Ghost variant - text-only, no fill or border */
.btn--ghost {
  background-color: transparent;
  color: var(--component-button-ghost-text);
  border-color: transparent;

  &:not(:disabled):not([aria-disabled="true"]):hover {
    background-color: color-mix(in srgb, currentColor 8%, transparent);
  }
}

/*
 * Card recipe
 *
 * A hairline-bordered panel. The house style is a 1px border and no shadow -
 * elevation is expressed by surface tint, not by drop shadow. .oq-card--raised
 * is the exception, for panels that genuinely float (menus, popovers).
 *
 * Usage:
 *   <div class="oq-card">
 *     <h2 class="oq-card__title">Two-factor authentication</h2>
 *     <p class="oq-card__subtitle">Add a second step to every sign-in.</p>
 *     …
 *   </div>
 *
 * Variants: (default)          page-surface fill, hairline border
 *           .oq-card--muted    subtle grey fill, for nested or secondary panels
 *           .oq-card--raised   floating panel with a shadow
 *           .oq-card--flush    no padding, for cards whose children own the inset
 */

.oq-card {
  background-color: var(--color-surface-default);
  border: var(--border-width-sm) solid var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: var(--spacing-inset);
}

.oq-card--muted {
  background-color: var(--color-surface-muted);
}

.oq-card--raised {
  background-color: var(--color-surface-raised);
  box-shadow: var(--shadow-dropdown);
}

.oq-card--flush {
  padding: 0;
}

.oq-card__title {
  margin: 0;
  color: var(--color-text-headings);
  font-family: var(--font-display);
  font-size: var(--type-h6-size);
  font-weight: var(--font-weight-semibold);
  line-height: var(--type-h6-line-height);
  letter-spacing: var(--type-h6-letter-spacing);
}

.oq-card__subtitle {
  margin: var(--spacing-2) 0 0;
  color: var(--color-text-tertiary);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
}

/* Full-bleed rule between card sections - cancels the card's inset */
.oq-card__divider {
  margin-block: var(--spacing-inset);
  margin-inline: calc(var(--spacing-inset) * -1);
  border: none;
  border-block-start: var(--border-width-sm) solid var(--color-border-subtle);
}

.oq-card--flush > .oq-card__divider {
  margin-inline: 0;
}

/*
 * Field recipe - labels, text controls, hints, and errors
 *
 * Covers the full anatomy of a form field: the label, the control, and the
 * hint or error message below it. .oq-input applies to <input>, <select>, and
 * <textarea> alike - the element-qualified rules below adjust height and
 * padding where a single-line box is wrong.
 *
 * Field height and radius match the button recipe, so an input stacked above a
 * submit button lines up on both axes.
 *
 * Usage:
 *   <div class="oq-field">
 *     <label class="oq-label" for="email">Email</label>
 *     <input class="oq-input" type="email" id="email" placeholder="you@example.com">
 *     <p class="oq-field__hint">We'll never share this.</p>
 *   </div>
 *
 * Invalid state - add .oq-input--error, or set aria-invalid="true" (equivalent):
 *   <input class="oq-input" aria-invalid="true">
 *   <p class="oq-field__error">Enter a valid email address.</p>
 *
 * Trailing control (password reveal, unit, clear button):
 *   <div class="oq-field__affix">
 *     <input class="oq-input" type="password">
 *     <button class="oq-field__affix-btn" type="button" aria-label="Show password">…</button>
 *   </div>
 */

.oq-field {
  display: flex;
  flex-direction: column;
}

.oq-label {
  display: block;
  margin-block-end: var(--component-field-label-gap);
  color: var(--component-field-label-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-medium);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
}

.oq-input {
  display: block;
  inline-size: 100%;
  block-size: var(--component-field-height);
  padding-block: 0;
  padding-inline: var(--component-field-padding-x);
  border: var(--border-width-sm) solid var(--component-field-border);
  border-radius: var(--component-field-radius);
  background-color: var(--component-field-bg);
  color: var(--component-field-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
  transition:
    border-color var(--motion-duration-fast) var(--motion-easing-standard),
    box-shadow var(--motion-duration-fast) var(--motion-easing-standard);

  &::placeholder {
    color: var(--component-field-placeholder);
  }

  &:hover:not(:disabled):not(:focus) {
    border-color: var(--component-field-border-hover);
  }

  &:focus {
    outline: none;
    border-color: var(--component-field-focus-border);
    box-shadow: 0 0 0 var(--component-field-focus-ring) var(--component-field-focus-ring-color);
  }

  &:disabled {
    background-color: var(--component-field-disabled-bg);
    color: var(--component-field-disabled-text);
    cursor: not-allowed;
  }
}

/* Multi-line and native-multiple controls grow with content */
textarea.oq-input,
select.oq-input[multiple],
select.oq-input[size] {
  block-size: auto;
  padding-block: var(--spacing-2);
}

textarea.oq-input {
  min-block-size: calc(var(--component-field-height) * 2);
  resize: vertical;
}

/* Leave room for the native select indicator */
select.oq-input:not([multiple]):not([size]) {
  padding-inline-end: var(--spacing-8);
}

/* Invalid state */
.oq-input--error,
.oq-input[aria-invalid="true"] {
  border-color: var(--component-field-error-border);

  &:hover:not(:disabled):not(:focus) {
    border-color: var(--component-field-error-border);
  }

  &:focus {
    border-color: var(--component-field-error-border);
    box-shadow: 0 0 0 var(--component-field-focus-ring) var(--component-field-error-ring-color);
  }
}

/* Hint and error messages */
.oq-field__hint,
.oq-field__error {
  margin-block: var(--component-field-hint-gap) 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-12);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
}

.oq-field__hint  { color: var(--component-field-hint-text); }
.oq-field__error { color: var(--color-text-error); }

/* Trailing affix - a button or unit label sitting inside the control */
.oq-field__affix {
  position: relative;
  display: block;

  & > .oq-input {
    padding-inline-end: var(--spacing-10);
  }
}

.oq-field__affix-btn {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: var(--component-field-padding-x);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-icon-subtle);
  font-family: var(--font-sans);
  font-size: var(--font-size-12);
  cursor: pointer;
  transition: color var(--motion-duration-fast) var(--motion-easing-standard);

  &:hover {
    color: var(--color-icon-default);
  }

  &:focus-visible {
    outline: var(--border-width-md) solid var(--component-field-focus-border);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }
}

/* Checkbox and radio - native control tinted to the brand accent */
.oq-checkbox,
.oq-radio {
  inline-size: var(--component-icon-size-md);
  block-size: var(--component-icon-size-md);
  accent-color: var(--color-surface-accent);
  cursor: pointer;

  &:focus-visible {
    outline: var(--border-width-md) solid var(--component-field-focus-border);
    outline-offset: 2px;
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
}

/* Inline label paired with a checkbox or radio */
.oq-check-label {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
  color: var(--color-text-body);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
  cursor: pointer;
}

/*
 * Icon recipe
 *
 * Wraps a Lucide-style stroke SVG (or any SVG that uses stroke="currentColor")
 * and exposes size, stroke weight, and color intent through composable
 * modifier classes. The host element is a <span>; the <svg> sits inside.
 *
 * Usage:
 *   <span class="oq-icon"><svg ...></svg></span>
 *   <span class="oq-icon oq-icon--lg oq-icon--accent"><svg ...></svg></span>
 *
 * SVG must:
 *   - use stroke="currentColor" (Lucide default)
 *   - omit width/height/stroke-width (the recipe owns these)
 */

.oq-icon {
  display: inline-block;
  flex-shrink: 0;
  width:  var(--component-icon-size-md);
  height: var(--component-icon-size-md);
  color:  var(--color-icon-default);
  vertical-align: -0.125em;
}

.oq-icon > svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: var(--component-icon-stroke-regular);
}

/* Sizes */
.oq-icon--xs { width: var(--component-icon-size-xs); height: var(--component-icon-size-xs); }
.oq-icon--sm { width: var(--component-icon-size-sm); height: var(--component-icon-size-sm); }
.oq-icon--lg { width: var(--component-icon-size-lg); height: var(--component-icon-size-lg); }
.oq-icon--xl { width: var(--component-icon-size-xl); height: var(--component-icon-size-xl); }

/* Stroke weights */
.oq-icon--thin > svg { stroke-width: var(--component-icon-stroke-thin); }
.oq-icon--bold > svg { stroke-width: var(--component-icon-stroke-bold); }

/* Color intents */
.oq-icon--accent   { color: var(--color-icon-accent); }
.oq-icon--action   { color: var(--color-icon-action); }
.oq-icon--subtle   { color: var(--color-icon-subtle); }
.oq-icon--disabled { color: var(--color-icon-disabled); }
.oq-icon--inverse  { color: var(--color-icon-inverse); }

.oq-icon--action:hover { color: var(--color-icon-action-hover); }

/* OneQode Design System - Loader recipe
 *
 * Two looping knot marks: an in-page block loader (.oq-loader--block) for
 * content that streams in, and a fixed global nav loader (.oq-navloader) for
 * server round-trips (toggled by html.oq-navloading via the OQMotion
 * navLoader controller). Colours come from the --oq-motion-* contract in
 * motion-theme.css, with hex fallbacks so the loader still renders if that
 * layer loads late or fails. Brand-dark by default in either mode; add
 * data-oq-motion="theme" to follow the app (or device) theme instead.
 */
@keyframes oq-spin { to { transform: rotate(360deg); } }
@keyframes oq-trace { 0% { stroke-dashoffset: 1; } 48% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -1; } }

.oq-loader { display: inline-flex; align-items: center; justify-content: center; }
.oq-loader svg { width: 34px; height: 34px; overflow: visible; animation: oq-spin 2s linear infinite; }
.oq-loader svg path {
  fill: none; stroke: var(--oq-motion-ink, #fafafa); stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: oq-trace 1.7s ease-in-out infinite;
}
.oq-loader--block { flex-direction: column; gap: 14px; padding: 56px 0; }
.oq-loader--block svg { width: 46px; height: 46px; }
.oq-loader__label {
  font-family: var(--font-display, sans-serif); font-size: .72rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--oq-motion-ink-muted, #c7c7c7);
}

.oq-navloader {
  position: fixed; z-index: 9998; right: 22px; bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 15px 8px 11px;
  background: var(--oq-motion-panel-bg, #0d0d0d); border: 1px solid var(--oq-motion-panel-border, #1f1f1f);
  border-radius: 999px; box-shadow: var(--oq-motion-panel-shadow, 0 6px 22px rgba(0,0,0,.10));
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
html.oq-navloading .oq-navloader { opacity: 1; transform: translateY(0); }
.oq-navloader svg { width: 22px; height: 22px; overflow: visible; animation: oq-spin 2s linear infinite; }
.oq-navloader svg path {
  fill: none; stroke: var(--oq-motion-ink, #fafafa); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: oq-trace 1.7s ease-in-out infinite;
}
.oq-navloader__label {
  font-family: var(--font-display, sans-serif); font-size: .7rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--oq-motion-ink-muted, #c7c7c7);
}

@media (prefers-reduced-motion: reduce) {
  .oq-loader svg, .oq-navloader svg { animation: none; }
  .oq-loader svg path, .oq-navloader svg path { animation: oq-trace 2.4s ease-in-out infinite; }
}

/* OneQode Design System - Motion theme contract (splash + loaders)
 *
 * The splash and loader recipes paint every colour through these six variables
 * instead of reaching for tokens directly, so a consumer can retheme the motion
 * overlays without overriding recipe internals. Each use site still carries a
 * hex fallback, so the recipes render even if this layer never loads.
 *
 * Default is brand-dark - a near-black ground with a light mark - regardless of
 * [data-theme]. That is the splash's designed intent, and it stays the default
 * so existing dark-ground consumers are unaffected.
 *
 * Opt in to theme-following with data-oq-motion="theme" on <html> (or any
 * ancestor of the overlay). The motion surfaces then resolve in this order:
 *   1. an explicit [data-theme="light"] on that element or an ancestor
 *   2. the OS preference, when no [data-theme] is declared at all
 * A light-only app (Identity, MNDA) needs nothing but the attribute pair
 * <html data-theme="light" data-oq-motion="theme">. A dual-mode app can let
 * OQMotion.theme.init() stamp both attributes before first paint instead,
 * which adds a persisted user override on top of the OS preference.
 */
:root {
  --oq-motion-bg: var(--color-neutral-900, #0d0d0d);
  --oq-motion-ink: var(--color-neutral-50, #fafafa);
  --oq-motion-ink-muted: var(--color-neutral-300, #c7c7c7);
  --oq-motion-panel-bg: var(--color-neutral-900, #0d0d0d);
  --oq-motion-panel-border: var(--color-neutral-800, #1f1f1f);
  --oq-motion-panel-shadow: 0 6px 22px rgba(0, 0, 0, 0.10);
}

/* Declared light theme - on the opted-in element itself, or on a light island
 * nested inside it (an in-page .oq-loader--block can sit in either). */
[data-oq-motion="theme"][data-theme="light"],
[data-oq-motion="theme"] [data-theme="light"] {
  --oq-motion-bg: var(--color-white, #ffffff);
  --oq-motion-ink: var(--color-neutral-900, #0d0d0d);
  --oq-motion-ink-muted: var(--color-neutral-600, #555555);
  --oq-motion-panel-bg: var(--color-white, #ffffff);
  --oq-motion-panel-border: var(--color-neutral-200, #e0e0e0);
  --oq-motion-panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}

/* No declared theme - follow the device. An app that declares data-theme="dark"
 * is opting out of this, which is why the guard is :not([data-theme]). */
@media (prefers-color-scheme: light) {
  [data-oq-motion="theme"]:not([data-theme]) {
    --oq-motion-bg: var(--color-white, #ffffff);
    --oq-motion-ink: var(--color-neutral-900, #0d0d0d);
    --oq-motion-ink-muted: var(--color-neutral-600, #555555);
    --oq-motion-panel-bg: var(--color-white, #ffffff);
    --oq-motion-panel-border: var(--color-neutral-200, #e0e0e0);
    --oq-motion-panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  }
}

/*
 * Nav recipe - vertical sidebar navigation
 *
 * A stack of navigation links with optional uppercase section headings. The
 * active item is a full ink fill with inverse text: black on white grounds,
 * white on black grounds. That inversion is the strongest available signal in a
 * monochrome system, which is why it marks location rather than a colour tint.
 *
 * Usage:
 *   <nav class="oq-nav" aria-label="Account">
 *     <p class="oq-nav__section">Account</p>
 *     <a class="oq-nav__item oq-nav__item--active" href="/portal" aria-current="page">
 *       <span class="oq-icon oq-icon--lg"><svg …></svg></span>
 *       Overview
 *     </a>
 *     <a class="oq-nav__item" href="/portal/security">
 *       <span class="oq-icon oq-icon--lg"><svg …></svg></span>
 *       Security
 *     </a>
 *   </nav>
 *
 * .oq-nav__item--active and [aria-current="page"] are equivalent - prefer
 * aria-current on links so the state reaches assistive technology too.
 */

.oq-nav {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-1);
}

.oq-nav__section {
  margin-block: var(--spacing-4) var(--spacing-2);
  padding-inline: var(--spacing-3);
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-medium);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-mono);
  text-transform: uppercase;

  &:first-child {
    margin-block-start: 0;
  }
}

.oq-nav__item {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding-block: var(--spacing-2);
  padding-inline: var(--spacing-3);
  border-radius: var(--radius-md);
  color: var(--color-text-body);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-medium);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--motion-duration-fast) var(--motion-easing-standard),
    color var(--motion-duration-fast) var(--motion-easing-standard);

  &:focus-visible {
    outline: var(--border-width-md) solid var(--color-border-focus);
    outline-offset: 1px;
  }
}

.oq-nav__item .oq-icon { color: currentColor; }

/* Hover - inactive items only */
.oq-nav__item:not(.oq-nav__item--active):not([aria-current="page"]):hover {
  background-color: var(--color-surface-muted);
  color: var(--color-text-headings);
  text-decoration: none;
}

/* Active item - full ink fill, inverse text */
.oq-nav__item--active,
.oq-nav__item[aria-current="page"] {
  background-color: var(--color-surface-inverse);
  color: var(--color-text-inverse);
}

/* Horizontal variant - topbar navigation */
.oq-nav--horizontal {
  flex-direction: row;
  align-items: center;
}

/* OneQode Design System - Splash recipe
 *
 * Full-screen brand intro: the Gordian-knot mark draws itself, then an optional
 * wordmark fades in. Shown/hidden via <html> state classes set by the OQMotion
 * controller (build/js/oq-motion.js). Colours come from the --oq-motion-*
 * contract in motion-theme.css, with hex fallbacks so the splash still renders
 * if that layer loads late or fails. Brand-dark by default in either mode; add
 * data-oq-motion="theme" to follow the app (or device) theme instead.
 * See patterns/splash docs.
 */
@keyframes oq-draw { to { stroke-dashoffset: 0; } }
@keyframes oq-fill { from { fill-opacity: 0; } to { fill-opacity: 1; stroke-opacity: 0; } }
@keyframes oq-word { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes oq-grow { 0% { transform: scale(.60); opacity: 0; } 24% { opacity: 1; } 72% { transform: scale(1.035); } 100% { transform: scale(1); } }

.oq-splash {
  position: fixed; inset: 0; z-index: 9999;
  display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
  background: var(--oq-motion-bg, #0d0d0d);
  transition: opacity .5s ease;
}
html.oq-splash-play { overflow: hidden; }
html.oq-splash-play .oq-splash { display: flex; }
html.oq-splash-done .oq-splash { display: none !important; }
.oq-splash.oq-leaving { opacity: 0; }

.oq-splash__knot {
  width: 104px; height: 104px; overflow: visible;
  transform: scale(.60); transform-origin: center;
  animation: oq-grow 1.7s cubic-bezier(.22,.68,.24,1) forwards;
}
.oq-splash__knot path {
  fill: var(--oq-motion-ink, #fafafa); fill-opacity: 0;
  stroke: var(--oq-motion-ink, #fafafa); stroke-width: .9;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: oq-draw 1.5s cubic-bezier(.55,.08,.24,.98) forwards,
             oq-fill .7s ease 1.28s forwards;
}
.oq-splash__word {
  font-family: var(--font-display, sans-serif); font-weight: 600;
  font-size: 1.4rem; letter-spacing: .34em; text-indent: .34em;
  text-transform: uppercase; color: var(--oq-motion-ink, #fafafa);
  opacity: 0; animation: oq-word .7s ease 1.5s forwards;
}

@media (prefers-reduced-motion: reduce) {
  .oq-splash__knot { animation: none; transform: scale(1); }
  .oq-splash__knot path { animation: none; fill-opacity: 1; stroke-opacity: 0; stroke-dashoffset: 0; }
  .oq-splash__word { animation: none; opacity: 1; }
}

/*
 * Stat recipe
 *
 * A strip of headline figures for the top of a dashboard or queue: a large
 * display-face numeral over a small uppercase tracked label, cells divided by
 * hairlines rather than gaps so the group reads as one object.
 *
 * Usage:
 *   <div class="oq-stat-grid">
 *     <div class="oq-stat">
 *       <p class="oq-stat__value">12</p>
 *       <p class="oq-stat__label">Awaiting details</p>
 *     </div>
 *     <div class="oq-stat">
 *       <p class="oq-stat__value">3</p>
 *       <p class="oq-stat__label">Awaiting review</p>
 *     </div>
 *   </div>
 *
 * Cells wrap once they fall below a readable width. The grid draws its own
 * outer border, so it needs no wrapping card.
 *
 * Dividers are a 1px gap over a divider-tinted background showing through,
 * not a line any cell draws itself: a cell-drawn edge on the first row or
 * column would land on the same pixels as the container's own border and
 * double its thickness. Layout is flex, not grid, so a wrapped final row has
 * no empty track left to paint the divider colour across; grid's `auto-fit`
 * would leave exactly that kind of gap when the cell count does not fill the
 * last row.
 */

.oq-stat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--component-grid-divider-width);
  background-color: var(--component-grid-divider-color);
  border: var(--component-grid-divider-width) solid var(--component-grid-divider-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.oq-stat {
  flex: 1 1 9rem;
  padding: var(--spacing-3) var(--spacing-4);
  background-color: var(--color-surface-default);
}

.oq-stat__value {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--font-size-28);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  letter-spacing: var(--font-letter-spacing-heading);
  color: var(--color-text-headings);
}

.oq-stat__label {
  margin-block: var(--spacing-2) 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--font-letter-spacing-label);
  color: var(--color-text-tertiary);
}

/*
 * Table recipe
 *
 * A data table in the house style: uppercase tracked column headers over a
 * 2px ink rule, hairline row separators, and a tinted row hover. Elevation is
 * never expressed with shadow, matching the card recipe.
 *
 * Usage:
 *   <table class="oq-table">
 *     <thead>
 *       <tr><th>Reference</th><th>Counterparty</th><th>Status</th></tr>
 *     </thead>
 *     <tbody>
 *       <tr><td>NDA-014</td><td>Acme Pte Ltd</td><td>Sent</td></tr>
 *     </tbody>
 *   </table>
 *
 * Add .oq-table--stack to collapse rows into stacked cards on narrow
 * viewports, which hides the header row and lets each cell sit on its own
 * line. In that mode the recipe renders each cell's column name from a
 * data-label attribute automatically; consumers only need to set the
 * attribute on the td. A cell without one renders no label.
 */

.oq-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  color: var(--color-text-body);
}

.oq-table th {
  padding: var(--spacing-2) var(--spacing-3);
  text-align: start;
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--font-letter-spacing-label);
  color: var(--color-text-tertiary);
  white-space: nowrap;
  border-block-end: var(--border-width-md) solid var(--color-border-strong);
}

.oq-table td {
  padding: var(--spacing-3);
  vertical-align: middle;
  border-block-end: var(--border-width-sm) solid var(--color-border-subtle);
}

/* The bounding hairline is the container's job, not the last row's. */
.oq-table tbody tr:last-child td {
  border-block-end: 0;
}

.oq-table tbody tr:hover td {
  background-color: var(--color-surface-raised);
}

/*
 * Stacked variant - each row becomes a card once columns no longer fit.
 * The header row is removed rather than hidden, so screen readers do not
 * announce headings that no longer describe a visible layout.
 */
@media (max-width: 40rem) {
  .oq-table--stack thead {
    display: none;
  }

  .oq-table--stack tbody tr {
    display: grid;
    gap: var(--spacing-1);
    padding-block: var(--spacing-3);
    border-block-end: var(--border-width-sm) solid var(--color-border-subtle);
  }

  .oq-table--stack tbody td {
    padding: 0;
    border-block-end: 0;
  }

  /*
   * Without this, hiding thead removes all column context from assistive
   * technology; rendering data-label here restores it. A cell without one
   * renders no label, which is what you want for an actions or icon column.
   */
  .oq-table--stack tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-block-end: var(--spacing-1);
    font-size: var(--font-size-12);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--font-letter-spacing-label);
    color: var(--color-text-tertiary);
  }
}

/*
 * Tabs recipe
 *
 * A pill-track tab switcher in the body typeface, for switching panels within a
 * page or form (sign-in method, account section). Distinct from
 * .oq-button-group, which is the uppercase-mono segmented control used for
 * filtering data views.
 *
 * Usage:
 *   <div class="oq-tabs oq-tabs--stretch" role="tablist">
 *     <button class="oq-tabs__tab" role="tab" aria-selected="true"
 *             aria-controls="panel-password" id="tab-password">Password</button>
 *     <button class="oq-tabs__tab" role="tab" aria-selected="false"
 *             aria-controls="panel-code" id="tab-code">Email code</button>
 *   </div>
 *   <div id="panel-password" role="tabpanel" aria-labelledby="tab-password">…</div>
 *
 * .oq-tabs--stretch makes the track full width with tabs sharing it evenly.
 * .oq-tabs__tab--active and [aria-selected="true"] are equivalent - either can
 * drive the selected appearance.
 */

.oq-tabs {
  display: inline-flex;
  align-items: stretch;
  gap: var(--spacing-1);
  padding: var(--spacing-1);
  border-radius: var(--radius-lg);
  background-color: var(--color-surface-muted);
}

.oq-tabs--stretch {
  display: flex;

  & > .oq-tabs__tab {
    flex: 1;
  }
}

.oq-tabs__tab {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-2);
  padding-block: var(--spacing-2);
  padding-inline: var(--spacing-4);
  border: var(--border-width-sm) solid transparent;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--color-text-tertiary);
  font-family: var(--font-sans);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  letter-spacing: var(--font-letter-spacing-body);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--motion-duration-fast) var(--motion-easing-standard),
    border-color var(--motion-duration-fast) var(--motion-easing-standard),
    color var(--motion-duration-fast) var(--motion-easing-standard);

  &:focus-visible {
    outline: var(--border-width-md) solid var(--color-border-focus);
    outline-offset: 1px;
  }

  &:disabled,
  &[aria-disabled="true"] {
    color: var(--color-text-disabled);
    cursor: not-allowed;
    pointer-events: none;
  }
}

.oq-tabs__tab .oq-icon { color: currentColor; }

/* Selected tab - lifts out of the track */
.oq-tabs__tab--active,
.oq-tabs__tab[aria-selected="true"] {
  background-color: var(--color-surface-default);
  border-color: var(--color-border-default);
  color: var(--color-text-headings);
}

/* Hover - unselected tabs only */
.oq-tabs__tab:not(.oq-tabs__tab--active):not([aria-selected="true"]):not(:disabled):hover {
  color: var(--color-text-headings);
}

/*
 * Tag recipe
 *
 * A pill for short status or category labels: uppercase, tracked, and small.
 * Built on the --component-tag-* token family, which is dual-mode.
 *
 * Usage:
 *   <span class="oq-tag oq-tag--outline">Draft</span>
 *   <span class="oq-tag">Signed</span>
 *   <span class="oq-tag oq-tag--accent">Action needed</span>
 *
 * Variants: (base)          solid fill, the strongest of the three
 *           .oq-tag--accent brand blue, for genuine signal only
 *           .oq-tag--outline hairline border, transparent fill
 *
 * House rule: in a monochrome system greyscale intensity carries rank, so an
 * ordinary status takes .oq-tag--outline and colour is reserved for something
 * that actually needs attention. A view where every tag is accent has no
 * signal left.
 *
 * Geometry borrows --component-badge-radius, a mode-independent pill value.
 * The badge family's colour tokens are deliberately not used: they have no
 * light override, so they would be wrong on a white ground.
 */

.oq-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-1);
  padding: var(--spacing-1) var(--spacing-2);
  border-radius: var(--component-badge-radius);
  border: var(--border-width-sm) solid var(--component-tag-default-border);
  background-color: var(--component-tag-default-bg);
  color: var(--component-tag-default-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: var(--font-letter-spacing-label);
  white-space: nowrap;
}

.oq-tag--accent {
  border-color: var(--component-tag-accent-border);
  background-color: var(--component-tag-accent-bg);
  color: var(--component-tag-accent-text);
}

.oq-tag--outline {
  border-color: var(--component-tag-outline-border);
  background-color: var(--component-tag-outline-bg);
  color: var(--component-tag-outline-text);
}
