/* Static pages (content pages + the prerender wrapper of the home landings).
   Loaded after the app stylesheet, so every token, font and component (.top, .search, .band, .foot)
   comes from src/styles.css; this file only adds what the static pages need. */

/* ---------- home prerender (see src/prerender.tsx and scripts/site/pre.js) ---------- */

/* The prerendered app frame sits in a wrapper that does not create a box, so it lays out exactly
   like the tree React renders over it. */
.pre {
  display: contents;
}
/* pre.js sets these before first paint: a ?q= view or a different UI language would show the wrong
   frame for a moment, so those visitors get the empty shell, as before. */
.pre-q .pre,
.pre-lang .pre {
  display: none;
}

/* On narrow screens the app's header links (.nav) take a second row, but React renders them only
   after /api/config answers, which pushed the headline and search down (CLS ~0.06 at 375px).
   Reserve that row up front: logo row 44px + gap 12px + links row 44px. */
@media (max-width: 720px) {
  #root .bar {
    min-height: 100px;
    align-content: flex-start;
  }
}

/* ---------- static pages: the "Menu" disclosure (phones; same links as the app's sheet) ---------- */

/* the popup spans the header width just under the button (the header's inner box is its containing block) */
.top-inner:has(.menu-d) {
  position: relative;
}
.menu-d > summary {
  list-style: none;
}
.menu-d > summary::-webkit-details-marker {
  display: none;
}
.menu-d[open] > summary {
  background: var(--on-yellow);
  color: var(--yellow);
}
.menu-pop {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  margin-top: 8px;
  z-index: 30;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -16px rgba(23, 21, 15, 0.55);
  overflow: hidden;
}
.menu-pop .menu-list {
  border-top: 0;
}
.menu-pop .menu-list li:last-child a {
  border-bottom: 0;
}
/* narrow phones: logo block + PT EN ES 中文 + Menu on one row (the link still names the site) */
@media (max-width: 440px) {
  .top:has(.menu-d) .logo span {
    display: none;
  }
}
.sitenav a[aria-current="page"],
.menu-list a[aria-current="page"],
.foot-pages a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* ---------- content pages ---------- */

.langs a {
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--on-yellow);
  font: 700 14px/1 var(--body);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}
.langs a:hover {
  background: rgba(23, 21, 15, 0.1);
}
.langs a[aria-current="true"] {
  background: var(--on-yellow);
  color: var(--yellow);
}
.page-strip .strip-inner {
  padding-bottom: 18px;
}
.page {
  padding-block: 28px 56px;
}
.crumbs ol {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 14px;
  color: var(--ink-soft);
}
.crumbs li + li::before {
  content: "/";
  margin-right: 4px;
  color: var(--line);
}
.crumbs a {
  color: var(--ink-soft);
}
.prose {
  max-width: 72ch;
}
.prose h1 {
  font: 800 clamp(30px, 4.4vw, 46px)/1.06 var(--display);
  letter-spacing: -0.035em;
  margin: 0 0 16px;
  max-width: 22ch;
}
.prose .lead {
  font-size: 19px;
  line-height: 1.55;
  margin: 0 0 10px;
}
.prose .updated {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.prose h2 {
  font: 800 25px/1.2 var(--display);
  letter-spacing: -0.02em;
  margin: 40px 0 10px;
  scroll-margin-top: 16px;
}
.prose h3 {
  font: 700 18px/1.3 var(--body);
  margin: 26px 0 8px;
}
.prose p,
.prose li {
  line-height: 1.65;
}
.prose p {
  margin: 0 0 14px;
}
.prose ul,
.prose ol {
  padding-left: 1.3em;
  margin: 0 0 16px;
  display: grid;
  gap: 6px;
}
.prose a {
  font-weight: 600;
  text-decoration-thickness: 1.5px;
}
.prose q {
  font-weight: 600;
}
.zh,
.prose [lang="zh-CN"] {
  font-family: var(--cjk), var(--body);
}
.table-wrap {
  overflow-x: auto;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}
.prose th,
.prose td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.prose tr:last-child td {
  border-bottom: 0;
}
.prose th {
  background: var(--chip);
  font-weight: 700;
}
.prose td.zh {
  font-size: 17px;
  white-space: nowrap;
}

/* FAQ: every question is a visible h2 with its answer right under it */
.faq-item h2 {
  font-size: 21px;
  margin-top: 30px;
}

/* step-by-step guide */
.steps {
  list-style: none;
  padding: 0 !important;
  margin: 26px 0 8px !important;
  counter-reset: step;
  gap: 0 !important;
}
.steps > li {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0 16px;
  padding-bottom: 6px;
}
.steps .step-n {
  font: 800 40px/1 var(--display);
  letter-spacing: -0.04em;
  color: var(--ink);
  -webkit-text-stroke: 0;
}
.steps h2 {
  margin: 4px 0 6px;
  font-size: 21px;
}

/* related reading */
.related {
  margin-top: 44px;
  max-width: 72ch;
}
.related h2 {
  font: 800 21px/1.2 var(--display);
  margin: 0 0 12px;
}
.related ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.related a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  font-weight: 700;
  line-height: 1.3;
  transition: border-color 0.15s;
}
.related a:hover {
  border-color: var(--ink);
}
.band .note {
  margin-top: 10px;
  font-size: 13.5px;
}

@media (max-width: 720px) {
  .related ul {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .prose .lead {
    font-size: 17.5px;
  }
  .steps > li {
    grid-template-columns: 34px 1fr;
    gap: 0 10px;
  }
  .steps .step-n {
    font-size: 30px;
  }
  .prose td.zh {
    white-space: normal;
  }
}

/* Pinyin is a pronunciation aid; on phones the term tables need the room for the words. */
@media (max-width: 560px) {
  .prose .py {
    display: none;
  }
  .prose th,
  .prose td {
    padding: 8px 10px;
  }
}

/* aviso destacado (impostos, tamanhos) */
.prose .note-box {
  margin: 0 0 22px;
  padding: 4px 18px;
  border-left: 4px solid var(--warn-ink);
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.prose .guide-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
}
.prose .guide-list li {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.prose td a {
  white-space: nowrap;
}

/* ---------- data pages (price index, "em alta"): sections filled by the Worker ---------- */

.dyn h2 {
  margin-top: 34px;
}
.dyn-sub {
  font-size: 14.5px;
  color: var(--ink-soft);
}
.prose .dyn-empty {
  margin: 18px 0 8px;
  padding: 14px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
}
.dyn-more a {
  font-weight: 700;
}
.mut {
  color: var(--ink-soft);
}
.prose .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.prose .pi-table th[scope="row"] {
  background: none;
  font-weight: 600;
}
.prose .pi-table caption {
  text-align: left;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 10px 14px 0;
}
.pi-table .up {
  color: var(--price);
}
.pi-table .down {
  color: var(--ink);
  font-weight: 700;
}

/* price index chart: one row per search, log-scale positions in % (works at any width) */
.pi-chart {
  margin: 18px 0 22px;
  padding: 16px 16px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.pi-chart figcaption {
  font-weight: 700;
  margin-bottom: 6px;
}
.prose .pi-legend {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.pi-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pi-k-iqr,
.pi-k-med {
  display: inline-block;
  flex: none;
}
.pi-k-iqr {
  width: 22px;
  height: 10px;
  border-radius: 3px;
  background: var(--yellow);
  border: 1px solid var(--on-yellow);
}
.pi-k-med {
  width: 3px;
  height: 16px;
  border-radius: 1px;
  background: var(--ink);
}
.prose .pi-rows {
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 2px;
}
.pi-rows li,
.pi-axis {
  display: grid;
  grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr) 4.6em;
  gap: 0 10px;
  align-items: center;
}
.pi-name {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.pi-val {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pi-bar {
  display: block;
  overflow: visible;
}
.pi-grid {
  stroke: var(--line);
  stroke-width: 1;
}
.pi-iqr {
  fill: var(--yellow);
  stroke: var(--on-yellow);
  stroke-width: 1;
}
.pi-med {
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
}
.pi-axis svg {
  display: block;
  overflow: visible;
}
.pi-axis text {
  fill: var(--ink-soft);
  font: 11.5px var(--body);
  font-variant-numeric: tabular-nums;
}

/* "em alta": ranked term lists + item cards */
.prose .ea-terms {
  list-style: none;
  padding: 0;
  margin: 12px 0 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ea-terms a {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 10px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s;
}
.ea-terms a:hover {
  border-color: var(--ink);
}
.ea-n {
  font: 800 18px/1 var(--display);
  min-width: 1.4em;
}
.ea-q {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.ea-note {
  flex-basis: 100%;
  padding-left: calc(1.4em + 10px);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.prose .ea-items {
  list-style: none;
  padding: 0;
  margin: 14px 0 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.ea-items li {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.ea-items img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--chip);
}
/* listing image not on the marketplace CDN (worker/src/pages.ts pageImage): empty square */
.ea-noimg {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--chip);
}
.ea-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
  flex: 1;
}
.prose .ea-body h3 {
  font: 600 15px/1.35 var(--body);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.prose .ea-zh,
.prose .ea-price {
  margin: 0;
}
.ea-zh {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.ea-price b {
  color: var(--price);
  font-size: 18px;
}
.ea-brl {
  font-size: 14px;
  color: var(--ink-soft);
}
.prose a.ea-buy {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--buy);
  text-align: center;
  font-size: 14.5px;
  line-height: 1.2;
  color: var(--on-buy);
  font-weight: 700;
  text-decoration: none;
}
@media (max-width: 720px) {
  .prose .ea-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  /* phones: the name sits above its bar, so the bar gets the full width */
  .pi-rows li,
  .pi-axis {
    grid-template-columns: minmax(0, 1fr) 4.4em;
    gap: 0 8px;
  }
  .pi-rows li {
    margin-bottom: 4px;
  }
  .pi-name {
    grid-column: 1 / -1;
    font-size: 14px;
  }
  .pi-axis > span:first-child {
    display: none;
  }
  .pi-chart {
    padding: 14px 12px 8px;
  }
  .prose .ea-terms {
    grid-template-columns: 1fr;
  }
  .prose .ea-items {
    gap: 10px;
  }
  .ea-body {
    padding: 10px 10px 12px;
  }
}
@media (forced-colors: active) {
  .pi-iqr,
  .pi-med {
    stroke: CanvasText;
  }
}
