/* Gold prices widget — scoped for homepage hero (ported from NarkoGold) */

.home-hero-section.hero {
  /* Measured at runtime from topbar + header (not fixed per breakpoint) */
  --home-chrome-height: 0px;
  --hero-below-header: calc(100dvh - var(--home-chrome-height));
  --hero-v-gap: 0px;
  --hero-v-gap-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  padding-top: var(--hero-v-gap-top);
  padding-bottom: var(--hero-v-gap);
  padding-left: 0;
  padding-right: 0;
}

.home-hero-gold {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
}

.gold-widget {
  --gw-bg: #fff;
  --gw-muted: #9a9a9a;
  --gw-gold: #c4a36a;
  --gw-green: #2cab57;
  --gw-red: #e06262;
  --gw-row-pink: #fde8e8;
  --gw-row-mint: #e8f6ea;
  width: min(800px, 100%);
  margin: 0 auto;
  color: #333;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  /* Transparent shell so the converter can sit as a separate card with a visible gap */
  background-color: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0 0 20px;
  overflow: hidden;
}

.gold-widget * {
  box-sizing: border-box;
}

.gold-widget-header {
  background: var(--gw-bg);
  text-align: center;
  padding: 16px 14px 10px;
  border-radius: 2px 2px 0 0;
}

.gold-widget-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--gw-gold);
  font-weight: 700;
}

.gold-tabs {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  margin-top: 12px;
  gap: 0;
}

.gold-tab {
  appearance: none;
  position: relative;
  flex: 1 1 0;
  width: 33.33%;
  min-width: 0;
  margin: 0;
  padding: 10px 8px;
  border: none;
  border-bottom: 2px solid #e5e5e5;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #666;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, font-weight 0.15s ease;
}

.gold-tab:hover {
  background: transparent;
  border-bottom-color: #d6c4a2;
  box-shadow: none;
  color: #444;
}

.gold-tab.is-active {
  background: transparent;
  border: none;
  border-bottom: 2px solid #e5e5e5;
  box-shadow: none;
  color: #333;
  font-weight: 700;
}

.gold-tab.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 160px;
  max-width: 85%;
  height: 3px;
  background: var(--gw-gold);
  transform: translateX(-50%);
  pointer-events: none;
}

.gold-widget-main {
  display: block;
  background-color: var(--gw-bg);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.gold-prices-panel {
  background: var(--gw-bg);
  border-radius: 0 0 2px 2px;
}

.gold-table-scroller {
  max-height: min(430px, 52vh);
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* Prefer native chaining; SmoothScroll boundary hand-off is handled in JS. */
  overscroll-behavior-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #a0a0a0 transparent;
}

.gold-table-scroller::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.gold-table-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.gold-table-scroller::-webkit-scrollbar-thumb {
  background-color: #a0a0a0;
  border-radius: 4px;
}

.gold-table-scroller::-webkit-scrollbar-thumb:hover {
  background-color: #666666;
}

.gold-prices-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.gold-prices-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-block: 8px 10px;
  padding-inline: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #8a8a8a;
  text-align: center;
  background: var(--gw-bg);
  border-bottom: 1px solid #ececec;
}

.gold-prices-table .th-name,
.gold-prices-table .name-cell {
  width: 38%;
  text-align: start;
  padding-inline: 10px 6px;
}

.gold-prices-time {
  font-size: 12px;
  font-weight: 400;
  color: var(--gw-muted);
}

.gold-prices-table tbody tr {
  background: #fff;
}

.gold-prices-table tbody tr.row-up {
  background: var(--gw-row-mint);
}

.gold-prices-table tbody tr.row-down {
  background: var(--gw-row-pink);
}

.gold-prices-table tbody td {
  padding-block: 10px;
  padding-inline: 8px;
  vertical-align: middle;
  font-size: 14px;
}

.gold-prices-table thead th,
.gold-prices-table tbody td {
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.gold-prices-table .name-title {
  font-weight: 700;
  font-size: 14px;
  color: #222;
  line-height: 1.15;
}

.gold-prices-table .name-sub {
  margin-top: 2px;
  font-weight: 500;
  color: var(--gw-muted);
  font-size: 11px;
}

.gold-prices-table .buy-cell,
.gold-prices-table .sell-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #2f2f2f;
}

.gold-prices-table .th-diff,
.gold-prices-table .diff-cell {
  text-align: center;
}

.gold-prices-table .th-buy,
.gold-prices-table .th-sell,
.gold-prices-table .th-diff,
.gold-prices-table .buy-cell,
.gold-prices-table .sell-cell,
.gold-prices-table .diff-cell {
  width: calc((100% - 38%) / 3);
}

.gold-prices-table .diff {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
}

.gold-prices-table .diff.up {
  color: var(--gw-green);
}

.gold-prices-table .diff.down {
  color: var(--gw-red);
}

.gold-prices-table .diff.flat {
  color: var(--gw-muted);
}

.gold-prices-table .diff svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.gold-prices-table .empty-row td {
  text-align: center;
  color: var(--gw-muted);
  padding: 28px 12px;
  background: #fff;
}

.gold-converter-card {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  grid-template-rows: auto auto;
  column-gap: 20px;
  row-gap: 10px;
  align-items: start;
  background-color: var(--gw-bg);
  margin-top: 10px;
  padding: 20px 18px 22px;
  border-radius: 2px;
  box-shadow: none;
}

.gold-converter-heading {
  grid-row: 1 / span 2;
  padding-top: 4px;
}

.gold-converter-title {
  font-family: inherit;
  font-weight: inherit;
  font-size: 13px;
  color: var(--gw-gold);
}

.gold-converter-note {
  margin-top: 4px;
  font-size: 13px;
  color: var(--gw-gold);
}

.gold-converter-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: end;
}

.gold-amount-group {
  position: relative;
  display: flex;
  align-items: flex-end;
}

.gold-amount-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #d5d5d5;
  background: transparent;
  padding: 8px 42px 6px 4px;
  font-size: 14px;
  color: #4a4a4a;
  outline: none;
}

.gold-amount-unit {
  position: absolute;
  right: 2px;
  bottom: 6px;
  color: #b0b0b0;
  font-size: 14px;
  pointer-events: none;
}

.gold-select-wrap {
  position: relative;
}

.gold-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  border-bottom: 1px solid #d5d5d5;
  border-radius: 2px;
  background: transparent;
  padding: 8px 12px 6px;
  font-size: 14px;
  color: #4a4a4a;
  cursor: pointer;
  text-align: left;
  outline: none;
  box-shadow: none;
}

.gold-select-btn:focus,
.gold-select-btn:focus-visible {
  outline: none;
  border-color: rgba(196, 163, 106, 0.45);
  box-shadow: none;
}

.gold-select-btn #gold-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gold-select-wrap.open .gold-select-btn {
  background: #f7f4ef;
  border-color: rgba(0, 0, 0, 0.08);
  border-bottom-color: var(--gw-gold);
  padding: 8px 12px 6px;
}

.gold-select-caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #333;
  flex: 0 0 auto;
}

.gold-select-wrap.open .gold-select-caret {
  border-top: 0;
  border-bottom: 6px solid #333;
}

.gold-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 2px);
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
  scrollbar-width: thin;
  scrollbar-color: #a0a0a0 transparent;
}

.gold-select-menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.gold-select-menu::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

.gold-select-menu::-webkit-scrollbar-thumb {
  background-color: #a0a0a0;
  border-radius: 4px;
}

.gold-select-menu::-webkit-scrollbar-thumb:hover {
  background-color: #666666;
}

.gold-select-option {
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.35;
  color: #333;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.gold-select-option:hover,
.gold-select-option:focus {
  background-color: var(--gw-gold);
  color: #fff;
  outline: none;
}

.gold-select-option[aria-selected="true"] {
  background-color: var(--gw-gold);
  color: #fff;
}

.gold-converter-prices {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #333;
  font-size: 14px;
  padding-top: 2px;
}

.gold-price-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gold-price-label {
  font-weight: 600;
  color: var(--gw-gold);
}

.gold-price-currencies {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 14px;
}

.gold-price-ccy {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.gold-conv-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* RTL: keep the unified block centered like LTR */
[dir="rtl"] .home-hero-gold {
  justify-content: center;
  padding-left: 16px;
  padding-right: 16px;
}

[dir="rtl"] .gold-amount-unit {
  right: auto;
  left: 2px;
}

[dir="rtl"] .gold-amount-input {
  padding: 8px 4px 6px 42px;
}

[dir="rtl"] .gold-select-btn {
  text-align: right;
}

@media (max-width: 991px) {
  .gold-widget {
    width: min(740px, 100%);
  }
}

@media (max-width: 767px) {
  /* Mobile: simple center in the space below the header (not desktop gap math) */
  .home-hero-section.hero {
    justify-content: flex-start;
    min-height: var(--hero-below-header);
    padding-top: 10px;
    padding-bottom: 20px;
  }

  /* Full-width card on mobile — WA is fixed bottom, not a side gutter */
  .home-hero-gold,
  [dir="rtl"] .home-hero-gold {
    justify-content: center;
    align-items: center;
    padding-left: 12px;
    padding-right: 12px;
  }

  .gold-widget {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .gold-table-scroller {
    max-height: min(420px, 55vh);
    overflow-x: auto;
  }

  .gold-prices-table thead th {
    padding-block: 8px 10px;
    padding-inline: 4px;
    font-size: 11px;
  }

  .gold-prices-table tbody td {
    padding-block: 9px;
    padding-inline: 4px;
    font-size: 12px;
  }

  .gold-prices-table .th-name,
  .gold-prices-table .name-cell {
    width: 42%;
    padding-inline: 8px 4px;
  }

  .gold-tabs {
    width: 100%;
  }

  .gold-tab {
    flex: 1 1 0;
    width: 33.33%;
    min-width: 0;
    padding: 10px 4px;
    font-size: 11px;
  }

  .gold-prices-table .name-title {
    font-size: 12px;
  }

  .gold-prices-table .name-sub {
    display: none;
  }

  .gold-prices-table .th-buy,
  .gold-prices-table .th-sell,
  .gold-prices-table .th-diff,
  .gold-prices-table .buy-cell,
  .gold-prices-table .sell-cell,
  .gold-prices-table .diff-cell {
    width: calc((100% - 28%) / 3);
  }

  .gold-prices-table .diff {
    font-size: 11px;
    gap: 2px;
  }

  .gold-prices-table .diff svg {
    width: 12px;
    height: 12px;
  }

  .gold-converter-card {
    grid-template-columns: 1fr;
    margin-top: 8px;
    padding: 16px 12px 18px;
    row-gap: 12px;
  }

  .gold-converter-heading {
    grid-row: auto;
  }

  .gold-converter-title {
    font-size: 12px;
  }

  .gold-converter-note {
    font-size: 12px;
  }

  .gold-converter-fields {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .gold-converter-prices {
    grid-column: 1;
    gap: 10px;
    font-size: 13px;
  }

  .gold-price-currencies {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .gold-amount-input,
  .gold-select-btn {
    font-size: 15px;
  }
}

@media (max-width: 420px) {
  .home-hero-gold,
  [dir="rtl"] .home-hero-gold {
    padding-left: 8px;
    padding-right: 8px;
  }

  .gold-prices-table .buy-cell,
  .gold-prices-table .sell-cell {
    font-size: 11px;
  }
}
