/* ══════════════════════════════════════════════════════
   OccuTeach Workbooks — Premium Frontend
   Fonts: DM Serif Display (headings) / Lexend (body)
   Colours: Purple #5B2D8E · Gold #C9A84C · White
   Mobile first throughout
══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Lexend:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --purple:      #5B2D8E;
    --purple-dk:   #3d1d63;
    --purple-lt:   #f3eefb;
    --gold:        #C9A84C;
    --gold-dk:     #b89840;
    --gold-lt:     #fdf8ee;
    --gold-grad:   linear-gradient(135deg, #d4b85c 0%, #C9A84C 60%, #b89840 100%);
    --text:        #1a1a2e;
    --text-muted:  #6b7280;
    --border:      #e8e3f0;
    --bg:          #f7f5fb;
    --white:       #ffffff;
    --radius:      12px;
    --radius-sm:   8px;
    --shadow:      0 2px 16px rgba(91,45,142,0.08);
    --shadow-md:   0 4px 24px rgba(91,45,142,0.12);
}

html { scroll-behavior: smooth; }

body.ocw-body {
    font-family: 'Lexend', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────── */
.ocw-header {
    background: var(--purple);
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 20px rgba(0,0,0,0.2);
}
.ocw-header-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.ocw-logo {
    max-height: 38px;
    width: auto;
    display: block;
}
.ocw-logo-text {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    color: var(--white);
    letter-spacing: 0.02em;
}
.ocw-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.ocw-learner-name {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.12);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ocw-expires {
    font-size: 11px;
    color: var(--gold);
    font-weight: 500;
    white-space: nowrap;
}

/* ── Progress strip ──────────────────────────────────── */
.ocw-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: rgba(0,0,0,0.1);
    z-index: 999;
}
.ocw-progress-fill {
    height: 100%;
    background: var(--gold-grad);
    transition: width 0.5s cubic-bezier(.4,0,.2,1);
    width: 0%;
    border-radius: 0 3px 3px 0;
}

/* ── Main layout ─────────────────────────────────────── */
.ocw-main {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

/* ── Save bar ─────────────────────────────────────────── */
.ocw-save-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    font-size: 12px;
    font-weight: 500;
}
.ocw-save-idle   { color: #059669; }
.ocw-save-saving { color: var(--gold-dk); }
.ocw-save-error  { color: #dc2626; }

/* ── Title block ─────────────────────────────────────── */
.ocw-workbook-title-block {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--gold);
    position: relative;
    overflow: hidden;
}
.ocw-workbook-title-block::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 120px; height: 120px;
    background: var(--purple-lt);
    border-radius: 0 0 0 120px;
    opacity: 0.6;
}
.ocw-workbook-title-block h1 {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(22px, 5vw, 32px);
    color: var(--purple);
    line-height: 1.2;
    margin-bottom: 12px;
    position: relative;
}
.ocw-intro {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
    font-weight: 300;
    position: relative;
}

/* ── Sections ────────────────────────────────────────── */
.ocw-section {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    counter-reset: question-counter;
}

.ocw-section-title {
    background: var(--purple);
    color: var(--white);
    padding: 16px 24px;
    font-family: 'DM Serif Display', serif;
    font-size: clamp(15px, 3vw, 18px);
    font-weight: 400;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ocw-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--gold);
    border-radius: 2px;
    flex-shrink: 0;
}

.ocw-section-content {
    padding: 20px 24px;
    background: var(--purple-lt);
    border-bottom: 1px solid var(--border);
    color: #3d2060;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.85;
}
.ocw-section-content p { margin-bottom: 10px; }
.ocw-section-content p:last-child { margin-bottom: 0; }
.ocw-section-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 16px 0;
    display: block;
    box-shadow: var(--shadow-md);
}

/* ── Questions ───────────────────────────────────────── */
.ocw-question {
    padding: 20px 24px;
    border-bottom: 1px solid #f0ebf8;
    counter-increment: question-counter;
}
.ocw-question:last-child { border-bottom: none; }

.ocw-q-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--purple-lt);
    border-left: 4px solid var(--purple);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.ocw-q-label::before {
    content: "Q" counter(question-counter);
    display: inline-block;
    background: var(--purple);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    margin-right: 8px;
    letter-spacing: 0.05em;
    vertical-align: middle;
}
.ocw-required { color: #dc2626; margin-left: 2px; }

/* ── Inputs ──────────────────────────────────────────── */
.ocw-input {
    width: 100%;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    font-family: 'Lexend', sans-serif;
    font-weight: 300;
    color: var(--text);
    background: #fdfcff;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
    min-height: 110px;
    line-height: 1.6;
}
.ocw-input:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(91,45,142,0.1);
    background: var(--white);
}
.ocw-input::placeholder { color: #c4b5d6; font-weight: 300; }

/* ── Radio / Yes/No ──────────────────────────────────── */
.ocw-yesno, .ocw-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}
.ocw-radio-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 18px;
    border: 2px solid var(--border);
    border-radius: 30px;
    background: #fdfcff;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 400;
    user-select: none;
}
.ocw-radio-opt input[type=radio] { accent-color: var(--purple); width: 16px; height: 16px; }
.ocw-radio-opt:hover { border-color: var(--purple); background: var(--purple-lt); }
.ocw-radio-opt.selected { border-color: var(--purple); background: var(--purple-lt); color: var(--purple); font-weight: 600; }

/* ── Checkboxes ──────────────────────────────────────── */
.ocw-checkbox-group { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ocw-check-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fdfcff;
    transition: all 0.2s;
    font-size: 14px;
}
.ocw-check-opt input[type=checkbox] { accent-color: var(--purple); width: 16px; height: 16px; flex-shrink: 0; }
.ocw-check-opt:hover { border-color: var(--purple); background: var(--purple-lt); }
.ocw-check-opt:has(input:checked) { border-color: var(--purple); background: var(--purple-lt); color: var(--purple); }

/* ── Table ───────────────────────────────────────────── */
.ocw-table-wrap { overflow-x: auto; margin-top: 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.ocw-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 400px; }
.ocw-table th { background: var(--purple); color: var(--white); padding: 12px 14px; text-align: left; font-weight: 600; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }
.ocw-table td { border-bottom: 1px solid var(--border); padding: 4px; vertical-align: top; }
.ocw-table tr:last-child td { border-bottom: none; }
.ocw-table-cell { width: 100%; min-height: 52px; border: none; padding: 8px 10px; font-family: 'Lexend', sans-serif; font-size: 13px; font-weight: 300; resize: none; background: transparent; line-height: 1.5; color: var(--text); }
.ocw-table-cell:focus { outline: none; background: var(--purple-lt); }

/* ── Submit ──────────────────────────────────────────── */
.ocw-submit-wrap {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}
.ocw-submit-wrap::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--gold-grad);
}
.ocw-submit-note {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-weight: 300;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}
.ocw-btn-submit {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--purple);
    color: var(--white);
    border: none;
    padding: 16px 40px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Lexend', sans-serif;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(91,45,142,0.3);
}
.ocw-btn-submit:hover { background: var(--purple-dk); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(91,45,142,0.4); }
.ocw-btn-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Error / Submitted ───────────────────────────────── */
.ocw-error-box, .ocw-submitted-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    max-width: 560px;
    margin: 40px auto;
}
.ocw-error-box h2 { font-family: 'DM Serif Display', serif; color: #dc2626; font-size: 24px; margin-bottom: 12px; }
.ocw-submitted-box h2 { font-family: 'DM Serif Display', serif; color: var(--purple); font-size: 24px; margin-bottom: 12px; }
.ocw-error-box p, .ocw-submitted-box p { color: var(--text-muted); font-size: 14px; margin-top: 8px; }
.ocw-error-box a, .ocw-submitted-box a { color: var(--purple); }

/* ── Footer ──────────────────────────────────────────── */
.ocw-footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 300;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    background: var(--white);
}

/* ── Modals ───────────────────────────────────────────── */
.ocw-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}
.ocw-modal-box {
    background: var(--white);
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: ocw-modal-in 0.2s ease;
}
@keyframes ocw-modal-in {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}
.ocw-modal-header {
    background: var(--purple);
    color: var(--white);
    padding: 20px 24px;
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    text-align: center;
}
.ocw-modal-header-success { background: #059669; }
.ocw-modal-header-error   { background: #dc2626; }
.ocw-modal-body {
    padding: 24px;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
}
.ocw-modal-body p { margin-bottom: 10px; }
.ocw-modal-body p:last-child { margin-bottom: 0; }
.ocw-modal-body strong { color: var(--text); }
.ocw-modal-body a { color: var(--purple); }
.ocw-modal-footer {
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.ocw-modal-btn-primary {
    background: var(--purple);
    color: var(--white);
    border: none;
    padding: 10px 22px;
    border-radius: 25px;
    font-family: 'Lexend', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.ocw-modal-btn-primary:hover { background: var(--purple-dk); }
.ocw-modal-btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--border);
    padding: 10px 22px;
    border-radius: 25px;
    font-family: 'Lexend', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.ocw-modal-btn-secondary:hover { border-color: var(--purple); color: var(--purple); }
@media (max-width: 479px) {
    .ocw-modal-footer { flex-direction: column-reverse; }
    .ocw-modal-btn-primary, .ocw-modal-btn-secondary { width: 100%; text-align: center; }
}
@media (min-width: 480px) {
    .ocw-main { padding: 28px 20px 80px; }
}
@media (min-width: 768px) {
    .ocw-header-inner { padding: 0 28px; height: 68px; }
    .ocw-logo { max-height: 40px; }
    .ocw-main { padding: 32px 28px 80px; }
    .ocw-workbook-title-block { padding: 36px 40px; }
    .ocw-section-title { padding: 18px 32px; }
    .ocw-section-content { padding: 24px 32px; font-size: 15px; }
    .ocw-question { padding: 24px 32px; }
    .ocw-submit-wrap { padding: 40px 48px; }
    .ocw-q-label { font-size: 15px; }
    .ocw-input { font-size: 15px; }
}
@media (max-width: 479px) {
    .ocw-yesno, .ocw-radio-group { flex-direction: column; }
    .ocw-radio-opt, .ocw-check-opt { width: 100%; }
    .ocw-btn-submit { width: 100%; justify-content: center; padding: 18px 24px; }
    .ocw-expires { display: none; }
    .ocw-learner-name { max-width: 110px; font-size: 11px; }
}