/* ==========================================================================
   Webtoget — shared theme system
   Toggle themes via [data-theme] on <html>. Default is dark.
   ========================================================================== */

/* Light is the default theme. Even before JS runs, an unattributed <html>
   renders in light. The opt-in [data-theme="dark"] block below switches
   to the dark palette. */
:root,
:root[data-theme="light"] {
  --bg:              #fafafa;
  --bg-raised:       #ffffff;
  --bg-overlay:      #f1f1f3;
  --bg-input:        #ffffff;

  --text:            #18181b;
  --text-strong:     #09090b;
  --text-muted:      #5a5a63;
  --text-faint:      #9a9aa3;

  --border:          rgba(15, 15, 20, 0.10);
  --border-strong:   rgba(15, 15, 20, 0.18);
  --border-faint:    rgba(15, 15, 20, 0.06);

  --accent:          #4f4dd6;
  --accent-hover:    #6563FC;
  --accent-soft:     rgba(79, 77, 214, 0.10);
  --accent-softer:   rgba(79, 77, 214, 0.05);

  --success:         #15803d;
  --success-strong:  #16a34a;

  --nav-bg:          rgba(255, 255, 255, 0.80);
  --nav-bg-scrolled: rgba(255, 255, 255, 0.95);
  --nav-border:      rgba(15, 15, 20, 0.08);

  --scrollbar-track: #ececef;
  --scrollbar-thumb: #cfcfd4;
  --scrollbar-hover: #a8a8b0;
  --selection-bg:    rgba(79, 77, 214, 0.20);
  --shadow-sm:       0 1px 2px rgba(15, 15, 20, 0.06);
  --shadow-md:       0 6px 24px rgba(15, 15, 20, 0.08);

  --logo-filter:     none;
  color-scheme:      light;
}

:root[data-theme="dark"] {
  --bg:              #09090b;
  --bg-raised:       #18181b;
  --bg-overlay:      #27272a;
  --bg-input:        #09090b;

  --text:            #fafafa;
  --text-strong:     #ffffff;
  --text-muted:      #a1a1aa;
  --text-faint:      #52525b;

  --border:          rgba(255, 255, 255, 0.08);
  --border-strong:   rgba(255, 255, 255, 0.14);
  --border-faint:    rgba(255, 255, 255, 0.05);

  --accent:          #6563FC;
  --accent-hover:    #8382FF;
  --accent-soft:     rgba(101, 99, 252, 0.10);
  --accent-softer:   rgba(101, 99, 252, 0.05);

  --success:         #86efac;
  --success-strong:  #22c55e;

  --nav-bg:          rgba(15, 15, 18, 0.78);
  --nav-bg-scrolled: rgba(15, 15, 18, 0.92);
  --nav-border:      rgba(255, 255, 255, 0.07);

  --scrollbar-track: #0c0c0e;
  --scrollbar-thumb: #2a2a2e;
  --scrollbar-hover: #3f3f46;
  --selection-bg:    rgba(101, 99, 252, 0.25);
  --shadow-sm:       0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.35);

  --logo-filter:     brightness(0) invert(1);
  color-scheme:      dark;
}

/* --------------------------------------------------------------------------
   Smooth theme transitions on color-bearing properties
   -------------------------------------------------------------------------- */
html,
body,
nav,
.nav-glass,
.service-card,
.contact-form-card,
.contact-input,
.mobile-menu,
.ty-overlay,
.ty-card,
.gradient-line,
footer,
a,
button,
input,
textarea,
.nav-link,
[class*="bg-surface"],
[class*="bg-white"],
[class*="border-white"] {
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}

/* --------------------------------------------------------------------------
   Base — body / scrollbars / selection
   These use !important so they override per-page inline <style> blocks.
   -------------------------------------------------------------------------- */
body {
  background: var(--bg) !important;
  color: var(--text) !important;
}

::-webkit-scrollbar-track { background: var(--scrollbar-track) !important; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb) !important; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover) !important; }

::selection { background: var(--selection-bg) !important; color: var(--text) !important; }

/* --------------------------------------------------------------------------
   Remove AI tell-signs
   -------------------------------------------------------------------------- */

/* 1. Static decorative gradient/blur glows
      (utility-classed divs sized big with `bg-accent/*` + `blur-[...]`) */
div[class*="blur-["],
div[class*="blur-3xl"],
div[class*="blur-2xl"] {
  display: none !important;
}

/* 2. Text-shadow accent glow on hero / headings */
.green-glow,
[class*="green-glow"] {
  text-shadow: none !important;
}

/* 3. Gradient divider line → subtle solid border */
.gradient-line {
  background: var(--border) !important;
  opacity: 1 !important;
}

/* 4. Service card mouse-follow radial gradient */
.service-card::before { display: none !important; }

/* 5. Noise overlay */
.noise::before { display: none !important; }

/* 6. Hero typed-cursor still allowed (functional, not pure decoration) */

/* --------------------------------------------------------------------------
   Components — re-skinned with variables
   -------------------------------------------------------------------------- */

/* Navigation glass — solid, calm */
.nav-glass {
  background: var(--nav-bg) !important;
  backdrop-filter: blur(14px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(14px) saturate(140%) !important;
  border: 1px solid var(--nav-border) !important;
}

/* Scrolled-state override (the per-page JS pins inline background-color on
   the <nav>; we override with attribute selector + !important). */
nav[style] {
  background: var(--nav-bg-scrolled) !important;
  border-color: var(--nav-border) !important;
}

/* Nav links */
.nav-link { color: var(--text-muted) !important; }
.nav-link:hover { color: var(--text) !important; }
.nav-link::after { background: var(--accent) !important; }

/* Logo (white on dark, black on light) */
nav img[alt*="logo" i],
footer img[alt*="logo" i] {
  filter: var(--logo-filter) !important;
}

/* Mobile menu */
.mobile-menu {
  background: var(--nav-bg-scrolled) !important;
  backdrop-filter: blur(18px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(140%) !important;
}
.mobile-menu a { color: var(--text) !important; }
.mobile-menu a:hover { color: var(--accent) !important; }

/* Hamburger bars */
#bar1, #bar2, #bar3 { background: var(--text) !important; }

/* Service / generic dark cards */
.service-card {
  background: var(--bg-raised) !important;
  border: 1px solid var(--border) !important;
}
.service-card:hover {
  border-color: var(--accent) !important;
  transform: translateY(-2px);
}

/* Drift / pricing tier cards — solid surface in both themes
   (kills the static accent-tinted gradient inside the boxes). */
.tier-card,
.tier-card--featured,
.tier-card--hero {
  background: var(--bg-raised) !important;
}
.tier-card--featured {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important;
}
.tier-card--hero {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important;
}
/* Decorative accent halos behind the featured/hero tiers — gone. */
.tier-card--featured::before,
.tier-card--hero::before {
  display: none !important;
}

/* Portfolio project cards — overlay lives over a colour photo/mockup, so
   the gradient + text must stay dark/white in BOTH themes (otherwise the
   project title vanishes on a light page). */
.project-card .project-overlay {
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.55) 35%,
    rgba(0, 0, 0, 0.18) 70%,
    rgba(0, 0, 0, 0)   100%
  ) !important;
}
.project-card .project-info,
.project-card .project-info h3,
.project-card .project-info p,
.project-card .project-info span {
  color: #ffffff !important;
}
/* keep the eyebrow tag readable on the dark gradient regardless of theme */
.project-card .project-info .text-accent {
  color: var(--accent-hover) !important;
}

/* Contact card */
.contact-form-card {
  background: var(--bg-raised) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-md);
}

.contact-input {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.contact-input::placeholder { color: var(--text-faint) !important; }
.contact-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

/* Primary CTAs that sit on the accent background — text must stay white in
   BOTH themes, otherwise it falls back to var(--text-strong) which becomes
   near-black in light mode and disappears into the purple. */
.magnetic-btn,
.tier-btn--solid,
.tier-btn--solid:hover,
.cta-primary {
  color: #ffffff !important;
}
.magnetic-btn {
  background: var(--accent) !important;
}
.magnetic-btn:hover {
  background: var(--accent-hover) !important;
  box-shadow: 0 4px 16px rgba(101, 99, 252, 0.22) !important;
}

/* Thank-you modal */
.ty-overlay {
  background: rgba(0, 0, 0, 0.55) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}
:root[data-theme="light"] .ty-overlay {
  background: rgba(15, 15, 20, 0.35) !important;
}
.ty-card {
  background: var(--bg-raised) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.ty-card h3 { color: var(--text-strong) !important; }
.ty-card p  { color: var(--text-muted) !important; }
.ty-close {
  background: var(--bg-overlay) !important;
}

/* Confetti is festive but it's not a gradient-glow tell — keep, but lower count
   in CSS by hiding every other element to feel less synthetic */
.ty-confetti span:nth-child(odd) { display: none !important; }

/* --------------------------------------------------------------------------
   Tailwind utility-class overrides (so existing markup recolours cleanly)
   These hit utilities Tailwind CDN compiles, since Tailwind colors are
   defined per-page in `tailwind.config` — we let them work in dark and
   override only in light mode.
   -------------------------------------------------------------------------- */

:root[data-theme="light"] {
  /* Surface utilities */
}
:root[data-theme="light"] .bg-surface,
:root[data-theme="light"] [class*="bg-surface-DEFAULT"] {
  background-color: var(--bg) !important;
}
:root[data-theme="light"] .bg-surface-raised {
  background-color: var(--bg-raised) !important;
}
:root[data-theme="light"] .bg-surface-overlay {
  background-color: var(--bg-overlay) !important;
}

/* Text utilities */
:root[data-theme="light"] .text-white { color: var(--text-strong) !important; }
:root[data-theme="light"] .text-muted { color: var(--text-muted) !important; }
:root[data-theme="light"] .text-accent { color: var(--accent) !important; }
:root[data-theme="light"] .text-accent-light { color: var(--accent-hover) !important; }

/* Hover-state text colors — Tailwind compiles hover:text-white to a separate
   selector that we must override individually in light mode. */
:root[data-theme="light"] .hover\:text-white:hover,
:root[data-theme="light"] [class*="hover:text-white"]:hover {
  color: var(--text-strong) !important;
}
:root[data-theme="light"] [class*="hover:text-accent"]:hover {
  color: var(--accent) !important;
}

/* Generic white/* and border-white/* opacity-based utilities */
:root[data-theme="light"] [class*="text-white/"] { color: var(--text-muted) !important; }
:root[data-theme="light"] [class*="bg-white/"] { background-color: var(--bg-overlay) !important; }
:root[data-theme="light"] [class*="border-white/"] { border-color: var(--border) !important; }
:root[data-theme="light"] [class*="hover:bg-white/"]:hover { background-color: var(--bg-overlay) !important; }
:root[data-theme="light"] [class*="hover:border-white/"]:hover { border-color: var(--border-strong) !important; }

/* Accent variants in light mode */
:root[data-theme="light"] [class*="bg-accent/"] {
  background-color: var(--accent-soft) !important;
}
:root[data-theme="light"] [class*="border-accent/"] {
  border-color: var(--accent) !important;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important;
}

/* Subtle grid background — make it visible on white */
:root[data-theme="light"] .grid-bg {
  background-image:
    linear-gradient(rgba(15, 15, 20, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 15, 20, 0.04) 1px, transparent 1px) !important;
}

/* Typewriter cursor — pick the active accent */
.typed-cursor { color: var(--accent) !important; }

/* Hero text wrapper that uses inline accent text + glow */
:root[data-theme="light"] .text-accent { color: var(--accent) !important; }

/* Hover states on links to white text */
:root[data-theme="light"] a:hover { color: inherit; }

/* --------------------------------------------------------------------------
   Theme toggle button (injected by theme.js)
   -------------------------------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--bg-overlay);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}
/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun  { display: block; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Mobile size tweak */
@media (max-width: 767px) {
  .theme-toggle {
    width: 34px;
    height: 34px;
  }
  .theme-toggle svg { width: 14px; height: 14px; }
}

/* --------------------------------------------------------------------------
   Density — laptop+ viewports render the design at 80% scale so the default
   matches what the user previously got by manually zooming the browser out.
   Driven by the root font-size so every rem-based value (Tailwind spacing,
   type, sizing, arbitrary `[Xrem]` utilities) scales proportionally.
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  html { font-size: 80%; }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html, body, nav, .nav-glass, .service-card, .contact-form-card,
  .contact-input, .mobile-menu, .ty-overlay, .ty-card, .gradient-line,
  footer, a, button, input, textarea, .nav-link, .theme-toggle {
    transition: none !important;
  }
}
