/* ==========================================================================
   Klipzy shared stylesheet — clean modern light
   Single source of truth for header, footer, and shared components.
   Brand gradient matches logo.svg (#2563EB -> #7C3AED).
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #f3effd;
  --accent-2: #2563eb;
  --brand-grad: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --danger: #ef4444;
  --success: #16a34a;
  --border: #e2e6ee;
  --line: #cbd5e1;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .14);
  --maxw: 1200px;
  --header-h: 68px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* full-width gradient sections never cause sideways scroll */
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
/* Fluid gutter: scales with browser width so content always fits */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 4vw, 48px); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
/* Credits counter pinned to the true centre of the header. Absolute + translate
   rather than a flex child, so it stays centred on screen no matter how wide the
   logo or the nav links either side happen to be. */
.nav-container { position: relative; }
.nav-usage-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  white-space: nowrap;
}
@media (max-width: 768px) {
  /* No room to centre it next to the burger — sit it beside the logo instead. */
  .nav-usage-center { position: static; transform: none; margin-left: auto; margin-right: .75rem; }
}
.nav-container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; color: var(--text); }
.logo img { height: 48px; width: auto; }
.nav-links { display: flex; align-items: center; gap: .4rem; }
/* Desktop alignment for the guest/user groups (was previously inline on the
   elements, which overrode the mobile stacking rules — now stylesheet-owned so
   the media query below can win on phones). JS toggles their display. */
#guest-nav { display: flex; align-items: center; gap: .4rem; }
#user-nav { align-items: center; gap: .5rem; }
.nav-link {
  padding: .5rem .9rem;
  border-radius: var(--radius-pill);
  font-weight: 500;
  color: var(--text);
  transition: background .2s, color .2s;
}
.nav-link:hover { background: var(--bg-alt); }
.nav-link.cta { background: var(--brand-grad); color: #fff; font-weight: 600; }
.nav-link.cta:hover { opacity: .92; }
.usage-counter {
  background: var(--accent-soft);
  color: var(--accent);
  padding: .4rem .8rem;
  border-radius: var(--radius-pill);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.usage-counter.low { background: #fee2e2; color: var(--danger); }
.user-menu { display: flex; align-items: center; gap: .5rem; }
#user-email {
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem;
}
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: .8rem 1.6rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .2s, box-shadow .2s, background .2s, opacity .2s;
  text-align: center;
}
.btn-primary { background: var(--brand-grad); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(124, 58, 237, .35); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-alt); transform: translateY(-2px); }
.btn-block { display: block; width: 100%; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 5rem 20px 3rem; max-width: 880px; margin: 0 auto; }
.eyebrow {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: .85rem;
  padding: .35rem .9rem;
  border-radius: var(--radius-pill);
  margin-bottom: 1.25rem;
}
.hero h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; margin-bottom: 1.25rem; }
.hero .subtitle { font-size: clamp(1.1rem, 2.5vw, 1.35rem); color: var(--muted); margin-bottom: .5rem; }
.hero .description { font-size: 1.1rem; color: var(--muted); max-width: 640px; margin: 1rem auto 2rem; }
.cta-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Sections ---------- */
.section { padding: 4rem 0; border-top: 1px solid var(--line); }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line); }
.section-title { text-align: center; font-size: clamp(1.7rem, 4vw, 2.25rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: .75rem; }
.section-subtitle { text-align: center; color: var(--muted); max-width: 600px; margin: 0 auto 3rem; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 1.5rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.card .icon { font-size: 2.5rem; margin-bottom: 1rem; }
.card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; }
.card p { color: var(--muted); }

/* ---------- Stats ---------- */
.stat { text-align: center; padding: 1.5rem 1rem; }
.stat .num {
  font-size: 2.75rem;
  font-weight: 800;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat .label { color: var(--muted); font-weight: 500; }

/* ---------- Auth card (login / signup / password) ---------- */
.auth-wrap {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 20px;
  background: var(--bg-alt);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
}
.auth-card h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: .5rem; text-align: center; }
.auth-card .sub { color: var(--muted); text-align: center; margin-bottom: 1.75rem; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.form-control {
  width: 100%;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border .2s, box-shadow .2s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Prose (legal pages) ---------- */
.prose { max-width: 820px; margin: 0 auto; padding: 3rem 20px; }
.prose h1 { font-size: 2.25rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: -.02em; }
.prose h2 { font-size: 1.4rem; font-weight: 700; margin: 2rem 0 .75rem; }
.prose p, .prose li { color: #334155; margin-bottom: .85rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose a { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--line); padding: 3rem 0 2rem; margin-top: 0; }
.footer-content { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
.footer-brand .logo { margin-bottom: .75rem; }
.footer-brand .logo img { height: 34px; }
.footer-brand p { color: var(--muted); max-width: 280px; }
.footer-section h4 { font-size: .95rem; font-weight: 700; margin-bottom: .9rem; }
.footer-section a { display: block; color: var(--muted); margin-bottom: .5rem; transition: color .2s; }
.footer-section a:hover { color: var(--accent); }
.footer-bottom { text-align: center; color: var(--muted); font-size: .9rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.active {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    gap: .25rem;
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links.active .nav-link { padding: .85rem 1rem; min-height: 48px; display: flex; align-items: center; border-radius: var(--radius-sm); }
  .nav-links.active #guest-nav,
  .nav-links.active #user-nav { flex-direction: column; align-items: stretch; width: 100%; gap: .25rem; }
  .nav-links.active .user-menu { flex-direction: column; align-items: stretch; width: 100%; gap: .25rem; }
  .nav-links.active .usage-counter { text-align: center; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }

  .hero { padding: 3rem 20px 2rem; }
  .cta-buttons { flex-direction: column; }
  .cta-buttons .btn { width: 100%; }

  .section { padding: 2.5rem 0; }

  .footer-content { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .footer-content { grid-template-columns: 1fr; }
}

/* ---------- Accessibility ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
