/* =========================================================
   Frateschi — main.css
   Design tokens, reset, tipografia, layout primitives, utils.
   ========================================================= */

/* ──────────────── Tokens ──────────────── */
:root {
  /* Cores — extraídas do logo oficial Frateschi (SVG) */
  --fr-blue:        #003352;
  --fr-blue-dark:   #001E33;
  --fr-blue-light:  #1F5B85;
  --fr-blue-tint:   #E6EEF4;

  --fr-orange:      #C25E03;
  --fr-orange-dark: #944600;
  --fr-orange-light:#E5821F;
  --fr-orange-tint: #FCEFE0;

  --fr-text:        #1A1A1A;
  --fr-text-muted:  #5C5C5C;
  --fr-text-light:  #8A8A8A;

  --fr-bg:          #FFFFFF;
  --fr-bg-alt:      #F7F5F0;     /* off-white quente, levemente envelhecido */
  --fr-bg-deep:     #1A1A1A;

  --fr-border:      #E5E1DA;
  --fr-border-strong: #C9C2B5;
  --fr-success:     #2E7D32;
  --fr-danger:      #C53030;

  /* Tipografia */
  --fr-font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fr-font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;

  --fr-text-base: 16px;
  --fr-line-base: 1.65;

  /* Espaçamento (escala T-shirt) */
  --fr-space-2xs: .25rem;
  --fr-space-xs:  .5rem;
  --fr-space-sm:  .75rem;
  --fr-space-md:  1rem;
  --fr-space-lg:  1.5rem;
  --fr-space-xl:  2rem;
  --fr-space-2xl: 3rem;
  --fr-space-3xl: 5rem;

  /* Layout */
  --fr-max-w:     1200px;
  --fr-max-w-narrow: 760px;
  --fr-gutter:    clamp(1rem, 4vw, 2rem);

  /* Bordas e sombras */
  --fr-radius-sm: 4px;
  --fr-radius-md: 8px;
  --fr-radius-lg: 16px;
  --fr-shadow-sm: 0 1px 2px rgba(0, 51, 82, .06), 0 1px 3px rgba(0, 51, 82, .08);
  --fr-shadow-md: 0 4px 12px rgba(0, 51, 82, .08), 0 2px 4px rgba(0, 51, 82, .06);
  --fr-shadow-lg: 0 12px 32px rgba(0, 51, 82, .12), 0 4px 12px rgba(0, 51, 82, .08);

  /* Transições */
  --fr-ease: cubic-bezier(.4, 0, .2, 1);
  --fr-dur-fast: 150ms;
  --fr-dur-base: 250ms;

  /* Header */
  --fr-header-h: 72px;
}

/* ──────────────── Reset essencial ──────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: var(--fr-text-base);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--fr-font-body);
  font-size: 1rem;
  line-height: var(--fr-line-base);
  color: var(--fr-text);
  background: var(--fr-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--fr-blue);
  text-decoration: none;
  transition: color var(--fr-dur-fast) var(--fr-ease);
}
a:hover { color: var(--fr-orange); }
a:focus-visible { outline: 2px solid var(--fr-orange); outline-offset: 2px; border-radius: 2px; }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}
button:focus-visible { outline: 2px solid var(--fr-orange); outline-offset: 2px; }

/* ──────────────── Tipografia ──────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--fr-font-body);
  font-weight: 700;
  color: var(--fr-blue);
  line-height: 1.2;
  margin: 0 0 var(--fr-space-md);
}

h1 { font-size: clamp(1.875rem, 4vw + 1rem, 3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 2vw + .75rem, 2.25rem); letter-spacing: -.015em; }
h3 { font-size: clamp(1.25rem, 1vw + .75rem, 1.625rem); }
h4 { font-size: 1.125rem; font-family: var(--fr-font-body); font-weight: 600; }

p { margin: 0 0 var(--fr-space-md); }

.eyebrow {
  font-family: var(--fr-font-body);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fr-orange);
  margin: 0 0 var(--fr-space-xs);
  display: inline-block;
}

.lead {
  font-size: 1.125rem;
  color: var(--fr-text-muted);
  line-height: 1.6;
  max-width: 60ch;
}

/* ──────────────── Layout primitives ──────────────── */
.container {
  width: 100%;
  max-width: var(--fr-max-w);
  margin-inline: auto;
  padding-inline: var(--fr-gutter);
}
.container--narrow { max-width: var(--fr-max-w-narrow); }

.section { padding-block: clamp(var(--fr-space-xl), 6vw, var(--fr-space-3xl)); }
.section--tight { padding-block: var(--fr-space-xl); }
.section--alt { background: var(--fr-bg-alt); }
.section--dark { background: var(--fr-bg-deep); color: #fff; }
.section--dark h1, .section--dark h2, .section--dark h3 { color: #fff; }

/* Grid genérico */
.grid {
  display: grid;
  gap: var(--fr-space-lg);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.grid--cards { gap: var(--fr-space-xl); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid--4 { grid-template-columns: 1fr; } }

/* Skip link (acessibilidade) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  padding: var(--fr-space-sm) var(--fr-space-md);
  background: var(--fr-orange);
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 var(--fr-radius-md) 0;
  z-index: 100;
}
.skip-link:focus { top: 0; color: #fff; }

/* ──────────────── Botões ──────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--fr-space-xs);
  padding: .75rem 1.5rem;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.2;
  border-radius: var(--fr-radius-md);
  border: 1px solid transparent;
  transition: background var(--fr-dur-fast) var(--fr-ease),
              border-color var(--fr-dur-fast) var(--fr-ease),
              color var(--fr-dur-fast) var(--fr-ease),
              transform var(--fr-dur-fast) var(--fr-ease);
  text-decoration: none;
  cursor: pointer;
  min-height: 44px; /* touch target */
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--fr-blue);
  color: #fff;
  border-color: var(--fr-blue);
}
.btn--primary:hover { background: var(--fr-blue-light); color: #fff; border-color: var(--fr-blue-light); }

.btn--accent {
  background: var(--fr-orange);
  color: #fff;
  border-color: var(--fr-orange);
}
.btn--accent:hover { background: var(--fr-orange-dark); color: #fff; }

.btn--ghost {
  background: transparent;
  color: var(--fr-blue);
  border-color: var(--fr-blue);
}
.btn--ghost:hover { background: var(--fr-blue); color: #fff; }

.btn--large { padding: 1rem 2rem; font-size: 1.0625rem; }
.btn--block { display: flex; width: 100%; }

/* ──────────────── Card base (model, post) ──────────────── */
.card {
  display: flex;
  flex-direction: column;
  background: var(--fr-bg);
  border: 1px solid var(--fr-border);
  border-radius: var(--fr-radius-md);
  overflow: hidden;
  transition: box-shadow var(--fr-dur-base) var(--fr-ease),
              transform var(--fr-dur-base) var(--fr-ease);
  height: 100%;
  position: relative;
}
.card:hover { box-shadow: var(--fr-shadow-md); transform: translateY(-2px); }
.card a.card__link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.card__media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--fr-bg-alt);
}
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms var(--fr-ease);
}
.card:hover .card__media img { transform: scale(1.04); }

/* Card de modelo (locomotivas, vagões, carros) — imagem landscape sem crop */
.card--model .card__media {
  aspect-ratio: 16 / 7;
  background: #fff;
}
.card--model .card__media img {
  object-fit: contain;
  padding: var(--fr-space-sm);
}
.card--model .card__body { text-align: center; align-items: center; }

.card__body { padding: var(--fr-space-lg); display: flex; flex-direction: column; gap: var(--fr-space-xs); flex: 1; }
.card__title { font-family: var(--fr-font-body); font-size: 1.25rem; color: var(--fr-blue); margin: 0; }
.card__meta { font-size: .8125rem; color: var(--fr-text-light); }
.card__excerpt { font-size: .95rem; color: var(--fr-text-muted); margin: 0; }
.card__tag { display: inline-block; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--fr-orange); }

/* ──────────────── Hero pattern ──────────────── */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--fr-blue), var(--fr-blue-light));
  color: #fff;
  padding-block: clamp(var(--fr-space-2xl), 8vw, var(--fr-space-3xl));
  overflow: hidden;
}
.hero h1 { color: #fff; }
.hero .lead { color: rgba(255, 255, 255, .92); }
.hero .eyebrow { color: var(--fr-orange-light); }
.hero--with-image { padding-block: clamp(var(--fr-space-3xl), 12vw, 8rem); }
.hero__bg {
  position: absolute; inset: 0;
  object-fit: cover; width: 100%; height: 100%;
  z-index: 0;
}
.hero__bg + .hero__overlay {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,51,82,.85), rgba(0,51,82,.55));
  z-index: 1;
}
.hero--with-image .hero__inner { position: relative; z-index: 2; color: #fff; }
.hero--with-image .hero__inner h1 { color: #fff; }
.hero--with-image .lead { color: rgba(255,255,255,.92); }

/* ──────────────── Tabela de especificações ──────────────── */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.spec-table th,
.spec-table td {
  text-align: left;
  padding: var(--fr-space-sm) var(--fr-space-md);
  border-bottom: 1px solid var(--fr-border);
  vertical-align: top;
}
.spec-table th {
  font-weight: 600;
  color: var(--fr-text-muted);
  background: var(--fr-bg-alt);
  width: 38%;
}

/* ──────────────── Breadcrumb ──────────────── */
.breadcrumb {
  font-size: .875rem;
  color: var(--fr-text-muted);
  margin-bottom: var(--fr-space-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--fr-space-2xs) var(--fr-space-xs);
}
.breadcrumb__sep { color: var(--fr-text-light); }
.breadcrumb a { color: var(--fr-text-muted); }
.breadcrumb a:hover { color: var(--fr-orange); }
.breadcrumb [aria-current="page"] { color: var(--fr-blue); font-weight: 500; }

/* ──────────────── Flash messages ──────────────── */
.flash {
  padding: var(--fr-space-md);
  border-radius: var(--fr-radius-md);
  margin-bottom: var(--fr-space-md);
  border-left: 4px solid;
}
.flash--success { background: #E8F5E9; border-color: var(--fr-success); color: #1B5E20; }
.flash--error   { background: #FFEBEE; border-color: var(--fr-danger); color: #B71C1C; }
.flash--info    { background: var(--fr-blue-tint); border-color: var(--fr-blue); color: var(--fr-blue-dark); }

/* ──────────────── Form controls ──────────────── */
.field { display: flex; flex-direction: column; gap: var(--fr-space-2xs); margin-bottom: var(--fr-space-md); }
.field > label { font-weight: 600; font-size: .875rem; color: var(--fr-text); }
.field > input,
.field > textarea,
.field > select {
  font: inherit;
  padding: .65rem .85rem;
  border: 1px solid var(--fr-border-strong);
  border-radius: var(--fr-radius-md);
  background: var(--fr-bg);
  transition: border-color var(--fr-dur-fast) var(--fr-ease),
              box-shadow var(--fr-dur-fast) var(--fr-ease);
  width: 100%;
  min-height: 44px;
}
.field > input:focus,
.field > textarea:focus,
.field > select:focus {
  outline: none;
  border-color: var(--fr-blue);
  box-shadow: 0 0 0 3px rgba(0, 51, 82, .12);
}
.field > textarea { min-height: 140px; resize: vertical; }
.field__help { font-size: .8125rem; color: var(--fr-text-muted); }
.field__required { color: var(--fr-orange); }

/* ──────────────── Utilities ──────────────── */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.text-center { text-align: center; }
.muted { color: var(--fr-text-muted); }
.text-orange { color: var(--fr-orange); }
.no-margin { margin: 0; }
.gap-sm { gap: var(--fr-space-sm); }
.gap-md { gap: var(--fr-space-md); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ──────────────── Reduce motion ──────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
