/* Estudos — interface moderna (layout + documentação) */
:root {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-ring: rgba(79, 70, 229, 0.35);
  --doc-topbar-h: 3.5rem;
  --sidebar-w: 272px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07),
    0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08),
    0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-card-hover: 0 12px 24px -8px rgba(79, 70, 229, 0.18);
  --transition: 0.18s ease;
  /* compat legado */
  --radius: var(--radius-md);
  --shadow: var(--shadow-md);
}

[data-theme="dark"] {
  --bg: #0c0e14;
  --bg-elevated: #12151e;
  --surface: #141824;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #2d3548;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.12);
  --accent-ring: rgba(129, 140, 248, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.45);
  --shadow-card-hover: 0 12px 28px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(
      ellipse 120% 80% at 50% -30%,
      rgba(79, 70, 229, 0.09),
      transparent 55%
    ),
    radial-gradient(
      ellipse 80% 50% at 100% 0%,
      rgba(14, 165, 233, 0.05),
      transparent 45%
    );
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
  background-image: radial-gradient(
      ellipse 100% 60% at 50% -20%,
      rgba(79, 70, 229, 0.12),
      transparent 50%
    ),
    radial-gradient(
      ellipse 60% 40% at 100% 0%,
      rgba(56, 189, 248, 0.06),
      transparent 40%
    );
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Shell injetado pelo layout.js */
.doc-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.doc-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.35rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: var(--shadow-sm);
}

@supports not (backdrop-filter: blur(1px)) {
  .doc-topbar {
    background: var(--surface);
  }
}

.doc-topbar__brand {
  margin-right: auto;
  font-weight: 650;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.doc-topbar__brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.doc-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-body {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: flex-start;
}

.doc-sidebar {
  position: sticky;
  top: var(--doc-topbar-h);
  align-self: flex-start;
  width: var(--sidebar-w);
  flex-shrink: 0;
  max-height: calc(100vh - var(--doc-topbar-h));
  padding: 1.1rem 0 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.03);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

[data-theme="dark"] .doc-sidebar {
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.25);
}

.doc-sidebar__title {
  padding: 0 1rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.doc-nav a {
  display: block;
  margin: 0 0.5rem;
  padding: 0.45rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.doc-nav a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.doc-nav a.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
  color: var(--text);
}

.doc-nav details {
  margin-bottom: 0.2rem;
}

.doc-nav summary {
  margin: 0 0.5rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  list-style: none;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.doc-nav summary:hover {
  background: var(--accent-soft);
}

.doc-nav summary::-webkit-details-marker {
  display: none;
}

.doc-nav details[open] > summary {
  color: var(--accent);
}

.doc-nav .doc-nav__sub {
  padding-left: 0.35rem;
}

.doc-nav .doc-nav__sub a {
  padding-left: 1.15rem;
  font-size: 0.84rem;
  font-weight: 450;
}

.doc-main {
  flex: 1;
  min-width: 0;
  padding: 2.25rem 2.75rem 4rem;
  max-width: 780px;
}

.doc-main h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.65rem, 4vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.2;
  color: var(--text);
}

.doc-main .lead {
  margin: 0 0 1.75rem;
  font-size: 1.07rem;
  line-height: 1.6;
  color: var(--muted);
  max-width: 52ch;
}

.doc-main h2 {
  position: relative;
  margin: 2.25rem 0 0.85rem;
  font-size: 1.22rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  padding-bottom: 0.5rem;
  border-bottom: none;
}

.doc-main h2::after {
  content: "";
  display: block;
  margin-top: 0.5rem;
  width: 2.75rem;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.85;
}

.doc-main h3 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.doc-main p {
  margin: 0 0 1rem;
}

.doc-main ul,
.doc-main ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
}

.doc-main li {
  margin-bottom: 0.4rem;
}

.doc-card-list {
  display: grid;
  gap: 0.85rem;
  margin: 1.15rem 0 0;
  padding: 0;
  list-style: none;
}

.doc-card-list a {
  display: block;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), border-color var(--transition),
    box-shadow var(--transition);
}

.doc-card-list a:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  text-decoration: none;
}

.doc-card-list a:active {
  transform: translateY(0);
}

.doc-card-list a small {
  display: block;
  margin-top: 0.35rem;
  font-weight: 450;
  font-size: 0.86rem;
  letter-spacing: 0;
  color: var(--muted);
  line-height: 1.45;
}

.doc-empty {
  padding: 1.35rem 1.25rem;
  border: 1px dashed color-mix(in srgb, var(--muted) 35%, var(--border));
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.95rem;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft));
}

pre,
code {
  font-family: var(--mono);
  font-size: 0.9em;
}

pre {
  margin: 1rem 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  transition: background var(--transition), border-color var(--transition),
    transform 0.1s ease;
}

.btn-icon:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}

.btn-icon:active {
  transform: scale(0.96);
}

.btn-menu {
  display: none;
}

@media (max-width: 900px) {
  .doc-body {
    align-items: stretch;
  }

  .doc-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    width: min(var(--sidebar-w), 88vw);
    max-height: none;
    align-self: stretch;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
  }

  .doc-sidebar.is-open {
    transform: translateX(0);
  }

  .doc-main {
    padding: 1.35rem 1.25rem 3rem;
  }

  .btn-menu {
    display: inline-flex;
  }

  .doc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
  }

  .doc-overlay.is-visible {
    display: block;
  }
}

/* Rodapé global */
.doc-footer {
  flex-shrink: 0;
  padding: 1.1rem 1.35rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 95%, var(--bg));
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.doc-footer p {
  margin: 0;
}

.doc-footer a {
  color: var(--muted);
  font-weight: 600;
}

.doc-footer a:hover {
  color: var(--accent);
}
