/* ambiencemed.com — global stylesheet
   Tokens + reset + componentes. Mobile-first. Sem JS, sem webfonts. */

/* Reset minimal */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

/* Tokens — light */
:root {
  --color-bg: #FFFFFF;
  --color-bg-subtle: #FAFAF9;
  --color-border: #E7E5E4;
  --color-border-strong: #D6D3D1;
  --color-text-muted: #57534E;
  --color-text: #1C1917;
  --color-text-strong: #0C0A09;
  --color-accent: #1E3A8A;
  --color-accent-hover: #1E40AF;
  --color-accent-bg: #EEF2FF;
  --color-warn-bg: #FEF7E6;
  --color-warn-border: #E5B73B;
  --color-warn-text: #6B4E08;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo,
               Consolas, "Liberation Mono", monospace;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-h4: 1.25rem;
  --fs-h3: 1.5rem;
  --fs-h2: 1.875rem;
  --fs-h1: 1.875rem;

  --lh-tight: 1.25;
  --lh-snug: 1.4;
  --lh-body: 1.65;

  --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;

  --radius-sm: 4px;
  --radius-md: 6px;
}

@media (min-width: 768px) {
  :root { --fs-h1: 2.25rem; }
}

/* Tokens — dark */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0C0A09;
    --color-bg-subtle: #161513;
    --color-border: #292524;
    --color-border-strong: #3F3B38;
    --color-text-muted: #A8A29E;
    --color-text: #E7E5E4;
    --color-text-strong: #FAFAF9;
    --color-accent: #93C5FD;
    --color-accent-hover: #BFDBFE;
    --color-accent-bg: #1E2A4A;
    --color-warn-bg: #2A1F0A;
    --color-warn-border: #B8902C;
    --color-warn-text: #F5D78A;
  }
}

/* Base */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -10000px;
  top: 0;
  background: var(--color-accent);
  color: #fff;
  padding: var(--s-3) var(--s-4);
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* Container */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--s-4);
}
@media (min-width: 768px) {
  .container { padding: 0 var(--s-6); }
}
@media (min-width: 1024px) {
  .container { padding: 0 var(--s-8); }
}

.content { max-width: 720px; margin: 0 auto; }
.content--wide { max-width: 760px; }
.content--legal { font-size: var(--fs-lg); }
.content--legal p, .content--legal li { font-size: var(--fs-lg); }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  z-index: 50;
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) 0;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.site-logo {
  font-weight: 600;
  font-size: var(--fs-lg);
  color: var(--color-text-strong);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-nav {
  display: flex;
  gap: var(--s-1);
  flex-wrap: wrap;
}
.site-nav a {
  padding: var(--s-2) var(--s-3);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}
.site-nav a:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.site-nav a[aria-current="page"] {
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Main */
main { padding: var(--s-7) 0 var(--s-9); }

/* Typography */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text-strong);
  line-height: var(--lh-tight);
}
h1 { font-size: var(--fs-h1); margin-bottom: var(--s-2); }
h2 {
  font-size: var(--fs-h2);
  margin-top: var(--s-8);
  margin-bottom: var(--s-4);
  scroll-margin-top: 80px;
}
h3 { font-size: var(--fs-h3); margin-top: var(--s-6); margin-bottom: var(--s-3); }
h4 { font-size: var(--fs-h4); margin-top: var(--s-5); margin-bottom: var(--s-2); }

p { margin-bottom: var(--s-4); }
.lead { font-size: var(--fs-lg); color: var(--color-text); }
.meta { font-size: var(--fs-sm); color: var(--color-text-muted); margin-bottom: var(--s-5); }

/* Links */
a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; color: var(--color-accent-hover); }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Lists */
ul, ol { padding-left: var(--s-5); margin-bottom: var(--s-4); }
li { margin-bottom: var(--s-2); }
ol > li::marker { font-weight: 600; }

.list-nay { list-style: none; padding-left: 0; }
.list-nay li { padding-left: var(--s-4); position: relative; }
.list-nay li::before {
  content: "×";
  position: absolute;
  left: 0;
  color: var(--color-text-muted);
  font-weight: 600;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--s-4) 0;
  font-size: var(--fs-base);
}
caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: var(--s-2);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}
thead { background: var(--color-bg-subtle); }
th, td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
th {
  font-weight: 600;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

/* Mobile tables → cards */
@media (max-width: 640px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--s-3);
    padding: var(--s-3);
  }
  td { border: none; padding: var(--s-2) 0; }
  td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: var(--s-1);
  }
}

/* Callouts */
.callout {
  padding: var(--s-4);
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  margin: var(--s-5) 0;
}
.callout--info {
  background: var(--color-accent-bg);
  border-left-color: var(--color-accent);
}
.callout--warn {
  background: var(--color-warn-bg);
  border-left-color: var(--color-warn-border);
  color: var(--color-warn-text);
}
.callout > strong { display: inline-block; margin-right: var(--s-2); }

/* TL;DR */
.tldr {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--s-4) var(--s-5);
  margin: var(--s-4) 0 var(--s-6);
}
.tldr-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: var(--s-3);
}
.tldr ul { margin: 0; padding-left: var(--s-5); }
.tldr li { font-size: var(--fs-base); }
.tldr .disclaimer {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  font-style: italic;
  margin: var(--s-3) 0 0;
}

/* TOC */
.toc {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--s-3) var(--s-4);
  margin: var(--s-5) 0 var(--s-6);
}
.toc summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 120ms ease;
}
.toc[open] summary::before { content: "▾ "; }
.toc ul { list-style: none; padding-left: 0; margin: var(--s-3) 0 0; }
.toc li { margin-bottom: var(--s-2); font-size: var(--fs-sm); }
.toc a { color: var(--color-text); text-decoration: none; }
.toc a:hover { color: var(--color-accent); text-decoration: underline; }

/* TOC sticky lateral em desktop ≥1024px */
@media (min-width: 1024px) {
  .layout-with-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: var(--s-7);
    max-width: 1040px;
    margin: 0 auto;
  }
  .layout-with-toc .content { max-width: 720px; }
  .layout-with-toc .toc {
    position: sticky;
    top: 80px;
    align-self: start;
    margin: 0;
    background: transparent;
    border: none;
    border-left: 1px solid var(--color-border);
    border-radius: 0;
    padding: 0 0 0 var(--s-4);
  }
  .layout-with-toc .toc summary {
    pointer-events: none;
  }
  .layout-with-toc .toc summary::before { display: none; }
  .layout-with-toc .toc > ul { display: block !important; margin-top: var(--s-3); }
  .layout-with-toc details:not([open]) > ul { display: block !important; }
}

/* Heading anchor */
.anchor {
  margin-left: var(--s-2);
  color: var(--color-text-muted);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
  transition: opacity 120ms ease;
}
h2:hover .anchor, h3:hover .anchor,
.anchor:focus-visible { opacity: 1; }

/* Cards "Você é quem?" */
.cards { display: grid; gap: var(--s-3); margin: var(--s-5) 0; }
.cards > article {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--s-4) var(--s-5);
}
.cards h3 { margin-top: 0; font-size: var(--fs-h4); }
.cards p:last-child { margin-bottom: 0; }

/* Atalhos */
.shortcuts {
  margin-top: var(--s-8);
  padding-top: var(--s-5);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
.shortcuts strong { color: var(--color-text); margin-right: var(--s-2); }
.shortcuts a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: var(--s-9);
  padding: var(--s-7) 0;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
}
.site-footer-inner {
  display: grid;
  gap: var(--s-6);
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .site-footer-inner { grid-template-columns: 2fr 1fr 1fr; }
}
.site-footer h3 {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text);
  margin: 0 0 var(--s-3);
}
.site-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}
.site-footer address { font-style: normal; line-height: var(--lh-snug); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: var(--s-2); }
.site-footer-copy {
  margin-top: var(--s-4);
  font-size: var(--fs-xs);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
