/* Market detail modal. Colors only come from the theme variables of index.html. */

.md-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg); color: var(--text);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  animation: md-in 0.22s ease-out both;
}
.md-overlay:focus { outline: none; }
.md-overlay [hidden] { display: none !important; }
.md-overlay button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.md-sheet { max-width: 640px; margin: 0 auto; padding: 12px 16px 32px; }

.md-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.md-title { display: block; margin: 0; font-size: 1.1rem; font-weight: 700; min-width: 0; }
.md-symbol { color: var(--muted); font-size: 0.8rem; font-weight: 600; margin-left: 4px; }
.md-close {
  flex-shrink: 0; width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 50%;
}

.md-price { margin: 14px 0 10px; font-variant-numeric: tabular-nums; }
.md-price-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.md-price-change { font-size: 0.95rem; font-weight: 600; min-height: 1.4em; margin-top: 2px; }
.md-price-sub { color: var(--muted); font-size: 0.8rem; min-height: 1.3em; margin-top: 2px; }
.md-up { color: var(--positive); }
.md-down { color: var(--loss); }

.md-chart-wrap { position: relative; height: 240px; margin-bottom: 10px; }
.md-chart {
  --md-trend: var(--positive);
  display: block; width: 100%; height: 240px; overflow: visible;
}
.md-chart[data-trend="down"] { --md-trend: var(--loss); }
.md-grid { stroke: var(--border); stroke-width: 1; }
.md-ylabel, .md-xlabel { fill: var(--muted); font-size: 11px; font-family: inherit; }
.md-stop { stop-color: var(--md-trend); }
.md-line { fill: none; stroke: var(--md-trend); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.md-cross-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.md-dot { fill: var(--md-trend); stroke: var(--bg); stroke-width: 2; }

/* touch-action lets vertical swipes scroll the page while horizontal drags scrub the chart. */
.md-hit {
  position: absolute; inset: 0; touch-action: pan-y; cursor: crosshair;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.md-dim { transition: opacity 0.15s ease; }
.md-sheet[data-status="loading"] .md-dim { opacity: 0.4; }

.md-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 0 16px; text-align: center; color: var(--muted); font-size: 0.9rem; pointer-events: none;
}
.md-spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: md-spin 0.8s linear infinite;
}
.md-retry {
  min-height: 36px; padding: 8px 18px; pointer-events: auto;
  background: var(--accent); color: var(--bg); font-weight: 600;
}

.md-ranges {
  display: flex; gap: 6px; padding: 4px; margin: 0 -4px; /* room for the 2px focus ring + 2px offset */
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.md-ranges::-webkit-scrollbar { display: none; }
.md-range {
  flex: 1 0 auto; min-width: 40px; min-height: 36px; padding: 6px 10px; white-space: nowrap;
  background: var(--card); color: var(--muted); border: 1px solid var(--border); font-weight: 600;
}
.md-range[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.md-updated { display: flex; align-items: center; gap: 6px; min-height: 1.3em; margin-top: 8px; color: var(--muted); font-size: 0.75rem; }
.md-live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--positive); animation: md-pulse 2s ease-in-out infinite; }

.md-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 0; }
.md-stat { min-width: 0; padding: 10px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.md-stat dt { color: var(--muted); font-size: 0.75rem; }
.md-stat dd { margin: 2px 0 0; font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.md-note { margin: 14px 0 0; color: var(--muted); font-size: 0.75rem; line-height: 1.45; }

@keyframes md-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes md-spin { to { transform: rotate(360deg); } }
@keyframes md-pulse { 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .md-overlay, .md-live-dot { animation: none; }
  .md-dim { transition: none; }
  .md-spinner { animation: none; border-color: var(--accent); }
}
