/**
 * LEUKHOUT.nl - Base Styles
 *
 * Gebruikt CSS Custom Properties (variabelen) voor het kleurenschema.
 * Variabelen worden gedefinieerd in de HTML <style> tag door Jinja2.
 */

/* ============================================================ */
/* GLOBAL OVERFLOW PREVENTION */
/* ============================================================ */

/* Use width instead of max-width to properly contain content */
html {
    width: 100%;
}

body {
    width: 100%;
    min-width: 0; /* Allow flex children to shrink */
}

/* Main content container - properly contain width */
main {
    width: 100%;
    min-width: 0;
}

/* ============================================================ */
/* HEADER BANNER */
/* ============================================================ */
.header-banner {
    /* Responsive height using clamp() for smooth scaling */
    /* Min: 60px, Preferred: 10vw scaled to banner config, Max: banner-height-desktop */
    height: clamp(
        60px,
        calc(var(--banner-height-desktop, 180px) * 0.6),
        var(--banner-height-desktop, 180px)
    );
    max-height: clamp(60px, 12vw, var(--banner-height-desktop, 180px));
    width: auto;
    object-fit: contain;
}

@media (max-width: 767px) {
    .header-banner {
        height: var(--banner-height-mobile, 36px);
        max-height: var(--banner-height-mobile, 36px);
    }
}

/* ============================================================ */
/* DESKTOP NAVIGATION */
/* ============================================================ */
.site-nav-bar {
    position: relative;
    z-index: 500; /* Boven editor elementen */
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-sub);
    border-radius: 0.375rem;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-light);
}

.nav-item.active {
    color: var(--accent-secondary);
    background-color: var(--bg-surface-light);
}

.nav-chevron {
    transition: transform 0.2s ease;
}

.nav-dropdown-container:hover .nav-chevron {
    transform: rotate(180deg);
}

/* Dropdown container */
.nav-dropdown-container {
    position: relative;
}

/* Dropdown menu */
.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    padding: 0.5rem 0;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px var(--shadow-soft), 0 2px 4px rgba(0,0,0,0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1000; /* Boven editor toolbar */
}

.nav-dropdown-container:hover > .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown items */
.nav-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-sub);
    text-decoration: none;
    transition: all 0.15s ease;
}

.nav-dropdown-item:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-light);
}

/* Nested dropdown */
.nav-dropdown-container.nested {
    position: relative;
}

.nav-dropdown-container.nested > .nav-dropdown {
    position: absolute;
    top: -0.5rem;
    left: 100%;
    margin-left: 0;
}

.nav-chevron-right {
    transition: transform 0.2s ease;
}

.nav-dropdown-container.nested:hover > .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ============================================================ */
/* MOBILE MENU TOGGLE */
/* ============================================================ */
.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0.5rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
}

.mobile-menu-toggle:hover {
    background-color: var(--bg-surface-light);
}

.mobile-menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-secondary);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* ============================================================ */
/* MOBILE MENU */
/* ============================================================ */
.mobile-menu {
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border-soft);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-menu.open {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.mobile-nav {
    padding: 1rem;
}

.mobile-nav-item {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--text-sub);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
    color: var(--text-main);
    background-color: var(--bg-surface-light);
}

/* Mobile accordion */
.mobile-nav-accordion {
    border-radius: 0.5rem;
    overflow: hidden;
}

.mobile-nav-accordion.nested {
    margin-left: 1rem;
}

.mobile-nav-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-nav-item-link {
    flex: 1;
    display: block;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--text-sub);
    text-decoration: none;
    border-radius: 0.5rem 0 0 0.5rem;
    transition: all 0.15s ease;
}

.mobile-nav-item-link:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-light);
}

.mobile-nav-accordion-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0 0.5rem 0.5rem 0;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.mobile-nav-accordion-toggle:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-light);
}

.mobile-nav-accordion-toggle:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-secondary);
}

.mobile-nav-accordion-toggle svg {
    transition: transform 0.2s ease;
}

.mobile-nav-accordion-toggle svg.rotate-180 {
    transform: rotate(180deg);
}

/* Accordion content */
.mobile-nav-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 1rem;
    border-left: 2px solid var(--border-soft);
    margin-left: 1rem;
}

.mobile-nav-accordion-content.open {
    max-height: 500px;
}

/* ============================================================ */
/* CART BADGE STYLES */
/* ============================================================ */
.cart-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-main);
    transition: all 0.15s ease;
}

.cart-link:hover {
    background-color: var(--bg-surface-light);
    color: var(--accent-secondary);
}

.cart-badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(25%, -25%);
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    background-color: var(--accent-secondary);
    color: var(--text-invert);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translate(25%, -25%) scale(0.5);
    transition: all 0.2s ease;
}

.cart-badge.visible {
    opacity: 1;
    transform: translate(25%, -25%) scale(1);
}

.cart-badge.bounce {
    animation: cartBounce 0.4s ease;
}

@keyframes cartBounce {
    0%, 100% { transform: translate(25%, -25%) scale(1); }
    50% { transform: translate(25%, -25%) scale(1.3); }
}

/* ============================================================ */
/* HEADER LINKS (schalen met banner) */
/* ============================================================ */
.header-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--header-font-size, 14px);
    color: var(--text-sub);
    transition: color 0.15s ease;
}

.header-link:hover {
    color: var(--text-main);
}

.header-link svg {
    width: calc(var(--header-font-size, 14px) * 1.15);
    height: calc(var(--header-font-size, 14px) * 1.15);
}

@media (max-width: 767px) {
    .header-link {
        font-size: var(--header-font-size-mobile, 12px);
    }
    
    .header-link svg {
        width: calc(var(--header-font-size-mobile, 12px) * 1.15);
        height: calc(var(--header-font-size-mobile, 12px) * 1.15);
    }
    
    .cart-link svg {
        width: var(--header-icon-size-mobile, 20px);
        height: var(--header-icon-size-mobile, 20px);
    }
}

/* ============================================================ */
/* PROSE STYLES FOR CONTENT */
/* ============================================================ */

/* Container-level word wrapping to prevent horizontal overflow */
.prose {
    overflow-wrap: anywhere;
    word-wrap: break-word; /* Legacy fallback */
    word-break: normal;
    hyphens: auto;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.prose h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    overflow-wrap: break-word;
}

.prose h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.prose p {
    color: var(--text-sub);
    margin-bottom: 1rem;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.prose ul, .prose ol {
    margin-left: 0;
    margin-bottom: 1rem;
    padding-left: 0;
    color: var(--text-sub);
    list-style: none;
}

.prose ul li, .prose ol li {
    margin-bottom: 0.5rem;
    padding-left: 1.75rem;
    position: relative;
}

/* Bullet list styling */
.prose ul li::before {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 0.55em;
    width: 6px;
    height: 6px;
    background-color: var(--accent-secondary);
    border-radius: 50%;
}

/* Numbered list styling */
.prose ol {
    counter-reset: list-counter;
}

/* Alleen directe kinderen van ol krijgen counter, niet geneste ul items */
.prose ol > li {
    counter-increment: list-counter;
}

.prose ol > li::before {
    content: counter(list-counter) ".";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent-secondary);
    font-weight: 600;
    font-size: 0.95em;
}

/* Geneste ul binnen ol: geen nummers */
.prose ol ul li::before {
    content: "";
    background-color: var(--accent-secondary);
    border-radius: 50%;
    width: 6px;
    height: 6px;
    top: 0.55em;
    left: 0.5rem;
}

.prose hr {
    margin: 1.5rem 0;
    border-color: var(--border-soft);
}

.prose a {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.prose a:hover {
    color: var(--accent-secondary);
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

/* Carousel images inside prose should not inherit prose img styling */
.prose .lh-carousel img,
.prose .lh-carousel-image {
    max-width: none;
    border-radius: 0;
    margin: 0;
}

.prose blockquote {
    border-left: 3px solid var(--accent-secondary);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-sub);
    font-style: italic;
}

.prose code {
    background-color: var(--bg-surface-light);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.prose pre {
    background-color: var(--bg-surface-light);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.prose pre code {
    background: none;
    padding: 0;
}

/* ============================================================ */
/* CARDS & PANELS */
/* ============================================================ */
.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--shadow-soft);
}

.card {
    background-color: var(--text-invert);
    border: 1px solid var(--border-soft);
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px var(--shadow-soft);
}

.card:hover {
    border-color: var(--border-medium);
    box-shadow: 0 4px 12px var(--shadow-soft);
}

/* ============================================================ */
/* BUTTONS */
/* ============================================================ */
.btn-primary {
    background-color: var(--accent-secondary);
    color: var(--text-invert);
    transition: all 0.15s ease;
}

.btn-primary:hover {
    filter: brightness(0.9);
}

.btn-secondary {
    background-color: var(--bg-surface-light);
    color: var(--text-main);
    border: 1px solid var(--border-soft);
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background-color: var(--bg-surface);
    border-color: var(--border-medium);
}

/* ============================================================ */
/* FORM ELEMENTS */
/* ============================================================ */
.form-input {
    background-color: var(--text-invert);
    border: 1px solid var(--border-soft);
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-secondary) 20%, transparent);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* ============================================================ */
/* PRODUCT CARDS (index page) */
/* ============================================================ */
.product-card {
    background-color: var(--text-invert);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px var(--shadow-soft);
    overflow: hidden;
    transition: all 0.2s ease;
}

.product-card:hover {
    box-shadow: 0 8px 24px var(--shadow-soft);
    transform: translateY(-2px);
}

.product-card-image {
    background-color: var(--bg-surface-light);
}

.product-card-title {
    color: var(--text-main);
}

.product-card-price {
    color: var(--accent-secondary);
}

/* ============================================================ */
/* UTILITY CLASSES */
/* ============================================================ */
.text-main { color: var(--text-main); }
.text-sub { color: var(--text-sub); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-secondary); }

.bg-main { background-color: var(--bg-main); }
.bg-panel { background-color: var(--bg-panel); }
.bg-surface { background-color: var(--bg-surface); }
.bg-surface-light { background-color: var(--bg-surface-light); }

.border-soft { border-color: var(--border-soft); }
.border-medium { border-color: var(--border-medium); }

/* ============================================================ */
/* FOOTER STYLES */
/* ============================================================ */
.site-footer {
    border-top: 1px solid var(--border-soft);
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
}

.footer-content.prose {
    font-size: 0.875rem;
}

.footer-content.prose p {
    margin-bottom: 0.5rem;
    color: var(--text-sub);
}

.footer-content.prose p:last-child {
    margin-bottom: 0;
}

.footer-content.prose a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer-content.prose a:hover {
    color: var(--text-main);
    text-decoration: underline;
}

.footer-content.prose strong {
    color: var(--text-main);
}

/* ============================================================ */
/* MOBILE LAYOUT FIXES */
/* ============================================================ */

@media (max-width: 767px) {
    /* Ensure content doesn't overflow - use 100% not 100vw (vw includes scrollbar) */
    .max-w-6xl,
    main,
    header,
    footer,
    nav {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    /* Prose content on mobile - force proper word wrapping */
    .prose {
        max-width: 100%;
        width: 100%;
    }

    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Compact padding on mobile */
    main.px-4 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Touch-friendly links and buttons */
    .nav-item,
    .mobile-nav-item,
    .cart-link {
        min-height: 44px;
    }
    
    /* Cart badge positioning on mobile */
    .cart-badge {
        font-size: 0.625rem;
        min-width: 16px;
        height: 16px;
    }
}

/* 
 * Let op: Gebruik Tailwind's ingebouwde .hidden class.
 * Voeg GEEN custom .hidden toe met !important - dat breekt md:flex etc.
 */

/* ============================================================ */
/* PROTECTED EMAIL LINKS */
/* ============================================================ */

/* Email link styling */
.email-link {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.email-link:hover {
    color: var(--text-main);
    text-decoration: underline;
}

/* Placeholder voor niet-geladen email (pre-JS) */
.pe {
    display: inline;
    color: var(--text-muted);
    font-style: italic;
}

/* Noscript fallback styling */
.pe noscript {
    color: var(--text-muted);
    font-size: 0.875em;
}
