/* In-app tutorials: app-bar pill, overlay, intro, CSS scenes */

#quizly-tutorials-btn {
  display: none;
  align-items: center;
  gap: 0.35rem;
  background: #f5a623;
  color: #1a1204;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.45);
  font-family: inherit;
  font-size: 0.8rem;
}
#quizly-tutorials-btn.is-visible {
  display: inline-flex;
}
#quizly-tutorials-btn:hover,
#quizly-tutorials-btn:focus-visible {
  background: #ffb43a;
  color: #1a1204;
  outline: 2px solid #1a1204;
  outline-offset: 2px;
}

.qly-tut-overlay {
  position: fixed;
  inset: 0;
  z-index: 96;
  background: rgba(9, 9, 11, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.qly-tut-overlay[hidden],
.qly-tut-intro[hidden] {
  display: none !important;
}

.qly-tut-dialog {
  background: #fff;
  color: #18181b;
  border-radius: 1.5rem;
  width: min(920px, 96vw);
  max-height: min(88vh, 820px);
  overflow: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  padding: 1.15rem 1.25rem 1.35rem;
  border: 1px solid #e4e4e7;
}
html.dark .qly-tut-dialog {
  background: #18181b;
  color: #fafafa;
  border-color: #3f3f46;
}

.qly-tut-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.qly-tut-dialog__head h2 {
  margin: 0;
  font-size: 1.25rem;
}
.qly-tut-dialog__sub {
  margin: 0.2rem 0 0;
  color: #71717a;
  font-size: 0.9rem;
}
html.dark .qly-tut-dialog__sub {
  color: #a1a1aa;
}

.qly-tut-close,
.qly-tut-back {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem 0.4rem;
  color: inherit;
}

.qly-tut-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

button.qly-tut-card,
.qly-tut-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0;
  border: 1px solid #e4e4e7;
  border-radius: 1rem;
  padding: 0.75rem;
  background: #fff !important;
  text-align: left;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto !important;
  min-height: 0 !important;
  font: inherit;
  color: inherit;
  white-space: normal !important;
  line-height: 1.35;
  overflow: hidden;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  text-transform: none;
  isolation: isolate;
}
html.dark button.qly-tut-card,
html.dark .qly-tut-card {
  background: #27272a !important;
  border-color: #3f3f46;
}
.qly-tut-card:hover,
.qly-tut-card:focus-visible {
  border-color: #f5a623;
  box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.35);
  outline: none;
}
.qly-tut-card__thumb {
  flex: 0 0 72px;
  height: 72px;
  width: 100%;
  border-radius: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
}
.qly-tut-card__thumb--ai-builder { background: #6d28d9; }
.qly-tut-card__thumb--question-types { background: #1d4ed8; }
.qly-tut-card__thumb--submissions-marking { background: #0f766e; }
.qly-tut-card__thumb--automarking { background: #a16207; }
.qly-tut-card__thumb--export-filter { background: #0369a1; }
.qly-tut-card__thumb--teams-invites { background: #be185d; }
.qly-tut-card__thumb--share-quiz { background: #15803d; }
.qly-tut-card__thumb--guest-account { background: #7c3aed; }
.qly-tut-card__thumb--workspaces { background: #57534e; }
.qly-tut-card__thumb--add-from-file { background: #334155; }

.qly-tut-card__title {
  font-weight: 700;
  font-size: 1rem;
  white-space: normal;
  overflow-wrap: anywhere;
}
.qly-tut-card__blurb {
  color: #71717a;
  font-size: 0.85rem;
  margin-top: 0.25rem;
  white-space: normal !important;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
html.dark .qly-tut-card__blurb {
  color: #a1a1aa;
}

.qly-tut-detail {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1rem;
  align-items: start;
}
.qly-tut-detail__why {
  margin: 0.5rem 0 0.75rem 1.1rem;
  padding: 0;
}

.qly-tut-open {
  display: inline-flex;
  align-items: center;
  background: #f5a623;
  color: #1a1204;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  margin: 0.25rem 0.4rem 0 0;
}
.qly-tut-open:hover,
.qly-tut-open:focus-visible {
  background: #ffb43a;
  color: #1a1204;
  outline: 2px solid #1a1204;
  outline-offset: 2px;
}

.qly-tut-scene {
  background: #f4f4f5;
  border-radius: 1rem;
  padding: 0.75rem;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid #e4e4e7;
}
html.dark .qly-tut-scene {
  background: #27272a;
  border-color: #3f3f46;
}
.qly-tut-scene__caption {
  font-size: 0.85rem;
  color: #71717a;
  margin-bottom: 0.5rem;
  line-height: 1.35;
  min-height: 2.7em;
}
html.dark .qly-tut-scene__caption {
  color: #a1a1aa;
}

.qly-tut-replay,
.qly-tut-next-step {
  margin-top: 0.5rem;
  background: transparent;
  border: 1px solid #d4d4d8;
  border-radius: 0.5rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
html.dark .qly-tut-replay,
html.dark .qly-tut-next-step {
  border-color: #3f3f46;
}

.qly-tut-intro {
  position: fixed;
  inset: 0;
  z-index: 97;
  background: rgba(9, 9, 11, 0.4);
  pointer-events: auto;
}
.qly-tut-intro__tip {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: #fff;
  color: #18181b;
  border-radius: 0.75rem;
  padding: 0.5rem 0.7rem;
  max-width: min(360px, 80vw);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  border: 1px solid #e4e4e7;
}
html.dark .qly-tut-intro__tip {
  background: #27272a;
  color: #fafafa;
  border-color: #3f3f46;
}
.qly-tut-intro__skip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  border-radius: 0.5rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font: inherit;
}

.qly-tut-cursor {
  position: fixed;
  width: 18px;
  height: 18px;
  z-index: 98;
  pointer-events: none;
  background: #fff;
  clip-path: polygon(0 0, 0 100%, 28% 72%, 55% 100%, 68% 92%, 42% 62%, 100% 62%);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  transform: translate(-4px, -2px);
}

#quizly-tutorials-btn.qly-tut-pulse {
  animation: qly-tut-pulse 0.35s ease-in-out 2;
}
@keyframes qly-tut-pulse {
  50% { transform: scale(1.06); }
}

/* Mini scenes: 4 steps, ~3s each, 12s loop */
.qly-tut-mini {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 0.75rem;
  padding: 0.55rem;
  min-height: 188px;
  height: 188px;
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
}
html.dark .qly-tut-mini {
  background: #18181b;
  border-color: #3f3f46;
}
.qly-tut-mini .s {
  position: absolute;
  inset: 0.55rem;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  animation: qly-tut-step 12s linear infinite;
}
.qly-tut-mini .s:nth-child(1) { animation-delay: 0s; }
.qly-tut-mini .s:nth-child(2) { animation-delay: 3s; }
.qly-tut-mini .s:nth-child(3) { animation-delay: 6s; }
.qly-tut-mini .s:nth-child(4) { animation-delay: 9s; }
@keyframes qly-tut-step {
  0% { opacity: 0; }
  4% { opacity: 1; }
  22% { opacity: 1; }
  25% { opacity: 0; }
  100% { opacity: 0; }
}
.qly-tut-mini .hl {
  outline: 2px solid #f5a623;
  outline-offset: 1px;
  border-radius: 6px;
}

.tut-ui-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8a94a0;
}
html.dark .tut-ui-kicker {
  color: #a1a1aa;
}
.tut-ui-nav,
.tut-ui-months,
.tut-ui-chips {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.tut-ui-nav span,
.tut-ui-months span,
.tut-ui-chips span {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: #eef2f6;
  color: #445;
}
html.dark .tut-ui-nav span,
html.dark .tut-ui-months span,
html.dark .tut-ui-chips span {
  background: #3f3f46;
  color: #e4e4e7;
}
.tut-ui-nav .on,
.tut-ui-months .on,
.tut-ui-chips .on {
  background: #f5a623;
  color: #1a1204;
  font-weight: 700;
}
.tut-ui-search {
  font-size: 0.78rem;
  color: #8a94a0;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
html.dark .tut-ui-search {
  color: #a1a1aa;
  border-color: #3f3f46;
}
.tut-ui-grid {
  display: grid;
  grid-template-columns: 52px repeat(5, 1fr);
  gap: 3px;
  flex: 1;
  min-height: 0;
}
.tut-ui-grid .lab {
  font-size: 0.65rem;
  color: #6b7785;
  display: flex;
  align-items: center;
}
html.dark .tut-ui-grid .lab {
  color: #a1a1aa;
}
.tut-ui-grid .d {
  background: #f4f7fa;
  border-radius: 3px;
  min-height: 22px;
  position: relative;
}
html.dark .tut-ui-grid .d {
  background: #27272a;
}
.tut-ui-bar {
  position: absolute;
  left: 4%;
  right: 8%;
  top: 5px;
  height: 10px;
  border-radius: 3px;
  background: #7eb6d9;
}
.tut-ui-bar.clash { background: #e67e22; top: 16px; width: 55%; right: auto; }
.tut-ui-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem;
  flex: 1;
}
.tut-ui-tiles > div {
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  padding: 0.4rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
}
html.dark .tut-ui-tiles > div {
  background: #27272a;
  border-color: #3f3f46;
}
.tut-ui-phone {
  border: 1px solid #d8dee6;
  border-radius: 10px;
  padding: 0.5rem;
  font-size: 0.78rem;
  flex: 1;
}
html.dark .tut-ui-phone {
  border-color: #3f3f46;
}
.tut-ui-phone .id {
  border: 1px solid #cfd6de;
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  margin: 0.35rem 0;
  color: #5a6b7a;
}
html.dark .tut-ui-phone .id {
  border-color: #3f3f46;
  color: #a1a1aa;
}
.tut-ui-qr {
  width: 52px;
  height: 52px;
  background:
    repeating-linear-gradient(90deg, #222 0 4px, transparent 4px 8px),
    repeating-linear-gradient(#222 0 4px, transparent 4px 8px);
  background-size: 16px 16px;
  border-radius: 4px;
}
html.dark .tut-ui-qr {
  background:
    repeating-linear-gradient(90deg, #e4e4e7 0 4px, transparent 4px 8px),
    repeating-linear-gradient(#e4e4e7 0 4px, transparent 4px 8px);
  background-size: 16px 16px;
}
.tut-ui-form {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}
.tut-ui-field {
  border: 1px solid #d8dee6;
  border-radius: 5px;
  padding: 0.28rem 0.4rem;
  font-size: 0.75rem;
  color: #5a6b7a;
  background: #fafbfc;
}
html.dark .tut-ui-field {
  border-color: #3f3f46;
  color: #a1a1aa;
  background: #27272a;
}
.tut-ui-drop {
  flex: 1;
  border: 1px dashed #b7c2cc;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #6b7785;
  background: #f7fafc;
  min-height: 48px;
}
html.dark .tut-ui-drop {
  border-color: #52525b;
  color: #a1a1aa;
  background: #27272a;
}
.tut-ui-table {
  font-size: 0.72rem;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  overflow: hidden;
}
html.dark .tut-ui-table {
  border-color: #3f3f46;
}
.tut-ui-table div {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 0.28rem 0.4rem;
  gap: 0.3rem;
}
.tut-ui-table .head { background: #eef2f6; font-weight: 700; }
html.dark .tut-ui-table .head { background: #3f3f46; }
.tut-ui-ok { color: #1ba261; font-weight: 700; }

@media (max-width: 720px) {
  .qly-tut-grid { grid-template-columns: 1fr; }
  .qly-tut-detail { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .qly-tut-mini .s {
    animation: none;
    opacity: 0;
    position: absolute;
    display: flex;
    flex-direction: column;
    pointer-events: none;
  }
  .qly-tut-mini .s.is-current {
    opacity: 1;
    pointer-events: auto;
  }
  #quizly-tutorials-btn.qly-tut-pulse { animation: none; }
  .qly-tut-cursor { display: none !important; }
}
