/* mod_fxrates – horizontal exchange-rate strip. Colours come from module params via custom properties. */
.fxr {
  --fxr-ink: #1c2741;
  --fxr-accent: #1d3a8a;
  --fxr-bg: #f6f8fb;
  --fxr-line: #e2e7ee;
  --fxr-muted: color-mix(in srgb, var(--fxr-ink) 68%, transparent);
  container-type: inline-size;
  color: var(--fxr-ink);
}

.fxr__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem clamp(1rem, 1.6cqi, 2rem);
  padding: 1.5rem clamp(1.25rem, 2.2cqi, 2rem);
  background: var(--fxr-bg);
  border: 1px solid var(--fxr-line);
  border-radius: 12px;
}

/* Intro */
.fxr__intro { flex: 1 1 15rem; min-width: 9rem; }
.fxr .fxr__title {
  margin: 0 0 .3rem;
  font-size: clamp(1.125rem, 1.75cqi, 1.375rem);
  font-weight: 700;
  line-height: 1.25;
  color: inherit;
}
.fxr__sub { margin: 0; color: var(--fxr-muted); line-height: 1.45; }

/* Currencies */
.fxr__list {
  display: flex;
  flex-wrap: nowrap; /* keep all currencies on one line; sizes scale with the container instead */
  justify-content: center;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.fxr__item {
  display: flex;
  align-items: center;
  flex: none;
  gap: clamp(.6rem, 1cqi, .9rem);
  margin: 0;
  padding: 0 clamp(.75rem, 1.5cqi, 1.75rem);
  border-left: 1px solid var(--fxr-line);
}
.fxr__item:first-child { padding-left: 0; border-left: 0; }

.fxr__flag {
  flex: none;
  width: clamp(2.25rem, 3.4cqi, 3rem);
  height: clamp(2.25rem, 3.4cqi, 3rem);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fxr-ink) 8%, transparent);
}
.fxr__flag--text {
  display: grid;
  place-items: center;
  background: var(--fxr-line);
  font-size: .8rem;
  font-weight: 700;
}

.fxr abbr.fxr__code[title],
.fxr__code {
  display: block;
  margin-bottom: .35rem;
  font-size: clamp(1rem, 1.4cqi, 1.125rem);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border-bottom: 0;
  cursor: default;
}

.fxr__rates {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: clamp(.8125rem, 1.15cqi, .9375rem);
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.fxr__rate { display: flex; gap: .3rem; }
.fxr__rate + .fxr__rate {
  margin-left: .6rem;
  padding-left: .6rem;
  border-left: 1px solid color-mix(in srgb, var(--fxr-ink) 30%, transparent);
}
.fxr__rates dt { margin: 0; font-weight: 400; color: var(--fxr-muted); }
.fxr__rates dd { margin: 0; font-weight: 700; color: var(--fxr-ink); }

/* Last updated + link */
.fxr__meta {
  flex: none;
  padding-left: clamp(1rem, 1.6cqi, 2rem);
  border-left: 1px solid var(--fxr-line);
  font-size: clamp(.8125rem, 1.15cqi, .9375rem);
}
.fxr__updated { margin: 0 0 .55rem; color: var(--fxr-muted); line-height: 1.4; }
.fxr__updated > * { display: block; }

.fxr__link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-weight: 700;
  color: var(--fxr-accent);
  text-decoration: none;
}
.fxr__link:hover { text-decoration: underline; text-underline-offset: 3px; }
.fxr__link:focus-visible { outline: 2px solid var(--fxr-accent); outline-offset: 3px; border-radius: 2px; }
.fxr__arrow { transition: transform .15s ease; }
.fxr__link:hover .fxr__arrow { transform: translateX(3px); }

/* Heading on top (default): title row first, then currencies + meta on one row */
.fxr--top .fxr__inner { flex-wrap: wrap; row-gap: 1.1rem; }
.fxr--top .fxr__intro { flex: 1 1 100%; min-width: 0; }
.fxr--top .fxr__list { flex: 0 0 auto; justify-content: flex-start; }
.fxr--top .fxr__meta { margin-left: auto; }

/* Medium: currencies in an even grid, meta along the bottom.
   Heading-left layout needs this sooner than heading-on-top. */
@container (max-width: 1120px) {
  .fxr:not(.fxr--top) .fxr__inner { flex-wrap: wrap; }
  .fxr:not(.fxr--top) .fxr__intro { flex-basis: 100%; }
  .fxr:not(.fxr--top) .fxr__list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
    gap: 1rem 1.5rem;
    justify-content: stretch;
    flex: 1 1 100%;
  }
  .fxr:not(.fxr--top) .fxr__item, .fxr:not(.fxr--top) .fxr__item:first-child { padding: 0; border-left: 0; }
  .fxr:not(.fxr--top) .fxr__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    flex: 1 1 100%;
    padding: 1rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--fxr-line);
  }
  .fxr:not(.fxr--top) .fxr__updated { margin: 0; }
  .fxr:not(.fxr--top) .fxr__updated > * { display: inline; }
  .fxr:not(.fxr--top) .fxr__updated > span::after { content: " "; }
}

@container (max-width: 900px) {
  .fxr--top .fxr__inner { flex-wrap: wrap; }
  .fxr--top .fxr__intro { flex-basis: 100%; }
  .fxr--top .fxr__list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
    gap: 1rem 1.5rem;
    justify-content: stretch;
    flex: 1 1 100%;
  }
  .fxr--top .fxr__item, .fxr--top .fxr__item:first-child { padding: 0; border-left: 0; }
  .fxr--top .fxr__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    flex: 1 1 100%;
    padding: 1rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--fxr-line);
  }
  .fxr--top .fxr__updated { margin: 0; }
  .fxr--top .fxr__updated > * { display: inline; }
  .fxr--top .fxr__updated > span::after { content: " "; }
  .fxr--top .fxr__meta { margin-left: 0; }
}

/* Small: one currency per row, rates aligned right */
@container (max-width: 560px) {
  .fxr .fxr__inner { padding: 1.25rem; }
  .fxr .fxr__inner .fxr__title { font-size: 1.25rem; }
  .fxr .fxr__inner .fxr__list { grid-template-columns: 1fr; gap: 0; }
  .fxr .fxr__inner .fxr__item, .fxr .fxr__inner .fxr__item:first-child { padding: .8rem 0; border-top: 1px solid var(--fxr-line); }
  .fxr .fxr__inner .fxr__item:first-child { padding-top: 0; border-top: 0; }
  .fxr .fxr__inner .fxr__item:last-child { padding-bottom: 0; }
  .fxr .fxr__inner .fxr__flag { width: 2.5rem; height: 2.5rem; }
  .fxr .fxr__inner .fxr__body {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .25rem 1rem;
  }
  .fxr .fxr__inner .fxr__code { margin: 0; }
}

/* Viewport ranges (Bootstrap md / lg), requested for the site's wider font.
   767–1199: "Last updated" + link always get their own line under the rates. */
@media (min-width: 767px) and (max-width: 1199.98px) {
  .fxr .fxr__inner .fxr__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    flex: 1 1 100%;
    margin-left: 0;
    padding: 1rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--fxr-line);
  }
  .fxr .fxr__inner .fxr__updated { margin: 0; }
  .fxr .fxr__inner .fxr__updated > * { display: inline; }
  .fxr .fxr__inner .fxr__updated > span::after { content: " "; }
}

/* 767–991: Buy and Sell on separate lines, numbers aligned */
@media (min-width: 767px) and (max-width: 991.98px) {
  .fxr .fxr__inner .fxr__rates {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    column-gap: .35rem;
    row-gap: .15rem;
  }
  .fxr .fxr__inner .fxr__rate { display: contents; }
  .fxr .fxr__inner .fxr__rate + .fxr__rate { margin: 0; padding: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .fxr__arrow { transition: none; }
}
