/* =====================================================================
   PDFEzy — Design System (main.css)
   Aesthetic direction: "Minimal-AI Clarity" — bright, spacious, trustworthy
   utility UI with one confident accent, soft custom elevation, and a fully
   paired light/dark theme. Tokens in OKLCH; theme via color-scheme + light-dark().
   Fonts: Bricolage Grotesque (display) + Plus Jakarta Sans (body).
   ===================================================================== */

@layer base, components, utilities;

/* ----------------------------- Tokens ------------------------------- */
:root {
    color-scheme: light dark;

    /* Brand accent (confident azure-indigo) + neutrals */
    --accent:        light-dark(oklch(55% 0.18 256), oklch(72% 0.15 256));
    --accent-strong: light-dark(oklch(48% 0.19 256), oklch(80% 0.13 256));
    --accent-contrast: oklch(99% 0 0);
    --accent-subtle: color-mix(in oklch, var(--accent) 12%, transparent);
    --accent-ring:   color-mix(in oklch, var(--accent) 45%, transparent);

    /* Surfaces & text */
    --bg:          light-dark(oklch(98.5% 0.004 256), oklch(15% 0.018 256));
    --surface:     light-dark(oklch(100% 0 0),        oklch(19.5% 0.02 256));
    --surface-2:   light-dark(oklch(97% 0.006 256),   oklch(23% 0.022 256));
    --surface-3:   light-dark(oklch(94.5% 0.008 256), oklch(27% 0.024 256));
    --text:        light-dark(oklch(24% 0.02 262),    oklch(95% 0.008 262));
    --text-muted:  light-dark(oklch(47% 0.02 262),    oklch(72% 0.015 262));
    --border:      light-dark(oklch(90% 0.01 262),    oklch(32% 0.02 262));
    --border-strong: light-dark(oklch(82% 0.015 262), oklch(42% 0.02 262));

    /* Semantic */
    --success: light-dark(oklch(58% 0.15 150), oklch(72% 0.16 150));
    --danger:  light-dark(oklch(58% 0.2 27),   oklch(70% 0.18 27));
    --warning: light-dark(oklch(70% 0.16 75),  oklch(80% 0.15 75));
    --info: var(--accent);

    /* Elevation — soft, layered, themed (not generic) */
    --shadow-sm: 0 1px 2px light-dark(oklch(50% 0.03 262 / 0.08), oklch(0% 0 0 / 0.4));
    --shadow-md: 0 4px 14px light-dark(oklch(50% 0.04 262 / 0.1), oklch(0% 0 0 / 0.45)),
                 0 1px 3px light-dark(oklch(50% 0.04 262 / 0.06), oklch(0% 0 0 / 0.4));
    --shadow-lg: 0 18px 48px light-dark(oklch(45% 0.05 262 / 0.16), oklch(0% 0 0 / 0.55)),
                 0 4px 12px light-dark(oklch(45% 0.05 262 / 0.08), oklch(0% 0 0 / 0.4));

    /* Radius & spacing scale */
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    --container: 1180px;
    --space-section: clamp(3.5rem, 8vw, 6.5rem);

    /* Type */
    --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;

    /* Legacy aliases kept so older inline references still resolve */
    --primary-color: var(--accent);
    --primary-dark: var(--accent-strong);
    --text-dark: var(--text);
    --text-medium: var(--text-muted);
    --text-light: var(--accent-contrast);
    --background-light: var(--bg);
    --background-white: var(--surface);
    --success-color: var(--success);
    --danger-color: var(--danger);
    --warning-color: var(--warning);
    --info-color: var(--info);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ----------------------------- Reset -------------------------------- */
@layer base {
    *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

    html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

    body {
        font-family: var(--font-body);
        font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
        line-height: 1.65;
        color: var(--text);
        background: var(--bg);
        -webkit-font-smoothing: antialiased;
        text-rendering: optimizeLegibility;
        overflow-x: hidden;
    }

    img, picture, svg, canvas { max-width: 100%; display: block; }

    h1, h2, h3, h4 {
        font-family: var(--font-display);
        line-height: 1.12;
        letter-spacing: -0.02em;
        font-weight: 700;
        color: var(--text);
        text-wrap: balance;
    }
    h1 { font-size: clamp(2.25rem, 1.6rem + 3.2vw, 3.75rem); }
    h2 { font-size: clamp(1.75rem, 1.35rem + 1.9vw, 2.6rem); }
    h3 { font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem); }
    p { text-wrap: pretty; }

    a { color: var(--accent); text-decoration: none; transition: color 0.2s ease; }
    a:hover { color: var(--accent-strong); }

    button { cursor: pointer; font-family: inherit; color: inherit; }

    ::selection { background: var(--accent-subtle); }
}

/* --------------------------- Layout --------------------------------- */
@layer base {
    .container {
        width: 100%;
        max-width: var(--container);
        margin-inline: auto;
        padding-inline: clamp(1rem, 4vw, 2rem);
    }

    main { display: block; }

    section { scroll-margin-top: 90px; }
}

/* --------------------------- Buttons -------------------------------- */
@layer components {
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.8rem 1.4rem;
        min-height: 44px;
        border: 1px solid transparent;
        border-radius: var(--radius-pill);
        font-weight: 600;
        font-size: 0.98rem;
        line-height: 1;
        text-align: center;
        transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
        white-space: nowrap;
    }
    .btn:active { transform: translateY(1px); }

    .btn-primary {
        background: var(--accent);
        color: var(--accent-contrast);
        box-shadow: var(--shadow-sm);
    }
    .btn-primary:hover { background: var(--accent-strong); color: var(--accent-contrast); box-shadow: var(--shadow-md); }

    .btn-outline {
        background: transparent;
        border-color: var(--border-strong);
        color: var(--text);
    }
    .btn-outline:hover { background: var(--surface-2); border-color: var(--accent); color: var(--text); }

    .btn-ghost { background: var(--surface-2); color: var(--text); }
    .btn-ghost:hover { background: var(--surface-3); }

    .btn-lg { padding: 1rem 1.8rem; font-size: 1.05rem; }
    .btn-block { width: 100%; }
}

/* --------------------------- Header --------------------------------- */
@layer components {
    header[role="banner"], body > header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: color-mix(in oklch, var(--bg) 82%, transparent);
        backdrop-filter: saturate(1.4) blur(12px);
        border-bottom: 1px solid var(--border);
    }

    .header-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding-block: 0.85rem;
    }

    .logo {
        font-family: var(--font-display);
        font-size: 1.5rem;
        font-weight: 800;
        letter-spacing: -0.03em;
        color: var(--text);
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }
    .logo span { color: var(--accent); }
    .logo svg { width: 30px; height: 30px; }

    nav[aria-label] ul, header nav ul { list-style: none; display: flex; align-items: center; gap: 0.35rem; }

    header nav a {
        color: var(--text-muted);
        font-weight: 600;
        font-size: 0.95rem;
        padding: 0.55rem 0.85rem;
        border-radius: var(--radius-sm);
        transition: color 0.2s ease, background 0.2s ease;
    }
    header nav a:hover, header nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

    .header-actions { display: flex; align-items: center; gap: 0.5rem; }

    /* Dark-mode toggle */
    #theme-toggle {
        width: 42px; height: 42px;
        display: inline-grid; place-items: center;
        border-radius: var(--radius-pill);
        border: 1px solid var(--border);
        background: var(--surface);
        color: var(--text);
        transition: background 0.2s ease, border-color 0.2s ease;
    }
    #theme-toggle:hover { background: var(--surface-2); border-color: var(--border-strong); }
    #theme-toggle .icon-sun { display: none; }
    #theme-toggle .icon-moon { display: block; }
    :root[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
    :root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }
    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) #theme-toggle .icon-sun { display: block; }
        :root:not([data-theme="light"]) #theme-toggle .icon-moon { display: none; }
    }
    #theme-toggle svg { width: 20px; height: 20px; }
}

/* ------------------------ Mobile menu ------------------------------- */
@layer components {
    .menu-toggle {
        display: none;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        width: 44px; height: 44px;
        padding: 0;
        place-items: center;
        z-index: 120;
    }
    .menu-toggle span {
        display: block;
        width: 22px; height: 2px;
        background: var(--text);
        margin: 4px auto;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    .menu-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .menu-toggle.active span:nth-child(2) { opacity: 0; }
    .menu-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

    .mobile-menu {
        position: fixed;
        inset: 0;
        background: var(--bg);
        z-index: 110;
        display: grid;
        place-items: center;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-12px);
        transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    }
    .mobile-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }
    .mobile-menu ul { list-style: none; text-align: center; display: grid; gap: 1.25rem; }
    .mobile-menu a { color: var(--text); font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
    .mobile-menu a:hover { color: var(--accent); }
    body.menu-open { overflow: hidden; }
}

/* --------------------------- Footer --------------------------------- */
@layer components {
    footer[role="contentinfo"], body > footer {
        background: var(--surface-2);
        border-top: 1px solid var(--border);
        padding-block: clamp(2.5rem, 5vw, 4rem) 2rem;
        margin-top: var(--space-section);
    }
    .footer-content {
        display: grid;
        grid-template-columns: 1.6fr repeat(3, 1fr);
        gap: 2rem;
    }
    .footer-column h3 { font-size: 1rem; margin-bottom: 1rem; color: var(--text); }
    .footer-column p { color: var(--text-muted); font-size: 0.95rem; max-width: 32ch; }
    .footer-column ul { list-style: none; display: grid; gap: 0.6rem; }
    .footer-column a { color: var(--text-muted); font-size: 0.93rem; }
    .footer-column a:hover { color: var(--accent); }
    .footer-brand .logo { margin-bottom: 0.85rem; }
    .copyright {
        text-align: center;
        margin-top: 2.5rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border);
        color: var(--text-muted);
        font-size: 0.9rem;
    }
}

/* ------------------------ Notifications ----------------------------- */
@layer components {
    .notification-container {
        position: fixed;
        top: 1rem; right: 1rem;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        gap: 0.6rem;
        max-width: min(380px, calc(100vw - 2rem));
    }
    .notification {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 0.85rem 1rem;
        box-shadow: var(--shadow-lg);
        transform: translateX(120%);
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    .notification.active { transform: translateX(0); }
    .notification-icon {
        flex-shrink: 0;
        width: 32px; height: 32px;
        border-radius: 50%;
        display: grid; place-items: center;
        color: #fff;
        font-size: 1rem;
    }
    .notification-success .notification-icon { background: var(--success); }
    .notification-error .notification-icon { background: var(--danger); }
    .notification-warning .notification-icon { background: var(--warning); color: oklch(25% 0.05 75); }
    .notification-info .notification-icon { background: var(--info); }
    .notification-content { flex-grow: 1; }
    .notification-content p { margin: 0; font-size: 0.92rem; line-height: 1.4; color: var(--text); }
    .notification-close { background: none; border: none; font-size: 1.25rem; color: var(--text-muted); padding: 0 0.25rem; }
    .notification-close:hover { color: var(--text); }
}

/* --------------------- Confirmation dialog -------------------------- */
@layer components {
    .confirmation-overlay {
        position: fixed; inset: 0;
        background: oklch(0% 0 0 / 0.5);
        display: grid; place-items: center;
        z-index: 1000;
        opacity: 0; visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .confirmation-overlay.active { opacity: 1; visibility: visible; }
    .confirmation-dialog {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        width: 90%; max-width: 420px;
        box-shadow: var(--shadow-lg);
        transform: translateY(-16px);
        transition: transform 0.3s ease;
    }
    .confirmation-overlay.active .confirmation-dialog { transform: translateY(0); }
    .confirmation-content { padding: 1.5rem; }
    .confirmation-content p { margin: 0 0 1.5rem; }
    .confirmation-buttons { display: flex; justify-content: flex-end; gap: 0.75rem; }
}

/* --------------------------- Spinner -------------------------------- */
@layer components {
    .spinner {
        width: 40px; height: 40px;
        border: 4px solid var(--surface-3);
        border-top-color: var(--accent);
        border-radius: 50%;
        animation: spin 0.9s linear infinite;
        margin: 20px auto;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
}

/* --------------------------- Animations ----------------------------- */
@layer base {
    .animate-on-scroll { opacity: 0; transform: translateY(26px); transition: opacity 0.6s ease, transform 0.6s ease; }
    .animate-on-scroll.animated { opacity: 1; transform: none; }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    .fade-in { animation: fadeIn 0.5s ease-in; }
}

/* ------------------ Accessibility & utilities ----------------------- */
@layer base {
    .skip-link {
        position: absolute;
        left: 1rem; top: -100px;
        background: var(--accent);
        color: var(--accent-contrast);
        padding: 0.7rem 1.1rem;
        border-radius: var(--radius-sm);
        z-index: 9999;
        transition: top 0.2s ease;
    }
    .skip-link:focus { top: 1rem; color: var(--accent-contrast); }

    :focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 3px;
        border-radius: 4px;
    }
    @media (forced-colors: active) {
        :focus-visible { outline: 3px solid ButtonText; }
    }

    .visually-hidden {
        position: absolute !important;
        width: 1px; height: 1px;
        margin: -1px; padding: 0; border: 0;
        clip: rect(0 0 0 0); clip-path: inset(50%);
        overflow: hidden; white-space: nowrap;
    }
    .hidden { display: none !important; }
    .text-center { text-align: center; }
}

@layer utilities {
    @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;
        }
        .animate-on-scroll { opacity: 1; transform: none; }
    }
}

/* ------------------------- Responsive ------------------------------- */
@media (max-width: 880px) {
    header nav ul { display: none; }
    .menu-toggle { display: grid; }
    .header-actions #theme-toggle { display: inline-grid; }
    .footer-content { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
    .footer-content { grid-template-columns: 1fr; }
}
