/*
 * docs.punchly.work — Punchly's brand scale (apps/web/src/styles/brand.css), light and dark.
 */
:root {
  --brand-50: #e8f5ef;
  --brand-100: #cfeadf;
  --brand-300: #6fba9c;
  --brand-500: #1d7f5d;
  --brand-600: #0f6547;
  --brand-700: #0a4733;
  --brand-800: #083a2a;

  --bg: #ffffff;
  --bg-soft: #f6f9f7;
  --fg: #0c1a14;
  --muted: #5b6b65;
  --border: #dde5e1;
  --link: var(--brand-600);
  --accent: var(--brand-700);
  --code-bg: #f1f5f3;
  --code-fg: #13251e;
  --pre-bg: #0f1d18;
  --pre-fg: #e4ece8;
  --note-bg: var(--brand-50);
  --note-border: var(--brand-300);

  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1511;
    --bg-soft: #111e19;
    --fg: #e4ece8;
    --muted: #93a69f;
    --border: #22362d;
    --link: var(--brand-300);
    --accent: var(--brand-300);
    --code-bg: #17271f;
    --code-fg: #d6e6de;
    --pre-bg: #07100c;
    --note-bg: #10241b;
    --note-border: #1d7f5d;
    color-scheme: dark;
  }
  .logo-dark-text {
    display: none;
  }
}
@media (prefers-color-scheme: light) {
  .logo-light-text {
    display: none;
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 72px;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 var(--font);
}
a {
  color: var(--link);
  text-underline-offset: 2px;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
}
.logo {
  height: 20px;
  width: auto;
}
.brand-docs {
  font-weight: 600;
  color: var(--muted);
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.topnav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 15px;
}
.topnav a {
  color: var(--fg);
  text-decoration: none;
}
.topnav a[aria-current='page'] {
  color: var(--accent);
  font-weight: 600;
}
.topnav .topnav-app {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--brand-700);
  color: #fff;
  font-weight: 600;
}
.topnav .topnav-app:hover {
  background: var(--brand-800);
}

/* Three columns: guides, article, on this page */
.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 40px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}
.sidebar,
.toc {
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 28px 0;
  font-size: 14px;
}
.nav-section + .nav-section {
  margin-top: 20px;
}
.nav-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar ul,
.phone-menu ul,
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar a,
.phone-menu a,
.toc a {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
}
.sidebar a:hover,
.phone-menu a:hover,
.toc a:hover {
  background: var(--bg-soft);
}
.sidebar a[aria-current='page'],
.phone-menu a[aria-current='page'] {
  background: var(--note-bg);
  color: var(--accent);
  font-weight: 600;
}
.toc a {
  color: var(--muted);
  padding: 3px 10px;
}
.phone-menu {
  display: none;
}

/* The article */
.article {
  min-width: 0;
  max-width: 780px;
  padding: 28px 0 64px;
}
.article h1 {
  margin: 8px 0 12px;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.article h2 {
  margin: 44px 0 12px;
  padding-top: 8px;
  font-size: 1.45rem;
  line-height: 1.3;
  border-top: 1px solid var(--border);
}
.article h3 {
  margin: 28px 0 8px;
  font-size: 1.12rem;
}
.article h2,
.article h3 {
  position: relative;
}
.anchor {
  position: absolute;
  left: -1.1em;
  padding-right: 0.3em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
}
h2:hover .anchor,
h3:hover .anchor {
  opacity: 1;
}
.article p,
.article ul,
.article ol {
  margin: 0 0 16px;
}
.article li + li {
  margin-top: 4px;
}
.article blockquote {
  margin: 20px 0;
  padding: 12px 16px;
  background: var(--note-bg);
  border-left: 4px solid var(--note-border);
  border-radius: 0 8px 8px 0;
}
.article blockquote p:last-child {
  margin-bottom: 0;
}
code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.12em 0.36em;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--code-fg);
  overflow-wrap: anywhere;
}
.code {
  position: relative;
  margin: 0 0 20px;
}
.code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--pre-bg);
  color: var(--pre-fg);
  font: 13.5px/1.6 var(--mono);
}
.code pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  overflow-wrap: normal;
}
.code-lang {
  position: absolute;
  top: 6px;
  right: 10px;
  font: 11px var(--mono);
  color: #93a69f;
  text-transform: uppercase;
}
/* A name in a table cell stays whole; the table scrolls in its box instead. */
td code {
  overflow-wrap: normal;
}
.table-wrap {
  margin: 0 0 20px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
th,
td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 600;
  background: var(--bg-soft);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
}
.pager a {
  flex: 1;
  max-width: 48%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
}
.pager a:hover {
  border-color: var(--brand-500);
}
.pager span {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.pager-next {
  text-align: right;
}
.footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
}

/* The reference page: Scalar fills everything under the top bar. */
body.reference {
  background: var(--bg);
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }
  .brand-docs,
  .topnav-app {
    display: none;
  }
  .topnav {
    gap: 14px;
  }
  .shell {
    display: block;
    padding: 0 16px;
  }
  .sidebar {
    display: none;
  }
  .phone-menu {
    display: block;
    margin: 12px 0 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
  }
  .phone-menu summary {
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
  }
  .phone-menu nav {
    padding: 0 8px 12px;
  }
  .article {
    padding-top: 16px;
  }
  .article h1 {
    font-size: 1.7rem;
  }
  .anchor {
    display: none;
  }
  .pager {
    flex-direction: column;
  }
  .pager a {
    max-width: none;
  }
}
