/* ── Budget Gold Monitor — Minimal Dark UI ─────────────── */

:root {
  --bg: #060e24;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #f0f4ff;
  --text-secondary: rgba(255, 255, 255, 0.45);
  --text-muted: rgba(255, 255, 255, 0.28);
  --gold: #e8b931;
  --gold-glow: rgba(232, 185, 49, 0.15);
  --silver: #a8b8d0;
  --silver-glow: rgba(168, 184, 208, 0.12);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.1);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Background glows ──────────────────────────────────── */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  animation: glowPulse 8s ease-in-out infinite alternate;
}
.bg-glow--gold {
  width: 600px; height: 600px;
  top: -200px; left: -100px;
  background: radial-gradient(circle, var(--gold-glow), transparent 70%);
}
.bg-glow--silver {
  width: 500px; height: 500px;
  bottom: -150px; right: -80px;
  background: radial-gradient(circle, var(--silver-glow), transparent 70%);
  animation-delay: 4s;
}
@keyframes glowPulse {
  0% { opacity: 0.3; transform: scale(1); }
  100% { opacity: 0.6; transform: scale(1.15); }
}

/* ── Layout ────────────────────────────────────────────── */
/* Hard 100vh / 100dvh layout — the dashboard is meant to live on one screen
 * with no scrolling (typically a TV mount). Three-row grid: header / cards
 * (fills remaining space) / footer. min-height:0 on the cards row lets them
 * shrink when the viewport is short. */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 14px 20px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.header__left { display: flex; align-items: center; gap: 18px; flex: 1; }
.header__center { display: flex; align-items: center; flex-shrink: 0; }
.header__right { display: flex; align-items: center; flex: 1; justify-content: flex-end; }

.logo { display: flex; align-items: center; gap: 12px; }
.logo__dot {
  width: 12px; height: 12px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--gold-glow);
  flex-shrink: 0;
}
.logo__text {
  font-size: clamp(18px, 1.6vw, 24px);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: 24px;
  background: var(--green-bg);
  border: 1px solid rgba(52, 211, 153, 0.2);
  font-size: clamp(14px, 1.4vw, 18px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green);
  transition: var(--transition);
}
.status-pill__dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}
.status-pill.is-error {
  background: var(--red-bg);
  border-color: rgba(248, 113, 113, 0.15);
  color: var(--red);
}
.status-pill.is-error .status-pill__dot {
  background: var(--red);
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Market badge: label is the primary signal, the "closes in …" value is
 * supporting metadata — small and muted so it doesn't shout. */
.market-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
}
.market-badge__label {
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: clamp(13px, 1.2vw, 16px);
  text-transform: uppercase;
}
.market-badge__value {
  color: var(--text-muted);
  font-weight: 500;
  font-size: clamp(11px, 1.0vw, 13px);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Clock: stacked time + date so the row never wraps when the viewport
 * narrows. Time is the primary signal (tabular nums); date is secondary. */
.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  text-align: right;
  white-space: nowrap;
}
.clock__time {
  font-size: clamp(16px, 1.5vw, 22px);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.clock__date {
  font-size: clamp(11px, 1.0vw, 13px);
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Cards grid ────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 0; /* allow children to shrink in the 1fr row */
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.card:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

/* subtle top accent line */
.card--gold::before,
.card--silver::before {
  content: "";
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 1px;
  border-radius: 0 0 1px 1px;
}
.card--gold::before {
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.3;
}
.card--silver::before {
  background: linear-gradient(90deg, transparent, var(--silver), transparent);
  opacity: 0.2;
}

.card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}
.card__label { display: flex; flex-direction: column; gap: 2px; }
.card__metal {
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.card--gold .card__metal { color: var(--gold); }
.card--silver .card__metal { color: var(--silver); }
.card__pair {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.card__arrow {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--green-bg);
  color: var(--green);
  transition: all 0.3s ease;
}
.card__arrow.is-down {
  background: var(--red-bg);
  color: var(--red);
  transform: rotate(180deg);
}

/* ── Price ──────────────────────────────────────────────── */
.card__price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.card__price {
  font-size: clamp(34px, 3.6vw, 52px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.4s ease;
}
.card__price.flash-up { color: var(--green); }
.card__price.flash-down { color: var(--red); }

.card__delta {
  font-size: clamp(13px, 1.2vw, 18px);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  transition: var(--transition);
  white-space: nowrap;
}
.card__delta.is-up {
  color: var(--green);
  background: var(--green-bg);
}
.card__delta.is-down {
  color: var(--red);
  background: var(--red-bg);
}
.card__delta.is-flat {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Bid / Ask row ─────────────────────────────────────── */
.card__bidask {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}
.card__bidask-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card__bidask-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.card__bidask-value {
  font-size: clamp(20px, 2.0vw, 30px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}
.card__bidask-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* ── Chart ──────────────────────────────────────────────── */
.card__chart {
  position: relative;
  flex: 1;
  min-height: 0; /* allows the chart to shrink with the viewport */
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  cursor: crosshair;
}
.card__chart canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.card__tooltip {
  display: none;
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(6, 14, 36, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

/* ── Meta row ──────────────────────────────────────────── */
.card__meta {
  display: flex;
  gap: 24px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.card__meta-item { display: flex; flex-direction: column; gap: 2px; }
.card__meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.card__meta-value {
  font-size: clamp(14px, 1.2vw, 18px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ── Footer ────────────────────────────────────────────── */
.footer {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Prayer widget ─────────────────────────────────────── */
.prayer-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: 24px;
  background: rgba(139, 156, 244, 0.18);
  border: 1.5px solid rgba(165, 180, 252, 0.55);
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 700;
  color: #c7d2fe;
  white-space: nowrap;
  box-shadow: 0 0 18px rgba(139, 156, 244, 0.25), inset 0 0 12px rgba(139, 156, 244, 0.08);
  animation: prayerPulse 3s ease-in-out infinite;
}
@keyframes prayerPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(139,156,244,0.25), inset 0 0 12px rgba(139,156,244,0.08); }
  50%       { box-shadow: 0 0 28px rgba(139,156,244,0.55), inset 0 0 16px rgba(139,156,244,0.15); }
}
.prayer__icon {
  font-size: 1.15em;
}
.prayer__name {
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #e0e7ff;
}
.prayer__sep {
  opacity: 0.45;
  color: #a5b4fc;
}
.prayer__countdown {
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-weight: 600;
}

/* ── Big TV mode (?big=1 in URL) ──────────────────────── */
.big-tv .card__price { font-size: clamp(64px, 9vw, 128px); }
.big-tv .card__delta { font-size: clamp(22px, 2.4vw, 36px); }
.big-tv .card__bidask-value { font-size: clamp(48px, 5.6vw, 80px); }
.big-tv .card__bidask-label { font-size: 20px; }
.big-tv .card__meta-value { font-size: clamp(24px, 2.4vw, 36px); }
.big-tv .card__meta-label { font-size: 16px; }
.big-tv .card__metal { font-size: clamp(22px, 2.4vw, 32px); }
.big-tv .logo__text { font-size: clamp(36px, 4vw, 56px); }
.big-tv .status-pill { font-size: clamp(22px, 2.4vw, 32px); }
.big-tv .prayer-pill { font-size: clamp(22px, 2.4vw, 32px); }
.big-tv .market-badge__label { font-size: clamp(22px, 2.4vw, 36px); }
.big-tv .market-badge__value { font-size: clamp(22px, 2.4vw, 36px); }
.big-tv .clock { font-size: clamp(30px, 3.2vw, 48px); }

/* ── Prayer Popup ──────────────────────────────────────── */
.prayer-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6, 14, 36, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  animation: popupFadeIn 0.5s ease;
}
.prayer-popup.is-visible { display: flex; }
@keyframes popupFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.prayer-popup__card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 72px 40px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.35);
  min-width: 380px;
  max-width: 500px;
  text-align: center;
  animation: cardSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardSlideUp {
  from { transform: translateY(36px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.prayer-popup__ornament {
  font-size: 20px;
  color: #b8860b;
  opacity: 0.6;
  letter-spacing: 8px;
}
.prayer-popup__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #888;
}
.prayer-popup__name {
  font-size: clamp(52px, 7vw, 84px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #8b0000;
}
.prayer-popup__time {
  font-size: clamp(30px, 3.8vw, 52px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #111;
}
.prayer-popup__sub {
  font-size: clamp(17px, 1.8vw, 24px);
  color: #555;
  font-weight: 500;
  direction: rtl;
}
.prayer-popup__progress {
  width: 100%;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.prayer-popup__progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8b0000, #c0392b);
  border-radius: 2px;
  transform-origin: left;
  transition: transform 1s linear;
}
.prayer-popup__close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}
.prayer-popup__close:hover { color: #333; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr; }
  .header { flex-wrap: wrap; gap: 12px; }
  .header__center { order: 3; flex-basis: 100%; justify-content: flex-start; }
}
@media (max-width: 600px) {
  .app { padding: 12px 14px; }
  .card { padding: 16px; }
  .header__left { flex-wrap: wrap; }
  .footer { flex-direction: column; align-items: center; gap: 4px; }
}
