/* 
 * Websly Theme System v3.0 - Global Tokens
 * These static tokens form the foundation for spacing, typography, radius, shadow, and motion.
 * They are defined before utility classes so that Tailwind can consume them seamlessly.
 */

:root {
    /* =========================================
     Typography Tokens (Fluid Clamps)
     ========================================= */
    --text-xs: clamp(0.7rem, 0.7rem + 0.1vw, 0.75rem);
    --text-sm: clamp(0.8rem, 0.8rem + 0.15vw, 0.875rem);
    --text-base-size: clamp(0.95rem, 0.9rem + 0.25vw, 1.125rem);
    --text-lg: clamp(1.1rem, 1rem + 0.5vw, 1.25rem);
    --text-xl: clamp(1.2rem, 1.1rem + 0.75vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --text-3xl: clamp(1.8rem, 1.5rem + 1.5vw, 2.5rem);
    --text-4xl: clamp(2rem, 1.8rem + 2vw, 3.5rem);
    --text-5xl: clamp(2.5rem, 2rem + 3vw, 4.5rem);
    --text-6xl: clamp(3rem, 2.5rem + 4vw, 6rem);
    --text-7xl: clamp(3.5rem, 3rem + 5vw, 8rem);

    /* =========================================
     Spacing Tokens (Inner Element Rhythm)
     ========================================= */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;

    /* =========================================
     Section Spacing Tokens (Outer Paddings)
     ========================================= */
    --section-space-sm: clamp(2rem, 4vw, 4rem);
    --section-space-md: clamp(3rem, 6vw, 6rem);
    --section-space-lg: clamp(4rem, 8vw, 8rem);
    --section-space-xl: clamp(6rem, 12vw, 12rem);

    /* =========================================
     Radius Tokens
     ========================================= */
    --radius-none: 0px;
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-3xl: 3rem;
    --radius-4xl: 4rem;
    --radius-full: 9999px;

    /* =========================================
     Shadow & Elevation Tokens
     Using fallback hex for black, to be themed via RGBA where needed
     ========================================= */
    --shadow-none: none;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* A brand-colored diffuse glow - the color will be overridden dynamically per theme if needed,
     but we provide a default that uses the theme accent variable */
    --shadow-glow: 0 0 20px 0 color-mix(in srgb, var(--theme-accent) 40%, transparent);

    /* =========================================
     Motion Tokens
     ========================================= */
    --duration-fast: 0.15s;
    --duration-normal: 0.3s;
    --duration-slow: 0.5s;
    --ease-default: ease;
    --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Lordicon Integration */
lord-icon {
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
}

.dark {
    /* Dark mode shadow variations */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* =========================================
   Universal Wrapper CSS Utilities
   These map the tokens directly to utility classes used by websly_get_wrapper_attrs()
   ========================================= */

/* Top Padding */
.ws-pt-none {
    padding-top: 0 !important;
}

.ws-pt-2xs {
    padding-top: var(--space-2xs);
}

.ws-pt-xs {
    padding-top: var(--space-xs);
}

.ws-pt-sm {
    padding-top: var(--space-sm);
}

.ws-pt-md {
    padding-top: var(--space-md);
}

.ws-pt-lg {
    padding-top: var(--space-lg);
}

.ws-pt-xl {
    padding-top: var(--space-xl);
}

.ws-pt-2xl {
    padding-top: var(--space-2xl);
}

.ws-pt-section-sm {
    padding-top: var(--section-space-sm);
}

.ws-pt-section-md {
    padding-top: var(--section-space-md);
}

.ws-pt-section-lg {
    padding-top: var(--section-space-lg);
}

.ws-pt-section-xl {
    padding-top: var(--section-space-xl);
}

/* Bottom Padding */
.ws-pb-none {
    padding-bottom: 0 !important;
}

.ws-pb-2xs {
    padding-bottom: var(--space-2xs);
}

.ws-pb-xs {
    padding-bottom: var(--space-xs);
}

.ws-pb-sm {
    padding-bottom: var(--space-sm);
}

.ws-pb-md {
    padding-bottom: var(--space-md);
}

.ws-pb-lg {
    padding-bottom: var(--space-lg);
}

.ws-pb-xl {
    padding-bottom: var(--space-xl);
}

.ws-pb-2xl {
    padding-bottom: var(--space-2xl);
}

.ws-pb-section-sm {
    padding-bottom: var(--section-space-sm);
}

.ws-pb-section-md {
    padding-bottom: var(--section-space-md);
}

.ws-pb-section-lg {
    padding-bottom: var(--section-space-lg);
}

.ws-pb-section-xl {
    padding-bottom: var(--section-space-xl);
}

/* Top Margin */
.ws-mt-none {
    margin-top: 0 !important;
}

.ws-mt-2xs {
    margin-top: var(--space-2xs);
}

.ws-mt-xs {
    margin-top: var(--space-xs);
}

.ws-mt-sm {
    margin-top: var(--space-sm);
}

.ws-mt-md {
    margin-top: var(--space-md);
}

.ws-mt-lg {
    margin-top: var(--space-lg);
}

.ws-mt-xl {
    margin-top: var(--space-xl);
}

.ws-mt-2xl {
    margin-top: var(--space-2xl);
}

/* Bottom Margin */
.ws-mb-none {
    margin-bottom: 0 !important;
}

.ws-mb-2xs {
    margin-bottom: var(--space-2xs);
}

.ws-mb-xs {
    margin-bottom: var(--space-xs);
}

.ws-mb-sm {
    margin-bottom: var(--space-sm);
}

.ws-mb-md {
    margin-bottom: var(--space-md);
}

.ws-mb-lg {
    margin-bottom: var(--space-lg);
}

.ws-mb-xl {
    margin-bottom: var(--space-xl);
}

.ws-mb-2xl {
    margin-bottom: var(--space-2xl);
}

/* Visibility Utilities */
@media (max-width: 767px) {
    .ws-hide-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .ws-hide-desktop {
        display: none !important;
    }
}

/* Radius Utilities */
.ws-radius-none {
    border-radius: var(--radius-none);
}

.ws-radius-sm {
    border-radius: var(--radius-sm);
}

.ws-radius-md {
    border-radius: var(--radius-md);
}

.ws-radius-lg {
    border-radius: var(--radius-lg);
}

.ws-radius-xl {
    border-radius: var(--radius-xl);
}

.ws-radius-2xl {
    border-radius: var(--radius-2xl);
}

.ws-radius-3xl {
    border-radius: var(--radius-3xl);
}

.ws-radius-4xl {
    border-radius: var(--radius-4xl);
}

.ws-radius-full {
    border-radius: var(--radius-full);
}

.ws-radius-pill {
    border-radius: var(--radius-full);
}

/* Shadow Utilities */
.ws-shadow-none {
    box-shadow: var(--shadow-none);
}

.ws-shadow-sm {
    box-shadow: var(--shadow-sm);
}

.ws-shadow-md {
    box-shadow: var(--shadow-md);
}

.ws-shadow-lg {
    box-shadow: var(--shadow-lg);
}

.ws-shadow-glow {
    box-shadow: var(--shadow-glow);
}

/* Elevation Aliases (v4.0 Schema) */
.ws-elevation-none { box-shadow: var(--shadow-none); }
.ws-elevation-low { box-shadow: var(--shadow-sm); }
.ws-elevation-normal { box-shadow: var(--shadow-md); }
.ws-elevation-high { box-shadow: var(--shadow-lg); }
.ws-elevation-glow { box-shadow: var(--shadow-glow); }

/* Card Density Utilities */
.ws-card-density-cozy { padding: 1.25rem !important; }
.ws-card-density-default { padding: 1.5rem !important; }
.ws-card-density-spacious { padding: 2.5rem !important; }

/* Grid Gaps matching density */
.ws-grid-gap-cozy { gap: 1rem !important; }
.ws-grid-gap-default { gap: 1.5rem !important; }
.ws-grid-gap-spacious { gap: 2.5rem !important; }

/* Hover Effects */
.ws-hover-lift {
    transition: transform var(--duration-normal) var(--ease-smooth), box-shadow var(--duration-normal) var(--ease-smooth);
}

.ws-hover-lift:hover {
    transform: translateY(-4px);
}

.ws-hover-scale {
    transition: transform var(--duration-normal) var(--ease-smooth);
}

.ws-hover-scale:hover {
    transform: scale(1.02);
}

.ws-hover-shadow-bright {
    transition: box-shadow var(--duration-normal) var(--ease-smooth);
}
.ws-min-h-fullscreen { min-height: 100vh !important; min-height: 100dvh !important; }
.ws-min-h-90vh { min-height: 90vh !important; min-height: 90dvh !important; }
.ws-min-h-80vh { min-height: 80vh !important; min-height: 80dvh !important; }
.ws-min-h-70vh { min-height: 70vh !important; min-height: 70dvh !important; }
.ws-min-h-60vh { min-height: 60vh !important; min-height: 60dvh !important; }

/* =========================================
   Typography Scaling Utilities
   ========================================= */
.ws-text-xs {
    font-size: var(--text-xs);
}

.ws-text-sm {
    font-size: var(--text-sm);
}

.ws-text-base {
    font-size: var(--text-base-size);
}

.ws-text-lg {
    font-size: var(--text-lg);
}

.ws-text-xl {
    font-size: var(--text-xl);
}

.ws-text-2xl {
    font-size: var(--text-2xl);
}

.ws-text-3xl {
    font-size: var(--text-3xl);
}

.ws-text-4xl {
    font-size: var(--text-4xl);
}

.ws-text-5xl {
    font-size: var(--text-5xl);
}

.ws-text-6xl {
    font-size: var(--text-6xl);
}

.ws-text-7xl {
    font-size: var(--text-7xl);
}

/* Section-Specific Fluid Tokens (Beautiful Defaults) */
.text-section-title {
    font-size: clamp(2.25rem, 6vw, 4.5rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.text-section-subtitle {
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    line-height: 1.5;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ws-italic {
    font-style: italic;
}

.ws-font-serif {
    font-family: var(--font-drama);
}

.ws-font-sans {
    font-family: var(--font-primary);
}

.ws-font-mono {
    font-family: var(--font-ui);
}

/* Base Tailwind Aliases for Dropdown Compatibility */
.text-section-title { font-size: clamp(2.25rem, 5vw, 3.5rem); line-height: 1.1; letter-spacing: -0.01em; }
.text-section-subtitle {
    font-size: clamp(1rem, 1.5vw, 1.125rem); /* Max 1.125rem = 18px */
    line-height: 1.6;
}
.text-hero-title { font-size: clamp(2.5rem, 5vw, 4.5rem); line-height: 1.05; letter-spacing: -0.02em; }
.text-fluid-h1 { font-size: clamp(2.5rem, 5vw, 4rem); line-height: 1.05; letter-spacing: -0.02em; }
.text-fluid-h2 { font-size: clamp(2rem, 5vw, 4rem); line-height: 1.1; letter-spacing: -0.015em; }
.text-fluid-h3 { font-size: clamp(1.5rem, 3.5vw, 2.75rem); line-height: 1.2; letter-spacing: -0.01em; }

.text-7xl { font-size: var(--text-7xl, 4.5rem); }
.text-6xl { font-size: var(--text-6xl, 3.75rem); }
.text-5xl { font-size: var(--text-5xl, 3rem); }
.text-4xl { font-size: var(--text-4xl, 2.25rem); }
.text-3xl { font-size: var(--text-3xl, 1.875rem); }
.text-2xl { font-size: var(--text-2xl, 1.5rem); }
.text-xl { font-size: var(--text-xl, 1.25rem); }
.text-lg { font-size: var(--text-lg, 1.125rem); }
.text-base { font-size: var(--text-base-size, 1rem); }
.text-sm { font-size: var(--text-sm, 0.875rem); }
.text-xs { font-size: var(--text-xs, 0.75rem); }
.text-strong { color: var(--theme-text-strong); }
.text-muted { color: var(--theme-text-muted); }
.text-theme-text-strong { color: var(--theme-text-strong); }
.text-theme-text-muted { color: var(--theme-text-muted); }
.text-theme-text { color: var(--theme-text); }
/* =========================================
   vNext Decoupled Architecture Utilities
   These consume the structural variables set by Personalities / Global Tokens
   ========================================= */

/* --- 1. Spacing & Density (Section/Card) --- */
.ws-section-density-none { padding-top: 0; padding-bottom: 0; }
.ws-section-density-compact { padding-top: var(--section-space-sm); padding-bottom: var(--section-space-sm); }
.ws-section-density-default { padding-top: var(--section-space-md); padding-bottom: var(--section-space-md); }
.ws-section-density-spacious { padding-top: var(--section-space-lg); padding-bottom: var(--section-space-lg); }
.ws-section-density-hero { padding-top: var(--section-space-xl); padding-bottom: var(--section-space-xl); }

.ws-card-density-none { padding: 0; }
.ws-card-density-cozy { padding: var(--space-sm); gap: var(--space-sm); }
.ws-card-density-default { padding: var(--space-md); gap: var(--space-md); }
.ws-card-density-spacious { padding: var(--space-lg); gap: var(--space-lg); }

/* --- 2. Surface Model (3-Axis) --- */

/* Axis A: Material */
.ws-mat-solid { 
    background-color: var(--surface-bg-color, var(--theme-surface)); 
}
.ws-mat-glass { 
    background-color: var(--surface-bg-glass, rgba(var(--bg-base-rgb), 0.7)); 
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.ws-mat-transparent { 
    background-color: transparent; 
}

/* Axis B: Tone (Surface Ownership Model) 
   Visible materials (solid/glass) define a local contrast root for descendants.
   Transparent materials inherit context from the parent. */

/* 1. Standard Context: Base & Subtle (Forced Contrast Surfaces) */
:is(.ws-mat-solid, .ws-mat-glass).ws-tone-base {
    /* Background Surface (Shadowed from Page) */
    --surface-bg-color: var(--page-bg-base);
    --surface-bg-glass: rgba(var(--page-bg-base-rgb), 0.7);
    --bg-base-rgb: var(--page-bg-base-rgb);
    --bg-surface-rgb: var(--page-bg-base-rgb);

    /* Text & Contrast Root (Local Tone Shadowing) */
    color: var(--text-base);
    --text-base: var(--page-text-base);
    --text-base-rgb: var(--page-text-base-rgb);
    --text-strong: var(--page-text-strong);
    --text-strong-rgb: var(--page-text-strong-rgb);
    --text-muted: var(--page-text-muted);
    --text-muted-rgb: var(--page-text-muted-rgb);
    
    /* Global Aliases for descendants */
    --theme-text: var(--text-base);
    --theme-text-rgb: var(--text-base-rgb);
    --theme-text-strong: var(--text-strong);
    --theme-text-muted: var(--text-muted);
    --ws-card-title: var(--text-strong);
    --ws-card-body: var(--text-base);
}


:is(.ws-mat-solid, .ws-mat-glass).ws-tone-subtle {
    /* Background Surface (Shadowed from Page Surface) */
    --surface-bg-color: var(--page-bg-surface, var(--bg-surface));
    --surface-bg-glass: rgba(var(--page-bg-surface-rgb, var(--bg-surface-rgb)), 0.7);
    --bg-base-rgb: var(--page-bg-base-rgb);
    --bg-surface-rgb: var(--page-bg-surface-rgb, var(--bg-surface-rgb));

    /* Text & Contrast Root (Local Tone Shadowing) */
    color: var(--text-base);
    --text-base: var(--page-text-base);
    --text-base-rgb: var(--page-text-base-rgb);
    --text-strong: var(--page-text-strong);
    --text-strong-rgb: var(--page-text-strong-rgb);
    --text-muted: var(--page-text-muted);
    --text-muted-rgb: var(--page-text-muted-rgb);

    /* Global Aliases for descendants */
    --theme-text: var(--text-base);
    --theme-text-rgb: var(--text-base-rgb);
    --theme-text-strong: var(--text-strong);
    --theme-text-muted: var(--text-muted);
    --ws-card-title: var(--text-strong);
    --ws-card-body: var(--text-base);
}


/* 2. Inverse Context: Strong & Inverted (Flip contrast vs page mode) */
:is(.ws-mat-solid, .ws-mat-glass).ws-tone-strong {
    --surface-bg-color: var(--theme-surface-strong);
    --surface-bg-glass: rgba(var(--bg-strong-rgb), 0.8);
    color: var(--theme-text-inverse);
    --text-base: var(--theme-text-inverse);
    --text-base-rgb: var(--theme-text-inverse-rgb);
    --text-strong: var(--theme-text-inverse);
    --text-muted: rgba(var(--theme-text-inverse-rgb), 0.7);
    --theme-text: var(--text-base);
    --theme-text-rgb: var(--text-base-rgb);
    --theme-text-strong: var(--text-strong);
    --theme-text-muted: var(--text-muted);
    --ws-card-title: var(--text-strong);
    --ws-card-body: var(--text-base);
}

:is(.ws-mat-solid, .ws-mat-glass).ws-tone-inverted {
    --surface-bg-color: var(--page-text-base, var(--theme-text)); 
    --surface-bg-glass: rgba(var(--page-text-base-rgb, var(--text-base-rgb)), 0.8);
    color: var(--theme-surface);
    --text-base: var(--theme-surface);
    --text-base-rgb: var(--bg-base-rgb);
    --text-strong: var(--theme-surface);
    --text-muted: rgba(var(--bg-base-rgb), 0.7);
    --theme-text: var(--text-base);
    --theme-text-rgb: var(--text-base-rgb);
    --theme-text-strong: var(--text-base);
    --theme-text-muted: var(--text-muted);
    --ws-card-title: var(--text-base);
    --ws-card-body: var(--text-base);
}

/* 3. Accent Context: Branded Surface */
:is(.ws-mat-solid, .ws-mat-glass).ws-tone-accent {
    --surface-bg-color: var(--theme-accent);
    --surface-bg-glass: rgba(var(--accent-default-rgb), 0.8);
    color: var(--theme-text-on-accent);
    --text-base: var(--theme-text-on-accent);
    --text-base-rgb: var(--theme-text-on-accent-rgb);
    --text-strong: var(--theme-text-on-accent);
    --text-muted: rgba(var(--theme-text-on-accent-rgb), 0.8);
    --theme-text: var(--text-base);
    --theme-text-rgb: var(--text-base-rgb);
    --theme-text-strong: var(--text-base);
    --theme-text-muted: var(--text-muted);
    --ws-card-title: var(--text-base);
    --ws-card-body: var(--text-base);
}

/* 4. Pass-through (Transparent) */
.ws-mat-transparent.ws-tone-base { --surface-bg-color: transparent; }
.ws-mat-transparent.ws-tone-subtle { --surface-bg-color: transparent; }
.ws-mat-transparent.ws-tone-strong { --surface-bg-color: transparent; }
.ws-mat-transparent.ws-tone-accent { --surface-bg-color: transparent; }
.ws-mat-transparent.ws-tone-inverted { --surface-bg-color: transparent; }

/* Axis C: Frame */
.ws-frame-none { border: none !important; }
.ws-frame-subtle { border: 1px solid var(--theme-border-subtle); }
.ws-frame-strong { border: 2px solid var(--theme-border-strong); }
.ws-frame-glow { 
    box-shadow: 0 0 15px var(--theme-glow-color, rgba(var(--accent-default-rgb), 0.5)); 
    border: 1px solid var(--theme-glow-color, rgba(var(--accent-default-rgb), 0.5)); 
}

/* --- 3. Width & Height --- */
.ws-width-contained {
    max-width: var(--theme-max-width, 1280px);
    margin-left: auto;
    margin-right: auto;
}
.ws-width-full {
    width: 100%;
    max-width: none;
}
/* --- 4. Inner Container Constraints --- */
.ws-container-inner {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
}
.ws-width-contained .ws-container-inner {
    max-width: var(--theme-max-width, 1280px);
}
.ws-width-full .ws-container-inner {
    max-width: none;
}

/* --- Badge Primitive --- */
.ws-badge-primitive {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.625rem; /* 10px */
    white-space: nowrap;
    border-radius: var(--radius-full);
    transition: all var(--duration-normal) var(--ease-smooth);
}

/* Sizes */
.ws-badge-sm { padding: 0.125rem 0.5rem; font-size: 0.5rem; }
.ws-badge-md { padding: 0.25rem 0.75rem; font-size: 0.625rem; }
.ws-badge-lg { padding: 0.5rem 1rem; font-size: 0.75rem; }

/* Position */
.ws-badge-absolute { position: absolute; }
.ws-badge-relative { position: relative; }
