/* Splash and tutorial presentation components.
   Component rules extracted from the legacy main application stylesheet. */

/* ── Tutorial button & modal ─────────────────────────────────── */
#tutorial-btn-wrap {
  position: absolute; top: 44px; left: 10px; z-index: 22;
  display: inline-flex; align-items: flex-start;
}
#tutorial-btn {
  position: relative;
  background: #22c55e; color: #fff !important;
  border: none; padding: 5px 11px;
  border-radius: 20px; font-size: 14px; font-weight: 700;
  cursor: pointer; letter-spacing: .4px;
  display: flex; align-items: center; gap: 5px;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s, box-shadow .3s;
  animation: tut-pulse 1.8s ease-in-out infinite;
}
#tutorial-btn svg { stroke: #fff !important; }
#tutorial-btn.seen { animation: none; }
#tutorial-btn:active { transform: scale(.95); }
/* Close ✕ badge — sits at top-right corner of the button */
#tutorial-close-btn {
  position: relative;
  margin-left: -10px; margin-top: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  color: #fff;
  font-size: 9px; font-weight: 900;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 1;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: transform .12s, background .15s;
}
#tutorial-close-btn:active { transform: scale(.85); background: #b91c1c; }

/* ── 5-second intro glow on first load ─────────────────────── */
#tutorial-btn.tut-intro {
  animation: tut-intro-glow 1s ease-in-out infinite;
}
@keyframes tut-intro-glow {
  0%   { box-shadow: 0 0 0 0   rgba(255,220,0,0),
                     0 0 0 0   rgba(255,220,0,0);
         transform: scale(1); }
  30%  { box-shadow: 0 0 0 4px rgba(255,220,0,.9),
                     0 0 22px 8px rgba(255,220,0,.55);
         transform: scale(1.06); }
  60%  { box-shadow: 0 0 0 8px rgba(255,220,0,.4),
                     0 0 32px 12px rgba(255,220,0,.25);
         transform: scale(1.04); }
  100% { box-shadow: 0 0 0 14px rgba(255,220,0,0),
                     0 0 0 0   rgba(255,220,0,0);
         transform: scale(1); }
}

@keyframes tut-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,220,0,.85); }
  50%      { box-shadow: 0 0 0 9px rgba(255,220,0,0); }
}
/* Modal overlay */
#tutorial-modal {
  display: none; position: fixed; inset: 0; z-index: 10500;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  opacity: 0; transition: opacity .25s;
}
#tutorial-modal.tm-open { display: flex; }
#tutorial-modal.tm-visible { opacity: 1; }
/* Generic ad-gate popup shares the tutorial card presentation. */
#ad-gate-modal {
  display: none; position: fixed; inset: 0; z-index: 10500;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  opacity: 0; transition: opacity .25s;
}
#ad-gate-modal.tm-open { display: flex; }
#ad-gate-modal.tm-visible { opacity: 1; }
#ad-gate-modal.tm-visible .tm-card { transform: none; }
.tm-card {
  background: #1a1a1d;
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  width: min(480px, 94vw);
  max-height: 82vh;
  display: flex; flex-direction: column;
  box-shadow: 0 0 40px rgba(232,125,13,.18), 0 24px 70px rgba(0,0,0,.75);
  overflow: hidden;
  transform: translateY(10px) scale(.97);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
#tutorial-modal.tm-visible .tm-card { transform: none; }
.tm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.tm-title {
  font-size: 15px; font-weight: 800; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.tm-title-icon {
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.tm-close {
  background: rgba(255,255,255,.08); border: none; color: var(--text-dim);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tm-close:hover { background: rgba(255,255,255,.16); color: #fff; }
.tm-body {
  flex: 1; overflow-y: auto; padding: 20px 20px 6px;
  scrollbar-width: none;
}
.tm-body::-webkit-scrollbar { display: none; }
.tm-footer {
  padding: 14px 20px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   SPLASH SCREEN
══════════════════════════════════════════════════════════════ */
#splash-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .35s cubic-bezier(.4,0,.2,1);
}
#splash-overlay.sp-visible { opacity: 1; pointer-events: auto; }

.sp-modal {
  position: relative;
  width: min(700px, 96vw);
  background: #1c1c1e;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 32px 90px rgba(0,0,0,.85), 0 0 0 1px rgba(255,255,255,.08);
  display: flex; flex-direction: column;
  transform: translateY(12px) scale(.97);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  max-height: 92vh;
}
#splash-overlay.sp-visible .sp-modal { transform: none; }

/* ── Banner ──────────────────────────────────────────────── */
.sp-banner {
  position: relative; overflow: hidden;
  background: #f0f0f0; /* matches the chameleon image's white/light-gray background */
  height: clamp(200px, 46vw, 290px);
  flex-shrink: 0;
}
.sp-banner-img {
  width: 100%; height: 100%;
  object-fit: contain;   /* show the FULL chameleon — no cropping */
  object-position: center center;
  display: block;
}
.sp-banner-grad {
  position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.04) 0%,
    rgba(0,0,0,.0)  40%,
    rgba(28,28,30,.55) 70%,
    rgba(28,28,30,1) 100%
  );
}
.sp-banner-logo {
  position: absolute; bottom: 14px; left: 20px;
  display: flex; align-items: flex-end; gap: 10px;
}
.sp-banner-title {
  font-size: 34px; font-weight: 800; letter-spacing: -1px;
  color: #fff; line-height: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,.5);
}
.sp-banner-sub {
  display: flex; flex-direction: column; align-items: flex-start;
  padding-bottom: 3px; gap: 1px;
}
.sp-banner-ver {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: rgba(0,0,0,.35); border-radius: 4px;
  padding: 1px 6px; letter-spacing: .6px; line-height: 1.6;
}
.sp-banner-tagline {
  font-size: 10px; color: rgba(255,255,255,.55); letter-spacing: .4px;
}
.sp-close {
  position: absolute; top: 10px; right: 12px;
  background: rgba(0,0,0,.4); border: none; color: rgba(255,255,255,.7);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); transition: background .15s;
  flex-shrink: 0;
}
.sp-close:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── Body columns ────────────────────────────────────────── */
.sp-body {
  display: flex; gap: 0; flex: 1; min-height: 0;
  overflow: hidden;
}
.sp-col {
  padding: 18px 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; min-height: 0;
}
.sp-col-start {
  flex: 1; min-width: 0;           /* equal 50% share */
  border-right: 1px solid rgba(255,255,255,.07);
}
.sp-col-recent { flex: 1; min-width: 0; }

.sp-col-title {
  font-size: 9px; font-weight: 700; letter-spacing: 1.4px;
  color: rgba(255,255,255,.35); text-transform: uppercase;
  margin-bottom: 6px;
}

/* Start buttons */
.sp-action-btn {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px; color: #e0e0e0; cursor: pointer;
  padding: 9px 12px; font-size: 12px; font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
  text-align: left; width: 100%;
}
.sp-action-btn:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); color: #fff; }
.sp-action-btn:active { background: rgba(255,255,255,.14); }
.sp-action-btn .sp-btn-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: rgba(255,255,255,.08); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.sp-action-btn.sp-accent .sp-btn-icon { background: var(--accent); }
.sp-action-btn.sp-accent:hover { border-color: var(--accent); }
.sp-btn-label { display: flex; flex-direction: column; gap: 1px; }
.sp-btn-label span { display: block; }
.sp-btn-label .sp-btn-sub { font-size: 10px; color: rgba(255,255,255,.4); font-weight: 400; }

/* Recent list */
.sp-recent-empty {
  color: rgba(255,255,255,.3); font-size: 11px; padding: 8px 0;
  font-style: italic;
}
.sp-recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  transition: background .12s; border: 1px solid transparent;
}
.sp-recent-item:hover {
  background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.08);
}
.sp-recent-thumb {
  width: 36px; height: 36px; border-radius: 6px; flex-shrink: 0;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: rgba(255,255,255,.3);
}
.sp-recent-info { flex: 1; min-width: 0; }
.sp-recent-name {
  font-size: 12px; font-weight: 500; color: #d8d8d8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-recent-meta {
  font-size: 10px; color: rgba(255,255,255,.35); margin-top: 1px;
}
.sp-recent-del {
  opacity: 0; width: 22px; height: 22px; border-radius: 4px;
  border: none; background: transparent; color: rgba(255,255,255,.4);
  cursor: pointer; font-size: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, opacity .12s;
}
.sp-recent-item:hover .sp-recent-del { opacity: 1; }
.sp-recent-del:hover { background: rgba(255,80,80,.2); color: #ff6b6b; }

/* ── Footer ──────────────────────────────────────────────── */
.sp-footer {
  padding: 8px 20px; border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sp-footer:hover .sp-footer-hint,
.sp-footer:active .sp-footer-hint { color: rgba(255,255,255,.5); }
.sp-footer-hint { font-size: 10px; color: rgba(255,255,255,.25); }
.sp-footer-hint kbd {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: 3px; padding: 0 4px; font-size: 10px;
  font-family: monospace; color: rgba(255,255,255,.45);
}
.sp-footer-link {
  font-size: 10px; color: rgba(255,255,255,.25);
}

/* ── Component responsive rules ───────────────────────────── */
@media (max-width: 460px) {
  .sp-col-start { flex: none; width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,.07); }
  .sp-body { flex-direction: column; }
  .sp-banner-title { font-size: 26px; }
}

@media (pointer: coarse), (max-width: 720px), (max-height: 600px) {
  #tutorial-close-btn {
    width: 44px;
    height: 44px;
    margin-left: -15px;
    margin-top: -13px;
    border: 0;
    background: radial-gradient(circle, #ef4444 0 10px, transparent 11px);
    font-size: 10px;
    box-shadow: none;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .sp-modal {
    width: min(700px, calc(100vw - 12px));
    max-height: calc(100dvh - 12px);
    flex-direction: row;
  }
  .sp-banner { width: 38%; height: auto; min-height: 0; }
  .sp-banner-logo { left: 12px; bottom: 12px; }
  .sp-banner-title { font-size: 25px; }
  .sp-body { flex: 1; min-width: 0; }
  .sp-col { padding: 12px; }
  .sp-footer { display: none; }
}

/* ── Tutorial overlay v2 — AAA mobile-first, responsive ─────── */
:root { --tut-sat:0px; --tut-sar:0px; --tut-sab:0px; --tut-sal:0px; }
#tut-tip {
  background: #1c1c1f; border: 1.5px solid rgba(255,255,255,.12);
  border-radius: 14px; padding: 12px 14px 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.65);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; box-sizing: border-box;
  /* width + position set fully by JS, never fixed here */
}
.tut-progress { font-size: 10px; color: #ff8c1a; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase; margin-bottom: 5px; }
.tut-track { height: 3px; background: rgba(255,255,255,.08);
  border-radius: 2px; margin-bottom: 8px; overflow: hidden; }
.tut-fill  { height: 100%; background: #ff8c1a; border-radius: 2px; transition: width .3s; }
.tut-instr { font-size: 13px; color: #e8e8e8; font-weight: 600; line-height: 1.4;
  margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tut-nav-row { display: flex; gap: 6px; align-items: center; }
.tut-hint { color: #c7c7cc; font-size: 12px; line-height: 1.45; margin-bottom: 10px; }
.tut-tap-hint { flex: 1; color: #ffb15c; font-size: 11px; line-height: 1.35; }
.tut-nav-btn {
  flex: 1; padding: 7px 0; border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: rgba(255,255,255,.08); color: #bbb;
}
.tut-nav-btn.primary { background: #e87d0d; color: #fff; }
.tut-nav-btn:disabled { opacity: .35; pointer-events: none; }
.tut-nav-btn:active   { opacity: .75; }
.tut-restart-btn {
  flex-shrink: 0; padding: 7px 9px; border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  background: rgba(255,255,255,.05); color: #666;
  -webkit-tap-highlight-color: transparent;
}
.tut-restart-btn:active { background: rgba(255,255,255,.10); }
/* Done card */
#tut-done-inner {
  background: #1c1c1f; border: 1.5px solid rgba(255,140,26,.4);
  border-radius: 18px; padding: 32px 28px 24px; text-align: center;
  max-width: 340px; width: 92vw;
  box-shadow: 0 0 60px rgba(255,140,26,.15), 0 24px 70px rgba(0,0,0,.75);
}
.tut-done-emoji { font-size: 52px; display: block; margin-bottom: 12px;
  animation: tut-bounce .6s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes tut-bounce {
  0%,100%{transform:scale(1)} 40%{transform:scale(1.25)} 70%{transform:scale(.95)}
}
.tut-done-title { font-size: 18px; font-weight: 800; color: #fff; margin-bottom: 8px; }
.tut-done-msg   { font-size: 13px; color: #aaa; line-height: 1.5; margin-bottom: 20px; }
.tut-done-btns  { display: flex; flex-direction: column; gap: 8px; }
.tut-done-btn {
  padding: 11px 0; border: none; border-radius: 10px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tut-done-btn.primary   { background: #e87d0d; color: #fff; }
.tut-done-btn.secondary { background: rgba(255,255,255,.06); color: #aaa; }
/* Confetti */
.tut-piece { position: absolute; border-radius: 2px; animation: tut-fall linear forwards; }
@keyframes tut-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh)  rotate(720deg); opacity: 0; }
}
/* Spotlight pulse */
@keyframes tut-spot-ring {
  0%,100% { box-shadow: 0 0 0 3px rgba(255,140,26,.45), 0 0 16px 5px rgba(255,140,26,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(255,140,26,.6),  0 0 28px 9px rgba(255,140,26,.78); }
}
#tut-spotlight.tut-pulse { animation: tut-spot-ring 1.4s ease-in-out infinite; }

/* ── Tutorial state machine visuals ─────────────────────────── */
/* Spotlight after completion: highlight is REMOVED (fades out); the
   tutorial then auto-advances to the next step. */
#tut-spotlight { transition: opacity .3s ease; }
#tut-spotlight.tut-spot-hidden {
  opacity: 0 !important;
  animation: none !important;
}
/* One strong ring to pull the eye back when Next is pressed too early. */
#tut-spotlight.tut-attn { animation: tut-attn-ring .45s ease-out 2; }
@keyframes tut-attn-ring {
  0%   { box-shadow: 0 0 0 4px rgba(255,140,26,.5),  0 0 22px 7px rgba(255,140,26,.7); }
  50%  { box-shadow: 0 0 0 14px rgba(255,140,26,0),  0 0 30px 10px rgba(255,140,26,.9); }
  100% { box-shadow: 0 0 0 4px rgba(255,140,26,.18), 0 0 22px 7px rgba(255,140,26,.6); }
}
/* Card shake for rejected Next presses. */
#tut-tip.tut-shake { animation: tut-shake .4s ease; }
@keyframes tut-shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); } 50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}
body.tut-active { cursor: pointer; }  /* any click performs the step */
body.tut-active #tut-tip, body.tut-active #tut-tip *,
body.tut-active #tut-done, body.tut-active #tut-done * { cursor: auto; }
