/* ═══════════════════════════════════════════════════════════════════════
   CORKBOARD STUDIO — TUTORIAL SYSTEM  v2.0
   Cecil B. Slate — Director Character + Blur Spotlight Overlay
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Root layer (pointer-events OFF — children handle interactivity) ─ */
#cbs-tut-root {
  position: fixed;
  inset: 0;
  z-index: 98000;
  pointer-events: none;
}

/* ── Blur + dark overlay ─────────────────────────────────────────────
   SVG mask-image is set in JS to cut a transparent hole over the
   spotlight target. Everything outside the hole gets blurred + dimmed.
   pointer-events: auto blocks clicks on the blurred (non-spotlight) area.
   ─────────────────────────────────────────────────────────────────── */
#cbs-tut-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 30, 0.60);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  pointer-events: auto;   /* blocks accidental clicks on the app */
  z-index: 98005;
  transition: opacity 0.28s ease;
  /* mask-image set by JS per-step */
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

/* ── Spotlight ring (glowing border around the target) ───────────────
   Box-shadow creates the pulsing glow; no background so the element
   beneath stays fully visible and interactive.
   ─────────────────────────────────────────────────────────────────── */
.cbs-tut-spotlight {
  position: fixed;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  /* glow ring that animates */
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18),
              0 0 22px 6px rgba(255, 255, 255, 0.22),
              0 0 0 9999px transparent; /* no overlay — handled by #cbs-tut-overlay */
  pointer-events: none;
  z-index: 98015;
  /* smooth movement when spotlight changes target */
  transition: top    .42s cubic-bezier(.4,0,.2,1),
              left   .42s cubic-bezier(.4,0,.2,1),
              width  .42s cubic-bezier(.4,0,.2,1),
              height .42s cubic-bezier(.4,0,.2,1),
              border-radius .3s ease,
              opacity .25s ease;
  animation: cbsSpotPulse 2.4s ease-in-out infinite;
  will-change: top, left, width, height;
}

@keyframes cbsSpotPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(255,255,255,.55),
                0 0 18px 4px rgba(255,255,255,.22);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(255,255,255,.80),
                0 0 32px 10px rgba(255,255,255,.36);
  }
}

/* ── Sticky Note ─────────────────────────────────────────────────────── */
.cbs-tut-note {
  position: fixed;
  background: #fef9c3;
  border-radius: 3px 7px 7px 3px;
  padding: 24px 18px 16px;
  width: 296px;
  box-shadow: 4px 5px 20px rgba(0,0,0,.30),
              1px 1px 0 rgba(0,0,0,.06) inset,
              -1px 0 0 #fde68a inset;
  z-index: 98025;
  pointer-events: all;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  animation: cbsNoteIn .38s cubic-bezier(.34,1.56,.64,1) both;
  border-left: 5px solid #f59e0b;
  /* subtle paper texture via repeating gradient */
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    rgba(234,179,8,.12) 28px
  );
}

/* Tape strip */
.cbs-tut-tape {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-1.2deg);
  width: 58px;
  height: 24px;
  background: rgba(253, 230, 138, 0.80);
  border-radius: 3px;
  box-shadow: 0 1px 5px rgba(0,0,0,.18);
}
.cbs-tut-tape::after {
  content: '';
  position: absolute;
  inset: 3px 6px;
  background: rgba(255,255,255,.25);
  border-radius: 2px;
}

/* Step counter */
.cbs-tut-step-label {
  font-size: .58rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #92400e;
  margin-bottom: 6px;
  opacity: .8;
}

.cbs-tut-note-title {
  font-size: 1rem;
  font-weight: 800;
  color: #1c1917;
  margin: 0 0 9px;
  line-height: 1.3;
}

.cbs-tut-note-body {
  font-size: .83rem;
  color: #3b3223;
  line-height: 1.68;
  margin: 0 0 8px;
}

.cbs-tut-tip {
  font-size: .75rem;
  color: #78350f;
  font-style: italic;
  border-top: 1px dashed rgba(245,158,11,.5);
  padding-top: 8px;
  margin-bottom: 10px;
  line-height: 1.55;
}

/* Nav row */
.cbs-tut-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 10px;
  border-top: 1px solid rgba(245,158,11,.25);
  padding-top: 9px;
}

.cbs-tut-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 108px;
}
.cbs-tut-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 1.5px solid #d1d5db;
  transition: background .2s, transform .2s, border-color .2s;
  flex-shrink: 0;
}
.cbs-tut-dot.active {
  background: #2563eb;
  border-color: #2563eb;
  transform: scale(1.4);
}
.cbs-tut-dot.done {
  background: #16a34a;
  border-color: #16a34a;
}

/* Buttons */
.cbs-tut-btn {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: .76rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  line-height: 1.4;
}
.cbs-tut-btn:hover  { opacity: .85; }
.cbs-tut-btn:active { transform: scale(.95); }

.cbs-tut-btn-skip {
  background: transparent;
  color: #a8a29e;
  padding: 5px 2px;
  font-size: .7rem;
  font-weight: 600;
}
.cbs-tut-btn-skip:hover { color: #78716c; opacity: 1; }

.cbs-tut-btn-prev {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}
.cbs-tut-btn-next {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.cbs-tut-btn-next:hover { background: #1d4ed8; opacity: 1; }
.cbs-tut-btn-done {
  background: #16a34a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,.35);
}
.cbs-tut-btn-done:hover { background: #15803d; opacity: 1; }

/* Arrow connector */
.cbs-tut-arrow {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 98020;
  border: 11px solid transparent;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.15));
}
.cbs-tut-arrow.above { border-bottom-color: #fef9c3; border-top: none; }
.cbs-tut-arrow.below { border-top-color: #fef9c3;    border-bottom: none; }
.cbs-tut-arrow.left  { border-right-color: #fef9c3;  border-left: none; }
.cbs-tut-arrow.right { border-left-color: #fef9c3;   border-right: none; }

/* ═══════════════════════════════════════════════════════════════════════
   WELCOME / DONE MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.cbs-tut-modal {
  position: fixed;
  inset: 0;
  z-index: 98050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.60);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: all;
  animation: cbsFadeIn .32s ease both;
}
.cbs-tut-modal-card {
  background: #fff;
  border-radius: 22px;
  padding: 42px 32px 30px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 70px rgba(0,0,0,.30);
  text-align: center;
  animation: cbsNoteIn .42s cubic-bezier(.34,1.56,.64,1) both;
  position: relative;
  overflow: visible;
}
.cbs-tut-modal-slate {
  position: absolute;
  top: -68px;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 5px 16px rgba(0,0,0,.35));
}
.cbs-tut-modal-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: #1e3a8a;
  margin: 44px 0 10px;
  line-height: 1.3;
}
.cbs-tut-modal-body {
  font-size: .87rem;
  color: #374151;
  line-height: 1.72;
  margin: 0 0 24px;
}
.cbs-tut-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cbs-tut-modal-start {
  padding: 13px 26px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 13px;
  font-size: .93rem;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, transform .1s;
  box-shadow: 0 3px 12px rgba(37,99,235,.35);
}
.cbs-tut-modal-start:hover  { background: #1d4ed8; }
.cbs-tut-modal-start:active { transform: scale(.97); }
.cbs-tut-modal-skip {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: .8rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1.5;
}
.cbs-tut-modal-skip:hover { color: #6b7280; }

/* ═══════════════════════════════════════════════════════════════════════
   CECIL B. SLATE — DIRECTOR CHARACTER
   ═══════════════════════════════════════════════════════════════════════ */
.cbs-slate-char {
  position: fixed;
  bottom: 20px;
  right: 22px;
  width: 90px;
  z-index: 98035;
  pointer-events: none;
  transition: right  .55s cubic-bezier(.34,1.56,.64,1),
              bottom .55s cubic-bezier(.34,1.56,.64,1);
  filter: drop-shadow(0 7px 16px rgba(0,0,0,.40));
  animation: cbsSlateEntrance .65s cubic-bezier(.34,1.56,.64,1) both;
}

/* ── Director's Beret ── */
.cbs-slate-hat {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-44%) rotate(-8deg);
  width: 54px;
  height: 18px;
  background: #7f1d1d; /* deep director red */
  border-radius: 70% 70% 20% 20% / 90% 90% 20% 20%;
  z-index: 2;
}
/* Beret band */
.cbs-slate-hat::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: -4px;
  right: -4px;
  height: 6px;
  background: #6b1b1b;
  border-radius: 3px;
}
/* Beret pompom */
.cbs-slate-hat::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* ── Arms ── */
.cbs-slate-arm {
  position: absolute;
  width: 14px;
  height: 38px;
  background: #1a1a2e;
  border-radius: 7px;
  top: 38px;
  transform-origin: top center;
  transition: transform .35s ease;
}
.cbs-slate-arm-l { left: -11px;  transform: rotate(28deg); }
.cbs-slate-arm-r { right: -11px; transform: rotate(-28deg); }

/* Emotion arm angles */
.cbs-slate-char.excited        .cbs-slate-arm-l { transform: rotate(-28deg); }
.cbs-slate-char.excited        .cbs-slate-arm-r { transform: rotate(28deg);  }
.cbs-slate-char.waving         .cbs-slate-arm-r { animation: cbsArmWave .7s ease-in-out infinite; }
.cbs-slate-char.pointing-right .cbs-slate-arm-r { transform: rotate(-65deg); }
.cbs-slate-char.pointing-left  .cbs-slate-arm-l { transform: rotate(65deg);  }
.cbs-slate-char.thinking       .cbs-slate-arm-r { transform: rotate(-85deg); }
.cbs-slate-char.celebrating    .cbs-slate-arm-l { animation: cbsArmCelebL .5s ease-in-out infinite alternate; }
.cbs-slate-char.celebrating    .cbs-slate-arm-r { animation: cbsArmCelebR .5s ease-in-out infinite alternate; }

/* ── Body ── */
.cbs-slate-body {
  width: 90px;
  background: #1a1a2e;
  border-radius: 6px 6px 10px 10px;
  overflow: hidden;
  position: relative;
}

/* ── Clapper ── */
.cbs-slate-clapper {
  width: 100%;
  height: 24px;
  background: repeating-linear-gradient(
    -50deg,
    #fff 0px, #fff 7px,
    #111827 7px, #111827 14px
  );
  border-radius: 4px 4px 0 0;
  transform-origin: left center;
  transition: transform .15s ease-in-out;
  position: relative;
}
/* Hinge pin */
.cbs-slate-clapper::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #374151;
  border: 1.5px solid #4b5563;
}

/* Clap */
.cbs-slate-char.clapping .cbs-slate-clapper {
  animation: cbsSlateClap .42s ease-in-out 2;
}

/* ── Board info ── */
.cbs-slate-info {
  padding: 4px 6px 2px;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 6.5px;
  color: #9ca3af;
  line-height: 1.6;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Eyes ── */
.cbs-slate-eyes {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 7px 0 3px;
}
.cbs-slate-eye {
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.cbs-slate-pupil {
  width: 10px;
  height: 10px;
  background: #111827;
  border-radius: 50%;
  position: relative;
  transition: transform .2s ease;
}
.cbs-slate-pupil::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
}

/* Eye emotions */
.cbs-slate-char.happy   .cbs-slate-eye     { border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; }
.cbs-slate-char.excited .cbs-slate-eye     { width: 22px; height: 22px; }
.cbs-slate-char.thinking .cbs-slate-eye:last-child { border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%; }

/* ── Mouth ── */
.cbs-slate-mouth {
  display: flex;
  justify-content: center;
  padding: 2px 0 7px;
}
.cbs-slate-smile {
  width: 30px;
  height: 11px;
  border-bottom: 3px solid #fbbf24;
  border-radius: 0 0 15px 15px;
}
.cbs-slate-char.excited .cbs-slate-smile,
.cbs-slate-char.celebrating .cbs-slate-smile {
  border-bottom-color: #f59e0b;
  width: 36px;
}
.cbs-slate-char.thinking .cbs-slate-smile {
  border: none;
  border-left:   3px solid #fbbf24;
  border-bottom: 3px solid #fbbf24;
  border-radius: 0 0 0 12px;
  width: 14px;
  height: 8px;
}

/* ── Feet ── */
.cbs-slate-feet {
  display: flex;
  justify-content: space-around;
  padding: 4px 10px 0;
}
.cbs-slate-foot {
  width: 26px;
  height: 10px;
  background: #111827;
  border-radius: 0 0 8px 8px;
}

/* ── Megaphone (director's tool) on the right arm ── */
.cbs-slate-arm-r::after {
  content: '📣';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%) rotate(20deg);
  font-size: 10px;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes cbsNoteIn {
  from { opacity: 0; transform: scale(.82) translateY(12px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

/* Center-position variant that preserves translate(-50%,-50%) */
.cbs-tut-note.centered {
  animation: cbsNoteInCenter .38s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes cbsNoteInCenter {
  from { opacity: 0; transform: translate(-50%,-50%) scale(.82); }
  to   { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}

@keyframes cbsSlateEntrance {
  from { transform: translateY(130px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@keyframes cbsSlateBounce {
  0%,100% { transform: translateY(0) rotate(0deg); }
  30%     { transform: translateY(-11px) rotate(-2deg); }
  60%     { transform: translateY(-6px)  rotate(1deg); }
}

@keyframes cbsSlateIdle {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

@keyframes cbsSlateClap {
  0%   { transform: rotate(0deg); }
  40%  { transform: rotate(-40deg); }
  70%  { transform: rotate(-40deg); }
  100% { transform: rotate(0deg); }
}

@keyframes cbsArmWave {
  0%,100% { transform: rotate(-28deg); }
  40%     { transform: rotate(-72deg); }
}

@keyframes cbsArmCelebL {
  from { transform: rotate(-52deg); }
  to   { transform: rotate(-10deg); }
}
@keyframes cbsArmCelebR {
  from { transform: rotate(10deg);  }
  to   { transform: rotate(52deg);  }
}

@keyframes cbsFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes cbsBlink {
  0%,88%,100% { transform: scaleY(1); }
  94%          { transform: scaleY(0.08); }
}

/* Idle / emotion body animations */
.cbs-slate-char          { animation: cbsSlateEntrance .65s cubic-bezier(.34,1.56,.64,1) both; }
.cbs-slate-char.idle     { animation: cbsSlateEntrance .65s cubic-bezier(.34,1.56,.64,1) both,
                                       cbsSlateIdle 2.6s 0.7s ease-in-out infinite; }
.cbs-slate-char.bouncing { animation: cbsSlateBounce 1s ease-in-out infinite; }

.cbs-slate-eye.blinking  { animation: cbsBlink .28s ease-in-out; }

/* ═══════════════════════════════════════════════════════════════════════
   HELP BUTTON — hidden; tutorial access moved into Tools & Settings menu
   ═══════════════════════════════════════════════════════════════════════ */
#cbs-tut-help-btn {
  display: none !important;
  pointer-events: none !important;
}

/* Tutorial picker menu — centred modal-style when launched from Tools menu */
#cbs-tut-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  bottom: auto;
  right: auto;
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  width: 280px;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
  z-index: 97500;
  animation: cbsNoteIn .26s cubic-bezier(.34,1.56,.64,1) both;
  border: 1px solid #e5e7eb;
  transform-origin: center center;
}
#cbs-tut-menu h4 {
  margin: 0 0 10px;
  font-size: .8rem;
  font-weight: 900;
  color: #1e3a8a;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.cbs-tut-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: .82rem;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  transition: background .12s;
}
.cbs-tut-menu-item:hover { background: #eff6ff; color: #1d4ed8; }
.cbs-tut-menu-item .cbs-tut-menu-done {
  margin-left: auto;
  font-size: .64rem;
  color: #16a34a;
  font-weight: 900;
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .cbs-tut-note {
    width: 90vw;
    max-width: 340px;
    padding: 22px 14px 14px;
    font-size: .85rem;
  }
  .cbs-slate-char {
    transform: scale(.85);
    transform-origin: bottom right;
  }
  #cbs-tut-menu {
    width: calc(100vw - 32px);
  }
}
