/* ==========================================================================
   BASE — reset, tipografia, layout estrutural e utilitários.
   Nenhum valor literal: tudo vem de tokens.css.
   ========================================================================== */

/* ---------------------------------------------------------------- Reset */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

img { height: auto; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }

p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

ul, ol { list-style: none; padding: 0; }

a { color: inherit; text-decoration: none; }

table { border-collapse: collapse; width: 100%; }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

:target { scroll-margin-top: calc(var(--header-height) + var(--space-4)); }


/* ---------------------------------------------------------------- Foco */

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Link para pular direto ao conteúdo (leitores de tela / teclado) */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: var(--color-text-on-brand);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible { transform: translateY(0); }


/* ---------------------------------------------------------------- Tipografia */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p { text-wrap: pretty; }

small { font-size: var(--text-sm); }

strong, b { font-weight: var(--weight-semibold); }

mark {
  background: var(--color-accent-soft);
  color: var(--color-text);
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-sunken);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-xs);
}


/* ---------------------------------------------------------------- Layout */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container--narrow { max-width: var(--container-narrow); }
.container--wide   { max-width: var(--container-wide); }

.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page__main {
  flex: 1;
  padding-block: var(--space-8) var(--section-gap);
}

.section { margin-block: var(--section-gap); }

.section__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.section__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.section__subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

.section__link {
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  transition: gap var(--duration-fast) var(--ease-out);
}

.section__link:hover { gap: var(--space-2); }


/* Grades reutilizáveis */

.grid { display: grid; gap: var(--grid-gap); }

.grid--products {
  grid-template-columns: repeat(var(--grid-products-mobile), minmax(0, 1fr));
}

@media (min-width: 640px) {
  .grid--products {
    grid-template-columns: repeat(var(--grid-products-tablet), minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid--products {
    grid-template-columns: repeat(var(--grid-products-desktop), minmax(0, 1fr));
  }
}

.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }

/* Layout com barra lateral (catálogo, conta) */
.layout-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 1024px) {
  .layout-sidebar { grid-template-columns: 260px 1fr; }
  .layout-sidebar--right { grid-template-columns: 1fr 340px; }
}

/* Layout do checkout: formulário + resumo fixo */
.layout-checkout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 1024px) {
  .layout-checkout { grid-template-columns: minmax(0, 1fr) 400px; }
}


/* Carrossel horizontal com rolagem por toque */
.scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(200px, 1fr);
  gap: var(--grid-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

.scroller > * { scroll-snap-align: start; }

.scroller::-webkit-scrollbar { height: 6px; }
.scroller::-webkit-scrollbar-track { background: transparent; }
.scroller::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
}

@media (min-width: 640px) {
  .scroller { grid-auto-columns: minmax(240px, 1fr); }
}


/* ---------------------------------------------------------------- Utilitários */

.stack        { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm    { gap: var(--space-2); }
.stack--lg    { gap: var(--space-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.cluster--sm    { gap: var(--space-2); }
.cluster--between { justify-content: space-between; }

.center { display: grid; place-items: center; }

.text-muted   { color: var(--color-text-muted); }
.text-subtle  { color: var(--color-text-subtle); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }

.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

.text-center { text-align: center; }
.text-right  { text-align: right; }

.uppercase {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Corta o texto em N linhas */
.clamp-1, .clamp-2, .clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

.full-width { width: 100%; }

.hidden { display: none !important; }

/* Visível apenas para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 767px)  { .hide-mobile  { display: none !important; } }
@media (min-width: 768px)  { .hide-desktop { display: none !important; } }
@media (max-width: 1023px) { .hide-tablet  { display: none !important; } }

.divider {
  height: 1px;
  background: var(--color-border);
  border: none;
  margin-block: var(--space-4);
}

/* Barra de rolagem discreta em áreas com overflow */
.scroll-y {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}


/* ---------------------------------------------------------------- Impressão */

@media print {
  .site-header,
  .site-footer,
  .topbar,
  .btn,
  .cart-drawer,
  .cookie-banner { display: none !important; }

  body { background: #fff; color: #000; }

  .page__main { padding: 0; }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: var(--text-xs);
  }
}
