/* saas-template brand layer — sits on top of Pico CSS (pico.min.css).
 * Pico is the design system; this file only (1) repaints Pico's primary to the
 * project indigo for light and dark, and (2) adds the few components Pico doesn't
 * ship: the brand mark, nav active-state, breadcrumbs polish, hero, feature grid,
 * badges and notices. Restyle the app from the tokens below — avoid new ad-hoc CSS.
 */

/* 1 — Indigo primary. The selectors below mirror Pico's own theme selectors
 * exactly so these overrides win on specificity (Pico sets --pico-primary under
 * ':root:not([data-theme=dark]),[data-theme=light]', not a bare ':root'). */
:root { --pico-border-radius: 0.5rem; }

:root:not([data-theme=dark]),
[data-theme="light"] {
    --pico-primary: #4f46e5;
    --pico-primary-background: #4f46e5;
    --pico-primary-border: #4f46e5;
    --pico-primary-hover: #4338ca;
    --pico-primary-hover-background: #4338ca;
    --pico-primary-hover-border: #4338ca;
    --pico-primary-focus: rgba(79, 70, 229, 0.25);
    --pico-primary-inverse: #ffffff;
    --pico-primary-underline: rgba(79, 70, 229, 0.4);
    --brand-accent-soft: #eef2ff;
}

/* Dark: Pico applies dark vars via the prefers-color-scheme media query (auto
 * theme) and via [data-theme=dark] (explicit). Match both. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --pico-primary: #a5b4fc;
        --pico-primary-background: #6366f1;
        --pico-primary-border: #6366f1;
        --pico-primary-hover: #c7d2fe;
        --pico-primary-hover-background: #818cf8;
        --pico-primary-hover-border: #818cf8;
        --pico-primary-focus: rgba(129, 140, 248, 0.3);
        --pico-primary-inverse: #ffffff;
        --pico-primary-underline: rgba(165, 180, 252, 0.4);
        --brand-accent-soft: #1e1b3a;
    }
}
[data-theme="dark"] {
    --pico-primary: #a5b4fc;
    --pico-primary-background: #6366f1;
    --pico-primary-border: #6366f1;
    --pico-primary-hover: #c7d2fe;
    --pico-primary-hover-background: #818cf8;
    --pico-primary-hover-border: #818cf8;
    --pico-primary-focus: rgba(129, 140, 248, 0.3);
    --pico-primary-inverse: #ffffff;
    --pico-primary-underline: rgba(165, 180, 252, 0.4);
    --brand-accent-soft: #1e1b3a;
}

/* 2 — App shell: sticky, blurred header; footer pinned to the bottom. */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > footer.site-footer { margin-top: auto; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--pico-background-color);
    border-bottom: 1px solid var(--pico-muted-border-color);
    backdrop-filter: saturate(180%) blur(8px);
}

.app-header > nav { padding-block: 0.25rem; }

/* Brand mark + wordmark */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--pico-color);
    --pico-text-decoration: none;
}

.brand::before {
    content: "";
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    flex: none;
}

/* Primary nav links: muted by default, solid + accented on the current page. */
.app-header nav a:not(.brand):not([role="button"]) {
    color: var(--pico-secondary);
    --pico-text-decoration: none;
    font-weight: 500;
}

.app-header nav a:not(.brand):not([role="button"]):hover {
    color: var(--pico-color);
}

.app-header nav a[aria-current="page"] {
    color: var(--pico-primary);
    font-weight: 600;
}

.nav-email {
    color: var(--pico-secondary);
    font-size: 0.85rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Smaller buttons for header actions */
.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    width: auto;
}

/* Theme toggle: a ghost icon button in the header (wired by /static/js/theme.js) */
.theme-toggle {
    width: auto;
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
    line-height: 1;
    background: transparent;
    border: 1px solid var(--pico-muted-border-color);
    color: var(--pico-secondary);
    border-radius: var(--pico-border-radius);
}
.theme-toggle:hover,
.theme-toggle:focus {
    background: transparent;
    color: var(--pico-primary);
    border-color: var(--pico-primary);
}

/* Breadcrumb spacing (Pico styles the separators) */
nav[aria-label="breadcrumb"] { margin-bottom: 0.75rem; font-size: 0.9rem; }
nav[aria-label="breadcrumb"] a { --pico-text-decoration: none; }

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--pico-secondary);
    --pico-text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.back-link:hover { color: var(--pico-primary); }

.page-title { margin-bottom: 1.5rem; }
.page-title h1, .page-title h2 { margin-bottom: 0.25rem; }
.page-title p { color: var(--pico-secondary); margin-bottom: 0; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    color: var(--pico-secondary);
    padding-block: 1.5rem;
    font-size: 0.9rem;
}
.site-footer nav { padding: 0; }
.site-footer a { color: var(--pico-secondary); }
.site-footer a:hover { color: var(--pico-primary); }

/* 3 — Marketing components */
.hero { text-align: center; padding: 5.5rem 0 4rem; }
.hero h1 { font-size: clamp(2.4rem, 5.5vw, 3.4rem); letter-spacing: -0.03em; line-height: 1.1; }
.hero .subtitle { font-size: 1.15rem; color: var(--pico-secondary); max-width: 640px; margin: 1rem auto 2rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.hero-actions [role="button"] { width: auto; }

.eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pico-primary);
    background: var(--brand-accent-soft);
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    margin-bottom: 1.25rem;
}

.section-muted { background: var(--pico-card-background-color); border-block: 1px solid var(--pico-muted-border-color); }
.section { padding: 4.5rem 0; }
.section-title { text-align: center; margin-bottom: 2.5rem; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 1.25rem;
}
.feature-grid article { margin: 0; }
.feature-grid h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.feature-grid p { color: var(--pico-secondary); font-size: 0.95rem; margin-bottom: 0; }

.benefit-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: var(--brand-accent-soft);
    margin-bottom: 1rem;
}

.stack-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem; margin-top: 2.5rem; }

.cta-box { text-align: center; padding: 3rem 2rem; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--pico-muted-border-color);
    color: var(--pico-secondary);
    background: var(--pico-background-color);
    line-height: 1.5;
}
.badge.accent { color: var(--pico-primary); background: var(--brand-accent-soft); border-color: transparent; }

/* Notices (Pico ships no alert component) */
.notice {
    padding: 0.85rem 1rem;
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-muted-border-color);
    background: var(--pico-card-background-color);
    font-size: 0.925rem;
}
.notice-success { border-color: #16a34a; color: #15803d; background: color-mix(in srgb, #16a34a 8%, transparent); }
.notice-danger { border-color: #dc2626; color: #b91c1c; background: color-mix(in srgb, #dc2626 8%, transparent); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .notice-success { color: #4ade80; }
    :root:not([data-theme]) .notice-danger { color: #f87171; }
}

/* Danger zone card + button */
article.danger-zone { border: 1px solid color-mix(in srgb, #dc2626 45%, var(--pico-muted-border-color)); }
article.danger-zone h3 { color: #dc2626; }
.btn-danger { --pico-background-color: #dc2626; --pico-border-color: #dc2626; --pico-color: #fff; }
.btn-danger:hover { --pico-background-color: #b91c1c; --pico-border-color: #b91c1c; }

/* Toast (profile save/delete feedback) */
.toast {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2000;
    padding: 0.8rem 1.1rem;
    border-radius: var(--pico-border-radius);
    box-shadow: var(--pico-card-box-shadow);
    background: var(--pico-card-background-color);
    border-left: 3px solid var(--pico-primary);
    font-size: 0.9rem;
}
.toast.success { border-left-color: #16a34a; }
.toast.error { border-left-color: #dc2626; }

/* Auth pages (login): narrow, centered card on its own minimal shell */
.auth-main { max-width: 25rem; margin-top: 3.5rem; }
.auth-main hgroup { text-align: center; }
.auth-main .notice { margin-top: 1rem; }
.app-header .back-link { margin: 0; }

/* Layout helpers */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.metric-grid article { margin: 0; text-align: center; }
.metric-check { font-size: 1.6rem; margin: 0.35rem 0; color: #16a34a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .metric-check { color: #4ade80; } }
[data-theme="dark"] .metric-check { color: #4ade80; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--pico-secondary); }
.stack > * + * { margin-top: 1rem; }

/* Generated identicon avatar (internal/avatar) */
.avatar { display: inline-block; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; vertical-align: middle; }
.avatar svg { display: block; width: 100%; height: 100%; }
.page-title-avatar { display: flex; align-items: center; gap: 1rem; }

@media (max-width: 720px) {
    .nav-email { display: none; }
    .hero { padding: 3.5rem 0 2.5rem; }
}


/* Waitlist form (landing page email capture, D22) */
.waitlist-form { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin-top: 1.25rem; }
.waitlist-form input[type=email] { flex: 1 1 220px; max-width: 320px; margin-bottom: 0; }
.waitlist-form button { flex: 0 0 auto; }
.waitlist-success { color: #16a34a; margin-top: 0.75rem; }
.waitlist-error { color: #dc2626; margin-top: 0.75rem; }
