/* ── Jigsaw Reading Tool — Frontend (Tonkla LMS style) ───────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&family=Baloo+2:wght@500;600;700;800&display=swap');

/* ─── Design Tokens (mirrors Tonkla base.css) ─── */
:root {
    --jrt-font:           'Nunito', 'Segoe UI', system-ui, sans-serif;
    --jrt-font-display:   'Baloo 2', 'Nunito', cursive;

    --jrt-primary:        #0d9488;
    --jrt-primary-dark:   #0f766e;
    --jrt-primary-light:  rgba(13,148,136,0.08);
    --jrt-primary-glow:   rgba(13,148,136,0.18);

    --jrt-violet:         #8b5cf6;
    --jrt-violet-light:   rgba(139,92,246,0.10);
    --jrt-coral:          #f97066;
    --jrt-amber:          #f59e0b;
    --jrt-amber-light:    rgba(245,158,11,0.10);
    --jrt-sky:            #38bdf8;

    --jrt-success:        #10b981;
    --jrt-error:          #ef4444;

    --jrt-bg:             #f0fdf8;
    --jrt-card-bg:        #ffffff;
    --jrt-border:         #e2e8f0;
    --jrt-border-light:   #f1f5f9;
    --jrt-text:           #1e293b;
    --jrt-text-soft:      #64748b;
    --jrt-text-muted:     #94a3b8;

    --jrt-radius:         12px;
    --jrt-radius-lg:      16px;
    --jrt-radius-xl:      20px;
    --jrt-radius-pill:    100px;

    --jrt-shadow:         0 2px 8px rgba(0,0,0,0.06);
    --jrt-shadow-lg:      0 4px 20px rgba(0,0,0,0.08);
    --jrt-shadow-teal:    0 4px 14px rgba(13,148,136,0.12);

    --jrt-ease-bounce:    cubic-bezier(.34,1.56,.64,1);
    --jrt-ease-smooth:    cubic-bezier(.34,1.2,.64,1);
}

/* ─── Wrap — dot-grid background like Tonkla portal ─── */
.jrt-wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
    font-family: var(--jrt-font);
    font-size: 15px;
    color: var(--jrt-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    background-image: radial-gradient(circle at 1px 1px, rgba(13,148,136,0.035) 1px, transparent 0);
    background-size: 30px 30px;
}

.jrt-wrap *, .jrt-wrap *::before, .jrt-wrap *::after { box-sizing: border-box; }

/* ─── Card ─── */
.jrt-card {
    background: var(--jrt-card-bg);
    border-radius: var(--jrt-radius-lg);
    box-shadow: var(--jrt-shadow);
    border: 2px solid transparent;
    padding: 26px;
    margin-bottom: 20px;
    transition: all 0.3s var(--jrt-ease-bounce);
}

.jrt-card:hover { box-shadow: var(--jrt-shadow-lg); }

/* ─── Card Header (gradient band, like Tonkla modal-header) ─── */
.jrt-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(13,148,136,0.04), rgba(56,189,248,0.03));
    margin: -26px -26px 28px;
    padding: 22px 26px;
    border-bottom: 2px solid var(--jrt-border-light);
    border-radius: var(--jrt-radius-lg) var(--jrt-radius-lg) 0 0;
}

.jrt-logo { font-size: 2.6rem; line-height: 1; flex-shrink: 0; }

.jrt-title {
    font-family: var(--jrt-font-display);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--jrt-primary-dark);
}

.jrt-subtitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--jrt-text-soft);
    margin: 0;
}

/* ─── Grid ─── */
.jrt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .jrt-grid-2 { grid-template-columns: 1fr; } }
.jrt-field--full { grid-column: 1 / -1; }

/* ─── Field / Form group ─── */
.jrt-field { display: flex; flex-direction: column; gap: 0; }

.jrt-field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--jrt-text);
    margin-bottom: 6px;
}

.jrt-required { color: var(--jrt-coral); margin-left: 2px; }

.jrt-hint {
    font-size: 12px;
    font-weight: 500;
    color: var(--jrt-text-muted);
    margin-top: 5px;
}

/* ─── Inputs (Tonkla tonkla-input style) ─── */
.jrt-wrap input[type="text"],
.jrt-wrap input[type="number"],
.jrt-wrap select,
.jrt-wrap textarea {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: 2px solid var(--jrt-border);
    border-radius: var(--jrt-radius);
    font-family: var(--jrt-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 40px;
    color: var(--jrt-text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin: 0;
}

.jrt-wrap input:focus,
.jrt-wrap select:focus,
.jrt-wrap textarea:focus {
    outline: none;
    border-color: var(--jrt-primary);
    box-shadow: 0 0 0 4px var(--jrt-primary-glow);
}

.jrt-wrap textarea {
    height: auto;
    min-height: 110px;
    padding: 12px 16px;
    line-height: 1.7;
    resize: vertical;
}

.jrt-wrap select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%230d9488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.jrt-wrap input::placeholder { color: var(--jrt-text-muted); }

.jrt-wrap input.jrt-invalid,
.jrt-wrap select.jrt-invalid,
.jrt-wrap textarea.jrt-invalid {
    border-color: var(--jrt-error);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}

/* ─── Form Footer ─── */
.jrt-form-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid var(--jrt-border-light);
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.jrt-notice {
    font-size: 13px;
    font-weight: 500;
    color: var(--jrt-text-muted);
    margin: 0;
    flex: 1;
}

/* ─── Buttons ─── */
.jrt-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--jrt-radius);
    font-family: var(--jrt-font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.25s var(--jrt-ease-bounce);
}

.jrt-btn:hover  { transform: translateY(-1px); }
.jrt-btn:active { transform: translateY(0) scale(0.97); }

/* Primary — Tonkla teal gradient */
.jrt-btn--primary {
    background: linear-gradient(135deg, var(--jrt-primary), #14b8a6);
    color: #fff;
    box-shadow: 0 3px 12px rgba(13,148,136,0.28);
    padding: 12px 28px;
    font-size: 15px;
    border-radius: var(--jrt-radius-lg);
}
.jrt-btn--primary:hover:not(:disabled) { box-shadow: 0 5px 18px rgba(13,148,136,0.36); }
.jrt-btn--primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Secondary — outline */
.jrt-btn--secondary {
    background: transparent;
    border: 2px solid var(--jrt-primary);
    color: var(--jrt-primary);
    font-weight: 700;
}
.jrt-btn--secondary:hover { background: var(--jrt-primary); color: #fff; box-shadow: var(--jrt-shadow-teal); }

/* Ghost */
.jrt-btn--ghost {
    background: transparent;
    color: var(--jrt-text-soft);
    border: 2px solid var(--jrt-border);
    padding: 7px 16px;
    font-size: 13px;
    border-radius: 10px;
    font-weight: 700;
}
.jrt-btn--ghost:hover { background: var(--jrt-primary-light); color: var(--jrt-primary); border-color: var(--jrt-primary); }

/* Download — Tonkla data-item card style */
.jrt-btn--download {
    background: #fff;
    color: var(--jrt-text-soft);
    border: 2px solid var(--jrt-border-light);
    border-radius: var(--jrt-radius);
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    justify-content: flex-start;
    padding: 14px 18px;
    transition: all 0.25s var(--jrt-ease-bounce);
    gap: 12px;
}
.jrt-btn--download:hover {
    border-color: var(--jrt-primary);
    background: var(--jrt-primary-light);
    color: var(--jrt-primary);
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(13,148,136,0.1);
}

.jrt-btn-icon { font-size: 1.1rem; }
.jrt-btn-label { flex: 1; }

/* ─── Loading State ─── */
.jrt-loading {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, #fafffe, #f0fdf8) !important;
    border: 2px solid rgba(13,148,136,0.1) !important;
}

.jrt-loader-inner h3 {
    font-family: var(--jrt-font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--jrt-primary-dark);
    margin: 22px 0 8px;
}

.jrt-loader-inner p {
    font-size: 13px;
    font-weight: 600;
    color: var(--jrt-text-soft);
    margin: 0 0 24px;
    min-height: 1.4em;
}

/* Tonkla dual-colour spinner */
.jrt-spinner {
    display: inline-block;
    width: 64px;
    height: 64px;
    border: 5px solid #e2e8f0;
    border-top-color: var(--jrt-primary);
    border-right-color: var(--jrt-sky);
    border-radius: 50%;
    animation: jrtSpin 0.7s linear infinite;
    margin: 0 auto;
}

@keyframes jrtSpin { to { transform: rotate(360deg); } }

/* Tonkla shimmer progress bar */
.jrt-progress-bar {
    height: 10px;
    background: #e2e8f0;
    border-radius: var(--jrt-radius-pill);
    overflow: hidden;
    max-width: 360px;
    margin: 0 auto;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.jrt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--jrt-primary), #2dd4bf, var(--jrt-sky));
    background-size: 200% 100%;
    border-radius: var(--jrt-radius-pill);
    width: 5%;
    transition: width 0.6s var(--jrt-ease-smooth);
    animation: jrtShimmer 2.5s ease-in-out infinite;
}

@keyframes jrtShimmer {
    0%,100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* ─── Results ─── */
.jrt-results { animation: jrtPanelIn 0.35s ease; }

@keyframes jrtPanelIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ─── Section headings ─── */
.jrt-section-title {
    font-family: var(--jrt-font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--jrt-primary-dark);
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.jrt-icon { font-size: 1.1rem; }

.jrt-section-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--jrt-text-soft);
    margin: 0 0 20px;
}

/* ─── Schema activation card ─── */
.jrt-schema-preview {
    border-left: 4px solid var(--jrt-amber) !important;
    background: linear-gradient(135deg, #fffbeb, #fefce8) !important;
    border-color: #fde68a !important;
}

.jrt-schema-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jrt-schema-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border: 2px solid #fde68a;
    border-radius: var(--jrt-radius);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--jrt-text);
    transition: all 0.2s;
}

.jrt-schema-list li:hover { border-color: var(--jrt-amber); background: var(--jrt-amber-light); }
.jrt-schema-list li::before { content: "💬"; flex-shrink: 0; }

/* ─── Downloads ─── */
.jrt-downloads { display: flex; flex-direction: column; gap: 6px; }

.jrt-download-group { margin-bottom: 14px; }

/* Tonkla data-list section label */
.jrt-download-group-label {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--jrt-primary);
    margin: 0 0 8px 4px;
}

/* ─── Error Card ─── */
.jrt-error-card {
    display: flex;
    align-items: center;
    gap: 14px;
    border-color: rgba(239,68,68,0.2) !important;
    background: linear-gradient(135deg, rgba(239,68,68,0.04), rgba(252,165,165,0.02)) !important;
    flex-wrap: wrap;
    animation: jrtResultIn 0.4s var(--jrt-ease-bounce);
}

@keyframes jrtResultIn {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.jrt-error-icon { font-size: 2rem; flex-shrink: 0; }

.jrt-error-card strong {
    display: block;
    font-family: var(--jrt-font-display);
    font-size: 16px;
    color: var(--jrt-error);
    margin-bottom: 4px;
}

.jrt-error-card p { margin: 0; font-size: 14px; color: var(--jrt-text); flex: 1; min-width: 200px; }

/* ─── Start over ─── */
.jrt-start-over-wrap { text-align: center; padding: 6px 0 8px; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .jrt-card { padding: 18px; }
    .jrt-card-header { margin: -18px -18px 22px; padding: 18px; }
    .jrt-form-footer { flex-direction: column; align-items: stretch; }
    .jrt-btn--primary { justify-content: center; }
    .jrt-notice { text-align: center; }
}

@media (max-width: 480px) {
    .jrt-wrap { padding: 0 0.5rem 3rem; }
    .jrt-card { padding: 14px; }
    .jrt-card-header { margin: -14px -14px 18px; padding: 14px; }
    .jrt-title { font-size: 18px; }
}

/* ─── Access Denied Card ─────────────────────────────────────────────────── */

.jrt-access-denied {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 20px;
}

.jrt-denied-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
    padding: 48px 40px 40px;
    border-top: 4px solid #f97066;
}

.jrt-denied-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 16px;
    filter: drop-shadow(0 2px 6px rgba(249,112,102,0.25));
    animation: jrtBounceIn 0.5s var(--jrt-ease-bounce);
}

.jrt-denied-title {
    font-family: 'Baloo 2', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--jrt-text);
    margin: 0 0 12px;
}

.jrt-denied-message {
    font-size: 1rem;
    font-weight: 500;
    color: var(--jrt-text-soft);
    margin: 0 0 8px;
    line-height: 1.6;
}

.jrt-denied-hint {
    font-size: 0.9rem;
    color: var(--jrt-text-muted);
    margin: 8px 0 0;
}

.jrt-denied-hint a {
    color: var(--jrt-primary);
    font-weight: 700;
    text-decoration: none;
}
.jrt-denied-hint a:hover {
    text-decoration: underline;
}

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