/* editor-content — the post body's styles, all inside @scope (.editor-content) */

/* type scale: headings 1.875 -> 1rem at 600, body 1.125rem, 1.5rem block rhythm; headings open their section with extra air above */
@scope (.editor-content) {
  /* --- headings --- */
  /* (anchor-jump scroll-margins live in interactive.css) */
  h2 {
    color: var(--text-primary);
    font-size: calc(1.875rem * var(--reader-scale, 1));
    font-weight: 600;
    line-height: 1.26667;
    margin-block-start: 3rem;
    margin-block-end: 1.25rem;
    @media (width <= 375px) {
      font-size: calc(1.5rem * var(--reader-scale, 1));
      line-height: 1.33333;
      margin-block-end: 1rem;
    }
  }
  h3 {
    color: var(--text-primary);
    font-size: calc(1.5rem * var(--reader-scale, 1));
    font-weight: 600;
    line-height: 1.33333;
    margin-block-start: 2.25rem;
    margin-block-end: 1rem;
    @media (width <= 375px) {
      font-size: calc(1.25rem * var(--reader-scale, 1));
      line-height: 1.5;
      margin-block-end: 0.75rem;
    }
  }
  h4 {
    color: var(--text-primary);
    font-size: calc(1.25rem * var(--reader-scale, 1));
    font-weight: 600;
    line-height: 1.5;
    margin-block-start: 2rem;
    margin-block-end: 1rem;
    @media (width <= 375px) {
      font-size: calc(1.125rem * var(--reader-scale, 1));
      line-height: 1.55556;
      margin-block-end: 0.75rem;
    }
  }
  h5 {
    color: var(--text-primary);
    font-size: calc(1.125rem * var(--reader-scale, 1));
    font-weight: 600;
    line-height: 1.55556;
    margin-block-end: 0.75rem;
  }
  h6 {
    color: var(--text-primary);
    font-size: calc(1rem * var(--reader-scale, 1));
    font-weight: 600;
    line-height: 1.5;
    margin-block-end: 0.75rem;
  }
  /* a heading opening the body sits flush */
  :scope > :first-child {
    margin-block-start: 0;
  }

  /* --- body text --- */
  /* body text, headings and code scale with --reader-scale (text-size.js) */
  p {
    color: var(--text-tertiary);
    font-size: calc(1.125rem * var(--reader-scale, 1));
    line-height: 1.55556;
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      font-size: calc(1rem * var(--reader-scale, 1));
      line-height: 1.5;
      margin-block-end: 1.25rem;
    }
  }
  /* running-text links only, so kg-card links stay untouched */
  p a,
  li a {
    color: var(--text-brand-secondary);
    text-decoration: underline;
    text-underline-offset: 0.125em;
  }
  strong {
    color: var(--text-secondary);
    font-weight: 600;
  }

  /* --- lists --- */
  ul,
  ol {
    color: var(--text-tertiary);
    font-size: calc(1.125rem * var(--reader-scale, 1));
    line-height: 1.55556;
    padding-inline-start: 1.5rem;
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      font-size: calc(1rem * var(--reader-scale, 1));
      line-height: 1.5;
      margin-block-end: 1.25rem;
    }
  }
  li + li {
    margin-block-start: 0.75rem;
  }
  li::marker {
    color: var(--fg-quaternary);
  }
  /* nested lists stay inside their parent's rhythm */
  li > ul,
  li > ol {
    margin-block: 0.75rem 0;
  }

  /* --- quotes --- */
  blockquote {
    padding-inline-start: 1.25rem;
    border-inline-start: 3px solid var(--utility-brand-700);
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      margin-block-end: 1.25rem;
    }
  }
  blockquote p {
    color: var(--text-primary);
    font-size: calc(1.25rem * var(--reader-scale, 1));
    line-height: 1.5;
    margin-block-end: 0;
    @media (width <= 375px) {
      font-size: calc(1.125rem * var(--reader-scale, 1));
      line-height: 1.55556;
    }
  }
  blockquote p + p {
    margin-block-start: 1rem;
  }

  /* --- code --- */
  /* (the font-family comes from the global pre/code rule, theme.css) */
  code {
    font-size: 0.875em;
    padding: 0.125em 0.375em;
    border-radius: 0.25rem;
    color: var(--utility-gray-blue-700);
    background-color: var(--utility-gray-blue-50);
    border: 1px solid var(--utility-gray-blue-200);
  }
  pre {
    padding: 1.25rem;
    border-radius: 0.5rem;
    background-color: var(--utility-gray-blue-50);
    border: 1px solid var(--utility-gray-blue-200);
    margin-block-end: 1.5rem;
    /* thin scrollbar on hover devices only; touch hides it */
    overflow-x: auto;
    scrollbar-width: none;
    @media (hover: hover) {
      scrollbar-width: thin;
      scrollbar-color: var(--fg-quaternary) transparent;
    }
    @media (width <= 375px) {
      margin-block-end: 1.25rem;
    }
  }
  pre code {
    display: block;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-secondary);
    /* scales with the zoom controls; inline code follows its paragraph via em */
    font-size: calc(0.875rem * var(--reader-scale, 1));
    line-height: 1.5;
  }

  /* syntax highlighting: Prism tokenizes, the utility-*-700 tokens color */
  pre code .token.comment,
  pre code .token.prolog,
  pre code .token.cdata {
    color: var(--fg-quaternary);
    font-style: italic;
  }
  pre code .token.punctuation,
  pre code .token.operator {
    color: var(--text-tertiary);
  }
  pre code .token.keyword,
  pre code .token.atrule,
  pre code .token.rule,
  pre code .token.important {
    color: var(--utility-purple-700);
  }
  pre code .token.selector,
  pre code .token.tag {
    color: var(--utility-pink-700);
  }
  pre code .token.property,
  pre code .token.attr-name,
  pre code .token.variable {
    color: var(--utility-indigo-700);
  }
  pre code .token.string,
  pre code .token.char,
  pre code .token.attr-value,
  pre code .token.url {
    color: var(--utility-blue-light-700);
  }
  pre code .token.number,
  pre code .token.boolean {
    color: var(--utility-orange-700);
  }
  pre code .token.function,
  pre code .token.class-name {
    color: var(--utility-brand-700);
  }

  /* code toolbar: copy-code.js puts the wrap + copy buttons in flow above the pre */
  .code-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-block-end: 0.5rem;
    /* narrow screens: scroll sideways like the nav, don't wrap */
    overflow-x: auto;
    scrollbar-width: none;
    @media (hover: hover) {
      scrollbar-width: thin;
      scrollbar-color: var(--fg-quaternary) transparent;
    }
  }
  .code-toolbar > * {
    flex-shrink: 0;
  }
  .code-toolbar button {
    display: grid;
    place-items: center; /* icon buttons: no baseline gap */
    padding: 0.25rem 0.625rem;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    cursor: pointer;
  }
  /* language label: painted from data-lang, plain colored text parked on the start edge */
  .code-toolbar[data-lang]::before {
    content: attr(data-lang);
    flex-shrink: 0;
    margin-inline-end: auto;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-brand-secondary);
    text-transform: lowercase;
  }
  .code-toolbar button.is-copied,
  .code-toolbar button[aria-pressed="true"] {
    color: var(--utility-brand-700);
    border-color: var(--utility-brand-200);
    background-color: var(--utility-brand-50);
  }
  .code-block.is-wrapped pre code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  /* --- media --- */
  img {
    display: block;
    max-inline-size: 100%;
    block-size: auto;
    margin-inline: auto;
    border-radius: 0.5rem;
  }
  figure {
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      margin-block-end: 1.25rem;
    }
  }
  /* inside a code card the figure owns the block gap */
  .kg-code-card pre {
    margin-block-end: 0;
  }
  figcaption {
    margin-block-start: 0.75rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    line-height: 1.42857;
  }

  /* --- divider --- */
  hr {
    border: none;
    border-block-start: 1px solid var(--border-primary);
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      margin-block-end: 1.25rem;
    }
  }

  /* --- tables --- */
  table {
    inline-size: 100%;
    border-collapse: collapse;
    margin-block-end: 1.5rem;
    line-height: 1.5;
  }
  th {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: start;
  }
  td {
    color: var(--text-tertiary);
    font-size: 1rem;
  }
  th,
  td {
    padding: 0.75rem 1rem;
    border-block-end: 1px solid var(--border-primary);
  }

  /* --- Ghost width variations --- */
  .kg-width-wide {
    --wide-size: min(65rem, 100vi - 2rem);
    inline-size: var(--wide-size);
    margin-inline-start: calc(50% - var(--wide-size) / 2);
  }
  .kg-width-full {
    inline-size: 100vi;
    margin-inline-start: calc(50% - 50vi);
  }
  .kg-width-full img {
    border-radius: 0;
  }

  /* --- Ghost cards --- */
  /* cards.min.css loads after this file; the :scope prefix out-ranks it */

  /* block rhythm for the div-based cards */
  :scope .kg-callout-card,
  :scope .kg-toggle-card,
  :scope .kg-button-card,
  :scope .kg-product-card,
  :scope .kg-file-card,
  :scope .kg-collection-card,
  :scope .kg-header-card,
  :scope .kg-signup-card,
  :scope .kg-cta-card {
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      margin-block-end: 1.25rem;
    }
  }

  /* callout: Ghost's translucent ground stays, the text is retinted */
  :scope .kg-callout-text {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
  }
  :scope .kg-callout-card-accent .kg-callout-text {
    color: var(--text-white);
  }

  /* bookmark */
  :scope .kg-bookmark-container {
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    overflow: hidden;
    text-decoration: none;
  }
  :scope .kg-bookmark-title {
    color: var(--text-primary);
  }
  :scope .kg-bookmark-description,
  :scope .kg-bookmark-metadata {
    color: var(--text-tertiary);
  }

  /* button + toggle follow the theme's shape and palette */
  :scope .kg-toggle-card {
    border-radius: 0.5rem;
  }
  :scope .kg-toggle-heading-text {
    color: var(--text-primary);
  }
  :scope .kg-toggle-content-text {
    color: var(--text-tertiary);
  }

  /* embeds scale down instead of overflowing the content column */
  :scope .kg-embed-card iframe {
    max-inline-size: 100%;
  }

  /* alt blockquote — centered pull-quote, so no side border */
  :scope .kg-blockquote-alt {
    border-inline-start: none;
    color: var(--text-secondary);
  }
  :scope .kg-blockquote-alt p {
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    margin-block-end: 0;
  }

  /* audio */
  :scope .kg-audio-card {
    border-radius: 0.5rem;
  }
  :scope .kg-audio-title {
    color: var(--text-primary);
  }

  /* file — cards.min.css hardcodes a white box; retint with tokens */
  :scope .kg-file-card-container {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
  }
  :scope .kg-file-card-title {
    color: var(--text-primary);
  }
  :scope .kg-file-card-metadata {
    color: var(--text-tertiary);
  }

  /* product — same hardcoded white box treatment */
  :scope .kg-product-card-container {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    box-shadow: none;
  }
  :scope .kg-product-card-title {
    color: var(--text-primary);
  }
  :scope .kg-product-card-description {
    color: var(--text-tertiary);
  }
  :scope .kg-product-card-button {
    font-family: inherit;
    border-radius: 0.5rem;
  }

  /* header / signup / cta controls follow the theme shape */
  :scope a.kg-header-card-button,
  :scope .kg-signup-card-button,
  :scope a.kg-cta-button {
    font-family: inherit;
    border-radius: 0.5rem;
  }
  :scope .kg-signup-card-input {
    border-radius: 0.5rem;
  }
  :scope .kg-cta-text {
    color: var(--text-secondary);
  }

  /* collection: sizes flattened to the 16px root; !important beats the column variants */
  :scope .kg-collection-card-title {
    font-size: 0.875rem !important;
    color: var(--text-brand-secondary);
  }
  :scope .kg-collection-card-content {
    font-size: 1rem !important;
  }
  :scope h2.kg-collection-card-post-title {
    font-size: 1.125rem !important;
    color: var(--text-primary);
  }
  :scope .kg-collection-card-post-excerpt {
    font-size: 1rem !important;
    color: var(--text-tertiary);
  }
  :scope .kg-collection-card-post-meta {
    font-size: 0.875rem !important;
  }
  :scope .kg-collection-card-list,
  :scope .kg-collection-card-post {
    gap: 2rem !important;
  }
  :scope .kg-collection-card-grid {
    gap: 1.5rem !important;
  }

  /* --- updates fold: the authored details.post-updates card --- */
  :scope .post-updates {
    margin-block-end: 1.5rem;
    @media (width <= 375px) {
      margin-block-end: 1.25rem;
    }
  }
  /* summary: a bare mono word; the two spans swap SHOW/HIDE with the fold state */
  :scope .post-updates summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
  }
  :scope .post-updates summary::-webkit-details-marker {
    display: none;
  }
  /* solid caret, the filter selects' recipe; flips while open */
  :scope .post-updates summary::after {
    content: "";
    border-inline: 0.25rem solid transparent;
    border-block-start: 0.3125rem solid currentcolor;
  }
  :scope .post-updates[open] summary::after {
    rotate: 180deg;
  }
  :scope .post-updates summary > span {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: inherit;
  }
  :scope .post-updates summary:hover {
    color: var(--accent-text);
  }
  :scope .post-updates .when-open,
  :scope .post-updates[open] .when-closed {
    display: none;
  }
  :scope .post-updates[open] .when-open {
    display: block;
  }
  /* entries: mono date gutter, sentence + optional diff rows right */
  :scope .post-updates ul {
    list-style: none;
    padding-inline-start: 0;
    margin-block: 1.25rem 0;
  }
  :scope .post-updates li {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1.25rem;
    row-gap: 0.5rem;
  }
  :scope .post-updates li + li {
    margin-block-start: 1.25rem;
  }
  :scope .post-updates time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.40625rem; /* absolute, matches the sentence line box */
    color: var(--text-tertiary);
  }
  :scope .post-updates li p,
  :scope .post-updates .diff {
    grid-column: 2;
  }
  :scope .post-updates li p {
    margin-block-end: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-secondary);
  }
  /* diff: stacked del/ins rows in one rounded box, red out, green in */
  :scope .post-updates .diff {
    justify-self: start;
    border-radius: 0.5rem;
    overflow: hidden;
    font-size: 0.9375rem;
    line-height: 1.5;
  }
  :scope .post-updates .diff del,
  :scope .post-updates .diff ins {
    display: block;
    padding: 0.375rem 0.875rem;
  }
  :scope .post-updates .diff del {
    color: var(--utility-red-700);
    background-color: color-mix(in srgb, var(--utility-red-700) 8%, transparent);
  }
  :scope .post-updates .diff ins {
    text-decoration: none;
    color: var(--utility-green-700);
    background-color: color-mix(in srgb, var(--utility-green-700) 8%, transparent);
  }
  /* code rows read as bare -/+ diff lines, no strikethrough */
  :scope .post-updates .diff code {
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font-size: 0.8125rem;
  }
  :scope .post-updates .diff del:has(> code) {
    text-decoration: none;
  }
  :scope .post-updates .diff del code::before {
    content: "- ";
  }
  :scope .post-updates .diff ins code::before {
    content: "+ ";
  }
}

