/* ==========================================================================
   KIDZAPS — Worksheet Template styles (Phase A: 5 core categories)
   Loaded on worksheet pages (screen + print). Companion of HtmlTemplateBuilder.
   Author: KidZaps Team — 2026-08
   ========================================================================== */

.kz-tpl {
    position: relative;
    page-break-inside: avoid;
    box-sizing: border-box;
    font-family: "Nunito", "Segoe UI", sans-serif;
    max-width: 210mm;
    margin: 0 auto;
}

.kz-tpl *,
.kz-tpl *::before,
.kz-tpl *::after {
    box-sizing: border-box;
}

.kz-tpl-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 12px;
    border-bottom: 2px dashed #cbd5e1;
}

.kz-tpl-header-alpha {
    padding: 12px 0 16px;
}

.kz-tpl-title {
    font: 700 26pt "Fredoka", "Baloo 2", sans-serif;
    text-align: center;
    margin: 0;
    line-height: 1.2;
}

.kz-tpl-subtitle {
    color: #4338ca;
    font: 700 14pt "Nunito", sans-serif;
    margin-top: 4px;
    text-align: center;
}

.kz-tpl-directions {
    color: #4b5563;
    font: 400 11pt "Nunito", sans-serif;
    margin: 4px 0 0;
    text-align: center;
}

.kz-tpl-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px 0;
}

.kz-tpl-footer-hint {
    text-align: center;
    font-size: 10pt;
    color: #6b7280;
    margin-top: 16px;
    font-style: italic;
}

.kz-btn {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1.5px solid #d1d5db;
    background: white;
    color: #374151;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.kz-btn:hover {
    background: #f3f4f6;
}

.kz-btn-color {
    background: #eef2ff;
    border-color: #a5b4fc;
    color: #4338ca;
}

.kz-btn-clear {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.kz-rainbow {
    letter-spacing: 4px;
}

/* ==========================================================================
   NUMBERS 1-20 tracing grid
   ========================================================================== */
.kz-tpl-numbers {
    padding: 8px;
}

.kz-num-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 12px 0;
}

.kz-num-cell {
    aspect-ratio: 1;
    border: 2px solid #93c5fd;
    border-radius: 10px;
    background: #f0f9ff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px;
}

.kz-num-trace {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.kz-num-outline {
    font-family: "Fredoka", sans-serif;
    font-size: 46pt;
    font-weight: 700;
    color: transparent;
    -webkit-text-stroke: 2.5px #1e40af;
    position: relative;
    user-select: none;
    line-height: 1;
}

/* SVG-based digit outline inside a number cell */
.kz-num-svg {
    width: 90%;
    height: 90%;
    display: block;
    margin: 0 auto;
}

/* Canvas overlay on top of each cell for finger-drawing */
.kz-num-cell,
.kz-alpha-cell {
    overflow: hidden;
}

.kz-num-trace,
.kz-alpha-trace {
    position: relative;
    width: 100%;
    height: 100%;
}

.kz-trace-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    /* prevent page scroll while tracing */
    cursor: crosshair;
    background: transparent;
    z-index: 2;
}

.kz-alpha-svg {
    width: 92%;
    height: 92%;
    display: block;
    margin: 0 auto;
}

.kz-num-strokes {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 3px;
    flex-direction: row;
}

.kz-num-stroke-badge {
    min-width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4338ca;
    color: white;
    font-size: 8pt;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ==========================================================================
   ALPHABET A-Z tracing grid
   ========================================================================== */
.kz-alpha-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.kz-alpha-cell {
    aspect-ratio: 1;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px;
    position: relative;
}

.kz-alpha-trace {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.kz-alpha-outline {
    font-family: Arial, sans-serif;
    font-size: 56pt;
    font-weight: 900;
    color: transparent;
    -webkit-text-stroke: 2.5px #111827;
    letter-spacing: -2px;
    line-height: 1;
    user-select: none;
}

/* ==========================================================================
   CURSIVE dotted midline
   ========================================================================== */
.kz-tpl-cursive {
    padding: 8px;
}

.kz-cursive-title {
    font-size: 22pt;
    margin-bottom: 16px;
}

.kz-cursive-line {
    position: relative;
    height: 84px;
    border-bottom: 2px solid #1e40af;
    border-top: 2px solid #1e40af;
    margin-bottom: 20px;
    background: rgba(219, 234, 254, 0.15);
}

.kz-cursive-guide {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1.5px dashed #94a3b8;
    transform: translateY(-50%);
    pointer-events: none;
}

.kz-cursive-content {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 20px;
    padding: 0 12px;
    height: 100%;
}

.kz-cursive-token {
    font-family: "Kalam", "Homemade Apple", cursive;
    font-size: 42pt;
    font-weight: 400;
    color: transparent;
    -webkit-text-stroke: 1.5px #6b7280;
    letter-spacing: 4px;
    user-select: none;
    line-height: 1;
}

/* ==========================================================================
   MISSING NUMBERS train wagons
   ========================================================================== */
.kz-tpl-missing {
    padding: 12px 4px;
}

.kz-missing-title {
    font-size: 18pt;
    color: #1f2937;
    margin: 8px 0 20px;
    font-weight: 700;
}

.kz-train-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kz-train-loco {
    font-size: 46pt;
    line-height: 1;
    margin-right: 8px;
    flex-shrink: 0;
}

.kz-train-loco-spacer {
    width: 60px;
    flex-shrink: 0;
}

.kz-train-wagon {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.kz-train-wagon .kz-number-box {
    width: 60px;
    height: 60px;
    border: 3px solid #1f2937;
    border-radius: 12px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Fredoka", sans-serif;
    font-size: 22pt;
    font-weight: 700;
    color: #111827;
    position: relative;
}

.kz-train-wagon.kz-empty .kz-number-box {
    background: #f9fafb;
    cursor: pointer;
}

.kz-train-wagon.kz-empty .kz-number-box:hover {
    background: #eef2ff;
    border-color: #6366f1;
}

.kz-number-input {
    position: absolute;
    inset: 0;
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
    font-family: "Fredoka", sans-serif;
    font-size: 22pt;
    font-weight: 700;
    color: #111827;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

.kz-wagon-wheels {
    display: flex;
    gap: 10px;
    margin-top: 2px;
}

.kz-wheel {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #7f1d1d;
    border: 2px solid #450a0a;
}

.kz-train-wagon.kz-correct .kz-number-box {
    background: #dcfce7;
    border-color: #16a34a;
    color: #14532d;
}

.kz-train-wagon.kz-wrong .kz-number-box {
    background: #fee2e2;
    border-color: #dc2626;
    color: #7f1d1d;
    animation: kzShake 0.35s ease;
}

/* ==========================================================================
   FLASH CARDS colored
   ========================================================================== */
.kz-tpl-flash {
    padding: 8px;
}

.kz-flash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 12px 0;
}

.kz-flash-card {
    background: var(--card-bg, #fef3c7);
    color: var(--card-fg, #1f2937);
    border-radius: 14px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    aspect-ratio: 3 / 4;
    cursor: pointer;
    transition: transform 0.15s;
}

.kz-flash-card:hover {
    transform: translateY(-2px);
}

.kz-flash-letter {
    font-family: "Fredoka", sans-serif;
    font-size: 30pt;
    font-weight: 800;
    line-height: 1;
    align-self: flex-start;
    margin-left: 4px;
}

.kz-flash-picture {
    font-size: 42pt;
    line-height: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kz-flash-word {
    font-family: "Nunito", sans-serif;
    font-size: 12pt;
    font-weight: 700;
    text-align: center;
    align-self: stretch;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes kzShake {
    0% {
        transform: translateX(0);
    }

    15% {
        transform: translateX(-6px);
    }

    30% {
        transform: translateX(6px);
    }

    45% {
        transform: translateX(-6px);
    }

    60% {
        transform: translateX(6px);
    }

    75% {
        transform: translateX(-3px);
    }

    90% {
        transform: translateX(3px);
    }

    100% {
        transform: translateX(0);
    }
}

/* ==========================================================================
   Responsive (mobile)
   ========================================================================== */
@media (max-width: 640px) {
    .kz-num-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .kz-num-outline {
        font-size: 36pt;
    }

    .kz-alpha-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .kz-alpha-outline {
        font-size: 40pt;
    }

    .kz-flash-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kz-flash-letter {
        font-size: 24pt;
    }

    .kz-flash-picture {
        font-size: 32pt;
    }
}

/* ==========================================================================
   Print overrides
   ========================================================================== */
@media print {

    .kz-btn,
    .kz-tpl-actions,
    .kz-tpl-footer-hint {
        display: none !important;
    }

    .kz-num-cell,
    .kz-alpha-cell {
        page-break-inside: avoid;
    }

    .kz-num-outline,
    .kz-alpha-outline,
    .kz-cursive-token,
    .kz-train-wagon .kz-wheel,
    .kz-flash-card {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .kz-number-input {
        display: none;
    }

    .kz-cursive-line {
        background: transparent;
    }

    .kz-flash-card {
        box-shadow: none;
    }

    .kz-tpl {
        max-width: 100%;
    }
}