/* Second Brain method page, after the Promptotyping start page as reference. Loads after the
   shared DHCraft tokens and building blocks under assets/dhcraft/, whose rules sit in the
   layer dh and lose to every layer declared here. The explorer pages load this file too, for
   the short role names and the reading styles. */
@layer dh, reset, base, layout, components, utilities;

/* Site roles, all derived from the shared tokens. The page opens light: index.html sets
   data-theme="light", and the toggle switches to the shared dark values. */
:root {
  --ground: var(--dh-ground);
  --ground-alt: var(--dh-ground-alt);
  --surface: var(--dh-surface);
  --ink: var(--dh-ink);
  --ink-soft: var(--dh-ink-soft);
  --ink-faint: var(--dh-ink-soft);
  --edge: var(--dh-line);
  --edge-hi: var(--dh-line-strong);
  --accent: var(--dh-accent);
  --accent-hi: var(--dh-link);
  --on-accent: var(--dh-on-accent);
  --focus: var(--dh-focus);
  --font: var(--dh-font-text);
  --display: var(--dh-font-display);
  --mono: var(--dh-font-mono);
  --step--1: var(--dh-step--1);
  --step-0: var(--dh-step-0);
  --step-1: var(--dh-step-1);
  --step-2: var(--dh-step-2);
  --step-3: var(--dh-step-3);
  --gutter: var(--dh-gutter);
  --wide: var(--dh-page);
  --measure: var(--dh-measure);
  --g-control: light-dark(var(--dh-blue-deep), var(--dh-blue));
  /* The figure is a light plate in both schemes, so it reads the same on a page, in a paper
     and on a slide. */
  --plate: var(--dh-paper);
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, h4, p, ol, ul, dl, dd, figure, pre { margin: 0; }
  ol, ul { padding: 0; list-style: none; }
  img, svg { display: block; max-inline-size: 100%; }
  button, input, select { font: inherit; color: inherit; }
}

@layer base {
  html { scroll-padding-block-start: 1rem; }
  @media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
  body { -webkit-font-smoothing: antialiased; }
  code { overflow-wrap: anywhere; }
  [hidden] { display: none !important; }
  .icon-set { display: none; }
}

@layer layout {
  .site-head .dh-brand img { block-size: 2rem; inline-size: auto; }
  .head-tools { display: flex; gap: var(--dh-space-1); align-items: center; margin-inline-start: auto; }
  @media (max-width: 47.99rem) { .site-head { gap: 0 var(--dh-space-2); } .site-head .head-tools { order: 2; } .site-head .dh-nav { order: 3; } }

  .page { max-inline-size: var(--wide); margin-inline: auto; padding: 0 var(--gutter); }
  .part { display: grid; gap: var(--dh-space-4); padding-block: var(--dh-space-7); border-block-start: var(--dh-hairline) solid var(--edge); }
  .part > p { max-inline-size: var(--measure); color: var(--ink-soft); }
  .dh-foot { margin-block-start: 0; }
}

@layer components {
  .icon-button { display: inline-flex; align-items: center; justify-content: center; inline-size: 2.5rem; block-size: 2.5rem; border: 0; border-radius: var(--dh-radius-pill); background: transparent; color: var(--ink-soft); cursor: pointer; }
  .icon-button:hover, .icon-button:focus-visible { color: var(--ink); background: var(--ground-alt); }
  .icon-button svg { inline-size: 1.2rem; block-size: 1.2rem; }
  .lang { display: inline-flex; align-items: center; justify-content: center; min-inline-size: 2.5rem; block-size: 2.5rem; border-radius: var(--dh-radius-pill); color: var(--ink-soft); font-weight: 600; font-size: var(--step--1); text-decoration: none; }
  .lang:hover, .lang:focus-visible { color: var(--ink); background: var(--ground-alt); }
  .icon { inline-size: 1.1rem; block-size: 1.1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

  /* Title, abstract, main figure and the prose that explains it. */
  .intro { display: grid; gap: var(--dh-space-5); padding-block: var(--dh-space-7); }
  .intro .lead { max-inline-size: var(--measure); font-size: var(--step-1); line-height: 1.5; }
  .main-figure { border-radius: var(--dh-radius-m); background: var(--plate); border: var(--dh-hairline) solid var(--edge); }
  .main-figure img { inline-size: 100%; block-size: auto; }
  /* On phones the figure keeps a legible size and scrolls sideways inside its frame. */
  @media (max-width: 47.99rem) { .main-figure { overflow-x: auto; } .main-figure img { inline-size: 56rem; max-inline-size: none; } }
  .prose-intro { display: grid; gap: var(--dh-space-3); max-inline-size: var(--measure); }
  .prose-intro p { color: var(--ink); }

  /* Files to take away: one visibly separate block with one control per item. */
  .takeaway { display: flex; flex-wrap: wrap; gap: var(--dh-space-3); padding: var(--dh-space-5); border-radius: var(--dh-radius-m); background: var(--ground-alt); border: var(--dh-hairline) solid var(--edge); }

  /* Numbered steps; a step name or instruction shares the row above its block with the copy
     button. */
  .steps { display: grid; gap: var(--dh-space-5); counter-reset: step; max-inline-size: 56rem; }
  .steps > li { counter-increment: step; position: relative; padding-inline-start: 2.6rem; display: grid; gap: var(--dh-space-1); }
  .steps > li::before {
    content: counter(step); position: absolute; inset-inline-start: 0; inset-block-start: 0.2rem;
    inline-size: 1.8rem; block-size: 1.8rem; display: grid; place-items: center; border-radius: 50%;
    border: 2px solid var(--accent); color: var(--accent); font-weight: 600; font-size: var(--step--1); font-variant-numeric: tabular-nums;
  }
  .steps .dh-code { margin: 0; }
  .steps .dh-code figcaption { display: flex; gap: var(--dh-space-2); align-items: center; color: var(--ink); font-size: var(--step-0); }
  .steps .dh-code figcaption .icon { color: var(--ink-soft); }
  .dh-code pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.86rem; }
  .yields { color: var(--ink-soft); font-size: var(--step--1); }
  .part > .dh-code { margin: 0; max-inline-size: 56rem; }
  .plain { display: grid; gap: var(--dh-space-2); max-inline-size: var(--measure); }
  .plain li { color: var(--ink-soft); }

  /* Reading styles of the explorer pages. */
  .prose { display: grid; gap: var(--dh-space-3); min-inline-size: 0; overflow-wrap: anywhere; }
  .prose h1 { font-size: var(--step-2); }
  .prose h2 { font-size: var(--step-1); margin-block-start: var(--dh-space-2); }
  .prose h3, .prose h4 { font-size: var(--step-0); }
  .prose ul, .prose ol { padding-inline-start: 1.3rem; list-style: revert; }
  .prose pre { background: var(--ground-alt); padding: var(--dh-space-3); border-radius: var(--dh-radius-s); overflow-x: auto; }
  .prose table { font-size: var(--step--1); display: block; overflow-x: auto; border-collapse: collapse; }
  .prose th, .prose td { text-align: start; vertical-align: top; padding: var(--dh-space-2) var(--dh-space-3) var(--dh-space-2) 0; border-block-end: 1px solid var(--edge); }
  .prose blockquote, .prose .callout { margin: 0; padding: var(--dh-space-2) var(--dh-space-4); border-inline-start: 3px solid var(--accent); background: var(--ground-alt); border-radius: var(--dh-radius-s); }
  .prose .callout-title { font-weight: 700; }
  .prose .inline-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.15rem var(--dh-space-3); font-size: var(--step--1); }
  .prose .inline-fields dt { font-family: var(--mono); color: var(--ink-soft); }
  .prose .block-id, .prose .footnotes { font-size: var(--step--1); color: var(--ink-soft); }
  .prose .dead-link { color: var(--ink-soft); text-decoration: line-through; }
  .frontmatter { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.1rem var(--dh-space-3); font-family: var(--mono); font-size: var(--step--1); background: var(--ground-alt); padding: var(--dh-space-2) var(--dh-space-3); border-radius: var(--dh-radius-s); }
  .frontmatter dt { color: var(--ink-soft); }
}

@layer utilities {
  .visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
