/* ============================================================
   CryptoTrade Motion System — iOS-native feel
   - Elastic scroll / momentum
   - Touch press states on every interactive surface
   - Spring easing on all transitions
   - No tap highlight flash
   ============================================================ */

/* ── 1. Scroll feel ─────────────────────────────────────── */

html {
  scroll-behavior: smooth;
}

/* Momentum scrolling on touch devices */
body,
.overflow-y-auto,
.overflow-y-scroll,
[class*="scroll"] {
  -webkit-overflow-scrolling: touch;
}

/* Elastic overscroll only on the root — contained elsewhere */
body {
  overscroll-behavior-y: auto;
}

.overflow-y-auto,
.overflow-y-scroll {
  overscroll-behavior-y: contain;
}

/* ── 2. Remove tap flash (iOS blue highlight) ────────────── */

*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Re-enable text selection where it matters */
p, h1, h2, h3, h4, span, li, td, th, input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* ── 3. iOS easing curve ─────────────────────────────────── */

:root {
  --ios-ease:        cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ios-ease-in:     cubic-bezier(0.42, 0.00, 1.00, 1.00);
  --ios-ease-out:    cubic-bezier(0.00, 0.00, 0.58, 1.00);
  --ios-spring:      cubic-bezier(0.34, 1.56, 0.64, 1.00);
  --duration-fast:   150ms;
  --duration-normal: 220ms;
  --duration-slow:   350ms;
}

/* ── 4. Card press states ────────────────────────────────── */

/* Every frosted card gets a smooth lift on hover and press on tap */
[class*="liquid-glass"],
[class*="ct-card"],
[class*="card-"],
[data-ct-frosted="1"] {
  transition:
    transform var(--duration-fast) var(--ios-ease),
    box-shadow var(--duration-normal) var(--ios-ease),
    background var(--duration-normal) var(--ios-ease);
  cursor: default;
  will-change: transform;
}

/* Hover — desktop only: subtle lift */
@media (hover: hover) {
  [class*="liquid-glass"]:hover,
  [class*="ct-card"]:hover,
  [data-ct-frosted="1"]:hover {
    transform: translateY(-1px);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 1),
      0 18px 52px rgba(40, 80, 160, 0.14) !important;
  }
}

/* Active / tap — scale down like iOS spring press */
[class*="liquid-glass"]:active,
[class*="ct-card"]:active,
[data-ct-frosted="1"]:active {
  transform: scale(0.975);
  transition-duration: var(--duration-fast);
}

/* ── 5. Button press states ──────────────────────────────── */

button,
a[class*="btn"],
a[class*="button"],
[role="button"],
[class*="ct-btn"] {
  transition:
    transform var(--duration-fast) var(--ios-ease),
    opacity var(--duration-fast) var(--ios-ease),
    background var(--duration-normal) var(--ios-ease);
  -webkit-tap-highlight-color: transparent;
}

button:active,
a[class*="btn"]:active,
[role="button"]:active,
[class*="ct-btn"]:active {
  transform: scale(0.96);
  opacity: 0.85;
}

/* ── 6. List row press states (coin rows, activity rows) ─── */

/* Any clickable row inside a frosted card */
[data-ct-frosted="1"] > div[class*="flex"],
[data-ct-frosted="1"] > a,
[class*="liquid-glass"] > div[class*="flex items-center"],
[class*="liquid-glass"] > a {
  transition: background var(--duration-fast) var(--ios-ease);
  border-radius: 16px;
}

[data-ct-frosted="1"] > div[class*="flex"]:active,
[data-ct-frosted="1"] > a:active,
[class*="liquid-glass"] > div[class*="flex items-center"]:active {
  background: rgba(0, 0, 0, 0.04);
}

/* ── 7. Input / select focus ─────────────────────────────── */

input,
select,
textarea {
  transition:
    border-color var(--duration-fast) var(--ios-ease),
    box-shadow var(--duration-fast) var(--ios-ease);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 122, 255, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15) !important;
}

/* ── 8. Nav link transitions ────────────────────────────── */

nav a,
nav button {
  transition:
    color var(--duration-fast) var(--ios-ease),
    opacity var(--duration-fast) var(--ios-ease);
}

nav a:active,
nav button:active {
  opacity: 0.6;
}

/* ── 9. Modal / dialog entrance ─────────────────────────── */

[role="dialog"],
[class*="modal"],
[class*="dialog"],
[class*="sheet"],
[class*="drawer"] {
  animation: ct-modal-in var(--duration-slow) var(--ios-spring) both;
}

@keyframes ct-modal-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── 10. Page skeleton / loading shimmer ────────────────── */

@keyframes ct-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

[class*="skeleton"],
[class*="loading-placeholder"] {
  background: linear-gradient(
    90deg,
    rgba(200, 210, 230, 0.3) 25%,
    rgba(220, 228, 240, 0.6) 50%,
    rgba(200, 210, 230, 0.3) 75%
  );
  background-size: 800px 100%;
  animation: ct-shimmer 1.4s var(--ios-ease) infinite;
  border-radius: 10px;
}

/* ── 11. Smooth number changes (price tickers) ──────────── */

[class*="price"],
[class*="amount"],
[class*="balance"],
[class*="value"] {
  font-variant-numeric: tabular-nums;
  transition: color var(--duration-fast) var(--ios-ease);
}

/* ── 12. Image smoothness ────────────────────────────────── */

img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

img[class*="coin"],
img[class*="logo"],
img[class*="icon"] {
  image-rendering: auto;
}

/* ── 13. Scrollbar styling (webkit) ─────────────────────── */

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.30);
}

/* ── 14. Safe area insets (notch / home bar) ────────────── */

body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.fixed.bottom-0,
.sticky.bottom-0,
[class*="bottom-nav"],
[class*="tab-bar"] {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}

/* ── 11. Mobile touch interactions ────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  /* Touch devices: disable hover states, use active only */
  [class*="liquid-glass"]:hover,
  [class*="ct-card"]:hover,
  [data-ct-frosted="1"]:hover {
    transform: none;
    box-shadow: none;
  }

  /* Enhance active state for touch */
  [class*="liquid-glass"]:active,
  [class*="ct-card"]:active,
  [data-ct-frosted="1"]:active {
    transform: scale(0.97);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 1),
      0 8px 24px rgba(40, 80, 160, 0.12) !important;
  }

  /* Button press on touch */
  button:active,
  a[class*="btn"]:active,
  [role="button"]:active {
    transform: scale(0.94);
    opacity: 0.8;
  }

  /* Disable text selection on interactive elements */
  button,
  [role="button"],
  a[class*="btn"],
  nav a,
  nav button {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ── 12. Bottom navigation tab press ──────────────────────── */

.ct-tabbar button {
  transition:
    transform var(--duration-fast) var(--ios-ease),
    color var(--duration-fast) var(--ios-ease),
    background var(--duration-fast) var(--ios-ease);
  -webkit-user-select: none;
  user-select: none;
}

.ct-tabbar button:active {
  transform: scale(0.92);
}

.ct-tabbar button.active {
  color: #007AFF;
}

/* ── 13. Swipe gesture indicators ─────────────────────────── */

/* Smooth transition for page changes */
[role="main"],
.page-container,
[class*="page-"] {
  animation: ct-page-in var(--duration-normal) var(--ios-ease) both;
}

@keyframes ct-page-in {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── 14. Pull-to-refresh indicator (optional) ────────────── */

.ct-pull-to-refresh {
  transition:
    transform var(--duration-fast) var(--ios-ease),
    opacity var(--duration-fast) var(--ios-ease);
}

.ct-pull-to-refresh.active {
  transform: rotate(180deg);
  opacity: 1;
}

/* ── 15. Safe area adjustments for notch/home indicator ──── */

@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-top: max(0px, env(safe-area-inset-top));
  }

  .ct-tabbar {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}
