/* Code annotated layouts for documentation code examples */


/* Inline code tokens (unchanged) */
:where(p, li, dd, figcaption) code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .95em;
  padding: .15em .35em;
  border-radius: .3rem;
  background: color-mix(in srgb, currentColor 8%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Subtle link styling ONLY for code-wrapped links */
a.code-link {
  text-decoration: underline dotted;
  text-underline-offset: 2px;         /* keep your spacing */
  text-decoration-thickness: 1px;     /* prevents dots from merging */
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}

/* Make the code inherit the link decoration (avoids double underline) */
a.code-link > code { text-decoration: inherit; }

/* Stronger cue on hover/focus */
a.code-link:hover,
a.code-link:focus-visible {
  text-decoration-style: solid;
  text-decoration-color: currentColor;
}

/* Keyboard focus ring that matches the chip */
a.code-link:focus-visible > code {
  outline: 2px solid color-mix(in srgb, currentColor 50%, transparent);
  outline-offset: 2px;
  border-radius: .3rem;
}

/* High-contrast / forced colors fallback */
@media (forced-colors: active) {
  a.code-link { text-decoration: underline; }
}


/* Visible keyboard focus without shifting layout */
a:focus-visible > code {
  outline: 2px solid color-mix(in srgb, currentColor 50%, transparent);
  outline-offset: 2px;
  border-radius: .3rem; /* match your chip radius */
}


.code-annotated {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 360px);
  gap: 1rem;
  align-items: start;
  margin: var(--space-6) 0;
}

.code-annotated .code-annotated-toolbar {
  display: none;
  /* only on small screens */
  gap: .5rem;
  margin-bottom: .5rem;
}

/* Toolbar buttons styled similar to code tabs (mobile toggle) */
.code-annotated .code-annotated-toolbar button {
  border: 1px solid var(--neutral-700);
  background: var(--neutral-900);
  color: var(--neutral-200);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.code-annotated .code-annotated-toolbar button:hover {
  border-color: rgba(var(--primary-rgb), 0.5);
}

.code-annotated .code-annotated-toolbar button[aria-pressed="true"] {
  background: var(--color-primary);
  color: var(--neutral-50);
  border-color: rgba(var(--primary-rgb), 0.6);
}

.code-pane {
  position: relative;
  min-width: 0;
}

.code-annotated .code-pane > .code-block {
  margin: 0;
}

.code-pane pre {
  margin: 0;
  position: relative;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.code-pane pre code {
  position: relative;
  z-index: 2;
  white-space: inherit;
  word-break: normal;
  overflow-wrap: normal;
}

/* Schema tabs now use generic code-tabs; follow active panel attribute */
.code-annotated[data-code-tabs="schema"][data-active-panel] .code-block[data-panel] {
  display: none;
}

.code-annotated[data-code-tabs="schema"][data-active-panel="schema"] .code-block[data-panel="schema"],
.code-annotated[data-code-tabs="schema"][data-active-panel="minimal"] .code-block[data-panel="minimal"],
.code-annotated[data-code-tabs="schema"][data-active-panel="full"] .code-block[data-panel="full"] {
  display: block;
}

.code-annotated[data-code-tabs="schema"][data-active-panel]:not([data-active-panel="schema"]) .notes {
  display: none;
}

/* Align schema tabs container with code-tabs styles */
.code-annotated[data-code-tabs="schema"] .code-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  grid-column: 1 / -1;
}

/* Make schema tab buttons look like .code-tab */
.code-annotated[data-code-tabs="schema"] .code-tab {
  border: 1px solid var(--neutral-700);
  background: var(--neutral-900);
  color: var(--neutral-200);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.code-annotated[data-code-tabs="schema"] .code-tab:hover {
  border-color: rgba(var(--primary-rgb), 0.5);
}

.code-annotated[data-code-tabs="schema"] .code-tab[aria-pressed="true"] {
  background: var(--color-primary);
  color: var(--neutral-50);
  border-color: rgba(var(--primary-rgb), 0.6);
}

.notes {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: var(--space-3);
  background: linear-gradient(180deg, #f8fafc 0%, rgba(14, 165, 233, 0.06) 100%);
  border: 1px solid color-mix(in srgb, var(--color-primary) 14%, #e2e8f0);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.notes .note {
  cursor: pointer;
}

.note {
  position: relative;
  padding: .5rem .5rem .75rem;
  border-radius: .5rem;
  border: 1px solid color-mix(in srgb, #e2e8f0 70%, transparent);
  background: rgba(255, 255, 255, .72);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .15s ease;
}

.note + .note {
  margin-top: .5rem;
}

.note.active {
  border-color: color-mix(in srgb, var(--color-primary) 55%, #bfdbfe);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), .16) 0%, rgba(14, 165, 233, .12) 100%);
  box-shadow: 0 10px 24px -12px rgba(var(--primary-rgb), .55), 0 0 0 1px color-mix(in srgb, var(--color-primary) 30%, transparent);
  transform: translateX(2px);
}

.note h4 {
  margin: 0 0 .25rem;
  font-weight: 600;
}

.note .type {
  font-weight: 400;
  opacity: .8;
}

/* Badges for required/optional/default in schema notes */
.note h4 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .25rem .5rem;
}

/* Shared badge look applied via pseudo-elements */
.note[data-required] h4::after,
.note[data-required="conditional"][data-required-text] h4::after,
.note p[data-default]::before {
  display: inline-block;
  font-size: .75em;
  line-height: 1;
  padding: .2em .5em;
  border-radius: .375rem;
  border: 1px solid transparent;
  font-weight: 600;
  letter-spacing: .01em;
}

/* Required badge */
.note[data-required="true"] h4::after {
  content: "Required";
  background: #fee2e2;            /* red-100 */
  color: #991b1b;                 /* red-800 */
  border-color: #fecaca;          /* red-200 */
}

/* Optional badge */
.note[data-required="false"] h4::after {
  content: "Optional";
  background: #f1f5f9;            /* slate-100 */
  color: #334155;                 /* slate-700 */
  border-color: #e2e8f0;          /* slate-200 */
}

/* Conditional required badge with custom text */
.note[data-required="conditional"][data-required-text] h4::after {
  content: attr(data-required-text);
  background: #fff7ed;            /* orange-50 */
  color: #9a3412;                 /* orange-800 */
  border-color: #fed7aa;          /* orange-200 */
}

/* Default value badge at the start of content (before first paragraph) */
.note p[data-default]::before {
  content: "Default: " attr(data-default);
  display: block;
  width: fit-content;
  margin: 0 0 .375rem 0;           /* top/right/bottom/left */
  background: #ecfeff;            /* cyan-50 */
  color: #155e75;                 /* cyan-800 */
  border-color: #a5f3fc;          /* cyan-200 */
}

/* High-contrast / forced colors fallback for badges */
@media (forced-colors: active) {
  .note[data-required] h4::after,
  .note[data-required="conditional"][data-required-text] h4::after,
  .note p[data-default]::before {
    border: 1px solid CanvasText;
    color: CanvasText;
    background: Canvas;
  }
}

pre .line-highlight {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

/* Ensure un-tokenized code is legible on dark themes */
.code-block code,
.code-pane code {
  color: #e5e7eb;
}

/* Ensure base code color overrides Prism's base in our panes */
.code-annotated pre code[class*="language-"],
.code-block pre code[class*="language-"] {
  color: #e5e7eb;
  text-shadow: none;
  white-space: inherit;
  word-break: normal;
  overflow-wrap: normal;
}

/* Identifier color (variables/constants/symbols) to complement theme */
.code-annotated .token.variable,
.code-annotated .token.constant,
.code-annotated .token.symbol,
.code-block .token.variable,
.code-block .token.constant,
.code-block .token.symbol {
  color: #9cdcfe;
}

/* Highlight the code token itself when focused from notes */
.code-token-hl {
  background: rgba(255, 208, 0, .35);
  border-radius: .25rem;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}

@media (max-width: 900px) {
  .code-annotated {
    grid-template-columns: 1fr;
  }

  .code-annotated .code-annotated-toolbar {
    display: flex;
  }

  .code-pane,
  .notes {
    display: none;
  }

  .code-annotated[data-view="code"] .code-pane {
    display: block;
  }

  .code-annotated[data-view="details"] .notes {
    display: block;
  }

  .notes {
    position: static;
    max-height: none;
  }

  .code-annotated .code-annotated-toolbar button[aria-pressed="true"] {
    outline: 2px solid currentColor;
  }

  .code-annotated[data-code-tabs="schema"][data-active-panel]:not([data-active-panel="schema"]) .code-annotated-toolbar {
    display: none;
  }
}
