/* ============================================================
   QuizForge — shared design tokens & components
   Modernized utility-app system. Teal accent.
   All scoped under .qf so it never touches the canvas chrome.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Schibsted+Grotesk:wght@400;500;600;700;800;900&family=Public+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

.qf {
  /* palette */
  --teal: #0E7C66;
  --teal-strong: #0A6452;
  --teal-deep: #073f34;
  --teal-tint: #E7F3EF;
  --teal-tint-2: #D4E9E2;
  --teal-ring: rgba(14, 124, 102, 0.22);

  --ink: #14201C;
  --ink-2: #2C3A35;
  --muted: #5E6E68;
  --faint: #8A988F;

  --line: #E4E9E6;
  --line-2: #D7DEDA;
  --surface: #FFFFFF;
  --canvas: #F6F8F7;
  --canvas-2: #EFF3F1;

  --pass: #0E7C66;
  --pass-tint: #E4F3ED;
  --warn: #C77A12;
  --warn-tint: #FBF1E0;
  --fail: #C7453B;
  --fail-tint: #FBEBE9;

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(20, 40, 34, 0.05);
  --shadow-sm: 0 1px 3px rgba(20, 40, 34, 0.07), 0 1px 2px rgba(20, 40, 34, 0.04);
  --shadow-md: 0 6px 18px rgba(20, 40, 34, 0.08), 0 2px 6px rgba(20, 40, 34, 0.05);
  --shadow-lg: 0 18px 48px rgba(15, 50, 40, 0.14), 0 6px 16px rgba(15, 50, 40, 0.07);
  --shadow-teal: 0 10px 26px rgba(14, 124, 102, 0.30);

  --font: 'Public Sans', system-ui, -apple-system, sans-serif;
  --display: 'Schibsted Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  font-family: var(--font);
  color: var(--ink);
  background: var(--surface);
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.qf *, .qf *::before, .qf *::after { box-sizing: border-box; }
.qf p { margin: 0; }
.qf button { font-family: inherit; }

/* ---------- typography helpers ---------- */
.qf-display { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; color: var(--ink); line-height: 1.02; }
.qf-kicker { font-family: var(--display); font-weight: 700; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--teal); }
.qf-mono { font-family: var(--mono); }
.qf-lead { color: var(--muted); line-height: 1.55; font-size: 15px; }

/* ---------- brand mark ---------- */
.qf-mark {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--teal) 0%, var(--teal-strong) 60%, var(--teal-deep) 100%);
  box-shadow: var(--shadow-teal);
  flex: none;
}
.qf-mark svg { display: block; }
.qf-wordmark { font-family: var(--display); font-weight: 800; letter-spacing: -0.025em; color: var(--ink); }
.qf-wordmark b { color: var(--teal); font-weight: 800; }

/* ---------- buttons ---------- */
.qf-btn {
  --bg: var(--teal); --fg: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: -0.005em;
  padding: 0 20px; height: 46px; border-radius: var(--r-md); border: none;
  background: var(--bg); color: var(--fg); cursor: pointer;
  transition: transform .14s cubic-bezier(.2,.7,.3,1), box-shadow .18s, background .18s, filter .18s;
  white-space: nowrap; box-shadow: var(--shadow-teal);
}
.qf-btn:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 14px 32px rgba(14,124,102,.36); }
.qf-btn:active { transform: translateY(0); filter: brightness(.97); }
.qf-btn svg { width: 18px; height: 18px; }

.qf-btn--ghost {
  background: var(--surface); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-xs);
}
.qf-btn--ghost:hover { background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-sm); filter: none; transform: translateY(-1px); }

.qf-btn--soft {
  background: var(--teal-tint); color: var(--teal-strong); box-shadow: none;
}
.qf-btn--soft:hover { background: var(--teal-tint-2); box-shadow: none; filter: none; }

.qf-btn--sm { height: 38px; font-size: 13.5px; padding: 0 14px; border-radius: var(--r-sm); gap: 7px; }
.qf-btn--sm svg { width: 15px; height: 15px; }

.qf-btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; filter: none; }

/* link-ish quiet action */
.qf-link {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-weight: 600; font-size: 13.5px; color: var(--teal-strong); background: none; border: none; padding: 4px 2px;
  transition: color .15s;
}
.qf-link:hover { color: var(--teal-deep); }
.qf-link svg { width: 15px; height: 15px; }

/* ---------- paste box ---------- */
.qf-paste {
  position: relative; width: 100%;
  background: var(--canvas); border: 1.5px dashed var(--line-2); border-radius: var(--r-lg);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.qf-paste:hover { border-color: var(--teal-tint-2); background: var(--surface); }
.qf-paste--focus { border-style: solid; border-color: var(--teal); background: var(--surface); box-shadow: 0 0 0 4px var(--teal-ring); }
.qf-paste-inner { padding: 22px 22px 18px; min-height: 190px; display: flex; flex-direction: column; gap: 14px; }
.qf-paste-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 26px 20px; color: var(--muted); flex: 1; }
.qf-paste-empty .qf-dropicon { width: 46px; height: 46px; border-radius: 13px; background: var(--teal-tint); color: var(--teal); display: flex; align-items: center; justify-content: center; }
.qf-paste-empty .qf-dropicon svg { width: 24px; height: 24px; }
.qf-paste-empty h4 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -.01em; }
.qf-paste-empty p { font-size: 13.5px; max-width: 320px; line-height: 1.5; }
.qf-paste-empty .qf-or { font-size: 12px; color: var(--faint); }

/* ---------- check pills (validation) ---------- */
.qf-checks { display: flex; flex-wrap: wrap; gap: 9px; }
.qf-check {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px 8px 10px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: var(--canvas); color: var(--faint); box-shadow: inset 0 0 0 1px var(--line);
  transition: background .3s, color .3s, box-shadow .3s, transform .3s;
  opacity: 0; transform: translateY(8px) scale(.96);
}
.qf-check.in { opacity: 1; transform: none; }
.qf-check .qf-dot {
  width: 18px; height: 18px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--line-2); color: #fff; transition: background .3s;
}
.qf-check .qf-dot svg { width: 11px; height: 11px; opacity: 0; transform: scale(.5); transition: opacity .25s, transform .25s; }
.qf-check--running { color: var(--ink-2); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }
.qf-check--running .qf-dot { background: var(--teal); animation: qf-spin 0.7s linear infinite; }
.qf-check--running .qf-dot::after { content:''; width: 9px; height: 9px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; }
.qf-check--pass { color: var(--teal-deep); background: var(--pass-tint); box-shadow: inset 0 0 0 1px rgba(14,124,102,.22); }
.qf-check--pass .qf-dot { background: var(--pass); animation: qf-pop .35s cubic-bezier(.2,1.4,.4,1); }
.qf-check--pass .qf-dot svg { opacity: 1; transform: none; }
.qf-check--fail { color: var(--fail); background: var(--fail-tint); box-shadow: inset 0 0 0 1px rgba(199,69,59,.25); }
.qf-check--fail .qf-dot { background: var(--fail); }
.qf-check--fail .qf-dot svg { opacity: 1; transform: none; }

@keyframes qf-spin { to { transform: rotate(360deg); } }
@keyframes qf-pop { 0% { transform: scale(.4);} 60%{transform: scale(1.18);} 100%{transform: scale(1);} }

/* ---------- success panel ---------- */
.qf-success {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px;
  background: linear-gradient(120deg, var(--pass-tint), var(--surface) 80%);
  border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px rgba(14,124,102,.18);
}
.qf-success-badge { width: 46px; height: 46px; border-radius: 13px; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; box-shadow: var(--shadow-teal); animation: qf-pop .4s cubic-bezier(.2,1.4,.4,1); }
.qf-success-badge svg { width: 26px; height: 26px; }
.qf-success h4 { margin: 0 0 2px; font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--teal-deep); letter-spacing: -.01em; }
.qf-success p { font-size: 13px; color: var(--ink-2); line-height: 1.45; }

/* reveal wrapper */
.qf-reveal { overflow: hidden; }
.qf-fade-up { animation: qf-fadeup .5s cubic-bezier(.2,.7,.3,1) both; }
@keyframes qf-fadeup { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- step chip / how-it-works ---------- */
.qf-stepnum {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: 13px;
  background: var(--teal-tint); color: var(--teal-strong);
}
.qf-stepnum--solid { background: var(--teal); color: #fff; }

/* small util */
.qf-tag {
  font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--teal-strong);
  background: var(--teal-tint); padding: 2px 7px; border-radius: 6px;
}
.qf-divider { height: 1px; background: var(--line); width: 100%; }
.qf-priv {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--canvas); padding: 6px 12px 6px 9px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line);
}
.qf-priv svg { width: 14px; height: 14px; color: var(--teal); }

/* ---------- bundle-contents pill ---------- */
.qf-bundle {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--canvas); border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line);
  padding: 7px 16px 7px 15px;
}
.qf-bundle-label { font-family: var(--display); font-weight: 700; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.qf-bundle-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.qf-bundle-item svg { width: 15px; height: 15px; color: var(--teal); flex: none; }
.qf-bundle-sep { width: 1px; height: 16px; background: var(--line-2); flex: none; }

/* ---------- import guide ---------- */
.qf-import { background: var(--surface); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line); padding: 18px 20px; }
.qf-import-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; flex-wrap: wrap; }
.qf-import-title { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--ink); display: inline-flex; align-items: center; gap: 9px; }
.qf-import-title svg { flex: none; }
.qf-isteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.qf-isteps li { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.qf-istep-num {
  flex: none; width: 22px; height: 22px; border-radius: 7px;
  background: var(--teal-tint); color: var(--teal-strong);
  font-family: var(--display); font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.qf-isteps code { font-family: var(--mono); font-weight: 500; color: var(--teal-strong); background: var(--teal-tint); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.qf-isteps .qf-ui { font-weight: 700; color: var(--ink); }
.qf-kebab-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px; vertical-align: -4px; margin: 0 1px;
  background: var(--canvas-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2);
}
.qf-kebab-ico svg { width: 13px; height: 13px; }
.qf-tip {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 13px 15px;
  background: var(--warn-tint); border-radius: var(--r-md); font-size: 13px; line-height: 1.5; color: var(--ink-2);
}
.qf-tip svg { flex: none; color: var(--warn); margin-top: 1px; }
.qf-tip .qf-ui { font-weight: 700; color: var(--ink); }
.qf-import-foot { margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- import modal ---------- */
.qf-modal-backdrop {
  position: fixed; inset: 0; z-index: 60; padding: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 32, 27, 0.42); animation: qf-fadeup .18s ease;
}
.qf-modal { position: relative; width: 560px; max-width: 100%; }
.qf-modal .qf-import { box-shadow: var(--shadow-lg); padding: 24px 26px; }
.qf-modal-close {
  position: absolute; top: 16px; right: 16px; width: 30px; height: 30px; border-radius: 8px;
  border: none; cursor: pointer; background: var(--canvas-2); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; transition: background .14s;
}
.qf-modal-close:hover { background: var(--line-2); }
.qf-modal-close svg { width: 16px; height: 16px; }

/* ---------- question types grid ---------- */
.qf-qtypes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qf-qtype {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border-radius: var(--r-md); background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-2); line-height: 1.2;
}
.qf-qtype-ico {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--teal-tint); color: var(--teal-strong);
  display: flex; align-items: center; justify-content: center;
}
.qf-qtype-ico svg { width: 17px; height: 17px; }

/* ============================================================
   Dark mode — token overrides
   Triggered by html[data-theme="dark"] set via JS toggle.
   ============================================================ */

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: #0E1C18;
}

html[data-theme="dark"] .qf {
  --ink:   #DFF0E8;
  --ink-2: #9DBDAC;
  --muted: #628272;
  --faint: #3A5A4A;

  --teal:        #12A882;
  --teal-strong: #18D09E;
  --teal-deep:   #6ECFB2;
  --teal-tint:   rgba(18, 168, 130, 0.14);
  --teal-tint-2: rgba(18, 168, 130, 0.24);
  --teal-ring:   rgba(18, 168, 130, 0.38);

  --line:     #1A3028;
  --line-2:   #142818;
  --surface:  #152820;
  --canvas:   #0E1C18;
  --canvas-2: #112018;

  --pass:       #12A882;
  --pass-tint:  rgba(18, 168, 130, 0.14);
  --fail:       #E05850;
  --fail-tint:  rgba(224, 88, 80, 0.16);
  --warn:       #E89832;
  --warn-tint:  rgba(232, 152, 50, 0.16);

  --shadow-xs:   0 1px 2px rgba(0,0,0,.40);
  --shadow-sm:   0 1px 3px rgba(0,0,0,.50), 0 1px 2px rgba(0,0,0,.30);
  --shadow-md:   0 6px 18px rgba(0,0,0,.50), 0 2px 6px rgba(0,0,0,.30);
  --shadow-lg:   0 18px 48px rgba(0,0,0,.60), 0 6px 16px rgba(0,0,0,.35);
  --shadow-teal: 0 10px 26px rgba(18, 168, 130, .40);
}

html[data-theme="dark"] .qf-modal-backdrop {
  background: rgba(0,0,0,.65);
}

html[data-theme="dark"] .qf-revision textarea {
  background: rgba(255,255,255,.05);
}

/* Smooth transition only during theme switch (class added/removed by JS) */
html.qf-transitioning .qf,
html.qf-transitioning .qf * {
  transition: background-color .25s, border-color .25s, color .2s, box-shadow .25s !important;
}
