/* Capy — monochromatic theme override.
 *
 * Loaded AFTER home.css via extra_css. Pushes the site to a
 * white / black / grey palette, tightens the type hierarchy, makes
 * headers bold, and replaces the Material palette toggle (a plain
 * icon button) with a proper iOS-style slider switch.
 */

/* ─── Palette: light ─────────────────────────────────────────────── */

[data-md-color-scheme="default"] {
  /* Ink + paper */
  --md-default-bg-color:           #ffffff;
  --md-default-fg-color:           #111111;
  --md-default-fg-color--light:    #4a4a4a;
  --md-default-fg-color--lighter:  #707070;
  --md-default-fg-color--lightest: #a0a0a0;

  /* Primary chrome stays grey-on-white; we don't want a coloured topbar. */
  --md-primary-fg-color:           #111111;
  --md-primary-fg-color--light:    #2a2a2a;
  --md-primary-fg-color--dark:     #000000;
  --md-primary-bg-color:           #ffffff;
  --md-primary-bg-color--light:    #f4f4f4;

  /* Accents — links, focus rings, eyebrow tags. Use a single grey
     so the eye isn't pulled to a coloured highlight. */
  --md-accent-fg-color:            #000000;
  --md-accent-fg-color--transparent: rgba(0, 0, 0, 0.08);
  --md-accent-bg-color:            #ffffff;

  /* Code / details / tables — flat grey rails. */
  --md-code-bg-color:              #f4f4f4;
  --md-code-fg-color:              #1a1a1a;
  --md-typeset-a-color:            #000000;

  --capy-rule:                     #e6e6e6;
  --capy-surface-soft:             #f7f7f7;
  --capy-surface-card:             #fcfcfc;
}

/* ─── Palette: dark ──────────────────────────────────────────────── */

[data-md-color-scheme="slate"] {
  --md-default-bg-color:           #0e0e0e;
  --md-default-fg-color:           #f2f2f2;
  --md-default-fg-color--light:    #cfcfcf;
  --md-default-fg-color--lighter:  #9a9a9a;
  --md-default-fg-color--lightest: #6a6a6a;

  --md-primary-fg-color:           #0a0a0a;
  --md-primary-fg-color--light:    #1a1a1a;
  --md-primary-fg-color--dark:     #000000;
  --md-primary-bg-color:           #f2f2f2;
  --md-primary-bg-color--light:    #cfcfcf;

  --md-accent-fg-color:            #ffffff;
  --md-accent-fg-color--transparent: rgba(255, 255, 255, 0.10);
  --md-accent-bg-color:            #000000;

  --md-code-bg-color:              #1a1a1a;
  --md-code-fg-color:              #e8e8e8;
  --md-typeset-a-color:            #ffffff;

  --capy-rule:                     #2a2a2a;
  --capy-surface-soft:             #161616;
  --capy-surface-card:             #141414;
}

/* ─── Type hierarchy ─────────────────────────────────────────────── */
/* Material's stock h1/h2/h3 are subtle. We want bolder, tighter,
 * with clear size deltas so scanning works at a glance. */

.md-typeset h1 {
  font-weight: 800;
  font-size: 2.4em;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
  color: var(--md-default-fg-color);
}
.md-typeset h2 {
  font-weight: 800;
  font-size: 1.7em;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 2.4em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--capy-rule);
  color: var(--md-default-fg-color);
}
.md-typeset h3 {
  font-weight: 700;
  font-size: 1.25em;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 2em 0 0.5em;
  color: var(--md-default-fg-color);
}
.md-typeset h4 {
  font-weight: 700;
  font-size: 1.05em;
  margin: 1.6em 0 0.4em;
  color: var(--md-default-fg-color);
}
.md-typeset h5,
.md-typeset h6 {
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--md-default-fg-color);
}

.md-typeset p,
.md-typeset li {
  color: var(--md-default-fg-color);
  line-height: 1.65;
}

/* Inline + block code — neutral grey, no syntax-colour rainbow on the
 * page background. (Highlight.js inside fenced blocks still colours
 * tokens; we only flatten the surrounding chrome.) */
.md-typeset code {
  background: var(--md-code-bg-color);
  color: var(--md-code-fg-color);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.92em;
}
.md-typeset pre {
  background: var(--md-code-bg-color);
  border-radius: 8px;
}

/* Links — black underline (or white in dark). No coloured links. */
.md-typeset a {
  color: var(--md-typeset-a-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.md-typeset a:hover {
  text-decoration-thickness: 2px;
}

/* Top header — pure black band, no teal. */
.md-header {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}
.md-tabs {
  background: var(--md-primary-fg-color);
}

/* Buttons — outline-by-default, solid on hover. Monochrome only. */
.md-typeset .md-button {
  background: transparent;
  color: var(--md-default-fg-color);
  border: 1px solid var(--md-default-fg-color);
  border-radius: 6px;
  padding: 0.5em 1.1em;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.md-typeset .md-button:hover {
  background: var(--md-default-fg-color);
  color: var(--md-default-bg-color);
}
.md-typeset .md-button--primary {
  background: var(--md-default-fg-color);
  color: var(--md-default-bg-color);
  border-color: var(--md-default-fg-color);
}
.md-typeset .md-button--primary:hover {
  background: transparent;
  color: var(--md-default-fg-color);
}

/* Tables — clean grey lines, no zebra. */
.md-typeset table:not([class]) {
  border: 1px solid var(--capy-rule);
}
.md-typeset table:not([class]) th {
  background: var(--capy-surface-soft);
  color: var(--md-default-fg-color);
  font-weight: 700;
}
.md-typeset table:not([class]) td,
.md-typeset table:not([class]) th {
  border-color: var(--capy-rule);
}

/* Tabbed content — quieter active state. */
.md-typeset .tabbed-set > input:checked + label {
  color: var(--md-default-fg-color);
  border-color: var(--md-default-fg-color);
}

/* Admonitions — strip the colour bar; use a thicker grey rail. */
.md-typeset .admonition,
.md-typeset details {
  border-left: 4px solid var(--md-default-fg-color--lighter);
  background: var(--capy-surface-soft);
}

/* ─── Override hero + cards to monochrome ────────────────────────── */
/* Cancels the coloured radial gradients in home.css. */
.capy-hero {
  background: var(--capy-surface-soft) !important;
  border: 1px solid var(--capy-rule) !important;
}
.capy-eyebrow {
  background: transparent !important;
  border: 1px solid var(--md-default-fg-color) !important;
  color: var(--md-default-fg-color) !important;
  font-weight: 700;
}
.capy-section h2 { color: var(--md-default-fg-color) !important; }

.show-card,
.audience-card {
  background: var(--capy-surface-card) !important;
  border: 1px solid var(--capy-rule) !important;
}

/* ─── Toggle switch (replaces the palette icon-button) ───────────── */
/* Material renders the palette switcher as a hidden checkbox + a
 * <label> wrapping an icon. We hide the icon and draw a slider
 * switch in its place. CSS-only, no JS. */

.md-header__option [data-md-component="palette"] {
  /* tighten the container so the switch sits nicely in the header */
  padding: 0 8px;
}

/* Hide the original icon swap that Material renders. */
.md-header__option [for^="__palette"] .md-icon {
  display: none !important;
}

/* Respect the `hidden` attribute Material uses to swap which palette
 * button is active — without this, our display:inline-block below
 * would override the default display:none from `hidden`. */
.md-header__option [for^="__palette"][hidden] {
  display: none !important;
}

/* The label itself becomes the switch track. */
.md-header__option [for^="__palette"] {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.18s, border-color 0.18s;
  /* override Material's default sizing on the label container */
  padding: 0 !important;
  margin: 0 4px;
}

/* The knob — pure white circle that slides across. */
.md-header__option [for^="__palette"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s, background 0.18s;
}

/* Dark scheme active → slide the knob right + flip track colour. */
[data-md-color-scheme="slate"] .md-header__option [for^="__palette"] {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}
[data-md-color-scheme="slate"] .md-header__option [for^="__palette"]::after {
  transform: translateX(20px);
  background: #0a0a0a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Tiny sun / moon glyphs inside the track on each side (decoration only). */
.md-header__option [for^="__palette"]::before {
  content: "☀ ☾";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  font-size: 10px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
[data-md-color-scheme="slate"] .md-header__option [for^="__palette"]::before {
  color: rgba(255, 255, 255, 0.7);
}

/* ─────────────────────────────────────────────────────────────────────
   AI multi-target rendering pattern (docs/ai-agents.md):
   subtle visual cues that the tabbed examples are "live transitions"
   of the same underlying Capy source rather than separate snippets.
   ───────────────────────────────────────────────────────────────────── */

.md-typeset .tabbed-set > input:checked + label {
  /* Pulse the active tab so the reader notices it changed. */
  animation: capy-target-pulse 320ms ease-out;
}

@keyframes capy-target-pulse {
  0%   { box-shadow: 0 0 0 0 var(--md-accent-fg-color, #4ef); }
  60%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.md-typeset .tabbed-set .tabbed-content {
  /* Fade-in the freshly-selected target. */
  animation: capy-target-fade-in 280ms ease-out;
}

@keyframes capy-target-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────────────────────────────────
   Home-page "Built for AI agents" banner.
   High-contrast feature block placed right under the hero so the
   AI use-case is visible above the fold.
   ───────────────────────────────────────────────────────────────────── */

.md-typeset .capy-ai-banner {
  position: relative;
  margin: 32px 0 12px;
  padding: 28px 28px 24px;
  border-radius: 18px;
  background: linear-gradient(135deg,
    rgba(78, 238, 255, 0.07) 0%,
    rgba(78, 238, 255, 0.02) 60%,
    transparent 100%);
  border: 1px solid rgba(78, 238, 255, 0.20);
  overflow: hidden;
}

.md-typeset .capy-ai-banner::before {
  /* Subtle scanline that "powers up" once when the section enters view. */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(78, 238, 255, 0.10) 50%,
    transparent 100%);
  transform: translateX(-100%);
  animation: capy-ai-sweep 2.4s ease-out 0.4s 1 forwards;
  pointer-events: none;
}

@keyframes capy-ai-sweep {
  to { transform: translateX(100%); }
}

.md-typeset .capy-ai-banner h2 {
  margin-top: 0;
  letter-spacing: -0.01em;
}

.md-typeset .capy-ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 22px 0 24px;
}

.md-typeset .capy-ai-cell {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  font-size: 0.92em;
  line-height: 1.55;
  transition: transform 180ms ease, border-color 180ms ease;
}

.md-typeset .capy-ai-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(78, 238, 255, 0.35);
}

.md-typeset .capy-ai-cell strong {
  display: block;
  margin-bottom: 4px;
  color: var(--md-accent-fg-color, #4ef);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .md-typeset .capy-ai-banner::before { animation: none; }
}
