/* ==========================================================================
   dq-theme.css — shared design system for David Quintana's project demos.
   Same tokens, type, and components as davidquintana.dev, so every demo
   looks like part of one portfolio. Each project's own stylesheet builds
   on these variables; nothing here is project-specific.
   Dark is the default; [data-theme="light"] on <html> switches palettes.
   ========================================================================== */

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --border: #2e2e2e;
  --border-strong: #3d3d3d;
  --text: #f2f2f2;
  --text-muted: #b9b9b9;
  --text-faint: #8a8a8a;
  --accent: #ff6a00;
  --accent-hover: #ff8a33;
  --accent-ink: #000;
  --accent-soft: rgba(255, 106, 0, 0.12);
  --accent-line: rgba(255, 106, 0, 0.35);
  --amber: #ffb300;
  --ok: #3ccf91;
  --danger: #ff5c5c;
  --info: #6cb4ff;
  --header-bg: rgba(13, 13, 13, 0.88);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --grid-line: rgba(255, 255, 255, 0.025);
  --code-bg: #0a0a0a;
  --code-text: #e6e6e6;

  --font-display: 'Anton', 'Impact', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px;
  --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;

  --radius: 6px;
  --radius-lg: 10px;
  --container: 1080px;
  --header-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dadde3;
  --border-strong: #c3c8d0;
  --text: #14161b;
  --text-muted: #474e5b;
  --text-faint: #565d6b;
  --accent: #b4490a;
  --accent-hover: #8f3a06;
  --accent-ink: #fff;
  --accent-soft: rgba(180, 73, 10, 0.09);
  --accent-line: rgba(180, 73, 10, 0.35);
  --amber: #8a5a00;
  --ok: #0f7a4f;
  --danger: #b42318;
  --info: #1d5fa8;
  --header-bg: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 30px rgba(20, 22, 27, 0.10);
  --grid-line: rgba(0, 0, 0, 0.03);
  --code-bg: #14161b;
  --code-text: #f2f2f2;
  color-scheme: light;
}

/* Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.15; color: var(--text); text-wrap: balance; }
p { color: var(--text-muted); }
strong { color: var(--text); font-weight: 600; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
code, kbd, pre, samp { font-family: var(--font-mono); }
[hidden] { display: none !important; }

.dq-container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--s5); }
@media (min-width: 768px) { .dq-container { padding-inline: var(--s8); } }
.dq-main { flex: 1; padding-bottom: var(--s16); }

.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 1000;
  padding: var(--s2) var(--s4); background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: var(--s3); }

/* Header ----------------------------------------------------------------- */
.dq-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.dq-header-inner { display: flex; align-items: center; gap: var(--s3); min-height: var(--header-h); }

.brand { display: flex; align-items: center; gap: var(--s3); color: var(--text); text-decoration: none; margin-right: auto; min-width: 0; }
.brand:hover { color: var(--text); }
.brand-mark {
  flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.03em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.brand-role { font-size: 0.75rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 460px) { .brand-role { display: none; } }

.dq-tools { display: flex; align-items: center; gap: var(--s2); }

/* Icon buttons and the EN | ES switch share one look. */
.icon-btn, .seg {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  height: 36px; min-width: 36px; padding: 0 var(--s2);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-muted);
  font: 600 0.75rem/1 var(--font-mono); cursor: pointer;
}
.icon-btn:hover, .seg:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.seg { padding: 0 3px; }
.seg button, .seg .opt {
  appearance: none; border: 0; background: none; color: inherit; cursor: pointer;
  font: inherit; padding: 5px 7px; border-radius: 4px;
}
.seg button[aria-pressed="true"], .seg button.active,
html[lang="en"] .seg .opt-en, html[lang="es"] .seg .opt-es { background: var(--accent); color: var(--accent-ink); }

.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Hero ------------------------------------------------------------------- */
.dq-hero { padding-block: clamp(var(--s8), 5vw, var(--s12)) var(--s8); }
.kicker {
  display: inline-block; margin-bottom: var(--s3);
  color: var(--accent); font: 600 0.78rem/1.4 var(--font-mono);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.dq-hero h1, .display {
  font-family: var(--font-display); font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.01em;
  font-size: clamp(2.1rem, 5vw, 3.6rem); line-height: 1.05;
}
.lead { margin-top: var(--s4); font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--text-muted); max-width: 68ch; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; padding: 0; margin-top: var(--s5); }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font: 500 0.74rem/1.5 var(--font-mono);
}
.section-title {
  font-family: var(--font-display); font-weight: 400; text-transform: uppercase;
  letter-spacing: 0.015em; font-size: clamp(1.4rem, 2.6vw, 1.9rem);
}

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 46px; padding: 0 var(--s6);
  border: 1px solid transparent; border-radius: var(--radius);
  font: 700 0.9rem/1 var(--font-body); letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s3); }
.link-btn {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 3px;
}

/* Surfaces & forms ------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(var(--s5), 3vw, var(--s8));
}
.card-accent { border-top: 3px solid var(--accent); }

.field-label, .dq-form label {
  display: block; margin-bottom: var(--s2);
  color: var(--text-muted); font: 600 0.74rem/1.4 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.dq-input,
.dq-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.dq-form select,
.dq-form textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: 400 1rem/1.4 var(--font-body);
  transition: border-color .15s, box-shadow .15s;
}
.dq-form textarea { resize: vertical; }
.dq-form input::placeholder, .dq-form textarea::placeholder { color: var(--text-faint); }
.dq-input:focus, .dq-form input:focus, .dq-form select:focus, .dq-form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.dq-form input[type="checkbox"], .dq-form input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }
.dq-form input[type="file"] { color: var(--text-muted); font: 500 0.85rem var(--font-body); }
.dq-form input[type="file"]::file-selector-button {
  margin-right: var(--s3); padding: 8px 14px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius); font: 600 0.85rem var(--font-body);
}

.callout {
  padding: var(--s4) var(--s5); background: var(--accent-soft);
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
}

/* Live-demo engine status (Pyodide) ---------------------------------------- */
.engine-status {
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: var(--s2) var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font-size: 0.875rem; line-height: 1.5;
}
.engine-status > span:not(.engine-dot) { flex: 1 1 16rem; min-width: 0; }
.engine-dot { flex: none; width: 8px; height: 8px; margin-top: 0.4em; border-radius: 50%; background: var(--amber); }
.engine-status[data-state="loading"] .engine-dot { animation: dq-pulse 1.2s ease-in-out infinite; }
.engine-status[data-state="ready"] .engine-dot { background: var(--ok); }
.engine-status[data-state="error"] .engine-dot { background: var(--danger); }
@keyframes dq-pulse { 50% { opacity: 0.3; } }

/* Footer ----------------------------------------------------------------- */
.dq-footer { border-top: 1px solid var(--border); padding-block: var(--s8); font-size: 0.85rem; }
.dq-footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s6); }
.dq-footer p { color: var(--text-faint); }
.dq-footer nav { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.dq-footer a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.dq-footer a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
