/*
 * ┌─────────────────────────────────────────────────────────────────┐
 * │  STEP 5 of 13 — css/components.css                              │
 * │                                                                 │
 * │  Reusable UI pieces: buttons, the portfolio tab system, and     │
 * │  accessibility utilities.                                       │
 * │                                                                 │
 * │  KEY CONCEPT: WAI-ARIA Tab Pattern.                             │
 * │  The HTML uses role="tablist", role="tab", and aria-selected    │
 * │  to communicate the current state to screen readers. CSS then   │
 * │  uses [aria-selected="true"] or .active as visual hooks.        │
 * │  The JS in js/tabs.js keeps ARIA and visual state in sync.      │
 * │                                                                 │
 * │  KEY CONCEPT: skip-to-content link.                             │
 * │  Positioned off-screen (top: -40px) until focused. Keyboard     │
 * │  users pressing Tab as their first action land here and can     │
 * │  jump directly to main content, bypassing repeated nav links.   │
 * │  This is a WCAG 2.1 Level A requirement.                        │
 * │                                                                 │
 * │  KEY CONCEPT: prefers-reduced-motion.                           │
 * │  Some users have vestibular disorders that make animations      │
 * │  physically uncomfortable. This media query cuts all transitions│
 * │  to near-zero for those users.                                  │
 * │                                                                 │
 * │  ▶  Next: See css/teaching.css (Step 6)                        │
 * └─────────────────────────────────────────────────────────────────┘
 */

/* ===================================
   Buttons
   =================================== */
.btn {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 4px;
    font-weight: 500;
    transition: all var(--transition-medium);
    cursor: pointer;
    border: 2px solid transparent;
    /* Ensure minimum touch target size of 44px */
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.btn-primary:hover {
    background-color: transparent;
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-secondary {
    background-color: transparent;
    color: white;
    border-color: white;
}

.btn-secondary:hover {
    background-color: white;
    color: var(--primary-color);
}

/* ===================================
   Portfolio Tab System
   =================================== */

/* Tab Navigation Container */
.tab-navigation {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-color) var(--bg-alt);
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling for webkit browsers */
.tab-navigation::-webkit-scrollbar {
    height: 4px;
}

.tab-navigation::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

.tab-navigation::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 2px;
}

/* Tab Buttons */
.tab-button {
    background: transparent;
    border: none;
    color: var(--text-color);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-primary);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-medium);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    min-height: 44px;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Tab Button Hover State */
.tab-button:hover {
    color: var(--primary-color);
    background-color: rgba(52, 152, 219, 0.05);
}

/* Active Tab Button */
.tab-button.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
    font-weight: 600;
}

/* Tab Button Focus State */
.tab-button:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
    z-index: 1;
}

/* Tab Content Container */
.tab-content {
    position: relative;
    min-height: 400px;
}

/* Tab Panels */
.tab-panel {
    opacity: 0;
    transition: opacity var(--transition-medium);
}

.tab-panel[hidden] {
    display: none;
}

.tab-panel.active {
    opacity: 1;
    animation: fadeIn 0.3s ease;
}

/* Fade in animation for tab panels */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Screen reader announcement element */
#tab-announcer {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ===================================
   Responsive Tab Design
   =================================== */

/* Tablets: 768px and down */
@media (max-width: 768px) {
    .tab-navigation {
        gap: 0;
        justify-content: flex-start;
    }

    .tab-button {
        padding: var(--spacing-sm) var(--spacing-sm);
        font-size: 0.95rem;
        min-width: 90px;
        flex-shrink: 0;
    }

    .tab-content {
        min-height: 300px;
    }
}

/* Small phones: 480px and down */
@media (max-width: 480px) {
    .tab-button {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.9rem;
        min-width: 80px;
    }

    .tab-content {
        min-height: 250px;
    }
}

/* Very small phones: 360px and down */
@media (max-width: 360px) {
    .tab-button {
        padding: var(--spacing-xs);
        font-size: 0.85rem;
        min-width: 70px;
    }
}

/* High contrast mode for tabs */
@media (prefers-contrast: high) {
    .tab-button.active {
        border-bottom-width: 4px;
        font-weight: 700;
    }

    .tab-button:focus {
        outline-width: 3px;
    }
}

/* Reduced motion for tab transitions */
@media (prefers-reduced-motion: reduce) {
    .tab-panel.active {
        animation: none;
    }

    .tab-button {
        transition: none;
    }
}

/* ===================================
   Accessibility
   =================================== */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
.nav-link:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000;
        --secondary-color: #0066cc;
        --border-color: #000;
    }
}
