/* demo.css - demo container, toggle button, fail/pass states */

/* Demo container */
.demo-container {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--space-8);
}

/* Demo fail/pass state switches must be instant - no inherited theme transition */
.demo-container,
.demo-container * {
  transition: none !important;
}

.demo-container__toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.demo-container__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  flex: 1;
}

/* Toggle button */
.demo-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  cursor: pointer;
  background: transparent;
  color: var(--color-fail);
}

.demo-toggle:hover {
  background: var(--color-fail-bg);
}

/* When aria-pressed="true" (showing pass state) */
.demo-toggle[aria-pressed="true"] {
  color: var(--color-pass);
}

.demo-toggle[aria-pressed="true"]:hover {
  background: var(--color-pass-bg);
}

.demo-toggle__icon {
  font-size: 1em;
  line-height: 1;
}

/* Status indicator strip */
.demo-container[data-mode="fail"] .demo-status {
  background: var(--color-fail-bg);
  border-bottom: 1px solid var(--color-fail-border);
  color: var(--color-fail);
}

.demo-container[data-mode="pass"] .demo-status {
  background: var(--color-pass-bg);
  border-bottom: 1px solid var(--color-pass-border);
  color: var(--color-pass);
}

.demo-status {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.demo-status__text--fail { display: none; }
.demo-status__text--pass { display: none; }

.demo-container[data-mode="fail"] .demo-status__text--fail { display: inline; }
.demo-container[data-mode="pass"] .demo-status__text--pass { display: inline; }

/* Demo stage - where the actual demo lives */
.demo-stage {
  padding: var(--space-6);
}

/* Lock demo stage to light-mode tokens regardless of page theme.
   Demos must show their intended colors (fail reds, pass greens,
   contrast examples) without being distorted by dark-mode overrides. */
[data-theme="dark"] .demo-stage {
  --color-bg:           #ffffff;
  --color-surface:      #f5f5f5;
  --color-border:       #8a8a8a;
  --color-text:         #1a1a1a;
  --color-text-muted:   #5a5a5a;
  --color-accent:       #0055cc;
  --color-accent-hover: #003d99;
  --color-fail:         #b91c1c;
  --color-fail-bg:      #fef2f2;
  --color-fail-border:  #dc2626;
  --color-pass:         #15803d;
  --color-pass-bg:      #f0fdf4;
  --color-pass-border:  #16a34a;
  --color-focus:        #0055cc;
  color: #1a1a1a;
  background-color: #ffffff;
  color-scheme: light;
}

/* Fail-mode stage styling */
.demo-container[data-mode="fail"] .demo-stage {
  background: var(--color-fail-bg);
}

.demo-container[data-mode="pass"] .demo-stage {
  background: var(--color-pass-bg);
}

/* Demo explanation panels */
.demo-explanation {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.demo-explanation__panel {
  display: none;
  font-size: var(--font-size-sm);
}

.demo-explanation__panel--fail { color: var(--color-fail); }
.demo-explanation__panel--pass { color: var(--color-pass); }

.demo-container[data-mode="fail"] .demo-explanation__panel--fail { display: block; }
.demo-container[data-mode="pass"] .demo-explanation__panel--pass { display: block; }

.demo-explanation__heading {
  font-weight: 700;
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

/* Visually hidden (for screen readers) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Demo placeholder (no demo implemented yet) */
.demo-placeholder {
  padding: var(--space-8) var(--space-6);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Code display section styling */
.demo-code-section {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.demo-code-section__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-6);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.demo-code-section__toggle::-webkit-details-marker { display: none; }

.demo-code-section__toggle::before {
  content: '▶';
  font-size: 0.6em;
  transition: none;
}

.demo-code-section[open] .demo-code-section__toggle::before {
  content: '▼';
}

.demo-code-section pre {
  margin: 0;
  border-radius: 0;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: hidden;
}

.demo-code-section pre code {
  background: none !important;
  border: none !important;
  color: inherit !important;
  padding: 0;
}

/* Syntax highlight tokens (VS Code dark theme palette) */
.demo-code-section .hl-tag    { color: #569cd6; }
.demo-code-section .hl-value  { color: #ce9178; }
.demo-code-section .hl-comment { color: #6a9955; font-style: italic; }

/* Full-width line highlights for key diff lines */
.demo-code-section .hl-line-fail {
  display: block;
  background: rgba(220, 53, 53, 0.22);
  margin: 0 -1rem;
  padding: 0 1rem;
}
.demo-code-section .hl-line-pass {
  display: block;
  background: rgba(40, 167, 69, 0.22);
  margin: 0 -1rem;
  padding: 0 1rem;
}

/* -------------------------------------------------------
   Checkpoint-specific demo styles
   ------------------------------------------------------- */

/* 3.1.1 demo - mock Spanish page snippet */
.demo-mock-page {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  font-size: var(--font-size-sm);
}
.demo-mock-page h2 {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
}
.demo-mock-page p { margin: 0 0 var(--space-2); }
.demo-mock-page ul { margin: 0 0 var(--space-3); padding-left: var(--space-4); }
.demo-mock-page li { margin-bottom: var(--space-1); }
.demo-mock-page button {
  padding: var(--space-1) var(--space-3);
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--font-size-sm);
}
.demo-mock-label {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* 1.3.1 demo - table without headers (fail) vs with headers (pass) */
.demo-table-wrapper {
  overflow-x: auto;
}

.demo-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--font-size-sm);
}

.demo-table td,
.demo-table th {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}

.demo-table th {
  background: var(--color-surface);
  font-weight: 700;
}

/* The fail example table uses no th - just td */
.demo-container[data-mode="fail"] .demo-table td:first-child {
  /* no special treatment - demonstrating the problem */
  font-weight: normal;
}

/* -------------------------------------------------------
   Responsive - Mobile (≤640px)
   ------------------------------------------------------- */
@media (max-width: 640px) {
  /* Toolbar: allow label + toggle button to stack */
  .demo-container__toolbar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* Stage: allow wide demo content to scroll horizontally */
  .demo-stage {
    overflow-x: auto;
  }
}


/* Skip link pattern — visually hidden until focused (used in 2.4.1 demo) */
.demo-skip-link {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  display: inline-block;
  padding: 0.4em 0.9em;
  background: #000;
  color: #fff;
  border-radius: 4px;
  font-size: 0.9rem;
  text-decoration: none;
}
.demo-skip-link:focus {
  position: static;
  width: auto;
  height: auto;
}

/* Manual code blocks for CSS-only demos — toggled by data-mode on parent .demo-container */
[data-demo-code] { display: none; }
.demo-container[data-mode="fail"] [data-demo-code="fail"] { display: block; }
.demo-container[data-mode="pass"] [data-demo-code="pass"] { display: block; }
