/* Palette mirrors the TUI themes in cookie-agent/crates/tui/src/theme.rs. */
:root {
  color-scheme: light;

  --bg: #fbf4e6;          /* cream */
  --panel: #f2e5cc;       /* parchment */
  --panel-raised: #fbf4e6;
  --rule: #e6ce9e;        /* toasted */
  --rule-strong: #c9ae85; /* crust */
  --text: #46301f;        /* espresso */
  --muted: #625240;       /* ink */
  --accent: #9c5a10;      /* caramel */
  --button-bg: #46301f;
  --button-text: #fbf4e6;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --gutter: clamp(16px, 5vw, 64px);
  --max: 1280px;
}

/* Dark follows the system unless the header toggle picked a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #201c16;
    --panel: #29251d;
    --panel-raised: #393326;
    --rule: #393326;
    --rule-strong: #63563b;
    --text: #edc7ab;
    --muted: #c9b59c;
    --accent: #e78c33;    /* maple */
    --button-bg: #edc7ab;
    --button-text: #201c16;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #201c16;
  --panel: #29251d;
  --panel-raised: #393326;
  --rule: #393326;
  --rule-strong: #63563b;
  --text: #edc7ab;
  --muted: #c9b59c;
  --accent: #e78c33;    /* maple */
  --button-bg: #edc7ab;
  --button-text: #201c16;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: var(--gutter);
  top: 12px;
  padding: 8px 14px;
  background: var(--button-bg);
  color: var(--button-text);
  border-radius: 8px;
  z-index: 10;
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--rule);
}

.site-header .wrap {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand:hover {
  color: inherit;
}

.brand img {
  width: 40px;
  height: 40px;
}

.site-nav {
  display: flex;
  gap: clamp(16px, 3vw, 36px);
  font-size: 15px;
  font-weight: 500;
}

.site-nav {
  align-items: center;
}

.site-nav a {
  text-decoration: none;
  padding: 10px 0;
}

/* Theme toggle: the same sun icons as the docs header. */

.theme-toggle {
  width: 40px;
  height: 40px;
  margin: 0 -8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle .to-light {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .to-dark {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .to-light {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .to-dark {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle .to-light {
    display: block;
  }
}

/* Hero */

.hero .wrap {
  padding-top: clamp(40px, 7vw, 72px);
  padding-bottom: clamp(40px, 6vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(46px, 7vw, 84px);
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.lede {
  margin: 0;
  font-size: 19px;
  color: var(--muted);
  max-width: 34em;
}

.hero-art {
  display: flex;
  justify-content: center;
}

.hero-art img {
  width: 100%;
  max-width: 440px;
  height: auto;
}

/* Command box */

.command {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 6px 6px 6px 18px;
  min-width: 0;
}

.command .prompt {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  user-select: none;
}

.command pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  font-size: 14px;
  padding: 10px 24px 10px 0;
  /* Long commands scroll sideways; a faded edge replaces the scrollbar. */
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.command pre::-webkit-scrollbar {
  display: none;
}

.copy {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.copy:hover {
  color: var(--accent);
}

.copy .done,
.copy.copied .idle {
  display: none;
}

.copy.copied .done {
  display: block;
}

.command-note {
  margin: -16px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* Buttons */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 26px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}

.button.primary {
  background: var(--button-bg);
  color: var(--button-text);
}

.button.primary:hover {
  color: var(--button-text);
  opacity: 0.9;
}

.button.secondary {
  border: 1px solid var(--rule-strong);
}

/* Feature pillars */

.pillar {
  border-top: 1px solid var(--rule);
}

.pillar .wrap {
  padding-top: clamp(56px, 8vw, 104px);
  padding-bottom: clamp(56px, 8vw, 104px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(40px, 6vw, 80px);
  align-items: center;
}

.pillar.flip .pillar-copy {
  order: 2;
}

.pillar-copy {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kicker,
.layer-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}

.pillar h2,
.closing h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 4.4vw, 52px);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.pillar-copy > p:not(.kicker) {
  margin: 0;
  font-size: 18px;
  color: var(--muted);
}

.points {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 15px;
}

.points li {
  position: relative;
  padding-left: 22px;
}

.points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: clamp(20px, 3vw, 32px);
  min-width: 0;
}

/* 01 · mighty */

.layers {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chips li {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--panel-raised);
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* 02 · small */

.agent-doc {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.agent-doc pre {
  margin: 0 0 8px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--panel-raised);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.receives {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.receives li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--panel-raised);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.receives li > span:first-child::before {
  display: inline-block;
  width: 1.4em;
}

.receives .in > span:first-child::before {
  content: "✓";
  color: var(--accent);
}

.receives .fixed > span:first-child::before {
  content: "+";
  color: var(--muted);
}

.receives .out {
  background: transparent;
  border: 1px dashed var(--rule-strong);
  color: var(--muted);
}

.receives .out > span:first-child::before {
  content: "–";
}

/* 03 · presets */

.seg {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--panel-raised);
  border: 1px solid var(--rule);
  margin-bottom: 24px;
}

.seg button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--button-bg);
  color: var(--button-text);
}

.presets-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.tree {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.9;
  overflow-x: auto;
  color: var(--muted);
}

.tree > div {
  white-space: pre;
}

.tree [data-on] {
  opacity: 0.45;
  transition: opacity 0.15s, color 0.15s;
}

.presets[data-active="shared"] .tree [data-on~="shared"],
.presets[data-active="python"] .tree [data-on~="python"],
.presets[data-active="rust"] .tree [data-on~="rust"] {
  opacity: 1;
  color: var(--text);
}

.presets[data-active="python"] .tree [data-off~="python"],
.presets[data-active="rust"] .tree [data-off~="rust"] {
  text-decoration: line-through;
}

.tree-root {
  color: var(--text);
}

.effective {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.effective ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.presets[data-active="shared"] .effective ul[data-preset="shared"],
.presets[data-active="python"] .effective ul[data-preset="python"],
.presets[data-active="rust"] .effective ul[data-preset="rust"] {
  display: flex;
}

.effective li,
.context summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.effective li {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--panel-raised);
}

.src {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.src.hot {
  color: var(--accent);
}

/* 04 · delegation */

.delegation {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.agent-tree {
  width: 100%;
  max-width: 520px;
  align-self: center;
  height: auto;
  font-family: var(--font-mono);
}

.agent-tree .node {
  fill: var(--panel-raised);
  stroke: var(--rule-strong);
}

.agent-tree .node.root {
  fill: var(--button-bg);
  stroke: var(--button-bg);
}

.agent-tree .node-title {
  font-size: 14px;
  font-weight: 500;
  fill: var(--text);
}

.agent-tree .node-sub {
  font-size: 11.5px;
  fill: var(--muted);
}

.agent-tree .root + .node-title,
.agent-tree .root + .node-title + .node-sub {
  fill: var(--button-text);
}

.agent-tree .edge {
  fill: none;
  stroke: var(--rule-strong);
  stroke-width: 1.5;
}

.agent-tree .mail {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-dasharray: 6 5;
}

.agent-tree .arrow-head {
  fill: var(--accent);
}

.agent-tree .edge-label {
  font-size: 11.5px;
  fill: var(--muted);
}

.agent-tree .mail-label {
  font-size: 12px;
  fill: var(--accent);
}

.envelope,
.context pre {
  margin: 0;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--panel-raised);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* 05 · context */

.context {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.context .layer-label {
  margin-bottom: 8px;
}

.context details {
  border-radius: 10px;
  background: var(--panel-raised);
}

.context summary {
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
}

.context summary::-webkit-details-marker {
  display: none;
}

.context summary > span:first-child::before {
  content: "▸";
  display: inline-block;
  width: 1.2em;
  color: var(--accent);
  transition: transform 0.15s;
}

.context details[open] summary > span:first-child::before {
  transform: rotate(90deg);
}

.context details > p,
.context details > pre {
  margin: 0 14px 12px;
  font-size: 14px;
  color: var(--muted);
}

.context details > pre {
  padding: 12px 14px;
  background: var(--panel);
  font-size: 12.5px;
  color: var(--text);
}

.context-foot {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* 06 · anywhere */

.anywhere {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.topology {
  width: 100%;
  max-width: 520px;
  align-self: center;
  height: auto;
  font-family: var(--font-mono);
}

.topology .node {
  fill: var(--panel-raised);
  stroke: var(--rule-strong);
}

.topology .node.root {
  fill: var(--button-bg);
  stroke: var(--button-bg);
}

.topology .node-title {
  font-size: 14px;
  font-weight: 500;
  fill: var(--text);
}

.topology .node-sub {
  font-size: 11.5px;
  fill: var(--muted);
}

.topology .on-root {
  fill: var(--button-text);
}

.topology .link {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
}

.topology .link-label {
  font-size: 11.5px;
  fill: var(--muted);
}

.pillar .wrap.shots-row {
  display: block;
  padding-top: 0;
}

.shots {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  padding-bottom: 24px;
}

.shot {
  display: block;
  height: auto;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
}

.shot.desktop {
  width: 86%;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgb(70 48 31 / 0.14);
}

.shot.phone {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 24%;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgb(0 0 0 / 0.25);
}

/* One screenshot per theme, following the page's theme. */
.shot.for-dark {
  display: none;
}

:root[data-theme="dark"] .shot.for-light {
  display: none;
}

:root[data-theme="dark"] .shot.for-dark {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shot.for-light {
    display: none;
  }

  :root:not([data-theme="light"]) .shot.for-dark {
    display: block;
  }
}

/* Closing */

.closing {
  border-top: 1px solid var(--rule);
  background: var(--panel);
}

.closing .wrap {
  padding-top: clamp(56px, 8vw, 96px);
  padding-bottom: clamp(56px, 8vw, 96px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
}

.closing .install {
  width: 100%;
  max-width: 720px;
  align-items: center;
}

.closing .command {
  width: 100%;
  background: var(--bg);
  text-align: left;
}

.closing .os-tabs button[aria-pressed="true"] {
  background: var(--bg);
}

.closing .actions {
  justify-content: center;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--muted);
}

.site-footer .wrap {
  min-height: 88px;
  padding-top: 24px;
  padding-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

/* 404 */

.not-found .wrap {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

/* Responsive */

@media (max-width: 960px) {
  .pillar .wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .pillar.flip .pillar-copy {
    order: 0;
  }
}

@media (max-width: 760px) {
  .hero .wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .hero-art {
    order: -1;
    justify-content: flex-start;
  }

  .hero-art img {
    max-width: 160px;
  }

  .site-nav .optional {
    display: none;
  }
}

@media (max-width: 560px) {
  /* A phone sees the phone screenshot. */
  .shot.desktop {
    display: none !important;
  }

  .shot.phone {
    position: static;
    width: min(78%, 320px);
    margin: 0 auto;
  }

  .presets-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand {
    font-size: 20px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }
}

/* Install switch: one command per platform, chosen by the tabs above it. */

.install {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.os-tabs {
  display: flex;
  gap: 4px;
}

.os-tabs button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}

.os-tabs button:hover {
  color: var(--accent);
}

.os-tabs button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--text);
}

.install[data-active="unix"] .command[data-os="windows"],
.install[data-active="windows"] .command[data-os="unix"] {
  display: none;
}
