/* =========================================================
   Daminato Cambios — página /cambio
   Usa los tokens y componentes de styles.css
   ========================================================= */

.main-nav ul a[aria-current="page"] { color: var(--red-text); }

/* ---------- Pizarra (siempre oscura, como el hero de la home) ---------- */
.fx-hero {
  position: relative; isolation: isolate; overflow: hidden;
  background:
    radial-gradient(70% 90% at 100% 0%, rgb(224 0 10 / .30), transparent 60%),
    radial-gradient(50% 60% at 0% 100%, rgb(224 0 10 / .10), transparent 70%),
    #1C1517;
  color: #fff;
  padding-block: clamp(28px, 4vw, 44px) clamp(48px, 7vw, 88px);
}
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-sm); color: rgb(255 255 255 / .62); margin-bottom: clamp(28px, 5vw, 56px); }
.crumbs a { color: inherit; text-underline-offset: 3px; }
.crumbs a:hover { color: #fff; }
.crumbs [aria-current] { color: #fff; font-weight: 500; }

.fx-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 32px; }
.fx-head > div { display: grid; gap: 14px; }
.fx-hero .eyebrow { color: #FF6B70; }
.fx-hero h1 { font-size: clamp(2.6rem, 1.4rem + 5vw, 5rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1; }
.fx-lead {
  font-family: var(--font-accent); font-style: italic;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem); line-height: 1.2; color: rgb(255 255 255 / .9);
}
.fx-updated {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 16px; border-radius: 999px;
  background: rgb(255 255 255 / .07); border: 1px solid rgb(255 255 255 / .14);
  font-size: var(--fs-sm); color: rgb(255 255 255 / .78);
}
.fx-updated .ic { width: 16px; height: 16px; color: #FF6B70; }
.fx-updated strong { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }

.fx-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: clamp(32px, 5vw, 48px); }
.fx-card {
  display: grid; gap: 20px; align-content: start;
  padding: 22px 24px 20px; border-radius: var(--radius);
  background: rgb(255 255 255 / .05); border: 1px solid rgb(255 255 255 / .12);
  transition: border-color .25s, background-color .25s;
  container-type: inline-size;
}
.fx-card:hover { border-color: rgb(255 255 255 / .28); background: rgb(255 255 255 / .07); }
.fx-card-head { display: flex; align-items: center; gap: 14px; }
/* la "D" del logo como distintivo de moneda */
.fx-badge {
  display: inline-flex; align-items: center; justify-content: flex-start;
  min-width: 66px; height: 46px; padding: 0 20px 0 14px;
  border-radius: 5px 999px 999px 5px;
  background: var(--red-strong); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
}
.fx-name { font-size: 1.5rem; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
.fx-code { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; color: rgb(255 255 255 / .55); }
.fx-rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border-top: 1px solid rgb(255 255 255 / .12); }
.fx-rate { padding-top: 16px; display: grid; gap: 4px; min-width: 0; }
.fx-rate + .fx-rate { padding-left: 20px; border-left: 1px solid rgb(255 255 255 / .12); }
.fx-rate dt { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgb(255 255 255 / .6); }
.fx-rate dd {
  margin: 0; font-family: var(--font-display); font-weight: 600;
  font-size: 1.4rem;
  font-size: clamp(1.2rem, 7.4cqi, 2.4rem); /* se adapta al ancho de la tarjeta */
  letter-spacing: -0.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.fx-card-calc {
  justify-self: start; font-size: var(--fs-sm); font-weight: 500; color: rgb(255 255 255 / .75);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgb(255 255 255 / .35);
}
.fx-card-calc:hover { color: #fff; text-decoration-color: var(--red); }
.fx-note { margin-top: 18px; font-size: var(--fs-sm); color: rgb(255 255 255 / .6); }

/* ---------- Tabla + calculadora ---------- */
.fx-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(32px, 6vw, 80px); align-items: start; }
.fx-grid .section-head { margin-bottom: 24px; }
.fx-table-wrap { overflow-x: auto; }
.fx-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fx-table thead th {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  text-align: right; padding: 0 0 12px; border-bottom: 2px solid var(--ink);
}
.fx-table thead th:first-child { text-align: left; }
.fx-table tbody th, .fx-table td { padding: 16px 0; border-bottom: 1px solid var(--line); font-weight: 400; text-align: left; }
.fx-table tbody tr { transition: background-color .2s; }
.fx-table tbody tr:hover { background: var(--sand); }
.cur { display: flex; align-items: center; gap: 14px; min-width: 0; }
/* casilla del código: al pasar el mouse por la fila gira y muestra la bandera */
.cur-code {
  flex: none; position: relative; width: 44px; height: 33px; perspective: 300px; /* 4:3, igual que las banderas */
  font-family: var(--font-display); font-size: .8125rem; font-weight: 600; letter-spacing: .04em;
}
.cur-face {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden;
  border-radius: 6px; clip-path: inset(0 round 6px); /* recorte de esquinas fiable durante el giro */
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform .5s var(--ease), background-color .2s;
}
/* las dos caras son fichas llenas del mismo tamaño: código sobre fondo sólido / bandera */
.cur-front { background: var(--ink); color: var(--paper); }
.cur-back { transform: rotateX(-180deg); background: var(--ink); }
.cur-back img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.fx-table tbody tr:hover .cur-front, .fx-table tbody tr.is-flipped .cur-front { transform: rotateX(180deg); }
.fx-table tbody tr:hover .cur-back, .fx-table tbody tr.is-flipped .cur-back { transform: rotateX(0deg); }
.cur-name { font-weight: 500; }
.fx-table .num { text-align: right; font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; white-space: nowrap; padding-left: 16px; }

.calc {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: clamp(22px, 3.5vw, 32px); display: grid; gap: 16px;
  position: sticky; top: calc(var(--header-h) + 24px);
}
.calc h3 { font-size: var(--fs-lg); }
.calc-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: -8px; }
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; min-width: 0;
  padding: 4px; border-radius: 999px; background: var(--sand); border: 1px solid var(--line);
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  text-align: center; padding: 10px 12px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm); color: var(--ink-2);
  transition: background-color .2s, color .2s;
}
.seg input:checked + label { background: var(--red-strong); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--red); outline-offset: 2px; }
.calc-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.input-affix { position: relative; }
.input-affix input { padding-right: 62px; font-variant-numeric: tabular-nums; font-weight: 500; }
.input-affix span {
  position: absolute; right: 14px; top: 50%; translate: 0 -50%;
  font-family: var(--font-display); font-size: .8125rem; font-weight: 600; letter-spacing: .04em; color: var(--muted);
  pointer-events: none;
}
.calc-result {
  display: grid; gap: 4px; padding: 18px 20px; border-radius: 14px;
  background: var(--panel); color: var(--panel-ink);
}
.calc-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; opacity: .72; }
#calc-total {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1;
  font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.3rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.calc-rate { font-size: var(--fs-sm); opacity: .8; }
.calc .form-note { text-align: left; }

/* ---------- Historia ---------- */
.fx-history { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.fx-history-head { display: grid; gap: 18px; }
.fx-history-head h2 { font-size: var(--fs-2xl); }
.fx-history-head .link-arrow { justify-self: start; }
.timeline { display: grid; margin: 0; padding: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li { position: relative; display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 8px 24px; padding: 0 0 36px 30px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -8px; top: .7em;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 0 5px var(--sand);
}
.t-year { font-family: var(--font-accent); font-style: italic; font-size: 3rem; line-height: .9; color: var(--red); }
.timeline h3 { font-size: 1.2rem; margin-bottom: 6px; }
.timeline p { color: var(--ink-2); max-width: 56ch; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .fx-board { grid-template-columns: 1fr; }
  .fx-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 12px 24px; }
  .fx-rates { border-top: 0; }
  .fx-rate { padding-top: 0; }
  .fx-card-calc { grid-column: 1 / -1; }
  .fx-grid, .fx-history { grid-template-columns: minmax(0, 1fr); }
  .calc { position: static; }
}
@media (max-width: 640px) {
  .fx-card { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 16px; }
  .fx-rates { border-top: 1px solid rgb(255 255 255 / .12); }
  .fx-rate { padding-top: 14px; }
  .fx-rate + .fx-rate { padding-left: 16px; }
  .fx-badge { min-width: 58px; height: 40px; font-size: .95rem; padding: 0 16px 0 12px; }
  .fx-name { font-size: 1.3rem; }
  .fx-updated { font-size: var(--fs-xs); }
  .cur { gap: 10px; }
  .cur-code { width: 40px; height: 30px; font-size: .75rem; }
  .cur-name { font-size: var(--fs-sm); line-height: 1.3; }
  .fx-table .num { font-size: .9375rem; padding-left: 10px; }
  .calc-row { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); padding-left: 24px; }
}
@media (max-width: 420px) {
  .cur { flex-direction: column; align-items: flex-start; gap: 6px; }
  .t-year { font-size: 2.4rem; }
}

/* ---------- v10: avisos de cotizaciones atrasadas o no disponibles ---------- */
.fx-updated.is-stale { background: rgb(255 176 32 / .14); border-color: rgb(255 176 32 / .45); }
.fx-updated.is-stale .ic { color: #FFB020; }

.fx-alert {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: clamp(24px, 4vw, 36px); padding: 14px 16px 14px 18px; border-radius: var(--radius-sm);
  background: rgb(255 176 32 / .12); border: 1px solid rgb(255 176 32 / .4); color: rgb(255 255 255 / .86);
  font-size: var(--fs-sm);
}
.fx-alert > .ic { width: 20px; height: 20px; color: #FFB020; flex: none; }
.fx-alert p { flex: 1 1 240px; margin: 0; }
.fx-alert strong { color: #fff; font-weight: 600; }
.fx-alert + .fx-board { margin-top: 18px; }

.fx-empty {
  display: flex; align-items: center; gap: 18px 22px; flex-wrap: wrap;
  margin-top: clamp(32px, 5vw, 48px); padding: clamp(20px, 3vw, 28px); border-radius: var(--radius);
  background: rgb(255 255 255 / .05); border: 1px solid rgb(255 255 255 / .12); color: rgb(255 255 255 / .75);
}
.fx-empty > .ic { width: 36px; height: 36px; color: #FF6B70; flex: none; }
.fx-empty > div { flex: 1 1 260px; display: grid; gap: 4px; }
.fx-empty p { margin: 0; }
.fx-empty-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg); color: #fff; }

/* destello suave cuando llegan valores nuevos sin recargar la página */
@keyframes fx-fresh { from { background-color: rgb(224 0 10 / .28); } to { background-color: rgb(255 255 255 / .05); } }
.fx-board.is-fresh .fx-card { animation: fx-fresh 1.6s var(--ease); }
@media (prefers-reduced-motion: reduce) { .fx-board.is-fresh .fx-card { animation: none; } }
