/* ═══════════════════════════════════════════════════════════
   LINEAR CROSSWORD TUTORIAL (lc-tutorial.js)
   Dark crossword theme + Jackbox motion-graphics style
   ═══════════════════════════════════════════════════════════ */

/* --- Overlay --- */
.lct-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 60%, #0f0f23 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

/* Crossword-grid background pattern */
.lct-overlay::before {
    content: '';
    position: absolute;
    inset: -20%;
    width: 140%;
    height: 140%;
    background-image:
        linear-gradient(rgba(124, 58, 237, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(124, 58, 237, 0.04) 1px, transparent 1px);
    background-size: 54px 54px;
    animation: lctGridShift 30s linear infinite;
    pointer-events: none;
}

@keyframes lctGridShift {
    from { transform: translate(0, 0); }
    to   { transform: translate(54px, 54px); }
}

/* Ambient glow */
.lct-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 70%, rgba(124, 58, 237, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 30%, rgba(34, 197, 94, 0.08) 0%, transparent 50%);
    pointer-events: none;
    animation: lctGlow 8s ease-in-out infinite alternate;
}

@keyframes lctGlow {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}

.lct-overlay.lct-visible {
    opacity: 1;
}

/* --- Close button --- */
.lct-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.lct-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: rotate(90deg);
}

/* --- Modal mode --- */
.lct-overlay.lct-modal-mode {
    background: none;
}

.lct-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
}

.lct-modal-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 60%, #0f0f23 100%);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(124, 58, 237, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(124, 58, 237, 0.2);
    z-index: 1;
    aspect-ratio: 16 / 10;
}

.lct-modal-container .lct-close-btn {
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
}

.lct-modal-container .lct-stage { padding: 1.5rem; }
.lct-modal-container .lct-subtitle-bar { padding: 0 1.5rem 1rem; min-height: 60px; }
.lct-modal-container .lct-subtitle-text { font-size: 1rem; }
.lct-modal-container .lct-play-btn { padding: 1.5rem 2.5rem; font-size: 1rem; border-radius: 18px; }
.lct-modal-container .lct-play-btn svg { width: 36px; height: 36px; }
.lct-modal-container .lct-heading { font-size: 1.6rem; }
.lct-modal-container .lct-title-text { font-size: 3.5rem; }

/* --- Stage --- */
.lct-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    padding: 2rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
    position: relative;
    z-index: 1;
}

.lct-stage.lct-fade-out {
    opacity: 0;
    transform: scale(0.96);
}

.lct-stage.lct-fade-in {
    animation: lctFadeIn 0.4s ease both;
}

@keyframes lctFadeIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Subtitle bar --- */
.lct-subtitle-bar {
    width: 100%;
    max-width: 800px;
    min-height: 80px;
    padding: 0 2rem 1.5rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.lct-subtitle-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.15rem;
    line-height: 1.5;
    transition: opacity 0.25s ease;
    margin: 0;
}

/* --- Progress bar --- */
.lct-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 2;
}

.lct-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #22c55e);
    width: 0%;
    transition: width 0.3s linear;
}

/* --- Play overlay --- */
.lct-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    background: rgba(0, 0, 0, 0.4);
}

.lct-play-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border: none;
    border-radius: 24px;
    padding: 2rem 3rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    box-shadow:
        0 8px 40px rgba(124, 58, 237, 0.35),
        0 0 30px rgba(124, 58, 237, 0.2);
}

.lct-play-btn:hover {
    transform: scale(1.06);
    box-shadow:
        0 12px 50px rgba(124, 58, 237, 0.5),
        0 0 40px rgba(124, 58, 237, 0.3);
}

/* ─────────────────────────────────────────────────────
   SHARED SCENE STYLES
   ───────────────────────────────────────────────────── */
.lct-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.8rem;
    width: 100%;
}

.lct-heading {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 20px rgba(124, 58, 237, 0.3);
}

/* Reusable animations */
.lct-fade-up {
    animation: lctFadeUp 0.5s ease var(--delay, 0s) both;
}

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

@keyframes lctPopIn {
    from { opacity: 0; transform: scale(0) rotate(-10deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Title
   ───────────────────────────────────────────────────── */
.lct-title-text {
    font-size: 5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #7c3aed, #a78bfa, #22c55e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    letter-spacing: -2px;
    animation: lctTitleSlam 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    filter: drop-shadow(0 4px 30px rgba(124, 58, 237, 0.4));
}

.lct-title-text-2 {
    animation-delay: 0.15s;
    background: linear-gradient(135deg, #fbbf24, #f97316, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 4px 30px rgba(251, 191, 36, 0.4));
}

.lct-title-sub {
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.3rem;
    font-weight: 500;
    animation: lctFadeUp 0.5s ease 0.4s both;
}

@keyframes lctTitleSlam {
    from { opacity: 0; transform: scale(1.8) rotate(-3deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Intro – letters morph to numbers
   ───────────────────────────────────────────────────── */
.lct-intro-morph {
    position: relative;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lct-morph-letters,
.lct-morph-numbers {
    display: flex;
    gap: 6px;
    position: absolute;
}

.lct-morph-cell {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.6rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: white;
}

.lct-morph-num {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.4);
    color: #c4b5fd;
}

.lct-morph-pop {
    animation: lctPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

.lct-morph-fade-out {
    animation: lctMorphOut 0.6s ease 4.2s forwards;
}

.lct-morph-fade-in {
    animation: lctMorphIn 0.5s ease 4.8s both;
}

@keyframes lctMorphOut {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.7) translateY(10px); }
}

@keyframes lctMorphIn {
    from { opacity: 0; transform: scale(0.7) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Pattern – sequence with jump arrows above
   ───────────────────────────────────────────────────── */
.lct-pattern-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lct-jump-arrows {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.lct-jump {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 56px;
}

.lct-jump-svg {
    width: 56px;
    height: 24px;
}

.lct-jump-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #22c55e;
    margin-top: -2px;
}

.lct-pattern-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lct-seq-cell {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    font-family: 'Courier New', monospace;
}

.lct-seq-pop {
    animation: lctPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

.lct-diff {
    font-size: 0.85rem;
    font-weight: 700;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.25);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    white-space: nowrap;
}

.lct-pattern-label {
    color: rgba(255, 255, 255, 0.45);
    font-size: 1rem;
}

/* ─────────────────────────────────────────────────────
   SCENES: Spot Clues / Fill In / Write Rule
   Shared word-cell styles
   ───────────────────────────────────────────────────── */
.lct-word-row {
    display: flex;
    gap: 6px;
}

.lct-word-cell {
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    position: relative;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.12);
}

.lct-word-cell .lct-cell-val {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    font-family: 'Courier New', monospace;
}

.lct-word-cell .lct-cell-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
}

.lct-word-cell.lct-grid-seed {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.5);
}

.lct-word-cell.lct-grid-seed .lct-cell-val {
    color: #c4b5fd;
}

.lct-word-empty {
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.15);
}

.lct-empty-q {
    color: rgba(255, 255, 255, 0.2) !important;
    font-size: 1.6rem !important;
}

/* Word label / badge */
.lct-word-label {
    margin-bottom: -0.5rem;
}

.lct-word-badge {
    display: inline-block;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #c4b5fd;
    padding: 0.25rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Deduction row */
.lct-deduce-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.lct-deduce-bracket {
    position: relative;
    padding: 0.3rem 0.8rem;
    border: 2px solid rgba(251, 191, 36, 0.3);
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.lct-deduce-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fbbf24;
}

.lct-deduce-math {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Courier New', monospace;
}

.lct-deduce-arrow {
    color: rgba(255, 255, 255, 0.3);
}

/* ─── Fill In scene ─── */
.lct-word-filled {
    background: rgba(34, 197, 94, 0.1);
    border: 2px solid rgba(34, 197, 94, 0.4);
}

.lct-word-filled .lct-cell-val {
    color: #4ade80;
}

.lct-word-fill-anim {
    animation: lctFillPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

@keyframes lctFillPop {
    0%   { opacity: 0; transform: scale(0); background: rgba(34, 197, 94, 0); }
    50%  { background: rgba(34, 197, 94, 0.25); }
    100% { opacity: 1; transform: scale(1); background: rgba(34, 197, 94, 0.1); }
}

.lct-fillin-arrows {
    display: flex;
    gap: 42px;
    margin-top: -0.5rem;
    padding-left: 32px;
}

/* ─── Write Rule scene ─── */
.lct-rule-walkthrough {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.lct-rule-word {
    display: flex;
    gap: 4px;
}

.lct-word-cell-sm {
    width: 44px;
    height: 44px;
    font-size: 1rem;
}

.lct-word-cell-sm .lct-cell-val {
    font-size: 1rem;
}

.lct-word-correct {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    font-weight: 700;
    color: #4ade80;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
}

.lct-rule-connector {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.25);
}

.lct-rule-clue {
    width: 100%;
    max-width: 380px;
}

.lct-clue-active {
    background: rgba(124, 58, 237, 0.1) !important;
    border-left-color: #7c3aed !important;
    border-color: rgba(124, 58, 237, 0.3);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-left: 3px solid #7c3aed;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}

/* ─── Clue item (used in Write Rule scene) ─── */
.lct-clue-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.lct-clue-blank {
    background: rgba(251, 191, 36, 0.06);
    border-left-color: #fbbf24;
}

.lct-clue-num {
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
    min-width: 20px;
}

/* ─── Type input (used in Write Rule scene) ─── */
.lct-type-input-box {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(124, 58, 237, 0.4);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    min-width: 160px;
    text-align: center;
}

.lct-type-cursor {
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    animation: lctTypeBlink 1s step-end infinite;
}

@keyframes lctTypeBlink {
    50% { border-right-color: transparent; }
}

.lct-type-check-btn {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.lct-type-result {
    margin-top: -0.3rem;
}

.lct-result-correct {
    color: #22c55e;
    font-weight: 700;
    font-size: 1.2rem;
    animation: lctCorrectPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes lctCorrectPop {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Twenty patterns – progress + modes
   ───────────────────────────────────────────────────── */
.lct-twenty-bar-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 400px;
}

.lct-twenty-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
}

.lct-twenty-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7c3aed, #22c55e);
    border-radius: 5px;
    animation: lctFillUp 2s ease 0.3s forwards;
}

@keyframes lctFillUp {
    from { width: 0%; }
    to   { width: 100%; }
}

.lct-twenty-label {
    font-weight: 700;
    color: #22c55e;
    font-size: 1.1rem;
    min-width: 60px;
}

.lct-twenty-modes {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.lct-mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
}

.lct-mode-icon {
    font-size: 2.2rem;
}

.lct-mode-label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.lct-mode-or {
    color: rgba(255, 255, 255, 0.3);
    font-size: 1rem;
    font-weight: 500;
}

/* ─────────────────────────────────────────────────────
   SCENE: Outro
   ───────────────────────────────────────────────────── */
.lct-outro-scene .lct-title-text {
    font-size: 4rem;
}

.lct-outro-sub {
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.3rem;
    font-style: italic;
    animation: lctFadeUp 0.5s ease 0.3s both;
}

/* ─────────────────────────────────────────────────────
   HOW TO PLAY BUTTON (page integration)
   ───────────────────────────────────────────────────── */
.lct-how-to-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(124, 58, 237, 0.1);
    border: 2px solid rgba(124, 58, 237, 0.3);
    color: #7c3aed;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.lct-how-to-play-btn:hover {
    background: rgba(124, 58, 237, 0.18);
    border-color: rgba(124, 58, 237, 0.5);
}

/* ─────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .lct-title-text {
        font-size: 3rem;
    }

    .lct-heading {
        font-size: 1.5rem;
    }

    .lct-morph-cell {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .lct-seq-cell {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .lct-pattern-row {
        gap: 0.15rem;
    }

    .lct-diff {
        font-size: 0.7rem;
        padding: 0.1rem 0.3rem;
    }

    .lct-example-table {
        min-width: 260px;
    }

    .lct-clues-demo {
        flex-direction: column;
        gap: 1rem;
    }

    .lct-clue-col {
        min-width: unset;
    }

    .lct-type-input-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .lct-twenty-modes {
        gap: 0.75rem;
    }

    .lct-mode-card {
        padding: 0.75rem 1rem;
    }
}
