/* ParsonPython — drag-to-order Python puzzles */

:root {
  --bg: #0b1020;
  --bg-2: #111a31;
  --panel: #151f38;
  --panel-2: #1b2743;
  --line: #24324f;
  --ink: #eaf0ff;
  --ink-dim: #9fb0d0;
  --ink-faint: #6d7fa3;
  --accent: #4da3ff;
  --accent-2: #7ee0c0;
  --gold: #ffd166;
  --bad: #ff7b8a;
  --good: #58d69b;
  --radius: 14px;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(77, 163, 255, .20), transparent 60%),
    radial-gradient(900px 520px at 92% 0%, rgba(126, 224, 192, .14), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, .72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: #06122a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 12.5px; color: var(--ink-faint); }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.progress { display: flex; gap: 7px; }

.progress i {
  width: 26px;
  height: 6px;
  border-radius: 99px;
  background: var(--line);
  transition: background .25s ease;
}
.progress i.done { background: var(--good); }
.progress i.current { background: var(--accent); }

/* ------------------------------------------------------------------ layout */

.stage {
  flex: 1;
  width: min(860px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 44px) clamp(16px, 4vw, 40px) 60px;
}

.puzzle-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.kicker {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(126, 224, 192, .12);
  border: 1px solid rgba(126, 224, 192, .3);
  border-radius: 99px;
  padding: 3px 10px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.4vw, 32px);
  letter-spacing: -.02em;
  line-height: 1.15;
}

.goal { margin: 0; color: var(--ink-dim); max-width: 60ch; line-height: 1.6; }

.hint {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: rgba(255, 209, 102, .09);
  color: #f6e3b6;
  line-height: 1.55;
}

/* ------------------------------------------------------------------ editor */

.editor {
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  box-shadow: 0 24px 60px rgba(3, 8, 22, .5);
  overflow: hidden;
}

.editor-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
}

.dots { display: flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots i:first-child { background: #3d4a68; }

.filename { font-family: var(--mono); font-size: 13px; color: var(--ink-dim); }
.editor-note { margin-left: auto; font-size: 12px; color: var(--ink-faint); }

.lines {
  list-style: none;
  margin: 0;
  padding: 12px;
  counter-reset: ln;
}

.line {
  counter-increment: ln;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 12px;
  margin: 6px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 14.5px;
  white-space: pre;
  overflow-x: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.line:hover { border-color: #33456b; background: #1f2c4c; }

.line:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, .28);
}

.line::before {
  content: counter(ln);
  flex: none;
  width: 20px;
  text-align: right;
  color: var(--ink-faint);
  font-size: 12.5px;
}

.grip {
  flex: none;
  width: 12px;
  color: var(--ink-faint);
  letter-spacing: 1px;
  font-size: 12px;
}

.code { flex: 1; }

.line.dragging {
  cursor: grabbing;
  border-color: var(--accent);
  background: #22324f;
  box-shadow: 0 18px 36px rgba(0, 0, 0, .45);
  opacity: .96;
}

.placeholder {
  margin: 6px 0;
  border: 1px dashed #3a4d76;
  border-radius: 10px;
  background: rgba(77, 163, 255, .07);
  list-style: none;
}

.line.ok { border-color: rgba(88, 214, 155, .55); background: rgba(88, 214, 155, .10); }
.line.no { border-color: rgba(255, 123, 138, .5); background: rgba(255, 123, 138, .09); }

.lines.locked .line { cursor: default; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.lines.wrong { animation: shake .28s ease; }

/* keyword colouring */
.kw { color: #ff9ecb; }
.fn { color: var(--gold); }
.str { color: var(--accent-2); }
.num { color: #c4b5fd; }
.op { color: var(--ink-dim); }

.a11y-note {
  margin: 12px 2px 0;
  font-size: 12.5px;
  color: var(--ink-faint);
}

kbd {
  font-family: var(--mono);
  font-size: 11.5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--panel-2);
  color: var(--ink-dim);
}

/* ---------------------------------------------------------------- controls */

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.btn {
  font: inherit;
  font-size: 14.5px;
  font-weight: 550;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 11px 20px;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s ease, border-color .18s ease, background .18s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #3a4d76; }
.btn:active { transform: translateY(0); }

.btn.primary {
  border-color: transparent;
  color: #06122a;
  font-weight: 650;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.btn.ghost { background: transparent; color: var(--ink-dim); }
.btn.ghost:hover { color: var(--ink); }

.btn.sm { font-size: 13px; padding: 8px 14px; }

.feedback { margin: 0; font-size: 14px; color: var(--ink-dim); min-height: 1.2em; }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }

/* ------------------------------------------------------------------ result */

.result {
  margin-top: 26px;
  padding: 22px;
  border: 1px solid rgba(88, 214, 155, .35);
  border-radius: var(--radius);
  background: rgba(88, 214, 155, .07);
}

.result-head { display: flex; gap: 14px; align-items: flex-start; }

.result-head h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.result-head p { margin: 0; color: var(--ink-dim); font-size: 14px; }

.tick {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--good);
  color: #052a1c;
  font-weight: 800;
}

.console {
  margin: 16px 0 18px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #080e1c;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--accent-2);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ------------------------------------------------------------------ finish */

.finish { text-align: center; padding: 40px 0 20px; }
.trophy { font-size: 60px; line-height: 1; margin-bottom: 12px; }
.finish h1 { margin-bottom: 14px; }
.finish p { color: var(--ink-dim); max-width: 54ch; margin: 0 auto; line-height: 1.7; }
.finish code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}
.finish-actions { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* -------------------------------------------------------------------- foot */

.site-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-faint);
}
.site-foot a { color: var(--ink-dim); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

@media (max-width: 640px) {
  .puzzle-head { flex-direction: column; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .line { font-size: 13.5px; }
}

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