/* ============================================
   TVYAL.COM — /rate PAGE STYLES
   Extends homepage-styles.css.
   No snap-scroll; plain long-scroll page.
   ============================================ */

/* Disable snap-scroll for this page */
html { scroll-snap-type: none; }

/* ============================================
   LAYOUT
   ============================================ */

.rate-container {
  max-width: var(--container-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--container-pad);
}

.rate-section {
  padding: var(--space-8) 0;
  border-bottom: 1px solid var(--border-subtle);
}

#rate-header {
  background: var(--bg-secondary);
  padding: var(--space-7) 0 var(--space-6);
  border-bottom: 1px solid var(--border);
}

#rate-chart-section {
  background: var(--bg);
  padding: var(--space-7) 0;
  border-bottom: 1px solid var(--border-subtle);
}

#rate-narrative-section {
  background: var(--bg-secondary);
  padding: var(--space-7) 0;
  border-bottom: 1px solid var(--border-subtle);
}

#rate-table-section {
  background: var(--bg);
  padding: var(--space-7) 0;
  border-bottom: 1px solid var(--border-subtle);
}

#rate-seo-section {
  background: var(--bg-secondary);
  padding: var(--space-7) 0 var(--space-8);
}

.rate-subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin: 0 0 var(--space-6) 0;
  line-height: var(--leading-normal);
}

/* ============================================
   TICKER
   ============================================ */

.rate-ticker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-top: var(--space-5);
  flex-wrap: wrap;
}

.fx-ticker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
  animation: ratePulse 2.5s ease-in-out infinite;
}

.fx-ticker-dot.stale {
  background: var(--text-tertiary);
  animation: none;
}

@keyframes ratePulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1; }
}

/* ============================================
   9-CURRENCY GRID
   ============================================ */

#currency-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: var(--space-5);
}

.currency-card {
  background: var(--bg);
  padding: var(--space-5) var(--space-5);
  position: relative;
  overflow: hidden;
  transition: background 250ms ease;
}

.currency-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 350ms ease;
}

.currency-card--clickable {
  cursor: pointer;
}

.currency-card--clickable:hover {
  background: rgba(0, 63, 92, 0.18);
}

.currency-card--clickable:hover::before {
  transform: scaleX(1);
}

.currency-card--clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Skeleton shimmer while loading */
.currency-card-skeleton {
  background: var(--bg);
  min-height: 120px;
  position: relative;
  overflow: hidden;
}

.currency-card-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 124, 67, 0.05) 50%,
    transparent 100%);
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.card-flag {
  font-size: 18px;
  line-height: 1;
}

.card-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.card-arrow {
  margin-left: auto;
  font-size: 10px;
  font-family: var(--font-mono);
}

.arrow-up   { color: #4ade80; }
.arrow-down { color: var(--accent-hover); }
.arrow-flat { color: var(--text-tertiary); }

.card-rates {
  margin-bottom: var(--space-3);
}

.card-rate-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-1);
}

.card-rate-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.card-rate-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.card-spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
}

.card-spread-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.card-spread-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

/* Spread colour coding */
.spread-tight .card-spread { background: rgba(74, 222, 128, 0.08); }
.spread-tight .card-spread-value { color: #4ade80; }

.spread-medium .card-spread { background: rgba(255, 166, 0, 0.08); }
.spread-medium .card-spread-value { color: var(--brand-gold); }

.spread-wide .card-spread { background: rgba(249, 93, 106, 0.10); }
.spread-wide .card-spread-value { color: var(--accent-hover); }

/* ============================================
   CHART CONTROLS
   ============================================ */

.chart-controls-row {
  display: flex;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

/* When tabs take the full row, push type toggle to its own line */
.chart-ccy-tabs + .chart-type-toggle {
  margin-left: auto;
}

.chart-controls-row--secondary {
  margin-bottom: var(--space-3);
}

/* Currency tabs — wraps when all 9 shown */
.chart-ccy-tabs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.rate-tab {
  padding: 4px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms ease;
}

.rate-tab.active {
  color: var(--accent);
  border-color: var(--accent);
}

.rate-tab:hover:not(.active) {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

/* Type toggle */
.chart-type-toggle {
  display: flex;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-left: auto;
}

.type-btn {
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 200ms ease;
}

.type-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.type-btn:hover:not(.active) { color: var(--text-secondary); }

/* Mode toggle */
.chart-mode-toggle {
  display: flex;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mode-btn {
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 200ms ease;
}

.mode-btn.active {
  background: rgba(160, 81, 149, 0.12);
  color: var(--brand-purple);
}

.mode-btn:hover:not(.active) { color: var(--text-secondary); }

/* CBA checkbox */
.cba-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-left: auto;
}

.cba-toggle-label input[type='checkbox'] {
  accent-color: var(--brand-gold);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

/* ============================================
   STATS STRIP
   ============================================ */

.rate-stats-strip {
  display: flex;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.rate-stat {
  flex: 1;
  background: var(--surface);
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}

.rate-stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.rate-stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.rate-stat-change {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
}

.rate-stat-change.up   { color: #4ade80; }
.rate-stat-change.down { color: var(--accent-hover); }

/* ============================================
   CHART
   ============================================ */

.rate-chart-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--space-5);
  height: 480px;
  position: relative;
}

.rate-chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ============================================
   TIMEFRAME BUTTONS
   ============================================ */

.rate-tf-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  justify-content: flex-end;
}

.rate-tf-btn {
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms ease;
}

.rate-tf-btn.active {
  color: var(--text-secondary);
  border-color: rgba(255, 252, 245, 0.2);
}

.rate-tf-btn:hover:not(.active) {
  color: var(--text-secondary);
}

body:not(.dark-mode) .rate-tf-btn.active {
  border-color: rgba(26, 26, 26, 0.3);
}

/* ============================================
   NARRATIVE BLOCK
   ============================================ */

.narrative-block {
  border-left: 3px solid var(--accent);
  padding: var(--space-5) var(--space-6);
  background: var(--surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.narrative-text {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-loose);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.narrative-text:last-child { margin-bottom: 0; }

.narrative-text--secondary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
}

/* ============================================
   DATA TABLE
   ============================================ */

.table-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.table-filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.table-filter-group select {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 200ms;
}

.table-filter-group select:focus {
  border-color: var(--accent);
}

#tbl-download-btn {
  margin-left: auto;
  font-size: var(--text-xs);
  padding: 6px 16px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#rate-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

#rate-table thead {
  background: var(--surface-elevated);
  border-bottom: 2px solid var(--border);
}

#rate-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  white-space: nowrap;
}

#rate-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 150ms ease;
}

#rate-table tbody tr:hover {
  background: var(--accent-subtle);
}

#rate-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  white-space: nowrap;
}

#rate-table td strong {
  color: var(--text-primary);
  font-weight: 700;
}

.table-loading,
.table-empty {
  text-align: center;
  padding: var(--space-6) !important;
  color: var(--text-tertiary);
}

/* Type badge */
.type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.type-badge--xp    { background: var(--accent-subtle);          color: var(--accent); }
.type-badge--banks { background: rgba(0, 63, 92, 0.15);         color: #6ab0d8; }
.type-badge--all   { background: rgba(255, 252, 245, 0.05);     color: var(--text-tertiary); }

/* ============================================
   SEO CONTENT BLOCK
   ============================================ */

.seo-content-wrapper {
  position: relative;
}

.seo-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 500ms ease;
}

.seo-content--expanded {
  max-height: 800px;
}

.seo-content h3 {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  margin-top: var(--space-5);
}

.seo-content p {
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.seo-content p:last-child { margin-bottom: 0; }

.seo-read-more {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(255, 124, 67, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  cursor: pointer;
  transition: all 200ms ease;
  margin-top: var(--space-4);
  display: inline-block;
}

.seo-read-more:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ============================================
   LIGHT MODE OVERRIDES
   ============================================ */

body:not(.dark-mode) #rate-header,
body.light-mode #rate-header { background: var(--bg-secondary); }

body:not(.dark-mode) .rate-chart-wrapper,
body.light-mode .rate-chart-wrapper { background: var(--surface); }

body:not(.dark-mode) .rate-stats-strip,
body.light-mode .rate-stats-strip { background: var(--border); }

body:not(.dark-mode) #rate-table thead,
body.light-mode #rate-table thead { background: var(--bg-secondary); }

/* ============================================
   ARMENIAN FONT OVERRIDE
   ============================================ */

body.lang-hy .rate-subtitle,
body.lang-hy .rate-tab,
body.lang-hy .type-btn,
body.lang-hy .mode-btn,
body.lang-hy .rate-tf-btn,
body.lang-hy .card-rate-label,
body.lang-hy .card-spread-label,
body.lang-hy .rate-stat-label,
body.lang-hy .narrative-text,
body.lang-hy .seo-content p {
  font-family: var(--font-sans); /* NotoSansArm covers Armenian */
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
  #currency-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .rate-stats-strip {
    flex-wrap: wrap;
  }

  .rate-stat {
    flex: 1 1 45%;
  }

  .chart-controls-row {
    gap: var(--space-3);
  }

  .chart-type-toggle {
    margin-left: 0;
  }

  .cba-toggle-label {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  #currency-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .currency-card {
    padding: var(--space-4);
  }

  .card-flag { font-size: 14px; }
  .card-code { font-size: 11px; }
  .card-rate-value { font-size: var(--text-xs); }

  /* Stats strip: compact single row, hide Observations */
  .rate-stats-strip {
    flex-wrap: nowrap;
  }
  .rate-stat {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    min-width: 0;
  }
  .rate-stat-value {
    font-size: var(--text-sm);
    margin-bottom: 1px;
  }
  .rate-stat-label {
    margin-bottom: 1px;
  }
  /* Observations — not useful on mobile */
  .rate-stats-strip .rate-stat:last-child {
    display: none;
  }

  .rate-chart-wrapper { height: 340px; }

  .chart-controls-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-type-toggle,
  .cba-toggle-label {
    margin-left: 0;
  }

  .rate-tf-row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .table-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  #tbl-download-btn { margin-left: 0; }

  .narrative-block {
    padding: var(--space-4);
  }
}
