/* ============================================================
   Vlinderparadijs Papiliorama — Main Stylesheet
   Mobile first, CSS custom properties, geen framework
   ============================================================ */

/* ── Reset & basis ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Fallback kleuren — worden overschreven door PHP */
    --color-primary:    #2d7a4f;
    --color-secondary:  #f5a623;
    --color-accent:     #e84393;
    --color-background: #f9f5ee;
    --color-text:       #2c2c2c;
    --color-surface:    #ffffff;
    --color-border:     #e0d8cc;
    --radius-sm:  8px;
    --radius-md:  16px;
    --radius-lg:  24px;
    --shadow-sm:  0 2px 8px rgba(0,0,0,.08);
    --shadow-md:  0 4px 20px rgba(0,0,0,.12);
    --shadow-lg:  0 8px 40px rgba(0,0,0,.16);
    --font-body:  'Segoe UI', system-ui, sans-serif;
    --transition: .25s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--color-background);
    color: var(--color-text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Skip link ─────────────────────────────────────────── */
.skip-link {
    position: absolute; top: -9999px; left: 0;
    background: var(--color-primary); color: #fff;
    padding: .5rem 1rem; z-index: 9999;
    border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { top: 0; }

/* ── Header ────────────────────────────────────────────── */
.site-header {
    background: var(--color-surface);
    border-bottom: 3px solid var(--color-primary);
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 100;
}

.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1.25rem; gap: 1rem;
}

.site-logo {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 700; font-size: 1.15rem;
    color: var(--color-primary); text-decoration: none;
}
.logo-text { white-space: nowrap; }

/* Taalknopjes */
.lang-switcher { display: flex; gap: .3rem; }
.lang-btn {
    padding: .25rem .5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .75rem; font-weight: 600;
    color: var(--color-text);
    transition: var(--transition);
}
.lang-btn.active,
.lang-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* Hamburger */
.nav-toggle {
    display: flex; flex-direction: column;
    justify-content: space-between;
    width: 28px; height: 20px;
    background: none; border: none;
    cursor: pointer; padding: 0;
}
.nav-toggle span {
    display: block; height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Navigatie */
.main-nav {
    display: none;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}
.main-nav.open { display: block; }

.main-nav ul { list-style: none; }
.main-nav a {
    display: block; padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text); font-weight: 500;
    transition: var(--transition);
}
.main-nav a:hover {
    background: var(--color-primary);
    color: #fff; text-decoration: none;
}

@media (min-width: 768px) {
    .nav-toggle { display: none; }
    .main-nav { display: block; border-top: none; }
    .main-nav ul { display: flex; padding: 0 1.25rem; }
    .main-nav a {
        border-bottom: none; border-radius: 0;
        padding: .6rem 1rem;
    }
}

/* ── Niveau-schakelaar ─────────────────────────────────── */
.level-switch {
    display: flex; gap: .5rem;
    justify-content: center;
    margin: 1.5rem auto;
    background: var(--color-border);
    border-radius: var(--radius-lg);
    padding: .25rem;
    width: fit-content;
}
.level-btn {
    padding: .5rem 1.25rem;
    border: none; border-radius: var(--radius-lg);
    cursor: pointer; font-size: .9rem; font-weight: 600;
    background: transparent; color: var(--color-text);
    transition: var(--transition);
}
.level-btn.active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

/* ── Kaartjes ──────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

@media (min-width: 480px) {
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 768px) {
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem; padding: 1.5rem; }
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.card__img {
    width: 100%; aspect-ratio: 4/3;
    object-fit: cover;
    background: #e8f5e9;
}
.card__body { padding: .85rem 1rem 1rem; }
.card__title { font-size: 1rem; font-weight: 700; margin-bottom: .25rem; }
.card__subtitle { font-size: .8rem; color: #666; font-style: italic; }

/* ── Hero section ──────────────────────────────────────── */
.hero {
    position: relative;
    background: linear-gradient(135deg, var(--color-primary) 0%, #1a4d30 100%);
    color: #fff;
    padding: 3rem 1.5rem;
    text-align: center;
    overflow: hidden;
}
.hero::after {
    content: '🦋'; font-size: 8rem;
    position: absolute; right: -1rem; bottom: -1rem;
    opacity: .12; pointer-events: none;
}
.hero__title { font-size: clamp(1.8rem, 5vw, 3rem); margin-bottom: .75rem; }
.hero__sub   { font-size: clamp(1rem, 2.5vw, 1.3rem); opacity: .9; }

/* ── Detail pagina ─────────────────────────────────────── */
.detail-layout {
    max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem;
}
.detail-header {
    display: flex; flex-direction: column; gap: 1.5rem; margin-bottom: 2rem;
}
@media (min-width: 600px) {
    .detail-header { flex-direction: row; align-items: flex-start; }
}
.detail-image {
    width: 100%; max-width: 320px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    object-fit: cover; aspect-ratio: 1;
}
.detail-meta { flex: 1; }
.detail-meta h1 { font-size: clamp(1.4rem, 4vw, 2rem); color: var(--color-primary); }
.detail-meta .scientific { font-style: italic; color: #666; margin-bottom: 1rem; }

/* Gallerij */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .75rem; margin: 1.5rem 0;
}
.gallery img {
    width: 100%; aspect-ratio: 1;
    object-fit: cover; border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--transition);
}
.gallery img:hover { opacity: .85; }

/* Tekst secties */
.content-section { margin: 2rem 0; }
.content-section h2 { color: var(--color-primary); margin-bottom: .75rem; }

/* ── TTS balk ──────────────────────────────────────────── */
.tts-bar {
    position: fixed; bottom: 1rem; right: 1rem;
    display: flex; gap: .5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: .5rem .75rem;
    box-shadow: var(--shadow-md);
    z-index: 200;
}
.tts-btn {
    padding: .45rem 1rem;
    border: none; border-radius: var(--radius-lg);
    cursor: pointer; font-size: .85rem; font-weight: 600;
    transition: var(--transition);
}
.tts-btn--play  { background: var(--color-primary);   color: #fff; }
.tts-btn--pause { background: var(--color-secondary);  color: #fff; }
.tts-btn--stop  { background: #e74c3c; color: #fff; }
.tts-btn:hover  { opacity: .88; }

/* Actieve zin highlight */
.tts-active {
    background: rgba(245, 166, 35, .3);
    border-radius: 3px;
    transition: background .3s;
}

/* ── Flash berichten ────────────────────────────────────── */
.flash {
    padding: .85rem 3rem .85rem 1rem;
    margin: 0; position: relative;
    font-weight: 500;
}
.flash--success { background: #d4edda; color: #155724; }
.flash--error   { background: #f8d7da; color: #721c24; }
.flash--info    { background: #d1ecf1; color: #0c5460; }
.flash-close {
    position: absolute; right: 1rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    font-size: 1.25rem; cursor: pointer; opacity: .7;
}

/* ── Formulieren ────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block; margin-bottom: .4rem;
    font-weight: 600; font-size: .9rem;
}
.form-control {
    width: 100%; padding: .65rem .9rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem; font-family: inherit;
    background: var(--color-surface);
    transition: border-color var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45,122,79,.15);
}

/* ── Knoppen ────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .7rem 1.5rem;
    border: none; border-radius: var(--radius-lg);
    font-size: 1rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: var(--transition);
    min-height: 44px; /* Toegankelijk tapgebied */
}
.btn--primary   { background: var(--color-primary);   color: #fff; }
.btn--secondary { background: var(--color-secondary); color: #fff; }
.btn--accent    { background: var(--color-accent);    color: #fff; }
.btn--outline   {
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}
.btn:hover { opacity: .88; transform: translateY(-1px); }

/* ── Leven-cyclus stappen ───────────────────────────────── */
.lifecycle {
    display: flex; flex-direction: column; gap: 1.5rem;
    padding: 1.5rem 1rem;
}
@media (min-width: 768px) {
    .lifecycle { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
.lifecycle-step {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    text-align: center; flex: 1; min-width: 140px; max-width: 180px;
    position: relative;
}
.lifecycle-step__icon { font-size: 2.5rem; margin-bottom: .5rem; }
.lifecycle-step__title { font-weight: 700; }
.lifecycle-arrow {
    display: none; align-self: center; font-size: 1.5rem; color: var(--color-secondary);
}
@media (min-width: 768px) { .lifecycle-arrow { display: flex; } }

/* ── Quiz ───────────────────────────────────────────────── */
.quiz-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.quiz-options { list-style: none; display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.quiz-option {
    padding: .75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--transition);
}
.quiz-option:hover   { border-color: var(--color-primary); background: #f0faf5; }
.quiz-option.correct { border-color: #27ae60; background: #eafaf1; }
.quiz-option.wrong   { border-color: #e74c3c; background: #fdf3f3; }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
    background: var(--color-primary);
    color: rgba(255,255,255,.9);
    padding: 2rem 1.25rem;
    margin-top: auto;
}
.footer-inner {
    max-width: 1000px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 1rem;
    align-items: center; text-align: center;
}
.footer-logo { font-size: 1.2rem; font-weight: 700; color: #fff; }
.footer-nav  { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.footer-nav a { color: rgba(255,255,255,.8); font-size: .9rem; }
.footer-nav a:hover { color: #fff; }
.footer-copy { font-size: .8rem; opacity: .7; }

/* ── Lazy loading placeholder ───────────────────────────── */
img[loading="lazy"] { background: #e8f0e8; }

/* ── Utilities ──────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}