/* shadcn/ui's zinc theme, with the diagram's own canvas as the background */
:root {
  color-scheme: dark light;
  --canvas: #0a0b10;
  --muted: #27272a;
  --line: #27272a;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --ring: #d4d4d8;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* the names docs/theme/playground.css reads from mdBook */
  --quote-bg: #111216;
  --fg: var(--text);
  --mono-font: var(--mono);
}

@media (prefers-color-scheme: light) {
  :root {
    --canvas: #f6f8ff;
    --muted: #f4f4f5;
    --line: #e4e4e7;
    --text: #09090b;
    --text-muted: #71717a;
    --ring: #a1a1aa;
    --quote-bg: #ffffff;
  }
  .svugy-token-comment { color: #6a7385; }
  .svugy-token-string { color: #1f7a3a; }
  .svugy-token-keyword { color: #7b3fb8; }
  .svugy-token-key { color: #2557c7; }
  .svugy-token-number { color: #b5481f; }
  .svugy-token-arrow { color: #a06a00; }
  .svugy-token-punctuation { color: #5b6b80; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

code { font-family: var(--mono); }
h1 { margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:is(button, select, a):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }


/* the first screen is one view: header, compact hero, examples row, then the canvas filling the rest of the window */
body { display: flex; flex-direction: column; min-height: 100dvh; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 16px;
}
.wordmark { color: var(--text); font-weight: 600; font-size: 15px; text-decoration: none; }
.icon-links { display: flex; gap: 2px; }

/* shadcn's ghost icon button */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.icon-button:hover { color: var(--text); background: var(--muted); }
.icon-button svg { width: 18px; height: 18px; }

/* shadcn's outline button, small */
.outline-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.outline-button svg { width: 15px; height: 15px; }
.outline-button:hover:not(:disabled) { background: var(--muted); }
.outline-button:disabled { opacity: 0.5; cursor: default; }

.icon-check, [data-copied] .icon-copy { display: none; }
[data-copied] .icon-check { display: inline; }

main, main:has(.svugy-playground) {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* one centred column: title, OS switch over the command, then the installation prompt button */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 12px 0 8px;
  text-align: center;
}
.hero h1 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 28px; }
/* a bar cursor, solid while typing, blinking while the title rests */
.typed-title::after {
  content: "";
  display: inline-block;
  width: max(2px, 0.07em);
  height: 1em;
  margin-left: 0.06em;
  vertical-align: -0.12em;
  background: currentColor;
  animation: cursor-blink 1s step-end infinite;
}
.typed-title[data-typing]::after { animation: none; }
@keyframes cursor-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .typed-title::after { display: none; }
}

/* the OS switch sits right on the command */
.install { display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(100%, 620px); }
/* on a narrow phone the button drops under its label rather than wrapping either */
.ask-agent { margin: 8px 0 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px; font-size: 14.5px; color: var(--text-muted); white-space: nowrap; }
/* shadcn's tabs, small */
.segmented { display: flex; padding: 2px; background: var(--muted); border-radius: var(--radius); }
.segmented button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  padding: 3px 11px;
  cursor: pointer;
}
.segmented button[aria-selected="true"] { color: var(--text); background: var(--canvas); box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); }
/* an empty first column as wide as the copy button keeps the command at the exact centre */
.command {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
}
.command::before { content: ""; }
.command code { overflow-x: auto; white-space: nowrap; font-size: 16px; text-align: center; }
.command .icon-button { width: 38px; height: 38px; }


.try { display: flex; flex: 1; flex-direction: column; min-height: 420px; }
/* the example picker is a tab on the canvas's square top-left corner: its bottom border is the canvas's top border */
.try .picker { align-self: flex-start; margin-bottom: -1px; }
.try .picker select { height: 30px; font-size: 13px; padding: 0 28px 0 10px; border-radius: var(--radius) var(--radius) 0 0; }
.try .picker::after { right: 11px; width: 5px; height: 5px; }
.try .svugy-editor { border-top-left-radius: 0; }
/* shadcn's select trigger */
.picker { position: relative; }
.picker select {
  appearance: none;
  height: 38px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 32px 0 10px;
  cursor: pointer;
}
.picker::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* the canvas takes every pixel the column leaves: the diagram fills it, the curtain covers its height */
.svugy-live { display: flex; flex: 1; position: relative; }
/* before the live editor mounts, the committed SVG shows alone, as under a closed curtain */
.svugy-live:not([data-svugy-mounted]) textarea { display: none; }
.svugy-live:not([data-svugy-mounted]) object.svugy { position: absolute; inset: 0; }
/* the playground fills the canvas column */
.svugy-playground { flex: 1; margin: 0; }
.svugy-preview { position: absolute; inset: 0; min-height: 0; grid-template: 100% / 100%; }
/* matches the SVG document's scheme, else Chrome paints a white backdrop behind it */
.svugy-live object.svugy {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0 calc(var(--radius) + 6px) calc(var(--radius) + 6px);
  background: var(--canvas);
  color-scheme: normal;
}

/* phones scroll: the source stacks above a diagram of fixed height */
@media (max-width: 900px) {
  body { display: block; }
  .try { min-height: 0; }
  .svugy-live { display: block; }
  .svugy-live:not([data-svugy-mounted]) object.svugy { position: static; }
  .svugy-preview { position: static; }
  .svugy-editor { height: 300px; }
  .svugy-live object.svugy { height: min(75vh, 560px); }
}

@media (max-width: 640px) {
  /* one line on a phone: the spacer column gives its width back to the command */
  .command { grid-template-columns: minmax(0, 1fr) 34px; padding: 4px 4px 4px 10px; }
  .command .icon-button { width: 34px; height: 34px; }
  .command::before { display: none; }
  .command code { font-size: 11.5px; }
}

