/* ════════════════════════════════════════════════════════════════
   🎨 FYNX — PREMIUM UI UPGRADE (All 28 improvements)
   How to use: <link rel="stylesheet" href="premium-upgrade.css">
              AFTER your main styles.css link.
   ════════════════════════════════════════════════════════════════

   ⚠️ THEME-SAFETY CHECKLIST — read before adding/editing anything ⚠️
   ───────────────────────────────────────────────────────────────
   Any new rule that animates, transforms, or modifies COLORS must
   be tested against ALL 3 themes:
     • [data-theme="default"]  → indigo/purple/pink
     • [data-theme="dark"]     → dark navy with light text
     • [data-theme="saffron"]  → orange/green tricolor
   
   The Saffron theme is the most fragile because:
     1. Hero uses a 3-stop gradient (orange → orange → green)
        → animating background-position washes it out
     2. Logo gradient passes through WHITE → invisible on white nav
     3. Text contrast must always pair with backgrounds
   
   When in doubt, override with:
     [data-theme="saffron"] .your-selector { animation: none !important; }
   ════════════════════════════════════════════════════════════════ */

/* ─── 0. Prevent horizontal scroll (kills "page wiggle" from toasts/scale) ── */
html, body { overflow-x: clip !important; }

/* ─── 1. Custom Selection Color ────────────────────────────────── */
::selection { background: var(--primary); color: #fff; text-shadow: none; }
::-moz-selection { background: var(--primary); color: #fff; }

/* ─── 2. Smooth Scroll + Anchor Offset for Sticky Navbar ──────── */
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ─── 3. Custom Branded Scrollbar ─────────────────────────────── */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--bg); }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }
* { scrollbar-width: thin; scrollbar-color: var(--primary) var(--bg); }

/* ─── 4. Focus-Visible (Better Keyboard Nav) ──────────────────── */
*:focus { outline: none; }
*:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── 5. Crisp Image Rendering ────────────────────────────────── */
img { image-rendering: -webkit-optimize-contrast; }

/* ─── 14. Smooth Theme Transitions ────────────────────────────── */
body, .navbar, .calc-card, .calc-box, .result-box, .info-box,
.footer, .search-modal-box, .dropdown-menu, .theme-dropdown,
.form-group input, .form-group select, .form-group textarea {
  transition: background-color 0.4s ease, color 0.3s ease,
              border-color 0.3s ease, box-shadow 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ─── 15. Subtle Background Pattern (Dot Grid) ────────────────── */
body {
  background-image:
    radial-gradient(circle, rgba(99, 102, 241, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}
[data-theme="dark"] body {
  background-image: radial-gradient(circle, rgba(165, 180, 252, 0.05) 1px, transparent 1px);
}
[data-theme="saffron"] body {
  background-image: radial-gradient(circle, rgba(234, 88, 12, 0.07) 1px, transparent 1px);
}

/* ─── 6. Stagger Fade-In on Cards ─────────────────────────────── */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.calc-grid .calc-card {
  animation: cardFadeIn 0.5s ease-out backwards;
}
.calc-grid .calc-card:nth-child(1)  { animation-delay: 0.03s; }
.calc-grid .calc-card:nth-child(2)  { animation-delay: 0.06s; }
.calc-grid .calc-card:nth-child(3)  { animation-delay: 0.09s; }
.calc-grid .calc-card:nth-child(4)  { animation-delay: 0.12s; }
.calc-grid .calc-card:nth-child(5)  { animation-delay: 0.15s; }
.calc-grid .calc-card:nth-child(6)  { animation-delay: 0.18s; }
.calc-grid .calc-card:nth-child(7)  { animation-delay: 0.21s; }
.calc-grid .calc-card:nth-child(8)  { animation-delay: 0.24s; }
.calc-grid .calc-card:nth-child(9)  { animation-delay: 0.27s; }
.calc-grid .calc-card:nth-child(10) { animation-delay: 0.30s; }
.calc-grid .calc-card:nth-child(n+11) { animation-delay: 0.33s; }

/* ─── 8 + 16. Result Slide-In + Pop ───────────────────────────── */
@keyframes resultPop {
  0%   { opacity: 0; transform: translateY(20px) scale(0.96); }
  60%  { opacity: 1; transform: translateY(-3px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.result-box[style*="block"] {
  animation: resultPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ─── 9. Card Magnetic Hover with Theme-Aware Glow ────────────── */
.calc-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
}
.calc-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow:
    0 20px 40px -10px rgba(99, 102, 241, 0.25),
    0 0 0 1px var(--primary);
}
[data-theme="dark"] .calc-card:hover {
  box-shadow: 0 20px 40px -10px rgba(165, 180, 252, 0.3), 0 0 0 1px var(--primary);
}
[data-theme="saffron"] .calc-card:hover {
  box-shadow: 0 20px 40px -10px rgba(234, 88, 12, 0.3), 0 0 0 1px var(--primary);
}

/* ─── 10. Hero Animated Gradient (Subtle Shift) ───────────────── */
@keyframes heroGradient {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.hero {
  background-size: 200% 200%;
  animation: heroGradient 12s ease infinite;
}
@media (prefers-reduced-motion: reduce) { .hero { animation: none; } }
/* IMPORTANT: Saffron tricolor gradient washes out when animated → keep static */
[data-theme="saffron"] .hero {
  animation: none !important;
  background-size: 100% 100% !important;
}

/* ─── 11 + 19. Input Focus Ring + Gradient Border ─────────────── */
.form-group input,
.form-group select,
.form-group textarea {
  transition: border-color 0.2s ease, box-shadow 0.25s ease,
              transform 0.2s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.12),
    0 4px 16px -4px rgba(99, 102, 241, 0.2);
  transform: translateY(-1px);
}

/* ─── 12. Animated Underline on Nav Links ─────────────────────── */
.nav-links > li > a {
  position: relative;
}
.nav-links > li > a::before {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 0.85rem;
  right: 0.85rem;
  height: 2px;
  background: var(--gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
  border-radius: 2px;
}
.nav-links > li > a:hover::before {
  transform: scaleX(1);
}
@media (max-width: 768px) {
  .nav-links > li > a::before { display: none; }
}

/* ─── 13. Glassmorphism Navbar When Scrolled ─────────────────── */
.navbar {
  transition: backdrop-filter 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.navbar.scrolled {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .navbar.scrolled {
  background: rgba(15, 23, 42, 0.75);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}
[data-theme="saffron"] .navbar.scrolled {
  background: rgba(255, 251, 235, 0.8);
}

/* ─── 17. Button Pressed State (Tactile) ──────────────────────── */
.btn {
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease;
}
.btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.calc-card:active { transform: translateY(-4px) scale(1.00); }
.search-trigger:active { transform: scale(0.97); }

/* ─── 18. Sticky Calculate Button on Mobile ───────────────────── */
@media (max-width: 768px) {
  .calc-box .btn {
    position: sticky;
    bottom: 12px;
    z-index: 50;
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
  }
}

/* ─── 20. Inline Mini Progress Bar in Result Rows ─────────────── */
/* Add class="result-bar" + data-pct="65" to a row's parent for auto-bar */
.result-row.result-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}
.result-row.result-bar .bar-row {
  display: flex;
  justify-content: space-between;
}
.result-row.result-bar::after {
  content: '';
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.result-row.result-bar[data-pct]::after {
  background: linear-gradient(90deg, var(--secondary) var(--pct, 0%), var(--border) var(--pct, 0%));
}

/* ─── 21. View Transitions (Cross-Page Smoothness) ────────────── */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.25s;
}

/* ─── 22. Skeleton Shimmer (for Popular section while loading) ── */
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--border) 0%, var(--bg) 50%, var(--border) 100%);
  background-size: 1000px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 16px;
  height: 180px;
}

/* ─── 23. Spotlight on Hover (Cards Follow Mouse) ─────────────── */
.calc-card {
  position: relative;
  overflow: hidden;
}
.calc-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    400px circle at var(--mx, 50%) var(--my, 50%),
    rgba(99, 102, 241, 0.12),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}
.calc-card:hover::after { opacity: 1; }
.calc-card > * { position: relative; z-index: 2; }

/* ─── 24. Toast Notification System ───────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 12px;
  border-left: 4px solid var(--secondary);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
  font-size: 0.92rem;
  min-width: 240px;
  max-width: 340px;
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  pointer-events: auto;
}
.toast.toast-leave { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn  { from { transform: translateX(120%); } to { transform: translateX(0); } }
@keyframes toastOut { to   { transform: translateX(120%); opacity: 0; } }
@media (max-width: 600px) {
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: 100%; }
}

/* ─── 25. Keyboard Hint Tooltips (Subtle, Time-Delayed) ───────── */
.kbd-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 500;
}
.kbd-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.kbd-hint kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  margin: 0 2px;
}

/* ─── 26. Per-Category Accent Stripe ──────────────────────────── */
.calc-box { position: relative; overflow: hidden; }
.calc-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
body[data-cat="finance"]  .calc-box::before { background: linear-gradient(90deg, #10b981, #059669); }
body[data-cat="health"]   .calc-box::before { background: linear-gradient(90deg, #ef4444, #f97316); }
body[data-cat="education"].calc-box::before { background: linear-gradient(90deg, #3b82f6, #6366f1); }
body[data-cat="math"]     .calc-box::before { background: linear-gradient(90deg, #8b5cf6, #ec4899); }
body[data-cat="converters"].calc-box::before { background: linear-gradient(90deg, #06b6d4, #14b8a6); }
body[data-cat="daily"]    .calc-box::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }

/* ─── 27. Bottom Sheet on Mobile (Search Modal) ───────────────── */
@media (max-width: 600px) {
  .search-modal { align-items: flex-end; padding-top: 0; }
  .search-modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    animation: sheetUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 85vh;
  }
  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* ─── 28. Polished Counter Animation (used by JS) ─────────────── */
.result-value.counting {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ─── BONUS: Better Card Icon Wobble on Hover ─────────────────── */
.calc-card:hover .calc-icon {
  animation: iconWobble 0.6s ease;
}
@keyframes iconWobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg) scale(1.1); }
  75% { transform: rotate(8deg) scale(1.1); }
}

/* ─── BONUS: Floating action shadows on dark theme look better ── */
[data-theme="dark"] .calc-card,
[data-theme="dark"] .calc-box,
[data-theme="dark"] .result-box {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
