/* ========================================
   Docs — Layout & Typography
   ======================================== */

@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Fraunces Fallback";
  src: local("Georgia");
  size-adjust: 112%;
  ascent-override: 95%;
  descent-override: 25%;
  line-gap-override: 0%;
}

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

:root {
  --gray-0: #fff;
  --gray-1: #f8f8f6;
  --gray-2: #ededeb;
  --gray-3: #d9d9d6;
  --gray-4: #b8b8b4;
  --gray-5: #7a7a76;
  --gray-8: #454542;
  --gray-9: #2e2e2b;
  --gray-10: #1c1c1a;
  --gray-12: #0a0a09;

  --accent: #e8613c;
  --accent-hover: #d4532e;
  --accent-light: #fdf0ec;

  --blue-light: #e8f4fd;
  --blue: #3b82f6;
  --green-light: #ecfdf3;
  --green: #10b981;
  --purple-light: #f3e8ff;
  --purple: #a855f7;
  --yellow-light: #fef9e7;
  --yellow: #eab308;
  --orange-light: #fff4ed;
  --orange: #f97316;

  --font-body: "Inter", "Inter Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: "Fraunces", "Fraunces Fallback", serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;

  --sidebar-width: 260px;
  --content-max: 780px;
  --radius-sm: 6px;
  --radius-md: 10px;

  --ease: cubic-bezier(0.25, 0, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --focus-ring: 0 0 0 2px var(--gray-0), 0 0 0 4px var(--accent);
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--gray-10);
  background: var(--gray-0);
}

::selection {
  background: var(--accent-light);
  color: var(--gray-12);
}

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

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

img { max-width: 100%; height: auto; }

/* ========================================
   Top Nav
   ======================================== */

.docs-topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-2);
  height: 3.5rem;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.docs-topnav-inner {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 1.5rem;
}

.docs-topnav-logo {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-12);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  flex-shrink: 0;
}

.docs-topnav-logo img {
  border-radius: 4px;
}

.docs-topnav-logo:hover {
  color: var(--gray-12);
}

.docs-topnav-sep {
  color: var(--gray-3);
  font-size: 1.25rem;
  font-weight: 300;
  user-select: none;
}

.docs-topnav-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-5);
}

.docs-topnav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.docs-topnav-links a {
  font-size: 0.8125rem;
  color: var(--gray-5);
  font-weight: 500;
}

.docs-topnav-links a:hover {
  color: var(--gray-12);
}

.docs-mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  position: relative;
  margin-left: auto;
}

.docs-mobile-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--gray-8);
  position: absolute;
  left: 5px;
  transition: transform 0.2s, opacity 0.2s;
}

.docs-mobile-toggle span:first-child { top: 9px; }
.docs-mobile-toggle span:last-child { top: 17px; }

.docs-mobile-toggle.active span:first-child {
  transform: rotate(45deg);
  top: 13px;
}

.docs-mobile-toggle.active span:last-child {
  transform: rotate(-45deg);
  top: 13px;
}

/* Focus styles */
.docs-sidebar-link:focus-visible,
.docs-topnav-links a:focus-visible,
.docs-topnav-logo:focus-visible,
.docs-card:focus-visible,
.docs-page-nav a:focus-visible,
.docs-mobile-toggle:focus-visible,
.docs-toc a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ========================================
   Layout
   ======================================== */

.docs-layout {
  display: flex;
  min-height: calc(100vh - 3.5rem);
}

/* ========================================
   Sidebar
   ======================================== */

.docs-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--gray-2);
  padding: 1.5rem 0;
  position: sticky;
  top: 3.5rem;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  background: var(--gray-0);
}

.docs-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0 0.75rem;
}

.docs-sidebar-section {
  margin-top: 1.25rem;
}

.docs-sidebar-section:first-child {
  margin-top: 0;
}

.docs-sidebar-heading {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-5);
  padding: 0.5rem 0.75rem 0.375rem;
}

.docs-sidebar-link {
  display: block;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--gray-8);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

.docs-sidebar-link:hover {
  background: var(--gray-1);
  color: var(--gray-12);
}

.docs-sidebar-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

/* ========================================
   Content
   ======================================== */

.docs-content {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 3rem 4rem;
}

.docs-content-inner {
  max-width: var(--content-max);
}

/* Typography */
.docs-content h1 {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--gray-12);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
}

.docs-content .docs-subtitle {
  font-size: 1.0625rem;
  color: var(--gray-5);
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

.docs-content h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-12);
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-2);
  text-wrap: balance;
}

.docs-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-12);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.docs-content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-10);
  margin-top: 1.5rem;
  margin-bottom: 0.375rem;
}

.docs-content p {
  margin-bottom: 1rem;
  color: var(--gray-8);
}

/* Underline links in body content for scannability */
.docs-content p a,
.docs-content li a {
  text-decoration: underline;
  text-decoration-color: rgba(232, 97, 60, 0.3);
  text-underline-offset: 2px;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.docs-content p a:hover,
.docs-content li a:hover {
  text-decoration-color: var(--accent);
}

.docs-content ul,
.docs-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  color: var(--gray-8);
}

.docs-content li {
  margin-bottom: 0.375rem;
}

.docs-content li ul,
.docs-content li ol {
  margin-top: 0.375rem;
  margin-bottom: 0.375rem;
}

.docs-content strong {
  font-weight: 600;
  color: var(--gray-10);
}

.docs-content hr {
  border: none;
  border-top: 1px solid var(--gray-2);
  margin: 2.5rem 0;
}

/* Code */
.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--gray-1);
  border: 1px solid var(--gray-2);
  border-radius: 4px;
  padding: 0.125rem 0.375rem;
}

.docs-content pre {
  background: var(--gray-12);
  color: var(--gray-3);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Tables */
.docs-content .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

.docs-content .table-wrap table {
  margin-bottom: 0;
}

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.docs-content th {
  text-align: left;
  font-weight: 600;
  color: var(--gray-10);
  padding: 0.625rem 0.75rem;
  border-bottom: 2px solid var(--gray-2);
  white-space: nowrap;
}

.docs-content td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--gray-2);
  color: var(--gray-8);
  vertical-align: top;
}

.docs-content tr:last-child td {
  border-bottom: none;
}

/* Callout boxes */
.docs-callout {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.docs-callout p:last-child {
  margin-bottom: 0;
}

.docs-callout-info {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
}

.docs-callout-tip {
  background: var(--green-light);
  border-left: 3px solid var(--green);
}

.docs-callout-warning {
  background: var(--yellow-light);
  border-left: 3px solid var(--yellow);
}

.docs-callout-label {
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
  display: block;
}

.docs-callout-info .docs-callout-label { color: var(--blue); }
.docs-callout-tip .docs-callout-label { color: #0a7c5a; }
.docs-callout-warning .docs-callout-label { color: #92620a; }

/* Use tinted text on callout backgrounds instead of gray */
.docs-callout-info p { color: #1e3a5f; }
.docs-callout-tip p { color: #14532d; }
.docs-callout-warning p { color: #713f12; }

/* Keyboard shortcut styling */
kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--gray-1);
  border: 1px solid var(--gray-3);
  border-radius: 4px;
  padding: 0.125rem 0.5rem;
  box-shadow: 0 1px 0 var(--gray-3);
  color: var(--gray-10);
  white-space: nowrap;
}

/* Cards grid (for docs index) */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.docs-card {
  border: 1px solid var(--gray-2);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: block;
  color: inherit;
}

.docs-card:hover {
  border-color: var(--gray-3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  color: inherit;
}

.docs-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-12);
  margin: 0 0 0.25rem;
}

.docs-card p {
  font-size: 0.8125rem;
  color: var(--gray-5);
  margin: 0;
  line-height: 1.5;
}

/* Page nav (prev/next) */
.docs-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-2);
}

.docs-page-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  color: var(--gray-8);
  font-size: 0.8125rem;
  padding: 0.5rem 0;
}

.docs-page-nav a:hover {
  color: var(--accent);
}

.docs-page-nav a span:first-child {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-5);
}

.docs-page-nav a span:last-child {
  font-weight: 500;
  font-size: 0.9375rem;
}

.docs-page-nav .prev span:last-child::before {
  content: "\2190\00a0";
}

.docs-page-nav .next span:last-child::after {
  content: "\00a0\2192";
}

.docs-page-nav .next {
  text-align: right;
  margin-left: auto;
}

/* On this page (table of contents) */
.docs-toc {
  position: fixed;
  right: 1.5rem;
  top: 5rem;
  width: 200px;
  font-size: 0.75rem;
}

.docs-toc-heading {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-5);
  margin-bottom: 0.5rem;
}

.docs-toc a {
  display: block;
  padding: 0.2rem 0;
  color: var(--gray-5);
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  line-height: 1.4;
}

.docs-toc a:hover {
  color: var(--gray-10);
}

.docs-toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1200px) {
  .docs-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .docs-content {
    padding: 2rem 2rem 3rem;
  }
}

@media (max-width: 768px) {
  .docs-topnav-links {
    display: none;
  }

  .docs-mobile-toggle {
    display: block;
  }

  .docs-sidebar {
    position: fixed;
    top: 3.5rem;
    left: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: none;
    width: 280px;
  }

  .docs-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  }

  .docs-content {
    padding: 1.5rem 1.25rem 3rem;
  }

  .docs-content h1 {
    font-size: 1.75rem;
  }

  .docs-content h2 {
    font-size: 1.25rem;
  }

  .docs-cards {
    grid-template-columns: 1fr;
  }

  /* Bigger touch targets on mobile */
  .docs-sidebar-link {
    padding: 0.5rem 0.75rem;
  }
}

/* ========================================
   View Transitions
   ======================================== */

@view-transition {
  navigation: auto;
}

.docs-topnav {
  view-transition-name: docs-topnav;
}

.docs-sidebar {
  view-transition-name: docs-sidebar;
}

.docs-content {
  view-transition-name: docs-content;
}

::view-transition-old(docs-topnav),
::view-transition-new(docs-topnav),
::view-transition-old(docs-sidebar),
::view-transition-new(docs-sidebar) {
  animation: none;
}

::view-transition-old(docs-content) {
  animation: vt-slide-out 0.2s ease forwards;
}

::view-transition-new(docs-content) {
  animation: vt-slide-in 0.25s ease forwards;
}

@keyframes vt-slide-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(var(--vt-y-out, -12px)); }
}

@keyframes vt-slide-in {
  from { opacity: 0; transform: translateY(var(--vt-y-in, 12px)); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Reduced motion
   ======================================== */

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

  @view-transition {
    navigation: none;
  }

  html {
    scroll-behavior: auto;
  }
}
