/* =========================================================================
   Chatly — Docs
   Reuses the landing design tokens (see ../styles.css). This file only adds
   the docs shell (sidebar + content) and long-form prose styling.
   ========================================================================= */

/* ---------- docs shell ---------- */
.docs {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  padding: 0 clamp(1.1rem, 4vw, 2rem);
  align-items: start;
}

/* ---------- sidebar ---------- */
.docs__side {
  position: sticky;
  top: 64px;                       /* under the sticky nav */
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 2rem 0.4rem 3rem;
  scrollbar-width: thin;
}
.docs__side::-webkit-scrollbar { width: 8px; }
.docs__side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.docs__navgroup {
  font-family: "Clash Display", sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 1.5rem 0.9rem 0.5rem;
}
.docs__navgroup:first-child { margin-top: 0; }

.docs__navlink {
  display: block;
  padding: 0.5rem 0.9rem;
  margin: 0.1rem 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}
.docs__navlink:hover { color: var(--ink); background: var(--glass); }
.docs__navlink.is-active {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.16), rgba(124, 92, 255, 0.07));
  border-color: rgba(124, 92, 255, 0.4);
}

/* ---------- content column ---------- */
.docs__main { min-width: 0; padding: 2.4rem 0 4rem; }
.docs__content { max-width: 780px; }
.docs__eyebrow {
  font-family: "Clash Display", sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c2);
  margin-bottom: 0.6rem;
}
.docs__content h1 {
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 700;
  margin-bottom: 0.7rem;
}
.docs__lead {
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.6;
  margin-bottom: 2.2rem;
}

/* prose */
.docs__content h2 {
  font-size: 1.5rem;
  margin: 2.6rem 0 0.9rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}
.docs__content h3 { font-size: 1.15rem; margin: 1.8rem 0 0.6rem; }
.docs__content p { color: var(--muted); margin-bottom: 1rem; }
.docs__content a:not(.btn):not(.docs__navlink) {
  color: var(--c1);
  font-weight: 500;
  border-bottom: 1px solid rgba(54, 197, 255, 0.35);
  transition: border-color 0.18s, color 0.18s;
}
.docs__content a:not(.btn):not(.docs__navlink):hover { color: #7fd8ff; border-color: currentColor; }
.docs__content strong { color: var(--ink); font-weight: 700; }
.docs__content ul, .docs__content ol { color: var(--muted); margin: 0 0 1.2rem 0; padding-left: 1.3rem; }
.docs__content li { margin-bottom: 0.5rem; }
.docs__content li::marker { color: var(--c2); }
.docs__content hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* code */
.docs__content :not(pre) > code {
  color: #d8ccff;
  background: rgba(124, 92, 255, 0.12);
  border: 1px solid rgba(124, 92, 255, 0.22);
}
.docs__code {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.3rem;
}
.docs__code code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.88rem;
  color: #e7e9f3;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}
.docs__copy {
  position: absolute; top: 8px; right: 8px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--muted);
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3em 0.6em;
  cursor: pointer;
  opacity: 0; transition: opacity 0.18s, color 0.18s;
}
.docs__code:hover .docs__copy { opacity: 1; }
.docs__copy:hover { color: var(--ink); }

/* callouts */
.callout {
  display: flex; gap: 0.8rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--glass);
  margin: 0 0 1.4rem;
  font-size: 0.96rem;
}
.callout__icon { flex: none; font-size: 1.1rem; line-height: 1.5; }
.callout p { margin: 0; color: var(--ink); }
.callout p + p { margin-top: 0.5rem; }
.callout--tip  { border-color: rgba(70, 224, 168, 0.35); background: rgba(70, 224, 168, 0.06); }
.callout--note { border-color: rgba(54, 197, 255, 0.35); background: rgba(54, 197, 255, 0.06); }
.callout--warn { border-color: rgba(255, 179, 71, 0.4);  background: rgba(255, 179, 71, 0.07); }

/* tables */
.docs__table { width: 100%; border-collapse: collapse; margin: 0 0 1.5rem; font-size: 0.93rem; overflow: hidden; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.docs__tablewrap { overflow-x: auto; margin-bottom: 1.5rem; }
.docs__table th, .docs__table td { text-align: left; padding: 0.7rem 0.95rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.docs__table thead th { background: rgba(255, 255, 255, 0.03); color: var(--ink); font-family: "Clash Display", sans-serif; font-weight: 600; font-size: 0.85rem; }
.docs__table td { color: var(--muted); }
.docs__table tr:last-child td { border-bottom: 0; }
.docs__table code { white-space: nowrap; }

/* numbered steps */
.docs__steps { list-style: none; counter-reset: s; padding: 0; margin: 0 0 1.5rem; }
.docs__steps > li {
  position: relative;
  counter-increment: s;
  padding: 0 0 1.3rem 3.2rem;
  margin: 0;
  border-left: 1px solid var(--line);
  margin-left: 1rem;
}
.docs__steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.docs__steps > li::before {
  content: counter(s);
  position: absolute; left: -1rem; top: -0.2rem;
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  font-family: "Clash Display", sans-serif; font-weight: 700; font-size: 0.95rem;
  color: #0a0a0f;
  background: var(--grad);
  border-radius: 50%;
}
.docs__steps > li h3 { margin: 0 0 0.3rem; font-size: 1.08rem; }
.docs__steps > li p { margin: 0; }

/* feature grid (intro) */
.docs__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; margin: 0 0 1.5rem; }
.docs__tile {
  display: block;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--glass);
  transition: transform 0.18s, border-color 0.18s, background 0.18s;
}
.docs__tile:hover { transform: translateY(-3px); border-color: rgba(124, 92, 255, 0.4); background: var(--glass-2); }
.docs__tile strong { display: block; color: var(--ink); font-family: "Clash Display", sans-serif; font-weight: 600; margin-bottom: 0.2rem; }
.docs__tile span { color: var(--muted); font-size: 0.9rem; }
.docs__tile em { font-style: normal; }

/* prev / next pager */
.docs__pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; padding-top: 1.8rem; border-top: 1px solid var(--line); }
.docs__pagerlink {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--glass);
  transition: transform 0.18s, border-color 0.18s, background 0.18s;
}
.docs__pagerlink:hover { transform: translateY(-2px); border-color: rgba(124, 92, 255, 0.4); background: var(--glass-2); }
.docs__pagerlink--next { text-align: right; }
.docs__pagerlink small { color: var(--faint); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.docs__pagerlink span { color: var(--ink); font-family: "Clash Display", sans-serif; font-weight: 600; }
.docs__pager > :only-child.docs__pagerlink--next { margin-left: auto; }

/* mobile drawer bits */
.docs__mobilebar { display: none; }
.docs__scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  .docs { grid-template-columns: 1fr; }

  /* a proper full-width docs toolbar: menu button on the left, current page on the
     right for context — reads as intentional navigation, not a floating pill. */
  .docs__mobilebar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
    margin: 0 0 1.9rem;
    padding: 0.5rem 0.55rem 0.5rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--glass-2), var(--glass));
  }
  .docs__menubtn {
    display: inline-flex; align-items: center; gap: 0.55rem;
    font-family: "Clash Display", sans-serif; font-weight: 600; font-size: 0.92rem;
    color: var(--ink); background: none; border: 0; padding: 0.35rem 0.25rem; cursor: pointer;
    line-height: 1;
  }
  .docs__menubtn svg { color: var(--c2); flex: none; }
  .docs__here {
    color: var(--muted); font-size: 0.8rem; font-weight: 600;
    padding: 0.35rem 0.7rem; border-radius: 8px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
    max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  .docs__side {
    position: fixed;
    top: 0; left: 0;
    /* Explicit full-viewport height (not top:0/bottom:0) — a transformed fixed element
       collapses to content height on mobile, leaving a gap at the bottom. 100dvh tracks
       the visible height across every screen size and the mobile URL bar. */
    height: 100vh;
    height: 100dvh;
    width: min(300px, 84vw);
    max-height: none;
    overflow-y: auto;
    z-index: 200;
    padding: 1.4rem 1rem 2.5rem;
    background: rgba(12, 12, 18, 0.98);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-right: 1px solid var(--line);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
  }
  .docs__side.open { transform: translateX(0); }
  .docs__side .docs__sideclose {
    display: block; margin: 0 0 1rem auto;
    background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer;
  }

  .docs__scrim {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0; pointer-events: none; transition: opacity 0.28s;
  }
  .docs__scrim.show { display: block; opacity: 1; pointer-events: auto; }

  .docs__main { padding-top: 0.6rem; }
  .docs__grid { grid-template-columns: 1fr; }
  .docs__pager { grid-template-columns: 1fr; }
}

/* desktop: hide the mobile close button */
@media (min-width: 941px) { .docs__sideclose { display: none; } }

/* Phones: tables reflow into labeled cards instead of scrolling sideways. Each cell
   shows its column name (from data-label) above the value — no horizontal scrollbar. */
@media (max-width: 600px) {
  .docs__tablewrap { overflow-x: visible; margin-bottom: 1.4rem; }
  .docs__table { border: 0; border-radius: 0; }
  .docs__table thead {                          /* keep header for screen readers, hide visually */
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .docs__table tbody, .docs__table tr, .docs__table td { display: block; width: auto; }
  .docs__table tr {
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--glass); margin-bottom: 0.7rem; padding: 0.35rem 0.25rem;
  }
  .docs__table td { border: 0; padding: 0.4rem 0.95rem; display: flex; flex-direction: column; gap: 0.15rem; }
  .docs__table td::before {
    content: attr(data-label);
    font-family: "Clash Display", sans-serif; font-weight: 600;
    font-size: 0.66rem; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--faint);
  }
  .docs__table td[data-label=""]::before { display: none; }
  .docs__table code { white-space: normal; }    /* let long commands wrap inside the card */

  /* code examples wrap instead of scrolling sideways on phones */
  .docs__code { overflow-x: visible; }
  .docs__code code { white-space: pre-wrap; overflow-wrap: break-word; }
}
