/* ============================================
   Rise Bright Design System
   Shared tokens, components, and utilities.
   All classes use rb- prefix to avoid collision.
   ============================================ */

/* Anchor-scroll offset for fixed floating header (16px top + ~60px height + buffer) */
html {
    scroll-padding-top: 100px;
}

/* Ensure [hidden] always wins over component-level display rules */
[hidden] {
    display: none !important;
}

/* --- Colour tokens (canonical) --- */
:root {
    --rb-orange: #f97316;
    --rb-red: #ea580c;
    --rb-purple-light: #8b5cf6;
    --rb-purple: #9333ea;
    --rb-green: #10b981;
    --rb-text-dark: #1f2937;
    --rb-text-light: #6b7280;
    --rb-bg-light: #fefce8;
    --rb-bg-warm: #fff7ed;
    --rb-card-bg: #ffffff;
    --rb-card-border: rgba(0, 0, 0, 0.06);
    --rb-input-bg: #ffffff;
    --rb-input-border: #d1d5db;
    --rb-brand-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #9333ea 100%);

    /* Typography */
    --rb-font-display: 'Instrument Serif', Georgia, serif;
    --rb-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --rb-radius-sm: 10px;
    --rb-radius-md: 12px;
    --rb-radius-lg: 16px;
    --rb-radius-xl: 20px;

    /* Shadows */
    --rb-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
    --rb-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.03);
    --rb-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.03);
}

/* --- Dark mode token overrides --- */
[data-theme="dark"] {
    --rb-text-dark: #e8e2f0;
    --rb-text-light: #a8a0b8;
    --rb-bg-light: #13111a;
    --rb-bg-warm: #1a1724;
    --rb-card-bg: rgba(255, 255, 255, 0.04);
    --rb-card-border: rgba(255, 255, 255, 0.08);
    --rb-input-bg: rgba(255, 255, 255, 0.04);
    --rb-input-border: rgba(255, 255, 255, 0.1);
    --rb-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --rb-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --rb-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
}

/* --- Focus ring (accessibility) --- */
.rb-focus-ring:focus-visible,
.rb-btn-primary:focus-visible,
.rb-btn-secondary:focus-visible,
.rb-btn-outline:focus-visible,
.rb-btn-text:focus-visible,
.rb-input:focus-visible {
    outline: 2px solid var(--rb-purple-light);
    outline-offset: 2px;
}

/* --- Buttons --- */
.rb-btn-primary,
.rb-btn-secondary,
.rb-btn-outline,
.rb-btn-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--rb-font-body);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    border-radius: var(--rb-radius-md);
    padding: 0.65rem 1.25rem;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, color 150ms ease, opacity 150ms ease;
    text-decoration: none;
    line-height: 1.4;
    min-height: 44px;
}

.rb-btn-primary {
    background: var(--rb-brand-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}
.rb-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
}
.rb-btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.2);
}

.rb-btn-secondary {
    background: #f3f4f6;
    color: var(--rb-text-dark);
}
[data-theme="dark"] .rb-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--rb-text-dark);
}
.rb-btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: var(--rb-shadow-sm);
}
.rb-btn-secondary:active {
    transform: translateY(1px);
}

.rb-btn-outline {
    background: transparent;
    color: var(--rb-text-dark);
    border: 1.5px solid #d1d5db;
}
[data-theme="dark"] .rb-btn-outline {
    border-color: rgba(255, 255, 255, 0.12);
}
.rb-btn-outline:hover {
    transform: translateY(-1px);
    box-shadow: var(--rb-shadow-sm);
}
.rb-btn-outline:active {
    transform: translateY(1px);
}

.rb-btn-text {
    background: transparent;
    color: var(--rb-orange);
    padding: 0.5rem 0.75rem;
    border-radius: var(--rb-radius-sm);
}
[data-theme="dark"] .rb-btn-text {
    color: #fbbf24;
}
.rb-btn-text:hover {
    background: rgba(249, 115, 22, 0.06);
}

/* Disabled state (all buttons) */
.rb-btn-primary:disabled,
.rb-btn-secondary:disabled,
.rb-btn-outline:disabled,
.rb-btn-text:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading state */
.rb-btn-loading {
    pointer-events: none;
    opacity: 0.7;
}
.rb-btn-loading::after {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: rb-spin 0.6s linear infinite;
    margin-left: 0.5rem;
}

/* --- Form inputs --- */
.rb-input {
    display: block;
    width: 100%;
    padding: 0.65rem 0.875rem;
    font-family: var(--rb-font-body);
    font-size: 0.95rem;
    color: var(--rb-text-dark);
    background: var(--rb-input-bg);
    border: 1.5px solid var(--rb-input-border);
    border-radius: var(--rb-radius-sm);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.rb-input::placeholder {
    color: var(--rb-text-light);
}
.rb-input:focus {
    border-color: var(--rb-purple-light);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    outline: none;
}
.rb-input-error {
    border-color: #ef4444;
    background: #fef2f2;
}
[data-theme="dark"] .rb-input-error {
    background: rgba(239, 68, 68, 0.08);
}
.rb-input-error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

/* --- Cards --- */
.rb-card-elevated {
    background: var(--rb-card-bg);
    border: 1px solid var(--rb-card-border);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-sm);
}

.rb-card-flat {
    background: #f9fafb;
    border: 1px solid var(--rb-card-border);
    border-radius: var(--rb-radius-lg);
}
[data-theme="dark"] .rb-card-flat {
    background: rgba(255, 255, 255, 0.02);
}

.rb-card-interactive {
    background: var(--rb-card-bg);
    border: 1px solid var(--rb-card-border);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-sm);
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease;
}
.rb-card-interactive:hover {
    transform: translateY(-1px);
    box-shadow: var(--rb-shadow-md);
}
.rb-card-interactive:active {
    transform: translateY(1px);
    box-shadow: var(--rb-shadow-sm);
}

/* --- Utilities --- */
.rb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.rb-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Skeleton loader */
.rb-skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: rb-shimmer 1.5s infinite;
    border-radius: var(--rb-radius-sm);
}
[data-theme="dark"] .rb-skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
}

/* --- Animations --- */
@keyframes rb-spin {
    to { transform: rotate(360deg); }
}

@keyframes rb-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes rb-fade-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .rb-btn-primary,
    .rb-btn-secondary,
    .rb-btn-outline,
    .rb-btn-text,
    .rb-card-interactive,
    .rb-input {
        transition: none;
    }
    .rb-skeleton {
        animation: none;
    }
    .rb-btn-loading::after {
        animation: none;
    }
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
