/**
 * @file
 * Styles of the exchange rate table.
 *
 * The table is printed in the blog and served on its own to be embedded
 * anywhere else, so the rules live in the module and not in the theme: the
 * embed page carries this file and nothing else, and the table then looks the
 * same in both places and in whatever surrounds the frame.
 *
 * The colours are the ones the theme already uses for the product trend table
 * this one is modelled on.
 */

.tasas-table {
  margin-top: 1.5rem;
}

.tasas-table-card {
  overflow: hidden;
  border-radius: 0.6rem;
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(30, 20, 40, 0.14);
}

.tasas-table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 10px 16px;
  border-radius: 0.6rem 0.6rem 0 0;
  background-color: #da1a80;
  color: #fff;
  font-size: 1.3rem;
  font-style: italic;
  text-align: center;
}

.tasas-table-updated {
  flex: 0 0 auto;
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.tasas-table-header,
.tasas-table-row {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
}

.tasas-table-header {
  border-bottom: 2px solid #f3c6de;
  background-color: #f6f6f7;
  color: #da1a80;
  font-size: 0.8rem;
}

.tasas-table-row {
  border-bottom: 1px solid #ececf0;
  background-color: #fff;
  color: #2b4f86;
  font-size: 0.8rem;
  transition: background-color 0.15s ease;
}

.tasas-table-row:last-child {
  border-bottom: 0;
}

.tasas-table-row:hover {
  background-color: #fdf1f8;
}

/* The numbers sit against the right edge and the currency against the left
   one, so every figure of a column shares its edge and the headers end where
   their own data ends. Tabular numerals keep the decimals in line, which is
   what makes two amounts comparable at a glance. */
.tasas-table-cell {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  min-height: 53px;
  padding: 0.5rem 0.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.tasas-table-cell:first-child {
  flex: 0 1 18%;
  justify-content: flex-start;
  letter-spacing: 0.02em;
  text-align: left;
}

.tasas-table-header .tasas-table-cell {
  font-size: 0.8rem;
}

.tasas-table-row .tasas-table-cell {
  font-size: 0.85rem;
  font-weight: bold;
}

.tasas-table-row .tasas-table-cell:first-child {
  font-weight: 700;
}

/* The official and informal rates share the same tone: colour belongs to the
   change, not to the source. */

.tasas-table-row .tasas-table-cell--gap {
  gap: 0.4em;
  white-space: nowrap;
}

/* The rate and its change share one cell: side by side while the column is
   wide enough, the change dropping under the rate when it is not. The type is
   kept on one line each, so the break falls between the two pieces and never
   inside a number. */
.tasas-table-row .tasas-table-cell--rate {
  flex-wrap: wrap;
  gap: 0.15rem 0.4rem;
  white-space: nowrap;
}

/* The change is a soft pill sized to the widest change the table shows: an
   arrow, a sign and up to three integer digits. A fixed width keeps the rate's
   right edge still from row to row, so the decimals of a column line up even
   when one currency moved and another did not. Red marks a rise and green a
   fall, the convention the site already uses. */
.tasas-table-row .tasas-table-change {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  min-width: 6.9em;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background-color: #f1f2f5;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tasas-table-change.is-up {
  color: #c62828;
  background-color: #fdeaea;
}

.tasas-table-change.is-down {
  color: #1b7f3b;
  background-color: #e6f5eb;
}

.tasas-table-change.is-flat {
  color: #8a8fa0;
  background-color: #f1f2f5;
}

/* A flat change carries a small line of its own, so a value that did not
   move is read at a glance instead of looking like a percentage that got
   lost. */
.tasas-table-change.is-flat:not(.is-empty)::before {
  content: "";
  flex: 0 0 auto;
  width: 0.8em;
  height: 2px;
  border-radius: 1px;
  background-color: currentColor;
}

/* Nothing to show: the dash is not a trend, so it is not dressed as one. The
   row is named here so this rule outranks the compact sizes the responsive
   blocks give every variation, empty ones included: at a reduced size the
   empty dash has to keep its bare box instead of reserving a pill. */
.tasas-table-row .tasas-table-change.is-empty {
  min-width: 0;
  padding: 0;
  background-color: transparent;
}

/* The gap shows the gross difference in CUP: the percentage stays in the
   tooltip, because as visible text it crowds the column and takes more room
   than the table can spare. The word that names the rate that is above is
   written by the script as an attribute, so the markup only carries the figure
   and the side it belongs to. */
.tasas-table-cell--gap::before {
  color: #8a8fa0;
  font-size: 0.75rem;
  font-weight: 400;
}

.tasas-table-cell--gap[data-gap="higher"]::before {
  content: "Informal";
}

.tasas-table-cell--gap[data-gap="lower"]::before {
  content: "Oficial";
}

.tasas-table-link {
  display: block;
  width: 100%;
  padding: 10px 0;
  border-top: 1px solid #e4e7e9;
  color: #da1a80 !important;
  font-size: 1.2rem;
  font-weight: bold;
  text-align: center;
}

.tasas-table-link:hover {
  color: #295b95 !important;
}

.tasas-table-error {
  margin: 12px 10px 0;
  color: #a94442;
  font-size: 0.9rem;
  text-align: center;
}

/* The embed page carries nothing but the table, so it has no chrome and the
   table does not need the gap it has in the middle of a page. */
.tasas-embed-body {
  margin: 0;
  /* The card casts a soft shadow all around it, so the frame leaves room for
     it: without that the shadow is painted outside the frame and is never
     seen. */
  padding: 10px;
  box-sizing: border-box;
  background: transparent;
  /* The site stack, so the table reads the same inside the frame as it does
     in the page around it. */
  font-family: "Mon-regular", sans-serif;
  height: 100vh;
}

/* The frame gives the table a box and the table fills it: the title, the
   header and the link keep their own height and the rows share what is left,
   growing or shrinking, so the table looks the same in a short frame and in a
   tall one and is never cut at the bottom. */
.tasas-embed-body .tasas-table {
  margin-top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.tasas-embed-body .tasas-table-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tasas-embed-body .tasas-table-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tasas-embed-body .tasas-table-rows {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tasas-embed-body .tasas-table-row {
  flex: 1 1 0;
  min-height: 0;
}

.tasas-embed-body .tasas-table-cell {
  min-height: 0;
}

/* The theme sizes its boxes with the border box, so the table measures the
   same there and in the frame. Without this the rows are taller in the frame
   and the table does not fit the box it is given. */
.tasas-table,
.tasas-table * {
  box-sizing: border-box;
}

@media (max-width: 575.98px) {
  .tasas-table-title {
    font-size: 1.05rem;
  }

  .tasas-table-updated {
    font-size: 10px;
  }

  .tasas-table-header .tasas-table-cell,
  .tasas-table-row .tasas-table-cell {
    padding: 0.35rem 0.4rem;
  }

  .tasas-table-header .tasas-table-cell {
    font-size: 0.72rem;
  }

  .tasas-table-row .tasas-table-cell {
    font-size: 0.78rem;
  }

  .tasas-table-row .tasas-table-change {
    padding: 0.1em 0.4em;
    font-size: 0.72rem;
  }

  .tasas-table-link {
    font-size: 1rem;
  }
}

/* Four columns of a phone width leave no room for the label next to the gross
   figure. The gap stacks the two instead of hiding the word: the figure is
   always positive, so the word is what says which rate is above. */
@media (max-width: 480px) {
  .tasas-table-row .tasas-table-cell--gap {
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.1em;
  }
}

/* Narrow column, the sidebar the table is meant to live in. Four columns of
   a phone width are tight, so the title stacks and the type shrinks. */
@media (max-width: 400px) {
  .tasas-table-title {
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.95rem;
  }

  .tasas-table-updated {
    font-size: 10px;
  }

  .tasas-table-header .tasas-table-cell,
  .tasas-table-row .tasas-table-cell {
    min-height: 40px;
    padding: 0.3rem 0.15rem;
  }

  .tasas-table-header .tasas-table-cell {
    font-size: 0.66rem;
  }

  .tasas-table-row .tasas-table-cell {
    font-size: 0.72rem;
  }

  .tasas-table-row .tasas-table-change {
    padding: 0.05em 0.3em;
    font-size: 0.66rem;
  }

  .tasas-table-link {
    padding: 8px 0;
    font-size: 0.95rem;
  }

  .tasas-table-error {
    font-size: 0.8rem;
  }
}

/* A short frame: the type and the padding shrink so the table still fits the
   box it is given instead of being cut at the bottom. The thresholds are
   below the height the table needs on its own, so a frame with room for it
   keeps the full size type and the rows share what is left. */
@media (max-height: 290px) {
  .tasas-table-title {
    padding: 3px 8px;
    font-size: 1.05rem;
  }

  .tasas-table-updated {
    font-size: 10px;
  }

  .tasas-table-header .tasas-table-cell,
  .tasas-table-row .tasas-table-cell {
    min-height: 30px;
    padding: 0.25rem;
  }

  .tasas-table-header .tasas-table-cell {
    font-size: 0.72rem;
  }

  .tasas-table-row .tasas-table-cell {
    font-size: 0.78rem;
  }

  .tasas-table-row .tasas-table-change {
    padding: 0.05em 0.4em;
    font-size: 0.72rem;
  }

  .tasas-table-link {
    padding: 6px 0;
    font-size: 1rem;
  }

  .tasas-table-error {
    margin-top: 6px;
    font-size: 0.8rem;
  }
}

@media (max-height: 240px) {
  .tasas-table-title {
    padding: 2px 6px;
    font-size: 0.9rem;
  }

  .tasas-table-updated {
    font-size: 9px;
  }

  .tasas-table-header .tasas-table-cell,
  .tasas-table-row .tasas-table-cell {
    min-height: 24px;
    padding: 0.15rem;
  }

  .tasas-table-header .tasas-table-cell {
    font-size: 0.64rem;
  }

  .tasas-table-row .tasas-table-cell {
    font-size: 0.7rem;
  }

  .tasas-table-row .tasas-table-change {
    padding: 0.02em 0.3em;
    font-size: 0.64rem;
  }

  .tasas-table-link {
    padding: 4px 0;
    font-size: 0.9rem;
  }
}
