/*
 * Tabela e gráfico de cotações.
 *
 * Adaptado do protótipo aprovado (mockup-golden-sgf.html) com prefixo próprio. Não reutiliza
 * as classes .ppr-table do tema de propósito: o main.css põe-lhes display:flex nas linhas e
 * as colunas deixam de alinhar. As cores vêm das variáveis do tema, com valor de recurso.
 */

.gsgf-cot {
  --gsgf-cot-blue: var(--color-blue, #243141);
  --gsgf-cot-soft: var(--color-blue-soft, #273347);
  --gsgf-cot-green: var(--color-green, #177D7B);
  --gsgf-cot-green-alpha: var(--color-green-alpha, #177D7B1A);
  --gsgf-cot-cinza: #8A93A0;
  color: var(--gsgf-cot-soft);
}

.gsgf-cot *,
.gsgf-cot *::before,
.gsgf-cot *::after {
  box-sizing: border-box;
}

/* ---- separadores ---- */

.gsgf-cot-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 34px;
}

.gsgf-cot-tab {
  appearance: none;
  border: 2px solid var(--gsgf-cot-green);
  background: transparent;
  color: var(--gsgf-cot-green);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 12px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: .25s;
}

.gsgf-cot-tab:hover {
  opacity: .75;
}

.gsgf-cot-tab.is-active {
  background: var(--gsgf-cot-green);
  color: #fff;
}

/* ---- secções ---- */

.gsgf-cot-secao--grafico {
  padding-block: 110px;
  text-align: center;
}

.gsgf-cot-secao--light-blue {
  background: rgba(39, 51, 71, .08);
}

.gsgf-cot-secao--tabela {
  padding-block: 80px 100px;
}

.gsgf-cot-titulo {
  font-size: clamp(3.6rem, 5vw, 6rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--gsgf-cot-soft);
  text-align: center;
  text-transform: uppercase;
  margin: 0 0 1rem;
}

.gsgf-cot-titulo--grafico {
  font-size: clamp(3.4rem, 4.8vw, 6.9rem);
  font-weight: 300;
  line-height: 1.25;
  letter-spacing: -2px;
  color: var(--gsgf-cot-blue);
  margin: 0 0 26px;
}

.gsgf-cot-subtitulo {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 400;
  text-align: center;
  line-height: clamp(32px, 4vw, 48px);
  letter-spacing: -1px;
  margin: 0 auto 3rem;
  color: var(--gsgf-cot-soft);
  max-width: 1150px;
}

.gsgf-cot-subtitulo--grafico p {
  font-size: clamp(19px, 2.2vw, 34px);
  font-weight: 400;
  line-height: 1.42;
  color: var(--gsgf-cot-blue);
  margin: 0 auto 44px;
  max-width: 1150px;
}

/* ---- gráfico ---- */

.gsgf-cot-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px 34px;
  text-align: left;
}

.gsgf-cot-card__barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
  flex-wrap: wrap;
}

.gsgf-cot-hint {
  font-size: 13px;
  color: var(--gsgf-cot-cinza);
  margin: 0;
}

.gsgf-cot-btn-todos {
  appearance: none;
  border: 1.5px solid var(--gsgf-cot-green);
  background: #fff;
  color: var(--gsgf-cot-green);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: .2s;
}

.gsgf-cot-btn-todos:hover {
  background: var(--gsgf-cot-green);
  color: #fff;
}

.gsgf-cot-chart-wrap {
  position: relative;
}

.gsgf-cot-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
}

.gsgf-cot-grid {
  stroke: #D9DDE2;
  stroke-width: 1;
  stroke-dasharray: 4 5;
}

.gsgf-cot-band {
  fill: rgba(39, 51, 71, .06);
  opacity: 0;
}

.gsgf-cot-hline {
  stroke: #273347;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0;
}

.gsgf-cot-hline.is-on,
.gsgf-cot-band.is-on {
  opacity: 1;
}

.gsgf-cot-zone {
  fill: transparent;
  cursor: crosshair;
}

.gsgf-cot-serie {
  transition: opacity .18s, stroke-width .18s;
}

.gsgf-cot-tooltip {
  position: absolute;
  pointer-events: none;
  background: #fff;
  border: 1px solid rgba(39, 51, 71, .12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .12s;
  z-index: 5;
  min-width: 240px;
}

.gsgf-cot-tooltip.is-on {
  opacity: 1;
}

.gsgf-cot-tt-titulo {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 9px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--gsgf-cot-cinza);
}

.gsgf-cot-tt-linha {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
}

.gsgf-cot-tt-cor {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

.gsgf-cot-tt-nome {
  flex: 1;
  color: var(--gsgf-cot-soft);
  font-weight: 500;
}

.gsgf-cot-tt-valor {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gsgf-cot-blue);
}

.gsgf-cot-tt-linha.is-hi .gsgf-cot-tt-nome,
.gsgf-cot-tt-linha.is-hi .gsgf-cot-tt-valor {
  color: var(--gsgf-cot-blue);
  font-weight: 700;
}

/* Grid com colunas iguais: com flex-wrap os nomes não alinham entre colunas. */
.gsgf-cot-legenda {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 28px 32px;
  margin-top: 44px;
  padding-left: 6px;
}

.gsgf-cot-legenda-item {
  background: none;
  border: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: .2s;
  width: 100%;
}

.gsgf-cot-legenda-item:hover {
  transform: translateY(-1px);
}

.gsgf-cot-leg-rotulo {
  font-size: 14px;
  font-weight: 700;
  color: var(--gsgf-cot-soft);
  line-height: 1.2;
}

.gsgf-cot-leg-nome {
  font-size: 19px;
  font-weight: 700;
  color: var(--gsgf-cot-soft);
  line-height: 1.2;
  letter-spacing: -.4px;
}

.gsgf-cot-leg-barra {
  width: 42px;
  height: 7px;
  border-radius: 4px;
  margin-top: 4px;
}

.gsgf-cot-legenda-item.is-off {
  opacity: .34;
}

.gsgf-cot-legenda-item.is-off .gsgf-cot-leg-barra {
  background: #B9BFC7 !important;
}

.gsgf-cot-foot {
  font-size: 13px;
  color: #6B7280;
  margin: 26px 0 0;
  line-height: 1.6;
}

/* ---- tabela ---- */

.gsgf-cot-scroll-hint {
  display: none;
  font-size: 13px;
  color: var(--gsgf-cot-cinza);
  margin: 0 0 12px;
}

.gsgf-cot-tabela-wrap {
  border-bottom: 2px solid var(--gsgf-cot-soft);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/*
 * CSS grid e não flexbox: com flexbox os gap somam-se por cima dos 100% da largura e a tabela
 * transborda em desktop.
 */
.gsgf-cot-tabela {
  width: 100%;
  display: grid;
  grid-template-columns: 2.2fr repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 8px;
  margin: 0;
  border: 0;
  background: none;
}

.gsgf-cot-tabela thead,
.gsgf-cot-tabela tbody,
.gsgf-cot-tabela tr {
  display: contents;
}

.gsgf-cot-tabela th,
.gsgf-cot-tabela td {
  display: flex;
  flex-direction: column;
  place-content: center;
  font-size: 17px;
  text-align: center;
  min-width: 0;
  border: 0;
}

.gsgf-cot-tabela th {
  padding: 24px 18px;
}

.gsgf-cot-tabela td {
  padding: 16px 18px;
}

.gsgf-cot-th--span2 {
  grid-row: span 2;
}

.gsgf-cot-th--grupo {
  grid-column: span 5;
  background: var(--gsgf-cot-green);
  color: #fff;
  font-weight: 700;
  font-size: clamp(13px, 1.15vw, 18px);
  letter-spacing: .02em;
  border-radius: 12px 12px 0 0;
  padding: 12px 10px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gsgf-cot-tabela thead th {
  font-weight: 700;
  font-size: clamp(14px, 1.4vw, 19px);
  line-height: 1.3;
  color: #fff;
  background: var(--gsgf-cot-green);
}

/* Apenas o primeiro nivel do cabecalho e arredondado; o segundo nivel encosta ao grupo acima. */
.gsgf-cot-tabela thead tr:first-child th {
  border-radius: 12px 12px 0 0;
}

.gsgf-cot-th-data {
  font-size: clamp(14px, 1.4vw, 18px);
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--gsgf-cot-soft) !important;
  text-align: center !important;
}

.gsgf-cot-th-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  opacity: .8;
  letter-spacing: .01em;
  margin-top: 5px;
  text-transform: none;
  line-height: 1.35;
}

/*
 * A coluna fixa é escolhida por classe própria e nunca por :first-child: com o cabeçalho em
 * dois níveis, o :first-child apanhava também a primeira célula do segundo nível.
 */
.gsgf-cot-tabela .gsgf-cot-col-produto {
  text-align: left;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, .2);
  min-width: 0;
  position: sticky;
  left: 0;
  z-index: 3;
}

.gsgf-cot-tabela th.gsgf-cot-col-produto {
  z-index: 4;
}

.gsgf-cot-tabela tbody td:not(.gsgf-cot-col-produto) {
  text-align: center;
  background: var(--gsgf-cot-green-alpha);
  font-weight: 700;
  font-size: 17px;
  color: var(--gsgf-cot-blue);
}

.gsgf-cot-tabela tr:last-child td {
  border-bottom: 0;
}

.gsgf-cot-nome {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.gsgf-cot-nome strong {
  font-size: clamp(16px, 1.4vw, 21px);
  font-weight: 700;
  color: var(--gsgf-cot-soft);
  line-height: 1.2;
  letter-spacing: -.5px;
}

.gsgf-cot-nome__rotulo {
  font-size: 15px;
  font-weight: 700;
  color: var(--gsgf-cot-soft);
  display: block;
  opacity: .75;
}

.gsgf-cot-ponto {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.gsgf-cot-tabela tbody td.gsgf-cot-nd {
  color: #98A2AE;
  font-weight: 700;
}

.gsgf-cot-notas {
  margin-top: 22px;
}

.gsgf-cot-notas p {
  font-size: 16px;
  line-height: 26px;
  margin: 0 0 4px;
  color: var(--gsgf-cot-soft);
}

/* ---- download e avisos ---- */

.gsgf-cot-download {
  display: inline-block;
  margin-top: 22px;
  border: 1.5px solid var(--color-green, #177D7B);
  color: var(--color-green, #177D7B);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 11px 22px;
  border-radius: 999px;
  text-decoration: none;
  transition: .2s;
}

.gsgf-cot-download:hover {
  background: var(--color-green, #177D7B);
  color: #fff;
}

.gsgf-cot-aviso {
  margin: 20px auto;
  padding: 14px 18px;
  max-width: 900px;
  border-left: 4px solid #BF901E;
  background: #FDF6E7;
  font-size: 14px;
}

/* ---- responsivo ---- */

@media (max-width: 1500px) {
  .gsgf-cot-tabela th {
    padding: 20px 10px;
  }

  .gsgf-cot-tabela td {
    padding: 16px 10px;
  }

  .gsgf-cot-tabela thead th {
    font-size: clamp(13px, 1.25vw, 17px);
  }
}

/* Abaixo de 1024 px a tabela desliza; a coluna do produto passa a largura fixa, porque
   proporcional ocupava dois terços do ecrã no telemóvel. */
@media (max-width: 1000px) {
  .gsgf-cot-scroll-hint {
    display: block;
  }

  .gsgf-cot-tabela {
    grid-template-columns: 150px repeat(7, minmax(112px, 1fr));
    min-width: 1004px;
  }

  .gsgf-cot-tabela .gsgf-cot-col-produto {
    min-width: 0;
    box-shadow: 6px 0 12px -8px rgba(0, 0, 0, .25);
  }

  .gsgf-cot-tabela th,
  .gsgf-cot-tabela td {
    font-size: 15px;
  }

  .gsgf-cot-th-sub {
    font-size: 9.5px;
    letter-spacing: -.1px;
  }
}

@media (max-width: 860px) {
  .gsgf-cot-titulo,
  .gsgf-cot-titulo--grafico {
    font-size: 2.8rem;
  }

  .gsgf-cot-secao--grafico {
    padding-block: 60px;
  }

  .gsgf-cot-card {
    padding: 24px 16px;
  }

  .gsgf-cot-tabela th,
  .gsgf-cot-tabela td {
    padding: 14px 10px;
  }

  .gsgf-cot-nome strong {
    font-size: 15px;
    letter-spacing: -.3px;
  }

  .gsgf-cot-nome__rotulo {
    font-size: 12px;
  }

  .gsgf-cot-tabela thead th {
    font-size: 16px;
  }

  .gsgf-cot-legenda {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 16px;
  }

  .gsgf-cot-leg-nome {
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  .gsgf-cot-tabela {
    grid-template-columns: 132px repeat(7, minmax(106px, 1fr));
    min-width: 942px;
  }

  .gsgf-cot-nome strong {
    font-size: 13.5px;
    line-height: 1.15;
  }

  .gsgf-cot-nome__rotulo {
    font-size: 11px;
  }

  .gsgf-cot-tabela th,
  .gsgf-cot-tabela td {
    padding: 12px 8px;
  }
}
