/* Tennis API Documentation — Shared Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #16a34a;
  --accent-hover: #15803d;
  --accent-light: #dcfce7;
  --accent-dim:   #bbf7d0;
  --bg:           #ffffff;
  --bg-sidebar:   #f8fafc;
  --bg-toc:       #f8fafc;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --text-light:   #94a3b8;
  --code-bg:      #0f172a;
  --code-text:    #e2e8f0;
  --warn-bg:      #fffbeb;
  --warn-border:  #f59e0b;
  --info-bg:      #eff6ff;
  --info-border:  #3b82f6;
  --success-bg:   #f0fdf4;
  --success-border:#16a34a;
  --danger-bg:    #fff1f2;
  --danger-border:#f43f5e;
  --sidebar-w:    268px;
  --toc-w:        220px;
  --header-h:     58px;
  --radius:       8px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  overflow-x: hidden; /* prevent horizontal scroll from overflowing content */
}

/* ─── Layout ───────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ─── Header ───────────────────────────────────────────────── */
.header {
  grid-column: 1 / -1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  /* horizontal scroll on very small screens — no wrapping */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.header::-webkit-scrollbar { display: none; }

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  flex-shrink: 0;
}

.header-logo .logo-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.header-nav a {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.header-nav a:hover, .header-nav a.active {
  background: var(--accent-light);
  color: var(--accent);
}

.header-badge {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: var(--header-h);
  /* On mobile the header can be taller; JS could update this,
     but simply setting a safe value avoids the overlap. */
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 10px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.nav-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .method-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  letter-spacing: 0.04em;
}

/* ─── Main content ─────────────────────────────────────────── */
.main {
  grid-column: 2;
  grid-row: 2;
  padding: 40px 48px 80px;
  max-width: 860px;
  min-width: 0; /* prevents grid cell from overflowing its track */
  overflow-x: hidden;
}

/* ─── TOC (right sidebar) ──────────────────────────────────── */
.toc {
  grid-column: 3;
  grid-row: 2;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 28px 16px 40px 4px;
  border-left: 1px solid var(--border);
  background: var(--bg-toc);
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 0 12px 8px;
}

.toc-list {
  list-style: none;
}

.toc-list li a {
  display: block;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  line-height: 1.4;
}

.toc-list li a:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.toc-list li.toc-h3 a {
  padding-left: 22px;
  font-size: 0.76rem;
}

/* ─── Typography ───────────────────────────────────────────── */
.page-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 12px;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 20px);
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 10px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}

h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

p { margin-bottom: 14px; color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { padding-left: 22px; margin-bottom: 14px; }
li { margin-bottom: 4px; }

.page-intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.75;
}

/* ─── Callout boxes ────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border-left: 4px solid;
  margin: 20px 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.callout-body { flex: 1; }
.callout-body strong { display: block; margin-bottom: 2px; font-weight: 600; }

.callout.success  { background: var(--success-bg); border-color: var(--success-border); color: #166534; }
.callout.info     { background: var(--info-bg);    border-color: var(--info-border);    color: #1e40af; }
.callout.warning  { background: var(--warn-bg);    border-color: var(--warn-border);    color: #92400e; }
.callout.danger   { background: var(--danger-bg);  border-color: var(--danger-border);  color: #9f1239; }

/* ─── Endpoint block ───────────────────────────────────────── */
.endpoint {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 24px 0;
  overflow: hidden;
}

.endpoint-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  flex-wrap: wrap;
}

.method {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 5px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  margin-top: 1px;
}
.method.get    { background: #dbeafe; color: #1d4ed8; }
.method.post   { background: #dcfce7; color: #166534; }
.method.put    { background: #fef9c3; color: #854d0e; }
.method.delete { background: #fee2e2; color: #991b1b; }

.endpoint-path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  /* Break at path separators, not at arbitrary characters */
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.5;
}

.endpoint-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  width: 100%;
  padding-top: 2px;
}

.endpoint-body {
  padding: 20px 18px;
}

/* ─── Tables ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Must be constrained to parent width so overflow-x actually scrolls */
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  /* No fixed min-width — let cells size themselves and overflow-wrap handle wrapping */
}

thead tr {
  background: var(--bg-sidebar);
  border-bottom: 2px solid var(--border);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* Path/URL code inside tables: wrap at slash boundaries, not mid-char */
td code, th code {
  background: var(--accent-light);
  color: var(--accent-hover);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  white-space: nowrap;
  display: inline;
}

.required-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: #fee2e2;
  color: #991b1b;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.optional-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Code blocks ──────────────────────────────────────────── */
.code-block {
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 14px 0;
  font-size: 0.84rem;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.code-lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.copy-btn {
  background: #334155;
  border: none;
  color: #94a3b8;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s, color 0.15s;
}

.copy-btn:hover { background: #475569; color: #e2e8f0; }

.code-block pre {
  padding: 16px;
  overflow-x: auto;
  line-height: 1.6;
  margin: 0;
}

.code-block code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--code-text);
  background: none;
  white-space: pre;
}

/* JSON syntax colors */
.json-key    { color: #7dd3fc; }
.json-str    { color: #86efac; }
.json-num    { color: #fca5a5; }
.json-bool   { color: #f9a8d4; }
.json-null   { color: #94a3b8; }
.json-punc   { color: #e2e8f0; }
.http-method { color: #34d399; }
.http-url    { color: #7dd3fc; }
.http-header { color: #fcd34d; }

/* ─── Response object card ─────────────────────────────────── */
.response-schema {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 14px 0;
}

.response-schema h4 { margin-top: 0; }

.schema-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.schema-field:last-child { border-bottom: none; }

.schema-field-name {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent);
  min-width: 160px;
  flex-shrink: 0;
}

.schema-field-type {
  color: #7c3aed;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  min-width: 80px;
  flex-shrink: 0;
}

.schema-field-desc { color: var(--text-muted); flex: 1; }

/* ─── Quick Start Video Embed ──────────────────────────────── */
.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 960px;
  margin: 24px 0 40px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  background: #0a0a0a;
}
.video-embed iframe,
.video-embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ─── Cards (landing page) ─────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 32px 0;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(22,163,74,0.12);
  transform: translateY(-2px);
  text-decoration: none;
}

.card-icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.card-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-light); }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ─── Inline code ──────────────────────────────────────────── */
p code, li code {
  background: var(--accent-light);
  color: var(--accent-hover);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

/* ─── Type indicators in tables ────────────────────────────── */
.type-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

.type-string  { background: #f0fdf4; color: #15803d; }
.type-integer { background: #eff6ff; color: #1d4ed8; }
.type-number  { background: #eff6ff; color: #1d4ed8; }
.type-boolean { background: #fdf4ff; color: #7e22ce; }
.type-object  { background: #fff7ed; color: #c2410c; }
.type-array   { background: #fefce8; color: #a16207; }
.type-date    { background: #fff1f2; color: #be123c; }

/* ─── Section divider ──────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ─── Tabs ─────────────────────────────────────────────────── */
.tabs { margin: 16px 0; }

.tab-list {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: 'Inter', sans-serif;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn.active, .tab-btn:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ─── Mobile nav toggle ────────────────────────────────────── */
.nav-toggle {
  display: none;
}

.header-current-page {
  display: none;
}

/* ─── Responsive ───────────────────────────────────────────── */

/* ── 1200px: drop right TOC, 2-column layout ── */
@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .toc { display: none; }
}

/* ── 900px: drop sidebar, SINGLE column ── */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
  }
  .sidebar { display: none; }
  .toc     { display: none; }

  /* ▼ THE CRITICAL FIX: reset grid placement so main sits in column 1
       Without this, grid-column:2 creates an off-screen implicit column */
  .main {
    grid-column: 1;
    grid-row: 2;
    padding: 28px 24px 60px;
    max-width: 100%;
  }

  /* Header: disable horizontal scroll, enable dropdown nav */
  .header {
    overflow: visible;
    position: relative;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .header-divider { display: none; }
  .header-badge   { display: none; }

  /* Current page breadcrumb pill */
  .header-current-page {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    flex-shrink: 1;
  }

  /* Hamburger button */
  .nav-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
  }

  .nav-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    transform-origin: center;
  }

  /* Animate hamburger → X when open */
  .header.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .header.nav-open .nav-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .header.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Hide the inline nav; shown as dropdown when open */
  .header-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    z-index: 200;
    flex-direction: column;
    padding: 8px 0 12px;
    gap: 0;
  }

  .header.nav-open .header-nav { display: flex; }

  .header-nav a {
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 0;
    white-space: normal;
    border-left: 3px solid transparent;
  }

  .header-nav a:hover,
  .header-nav a.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
  }

  .card-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.2rem; }

  .endpoint-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .endpoint-desc   { padding-left: 0; }
  .tab-list        { overflow-x: auto; flex-wrap: nowrap; }
  .code-block pre  { overflow-x: auto; }

  .table-wrap {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .table-wrap::-webkit-scrollbar       { height: 5px; }
  .table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
}

/* ── 480px: compact mobile ── */
@media (max-width: 480px) {
  .main        { padding: 20px 16px 60px; }
  .card-grid   { grid-template-columns: 1fr; }
  h1           { font-size: 1.35rem; }
  h2           { font-size: 1.1rem; }

  .schema-field      { flex-direction: column; gap: 4px; }
  .schema-field-name { min-width: unset; }
  .schema-field-type { min-width: unset; }

  .endpoint-path { font-size: 0.78rem; }
  .callout       { padding: 12px 14px; font-size: 0.85rem; }
  .breadcrumb    { flex-wrap: wrap; }

  .header-current-page { max-width: 100px; }
}
