/**
 * main.css — Material Supply Theme
 *
 * Custom CSS that supplements Tailwind utility classes.
 * Everything here is either:
 *   (a) a structural pattern too dynamic for static Tailwind classes, or
 *   (b) a browser-level override that Tailwind cannot express cleanly.
 *
 * All colour values reference CSS custom properties from style.css :root.
 * Never add raw hex values here — use var(--color-*).
 *
 * Load order: style.css → main.css → Tailwind CDN
 *
 * @package MaterialSupply
 */

/* ============================================================
   SMOOTH SCROLL
   ============================================================ */

html {
    scroll-behavior: smooth;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   NO HORIZONTAL SCROLL
   ============================================================ */

body {
    overflow-x: hidden;
}

/* ============================================================
   CUSTOM SCROLLBAR (webkit)
   ============================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-navy-dark);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-orange);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) var(--color-navy-dark);
}

/* ============================================================
   MATERIAL SYMBOLS ICON SIZING
   ============================================================ */

.material-symbols-outlined {
    /* Prevent icons from stretching flex/grid containers */
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
    /* Optical size matches default font-size for sharpness */
    font-variation-settings: 'OPSZ' 24;
    user-select: none;
}

/* ============================================================
   BRAND LOGOS — grayscale at rest, colour on hover
   ============================================================ */

.msupply-brand-logo {
    filter: grayscale(100%);
    opacity: 0.6;
    transition: filter 300ms ease, opacity 300ms ease, transform 300ms ease;
    cursor: default;
}

.msupply-brand-logo:hover {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.08);
}

/* ============================================================
   STICKY HEADER — transition on scroll (driven by main.js)
   ============================================================ */

.site-header {
    transition: box-shadow 200ms ease, background-color 200ms ease;
}

.site-header.is-scrolled {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
    background-color: rgba(0, 34, 68, 0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ============================================================
   MOBILE MENU — slide-in animation (Alpine handles show/hide)
   ============================================================ */

[x-cloak] {
    display: none !important;
}

/* ============================================================
   FORM FOCUS STATES — orange ring matching the CTA
   ============================================================ */

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-orange) !important;
    box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.18);
}

/* ============================================================
   CTA GLOW SHADOW
   ============================================================ */

.cta-glow {
    box-shadow: 0 0 20px rgba(255, 153, 0, 0.3);
}

.cta-glow:hover {
    box-shadow: 0 0 30px rgba(255, 153, 0, 0.5);
}

/* ============================================================
   CTA BANNER — diagonal stripe accent
   ============================================================ */

.cta-stripe-bg {
    background-image:
        repeating-linear-gradient(
            -45deg,
            rgba(255, 255, 255, 0.025) 0,
            rgba(255, 255, 255, 0.025) 1px,
            transparent 1px,
            transparent 12px
        );
}

/* ============================================================
   PRODUCT CARD HOVER EFFECTS
   ============================================================ */

.product-card {
    transition:
        border-color 200ms ease,
        box-shadow 200ms ease,
        transform 200ms ease;
}

.product-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 153, 0, 0.4);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 153, 0, 0.15);
}

.product-card .product-thumb {
    transition: transform 350ms ease;
}

.product-card:hover .product-thumb {
    transform: scale(1.06);
}

/* ============================================================
   STATUS BADGES — product availability indicators
   ============================================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.available {
    background: rgba(22, 163, 74, 0.15);
    color: #4ade80;
    border: 1px solid rgba(22, 163, 74, 0.3);
}

.status-badge.recently_procured {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-badge.out_of_stock {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ============================================================
   CATEGORY FILTER PILLS
   ============================================================ */

.filter-pill {
    transition: background-color 200ms, color 200ms, border-color 200ms;
}

.filter-pill:hover {
    border-color: var(--color-orange);
}

.filter-pill.active {
    background-color: var(--color-orange);
    color: var(--color-navy-dark);
    border-color: var(--color-orange);
}

/* ============================================================
   GALLERY THUMBNAIL STRIP
   ============================================================ */

.gallery-thumb-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.gallery-thumb-strip button {
    flex-shrink: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 200ms;
}

.gallery-thumb-strip button.active,
.gallery-thumb-strip button:hover {
    border-color: var(--color-orange);
}

/* ============================================================
   STATS COUNTER — about page
   ============================================================ */

.stat-number {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    color: var(--color-orange);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
}

/* ============================================================
   MAP EMBED — responsive 16:9
   ============================================================ */

.map-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.map-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ============================================================
   SCROLL-TRIGGERED FADE-IN (class toggled by main.js)
   ============================================================ */

.fade-in-up {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.fade-in-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger delay helpers */
.fade-delay-1 { transition-delay: 100ms; }
.fade-delay-2 { transition-delay: 200ms; }
.fade-delay-3 { transition-delay: 300ms; }
.fade-delay-4 { transition-delay: 400ms; }
.fade-delay-5 { transition-delay: 500ms; }

/* ============================================================
   LINE CLAMP UTILITIES (Safari fallback)
   ============================================================ */

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    transition: border-color 200ms ease, color 200ms ease, background-color 200ms ease;
}

.pagination .page-numbers:hover {
    border-color: var(--color-orange);
    color: var(--color-orange);
    text-decoration: none;
}

.pagination .page-numbers.current {
    background-color: var(--color-orange);
    border-color: var(--color-orange);
    color: var(--color-navy-dark);
}

.pagination .page-numbers.dots {
    border-color: transparent;
    pointer-events: none;
}

/* ============================================================
   GALLERY LIGHTBOX (minimal — used if no plugin is installed)
   ============================================================ */

.msupply-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    cursor: zoom-out;
}

.msupply-lightbox-overlay img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    cursor: default;
}

.msupply-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 200ms ease;
}

.msupply-lightbox-close:hover {
    background: var(--color-orange);
    color: var(--color-navy-dark);
}

/* ============================================================
   WORDPRESS CONTENT (the_content area)
   ============================================================ */

.entry-content {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.9375rem;
    line-height: 1.75;
}

.entry-content > * + * {
    margin-top: 1rem;
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
    color: var(--color-white);
    margin-top: 1.75rem;
}

.entry-content a {
    color: var(--color-orange);
}

.entry-content a:hover {
    text-decoration: underline;
}

.entry-content ul,
.entry-content ol {
    padding-left: 1.5rem;
}

.entry-content li {
    color: rgba(255, 255, 255, 0.75);
}

.entry-content strong {
    color: var(--color-white);
    font-weight: 700;
}

.entry-content code {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.875em;
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-orange);
}

.entry-content pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    font-size: 0.875rem;
}

/* ============================================================
   MOBILE RESPONSIVE — 390px baseline (iPhone 12 mini)
   ============================================================ */

@media (max-width: 767px) {
    /* Hero text scales down gracefully */
    .hero-section h1 {
        font-size: 1.75rem;
    }

    /* Brand logos: 3 per row on mobile */
    .brand-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Product grids: single column on mobile */
    .product-grid-3 {
        grid-template-columns: 1fr;
    }

    /* Footer columns stack vertically */
    .footer-grid {
        grid-template-columns: 1fr;
    }

    /* Two-column forms go full-width */
    .form-two-col {
        grid-template-columns: 1fr;
    }

    /* Touch targets minimum 44px per WCAG */
    .btn,
    button,
    a.btn,
    input[type="submit"] {
        min-height: 44px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* Tablet: 2-column product grids */
    .product-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    header,
    footer,
    .cta-banner,
    .pagination,
    nav[aria-label="Breadcrumb"],
    [aria-label="Product filters"] {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
    }

    h1, h2, h3 {
        color: #000 !important;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #555;
    }

    .entry-content {
        color: #222 !important;
    }

    img {
        max-width: 400pt !important;
    }

    /* Remove box shadows and backgrounds for print clarity */
    .card,
    .product-card,
    .bg-\[\#003366\]\/40,
    .bg-\[\#003366\] {
        background: #f5f5f5 !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
