/* Design tokens now live in global.css (single source of truth) */

body {
    background-color: var(--mm-bg);
    transition: background-color 0.3s ease;
}

/* Lesson Container */
.lesson-page {
    max-width: 780px;
    margin: 28px auto;
    padding: 32px;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: 18px;
    color: var(--mm-text);
    font-family: var(--mm-font);
    line-height: 1.8;
}

.lesson-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    width: fit-content;
    margin: 0 0 28px;
    padding: 7px 12px;
    border: 1px solid var(--mm-border);
    border-radius: 999px;
    background: var(--mm-bg);
    color: var(--mm-text-dim);
    font-size: .84rem;
    line-height: 1.25;
}

.lesson-breadcrumbs a { color: var(--mm-accent); text-decoration: none; }
.lesson-breadcrumbs a:hover { color: var(--mm-text); text-decoration: underline; }
.lesson-breadcrumbs strong { color: var(--mm-text); }

.lesson-primary-action { background: var(--mm-accent-strong) !important; border-color: var(--mm-accent) !important; color: #fff !important; }
.lesson-secondary-action { opacity: .82; }

.exercise-number {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--mm-accent);
    background: rgba(96, 165, 250, .12);
    font-size: .8rem;
    font-weight: 700;
}

.copy-btn { position: relative; }
.copy-feedback {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    padding: 3px 7px;
    border-radius: 6px;
    color: #dcfce7;
    background: #166534;
    font-size: .72rem;
    white-space: nowrap;
    z-index: 5;
}

.lesson-page > p,
.lesson-page > ul,
.lesson-page > ol {
    max-width: 72ch;
    font-size: 1.05rem;
}

.lesson-page p + h2 {
    margin-top: 52px;
}

@media (max-width: 700px) {
    .lesson-page {
        margin: 20px 14px;
        padding: 24px 18px;
    }

    .lesson-page > p,
    .lesson-page > ul,
    .lesson-page > ol {
        font-size: 1rem;
    }

    .next-chapter-wrapper {
        flex-direction: column;
    }

    .next-chapter-btn {
        justify-content: center;
    }
}

/* Lesson Header with Reading Time */
.lesson-header {
    margin-bottom: 40px;
}

.lesson-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.lesson-meta .reading-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: var(--mm-text-dim);
    background: rgba(96, 165, 250, 0.1);
    padding: 6px 14px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Titles */
.underlined-title {
    border-bottom: 2px solid var(--mm-accent);
    width: fit-content;
    padding-bottom: 8px;
    margin-top: 40px;
    margin-bottom: 20px;
    color: var(--mm-accent);
}

.lesson-header .underlined-title {
    margin-top: 0;
}

/* Links within text */
.custom-link {
    color: var(--mm-accent);
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px dashed var(--mm-accent);
    transition: 0.3s;
}

.custom-link:hover {
    color: var(--mm-text);
    border-bottom-style: solid;
}

/* Code Blocks — always dark, editor-style, regardless of page theme
   (matches the code panels on the home page hero and the quiz screen) */
.code-block {
    direction: ltr !important;
    text-align: left !important;
    background-color: #0b1220;
    color: #cbd5e1;
    border-radius: 12px;
    font-family: var(--mm-mono);
    overflow-x: auto;
    unicode-bidi: plaintext;
    white-space: pre;
    display: table;
    width: 100%;
}

.code-block code {
    text-align: left !important;
    direction: ltr !important;
}

/* Footer Navigation Buttons */
.next-chapter-wrapper {
    margin-top: 60px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.next-chapter-btn {
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid var(--mm-accent);
    color: var(--mm-accent);
    padding: 12px 24px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: bold;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.next-chapter-btn:hover {
    background: var(--mm-accent);
    color: white;
    transform: translateY(-3px);
}

.lesson-complete {
    cursor: pointer;
    font-family: inherit;
}

.lesson-complete.is-complete {
    background: rgba(74, 222, 128, 0.14);
    border-color: #4ade80;
    color: #86efac;
}

.lesson-complete:disabled {
    cursor: default;
    transform: none;
}

body.light-mode .lesson-complete.is-complete {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #15803d;
}

/* --- Prism Light Mode Adjustment --- */

/* 1. Reset the background and text for the container */
body.light-mode pre[class*="language-"],
body.light-mode code[class*="language-"] {
    background: #f8fafc !important;
    color: #1e293b !important;
    text-shadow: none !important;
}

/* 2. Adjust the specific syntax colors for Light Mode */
body.light-mode .token.keyword,
body.light-mode .token.selector,
body.light-mode .token.important,
body.light-mode .token.atrule {
    color: #2563eb !important;
}

body.light-mode .token.operator,
body.light-mode .token.punctuation {
    color: #64748b !important;
}

body.light-mode .token.string,
body.light-mode .token.char,
body.light-mode .token.attr-value {
    color: #059669 !important;
}

body.light-mode .token.function,
body.light-mode .token.class-name {
    color: #7c3aed !important;
}

body.light-mode .token.comment {
    color: #94a3b8 !important;
    font-style: italic;
}

/* Code box (header + copy button + code) — same dark chrome as
   the quiz page's code blocks, always dark regardless of theme */
.code-box {
    background-color: #0b1220;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin: 25px 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.code-header {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #111827;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-lang {
    color: #64748b;
    font-size: 0.75rem;
    font-family: var(--mm-mono);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.copy-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    transition: color 0.2s ease, transform 0.2s ease;
}

.copy-btn:hover {
    color: var(--mm-accent);
    transform: scale(1.1);
}

.icon-check {
    display: none;
}

.copy-btn.success .icon-copy {
    display: none !important;
}

.copy-btn.success .icon-check {
    display: block !important;
    stroke: #4ade80;
}

.copy-btn.success {
    border-color: #4ade80;
}

.code-box .code-block {
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    display: block;
    box-sizing: border-box;
}

.analysis-box {
    background: rgba(255, 255, 255, 0.04);
    border-right: 4px solid var(--mm-accent); /* פס כחול בצד ימין (בגלל ה-RTL) */
    padding: 15px 20px;
    border-radius: 12px;
    margin: 20px 0;
}

.analysis-box p {
    margin: 8px 0;
    font-size: 1rem;
}

.pro-tip {
    background: rgba(250, 204, 21, 0.1);
    border: 1px dashed #facc15;
    padding: 15px;
    border-radius: 12px;
    color: #fef08a;
    font-size: 0.95rem;
}

/* --- Light Mode עבור תיבת הניתוח והטיפים --- */

body.light-mode .analysis-box {
    background: #f1f5f9;
    border-right-color: #2563eb;
}

body.light-mode .analysis-box strong {
    color: #2563eb;
}

body.light-mode .pro-tip {
    background: #fefce8;
    border-color: #eab308;
    color: #854d0e;
}

body.light-mode .pro-tip strong {
    color: #713f12;
}

/* Bagrut-angle box: standardized "how this shows up on the exam" callout,
   used once per lesson chapter. Distinct violet accent so it reads as its
   own category, not a mistake warning (analysis-box) or a general tip (pro-tip). */
.bagrut-tip-box {
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 12px;
    padding: 16px 20px;
    margin: 24px 0;
}

.bagrut-tip-box h4 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    color: #a78bfa;
}

.bagrut-tip-row {
    margin: 10px 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.bagrut-tip-row strong {
    color: #a78bfa;
}

body.light-mode .bagrut-tip-box {
    background: #f5f3ff;
    border-color: #c4b5fd;
}

body.light-mode .bagrut-tip-box h4,
body.light-mode .bagrut-tip-row strong {
    color: #6d28d9;
}

/* Table Styling */
.table-container {
    overflow-x: auto;
    margin: 25px 0;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.variable-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    overflow: hidden;
}

.variable-table th, .variable-table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--mm-border);
}

.variable-table th {
    background: rgba(96, 165, 250, 0.1);
    color: var(--mm-accent);
    font-weight: bold;
}

body.light-mode .variable-table {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

body.light-mode .variable-table th {
    background: #eff6ff;
    border-bottom: 2px solid #dbeafe;
}

/* מבטיח שכל תגיות הקוד יוצגו משמאל לימין, גם בתוך פסקה בעברית */
code, pre {
    direction: ltr !important;
    display: inline-block;
    unicode-bidi: embed;
}

/* Container Task (interactive exercise box) — shares the site's card
   language (surface/border tokens, 12px radius) and the same green/red
   used by .lesson-success, instead of a bespoke fixed-dark theme. */
.thm-task {
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: 12px;
    margin: 30px 0;
    overflow: hidden;
    font-family: var(--mm-font);
    color: var(--mm-text);
}

.thm-task-header {
    background: var(--mm-bg);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--mm-border);
}

.task-number {
    background: var(--mm-accent-strong);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
}

.task-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--mm-text);
}

.thm-task-body {
    padding: 20px;
}

.thm-input-group {
    display: flex;
    margin-top: 15px;
    max-width: 500px;
    direction: ltr; /* גורם לכפתור להיות מימין לקלט בצורה טבעית לקוד */
}

.thm-input {
    flex: 1;
    background: var(--mm-bg);
    border: 1px solid var(--mm-border);
    border-radius: 8px 0 0 8px;
    color: var(--mm-text);
    padding: 12px;
    outline: none;
}

.thm-input::placeholder {
    color: var(--mm-text-dim);
}

.thm-submit-btn {
    background: var(--mm-accent-strong);
    color: #ffffff;
    border: none;
    padding: 0 20px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.thm-submit-btn:hover {
    background: var(--mm-accent-deep);
}

.thm-feedback {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

.thm-feedback.correct {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid #4ade80;
}

.thm-feedback.wrong {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid #f87171;
}

.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-4px); }
}

.correct {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.lesson-success {
    margin: 34px 0 0;
    padding: 24px;
    text-align: center;
    border: 1px solid rgba(74, 222, 128, .6);
    border-radius: 16px;
    background: rgba(74, 222, 128, .09);
}

.lesson-success h2 { margin: 0; color: #86efac; }
.lesson-success p { margin: 10px 0 18px; color: #d1fae5; }
.lesson-success-action { display: inline-block; padding: 11px 20px; border-radius: 10px; background: #22c55e; color: #052e16; text-decoration: none; font-weight: 800; }
body.light-mode .lesson-success { background: #f0fdf4; border-color: #86efac; }
body.light-mode .lesson-success h2 { color: #15803d; }
body.light-mode .lesson-success p { color: #166534; }
