/* Embedded typefaces — the same ones used by the native rasterizer and
 * PDF exporter, so that graphics rendered by the browser in the playground
 * match the glyphs users see when they Export[…] a plot to PNG / PDF. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("AtkinsonHyperlegibleNext-VariableFont_wght.ttf") format("truetype-variations"),
    url("AtkinsonHyperlegibleNext-VariableFont_wght.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("AtkinsonHyperlegibleMono-VariableFont_wght.ttf") format("truetype-variations"),
    url("AtkinsonHyperlegibleMono-VariableFont_wght.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* Plot / Graphics SVGs emitted by Woxi set font-family="sans-serif" or
 * "monospace" inline on every <text> element. CSS on inline SVG text
 * overrides those presentation attributes, so this one rule makes the
 * playground pick up the embedded fonts without touching SVG generation. */
svg text {
  font-family: "Atkinson Hyperlegible Next", sans-serif;
}

svg text[font-family~="monospace"],
svg text[font-family*="Mono"],
svg text[font-family*="Courier"] {
  font-family: "Atkinson Hyperlegible Mono", monospace;
}

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #333;
  --text-secondary: #555;
  --text-muted: #666;
  --text-hint: #999;
  --link: #4977a8;
  --border: #ddd;
  --border-focus: #4977a8;
  --shadow: rgba(0, 0, 0, 0.1);
  --btn-bg: #f8f9fa;
  --btn-bg-hover: #e9ecef;
  --btn-border-hover: #adb5bd;
  --btn-text: #555;
  --btn-text-hover: #333;
  --active-line: #f0f4ff;
  --output-bg: #f8f9fa;
  --output-text: #333;
  --output-border: #ddd;
  --run-bg: #28a745;
  --run-bg-hover: #1e7e34;
  --run-disabled: #6c757d;
  --clear-bg: #6c757d;
  --clear-bg-hover: #545b62;
  --hr: #ddd;
  --status-info-bg: #d1ecf1;
  --status-info-text: #0c5460;
  --status-info-border: #bee5eb;
  --status-error-bg: #f8d7da;
  --status-error-text: #721c24;
  --status-error-border: #f5c6cb;
}

html.dark {
  --bg: #1a1a1a;
  --surface: #242424;
  --text: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #909090;
  --text-hint: #707070;
  --link: #6fa8dc;
  --border: #3a3a3a;
  --border-focus: #6fa8dc;
  --shadow: rgba(0, 0, 0, 0.4);
  --btn-bg: #2e2e2e;
  --btn-bg-hover: #3a3a3a;
  --btn-border-hover: #555;
  --btn-text: #b0b0b0;
  --btn-text-hover: #e0e0e0;
  --active-line: #2a2a2a;
  --output-bg: #1a1a1a;
  --output-text: #c9c9c9;
  --output-border: #3a3a3a;
  --run-bg: #238636;
  --run-bg-hover: #2ea043;
  --run-disabled: #484848;
  --clear-bg: #484848;
  --clear-bg-hover: #606060;
  --hr: #3a3a3a;
  --status-info-bg: #1a3a3a;
  --status-info-text: #79c0c0;
  --status-info-border: #2a4a4a;
  --status-error-bg: #3a1a1a;
  --status-error-text: #f08080;
  --status-error-border: #5a2a2a;
}

body {
  font-family: "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  max-width: 60rem;
  margin: 0 auto;
  background-color: var(--bg);
  color: var(--text);
}

#wrapper {
  background: var(--surface);
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  padding: 0.5rem 2rem 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 1rem var(--shadow);
}

h1 {
  color: var(--text);
  text-align: center;
  margin: 0.5rem 0 0.25rem;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 1rem;
}

h3 {
  color: var(--text-secondary);
  margin: 0 0 0.5rem 0;
}

hr {
  border: none;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--hr) 20%,
    var(--hr) 80%,
    transparent
  );
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#themeBtn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

#themeBtn:hover {
  background-color: var(--btn-bg-hover);
  border-color: var(--btn-border-hover);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.examples {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.examples span {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: bold;
}

.example-btn {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  cursor: pointer;
  font-size: 13px;
  background: var(--btn-bg);
  color: var(--btn-text);
  transition: all 0.2s;
}

.example-btn:hover {
  background: var(--btn-bg-hover);
  border-color: var(--btn-border-hover);
  color: var(--btn-text-hover);
}

/* CodeMirror editor */
.editor-container {
  margin: 1rem 0 0.5rem 0;
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.editor-container:focus-within {
  border-color: var(--border-focus);
}

.editor-container .cm-editor {
  font-size: 12px;
  min-height: 120px;
}

.editor-container .cm-editor.cm-focused {
  outline: none;
}

.editor-container .cm-scroller {
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  line-height: 1.5;
  padding: 0.5rem 0;
}

.editor-container .cm-content {
  padding: 0 0.75rem;
}

.editor-container .cm-activeLine {
  background-color: var(--active-line);
}

.controls {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 1.5rem;
  align-items: center;
}

.controls-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.disclaimer {
  display: flex;
  justify-content: flex-end;
  color: var(--text-hint);

  small {
    display: block;
    font-size: 0.7rem;
  }
}


#runBtn {
  background-color: var(--run-bg);
  color: white;
}

#runBtn:hover:not(:disabled) {
  background-color: var(--run-bg-hover);
}

#runBtn:disabled {
  background-color: var(--run-disabled);
  cursor: not-allowed;
}

#clearBtn {
  background: none;
  color: var(--text-muted);
}

#clearBtn:hover {
  background-color: var(--clear-bg);
  color: white;
}

#shareBtn {
  background: none;
  color: var(--text-muted);
}

#shareBtn:hover {
  background-color: color-mix(in srgb, var(--border-focus) 15%, transparent);
}

button {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 12px;
  font-weight: normal;
  white-space: nowrap;
  background: var(--text);
  color: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

.output-container {
  margin: 1rem 0;
}

#outputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: opacity 0.2s;
}

#outputs.stale {
  opacity: 0.4;
}

.output-box {
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--output-border);
  border-radius: 4px;
}

pre.output-box {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.output-box.text-box,
.output-box.print-box {
  background: var(--output-bg);
  color: var(--output-text);
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: auto;
}

.output-box.text-box svg {
  display: block;
}

.output-box.graphics-box {
  background: var(--surface);
}

.output-box.graphics-box svg,
.output-box.graphics-box img {
  max-width: 100%;
  height: auto;
  display: block;
}

.output-box.warning-box {
  background: var(--status-info-bg);
  color: var(--status-info-text);
  border-color: var(--status-info-border);
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 14px;
}

.output-box.error-box {
  background: var(--status-error-bg);
  color: var(--status-error-text);
  border-color: var(--status-error-border);
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 14px;
}

.output-box.manipulate-box {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.manipulate-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.manipulate-control-row {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) 1fr auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 13px;
  color: var(--text-secondary);
}

.manipulate-label {
  font-weight: 500;
  color: var(--text);
}

.manipulate-control-row input[type="range"] {
  width: 100%;
}

.manipulate-value {
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 3rem;
  text-align: right;
}

.manipulate-output {
  min-height: 2rem;
  transition: opacity 0.1s ease-out;
}

.manipulate-output.stale {
  opacity: 0.6;
}

.manipulate-output svg {
  max-width: 100%;
  height: auto;
}

.manipulate-output pre {
  margin: 0;
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.status {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  display: none;
  z-index: 100;
  font-size: 14px;
}

.status.info {
  background-color: var(--status-info-bg);
  color: var(--status-info-text);
  border: 1px solid var(--status-info-border);
}

.status.error {
  background-color: var(--status-error-bg);
  color: var(--status-error-text);
  border: 1px solid var(--status-error-border);
}

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  flex-shrink: 0;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* --- Alternative ways to use Woxi ---------------------------------- */

.alt-divider {
  margin: 3rem 0 2rem;
}

.alt-uses h2 {
  color: var(--text);
  text-align: center;
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.alt-lede {
  text-align: center;
  color: var(--text-muted);
  margin: 0 auto 2rem;
  max-width: 38rem;
  font-size: 15px;
  line-height: 1.5;
}

.alt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.alt-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 1px 2px var(--shadow);
  position: relative;
}

.alt-card:hover {
  box-shadow: 0 8px 24px var(--shadow);
  border-color: var(--border-focus);
  text-decoration: none;
}

.alt-card__image {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--output-bg);
  border-bottom: 1px solid var(--border);
}

.alt-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform 0.4s ease;
}

.alt-card:hover .alt-card__image img {
  transform: scale(1.03);
}

.alt-card__body {
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.alt-card__body h3 {
  color: var(--text);
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.alt-card__body p {
  color: var(--text-secondary);
  margin: 0 0 0.9rem;
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
}

.alt-card__body code {
  font-family: "Atkinson Hyperlegible Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
  padding: 0.05em 0.3em;
  background: var(--output-bg);
  border-radius: 3px;
}

.alt-card__cta {
  color: var(--link);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s ease;
}

.alt-card:hover .alt-card__cta {
  transform: translateX(3px);
  text-decoration: none;
}

/* "Stretched-link" overlay — lets the CTA act as the card's primary
   link when the card root is not itself an <a>. */
.alt-card__cta--stretched::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Inline links inside a card body sit above the stretched-link overlay
   so they remain independently clickable. */
.alt-card__inline-link {
  position: relative;
  z-index: 1;
}

/* An optional link wrapping a card's image — e.g. on the Jupyter tile
   the image links to JupyterLite while the rest of the card goes to
   the Jupyter docs page. */
.alt-card__image-link {
  display: block;
  height: 100%;
  position: relative;
  z-index: 1;
}

@media (max-width: 900px) {
  .alt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  #wrapper {
    padding: 0.5rem 1rem 1rem;
  }

  .controls {
    flex-wrap: wrap;
  }

  .controls-right {
    width: 100%;
  }

  .controls-right button {
    flex: 1;
  }

  .alt-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .alt-uses h2 {
    font-size: 1.35rem;
  }
}
