/* =============================================================
   AP DESIGN SYSTEM · TOKENS · v1.0
   Agência Pilaris · Palhoça SC
   Dark-first. OKLCH com fallback hex.
   ============================================================= */

:root {
  /* -------- Cor: Primária Laranja AP -------- */
  --ap-orange-50:  oklch(0.97 0.03 60);
  --ap-orange-100: oklch(0.93 0.06 55);
  --ap-orange-200: oklch(0.88 0.10 50);
  --ap-orange-300: oklch(0.82 0.13 47);
  --ap-orange-400: oklch(0.75 0.16 44);
  --ap-orange-500: oklch(0.68 0.17 41);   /* #FB8500 · âncora */
  --ap-orange-600: oklch(0.61 0.16 40);
  --ap-orange-700: oklch(0.55 0.16 38);
  --ap-orange-800: oklch(0.45 0.13 36);
  --ap-orange-900: oklch(0.35 0.10 34);
  --ap-orange-hex: #FB8500;

  /* -------- Cor: Secundária Terracota -------- */
  --ap-clay-100:   oklch(0.92 0.04 38);
  --ap-clay-300:   oklch(0.75 0.10 38);
  --ap-clay-500:   oklch(0.62 0.13 38);   /* #C96442 */
  --ap-clay-700:   oklch(0.48 0.11 36);
  --ap-clay-900:   oklch(0.32 0.08 34);
  --ap-clay-hex:   #C96442;

  /* -------- Cor: Acentos (uso pontual) -------- */
  --ap-gold:       oklch(0.82 0.15 85);   /* #FFB703 */
  --ap-gold-hex:   #FFB703;
  --ap-petrol:     oklch(0.45 0.08 220);
  --ap-petrol-hex: #2C5871;
  --ap-mint:       oklch(0.78 0.12 165);
  --ap-mint-hex:   #6FD7B7;
  --ap-indigo:     oklch(0.45 0.12 280);
  --ap-indigo-hex: #4A4FB5;

  /* -------- Cor: Navy institucional (legado AP) -------- */
  --ap-navy:       oklch(0.32 0.06 230);  /* #023047 */
  --ap-navy-hex:   #023047;

  /* -------- Neutros · LIGHT-FIRST · cinza NEUTRO (hue 0) -------- */
  --ap-bg:            #FFFFFF;
  --ap-surface:       #FAFAFA;
  --ap-surface-2:     #F2F2F2;
  --ap-border:        oklch(0 0 0 / 0.08);
  --ap-border-strong: oklch(0 0 0 / 0.16);
  --ap-text:          #0A0A0A;
  --ap-text-muted:    #5A5A5A;

  /* -------- Semânticas · iOS system -------- */
  --ok:    #34C759;
  --info:  #007AFF;
  --warn:  #FF9500;
  --attn:  #FFCC00;
  --error: #FF3B30;

  /* -------- Tipografia -------- */
  --font-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* -------- Escala tipográfica (px) -------- */
  --t-display: 72px;
  --t-h1: 56px;
  --t-h2: 40px;
  --t-h3: 28px;
  --t-h4: 22px;
  --t-body: 16px;
  --t-small: 14px;
  --t-mono: 13px;

  /* -------- Espaçamento -------- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* -------- Raio -------- */
  --r-0: 0;
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-pill: 9999px;

  /* -------- Sombra · sutil sempre -------- */
  --shadow-1: 0 1px 0 0 var(--ap-border);
  --shadow-2: 0 4px 12px -4px oklch(0 0 0 / 0.08);
  --shadow-3: 0 8px 16px -8px oklch(0 0 0 / 0.12);

  /* -------- Movimento -------- */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in:  cubic-bezier(0.4, 0, 1, 1);
  --d-micro: 150ms;
  --d-ui: 250ms;
  --d-page: 400ms;

  /* -------- Layout -------- */
  --sidebar-w: 240px;
  --content-max: 960px;
}

/* -------- Tema dark · cinza NEUTRO, nunca warm -------- */
[data-theme="dark"] {
  --ap-bg:            #0A0A0A;
  --ap-surface:       #161616;
  --ap-surface-2:     #1F1F1F;
  --ap-border:        oklch(1 0 0 / 0.08);
  --ap-border-strong: oklch(1 0 0 / 0.16);
  --ap-text:          #F5F5F5;
  --ap-text-muted:    #A3A3A3;
}

/* =============================================================
   Reset opinativo + base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ap-bg);
  color: var(--ap-text);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.6;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* Scrollbar discreta */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ap-border-strong);
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--ap-text-muted); }

/* =============================================================
   Utilitários da marca (não-Tailwind)
   ============================================================= */
.serif { font-family: var(--font-serif); font-style: italic; font-weight: 400; }
.serif-roman { font-family: var(--font-serif); font-style: normal; }
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--t-mono);
  color: var(--ap-text-muted);
}
.hairline { border-color: var(--ap-border); }

/* =============================================================
   Layout do handbook (sidebar + conteúdo)
   ============================================================= */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--ap-border);
  padding: var(--s-6) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  background: var(--ap-bg);
  z-index: 10;
}
.sidebar-brand .mark {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 56px;
  line-height: 1;
  color: var(--ap-text);
}
.sidebar-brand .mark .accent { color: var(--ap-orange-500); }
.sidebar-brand .label {
  margin-top: var(--s-2);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--ap-text-muted);
}
.sidebar-section-title {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--ap-text-muted);
  margin-bottom: var(--s-3);
}
.chapter-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.chapter-list a {
  display: flex;
  gap: var(--s-3);
  align-items: baseline;
  padding: var(--s-2) var(--s-3);
  border-left: 3px solid transparent;
  font-size: 14px;
  color: var(--ap-text-muted);
  transition: color var(--d-micro) var(--ease-out), border-color var(--d-micro) var(--ease-out), background var(--d-micro) var(--ease-out);
}
.chapter-list a:hover { color: var(--ap-text); }
.chapter-list a .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ap-text-muted);
}
.chapter-list a.active {
  color: var(--ap-text);
  border-left-color: var(--ap-orange-500);
  background: var(--ap-surface);
}
.chapter-list a.active .num { color: var(--ap-orange-500); }

.sidebar-meta { font-family: var(--font-mono); font-size: 12px; color: var(--ap-text-muted); line-height: 1.5; }
.sidebar-meta .key { display: block; text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px; opacity: 0.7; margin-bottom: 4px; }
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--ap-orange-500);
  color: #0A0A0A;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 600;
  padding: 10px 14px;
  border: none;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: background var(--d-micro) var(--ease-out), transform var(--d-micro) var(--ease-out);
}
.btn-export:hover { background: var(--ap-orange-400); transform: translateY(-1px); }
.btn-export:active { transform: translateY(0); }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--ap-border);
  color: var(--ap-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: color var(--d-micro), border-color var(--d-micro);
}
.theme-toggle:hover { color: var(--ap-text); border-color: var(--ap-border-strong); }

/* Conteúdo */
.content {
  padding: var(--s-9) var(--s-7);
  max-width: calc(var(--content-max) + var(--s-7) * 2);
  margin: 0 auto;
  width: 100%;
}
.chapter { padding-bottom: var(--s-9); border-bottom: 1px solid var(--ap-border); margin-bottom: var(--s-9); }
.chapter:last-child { border-bottom: 0; }
.chapter-hero { display: flex; align-items: baseline; gap: var(--s-5); margin-bottom: var(--s-7); }
.chapter-hero .num {
  font-family: var(--font-mono);
  font-size: 28px;
  color: var(--ap-text-muted);
  font-weight: 400;
}
.chapter-hero .title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: var(--t-display);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ap-text);
}
.chapter-hero .title em { font-style: italic; color: var(--ap-orange-500); }

h2.section-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-h2);
  font-weight: 400;
  margin: var(--s-7) 0 var(--s-4);
  letter-spacing: -0.02em;
}
h3.subsection {
  font-family: var(--font-sans);
  font-size: var(--t-h4);
  font-weight: 600;
  margin: var(--s-5) 0 var(--s-3);
}

p.lead {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ap-text-muted);
  max-width: 64ch;
}
p { max-width: 70ch; color: var(--ap-text-muted); }
p.body-strong { color: var(--ap-text); }

/* =============================================================
   Componentes do brandbook
   ============================================================= */

/* Card básico */
.card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-3);
  padding: var(--s-5);
}
.card-elev { background: var(--ap-surface-2); }

/* Swatch de cor */
.swatch {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.swatch .chip { aspect-ratio: 4/3; width: 100%; }
.swatch .meta { padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: 2px; }
.swatch .meta .name { font-family: var(--font-sans); font-weight: 600; font-size: 13px; color: var(--ap-text); }
.swatch .meta .val { font-family: var(--font-mono); font-size: 11px; color: var(--ap-text-muted); }
.swatch .meta .contrast {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
  color: var(--ap-text-muted);
}

.scale-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  margin-top: var(--s-3);
  border-radius: var(--r-2);
  overflow: hidden;
}
.scale-row .step {
  aspect-ratio: 1/2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: oklch(0 0 0 / 0.7);
}
.scale-row .step.dark-text { color: oklch(1 0 0 / 0.85); }

/* Botão */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: background var(--d-micro) var(--ease-out), transform var(--d-micro) var(--ease-out), border-color var(--d-micro) var(--ease-out);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--ap-orange-500);
  color: #0A0A0A;
}
.btn-primary:hover { background: var(--ap-orange-400); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: transparent;
  border-color: var(--ap-border-strong);
  color: var(--ap-text);
}
.btn-secondary:hover { border-color: var(--ap-orange-500); color: var(--ap-orange-500); }
.btn-link {
  background: transparent;
  color: var(--ap-orange-500);
  padding: 10px 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
}
.btn-link:hover { border-bottom-color: var(--ap-orange-500); }

/* Card de métrica */
.metric {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-3);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.metric .num {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 600;
  color: var(--ap-text);
  line-height: 1;
  letter-spacing: -0.02em;
}
.metric .num.accent { color: var(--ap-orange-500); }
.metric .label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--ap-text-muted);
}
.metric .delta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ok);
}
.metric .delta.down { color: var(--error); }

/* Callout */
.callout {
  background: var(--ap-surface-2);
  border-left: 4px solid var(--ap-orange-500);
  padding: var(--s-4) var(--s-5);
  border-radius: 0 var(--r-2) var(--r-2) 0;
  margin: var(--s-5) 0;
}
.callout .label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--ap-orange-500);
  margin-bottom: 6px;
}
.callout p { color: var(--ap-text); margin: 0; }

/* Tag */
.tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--ap-border-strong);
  color: var(--ap-text-muted);
}
.tag.primary { color: var(--ap-orange-500); border-color: var(--ap-orange-500); }
.tag.solid { background: var(--ap-orange-500); color: #0A0A0A; border-color: transparent; }

/* Tabela */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--ap-border);
  vertical-align: top;
}
.table th {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 500;
  color: var(--ap-text-muted);
}
.table td { color: var(--ap-text); }

/* Grid utilitários */
.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
}

/* Espaçamento visual demo */
.space-demo { display: flex; align-items: flex-end; gap: var(--s-3); padding: var(--s-4); background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: var(--r-3); }
.space-demo .block { background: var(--ap-orange-500); border-radius: 2px; }
.space-demo .block-cap { font-family: var(--font-mono); font-size: 10px; color: var(--ap-text-muted); margin-top: 6px; text-align: center; }

.radius-demo { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s-3); }
.radius-demo .r {
  aspect-ratio: 1;
  background: var(--ap-surface-2);
  border: 1px solid var(--ap-border);
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ap-text-muted);
}

/* Movimento demo */
.motion-demo {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-3);
  padding: var(--s-5);
  display: flex;
  align-items: center;
  gap: var(--s-5);
}
.motion-demo .dot {
  width: 14px; height: 14px;
  border-radius: var(--r-pill);
  background: var(--ap-orange-500);
  animation: pulse 2.4s var(--ease-out) infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.5; }
}

/* Logo lockup */
.lockup {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-3);
  padding: var(--s-7) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}
.lockup.on-dark { background: #0A0A0A; color: #FFFFFF; }
.lockup img { max-height: 96px; max-width: 90%; width: auto; height: auto; }
.lockup.lockup-tall { min-height: 220px; }
.lockup.lockup-tall img { max-height: 130px; }
.lockup-meta {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--ap-text-muted);
  margin-top: var(--s-3);
  padding: 0 4px;
}
.logo-block { display: flex; flex-direction: column; }

/* Princípios */
.principle {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: var(--s-5);
  padding: var(--s-5) 0;
  border-bottom: 1px solid var(--ap-border);
}
.principle:last-child { border-bottom: 0; }
.principle .num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ap-orange-500);
  padding-top: 6px;
}
.principle .q {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: var(--s-2);
  color: var(--ap-text);
}
.principle .a {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ap-text-muted);
  letter-spacing: 0.02em;
}

/* Do/Don't */
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.dodont .col {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-3);
  padding: var(--s-5);
}
.dodont .col h4 {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  margin: 0 0 var(--s-3);
}
.dodont .col.do h4 { color: var(--ok); }
.dodont .col.dont h4 { color: var(--error); }
.dodont ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.dodont li {
  font-size: 14px;
  color: var(--ap-text);
  padding-left: var(--s-4);
  position: relative;
}
.dodont .col.do li::before { content: '+'; position: absolute; left: 0; color: var(--ok); font-family: var(--font-mono); }
.dodont .col.dont li::before { content: '–'; position: absolute; left: 0; color: var(--error); font-family: var(--font-mono); }

/* Cover (index.html) */
.cover {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--s-7);
  position: relative;
}
.cover-header { display: flex; justify-content: space-between; align-items: center; }
.cover-header .brand-mark { font-family: var(--font-serif); font-style: italic; font-size: 32px; }
.cover-header .meta { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; color: var(--ap-text-muted); }
.cover-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.cover-main .eyebrow { margin-bottom: var(--s-5); }
.cover-main .title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(64px, 12vw, 180px);
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.cover-main .title em { color: var(--ap-orange-500); font-style: italic; }
.cover-main .sub {
  margin-top: var(--s-7);
  max-width: 720px;
  font-size: 22px;
  line-height: 1.5;
  color: var(--ap-text-muted);
}
.cover-footer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-5);
  border-top: 1px solid var(--ap-border);
  padding-top: var(--s-5);
}
.cover-footer .item { font-family: var(--font-mono); font-size: 12px; color: var(--ap-text-muted); }
.cover-footer .item .k { display: block; text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px; margin-bottom: 6px; opacity: 0.7; }
.cover-footer .item .v { color: var(--ap-text); }
.cover-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-7);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--ap-orange-500);
  border-bottom: 1px solid var(--ap-orange-500);
  padding-bottom: 4px;
  width: fit-content;
}

/* =============================================================
   PRINT
   ============================================================= */
@media print {
  :root, [data-theme="dark"] {
    --ap-bg: #FFFFFF;
    --ap-surface: #FAFAFA;
    --ap-surface-2: #F2F2F2;
    --ap-text: #0A0A0A;
    --ap-text-muted: #5A5A5A;
    --ap-border: rgba(0,0,0,0.12);
  }
  body { background: #FFFFFF; color: #0A0A0A; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sidebar, .btn-export, .theme-toggle { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 24px; max-width: 100%; }
  .chapter { page-break-before: always; border-bottom: 0; }
  .chapter:first-child { page-break-before: auto; }
  a { color: #0A0A0A; }
}
