/*
 * Embedarium user guide — reading layout.
 * Builds on the tokens and components of style.css, so the light and dark
 * themes, buttons and focus rings match the rest of the site.
 */

.guide-main {
  padding-block: clamp(1.5rem, 1rem + 2vw, 2.5rem) clamp(4rem, 3rem + 3vw, 6rem);
}

.guide-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 13rem;
  gap: clamp(2rem, 1rem + 3vw, 3.5rem);
  align-items: start;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.guide-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  max-height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
  padding-right: 0.5rem;
  font-size: 0.9rem;
  scrollbar-width: thin;
}

.guide-nav__toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.guide-nav__toggle::-webkit-details-marker {
  display: none;
}

.guide-nav__toggle::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--dur-2);
}

.guide-nav[open] .guide-nav__toggle::after {
  transform: rotate(-135deg) translateY(-2px);
}

.guide-nav__home {
  margin: 1.25rem 0 0.25rem;
  font-weight: 600;
}

.guide-nav__group {
  margin-top: 1.5rem;
}

.guide-nav__title {
  margin-bottom: 0.5rem;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.guide-nav li a,
.guide-nav__home a {
  display: block;
  margin-left: -1px;
  padding: 0.3rem 0.75rem;
  border-left: 2px solid transparent;
  color: var(--text-2);
  line-height: 1.45;
  text-decoration: none;
  transition: color var(--dur-1), border-color var(--dur-1);
}

.guide-nav__home a {
  padding-left: 0;
  border-left: 0;
  color: var(--text);
}

.guide-nav li a:hover,
.guide-nav__home a:hover {
  color: var(--text);
  border-left-color: var(--line-strong);
}

.guide-nav__home a:hover {
  color: var(--brand-ink);
}

.guide-nav a[aria-current='page'] {
  color: var(--brand-ink);
  border-left-color: var(--brand);
  font-weight: 600;
}

/* ── Search ──────────────────────────────────────────────────────────────── */

.guide-search {
  position: relative;
}

.guide-search__input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6878' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E")
    0.75rem center / 1rem no-repeat;
  color: var(--text);
  font-size: 1rem;
}

.guide-search__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(43 92 246 / 0.25);
}

.guide-search__results {
  margin-top: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.guide-search__results ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-search__results li + li {
  border-top: 1px solid var(--line);
}

.guide-search__results a {
  display: block;
  padding: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.guide-search__results a:hover,
.guide-search__results a:focus-visible {
  background: var(--bg-subtle);
}

.guide-search__page {
  display: block;
  color: var(--text-3);
  font-size: 0.75rem;
}

.guide-search__snippet {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-2);
  font-size: 0.8rem;
}

.guide-search__empty {
  margin: 0;
  padding: 0.75rem;
  color: var(--text-2);
}

/* ── Article ─────────────────────────────────────────────────────────────── */

.guide-article {
  min-width: 0;
  max-width: 48rem;
  color: var(--text);
  font-size: 1.0625rem;
  line-height: 1.75;
}

.guide-breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  color: var(--text-3);
  font-size: 0.875rem;
}

.guide-breadcrumbs li + li::before {
  content: '/';
  margin-right: 0.375rem;
  color: var(--line-strong);
}

.guide-breadcrumbs a {
  color: var(--text-2);
  text-decoration: none;
}

.guide-breadcrumbs a:hover {
  color: var(--brand-ink);
  text-decoration: underline;
}

.guide-article h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.guide-article h2 {
  margin: 3.5rem 0 0.875rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 1.625rem;
  line-height: 1.25;
  letter-spacing: -0.025em;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.guide-article h3 {
  margin: 2.25rem 0 0.5rem;
  font-size: 1.1875rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.guide-anchor {
  margin-left: 0.5rem;
  color: var(--text-3);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur-1);
}

h2:hover .guide-anchor,
h3:hover .guide-anchor,
.guide-anchor:focus-visible {
  opacity: 1;
}

.guide-article p,
.guide-article ul,
.guide-article ol {
  margin: 0 0 1.125rem;
}

.guide-article ul,
.guide-article ol {
  padding-left: 1.4rem;
}

.guide-article li {
  margin: 0.35rem 0;
}

.guide-article li > ul {
  margin: 0.35rem 0 0;
}

.guide-article a {
  color: var(--brand-ink);
  text-underline-offset: 3px;
}

.guide-lead {
  margin-bottom: 1.75rem !important;
  color: var(--text-2);
  font-size: 1.1875rem;
  line-height: 1.6;
}

.guide-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem !important;
}

.guide-role {
  padding: 0.15rem 0.625rem;
  border: 1px solid var(--brand-line);
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.75rem;
  font-weight: 600;
}

.guide-steps {
  padding-left: 0 !important;
  list-style: none;
  counter-reset: adim;
}

.guide-steps > li {
  position: relative;
  margin: 0.625rem 0;
  padding-left: 2.5rem;
  counter-increment: adim;
}

.guide-steps > li::before {
  content: counter(adim);
  position: absolute;
  left: 0;
  top: 0.15rem;
  display: grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border: 1px solid var(--brand-line);
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.guide-article :not(pre) > code {
  font-size: 0.85em;
}

.guide-code {
  margin: 0 0 1.375rem;
  padding: 1rem 1.125rem;
  overflow-x: auto;
  border: 1px solid #1f2a3d;
  border-radius: var(--r-md);
  background: #0a101d;
  color: #e7ecf4;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

.guide-code code {
  font-size: inherit;
}

kbd {
  padding: 0.1em 0.45em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 0.8em;
  white-space: nowrap;
}

.guide-figure {
  margin: 1.5rem 0 1.75rem;
}

.guide-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-2);
}

.guide-figure__link {
  display: block;
  width: fit-content;
  max-width: 100%;
  border-radius: var(--r-md);
  cursor: zoom-in;
}

.guide-figure figcaption {
  margin-top: 0.75rem;
  color: var(--text-3);
  font-size: 0.875rem;
  line-height: 1.55;
}

.callout {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--r-md);
  background: var(--surface);
}

.callout p {
  margin: 0 0 0.5rem !important;
}

.callout p:last-child {
  margin-bottom: 0 !important;
}

.callout__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.callout--note {
  border-left-color: var(--brand);
}

.callout--note .callout__label {
  color: var(--brand-ink);
}

.callout--tip {
  border-left-color: var(--ok);
}

.callout--tip .callout__label {
  color: var(--ok);
}

.callout--warning {
  border-color: transparent;
  border-left-color: #d97706;
  background: var(--warn-soft);
}

.callout--warning .callout__label {
  color: var(--warn-ink);
}

.guide-table {
  margin: 0 0 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.guide-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.guide-table th,
.guide-table td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.guide-table thead th {
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guide-table tbody th {
  font-weight: 600;
}

.guide-table tr:last-child th,
.guide-table tr:last-child td {
  border-bottom: 0;
}

.guide-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.guide-updated {
  margin-top: 3rem !important;
  color: var(--text-3);
  font-size: 0.875rem;
}

.guide-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.guide-pager a {
  display: block;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--text);
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}

.guide-pager a:hover {
  border-color: var(--brand-line);
  box-shadow: var(--shadow-2);
}

.guide-pager span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide-pager__prev span::before {
  content: '← ';
}

.guide-pager__next {
  grid-column: 2;
  text-align: right;
}

.guide-pager__next span::after {
  content: ' →';
}

.guide-help {
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.9375rem;
}

/* ── On-page contents ────────────────────────────────────────────────────── */

.guide-toc {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  max-height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
  font-size: 0.875rem;
}

.guide-toc__title {
  margin-bottom: 0.75rem;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.guide-toc a {
  display: block;
  margin-left: -1px;
  padding: 0.3rem 0 0.3rem 0.875rem;
  border-left: 2px solid transparent;
  color: var(--text-2);
  line-height: 1.4;
  text-decoration: none;
}

.guide-toc a:hover {
  color: var(--text);
}

.guide-toc a.is-active {
  color: var(--brand-ink);
  border-left-color: var(--brand);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .guide-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .guide-toc {
    display: none;
  }
}

@media (max-width: 860px) {
  .guide-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .guide-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .guide-nav__toggle {
    display: flex;
    margin-top: 0.75rem;
  }

  .guide-nav nav {
    padding: 0 0.5rem;
  }

  .guide-article {
    font-size: 1rem;
  }

  .guide-pager {
    grid-template-columns: 1fr;
  }

  .guide-pager__next {
    grid-column: 1;
  }
}

@media print {
  .guide-sidebar,
  .guide-toc,
  .guide-pager,
  .guide-help,
  .guide-anchor {
    display: none !important;
  }

  .guide-layout {
    display: block;
  }

  .guide-article {
    max-width: none;
  }

  .guide-code {
    border-color: #ccc;
    background: #f5f5f5;
    color: #000;
  }
}
