/**
 * ============================================================================
 * BASE.CSS
 * ============================================================================
 * 
 * Foundation styles for the Ticketing System application.
 * This file contains reset rules, root-level defaults, and base typography.
 * 
 * DEPENDENCIES:
 *   - definitions.css (must be loaded first for CSS custom properties)
 * 
 * SECTIONS:
 *   1. CSS Reset & Box Model
 *   2. Root Element Defaults
 *   3. Typography Base
 *   4. Link Defaults
 *   5. Media Defaults
 *   6. Selection Styles
 * 
 * LAST UPDATED: 2026-01-14
 * ============================================================================
 */


/* =============================================================================
   1. CSS RESET & BOX MODEL
   =============================================================================
   Modern CSS reset based on best practices.
   Ensures consistent rendering across browsers.
   ============================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Remove default list styles */
ul,
ol {
    list-style: none;
}

/* Prevent font size inflation on mobile */
html {
    -moz-text-size-adjust: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

/* Remove default button styles */
button {
    font: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* Remove default input styles */
input,
textarea,
select {
    font: inherit;
}


/* =============================================================================
   2. ROOT ELEMENT DEFAULTS
   =============================================================================
   Base styles for html and body elements.
   Sets up the foundational visual environment.
   ============================================================================= */

html {
    /* Smooth scrolling for anchor links */
    scroll-behavior: smooth;
    
    /* Respect user's reduced motion preference */
    @media (prefers-reduced-motion: reduce) {
        scroll-behavior: auto;
    }
}

body {
    /* Typography */
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
    font-size: var(--font-size-base, 14px);
    line-height: var(--line-height-base, 1.5);
    
    /* Colors from theme */
    color: var(--text-primary);
    background-color: var(--bg-primary);
    
    /* Prevent horizontal overflow */
    overflow-x: hidden;
    
    /* Smooth font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}


/* =============================================================================
   3. TYPOGRAPHY BASE
   =============================================================================
   Default heading and paragraph styles.
   Establishes the typographic hierarchy.
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

h1 {
    font-size: var(--text-3xl, 1.875rem);  /* 30px */
}

h2 {
    font-size: var(--text-2xl, 1.5rem);    /* 24px */
}

h3 {
    font-size: var(--text-xl, 1.25rem);    /* 20px */
}

h4 {
    font-size: var(--text-lg, 1.125rem);   /* 18px */
}

h5 {
    font-size: var(--text-base, 1rem);     /* 16px */
}

h6 {
    font-size: var(--text-sm, 0.875rem);   /* 14px */
}

p {
    margin-bottom: 1em;
    color: var(--text-secondary);
}

/* Last paragraph in a container shouldn't have bottom margin */
p:last-child {
    margin-bottom: 0;
}

/* Small text utility */
small {
    font-size: var(--text-xs, 0.75rem);    /* 12px */
    color: var(--text-tertiary);
}

/* Strong/bold text */
strong, b {
    font-weight: 600;
}

/* Emphasized/italic text */
em, i {
    font-style: italic;
}

/* Code/monospace text */
code, pre, kbd {
    font-family: var(--font-mono, 'SF Mono', 'Fira Code', 'Consolas', monospace);
    font-size: 0.9em;
}

code {
    padding: 2px 6px;
    background: var(--bg-surface-hover);
    border-radius: 4px;
    color: var(--text-primary);
}

pre {
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
}

pre code {
    padding: 0;
    background: none;
    border-radius: 0;
}


/* =============================================================================
   4. LINK DEFAULTS
   =============================================================================
   Base anchor/link styles with accessible focus states.
   ============================================================================= */

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Accessible focus state */
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}


/* =============================================================================
   5. MEDIA DEFAULTS
   =============================================================================
   Responsive images and media elements.
   ============================================================================= */

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Remove default iframe border */
iframe {
    border: none;
}


/* =============================================================================
   6. SELECTION STYLES
   =============================================================================
   Custom text selection highlighting.
   ============================================================================= */

::selection {
    background-color: var(--primary-color);
    color: white;
}

::-moz-selection {
    background-color: var(--primary-color);
    color: white;
}


/* =============================================================================
   7. FOCUS MANAGEMENT
   =============================================================================
   Global focus styles for accessibility.
   ============================================================================= */

/* Remove default focus outline - we'll add custom ones */
:focus {
    outline: none;
}

/* Visible focus for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip to content link (accessibility) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    z-index: 10000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}


/* =============================================================================
   8. REDUCED MOTION
   =============================================================================
   Respect user's motion preferences for accessibility.
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
