/* ==========================================================
   3Sixty Studio — Documentation styles
   Tokens, fonts and components mirror the landing page (../index.php).
   ========================================================== */

:root {
  --ink: #1B2530;
  --slate: #2C3643;
  --emerald: #00B16D;
  --emerald-deep: #00804F;
  --dusk: #F2B880;
  --fog: #EEF2F5;
  --paper: #FFFFFF;
  --muted: #5B6776;
  --line: #D6DDE4;

  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Instrument Sans", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --wrap: 1180px;
  --gutter: clamp(20px, 5vw, 48px);
  --topbar: 68px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 {
  font-family: var(--display);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0;
}
p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--emerald);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--paper); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; z-index: 100;
}
.skip:focus { left: 8px; }

/* ---------- BUTTONS (same as landing) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: 999px;
  font-family: var(--body); font-size: 16px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  border: 1.5px solid transparent;
  transition: background-color .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--emerald); color: var(--ink); }
.btn-primary:hover { background: #12C47F; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--slate); }

/* ---------- TOP BAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--ink); color: #fff;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 0 var(--gutter);
  height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none;
  font-family: var(--display); font-weight: 700; font-size: 20px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-icon {
  width: 30px; height: 30px; flex: none;
  border-radius: 7px;
  object-fit: cover;
}
.docs-tag {
  font-size: 13px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(0,177,109,.18); color: var(--emerald);
  text-decoration: none;
}
.top-links { margin-left: auto; display: flex; align-items: center; gap: 28px; }
.top-links a:not(.btn) {
  color: rgba(255,255,255,.82); text-decoration: none; font-weight: 500;
}
.top-links a:not(.btn):hover, .top-links a.is-current { color: #fff; }
.top-links a.is-current { box-shadow: inset 0 -2px 0 var(--emerald); padding-bottom: 2px; }
.top-links .btn { min-height: 42px; padding: 0 18px; font-size: 15px; }

.menu-btn {
  display: none;
  margin-left: auto;
  align-items: center; gap: 8px;
  min-height: 42px; padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,.55);
  background: transparent; color: #fff;
  font: 600 15px var(--body);
  cursor: pointer;
}
.menu-btn svg { width: 20px; height: 20px; }
.menu-btn:hover { background: rgba(255,255,255,.12); }

@media (max-width: 899px) {
  .top-links a:not(.btn) { display: none; }
  .top-links { gap: 12px; }
  .menu-btn { display: inline-flex; margin-left: 0; }
}
@media (max-width: 520px) {
  .top-links { display: none; }
  .menu-btn { margin-left: auto; }
  .brand { font-size: 18px; }
}

/* ---------- LAYOUT ---------- */
.docs {
  max-width: 1440px; margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) {
  .docs { grid-template-columns: 264px minmax(0, 1fr); }
}
@media (min-width: 1240px) {
  .docs { grid-template-columns: 264px minmax(0, 1fr) 220px; }
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: var(--fog);
  padding: 28px 20px 40px;
  border-right: 1px solid var(--line);
}
@media (min-width: 900px) {
  .sidebar {
    position: sticky; top: var(--topbar);
    align-self: start;
    height: calc(100vh - var(--topbar));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
@media (max-width: 899px) {
  .sidebar {
    position: fixed; z-index: 35;
    top: calc(var(--topbar) + env(safe-area-inset-top, 0px));
    left: 0; right: 0; bottom: 0;
    overflow-y: auto; overscroll-behavior: contain;
    padding: 20px var(--gutter) calc(40px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    display: none;
  }
  .sidebar.is-open { display: block; }
  body.menu-open { overflow: hidden; }
}
.side-group {
  margin: 22px 0 6px;
  font-family: var(--display); font-weight: 700;
  font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.side-group:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: block;
  padding: 7px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 16px; font-weight: 500;
  color: var(--slate);
}
.sidebar li a:hover { background: rgba(27,37,48,.06); color: var(--ink); }
.sidebar li a[aria-current="page"] {
  background: var(--ink); color: #fff;
  box-shadow: inset 3px 0 0 var(--emerald);
}
.side-download { margin-top: 28px; width: 100%; font-size: 15px; min-height: 44px; }

/* ---------- CONTENT ---------- */
.content {
  min-width: 0;
  padding: clamp(32px, 5vw, 56px) var(--gutter) 72px;
}
.prose { max-width: 760px; }
.crumb {
  font-size: 14px; color: var(--muted); margin-bottom: 10px;
}
.crumb a { color: var(--emerald-deep); text-decoration: none; font-weight: 600; }
.crumb a:hover { text-decoration: underline; }

.prose h1 {
  font-size: clamp(34px, 4.6vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.prose .lede {
  margin-top: 16px;
  font-size: 19px;
  color: var(--muted);
  max-width: 62ch;
}
.prose h2 {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  font-size: clamp(26px, 3vw, 32px);
  font-weight: 700;
  scroll-margin-top: calc(var(--topbar) + 16px);
}
.prose h3 {
  margin-top: 34px;
  font-size: 21px;
  font-weight: 700;
  scroll-margin-top: calc(var(--topbar) + 16px);
}
.prose tr[id] { scroll-margin-top: calc(var(--topbar) + 16px); }
.prose h2 + p, .prose h3 + p, .prose h2 + ul, .prose h3 + ul, .prose h2 + ol, .prose h3 + ol { margin-top: 14px; }
.prose p, .prose ul, .prose ol, .prose pre, .prose .table-wrap, .prose .callout { margin-top: 16px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 6px; }
.prose li > pre { margin-top: 10px; }
.prose a {
  color: var(--emerald-deep);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.prose a:hover { color: var(--ink); }
.prose strong { font-weight: 600; }

/* inline code + keys */
.prose code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--fog);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .08em .38em;
  overflow-wrap: anywhere;
}
kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: .05em .45em;
  font-family: var(--body); font-size: .82em; font-weight: 600;
  line-height: 1.5;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-width: 2.5px;
  border-radius: 7px;
  white-space: nowrap;
}

/* code blocks */
.prose pre {
  background: var(--ink);
  color: #E6EDF3;
  border-radius: 14px;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 14.5px;
  line-height: 1.6;
}
.prose pre code {
  background: none; border: 0; padding: 0;
  font-size: inherit; color: inherit;
  overflow-wrap: normal;
}

/* numbered steps (echo of landing "how it works") */
.prose ol.step-list {
  list-style: none; padding: 0;
  counter-reset: step;
}
.prose ol.step-list > li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  min-height: 34px;
}
.prose ol.step-list > li + li { margin-top: 14px; }
.prose ol.step-list > li::before {
  content: counter(step);
  position: absolute; left: 0; top: -1px;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 16px;
  background: var(--ink); color: var(--emerald);
}

/* tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
  line-height: 1.5;
}
.prose th, .prose td {
  text-align: left; vertical-align: top;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.prose th {
  background: var(--fog);
  font-weight: 600; font-size: 14px;
  color: var(--slate);
  white-space: nowrap;
}
.prose tr:last-child td { border-bottom: 0; }
.prose td:first-child { min-width: 9em; }
.prose table.keys td:first-child { white-space: nowrap; }
@media (max-width: 560px) {
  .prose table.keys td:first-child { white-space: normal; }
  .prose td:first-child { min-width: 7em; }
}

/* callouts */
.callout {
  border-radius: 14px;
  padding: 16px 18px 16px 20px;
  border-left: 4px solid var(--emerald);
  background: var(--fog);
  font-size: 16px;
}
.callout > p + p { margin-top: 8px; }
.prose .callout .callout-title {
  font-family: var(--display); font-weight: 700;
  font-size: 15px; letter-spacing: .01em;
  margin: 0 0 4px;
}
.callout-note .callout-title { color: var(--slate); }
.callout-tip { background: #E3F6EE; border-left-color: var(--emerald-deep); }
.callout-tip .callout-title { color: var(--emerald-deep); }
.callout-warn { background: #FBE6D2; border-left-color: #C9772C; }
.callout-warn .callout-title { color: #8A4B12; }
.callout p:not(.callout-title) { margin-top: 0; }

/* ---------- HOME CARDS ---------- */
.card-grid {
  margin-top: 32px;
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 620px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.prose a.card {
  display: grid; grid-template-columns: 44px 1fr; gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.prose a.card:hover {
  border-color: var(--emerald);
  box-shadow: 0 10px 30px rgba(27,37,48,.10);
  color: var(--ink);
}
.card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--emerald);
}
.card-icon svg { width: 22px; height: 22px; }
.card strong { display: block; font-family: var(--display); font-size: 18px; font-weight: 700; }
.card strong + span { display: block; margin-top: 2px; font-size: 15px; color: var(--muted); line-height: 1.45; }

/* ---------- HOME HERO ---------- */
.is-home .content { padding-top: 0; }
.is-home .prose h1 {
  margin: 0 calc(var(--gutter) * -1);
  padding: clamp(40px, 7vw, 72px) var(--gutter) 0;
}

/* ---------- SCREENSHOTS (same frames as landing) ---------- */
.shots {
  margin-top: 24px;
  display: grid; gap: 20px;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: end;
}
@media (max-width: 560px) { .shots { grid-template-columns: minmax(0, 1fr) 96px; gap: 12px; } }
figure.shot { margin: 0; min-width: 0; }
.shot-frame {
  border-radius: 16px;
  border: 8px solid var(--ink);
  background: var(--ink);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(27,37,48,.16);
}
.shot-frame.is-desktop { aspect-ratio: 16 / 10; }
.shot-frame.is-phone { aspect-ratio: 9 / 19.5; border-radius: 24px; border-width: 6px; }
.shot-frame img { width: 100%; height: 100%; object-fit: cover; }
.shot figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* ---------- PREV / NEXT ---------- */
.prevnext {
  max-width: 760px;
  margin-top: 64px;
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.pn {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  transition: border-color .15s, background-color .15s;
}
.pn:hover { border-color: var(--emerald); background: var(--fog); }
.pn span { display: block; font-size: 14px; color: var(--muted); }
.pn strong { display: block; font-family: var(--display); font-size: 18px; font-weight: 700; margin-top: 2px; }
.pn-next { text-align: right; grid-column: 2; }
.pn-prev span::before { content: "← "; }
.pn-next span::after { content: " →"; }
@media (max-width: 560px) {
  .prevnext { grid-template-columns: minmax(0, 1fr); }
  .pn-next { grid-column: 1; }
}

/* ---------- ON THIS PAGE ---------- */
.toc-col { display: none; }
@media (min-width: 1240px) {
  .toc-col { display: block; padding: 56px 24px 40px 0; }
  .toc {
    position: sticky; top: calc(var(--topbar) + 32px);
    max-height: calc(100vh - var(--topbar) - 64px);
    overflow-y: auto;
  }
}
.toc-title {
  font-family: var(--display); font-weight: 700;
  font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc li a {
  display: block;
  margin-left: -2px;
  padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  font-size: 14.5px; line-height: 1.4;
  color: var(--muted); text-decoration: none;
}
.toc li a:hover { color: var(--ink); }
.toc li a.is-active { color: var(--emerald-deep); border-left-color: var(--emerald); font-weight: 600; }

/* ---------- FOOTER (same as landing) ---------- */
.footer {
  background: var(--ink); color: rgba(255,255,255,.72);
  padding: 48px 0 calc(48px + env(safe-area-inset-bottom, 0px));
  font-size: 15px;
}
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 20px 40px;
  align-items: center; justify-content: space-between;
}
.footer a { color: #fff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-links { display: flex; flex-wrap: wrap; gap: 24px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .prose a.card, .pn { transition: none; }
}
