/* ═══════════════════════════════════════════════════════════════
   OCTOPILOT — Theme Toggle + Light-Mode Polish
   Loaded after every other stylesheet so its overrides win.
   ═══════════════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────────────────────
   Theme Toggle Button
   ───────────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background 0.3s var(--ease-out),
    border-color 0.3s var(--ease-out),
    color 0.3s var(--ease-out),
    transform 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--surface-4);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle__icon {
  width: 16px;
  height: 16px;
  position: absolute;
  inset: 0;
  margin: auto;
  transition:
    opacity 0.4s var(--ease-out),
    transform 0.5s var(--ease-spring);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Default = dark mode → show sun (clickable to go light) */
.theme-toggle__icon--sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
.theme-toggle__icon--moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

/* Light mode → show moon (clickable to go dark) */
[data-theme="light"] .theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}
[data-theme="light"] .theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Mobile-nav toggle is bigger and labeled */
.mobile-nav .theme-toggle {
  width: auto;
  height: auto;
  padding: 12px 22px;
  border-radius: var(--radius-full);
  gap: 10px;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.mobile-nav .theme-toggle .theme-toggle__icon {
  position: relative;
  inset: auto;
}

.mobile-nav .theme-toggle__label {
  display: inline-block;
}

.theme-toggle__label {
  display: none;
}


/* ─────────────────────────────────────────────────────────────
   Light Mode — Component Polish
   ───────────────────────────────────────────────────────────── */

/* Logo: subtle outline so the white octopus reads on a light bg */
[data-theme="light"] .nav-brand__logo,
[data-theme="light"] .footer__hero .nav-brand__logo,
[data-theme="light"] .macapp__icon img {
  filter:
    drop-shadow(0 1px 1px rgba(15, 23, 42, 0.18))
    drop-shadow(0 0 14px rgba(192, 21, 36, 0.22));
}

/* Card hover-line gradient — flips to a darker accent in light */
[data-theme="light"] .card::before {
  background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
  opacity: 0;
}

[data-theme="light"] .card:hover::before {
  opacity: 0.7;
}

/* Pillar connector line — softer in light mode */
[data-theme="light"] .pillars__grid .pillar::before {
  background: linear-gradient(180deg, var(--accent-bright), var(--border));
  opacity: 0.25;
}

/* Workflow mockup-line accent in light mode — keep brand red, soften white tail */
[data-theme="light"] .mockup-line--accent {
  background: linear-gradient(90deg, var(--accent-subtle), transparent);
}

/* Workflow accent top bar — already a transparent → accent → transparent gradient,
   but ensure visibility on white */
[data-theme="light"] .workflow__stage-inner::before {
  background: linear-gradient(90deg, transparent, var(--accent-bright), transparent);
}

/* Mockup sidebar active item — keep accent, but lighten background */
[data-theme="light"] .mockup-sidebar__item--active {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Macapp icon container in light mode — soft tile, brand drop-shadow */
[data-theme="light"] .macapp__icon {
  background: #ffffff;
  border-color: var(--border);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 24px rgba(15, 23, 42, 0.1);
}

/* Browser mockup — give it a light surface */
[data-theme="light"] .browser-mockup {
  background: #ffffff;
  box-shadow: var(--shadow-lg);
}

[data-theme="light"] .browser-mockup__bar {
  background: #f6f5f2;
}

/* Footer hero/social border respects new border token */
[data-theme="light"] .footer__hero {
  border-bottom-color: var(--border);
}

[data-theme="light"] .footer__bottom {
  border-top-color: var(--border);
}

/* Footer social svg uses fill, not stroke — flip to ink in light */
[data-theme="light"] .footer__social svg {
  fill: var(--text-secondary);
}

[data-theme="light"] .footer__social a:hover svg {
  fill: var(--accent-bright);
}

/* Selection: red highlight stays, but lighter contrast */
[data-theme="light"] ::selection {
  background: rgba(192, 21, 36, 0.18);
  color: var(--text-primary);
}

/* Preloader — invert in light */
[data-theme="light"] .preloader {
  background: var(--bg-deep);
}

[data-theme="light"] .preloader__spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
}

/* Sound toggle */
[data-theme="light"] .sound-toggle {
  background: var(--glass);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* Hero spline-wrap fade — already uses var(--bg-deep), themes correctly. */

/* Hero canvas reads slightly hot on white — calm it a hair */
[data-theme="light"] .hero__spline-wrap canvas {
  filter: saturate(0.92) brightness(0.96);
}

/* Hero spline overlay subtle warm wash so the 3D model has air around it */
[data-theme="light"] .hero__spline-fallback {
  background:
    radial-gradient(circle at center, rgba(192, 21, 36, 0.09), transparent 60%);
}

/* Particle dots in main.js paint with a fixed color (rgba(196, 20, 32, ...))
   which stays brand-correct in both modes — no override needed. */

/* Section divider — strong enough on light too thanks to --border token */

/* Nav scrolled state — slightly stronger shadow on light */
[data-theme="light"] .site-nav.is-scrolled {
  box-shadow: 0 1px 0 var(--border), 0 8px 24px rgba(15, 23, 42, 0.04);
}

/* Mobile nav backdrop — opaque in light too */
[data-theme="light"] .mobile-nav {
  background: var(--bg-deep);
}

/* Reveal-text shadow on hero title was already softened. */

/* Workflow stage hover accent lifts a card off white more dramatically */
[data-theme="light"] .workflow__stage-inner:hover {
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

/* Trust seal hover — keep on light */
[data-theme="light"] .trust-seal__icon svg {
  stroke: var(--silver-bright);
}

/* Eyebrow / labels stay accent-bright, fine in both modes */

/* Sub-page hero (privacy/terms/help/contact) — ensure background respects theme */
[data-theme="light"] .sub-hero {
  background:
    radial-gradient(ellipse at 30% 30%, rgba(192,21,36,0.08), transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(192,21,36,0.05), transparent 50%),
    var(--bg-deep) !important;
}

[data-theme="light"] .legal-meta {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="light"] .legal-nav,
[data-theme="light"] .help-card,
[data-theme="light"] .contact-card,
[data-theme="light"] .help-tile,
[data-theme="light"] .contact-channel,
[data-theme="light"] .form-card {
  background: var(--surface-1);
  border-color: var(--border);
}

[data-theme="light"] .legal-contact {
  background: rgba(192, 21, 36, 0.05);
  border-color: var(--border-accent);
}

/* Inputs in light mode */
[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #ffffff;
  border-color: var(--border-hover);
  color: var(--text-primary);
}

[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
  color: var(--text-muted);
}


/* ─────────────────────────────────────────────────────────────
   Auto-detect prefers-color-scheme on first visit
   (Only if user has not set a preference — handled in JS too,
    this is a no-flash CSS-only fallback when JS is disabled.)
   ───────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    color-scheme: light;
  }
}
