/*!
 * Ranyave design tokens (css/tokens.css) — owner: design system (a1-ui).
 *
 * WHO SETS WHAT
 *   - COLOUR tokens: this file ships the complete light default (scheme "Nube" + accent "Azul") on :root and the
 *     complete dark default (scheme "Medianoche" + accent "Azul") on :root[data-theme="dark"], with the exact values
 *     the theme engine (js/rv-theme.js) derives for those two combinations, so the page looks identical before and
 *     after the engine runs (or when it never runs). The engine overrides them inline on <html>.
 *   - SHAPE / SPACE / TYPE tokens: ONLY this file sets them, from the <html data-*> options (radius, density, font, fs,
 *     container, grid, ratio, header, card, scope, motion). The engine only flips the attributes.
 *
 * TOKEN CATALOGUE (SPEC 6.1) + the extras documented below
 *   colour    --rv-bg --rv-bg-alt --rv-surface --rv-surface-2 --rv-surface-3 --rv-border --rv-border-strong
 *             --rv-text --rv-text-dim --rv-text-faint --rv-accent(-hover|-soft|-ink) --rv-on-accent
 *             --rv-accent-2(-hover|-soft|-ink) --rv-on-accent-2 --rv-header-(bg|text|border) --rv-topbar-(bg|text)
 *             --rv-footer-(bg|text|dim) --rv-success|warning|danger|info (+ -soft, -ink) --rv-overlay --rv-focus
 *             --rv-skeleton-a|b --rv-shadow-sm|--rv-shadow|--rv-shadow-lg
 *   extras    (not set by the engine, defined per mode here) --rv-on-success|warning|danger|info = text on a solid status
 *             fill; --rv-success-fill|warning-fill|danger-fill|info-fill = solid status fills; --rv-star = rating gold.
 *   shape     --rv-radius-xs|sm|(none)|lg|pill · --rv-radius-tag (a pill that squares off when radius = none: badges, chips, counts)
 *   space     --rv-density --rv-s1 … --rv-s8
 *   type      --rv-font --rv-font-display --rv-font-mono --rv-fs --rv-fs-xs … --rv-fs-5xl --rv-track-display --rv-fw-display
 *   layout    --rv-container --rv-grid-cols --rv-card-ratio --rv-header-h --rv-topbar-h --rv-sticky-top --rv-control-h
 *   cards     --rv-card-bg --rv-card-border --rv-card-shadow --rv-card-shadow-h --rv-card-media-bg --rv-card-divider
 *   motion    --rv-ease --rv-dur-fast --rv-dur --rv-dur-slow
 *   layers    --rv-z-sticky --rv-z-header --rv-z-dropdown --rv-z-popover --rv-z-modal --rv-z-toast
 */

/* ==========================================================================
 * 1. LIGHT defaults — scheme "Nube" + accent "Azul" (mode light is the default of the whole suite)
 * ========================================================================== */
:root {
  color-scheme: light;

  --rv-bg: #ffffff;
  --rv-bg-alt: #f5f7fb;
  --rv-surface: #ffffff;
  --rv-surface-2: #f8fafc;
  --rv-surface-3: #eef2f7;
  --rv-border: #e4e8f0;
  --rv-border-strong: #cfd6e4;
  --rv-text: #111827;
  --rv-text-dim: #5b6577;
  --rv-text-faint: #8a94a6;

  --rv-accent: #2563eb;
  --rv-accent-hover: #2159d4;
  --rv-accent-soft: #e5ecfd;
  --rv-accent-ink: #2461e5;
  --rv-on-accent: #ffffff;
  --rv-accent-2: #f97316;
  --rv-accent-2-hover: #e06814;
  --rv-accent-2-soft: #feeee3;
  --rv-accent-2-ink: #b15210;
  --rv-on-accent-2: #0f172a;

  --rv-header-bg: #ffffff;
  --rv-header-text: #111827;
  --rv-header-border: #e4e8f0;
  --rv-topbar-bg: #0f172a;
  --rv-topbar-text: #e2e8f0;
  --rv-footer-bg: #0f172a;
  --rv-footer-text: #cbd5e1;
  --rv-footer-dim: #94a3b8;

  --rv-success: #16a34a;
  --rv-success-soft: #def2e6;
  --rv-success-ink: #117c39;
  --rv-warning: #d97706;
  --rv-warning-soft: #faecdc;
  --rv-warning-ink: #a35905;
  --rv-danger: #dc2626;
  --rv-danger-soft: #fae1e1;
  --rv-danger-ink: #c82323;
  --rv-info: #0284c7;
  --rv-info-soft: #dceef7;
  --rv-info-ink: #0270a9;

  --rv-overlay: rgba(15, 23, 42, .52);
  --rv-focus: #2563eb;
  --rv-skeleton-a: #eef2f7;
  --rv-skeleton-b: #e1e5eb;
  --rv-shadow-sm: 0 1px 2px rgba(13, 18, 29, .06), 0 1px 1px rgba(13, 18, 29, .04);
  --rv-shadow: 0 4px 12px rgba(13, 18, 29, .08), 0 2px 4px rgba(13, 18, 29, .05);
  --rv-shadow-lg: 0 18px 40px rgba(13, 18, 29, .14), 0 6px 14px rgba(13, 18, 29, .08);

  /* extras (per mode, never set by the engine): solid status fills and the text drawn on them */
  --rv-success-fill: var(--rv-success-ink);
  --rv-danger-fill: var(--rv-danger-ink);
  --rv-info-fill: var(--rv-info-ink);
  --rv-warning-fill: var(--rv-warning);
  --rv-on-success: #ffffff;
  --rv-on-danger: #ffffff;
  --rv-on-info: #ffffff;
  --rv-on-warning: #1f1300;
  --rv-star: #f59e0b;
}

/* ==========================================================================
 * 2. DARK defaults — scheme "Medianoche" + accent "Azul" (accent text lightened for contrast on dark surfaces)
 * ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --rv-bg: #0b1120;
  --rv-bg-alt: #0e1527;
  --rv-surface: #131c31;
  --rv-surface-2: #18223b;
  --rv-surface-3: #1f2a46;
  --rv-border: #26324b;
  --rv-border-strong: #33415f;
  --rv-text: #e8edf7;
  --rv-text-dim: #9aa7bf;
  --rv-text-faint: #6b7a96;

  --rv-accent: #2563eb;
  --rv-accent-hover: #346eec;
  --rv-accent-soft: #16274f;
  --rv-accent-ink: #5f8df0;
  --rv-on-accent: #ffffff;
  --rv-accent-2: #f97316;
  --rv-accent-2-hover: #f97e29;
  --rv-accent-2-soft: #382a2d;
  --rv-accent-2-ink: #f97316;
  --rv-on-accent-2: #0f172a;

  --rv-header-bg: #0f172a;
  --rv-header-text: #e8edf7;
  --rv-header-border: #26324b;
  --rv-topbar-bg: #060a14;
  --rv-topbar-text: #cbd5e1;
  --rv-footer-bg: #060a14;
  --rv-footer-text: #e8edf7;
  --rv-footer-dim: #9aa7bf;

  --rv-success: #4ade80;
  --rv-success-soft: #1b373c;
  --rv-success-ink: #4ade80;
  --rv-warning: #fbbf24;
  --rv-warning-soft: #33332f;
  --rv-warning-ink: #fbbf24;
  --rv-danger: #f87171;
  --rv-danger-soft: #33283a;
  --rv-danger-ink: #f87171;
  --rv-info: #38bdf8;
  --rv-info-soft: #18334d;
  --rv-info-ink: #38bdf8;

  --rv-overlay: rgba(0, 0, 0, .66);
  --rv-focus: #2563eb;
  --rv-skeleton-a: #1f2a46;
  --rv-skeleton-b: #2b3651;
  --rv-shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --rv-shadow: 0 6px 16px rgba(0, 0, 0, .45), 0 2px 4px rgba(0, 0, 0, .35);
  --rv-shadow-lg: 0 22px 48px rgba(0, 0, 0, .6), 0 8px 16px rgba(0, 0, 0, .4);

  --rv-on-success: #04210f;
  --rv-on-danger: #2a0707;
  --rv-on-info: #03202e;
  --rv-on-warning: #1f1300;
  --rv-star: #fbbf24;
}

/* ==========================================================================
 * 3. SHAPE, SPACE, TYPE, LAYOUT defaults (every one is re-mapped from a data-* option in section 4)
 * ========================================================================== */
:root {
  /* radius "md" */
  --rv-radius-sm: 8px;
  --rv-radius: 12px;
  --rv-radius-lg: 18px;
  --rv-radius-xs: calc(var(--rv-radius-sm) * .5);
  --rv-radius-pill: 9999px;
  --rv-radius-tag: calc(var(--rv-radius) * 999);   /* pill for tags/badges/chips, but fully square when radius = none */

  /* density "comfortable" */
  --rv-density: 1;
  --rv-s1: calc(var(--rv-density) * 4px);
  --rv-s2: calc(var(--rv-density) * 8px);
  --rv-s3: calc(var(--rv-density) * 12px);
  --rv-s4: calc(var(--rv-density) * 16px);
  --rv-s5: calc(var(--rv-density) * 24px);
  --rv-s6: calc(var(--rv-density) * 32px);
  --rv-s7: calc(var(--rv-density) * 48px);
  --rv-s8: calc(var(--rv-density) * 64px);

  /* font "system" (Google families are loaded by the engine on demand; the stacks always fall back gracefully) */
  --rv-font-sys: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --rv-font: var(--rv-font-sys);
  --rv-font-display: var(--rv-font-sys);
  --rv-font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --rv-fw-display: 750;
  --rv-track-display: -.022em;

  /* root font size: html { font-size: calc(16px * var(--rv-fs)) }; components only use rem */
  --rv-fs: 1;
  --rv-fs-xs: .75rem;
  --rv-fs-sm: .875rem;
  --rv-fs-md: 1rem;
  --rv-fs-lg: 1.125rem;
  --rv-fs-xl: 1.25rem;
  --rv-fs-2xl: clamp(1.35rem, 1.15rem + .8vw, 1.625rem);
  --rv-fs-3xl: clamp(1.6rem, 1.2rem + 1.5vw, 2.125rem);
  --rv-fs-4xl: clamp(2rem, 1.35rem + 2.6vw, 3rem);
  --rv-fs-5xl: clamp(2.5rem, 1.5rem + 4.2vw, 4.25rem);

  /* layout */
  --rv-container: 1240px;
  --rv-gutter: clamp(1rem, .6rem + 1.8vw, 2rem);
  --rv-grid-cols: 4;
  --rv-card-ratio: 1 / 1;
  --rv-header-h: 4.5rem;
  --rv-topbar-h: 2.25rem;
  --rv-sticky-top: calc(var(--rv-header-h) + var(--rv-s4));
  --rv-control-h: max(2.25rem, calc(2.5rem * var(--rv-density)));

  /* product-card styling ("classic" by default; remapped by data-card) */
  --rv-card-bg: var(--rv-surface);
  --rv-card-border: 1px solid var(--rv-border);
  --rv-card-shadow: none;
  --rv-card-shadow-h: var(--rv-shadow);
  --rv-card-media-bg: var(--rv-surface-2);
  --rv-card-divider: 0px solid transparent;
  --rv-card-lift: -2px;

  /* motion */
  --rv-ease: cubic-bezier(.2, .7, .2, 1);
  --rv-dur-fast: 120ms;
  --rv-dur: 180ms;
  --rv-dur-slow: 320ms;

  /* stacking order */
  --rv-z-sticky: 50;
  --rv-z-header: 100;
  --rv-z-dropdown: 200;
  --rv-z-popover: 900;
  --rv-z-modal: 1000;
  --rv-z-toast: 1500;

  font-size: calc(16px * var(--rv-fs));
}

/* ==========================================================================
 * 4. OPTION MAPPINGS (data-* attributes set by the theme engine on <html>)
 * ========================================================================== */

/* data-radius -> --rv-radius-sm / --rv-radius / --rv-radius-lg */
:root[data-radius="none"] { --rv-radius-sm: 0px;  --rv-radius: 0px;  --rv-radius-lg: 0px; }
:root[data-radius="sm"]   { --rv-radius-sm: 4px;  --rv-radius: 6px;  --rv-radius-lg: 10px; }
:root[data-radius="md"]   { --rv-radius-sm: 8px;  --rv-radius: 12px; --rv-radius-lg: 18px; }
:root[data-radius="lg"]   { --rv-radius-sm: 12px; --rv-radius: 16px; --rv-radius-lg: 24px; }
:root[data-radius="xl"]   { --rv-radius-sm: 16px; --rv-radius: 22px; --rv-radius-lg: 32px; }

/* data-density -> --rv-density (the --rv-s1…s8 scale derives from it) */
:root[data-density="compact"]     { --rv-density: .85; }
:root[data-density="comfortable"] { --rv-density: 1; }
:root[data-density="spacious"]    { --rv-density: 1.2; }

/* data-font -> font stacks (display faces get their own weight/tracking) */
:root[data-font="system"]     { --rv-font: var(--rv-font-sys); --rv-font-display: var(--rv-font-sys); --rv-fw-display: 750; --rv-track-display: -.022em; }
:root[data-font="inter"]      { --rv-font: "Inter", var(--rv-font-sys); --rv-font-display: "Inter", var(--rv-font-sys); --rv-fw-display: 750; --rv-track-display: -.028em; }
:root[data-font="poppins"]    { --rv-font: "Poppins", var(--rv-font-sys); --rv-font-display: "Poppins", var(--rv-font-sys); --rv-fw-display: 650; --rv-track-display: -.02em; }
:root[data-font="nunito"]     { --rv-font: "Nunito", var(--rv-font-sys); --rv-font-display: "Nunito", var(--rv-font-sys); --rv-fw-display: 800; --rv-track-display: -.012em; }
:root[data-font="montserrat"] { --rv-font: "Montserrat", var(--rv-font-sys); --rv-font-display: "Montserrat", var(--rv-font-sys); --rv-fw-display: 700; --rv-track-display: -.025em; }
:root[data-font="playfair"]   { --rv-font: var(--rv-font-sys); --rv-font-display: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif; --rv-fw-display: 700; --rv-track-display: -.012em; }
:root[data-font="mono"]       { --rv-font: "JetBrains Mono", "IBM Plex Mono", var(--rv-font-mono); --rv-font-display: "JetBrains Mono", "IBM Plex Mono", var(--rv-font-mono); --rv-fw-display: 700; --rv-track-display: -.03em; }

/* data-fs -> --rv-fs (root font size multiplier) */
:root[data-fs="s"]  { --rv-fs: .94; }
:root[data-fs="m"]  { --rv-fs: 1; }
:root[data-fs="l"]  { --rv-fs: 1.1; }
:root[data-fs="xl"] { --rv-fs: 1.2; }

/* data-container -> --rv-container */
:root[data-container="boxed"] { --rv-container: 1240px; }
:root[data-container="wide"]  { --rv-container: 1480px; }
:root[data-container="full"]  { --rv-container: 100%; }

/* data-grid -> --rv-grid-cols (columns of the product grid on desktop; responsive collapse is in base.css) */
:root[data-grid="3"] { --rv-grid-cols: 3; }
:root[data-grid="4"] { --rv-grid-cols: 4; }
:root[data-grid="5"] { --rv-grid-cols: 5; }
:root[data-grid="6"] { --rv-grid-cols: 6; }

/* data-ratio -> --rv-card-ratio (product image box) */
:root[data-ratio="square"]    { --rv-card-ratio: 1 / 1; }
:root[data-ratio="portrait"]  { --rv-card-ratio: 4 / 5; }
:root[data-ratio="landscape"] { --rv-card-ratio: 4 / 3; }

/* data-header -> header / topbar heights */
:root[data-header="classic"]  { --rv-header-h: 4.5rem;  --rv-topbar-h: 2.25rem; }
:root[data-header="centered"] { --rv-header-h: 5.5rem;  --rv-topbar-h: 2.25rem; }
:root[data-header="compact"]  { --rv-header-h: 3.5rem;  --rv-topbar-h: 2rem; }

/* data-card -> product-card surface treatment (consumed by .rv-pcard and reusable by any card-like tile) */
:root[data-card="classic"] {
  --rv-card-bg: var(--rv-surface);
  --rv-card-border: 1px solid var(--rv-border);
  --rv-card-shadow: none;
  --rv-card-shadow-h: var(--rv-shadow);
  --rv-card-media-bg: var(--rv-surface-2);
  --rv-card-divider: 0px solid transparent;
  --rv-card-lift: -2px;
}
:root[data-card="minimal"] {
  --rv-card-bg: transparent;
  --rv-card-border: 1px solid transparent;
  --rv-card-shadow: none;
  --rv-card-shadow-h: none;
  --rv-card-media-bg: var(--rv-surface-3);
  --rv-card-divider: 0px solid transparent;
  --rv-card-lift: 0px;
}
:root[data-card="bordered"] {
  --rv-card-bg: var(--rv-surface);
  --rv-card-border: 1.5px solid var(--rv-border-strong);
  --rv-card-shadow: none;
  --rv-card-shadow-h: none;
  --rv-card-media-bg: var(--rv-surface);
  --rv-card-divider: 1.5px solid var(--rv-border);
  --rv-card-lift: 0px;
}
:root[data-card="elevated"] {
  --rv-card-bg: var(--rv-surface);
  --rv-card-border: 1px solid transparent;
  --rv-card-shadow: var(--rv-shadow);
  --rv-card-shadow-h: var(--rv-shadow-lg);
  --rv-card-media-bg: var(--rv-surface-2);
  --rv-card-divider: 0px solid transparent;
  --rv-card-lift: -4px;
}

/* data-scope: the POS is touch-first (targets >= 44 px even at compact density) */
:root[data-scope="pos"] { --rv-control-h: max(2.75rem, calc(2.75rem * var(--rv-density))); }
:root[data-scope="display"] { --rv-control-h: 3rem; }
@media (pointer: coarse) {
  :root { --rv-control-h: max(2.5rem, calc(2.5rem * var(--rv-density))); }
  :root[data-scope="pos"] { --rv-control-h: max(2.75rem, calc(2.75rem * var(--rv-density))); }
}

/* data-motion="off" and the OS reduced-motion preference zero every duration token (base.css also kills keyframes) */
:root[data-motion="off"] { --rv-dur-fast: 0ms; --rv-dur: 0ms; --rv-dur-slow: 0ms; }
@media (prefers-reduced-motion: reduce) {
  :root { --rv-dur-fast: 0ms; --rv-dur: 0ms; --rv-dur-slow: 0ms; }
}

/* Local density scopes: wrap a region in .rv-dense / .rv-roomy to re-scale it without touching the page option
 * (custom properties holding calc() are resolved where they are declared, so the scale is redeclared here). */
.rv-dense, .rv-roomy {
  --rv-s1: calc(var(--rv-density) * 4px);
  --rv-s2: calc(var(--rv-density) * 8px);
  --rv-s3: calc(var(--rv-density) * 12px);
  --rv-s4: calc(var(--rv-density) * 16px);
  --rv-s5: calc(var(--rv-density) * 24px);
  --rv-s6: calc(var(--rv-density) * 32px);
  --rv-s7: calc(var(--rv-density) * 48px);
  --rv-s8: calc(var(--rv-density) * 64px);
}
.rv-dense { --rv-density: .85; }
.rv-roomy { --rv-density: 1.2; }
