/**
 * Rapid Texter GUI - Base Styles & Design System
 * Design tokens matching Theme.qml from Qt application
 * 
 * This file contains:
 * - CSS Variables (Design Tokens)
 * - Base/Reset Styles
 * - Typography
 * - Layout Utilities
 * - Custom Scrollbar
 * - Responsive Breakpoints
 * 
 * @author Alea Farrel & Team
 */

/* ========================================================================
 * CSS VARIABLES - Design Tokens (matching Theme.qml)
 * ======================================================================== */

:root {
    /* Background Colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #21262d;

    /* Text Colors */
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #484f58;

    /* Border Colors */
    --border-primary: #21262d;
    --border-secondary: #30363d;

    /* Accent Colors */
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-yellow: #d29922;
    --accent-red: #f85149;

    /* Status Background (10% opacity tints) */
    --success-bg: rgba(63, 185, 80, 0.1);
    --warning-bg: rgba(210, 153, 34, 0.1);
    --danger-bg: rgba(248, 81, 73, 0.1);
    --info-bg: rgba(88, 166, 255, 0.1);

    /* Typography */
    --font-family: 'JetBrains Mono', monospace;
    --font-size-xs: 10px;
    --font-size-s: 11px;
    --font-size-sm: 12px;
    --font-size-m: 13px;
    --font-size-l: 14px;
    --font-size-xl: 15px;
    --font-size-xxl: 18px;
    --font-size-display: 24px;
    --font-size-hero: 48px;
    --font-size-logo: 64px;
    --font-size-logo-subtitle: 12px;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-s: 6px;
    --spacing-sm: 8px;
    --spacing-m: 12px;
    --spacing-l: 16px;
    --spacing-xl: 20px;
    --spacing-xxl: 24px;
    --spacing-huge: 32px;
    --spacing-logo: 50px;

    /* Padding */
    --padding-xs: 4px;
    --padding-s: 6px;
    --padding-m: 10px;
    --padding-l: 14px;
    --padding-xl: 18px;
    --padding-xxl: 24px;
    --padding-huge: 28px;

    /* Component Sizes */
    --menu-key-min-width: 40px;
    --status-bar-height: 48px;
    --max-content-width: 1000px;
    --icon-size-xs: 12px;
    --icon-size-sm: 14px;
    --icon-size-md: 16px;
    --icon-size-lg: 18px;
    --icon-size-xl: 24px;
    --icon-size-xxl: 32px;

    /* Animation */
    --animation-duration: 150ms;
    --animation-duration-slow: 300ms;

    /* Border Radius */
    --radius-s: 4px;
    --radius-m: 8px;
    --radius-l: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* ========================================================================
 * CUSTOM SCROLLBAR
 * ======================================================================== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: var(--radius-s);
}

::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: var(--radius-s);
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

::-webkit-scrollbar-corner {
    background: var(--bg-primary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary) var(--bg-primary);
}

/* ========================================================================
 * BASE STYLES & RESET
 * ======================================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--status-bar-height);
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-m);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ========================================================================
 * ACCESSIBILITY & FOCUS
 * ======================================================================== */

/* Custom focus ring for keyboard users, matching theme aesthetics */
:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 4px;
    transition: outline-offset var(--animation-duration) ease;
}

/* Specific focus colors for colored elements */
.btn-primary:focus-visible,
.feature-card.accent-green:focus-visible {
    outline-color: var(--accent-green);
}

.btn-danger:focus-visible,
.feature-card.accent-red:focus-visible {
    outline-color: var(--accent-red);
}

.btn-yellow:focus-visible,
.feature-card.accent-yellow:focus-visible {
    outline-color: var(--accent-yellow);
}

/* ========================================================================
 * TYPOGRAPHY
 * ======================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: var(--font-size-logo);
}

h2 {
    font-size: var(--font-size-display);
}

h3 {
    font-size: var(--font-size-xxl);
}

h4 {
    font-size: var(--font-size-xl);
}

p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-m);
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--animation-duration) ease;
}

a:hover {
    color: var(--text-primary);
}

strong {
    font-weight: 600;
    color: var(--text-primary);
}

code {
    font-family: var(--font-family);
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-s);
    font-size: 0.9em;
}

::selection {
    background-color: var(--accent-blue);
    color: var(--bg-primary);
}

/* ========================================================================
 * IMAGES & MEDIA
 * ======================================================================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

svg {
    display: inline-block;
    vertical-align: middle;
}

/* ========================================================================
 * LAYOUT - CONTAINER
 * ======================================================================== */

.container {
    width: 100%;
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 var(--padding-xxl);
}

.container-wide {
    max-width: 1200px;
}

.container-narrow {
    max-width: 700px;
}

/* ========================================================================
 * SECTION STYLES
 * ======================================================================== */

.section {
    padding: 80px 0;
}

.section-alt {
    background-color: var(--bg-secondary);
}

.section-title {
    font-size: var(--font-size-display);
    font-weight: bold;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: var(--spacing-huge);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-m);
}

.section-title .icon {
    color: var(--accent-blue);
}

.section-subtitle {
    color: var(--text-secondary);
    text-align: center;
    max-width: 600px;
    margin: -20px auto 40px;
    font-size: var(--font-size-l);
}

/* ========================================================================
 * UTILITY CLASSES
 * ======================================================================== */

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-blue {
    color: var(--accent-blue);
}

.text-green {
    color: var(--accent-green);
}

.text-yellow {
    color: var(--accent-yellow);
}

.text-red {
    color: var(--accent-red);
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: var(--spacing-s);
}

.mb-2 {
    margin-bottom: var(--spacing-m);
}

.mb-3 {
    margin-bottom: var(--spacing-l);
}

.mb-4 {
    margin-bottom: var(--spacing-xl);
}

.mb-5 {
    margin-bottom: var(--spacing-huge);
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: var(--spacing-s);
}

.mt-2 {
    margin-top: var(--spacing-m);
}

.mt-3 {
    margin-top: var(--spacing-l);
}

.mt-4 {
    margin-top: var(--spacing-xl);
}

.mt-5 {
    margin-top: var(--spacing-huge);
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-1 {
    gap: var(--spacing-s);
}

.gap-2 {
    gap: var(--spacing-m);
}

.gap-3 {
    gap: var(--spacing-l);
}

.gap-4 {
    gap: var(--spacing-xl);
}

/* ========================================================================
 * ANIMATIONS
 * ======================================================================== */

/* Pulse animation (matching SplashScreen.qml) */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

/* Bounce animation */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(5px);
    }
}

/* Fade in up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading dots (matching SplashScreen) */
@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Rotate for loading */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-pulse {
    animation: pulse 2.4s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 2s ease-in-out infinite;
}

.animate-fadeInUp {
    animation: fadeInUp 0.5s ease forwards;
}

/* ========================================================================
 * RESPONSIVE BREAKPOINTS
 * ======================================================================== */

@media (max-width: 768px) {
    :root {
        --font-size-logo: 48px;
        --font-size-hero: 36px;
        --font-size-display: 20px;
        --padding-xxl: 16px;
        --status-bar-height: 56px;
    }

    .section {
        padding: 60px 0;
    }

    .hide-mobile {
        display: none !important;
    }
}

@media (max-width: 480px) {
    :root {
        --font-size-logo: 40px;
        --font-size-hero: 28px;
    }

    .section {
        padding: 40px 0;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}