/* assets/css/site.css — shared design system (nav, buttons, hero, cards, footer).
 * Included on every public page via includes/site_top.php; served as a single
 * external, cacheable file instead of being re-inlined on each request. */

    *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root, [data-theme="dark"] {
      --bg: #06080f; --bg2: #0a0d18; --surface: #11162a; --surface2: #1a2138;
      --border: rgba(148,163,184,0.10); --border-strong: rgba(148,163,184,0.22);
      --accent: #1d4ed8; --accent2: #60a5fa; --accent-glow: rgba(59,130,246,0.35);
      --accent-green: #22d3ee; --accent-purple: #a78bfa;
      --text: #f1f5f9; --text-muted: #94a3b8; --text-dim: #7a8aa8;
      --font-head: 'Space Grotesk','Inter',system-ui,sans-serif;
      --font-mono: 'JetBrains Mono',ui-monospace,monospace;
      --font-body: 'Inter',system-ui,-apple-system,sans-serif;
      --shadow-card: 0 12px 40px rgba(0,0,0,0.30);
    }
    [data-theme="light"] {
      --bg: #fafbfd; --bg2: #f1f4f9; --surface: #ffffff; --surface2: #f1f5f9;
      --border: rgba(15,23,42,0.08); --border-strong: rgba(15,23,42,0.16);
      --accent: #2563eb; --accent2: #1d4ed8; --accent-glow: rgba(37,99,235,0.18);
      --accent-green: #0891b2; --accent-purple: #7c3aed;
      --text: #0f172a; --text-muted: #475569; --text-dim: #64748b;
      --shadow-card: 0 12px 40px rgba(15,23,42,0.08);
    }

    html { scroll-behavior: smooth; }
    body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.6; min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; transition: background .3s, color .3s; }
    a { color: inherit; }
    .grid-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; background-image: linear-gradient(var(--border) 1px,transparent 1px), linear-gradient(90deg,var(--border) 1px,transparent 1px); background-size: 60px 60px; opacity: .5; }
    .wrap { max-width: 1000px; margin: 0 auto; padding: 0 clamp(20px,5vw,40px); position: relative; z-index: 1; }

    /* Nav */
    nav { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px,5vw,48px); height: 72px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); transition: height .2s ease, background .2s ease; }
    nav.scrolled { height: 60px; background: color-mix(in srgb, var(--bg) 92%, transparent); }
    .logo { display: flex; align-items: center; height: 40px; text-decoration: none; }
    .brand-logo { height: 30px; width: auto; }
    .dark-logo { display: none; } [data-theme="dark"] .dark-logo { display: block; } [data-theme="dark"] .light-logo { display: none; }
    .nav-links { display: flex; gap: 30px; list-style: none; }
    .nav-links a { color: var(--text-muted); text-decoration: none; font-size: 15px; font-weight: 500; transition: color .2s; }
    .nav-links a:hover { color: var(--text); }
    .nav-cta { display: flex; align-items: center; gap: 14px; }
    .theme-toggle { background: transparent; border: 1px solid var(--border); color: var(--text-muted); width: 38px; height: 38px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
    .theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
    /* Global search icon — same box as the theme toggle, tuned for a link:
       centred glyph, no underline, consistent padding/radius, hover + pressed +
       keyboard-focus states, and theme-aware via the CSS variables. */
    .nav-search { box-sizing: border-box; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1; text-decoration: none; cursor: pointer; transition: all .2s; }
    .nav-search:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface2); }
    .nav-search:active { transform: scale(.94); }
    .nav-search:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
    [data-theme="dark"] .fa-moon { display: none; } [data-theme="light"] .fa-sun { display: none; }
    .btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 10px; font-family: var(--font-body); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: all .2s; white-space: nowrap; }
    .btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 20px var(--accent-glow); }
    .btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
    .btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
    .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
    .btn-lg { padding: 14px 26px; font-size: 15px; border-radius: 12px; }
    .hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 6px; background: none; border: none; }
    .hamburger span { display: block; width: 24px; height: 2px; background: var(--text); border-radius: 2px; }

    .mobile-menu { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 96%, transparent); backdrop-filter: blur(20px); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; opacity: 0; pointer-events: none; transition: opacity .3s; padding: 24px; }
    .mobile-menu.open { opacity: 1; pointer-events: all; }
    .mobile-menu a:not(.btn) { font-family: var(--font-head); font-size: clamp(24px,7vw,30px); font-weight: 600; color: var(--text-muted); text-decoration: none; }
    .mobile-menu a:not(.btn):hover { color: var(--accent2); }
    .mobile-menu .btn { font-size: 16px; }
    .mobile-close { position: absolute; top: 18px; right: 22px; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px; background: none; color: var(--text-muted); font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

    .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

    /* Page hero */
    .page-hero { padding: clamp(56px,9vw,96px) 0 clamp(32px,5vw,48px); text-align: center; position: relative; z-index: 1; }
    .page-eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: .15em; text-transform: uppercase; color: var(--accent2); margin-bottom: 16px; }
    .page-title { font-family: var(--font-head); font-size: clamp(34px,6vw,60px); font-weight: 700; letter-spacing: -.03em; line-height: 1.08; }
    .page-sub { font-size: clamp(16px,2.4vw,19px); color: var(--text-muted); max-width: 680px; margin: 18px auto 0; }

    /* Content */
    main { position: relative; z-index: 1; padding-bottom: clamp(60px,9vw,110px); }
    .prose { max-width: 760px; margin: 0 auto; }
    .prose h2 { font-family: var(--font-head); font-size: clamp(22px,3.4vw,30px); font-weight: 700; letter-spacing: -.02em; margin: 40px 0 14px; }
    .prose h3 { font-family: var(--font-head); font-size: clamp(18px,2.6vw,22px); font-weight: 600; margin: 28px 0 10px; }
    .prose p { color: var(--text-muted); margin-bottom: 16px; }
    .prose ul { color: var(--text-muted); margin: 0 0 16px 22px; }
    .prose li { margin-bottom: 8px; }
    .prose a { color: var(--accent2); text-decoration: none; } .prose a:hover { text-decoration: underline; }
    .card-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap: 22px; max-width: 1000px; margin: 0 auto; }
    .ui-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: clamp(24px,3vw,30px); box-shadow: var(--shadow-card); transition: transform .25s, border-color .25s; }
    .ui-card:hover { transform: translateY(-4px); border-color: var(--border-strong); }
    .ui-card h3 { font-family: var(--font-head); font-size: 19px; font-weight: 700; margin-bottom: 10px; }
    .ui-card p { color: var(--text-muted); font-size: 15px; }
    .ui-ico { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg,var(--accent),var(--accent-green)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; margin-bottom: 18px; }

    /* Footer */
    footer { border-top: 1px solid var(--border); padding: clamp(48px,7vw,72px) clamp(20px,5vw,48px) 32px; position: relative; z-index: 1; background: var(--bg); }
    .footer-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; }
    .footer-brand p { color: var(--text-muted); font-size: 14px; margin-top: 16px; max-width: 280px; }
    .footer-col .footer-h { font-size: 13px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--text); margin-bottom: 16px; }
    .footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
    .footer-col a { color: var(--text-muted); text-decoration: none; font-size: 14px; transition: color .2s; }
    .footer-col a:hover { color: var(--accent2); }
    .footer-bottom { max-width: 1100px; margin: 48px auto 0; padding-top: 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
    .footer-bottom p { color: var(--text-dim); font-size: 13px; }
    .footer-social { display: flex; gap: 12px; }
    .social-link { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); text-decoration: none; transition: all .2s; }
    .social-link:hover { color: var(--accent2); border-color: var(--accent2); }

    @media (max-width: 860px) {
      .nav-links, .nav-cta .btn, #themeToggleDesktop, .nav-search { display: none; }
      .hamburger { display: flex; }
      .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
    }
    @media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

    /* ============================================================
       UI POLISH v2 — depth, motion & micro-interactions.
       Additive override layer; both themes supported.
       ============================================================ */

    /* Ambient backdrop: aurora glow behind the hero, grid fades downward */
    .grid-bg {
      -webkit-mask-image: radial-gradient(ellipse 110% 70% at 50% 0%, #000 20%, transparent 75%);
              mask-image: radial-gradient(ellipse 110% 70% at 50% 0%, #000 20%, transparent 75%);
    }
    .grid-bg::before {
      content: ''; position: absolute; inset: 0;
      background:
        radial-gradient(700px 380px at 15% -8%, var(--accent-glow), transparent 70%),
        radial-gradient(600px 340px at 85% -4%, rgba(34,211,238,0.13), transparent 70%);
      opacity: .5;
    }
    [data-theme="light"] .grid-bg::before { opacity: .35; }

    /* Text selection + slim themed scrollbars */
    ::selection { background: rgba(59,130,246,0.4); color: #fff; }
    [data-theme="light"] ::selection { background: rgba(37,99,235,0.18); color: var(--text); }
    * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 8px; border: 2px solid var(--bg); }

    /* Visible keyboard focus */
    a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
      outline: 2px solid var(--accent2); outline-offset: 2px;
    }

    /* Nav links: animated underline sweep */
    .nav-links a { position: relative; padding-bottom: 4px; }
    .nav-links a::after {
      content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 2px;
      border-radius: 2px; background: linear-gradient(90deg, var(--accent2), var(--accent-green));
      transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
    }
    .nav-links a:hover::after { transform: scaleX(1); }

    /* Buttons: gradient primary with press state */
    .btn-primary {
      background: linear-gradient(180deg, var(--accent2), var(--accent));
      box-shadow: 0 4px 20px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.22);
    }
    .btn-primary:hover { filter: brightness(1.08); }
    .btn-primary:active { transform: translateY(0); box-shadow: 0 3px 12px var(--accent-glow); }

    /* Cards: luminous top edge + slightly stronger hover */
    .ui-card { position: relative; overflow: hidden; }
    .ui-card::before {
      content: ''; position: absolute; top: 0; left: 8%; right: 8%; height: 1px;
      background: linear-gradient(90deg, transparent, rgba(99,179,237,0.35), transparent);
      pointer-events: none;
    }
    .ui-card:hover { box-shadow: var(--shadow-card), 0 0 0 1px var(--border-strong); }
    [data-theme="light"] .ui-card::before { background: linear-gradient(90deg, transparent, rgba(37,99,235,0.18), transparent); }

    /* Page-enter motion for hero */
    @keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
    .page-hero > * { animation: riseIn .55s cubic-bezier(.22,1,.36,1) both; }
    .page-hero > *:nth-child(2) { animation-delay: .08s; }
    .page-hero > *:nth-child(3) { animation-delay: .16s; }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
      html { scroll-behavior: auto; }
    }

    /* Breadcrumbs (shared: templates, blog, docs, …) */
    .crumbs { max-width: 1000px; margin: 0 auto; padding: 20px clamp(20px,5vw,40px) 0; font-size: 13px; }
    .crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0; }
    .crumbs li { display: flex; align-items: center; gap: 8px; color: var(--text-dim); }
    .crumbs li:not(:first-child)::before { content: '/'; color: var(--text-dim); opacity: .5; }
    .crumbs a { color: var(--text-muted); text-decoration: none; }
    .crumbs a:hover { color: var(--accent2); }
    .crumbs li[aria-current] { color: var(--text); font-weight: 500; }
