/* Main market/stocks page styles */

/* Enhanced page header */
.page-head {
  margin: 20px 0 24px;
  text-align: center;
  position: relative;
}

.page-title {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff, #e6edf3, #00ffa2);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  position: relative;
  display: inline-block;
}

/* Glow effect */
.page-title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: blur(8px);
  opacity: 0.3;
  z-index: -1;
}

/* Subtle underline accent */
.page-head::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
}

.page-sub{margin:4px 0 0;color:var(--muted);font-size:13px;}

/* Grid layout */
.grid-cards.only-images{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(14px,2vw,22px);}
@media (max-width:980px){.grid-cards.only-images{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media (max-width:620px){.grid-cards.only-images{grid-template-columns:1fr;}}

/* Flip cards */
.flip-card{
  perspective:1200px;
  border-radius:calc(var(--radius) + 4px);
  overflow:visible;
}

.flip-inner{
  position:relative;
  width:100%;
  aspect-ratio:16/9;
  transform-style:preserve-3d;
  transition:transform .5s cubic-bezier(.2,.7,.2,1);
  border-radius:inherit;
  box-shadow:var(--shadow);
  will-change:transform;
}

.flip-front,.flip-back{
  position:absolute;
  inset:0;
  backface-visibility:hidden;
  border-radius:inherit;
  overflow:hidden;
  border:1px solid rgba(255,255,255,0.08);
  background:#0c1218;
}

.flip-front{
  transform:rotateY(0deg);
  z-index:2;
}

.flip-front img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  transform:translateZ(0) scale(1.02);
  transition:transform .35s ease, filter .35s ease;
  filter:saturate(115%) contrast(1.05);
  backface-visibility:hidden;
  transform-style:preserve-3d;
}

.flip-card:hover .flip-front img{
  transform:translateZ(0) scale(1.06);
  filter:saturate(125%) contrast(1.08);
}

.flip-back{
  transform:rotateY(180deg);
  background:
    radial-gradient(600px 300px at 20% 20%, rgba(0,255,162,0.10), rgba(0,0,0,0) 60%),
    radial-gradient(700px 360px at 80% 80%, rgba(0,194,255,0.10), rgba(0,0,0,0) 60%),
    linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.75));
  border:1px solid rgba(255,255,255,0.10);
  backdrop-filter:blur(8px) saturate(120%);
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:12px;
  z-index:1;
}

.flip-card:hover .flip-inner{
  transform:rotateY(180deg);
}

.flip-card.flipped .flip-inner{
  transform:rotateY(180deg);
}

/* Back face content */
.back-top{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.fund-title{
  margin:0;
  font-size:15px;
  font-weight:700;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  color:#e6edf3;
}

.badge-invested{
  padding:6px 12px;
  border-radius:12px;
  font-size:12px;
  font-weight:700;
  border:1px solid rgba(0,255,162,0.35);
  background:rgba(0,255,162,0.10);
  color:#e6edf3;
}

.badge-invested .amount{
  font-weight:800;
  color:#00ffa2;
}

.badge-invested.negative{
  border-color:rgba(255,92,128,0.35);
  background:rgba(255,92,128,0.10);
}

.badge-invested.negative .amount{
  color:#ff5c80;
}

.back-bottom{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.etf-link{
  display:flex;
  align-items:center;
  gap:6px;
  padding:8px 12px;
  border-radius:10px;
  font-size:12px;
  font-weight:600;
  color:var(--muted);
  text-decoration:none;
  background:rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.08);
  transition:all .2s ease;
  letter-spacing:.2px;
}

.etf-link:hover{
  color:var(--text);
  background:rgba(255,255,255,0.06);
  border-color:rgba(255,255,255,0.15);
  transform:translateY(-1px);
}

.etf-link span{
  font-size:14px;
}

/* Sparkline container and overlay */
.spark-wrap{
  position:relative;
  background:rgba(0,0,0,0.18);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:10px;
  padding:6px;
  margin:6px 0 10px;
}

.spark{
  display:block;
  width:100%;
  height:auto;
}

.spark-overlay{
  position:absolute;
  inset:6px;
  pointer-events:none;
}

.price-pill, .move-pill{
  position:absolute;
  padding:4px 8px;
  border-radius:10px;
  font-size:12px;
  font-weight:800;
  background:rgba(0,0,0,0.55);
  border:1px solid rgba(255,255,255,0.14);
  color:#e6edf3;
  text-shadow:0 1px 0 rgba(0,0,0,0.3);
}

.price-pill.start{
  left:6px;
  bottom:6px;
}

.price-pill.end{
  right:6px;
  bottom:6px;
}

.move-pill{
  left:6px;
  top:6px;
  border-color:rgba(0,255,162,0.4);
}

.move-pill.down{
  border-color:rgba(255,92,128,0.5);
}

/* Action buttons */
.back-actions{
  display:flex;
  gap:10px;
}

.btn.sm{
  padding:10px 16px;
  border-radius:12px;
  font-size:13px;
  font-weight:800;
  letter-spacing:.3px;
  transition:all .2s ease;
  cursor:pointer;
  min-width:60px;
}

.btn.sm.buy{
  background:linear-gradient(135deg,rgba(0,255,162,0.25),rgba(0,194,255,0.20));
  border:2px solid rgba(0,255,162,0.6);
  box-shadow:0 6px 20px rgba(0,255,162,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
  color:#ffffff;
}

.btn.sm.sell{
  background:linear-gradient(135deg,rgba(255,92,128,0.25),rgba(255,92,128,0.18));
  border:2px solid rgba(255,92,128,0.6);
  box-shadow:0 6px 20px rgba(255,92,128,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
  color:#ffffff;
}

.btn.sm:hover{
  transform:translateY(-2px);
}

.btn.sm.buy:hover{
  border-color:rgba(0,255,162,0.8);
  box-shadow:0 8px 25px rgba(0,255,162,0.25), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn.sm.sell:hover{
  border-color:rgba(255,92,128,0.8);
  box-shadow:0 8px 25px rgba(255,92,128,0.25), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn.sm:active{
  transform:translateY(-1px);
}

/* Responsive adjustments for header */
@media (max-width: 768px) {
  .page-head {
    margin: 16px 0 20px;
  }
  
  .page-title {
    font-size: clamp(20px, 6vw, 28px);
    letter-spacing: -0.3px;
  }
}

/* Mobile-specific improvements - DO NOT affect desktop */
@media (max-width: 768px) {
  /* Adjust flip card aspect ratio for mobile */
  .flip-inner {
    aspect-ratio: 4/3;
  }
  
  /* Make buttons larger and more touch-friendly */
  .btn.sm {
    padding: 12px 20px;
    font-size: 14px;
    min-width: 70px;
  }
  
  /* Ensure back actions are always visible */
  .back-actions {
    gap: 12px;
  }
  
  /* Better spacing for mobile */
  .flip-back {
    padding: 16px;
  }
  
  /* Larger fund titles on mobile */
  .fund-title {
    font-size: 16px;
  }
  
  /* Better badge sizing */
  .badge-invested {
    font-size: 13px;
    padding: 8px 14px;
  }
  
  /* Larger ETF link for touch */
  .etf-link {
    padding: 10px 14px;
    font-size: 13px;
  }
  
  /* Better sparkline container */
  .spark-wrap {
    margin: 8px 0 12px;
    padding: 8px;
  }
  
  /* Larger price pills */
  .price-pill, .move-pill {
    padding: 6px 10px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  /* Even more touch-friendly on small phones */
  .btn.sm {
    padding: 14px 22px;
    font-size: 15px;
    min-width: 80px;
    font-weight: 700;
  }
  
  /* Larger gap for fat fingers */
  .back-actions {
    gap: 16px;
  }
  
  /* More padding on small screens */
  .flip-back {
    padding: 18px;
  }
  
  /* Larger fund title for readability */
  .fund-title {
    font-size: 17px;
  }
}