/* SQL Sandbox — The Lab (dark arcade / retro-terminal) */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  color-scheme: dark;

  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --surface-3: #20203200;
  --line: #28283c;
  --line-soft: #1e1e2e;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --faint: #6b7088;

  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --glow-cyan: 0 0 12px rgba(69, 240, 255, 0.55);
  --glow-magenta: 0 0 12px rgba(255, 61, 139, 0.5);
  --glow-gold: 0 0 12px rgba(255, 200, 87, 0.45);

  --radius: 10px;
  --radius-sm: 6px;

  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; }

body {
  position: relative;
  min-height: 100svh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(69, 240, 255, 0.07), transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(255, 61, 139, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle CRT scanline texture over the whole page */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

a { color: var(--cyan); text-underline-offset: 0.2em; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.2);
  border-radius: 3px;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--gold);
  background: rgba(255, 200, 87, 0.08);
  border: 1px solid rgba(255, 200, 87, 0.22);
  border-radius: 4px;
  padding: 0.05em 0.36em;
}

/* ---------- skip + back-to-lab ---------- */
.skip-link {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 200;
  transform: translate(-50%, -120%);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--bg);
  background: var(--cyan);
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-out-expo);
}
.skip-link:focus-visible { transform: translate(-50%, 0); outline-offset: 4px; }

.lab-link {
  position: fixed;
  top: clamp(0.7rem, 2.4vw, 1.15rem);
  left: clamp(0.7rem, 2.4vw, 1.15rem);
  z-index: 150;
  display: inline-flex;
  align-items: center;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--dim);
  text-decoration: none;
  padding: 0.65rem 0.85rem;
  background: rgba(10, 10, 18, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color var(--duration-fast) ease, border-color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) ease;
}
.lab-link:hover,
.lab-link:focus-visible {
  color: var(--cyan);
  border-color: var(--cyan);
  transform: translateX(-3px);
  box-shadow: var(--glow-cyan);
}

/* ---------- header / hero ---------- */
.site-header {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 0.7rem;
  text-align: center;
  padding: clamp(4.5rem, 9vw, 7rem) 1.25rem clamp(2rem, 4vw, 3rem);
}

.kicker {
  font-family: var(--pixel);
  font-size: clamp(8px, 1.8vw, 10px);
  letter-spacing: 0.28em;
  color: var(--magenta);
  text-shadow: var(--glow-magenta);
}

.wordmark {
  position: relative;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(1.5rem, 0.6rem + 6vw, 3.75rem);
  line-height: 1.12;
  letter-spacing: 0.01em;
  color: var(--text);
  text-shadow:
    0 0 18px rgba(69, 240, 255, 0.4),
    3px 3px 0 var(--magenta),
    0 0 48px rgba(69, 240, 255, 0.18);
}

.tagline {
  display: inline-flex;
  align-items: baseline;
  gap: 0.1ch;
  font-family: var(--mono);
  font-size: clamp(0.85rem, 0.8rem + 0.4vw, 1.05rem);
  color: var(--dim);
  letter-spacing: 0.01em;
}
.cursor { color: var(--cyan); animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--faint);
}
.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 9px rgba(65, 255, 139, 0.85);
  animation: pulse 2.4s var(--ease-out-expo) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- layout ---------- */
.app-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 84rem;
  margin: 0 auto;
  padding: 0 clamp(0.9rem, 3vw, 1.75rem) clamp(2rem, 5vw, 3.5rem);
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  align-items: start;
}

/* ---------- panels ---------- */
.panel {
  position: relative;
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface) 65%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.6vw, 1.6rem);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
/* top neon rail */
.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent 55%);
  opacity: 0.7;
}
.panel--query::before { background: linear-gradient(90deg, var(--magenta), transparent 55%); }
/* faint stage numeral watermark */
.panel::after {
  content: attr(data-stage);
  position: absolute;
  top: clamp(0.4rem, 1.5vw, 0.8rem);
  right: clamp(0.6rem, 2vw, 1.1rem);
  font-family: var(--pixel);
  font-size: clamp(28px, 6vw, 52px);
  line-height: 1;
  color: var(--line);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-title { max-width: 46ch; }

.panel-step {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--cyan);
  margin-bottom: 0.6rem;
}
.panel--query .panel-step { color: var(--magenta); }

.panel-title h2 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(13px, 2.6vw, 17px);
  line-height: 1.45;
  letter-spacing: 0.02em;
  margin-bottom: 0.65rem;
  text-shadow: 0 0 14px rgba(69, 240, 255, 0.25);
}

.hint {
  color: var(--dim);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ---------- fields ---------- */
.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.field-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--dim);
  text-transform: uppercase;
}
.field-tag {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  background: rgba(255, 200, 87, 0.1);
  border: 1px solid rgba(255, 200, 87, 0.28);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  text-transform: none;
}

select,
textarea,
input[type="file"] {
  width: 100%;
  background: rgba(10, 10, 18, 0.75);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}
select:hover,
textarea:hover,
input[type="file"]:hover { border-color: rgba(69, 240, 255, 0.5); }
select:focus,
textarea:focus,
input[type="file"]:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(69, 240, 255, 0.18);
}

select {
  min-height: 2.85rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%),
    linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 12px) center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
}
select option { background: var(--surface); color: var(--text); }

textarea {
  min-height: 11rem;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.55;
}
#dataInput { min-height: 13rem; }
#sqlInput {
  min-height: 7.5rem;
  color: var(--cyan);
  caret-color: var(--cyan);
  background:
    linear-gradient(180deg, rgba(69, 240, 255, 0.04), transparent 30%),
    rgba(8, 8, 14, 0.85);
  border-color: rgba(69, 240, 255, 0.3);
}

input[type="file"] {
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--dim);
}
input[type="file"]::file-selector-button {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--bg);
  background: var(--cyan);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  margin-right: 0.8rem;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
input[type="file"]::file-selector-button:hover { background: #6ff5ff; box-shadow: var(--glow-cyan); }

/* ---------- buttons ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0 0;
}
.actions--samples { margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 2.75rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.05rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  transition: transform var(--duration-fast) var(--ease-out-expo),
    box-shadow var(--duration-fast) var(--ease-out-expo),
    border-color var(--duration-fast) ease, background-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }

.btn-ghost { background: rgba(20, 20, 32, 0.6); color: var(--dim); }
.btn-ghost:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: var(--glow-cyan); }

.btn-primary {
  color: var(--bg);
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(69, 240, 255, 0.4), 0 6px 18px rgba(69, 240, 255, 0.2);
}
.btn-primary:hover {
  background: #6ff5ff;
  box-shadow: 0 0 0 1px var(--cyan), 0 8px 26px rgba(69, 240, 255, 0.4);
}

.btn-run {
  color: var(--bg);
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(65, 255, 139, 0.4), 0 6px 18px rgba(65, 255, 139, 0.2);
}
.btn-run:hover {
  background: #6affa6;
  box-shadow: 0 0 0 1px var(--green), 0 8px 26px rgba(65, 255, 139, 0.42);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
  box-shadow: none;
  color: var(--faint);
  border-color: var(--line);
  background: var(--surface);
}
.btn:disabled:hover { color: var(--faint); border-color: var(--line); }

/* ---------- status line ---------- */
.status {
  min-height: 1.4rem;
  margin: 1rem 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--dim);
  padding-left: 1.1rem;
  position: relative;
}
.status::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--green);
  font-weight: 700;
}
.status.error {
  color: var(--red);
  font-weight: 600;
}
.status.error::before { content: "✕"; color: var(--red); }

/* ---------- data tables ---------- */
.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 8, 14, 0.6);
  max-height: 26rem;
  scrollbar-color: var(--line) transparent;
}
.table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 2px solid var(--surface);
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

.data-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 38rem;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.data-grid caption {
  padding: 2.5rem 1rem;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.85rem;
  caption-side: top;
  text-align: center;
}

.data-grid th,
.data-grid td {
  border-bottom: 1px solid var(--line-soft);
  padding: 0.6rem 0.85rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.data-grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--cyan);
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line);
  box-shadow: 0 1px 0 rgba(69, 240, 255, 0.12);
}
.panel--query .data-grid th { color: var(--magenta); }

.data-grid tbody tr { transition: background-color var(--duration-fast) ease; }
.data-grid tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.018); }
.data-grid tbody tr:hover td { background: rgba(69, 240, 255, 0.06); }
.panel--query .data-grid tbody tr:hover td { background: rgba(255, 61, 139, 0.07); }
.data-grid tbody tr:last-child td { border-bottom: 0; }

.data-grid td { color: var(--text); }
.empty-cell { color: var(--faint); font-style: italic; }
.empty-cell::after { content: "∅"; }

/* ---------- footer ---------- */
.site-footer {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: clamp(2rem, 5vw, 3.5rem) 1.25rem clamp(2.5rem, 5vw, 3.5rem);
  border-top: 1px solid var(--line);
  margin-top: 1rem;
}
.footer-flavor {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-shadow: var(--glow-gold);
}
.footer-copy { font-family: var(--mono); font-size: 0.82rem; color: var(--faint); }
.footer-copy a { color: var(--dim); }
.footer-copy a:hover { color: var(--cyan); }

/* ---------- responsive ---------- */
@media (min-width: 960px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .lab-link { font-size: 8px; padding: 0.55rem 0.7rem; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .actions--samples .btn { flex: 1 1 auto; }
  .data-grid { font-size: 0.8rem; }
  .panel::after { font-size: 26px; }
}

@media (max-width: 360px) {
  .site-header { padding-top: 4.25rem; }
  .data-grid th, .data-grid td { padding: 0.5rem 0.6rem; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor,
  .privacy-dot { animation: none !important; }
  .btn:hover,
  .btn:active,
  .lab-link:hover,
  .lab-link:focus-visible { transform: none; }
  .data-grid tbody tr,
  .btn,
  .lab-link,
  select,
  textarea,
  input[type="file"] { transition: none; }
}
