/*
 * ui-polish.css
 * Global UI polish layer — loads after theme.css (alphabetical sort).
 * Adds: page transitions, focus states, hover refinements, skeleton loaders,
 * smooth scroll, custom scrollbars, typography tightening, card depth,
 * mobile nav, micro-details. Pure CSS — no template changes needed.
 *
 * Constraint: polish only — does NOT change layout, functionality, or palette.
 */

/* ====================================================================
   0. SMOOTH SCROLL & SELECTION
   ==================================================================== */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(0, 255, 136, 0.2);
  color: var(--fg);
}

::-moz-selection {
  background: rgba(0, 255, 136, 0.2);
  color: var(--fg);
}

/* ====================================================================
   1. PAGE ENTRY ANIMATION — content fades in on load
   ==================================================================== */
body {
  animation: pageEntry 0.35s ease-out;
}

@keyframes pageEntry {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====================================================================
   2. FOCUS STATES — accessibility for keyboard navigation
   ==================================================================== */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Remove outline on mouse click, keep for keyboard */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Special focus for buttons */
button:focus-visible,
.scan-btn:focus-visible,
.cta-primary:focus-visible,
.submit-btn:focus-visible,
.plan-cta:focus-visible,
.modal-upgrade-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.15);
}

/* Form inputs */
.form-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.1);
}

/* ====================================================================
   3. CURSOR: POINTER — every interactive element
   ==================================================================== */
a,
button,
[role="button"],
.filter-chip,
.platform-tag:hover,
.nav-tab,
.snav-link,
.nav-link,
.mp-nav-link,
.track-btn,
.view-btn,
.untrack-btn,
.modal-dismiss,
.flip-card,
.activity-feed-header,
summary {
  cursor: pointer;
}

/* ====================================================================
   4. ENHANCED HOVER STATES
   ==================================================================== */

/* --- Cards: subtle border glow + lift --- */
.stat-card,
.account-card,
.settings-card,
.rule-card,
.flip-card,
.alpha-stat,
.metric-card,
.roi-chart {
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover,
.account-card:hover,
.settings-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

/* --- Buttons: brightness increase + subtle scale --- */
.cta-primary,
.snav-btn,
.scan-btn,
.submit-btn,
.plan-cta,
.save-btn,
.founder-cta,
.modal-upgrade-btn,
.empty-btn,
.account-btn,
.back-scanner,
.mab-cta {
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.cta-primary:hover,
.snav-btn:hover,
.submit-btn:hover,
.plan-cta.primary:hover,
.save-btn:hover,
.founder-cta:hover,
.modal-upgrade-btn:hover,
.empty-btn:hover,
.back-scanner:hover,
.mab-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 255, 136, 0.15);
}

.cta-primary:active,
.snav-btn:active,
.submit-btn:active,
.plan-cta.primary:active,
.save-btn:active,
.founder-cta:active,
.modal-upgrade-btn:active,
.empty-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* --- Nav links: underline slide animation --- */
.snav-link,
.nav-tab,
.mp-nav-link {
  position: relative;
}

.snav-link::after,
.nav-tab::after,
.mp-nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 1.5px;
  background: var(--accent);
  transition: width 0.2s ease, left 0.2s ease;
}

.snav-link:hover::after,
.nav-tab:hover::after,
.nav-tab.active::after,
.mp-nav-link:hover::after,
.mp-nav-link.active::after {
  width: 100%;
  left: 0;
}

/* --- Filter chips: smooth appear/disappear --- */
.filter-chip {
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.filter-chip:hover {
  transform: scale(1.03);
}

.filter-chip:active {
  transform: scale(0.97);
}

/* ====================================================================
   5. CARD POLISH — consistent border radius, depth, elite glow
   ==================================================================== */

/* Consistent border radius for all card-like elements */
.stat-card,
.account-card,
.deal-card,
.feed-card,
.flip-card,
.rule-card,
.metric-card,
.alpha-stat,
.settings-card,
.plan-card,
.feature-card {
  border-radius: 10px;
}

/* Elite high-margin cards: electric green border glow */
.deal-card:hover,
.feed-card:hover {
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.08);
}

/* Plan card Pro hover enhancement */
.plan-card.pro:hover {
  box-shadow: 0 0 40px rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.4);
}

/* ====================================================================
   6. TYPOGRAPHY REFINEMENTS
   ==================================================================== */

/* Monospace numbers in stat values for tabular alignment */
.stat-value,
.price-cell,
.profit-cell,
.feed-price,
.feed-profit,
.plan-price,
.heat-number,
.margin-pill,
.fc-profit,
.roi-pct {
  font-variant-numeric: tabular-nums;
}

/* Profit values: electric green */
.profit-cell,
.feed-profit,
.fc-profit {
  color: var(--accent);
}

/* Loss values: red */
.profit-cell.loss {
  color: #f87171;
}

/* Section labels — subtle uppercase tracking */
.stat-label,
.account-card-title,
.sec-label,
.heat-label,
.mc-tag,
.filter-label,
.feed-header span,
.hds-label {
  text-transform: uppercase;
}

/* ====================================================================
   7. SKELETON LOADER ANIMATION — use class="skeleton" on placeholder elements
   ==================================================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    rgba(255, 255, 255, 0.06) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.skeleton * {
  visibility: hidden;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pre-built skeleton shapes */
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  min-height: 80px;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line:last-child {
  width: 60%;
}

/* ====================================================================
   8. CUSTOM SCROLLBAR — dark theme, accent accent
   ==================================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ====================================================================
   9. INPUT POLISH — distinctive styled inputs
   ==================================================================== */
input,
select,
textarea {
  font-size: 16px; /* Prevents iOS auto-zoom */
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Toggle switch polish */
.toggle-input {
  transition: background 0.25s ease;
}

.toggle-input::after {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================================================================
   10. MODAL POLISH — backdrop blur + scale transition
   ==================================================================== */
.modal-overlay {
  transition: opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

/* ====================================================================
   11. TOAST POLISH — slide up from bottom
   ==================================================================== */
.toast {
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

/* ====================================================================
   12. MOBILE LAYOUT — responsive adjustments (nav handled by mobile-nav.css)
   ==================================================================== */
@media (max-width: 768px) {
  /* Touch targets minimum 44px */
  .snav-link,
  .nav-tab,
  .nav-link,
  .mp-nav-link,
  .filter-chip,
  .scan-btn,
  .view-btn,
  .track-btn,
  .submit-btn,
  .plan-cta,
  .account-btn,
  button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Buttons full-width on mobile */
  .submit-btn,
  .plan-cta,
  .modal-upgrade-btn,
  .founder-cta {
    width: 100%;
    justify-content: center;
  }

  /* Prevent horizontal overflow */
  body {
    overflow-x: hidden;
  }

  .deal-card,
  .feed-card,
  .flip-card {
    overflow: hidden;
    word-break: break-word;
  }

  /* Stack account actions vertically */
  .account-actions {
    flex-direction: column;
  }

  .account-actions .account-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Full-width filter bar with scroll */
  .filter-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    flex-shrink: 0;
  }

  /* Pricing cards stack */
  .plans-grid {
    grid-template-columns: 1fr !important;
  }

  /* Modal full-width on mobile */
  .modal-card {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }

  .modal-overlay.open {
    align-items: flex-end;
  }

  /* Hero CTA stacks */
  .hero-cta {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-cta .cta-primary {
    width: 100%;
    text-align: center;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  /* Ensure cards don't overflow */
  .stats-row,
  .summary-row {
    grid-template-columns: 1fr 1fr;
  }

  .alpha-grid,
  .flip-cards,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  /* Feature grid single column */
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

/* ====================================================================
   13. LOADING / SPINNER UTILITY
   ==================================================================== */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin-smooth {
  to { transform: rotate(360deg); }
}

/* Pulse loading indicator */
.loading-pulse {
  animation: loadPulse 1.5s ease-in-out infinite;
}

@keyframes loadPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ====================================================================
   14. TRANSITION POLISH — smoother defaults
   ==================================================================== */

/* Links and interactive elements get smooth transitions */
a {
  transition: color 0.15s ease;
}

/* Badge and pill transitions */
.pro-badge-nav,
.pro-badge,
.plan-badge,
.cat-badge,
.tier-tag,
.trend-badge,
.margin-pill,
.platform-badge,
.plat-tag,
.arb-score,
.hconf-tag,
.niche-match-pill {
  transition: transform 0.15s ease;
}

/* ArbScore badge: subtle scale-up on first render */
.arb-score {
  animation: badgeEntry 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes badgeEntry {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ====================================================================
   15. STAGGERED CARD ENTRY
   ==================================================================== */
.deal-list .deal-card,
.feed-list .feed-card,
.flip-grid .flip-card,
.feature-grid .feature-card,
.stats-row .stat-card,
.summary-row .stat-card,
.metrics-grid .metric-card {
  animation: cardEntry 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardEntry {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger delays */
.deal-list .deal-card:nth-child(1),
.feature-grid .feature-card:nth-child(1),
.stats-row .stat-card:nth-child(1),
.metrics-grid .metric-card:nth-child(1) { animation-delay: 0s; }

.deal-list .deal-card:nth-child(2),
.feature-grid .feature-card:nth-child(2),
.stats-row .stat-card:nth-child(2),
.metrics-grid .metric-card:nth-child(2) { animation-delay: 0.04s; }

.deal-list .deal-card:nth-child(3),
.feature-grid .feature-card:nth-child(3),
.stats-row .stat-card:nth-child(3),
.metrics-grid .metric-card:nth-child(3) { animation-delay: 0.08s; }

.deal-list .deal-card:nth-child(4),
.feature-grid .feature-card:nth-child(4),
.stats-row .stat-card:nth-child(4),
.metrics-grid .metric-card:nth-child(4) { animation-delay: 0.12s; }

.deal-list .deal-card:nth-child(5),
.feature-grid .feature-card:nth-child(5) { animation-delay: 0.16s; }

.deal-list .deal-card:nth-child(6),
.feature-grid .feature-card:nth-child(6) { animation-delay: 0.2s; }

.deal-list .deal-card:nth-child(n+7) { animation-delay: 0.24s; }

/* ====================================================================
   16. EMPTY STATE POLISH
   ==================================================================== */
.empty-state,
.empty-feed {
  position: relative;
}

.empty-state::before,
.empty-feed::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(ellipse, rgba(0, 255, 136, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* ====================================================================
   17. HEADER DEPTH — subtle bottom shadow for sticky navs
   ==================================================================== */
.site-nav,
.dash-header,
.pro-header,
.mp-header,
.admin-header {
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.3);
}

/* ====================================================================
   18. FEATURE CARD ICON GLOW
   ==================================================================== */
.fc-icon {
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.3);
}

/* ====================================================================
   19. FOUNDER'S LOCK COUNTER BAR GLOW
   ==================================================================== */
.founder-counter-fill {
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

/* ====================================================================
   20. PRINT STYLES
   ==================================================================== */
@media print {
  body {
    background: white;
    color: black;
  }

  .site-nav,
  .dash-header,
  .pro-header,
  .mp-header,
  .admin-header,
  .scan-btn,
  .modal-overlay,
  .toast {
    display: none !important;
  }
}

/* ====================================================================
   21. REDUCED MOTION — respect user preference
   ==================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}
