/* ============================================================
   DHARAMRAJ SILVER ARTS – styles.css
   Brand: #003336 (primary/dark), #d9b25f (gold accent)
   Text: #1f2937 (dark) on #fff / #f9fafb background
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
  --brand:      #003336;
  --brand-mid:  #004d52;
  --brand-pale: #e6f0f0;
  --gold:       #d9b25f;
  --gold-pale:  #fdf6e3;
  --gold-dark:  #b8922e;

  --bg:         #f5f5f0;
  --surface:    #ffffff;
  --surface2:   #f9fafb;
  --border:     rgba(217,178,95,0.35);
  --border-soft: rgba(0,51,54,0.08);

  --text:       #0f1f1f;
  --text-sub:   #4b6060;
  --text-muted: #7a9090;

  --up-bg:      rgba(34,197,94,0.12);
  --up-fg:      #16a34a;
  --down-bg:    rgba(239,68,68,0.12);
  --down-fg:    #dc2626;
  --neu-bg:     rgba(0,51,54,0.05);
  --neu-fg:     #0f1f1f;

  --radius:     20px;
  --radius-sm:  12px;
  --radius-xs:  8px;
  --shadow-sm:  0 2px 12px rgba(0,51,54,0.07);
  --shadow-md:  0 8px 32px rgba(0,51,54,0.10);
  --shadow-lg:  0 16px 48px rgba(0,51,54,0.13);

  --header-h:   15vh;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- HEADER ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--brand);
  box-shadow: 0 2px 20px rgba(0,0,0,0.18);
  padding: env(safe-area-inset-top) 0 0;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.header-logo {
  height: 90px;
  width: auto;
  object-fit: contain;
  display: block;
  transition: height 0.3s ease;
}

/* ---------- MARQUEE & TIMER ---------- */
.marquee-container {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 8px;
}
.timer-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--brand-mid);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
  flex-shrink: 0;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  display: inline-block;
  transition: background 0.4s;
  flex-shrink: 0;
}
.status-dot.live   { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,0.25); }
.status-dot.disconnected { background: #ef4444; }
.last-updated {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  line-height: 1.2;
}
.marquee-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--brand-mid);
  color: #ffffff;
  padding: 14px 24px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;          /* prevent content bleed */
  will-change: contents;     /* GPU hint for smooth scroll */
  min-width: 0;
}
.marquee-bar marquee {
  /* Use CSS animation fallback on mobile for smoother scroll */
  display: block;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* ---------- PAGE LAYOUT ---------- */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 40px 30px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.vertical-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- SECTION LABEL ---------- */
.section { display: flex; flex-direction: column; gap: 10px; }
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
}

/* Slider dots */
.slider-dots { display: flex; gap: 6px; align-items: center; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
  cursor: pointer;
}
.dot.active { background: var(--gold); transform: scale(1.2); }

/* ---------- PRODUCT SLIDER ---------- */
.slider-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  cursor: grab;
}
.slider-track:active { cursor: grabbing; }
.slider-track::-webkit-scrollbar { display: none; }

.slider-card {
  flex: 0 0 calc(100% - 0px);
  scroll-snap-align: start;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  /* NO min-height — let content dictate height to prevent layout shifts */
}

/* ---------- RATES GRID ---------- */
.rates-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rate-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px;
}

/* ---------- CARD HEADER ---------- */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
}
.card-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.01em;
}

/* Metal badges */
.metal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 700;
}
.silver-badge {
  background: rgba(100,116,139,0.10);
  color: #475569;
  border: 1px solid rgba(100,116,139,0.2);
}
.gold-badge {
  background: rgba(217,178,95,0.14);
  color: var(--gold-dark);
  border: 1px solid rgba(217,178,95,0.3);
}

/* Live pill */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--up-fg);
  background: var(--up-bg);
  padding: 4px 10px;
  border-radius: 999px;
}
.live-dot {
  width: 7px;
  height: 7px;
  background: var(--up-fg);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ---------- TABLES ---------- */
.table-wrap { width: 100%; overflow: hidden; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.05rem;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

th:nth-child(1), td:nth-child(1) { width: 28%; }
th:nth-child(2), td:nth-child(2) { width: 18%; }
th:nth-child(3), td:nth-child(3) { width: 18%; }
th:nth-child(4), td:nth-child(4) { width: 18%; }
th:nth-child(5), td:nth-child(5) { width: 18%; }

thead th {
  padding: 14px 12px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
  background-color: var(--brand);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(217,178,95,0.15);
  vertical-align: middle;
  white-space: nowrap;
  font-weight: 700;
  font-size: 1.15rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0,51,54,0.035); }

.rowhead {
  font-weight: 800;
  color: var(--text);
  font-size: 1.15rem;
  font-family: 'Oswald', sans-serif;
  letter-spacing: 0.02em;
}

/* ---------- PRICE CHIPS ---------- */
.chip-val {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 1.05rem;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  min-width: 50px;
  font-variant-numeric: tabular-nums;
  transition: background 0.3s, color 0.3s;
}
.chip-val.up   { background: var(--up-bg);  color: var(--up-fg); }
.chip-val.down { background: var(--down-bg); color: var(--down-fg); }
.chip-val.same { background: var(--neu-bg); color: var(--neu-fg); }

/* High is always green text, Low always red text */
.chip-val.always-green { background: var(--up-bg);  color: var(--up-fg); }
.chip-val.always-red   { background: var(--down-bg); color: var(--down-fg); }

/* ---------- EMPTY / LOADING ---------- */
.empty-msg {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px 4px;
  font-style: italic;
}

/* ---------- FOOTER ---------- */
.site-footer {
  text-align: center;
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
}

/* ============================================================
   RESPONSIVE (Breakpoints)
   ============================================================ */

/* Extra Large Desktop */
@media (min-width: 1400px) {
  .page { width: 75%; max-width: none; gap: 28px; }
  .slider-card, .rate-card { padding: 28px; }
  .slider-card { flex: 0 0 calc(50% - 14px); }
  .slider-dots { display: none; }
  table { font-size: 1.4rem; }
  .chip-val { padding: 5px 12px; font-size: 1.25rem; min-width: 65px; }
  .rowhead { font-size: 1.4rem; }
  thead th { font-size: 1.2rem; padding: 14px 14px; }
  tbody td { padding: 12px 10px; }
  .section-title { font-size: 1.7rem; }
  .card-title { font-size: 1.8rem; }
  .marquee-bar { font-size: 1.4rem; padding: 16px 28px; }
}

/* Large Desktop */
@media (min-width: 1200px) and (max-width: 1399px) {
  .page { width: 75%; max-width: none; gap: 24px; }
  .slider-card { flex: 0 0 calc(50% - 12px); }
  .slider-dots { display: none; }
  .slider-card, .rate-card { padding: 24px; }
  table { font-size: 1.3rem; }
  .chip-val { padding: 4px 11px; font-size: 1.15rem; min-width: 60px; }
  .rowhead { font-size: 1.3rem; }
  thead th { font-size: 1.1rem; padding: 12px 12px; }
  tbody td { padding: 10px 8px; }
  .section-title { font-size: 1.6rem; }
  .card-title { font-size: 1.7rem; }
}

/* Small Desktop / Landscape Tablet */
@media (min-width: 992px) and (max-width: 1199px) {
  .page { width: 85%; max-width: none; gap: 20px; }
  .slider-card { flex: 0 0 calc(50% - 10px); }
  .slider-dots { display: none; }
  .slider-card, .rate-card { padding: 20px; }
  table { font-size: 1.2rem; }
  .chip-val { padding: 3px 10px; font-size: 1.05rem; min-width: 55px; }
  .rowhead { font-size: 1.2rem; }
  thead th { font-size: 1rem; padding: 10px 10px; }
  tbody td { padding: 9px 8px; }
}

/* Portrait Tablets */
@media (min-width: 768px) and (max-width: 991px) {
  .header-inner { padding: 12px 20px; }
  .header-logo { height: 75px; }
  .timer-box { padding: 0 14px; }
  .page { width: 95%; padding: 24px 20px; gap: 20px; }
  .rates-grid { grid-template-columns: 1fr; }
  .slider-card { flex: 0 0 100%; }
  .chip-val { min-width: 0; padding: 3px 8px; font-size: 1rem; }
  table { font-size: 1.05rem; }
  thead th { font-size: 0.95rem; }
  .rowhead { font-size: 1rem; }
}

/* Large Mobile / Phablets */
@media (min-width: 481px) and (max-width: 767px) {
  .header-inner { padding: 16px; }
  .header-logo { height: 70px; }
  .marquee-container { flex-direction: column; gap: 8px; }
  .timer-box { padding: 10px 16px; justify-content: center; }
  .page { width: 100%; padding: 16px 16px; gap: 16px; }
  .rates-grid { grid-template-columns: 1fr; }
  .slider-card { flex: 0 0 100%; padding: 14px; }
  .rate-card { padding: 14px; }
  
  .chip-val {
    min-width: 0;
    padding: 2px 6px;
    font-size: 0.9rem;
    letter-spacing: -0.3px;
  }
  thead th { font-size: 0.8rem; padding: 8px 6px; letter-spacing: 0; }
  tbody td { padding: 8px 6px; font-size: 0.95rem; }
  .rowhead  { font-size: 0.9rem; white-space: normal; }
}

/* Mobile */
@media (max-width: 480px) {
  .header-inner { padding: 12px 16px; }
  .header-logo { height: 60px; }
  .marquee-container { flex-direction: column; gap: 8px; }
  .timer-box { padding: 10px 14px; justify-content: center; }
  .last-updated { font-size: 0.95rem; }
  .page { width: 100%; padding: 12px; gap: 16px; }
  .slider-card { flex: 0 0 100%; padding: 14px; }
  .rate-card { padding: 12px; }
  .rates-grid { grid-template-columns: 1fr; }
  .marquee-bar { font-size: 1rem; padding: 10px 14px; }
  
  .chip-val {
    min-width: 0;
    padding: 2px 5px;
    font-size: 0.82rem;
    letter-spacing: -0.3px;
  }
  thead th { font-size: 0.7rem; padding: 8px 5px; letter-spacing: 0; }
  tbody td { padding: 8px 5px; font-size: 0.88rem; }
  .rowhead  { font-size: 0.82rem; white-space: normal; }
  .section-title { font-size: 1.2rem; }
  .card-title { font-size: 1.3rem; }
  .metal-badge { font-size: 0.9rem; padding: 6px 12px; }
}

/* Very small screens */
@media (max-width: 359px) {
  .chip-val { padding: 2px 4px; font-size: 0.8rem; letter-spacing: -0.5px; }
  thead th  { font-size: 0.65rem; padding: 8px 4px; }
  tbody td  { font-size: 0.85rem; padding: 8px 4px; }
  .rowhead  { font-size: 0.75rem; }
}
