/* ============================================================================
   ToolStack — Public Site Stylesheet
   ----------------------------------------------------------------------
   Mobile-first. No frameworks. Organized in sections:
   1. Design tokens      5. Header & navigation   9. Ad slots
   2. Reset & base       6. Hero                  10. Utilities
   3. Typography          7. Cards & empty states  11. Dark mode
   4. Layout              8. Footer                12. Responsive
   ========================================================================= */

/* ---------------------------------------------------------------------- */
/* 1. Design tokens                                                        */
/* ---------------------------------------------------------------------- */
:root {
    --color-primary: #4F46E5;
    --color-primary-dark: #4338CA;
    --color-primary-light: #EEF2FF;
    --color-accent: #06B6D4;

    --color-bg: #F5F6FA;
    --color-surface: #FFFFFF;
    --color-text: #1E1F26;
    --color-text-muted: #5C5F6E;
    --color-border: #E4E6ED;

    --color-success: #16A34A;
    --color-warning: #F59E0B;
    --color-danger: #DC2626;

    --font-display: 'Sora', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.06);
    --shadow-md: 0 2px 8px rgba(17, 24, 39, 0.08);
    --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.14);

    --header-height: 64px;
    --container-width: 1200px;

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

[data-theme="dark"] {
    --color-primary: #818CF8;
    --color-primary-dark: #6366F1;
    --color-primary-light: #1E1B3A;
    --color-accent: #22D3EE;

    --color-bg: #10111A;
    --color-surface: #1B1D27;
    --color-text: #E8E9EE;
    --color-text-muted: #9B9EAF;
    --color-border: #2A2C3A;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------------- */
/* 2. Reset & base                                                         */
/* ---------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-base), color var(--transition-base);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
input, button { font-family: inherit; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 var(--radius-sm) 0;
    z-index: 1000;
}
.skip-link:focus { left: 0; }

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* ---------------------------------------------------------------------- */
/* 3. Typography                                                           */
/* ---------------------------------------------------------------------- */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 0.5em;
    letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 800; }
h2 { font-size: clamp(1.375rem, 3vw, 1.875rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; color: var(--color-text-muted); }
code, pre { font-family: var(--font-mono); }

/* ---------------------------------------------------------------------- */
/* 4. Layout                                                               */
/* ---------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}
.section { padding: 2.5rem 0; }
.section__header { margin-bottom: 1.25rem; }
.section__header h2 { margin: 0; }

/* ---------------------------------------------------------------------- */
/* 5. Header & navigation                                                  */
/* ---------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.site-header__inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: var(--header-height);
}
.site-logo {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--color-primary);
    flex-shrink: 0;
}
.primary-nav { display: none; flex: 1; }
.primary-nav ul { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.primary-nav a, .primary-nav__empty {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text-muted);
}
.primary-nav a:hover { background: var(--color-primary-light); color: var(--color-primary); }
.primary-nav__empty { color: var(--color-text-muted); opacity: 0.6; cursor: default; }

.site-header__actions { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--color-text);
    border-radius: var(--radius-pill);
    transition: background-color var(--transition-fast);
}
.icon-btn:hover { background: var(--color-primary-light); color: var(--color-primary); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
.nav-toggle { display: inline-flex; }

.search-bar {
    display: none;
    border-top: 1px solid var(--color-border);
    padding: 0.75rem 0;
    background: var(--color-surface);
}
.search-bar.is-open { display: block; }
.search-bar__form,
.hero-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 0.5rem 0.5rem 0.5rem 1rem;
}
.search-bar__form svg, .hero-search svg { flex-shrink: 0; color: var(--color-text-muted); }
.search-bar__form input, .hero-search input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 0.9375rem;
    outline: none;
    min-width: 0;
}
.search-bar__form button, .hero-search button {
    border: none;
    background: var(--color-primary);
    color: #fff;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
    transition: background-color var(--transition-fast);
}
.search-bar__form button:hover, .hero-search button:hover { background: var(--color-primary-dark); }

.mobile-nav { display: none; border-top: 1px solid var(--color-border); background: var(--color-surface); }
.mobile-nav.is-open { display: block; }
.mobile-nav ul { padding: 0.5rem 1.25rem 1rem; }
.mobile-nav a, .mobile-nav .primary-nav__empty {
    display: block;
    padding: 0.75rem 0.25rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 500;
}
.mobile-nav li:last-child a { border-bottom: none; }

/* ---------------------------------------------------------------------- */
/* 6. Hero                                                                 */
/* ---------------------------------------------------------------------- */
.hero { padding: 3rem 0 2.5rem; text-align: center; }
.hero__inner { max-width: 720px; }
.hero__subtitle { font-size: 1.0625rem; margin-bottom: 1.75rem; }
.hero-search { max-width: 560px; margin: 0 auto; box-shadow: var(--shadow-sm); }
.hero-search input { font-size: 1rem; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; }
.chip {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ---------------------------------------------------------------------- */
/* 7. Cards & empty states                                                 */
/* ---------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
}
.empty-state svg { margin: 0 auto 1rem; color: var(--color-primary); }
.empty-state h3 { color: var(--color-text); }
.empty-state p { max-width: 420px; margin-inline: auto; }

.not-found { text-align: center; padding: 4rem 0; }
.not-found__code {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 800;
    color: var(--color-primary);
    margin: 0;
}

.btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.9375rem;
    transition: background-color var(--transition-fast);
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }

/* Breadcrumbs (produced by render_breadcrumbs() in functions.php) */
.breadcrumbs { padding: 0.75rem 0; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.8125rem; color: var(--color-text-muted); }
.breadcrumbs li:not(:last-child)::after { content: '/'; margin-left: 0.4rem; color: var(--color-border); }
.breadcrumbs a:hover { color: var(--color-primary); }

/* ---------------------------------------------------------------------- */
/* 8. Footer                                                               */
/* ---------------------------------------------------------------------- */
.site-footer { margin-top: 2rem; background: var(--color-surface); border-top: 1px solid var(--color-border); }
.site-footer__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2.5rem 0 1.5rem;
}
.footer-col h3 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.footer-col ul li { margin-bottom: 0.5rem; }
.footer-col a { color: var(--color-text); font-size: 0.9375rem; }
.footer-col a:hover { color: var(--color-primary); }
.footer-col .muted { color: var(--color-text-muted); font-size: 0.875rem; }
.footer-tagline { font-size: 0.9375rem; }
.site-footer__bottom {
    border-top: 1px solid var(--color-border);
    padding: 1.25rem 0;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}
.site-footer__bottom p { margin: 0; }

/* ---------------------------------------------------------------------- */
/* 9. Ad slots — reserve space up front to avoid layout shift (CLS)        */
/* ---------------------------------------------------------------------- */
.ad-slot {
    display: block;
    margin: 1.5rem auto;
    max-width: var(--container-width);
}
.ad-slot:empty { display: none; } /* nothing reserved until an ad is actually enabled */
.ad-slot--header, .ad-slot--footer { margin: 0; }

/* ---------------------------------------------------------------------- */
/* 10. Utilities                                                          */
/* ---------------------------------------------------------------------- */
.text-center { text-align: center; }
.muted { color: var(--color-text-muted); }

/* ---------------------------------------------------------------------- */
/* 11b. Auth pages (install.php, admin/login.php)                         */
/* ---------------------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    background: var(--color-bg);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 2rem;
}
.auth-card__logo { text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; color: var(--color-primary); margin-bottom: 0.25rem; }
.auth-card__subtitle { text-align: center; font-size: 0.875rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.4rem; }
.form-group input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.9375rem;
}
.form-group input:focus { border-color: var(--color-primary); }
.form-hint { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.3rem; }
.btn-block { width: 100%; text-align: center; border: none; }
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}
.alert--error { background: #FEF2F2; color: var(--color-danger); border: 1px solid #FCA5A5; }
.alert--success { background: #F0FDF4; color: var(--color-success); border: 1px solid #86EFAC; }
[data-theme="dark"] .alert--error { background: #2A1418; border-color: #7F1D1D; }
[data-theme="dark"] .alert--success { background: #0F2A1A; border-color: #14532D; }
/* honeypot field — invisible to people, present for simple bots */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------------- */
/* 12. Responsive — mobile-first, scale up from here                      */
/* ---------------------------------------------------------------------- */
@media (min-width: 768px) {
    .site-footer__grid { grid-template-columns: 2fr 1fr 1fr; }
}

@media (min-width: 960px) {
    .primary-nav { display: flex; }
    .nav-toggle { display: none; } /* categories already visible in .primary-nav, no hamburger needed */
}
