@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,700;1,9..144,300&family=DM+Sans:opsz,wght@9..40,400;9..40,500&family=DM+Mono:wght@400&display=swap');

@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Thin.woff2') format('woff2'); font-weight: 100; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-ThinItalic.woff2') format('woff2'); font-weight: 100; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-ExtraLight.woff2') format('woff2'); font-weight: 200; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-ExtraLightItalic.woff2') format('woff2'); font-weight: 200; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-LightItalic.woff2') format('woff2'); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-MediumItalic.woff2') format('woff2'); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-SemiBoldItalic.woff2') format('woff2'); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-BoldItalic.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-ExtraBold.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-4/web/InterDisplay-Black.woff2') format('woff2'); font-weight: 900; font-style: normal; font-display: swap; }

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

:root {
  --sidebar-w: 300px;
  --bg: #FCFCFC;
  --sidebar-bg: #0B2E29;
  --sidebar-hover: #13433C;
  --sidebar-active: #13433C;
  --sidebar-text: #CBD8D4;
  --sidebar-text-dim: #7C948E;
  --sidebar-accent: #74CDBD;
  --border: rgba(255,255,255,.08);
  --content-text: #0B2E29;
  --content-text2: #123f38;
  --content-text3: #7C948E;
  --content-border: rgba(11,46,41,.35);
  --content-border-soft: rgba(11,46,41,.10);
  --content-bg2: #F1F5F3;
  --accent: #17967A;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--content-text);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* ── MOBILE HEADER ─────────────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--sidebar-bg);
  z-index: 200;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}
.hamburger {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; padding: 4px;
}
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--sidebar-text); border-radius: 2px;
  transition: all .2s;
}
.mobile-title {
  font-family: 'Fraunces', serif;
  font-size: 15px; font-weight: 700;
  color: #fff; letter-spacing: -.01em;
}

/* ── OVERLAY ───────────────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 149;
}
.sidebar-overlay.active { display: block; }

/* ── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 150;
  overflow: hidden;
}

.sidebar-header {
  padding: 22px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand-img { display: block; margin-bottom: 2px; }
.sidebar-brand-img img { height: 20px; }
.sidebar-tagline {
  font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-text-dim);
}

.sidebar-search {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 7px 11px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--sidebar-text);
  outline: none;
}
.sidebar-search input::placeholder { color: var(--sidebar-text-dim); }
.sidebar-search input:focus { border-color: rgba(116,205,189,.40); }

.sidebar-docs {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.sidebar-docs::-webkit-scrollbar { width: 4px; }
.sidebar-docs::-webkit-scrollbar-track { background: transparent; }
.sidebar-docs::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.sidebar-doc { margin: 1px 0; }

.sidebar-doc-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 14px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--sidebar-text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.35;
  border-radius: 6px;
  margin: 0 4px;
  width: calc(100% - 8px);
  transition: background .12s, color .12s;
}
.sidebar-doc-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-doc.active .sidebar-doc-btn {
  background: rgba(116,205,189,.16);
  color: var(--sidebar-accent);
}
.sidebar-doc-num {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  color: var(--sidebar-text-dim);
  flex-shrink: 0;
  width: 20px;
}
.sidebar-doc.active .sidebar-doc-num { color: var(--sidebar-accent); opacity: .7; }
.sidebar-doc-title { flex: 1; font-weight: 500; }
.sidebar-doc-arrow {
  font-size: 14px;
  color: var(--sidebar-text-dim);
  transition: transform .2s;
  flex-shrink: 0;
}
.sidebar-doc.active .sidebar-doc-arrow { transform: rotate(90deg); color: var(--sidebar-accent); }

/* Outline */
.doc-outline {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.4,0,.2,1);
}
.sidebar-doc.active .doc-outline { max-height: 9999px; }

.outline-item {
  display: block;
  padding: 5px 14px 5px 44px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--sidebar-text-dim);
  text-decoration: none;
  cursor: pointer;
  transition: color .1s, background .1s;
  border-radius: 4px;
  margin: 0 4px;
}
.outline-item:hover { color: var(--sidebar-text); background: rgba(116,205,189,.16); }
.outline-item.active-anchor { color: var(--sidebar-accent); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 14px;
  flex-shrink: 0;
}
.sidebar-footer-link {
  font-size: 11px;
  color: var(--sidebar-text-dim);
  text-decoration: none;
}
.sidebar-footer-link:hover { color: var(--sidebar-text); }

/* ── CONTENT ───────────────────────────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.content-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 48px 24px;
  width: 100%;
  flex: 1;
}

/* Doc sections */
.doc-section {
  display: none;
  padding-top: 48px;
}
.doc-section.active { display: block; }

.doc-header {
  padding-bottom: 20px;
  margin-bottom: 0;
}
.doc-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.doc-title {
  font-family: 'Fraunces', serif;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -.022em;
  line-height: 1.1;
  margin-bottom: 10px;
}
.doc-subtitle {
  font-size: 15px;
  color: var(--content-text3);
  line-height: 1.55;
}

/* Content typography */
.doc-body { font-size: 15px; line-height: 1.8; color: var(--content-text2); }
.doc-body h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px; font-weight: 700;
  color: var(--content-text);
  margin: 46px 0 14px;
  line-height: 1.3;
  padding-top: 4px;
  scroll-margin-top: 84px;
}
.doc-body h2:first-child { margin-top: 0; }

/* Copy-link button trailing section and category headings */
.copy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-left: 8px;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--content-text3);
  cursor: pointer;
  border-radius: 6px;
  opacity: .55;
  position: relative;
  transition: opacity .15s, color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.copy-link svg { display: block; }
.copy-link:hover { opacity: 1; color: var(--accent); background: var(--content-bg2); }
.copy-link.copied { opacity: 1; color: var(--accent); }
.copy-link.copied::after {
  content: 'Copied';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--content-text);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
}

.doc-body p { margin: 0 0 16px; }
.doc-body ul, .doc-body ol { margin: 0 0 16px 22px; }
.doc-body li { margin-bottom: 6px; line-height: 1.7; }
.doc-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(29,158,117,.3); }
.doc-body a:hover { border-bottom-color: var(--accent); }
.doc-body strong { font-weight: 600; color: var(--content-text); }
.doc-body em { font-style: italic; }

/* Inline cross-reference links (jump to another formatting section) */
.doc-body a.xref {
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px solid rgba(29,158,117,.3);
  font-weight: 500;
}
.doc-body a.xref:hover { border-bottom-color: var(--accent); }

/* ── Live formatting examples (type / see) ──────────────────────────────── */
.fmt-examples {
  margin: 20px 0 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.fmt-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--content-text);
  margin-bottom: 6px;
}
.fmt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--content-border-soft);
  border-radius: 12px;
  overflow: hidden;
}
/* min-width:0 lets each cell shrink to its track so a wide code block scrolls
   inside its own cell instead of stretching the grid and squeezing "You type" */
.fmt-type, .fmt-see { padding: 14px 16px; min-width: 0; }
.fmt-type {
  background: var(--content-bg2);
  border-right: 1px solid var(--content-border-soft);
}
.fmt-cap {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--content-text3);
  margin-bottom: 8px;
}
.fmt-type pre { margin: 0; }
.fmt-type code {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--content-text);
  background: none;
}
.fmt-render { font-size: 15px; line-height: 1.7; color: var(--content-text2); min-width: 0; }
.fmt-render p:last-child { margin-bottom: 0; }
.fmt-render ul, .fmt-render ol { margin: 0 0 0 20px; }
.fmt-render li { margin-bottom: 4px; }
/* Blockquote renders as a pull quote: filled, rounded, bold italic (Memento) */
.fmt-render blockquote {
  margin: 0;
  padding: 14px 16px;
  background: var(--content-bg2);
  border-radius: 14px;
  color: var(--content-text);
  font-style: italic;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.4;
}
.fmt-render code {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  background: var(--content-bg2);
  border: 1px solid var(--content-border-soft);
  border-radius: 4px;
  padding: 1px 5px;
}
/* Fenced code block: filled, rounded, horizontally scrollable (Memento) */
.fmt-render pre.fmt-code {
  margin: 0;
  background: var(--content-bg2);
  border: 1px solid var(--content-border-soft);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}
.fmt-render pre.fmt-code code {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
  background: none;
  border: 0;
  padding: 0;
  color: var(--content-text);
}
/* Headings: left aligned and heading sized (Memento); # and ## largest, ### smaller */
.fmt-render .fmt-h1, .fmt-render .fmt-h3 {
  text-align: left;
  font-weight: 800;
  color: var(--content-text);
  line-height: 1.3;
}
.fmt-render .fmt-h1 { font-size: 20px; }
.fmt-render .fmt-h3 { font-size: 16px; }
.fmt-render .fmt-hr {
  border: 0;
  border-top: 1px solid var(--content-border);
  margin: 8px 0;
}
.fmt-render .fmt-note { color: var(--content-text3); font-style: italic; }

/* Spoiler: covered block that reveals on tap */
.doc-spoiler {
  background: var(--content-text);
  color: transparent;
  border-radius: 4px;
  padding: 0 5px;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, color .15s ease;
}
.doc-spoiler.revealed {
  background: rgba(11,46,41,.08);
  color: var(--content-text2);
}

/* Support matrix */
.fmt-table-wrap { margin: 18px 0 28px; overflow-x: auto; }
table.fmt-matrix {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}
table.fmt-matrix th, table.fmt-matrix td {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--content-border-soft);
}
table.fmt-matrix thead th {
  background: var(--content-bg2);
  color: var(--content-text);
  font-weight: 600;
}
table.fmt-matrix tbody td:first-child {
  font-weight: 600;
  color: var(--content-text);
}
table.fmt-matrix td.y { color: var(--accent); font-weight: 600; }
table.fmt-matrix td.n { color: var(--content-text3); }

@media (max-width: 640px) {
  .fmt-row { grid-template-columns: 1fr; }
  .fmt-type { border-right: 0; border-bottom: 1px solid var(--content-border-soft); }
}

/* Figures / screenshots */
figure.doc-figure {
  margin: 26px 0 30px;
  text-align: center;
}
/* Default: show the image whole at its own aspect ratio (height follows the
   image), capped so nothing runs absurdly tall. This lets short and wide images
   render un-cropped. */
figure.doc-figure img {
  width: auto;
  height: auto;
  max-width: min(78%, 280px);
  max-height: 562px;
  object-fit: contain;
  border-radius: 26px;
  border: 1px solid var(--content-border-soft);
  box-shadow: 0 10px 34px rgba(11,46,41,.12);
  background: var(--content-bg2);
  display: block;
  margin: 0 auto;
}
/* Tall portrait screenshots (full iPhone 15 Pro captures) are shown in a fixed,
   height-capped phone-width box that crops a sliver off the top and bottom, so
   the status bar and the space below the bottom nav are trimmed away. */
figure.doc-figure.tall img {
  width: 280px;
  max-width: 78%;
  height: 562px;
  max-height: 562px;
  object-fit: cover;
  /* bias the crop toward the bottom so the top (status bar) is trimmed more */
  object-position: center 65%;
}
figure.doc-figure figcaption {
  font-size: 12.5px;
  color: var(--content-text3);
  margin-top: 12px;
  line-height: 1.5;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

/* ── GLOSSARY ──────────────────────────────────────────────────────────────── */
.glossary-az {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 28px;
}
.glossary-az a {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--content-text2);
  text-decoration: none;
  border: 1px solid var(--content-border-soft);
  border-radius: 5px;
  padding: 4px 8px;
  min-width: 28px;
  text-align: center;
}
.glossary-az a:hover { border-color: var(--accent); color: var(--accent); }
.glossary-letter {
  font-family: 'Fraunces', serif;
  font-size: 18px; font-weight: 700;
  color: var(--accent);
  margin: 30px 0 10px;
  scroll-margin-top: 84px;
}
dl.glossary { margin: 0; }
dl.glossary dt {
  font-weight: 600;
  color: var(--content-text);
  font-size: 15px;
  margin-top: 18px;
  scroll-margin-top: 84px;
}
dl.glossary dd {
  margin: 4px 0 0;
  color: var(--content-text2);
  line-height: 1.7;
  font-size: 14.5px;
}

/* ── FOOTER ────────────────────────────────────────────────────────────────── */
.site-footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--content-border-soft);
  background: var(--content-bg2);
  padding: 30px 48px 40px;
  font-size: 13px;
  color: var(--content-text3);
}
.site-footer-inner { max-width: 760px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center; }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .footer-updated { font-family: 'DM Mono', monospace; font-size: 12px; }
.site-footer .footer-copy { width: 100%; color: var(--content-text3); }

/* ── SCROLL PROGRESS ───────────────────────────────────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: 2px;
  background: var(--sidebar-accent);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 100;
  transition: transform .05s linear;
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 260px; }
}
@media (max-width: 900px) {
  .content-inner { padding: 0 32px 24px; }
  .site-footer { padding: 30px 32px 40px; }
}
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  .mobile-header { display: flex; }
  body { padding-top: 52px; }
  .sidebar {
    width: 300px;
    padding-top: 52px;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    top: 0;
  }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; }
  .content-inner { padding: 0 20px 20px; }
  .site-footer { margin-left: 0; padding: 26px 20px 36px; }
  .doc-title { font-size: 28px; }
  .doc-section { padding-top: 32px; }
  .progress-bar { left: 0; }
  figure.doc-figure img { max-width: 260px; }
}
@media (max-width: 400px) {
  .doc-title { font-size: 24px; }
  .content-inner { padding: 0 16px 16px; }
}

/* ── SEARCH HIGHLIGHT ──────────────────────────────────────────────────────── */
.sidebar-doc.search-hidden { display: none; }

/* ── WELCOME / ILLUSTRATION FIGURES ────────────────────────────────────────── */
/* Phone render for What Folkic Is (near text-column width, slightly inset). */
figure.doc-figure.phone { margin: 30px 0 34px; }
figure.doc-figure.phone img {
  width: 600px;
  max-width: 92%;
  aspect-ratio: auto;
  object-fit: contain;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: none;
}
/* Full-bleed shards hero banner across the whole content area, right of the sidebar.
   Sits between each category header and its body, in place of the old divider. */
.category-hero {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100vw - var(--sidebar-w));
  max-width: none;
  height: 210px;
  margin: 0 0 18px;
  background: url('/img/shards.png') no-repeat center bottom;
  background-size: 1500px auto;
}
.store-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 22px 0 8px;
}
.store-badges a { border: none; }
.store-badges img {
  height: 46px;
  width: auto;
  display: block;
}
@media (max-width: 700px) {
  .category-hero { height: 150px; background-size: 820px auto; margin-bottom: 14px; }
  .store-badges img { height: 42px; }
}

/* ── EDITORIAL LEDE (category intro paragraph) ─────────────────────────────── */
.doc-body .doc-lede {
  font-size: 15px;
  line-height: 1.8;
  color: var(--content-text);
  margin: 0 0 8px;
}
.doc-body .doc-lede + h2 { margin-top: 34px; }
