/**
 * Main Pages Stylesheet
 *
 * Purpose: Standardized styles for main pages (index.html, start.html, Print-Calculator.html)
 * Excludes: Info pages (grass.html, r5.html, etc.)
 *
 * Layer Hierarchy:
 * 1. Background (parallax + particles)
 * 2. Main Cards (.main-card)
 * 3. Subcards (.subcard)
 *
 * STANDARD CARD WIDTHS:
 * =====================
 * Content Cards (wide): max-width: 1200px
 * - .main-card
 * - .bookmark-section
 * - .calculator-container
 * - Any multi-column content
 *
 * Personal Cards (narrow): max-width: 600px
 * - .profile-card
 * - .weather-widget
 * - .social-section
 * - Single-column focused content
 *
 * All cards: width: 100%, margin: 0 auto (centered)
 *
 * See: MAIN-PAGES-STYLE-GUIDE.md for complete documentation
 */

/* ============================================
   LAYER 2: MAIN CARDS
   ============================================ */

/**
 * Main Card
 * Top-level container for grouped content
 * Must contain: card-header + card-content
 */
.main-card {
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--main-card-radius);
    padding: var(--card-padding-standard);
    box-shadow: var(--shadow);
    animation: fadeInUp 0.8s ease-out;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* NOTE: Main cards do NOT have hover effects - they are static containers.
   Only interactive elements (buttons, links, clickable cards) get hover effects.
   See MAIN-PAGES-STANDARD.md for interactive element standards. */

/**
 * Card Header
 * Contains card title and optional subtitle
 * Always inside .main-card
 */
.card-header {
    text-align: center;
    margin-bottom: var(--card-padding-standard);
}

.card-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-title i {
    font-size: 2.5rem;
    margin-right: 10px;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

/**
 * Card Content
 * Container for subcards or direct content
 */
.card-content {
    display: flex;
    flex-direction: column;
    gap: var(--card-padding-standard);
}

/* ============================================
   LAYER 3: SUBCARDS
   ============================================ */

/**
 * Subcard
 * Sections within main cards
 * Must contain: subcard-header + subcard-content
 */
.subcard {
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--sub-card-radius);
    padding: var(--card-padding-standard);
    transition: all 0.3s ease;
}

.subcard:hover {
    border-color: var(--primary-color);
}

/**
 * Subcard Header
 * Contains subcard title
 * Always inside .subcard
 */
.subcard-header {
    margin-bottom: var(--space-md);
}

.subcard-title {
    font-size: 1.3rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: var(--card-padding-standard);
    font-weight: 700;
}

.subcard-title i {
    font-size: 1.2rem;
}

/**
 * Subcard Content
 * Container for actual content (grids, forms, etc.)
 */
.subcard-content {
    /* Content-specific styling applied via additional classes */
}

/* ============================================
   UNIFIED GRID SYSTEM
   ============================================ */

/**
 * Unified Responsive Grid
 *
 * ONE grid system that works everywhere:
 * - Automatically adjusts columns based on container width
 * - Centers incomplete rows
 * - No hard-coded values
 * - No media queries needed
 * - Works on desktop, tablet, and mobile
 *
 * Usage: Add class "unified-grid" to any container
 * Optional modifiers:
 * - "unified-grid-sm" for smaller items (min-width: 150px)
 * - "unified-grid-lg" for larger items (min-width: 300px)
 */
.unified-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-item-min-width), 100%), 1fr));
    gap: var(--grid-gap);
    justify-items: center;
    width: 100%;
}

.unified-grid > * {
    width: 100%;
    max-width: 100%;
}

/* Small variant - more items per row */
.unified-grid-sm {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-item-min-width-sm), 100%), 1fr));
    gap: var(--grid-gap);
    justify-items: center;
    width: 100%;
}

.unified-grid-sm > * {
    width: 100%;
    max-width: 100%;
}

/* Large variant - fewer items per row */
.unified-grid-lg {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-item-min-width-lg), 100%), 1fr));
    gap: var(--grid-gap);
    justify-items: center;
    width: 100%;
}

.unified-grid-lg > * {
    width: 100%;
    max-width: 100%;
}

/* ============================================
   COMMON LAYOUTS
   ============================================ */

/**
 * Bookmarks Container
 * Single-column layout - each topic gets its own row
 */
.bookmarks-container {
    display: flex;
    flex-direction: column;
    gap: var(--card-padding-standard);
}

/**
 * Bookmark Section Card
 * Each category gets its own glass card with flexible grid layout
 * Bookmarks fill the 1200px width and wrap only if they get too small
 */
.bookmark-section {
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--main-card-radius);
    padding: var(--card-padding-standard);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    animation: fadeInUp 0.8s ease-out;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;

    /* Flexible grid layout - bookmarks adjust to fill width, wrap if too small */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--card-padding-standard);
}

.bookmark-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px 0 rgba(88, 101, 242, 0.3);
}

/**
 * Bookmark Section Title
 * Title inside the card - spans full width
 */
.bookmark-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--text-primary);
    text-align: center;
    grid-column: 1 / -1; /* Span all columns */
}

/**
 * Social Section Card
 * Personal card width (600px) like profile/weather
 */
.social-section {
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--sub-card-radius);
    padding: var(--card-padding-standard);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    animation: fadeInUp 0.8s ease-out;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;

    /* Grid layout for social links - 2 columns that fill width */
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--card-padding-standard);
}

/* Hover removed - links handle their own hover effects */

/**
 * Social Section Title
 * Title inside the card - spans full width
 */
.social-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--text-primary);
    text-align: center;
    grid-column: 1 / -1; /* Span all columns */
}

/**
 * Grid Layout
 * For bookmarks, social links, stats, etc.
 */
.bookmark-grid,
.social-grid,
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--card-padding-standard);
}

/**
 * Form Layout
 * For calculator and other form-based pages
 */
.form-layout {
    display: flex;
    flex-direction: column;
    gap: var(--card-padding-standard);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--card-padding-standard);
}

.form-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--card-padding-standard);
}

.form-label i {
    color: var(--primary-color);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

/**
 * Text Inputs, Selects, Textareas
 * All use glass morphism styling
 */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'OpenDyslexic', sans-serif;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--primary-alpha-10);
    box-shadow: 0 0 0 3px var(--primary-alpha-20);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/**
 * Number Input Adjustments
 */
.form-input[type="number"] {
    -moz-appearance: textfield;
}

.form-input[type="number"]::-webkit-inner-spin-button,
.form-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/**
 * Select Dropdown
 */
.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* ============================================
   BUTTONS
   ============================================ */

/**
 * Primary Button
 * Solid color, high emphasis
 */
.btn-primary {
    padding: 12px 24px;
    background: var(--primary-color);
    color: var(--text-primary);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'OpenDyslexic', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--primary-alpha-40);
}

.btn-primary:active {
    transform: translateY(0);
}

/**
 * Glass Button
 * Glass morphism style, medium emphasis
 */
.btn-glass {
    padding: 12px 24px;
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    font-family: 'OpenDyslexic', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-glass:hover {
    background: var(--primary-alpha-10);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-glass.active {
    background: var(--primary-alpha-20);
    border-color: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-alpha-30);
}

/**
 * Button Group
 * For preset buttons (profit margin, filament selection, etc.)
 */
.button-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--card-padding-standard);
}

.button-group .btn-glass {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--card-padding-standard);
    padding: 12px 20px;
}

/* ============================================
   BOOKMARK LINKS
   ============================================ */

/**
 * Bookmark Link Item
 * Individual bookmark in a grid
 */
.bookmark-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--card-padding-standard);
    padding: var(--card-padding-standard);
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--sub-card-radius);
    text-decoration: none;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.bookmark-link:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: var(--primary-color);
    box-shadow: 0 10px 40px var(--primary-alpha-30);
}

.bookmark-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
}

.bookmark-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bookmark-icon i {
    font-size: 2rem;
}

.bookmark-name {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
}

.bookmark-url {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ============================================
   SOCIAL LINKS
   ============================================ */

/**
 * Social Link Item
 * Similar to bookmark but with different layout
 */
.social-link {
    display: flex;
    align-items: center;
    gap: var(--card-padding-standard);
    padding: var(--card-padding-standard);
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--sub-card-radius);
    text-decoration: none;
    transition: all 0.3s ease;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

/* Streak lighting effect */
.social-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--hover-streak-gradient);
    transition: left 0.5s ease;
}

.social-link:hover::before {
    left: 100%;
}

.social-link:hover {
    transform: var(--hover-transform);
    box-shadow: var(--hover-shadow);
}

.social-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.6s ease;
}

.social-link:hover .social-icon {
    transform: rotate(var(--hover-icon-rotation)) scale(var(--hover-icon-scale));
}

.social-name {
    font-size: 1rem;
    font-weight: 700;
}

.social-handle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ============================================
   STATS & RESULTS
   ============================================ */

/**
 * Stats Display
 * For calculator results, profile stats, etc.
 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--card-padding-standard);
}

.stat-item {
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--sub-card-radius);
    padding: var(--card-padding-standard);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ============================================
   ANIMATIONS
   ============================================ */

/**
 * Fade In Up
 * Default entrance animation for main cards
 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/**
 * Stagger animations for multiple cards
 */
.main-card:nth-child(1) { animation-delay: 0s; }
.main-card:nth-child(2) { animation-delay: 0.1s; }
.main-card:nth-child(3) { animation-delay: 0.2s; }
.main-card:nth-child(4) { animation-delay: 0.3s; }
.main-card:nth-child(5) { animation-delay: 0.4s; }

/**
 * Pulse animation
 * For status indicators, active states, etc.
 */
@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/**
 * Tablet (768px and below)
 */
@media (max-width: 768px) {
    .main-card {
            padding: var(--card-padding-standard);
            border-radius: var(--responsive-main-card-radius);    }

    .card-title {
        font-size: 2rem;
    }

    .card-title i {
        font-size: 2rem;
    }

    .card-subtitle {
        font-size: 1rem;
    }

    .subcard {
            padding: var(--card-padding-standard);
            border-radius: var(--sub-card-radius);    }

    .subcard-title {
        font-size: 1.15rem;
    }

    /* Bookmarks container already single-column by default */

    .bookmark-section {
        /* Maintain flexible grid on tablet, just with smaller items */
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .social-section {
        grid-template-columns: 1fr;
    }

    .bookmark-grid,
    .social-grid,
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .button-group {
        grid-template-columns: 1fr;
    }
}

/**
 * Mobile (480px and below)
 */
@media (max-width: 480px) {
    .main-card {
            padding: var(--card-padding-standard);
            border-radius: var(--responsive-main-card-radius);    }

    .card-title {
        font-size: 1.75rem;
    }

    .card-title i {
        font-size: 1.75rem;
    }

    .subcard {
        padding: var(--card-padding-standard);
    }

    .bookmark-icon {
        width: 50px;
        height: 50px;
    }

    .bookmark-name {
        font-size: 0.9rem;
    }

    .bookmark-url {
        font-size: 0.8rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/**
 * Focus States
 * Ensure keyboard navigation visibility
 */
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.btn-primary:focus,
.btn-glass:focus,
.bookmark-link:focus,
.social-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/**
 * Reduced Motion
 * Respect user preference for reduced motion
 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/**
 * High Contrast Mode
 * Ensure readability in high contrast mode
 */
@media (prefers-contrast: high) {
    .main-card,
    .subcard,
    .bookmark-link,
    .social-link {
        border-width: 2px;
    }

    .card-title,
    .subcard-title {
        -webkit-text-fill-color: var(--text-primary);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/**
 * Spacing utilities
 */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/**
 * Text utilities
 */
.text-center { text-align: center; }
.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }

/**
 * Display utilities
 */
.hidden { display: none; }
.flex { display: flex; }
.flex-column { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ============================================
   END OF MAIN PAGES STYLESHEET
   ============================================ */
