/* ==========================================================================
   Sonexa — Premium polish layer
   Loaded last: refines depth, focus, motion and detail on top of the
   existing design system without touching structure or JS hooks.
   ========================================================================== */

/* ----------------------------- Refined tokens ----------------------------- */
:root {
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.24), 0 1px 1px rgba(0, 0, 0, 0.14);
  --shadow-md:  0 6px 20px -4px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.20);
  --shadow-lg:  0 16px 44px -8px rgba(0, 0, 0, 0.42), 0 4px 12px rgba(0, 0, 0, 0.24);
  --shadow-xl:  0 28px 72px -12px rgba(0, 0, 0, 0.50), 0 8px 20px rgba(0, 0, 0, 0.28);
  --ring:       0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --shadow-sm:  0 1px 2px rgba(20, 16, 8, 0.05);
    --shadow-md:  0 6px 20px -4px rgba(20, 16, 8, 0.08), 0 2px 6px rgba(20, 16, 8, 0.04);
    --shadow-lg:  0 16px 44px -8px rgba(20, 16, 8, 0.10), 0 4px 12px rgba(20, 16, 8, 0.05);
    --shadow-xl:  0 28px 72px -12px rgba(20, 16, 8, 0.12);
    --ring:       0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
  }
}
:root[data-theme="light"] {
  --shadow-sm:  0 1px 2px rgba(20, 16, 8, 0.05);
  --shadow-md:  0 6px 20px -4px rgba(20, 16, 8, 0.08), 0 2px 6px rgba(20, 16, 8, 0.04);
  --shadow-lg:  0 16px 44px -8px rgba(20, 16, 8, 0.10), 0 4px 12px rgba(20, 16, 8, 0.05);
  --shadow-xl:  0 28px 72px -12px rgba(20, 16, 8, 0.12);
}

/* ----------------------------- Base refinement ----------------------------- */
html { scroll-behavior: smooth; }

body {
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum";
  letter-spacing: -0.006em;
}

::selection {
  background: var(--accent-glow);
  color: var(--text-inverse);
}

/* Accessible, consistent focus ring everywhere — replaces mismatched
   per-component focus treatments with one clear signal */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}
button:focus-visible,
.nav-link:focus-visible,
.chat-list-item:focus-visible,
.btn:focus-visible,
a:focus-visible {
  box-shadow: var(--ring);
}

/* Custom scrollbars, themed */
* {
  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(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ----------------------------- Headings ----------------------------- */
.welcome-title,
.about-title,
.docs-title,
.settings-title,
.service-title,
.chat-empty-title {
  letter-spacing: -0.02em;
  font-weight: 650;
}

/* ----------------------------- Top bar / chrome ----------------------------- */
.top-bar {
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: 0 1px 0 var(--border);
}

.logo-mark {
  border-radius: 10px;
  background: linear-gradient(150deg, var(--accent-soft), transparent);
  transition: transform 420ms var(--ease-spring);
}
.top-bar-brand:hover .logo-mark { transform: rotate(-6deg) scale(1.05); }

.navbar {
  box-shadow: var(--shadow-lg);
}

.nav-link {
  position: relative;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.nav-link::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 2px;
  background: var(--accent);
  transition: height 200ms var(--ease-out);
}
.nav-link.is-active::before { height: 60%; }
.nav-link:active { transform: scale(0.98); }

/* ----------------------------- Buttons ----------------------------- */
.btn,
.btn-primary,
.btn-secondary,
.btn-large,
.chat-suggestion-btn {
  transition: transform 160ms var(--ease-out), box-shadow 200ms var(--ease-out),
              background 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.btn-primary {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 2px 8px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset, 0 6px 18px var(--accent-glow); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-secondary:hover { transform: translateY(-1px); }
.btn:active, .btn-large:active { transform: scale(0.97); }

.btn-icon-only {
  transition: background 160ms var(--ease-out), transform 160ms var(--ease-spring), color 160ms var(--ease-out);
}
.btn-icon-only:hover { transform: translateY(-1px); }
.btn-icon-only:active { transform: scale(0.92); }

/* ----------------------------- Chat ----------------------------- */
.chat-panel {
  box-shadow: var(--shadow-lg);
}

.chat-message-content {
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms var(--ease-out);
}
.chat-message-assistant .chat-message-content {
  box-shadow: var(--shadow-sm);
}
.chat-message-user .chat-message-content {
  box-shadow: none;
}
.chat-message-avatar {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chat-messages {
  scroll-padding-bottom: 24px;
}

.chat-form {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.chat-input {
  transition: border-color 160ms var(--ease-out), box-shadow 200ms var(--ease-out), background 160ms var(--ease-out);
}
.chat-input:focus {
  box-shadow: var(--ring);
}
.chat-send,
.chat-stop {
  transition: transform 160ms var(--ease-spring), box-shadow 200ms var(--ease-out);
}
.chat-send:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); }
.chat-send:active:not(:disabled) { transform: scale(0.94); }

.chat-suggestion-btn:hover { transform: translateX(2px); }

/* ----------------------------- Cards / panels ----------------------------- */
.panel,
.about-card,
.welcome-card,
.spoiler-card {
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out), border-color 220ms var(--ease-out);
}
.about-card:hover,
.spoiler-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.hero-pill {
  transition: transform 180ms var(--ease-spring), background 180ms var(--ease-out), border-color 180ms var(--ease-out);
}
.hero-pill:hover { transform: translateY(-2px); }

/* ----------------------------- Inputs ----------------------------- */
.text-input,
select,
textarea {
  transition: border-color 160ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.text-input:focus,
select:focus,
textarea:focus {
  box-shadow: var(--ring);
}

/* ----------------------------- Motion & accessibility ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ----------------------------- Fine detail ----------------------------- */
.beta-badge {
  letter-spacing: 0.06em;
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.status-icon { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15)); }

/* Slightly deeper contrast on disabled controls so intent reads clearly */
button:disabled,
.btn:disabled,
.is-disabled {
  filter: saturate(0.7);
}
