/* Academy pages — same visual language as the HOY app and /admin */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --scaffold: #162739;
  --appbar: #0f1d2d;
  --card: rgba(30, 47, 70, 0.6);
  --card-solid: #1e2f46;
  --card-hover: rgba(35, 55, 82, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-high: rgba(255, 255, 255, 0.87);
  --text-medium: rgba(255, 255, 255, 0.60);
  --text-low: rgba(255, 255, 255, 0.38);
  --accent: #7986CB;
  --accent-hover: #9fa8da;
  --gold: #c9a84c;
  --danger: #ef5350;
  --success: #66bb6a;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --appbar-bg: rgba(15, 29, 45, 0.85);
  --tint-1: rgba(255, 255, 255, 0.05);
  --tint-2: rgba(255, 255, 255, 0.08);
  --tint-3: rgba(255, 255, 255, 0.16);
  --inset: rgba(0, 0, 0, 0.22);
  --primary-bg: #fff;
  --primary-fg: #162739;
  --err-fg: #ff8a80;
  --ok-fg: #a5d6a7;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-strong: 0 18px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* Light mode: follows the system unless the visitor picked a theme with the toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --scaffold: #eef1f7; --appbar: #fff; --appbar-bg: rgba(255, 255, 255, 0.88);
    --card: rgba(255, 255, 255, 0.82); --card-solid: #fff; --card-hover: #fff;
    --card-border: rgba(22, 39, 57, 0.11);
    --text-high: rgba(15, 29, 45, 0.92); --text-medium: rgba(15, 29, 45, 0.66); --text-low: rgba(15, 29, 45, 0.46);
    --accent: #5c6bc0; --accent-hover: #3f51b5; --gold: #94721c;
    --tint-1: rgba(22, 39, 57, 0.04); --tint-2: rgba(22, 39, 57, 0.06); --tint-3: rgba(22, 39, 57, 0.16);
    --inset: rgba(22, 39, 57, 0.04);
    --primary-bg: #162739; --primary-fg: #fff; --err-fg: #c62828; --ok-fg: #2e7d32;
    --shadow: 0 4px 14px rgba(22, 39, 57, 0.10); --shadow-strong: 0 16px 40px rgba(22, 39, 57, 0.16);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --scaffold: #eef1f7; --appbar: #fff; --appbar-bg: rgba(255, 255, 255, 0.88);
  --card: rgba(255, 255, 255, 0.82); --card-solid: #fff; --card-hover: #fff;
  --card-border: rgba(22, 39, 57, 0.11);
  --text-high: rgba(15, 29, 45, 0.92); --text-medium: rgba(15, 29, 45, 0.66); --text-low: rgba(15, 29, 45, 0.46);
  --accent: #5c6bc0; --accent-hover: #3f51b5; --gold: #94721c;
  --tint-1: rgba(22, 39, 57, 0.04); --tint-2: rgba(22, 39, 57, 0.06); --tint-3: rgba(22, 39, 57, 0.16);
  --inset: rgba(22, 39, 57, 0.04);
  --primary-bg: #162739; --primary-fg: #fff; --err-fg: #c62828; --ok-fg: #2e7d32;
  --shadow: 0 4px 14px rgba(22, 39, 57, 0.10); --shadow-strong: 0 16px 40px rgba(22, 39, 57, 0.16);
  color-scheme: light;
}

html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  font-family: 'Alexandria', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--scaffold);
  min-height: 100vh;
  color: var(--text-high);
  line-height: 1.8;
  direction: rtl;
  font-size: 15px;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(121, 134, 203, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(92, 143, 155, 0.07) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { position: relative; z-index: 1; width: min(1080px, calc(100% - 32px)); margin: 0 auto; }
.glass {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}

/* ── App bar ── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--appbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}
.appbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-high); }
.brand:hover { color: var(--text-high); }
.brand img { width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: contain; box-shadow: var(--shadow); }
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.brand-name small { display: block; font-family: 'Playball', cursive; color: var(--text-medium); font-size: 14px; font-weight: 400; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--text-medium); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.nav a:hover { color: var(--text-high); background: var(--tint-1); }
@media (max-width: 720px) { .nav .hide-sm { display: none; } }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-lg); border: none;
  font-weight: 600; font-size: 15px; transition: transform .15s, box-shadow .15s, background .2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); box-shadow: var(--shadow); }
.btn-primary:hover { color: var(--primary-fg); box-shadow: var(--shadow-strong); }
.btn-glass { background: var(--card); border: 1px solid var(--card-border); color: var(--text-high); backdrop-filter: blur(12px); }
.btn-glass:hover { color: var(--text-high); border-color: var(--tint-3); background: var(--card-hover); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: transparent; border: 1px solid rgba(239,83,80,.5); color: var(--danger); }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-md); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 14px; padding: 2px 0; }
.link-btn:hover { color: var(--accent-hover); }

/* ── Public page ── */
.hero { padding: 64px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 40px; align-items: center; }
.kicker { display: inline-flex; align-items: center; gap: 8px; color: var(--gold); font-size: 13px; font-weight: 500; }
.hero h1 { font-size: clamp(34px, 5.4vw, 58px); font-weight: 700; line-height: 1.35; margin: 14px 0 18px; }
.hero h1 span { display: block; }
.hero h1 .soft { color: var(--accent-hover); }
.lead { color: var(--text-medium); font-size: clamp(15px, 1.6vw, 17px); max-width: 58ch; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.icon-frame { width: min(340px, 100%); aspect-ratio: 1; margin: 0 auto; padding: 18px; display: grid; place-items: center; border-radius: var(--radius-xl); border: 1px solid var(--card-border); background: #fff; box-shadow: var(--shadow-strong); }
.icon-frame img { width: 100%; height: auto; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 30px; max-width: 520px; }
.stat { padding: 14px 16px; }
.stat b { display: block; font-size: 28px; line-height: 1.2; color: var(--text-high); }
.stat span { color: var(--text-medium); font-size: 13px; }
@media (max-width: 820px) {
  .hero { padding: 32px 0 24px; }
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .icon-frame { width: 220px; order: -1; }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 22px; }
}

.section { padding: 48px 0; }
.section-head { margin-bottom: 22px; }
.section-head h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 600; margin-top: 4px; }
.section-head p { color: var(--text-medium); max-width: 62ch; margin-top: 6px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 820px) { .grid-3 { grid-template-columns: 1fr; } }
.card { padding: 22px; transition: background .2s, border-color .2s; }
.card:hover { background: var(--card-hover); border-color: var(--tint-3); }
.card h3 { font-size: 17px; font-weight: 600; margin: 10px 0 6px; }
.card p { color: var(--text-medium); font-size: 14px; }
.glyph { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(121,134,203,.15); color: var(--accent-hover); font-size: 20px; }
.tag { display: inline-block; font-size: 12px; color: var(--gold); border: 1px solid rgba(201,168,76,.35); border-radius: 99px; padding: 1px 10px; }
.note { margin-top: 14px; padding: 12px 16px; color: var(--text-medium); font-size: 14px; }
.sources { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 720px) { .sources { grid-template-columns: 1fr; } }
.source { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; color: var(--text-high); }
.source:hover { color: var(--text-high); background: var(--card-hover); }
.source b { display: block; font-weight: 600; font-size: 15px; }
.source span span { color: var(--text-medium); font-size: 13px; }
.portal-cta { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center; padding: 32px; background: linear-gradient(135deg, rgba(121,134,203,.22), var(--card)); }
.portal-cta ul { list-style: none; display: grid; gap: 8px; }
.portal-cta li { padding: 8px 12px; border-radius: var(--radius-md); background: var(--tint-1); font-size: 14px; }
.portal-cta li::before { content: '✓ '; color: var(--gold); }
@media (max-width: 820px) { .portal-cta { grid-template-columns: 1fr; padding: 22px; } }
.footer { position: relative; z-index: 1; text-align: center; color: var(--text-low); font-size: 13px; padding: 36px 0 28px; }
.footer .cross { font-size: 18px; color: var(--text-medium); }

/* ── Forms / auth ── */
.auth { min-height: calc(100vh - 68px); display: grid; place-items: center; padding: 32px 0; }
.auth-card { width: min(420px, 100%); padding: 30px 26px; text-align: center; }
.auth-card .seal { width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 50%; background: #fff; padding: 6px; object-fit: contain; }
.auth-card h1 { font-size: 22px; font-weight: 600; }
.auth-card .sub { color: var(--text-medium); font-size: 14px; margin: 6px 0 4px; }
.tabs { display: flex; gap: 6px; padding: 4px; margin: 18px 0 6px; border-radius: var(--radius-md); background: var(--inset); }
.tabs button { flex: 1; border: none; background: none; color: var(--text-medium); padding: 8px; border-radius: var(--radius-sm); font-size: 14px; }
.tabs button.active { background: var(--card-solid); color: var(--text-high); }
.form-group { text-align: start; margin-top: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-medium); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--card-border); background: var(--inset); color: var(--text-high); font-size: 15px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(121,134,203,.2); }
.auth-card .btn { width: 100%; margin-top: 20px; }
.msg { display: none; margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-md); font-size: 14px; text-align: start; }
.msg.err { display: block; background: rgba(239,83,80,.12); color: var(--err-fg); }
.msg.ok { display: block; background: rgba(102,187,106,.12); color: var(--ok-fg); }
.fine { color: var(--text-low); font-size: 12px; margin-top: 18px; }

/* ── Library ── */
.lib-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 14px; padding: 26px 0 16px; }
.lib-head h1 { font-size: clamp(22px, 3vw, 30px); font-weight: 600; }
.lib-head p { color: var(--text-medium); font-size: 14px; }
.search { position: relative; width: min(340px, 100%); }
.search .input { padding-inline-start: 40px; }
.search svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--text-low); }
.lib { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; padding-bottom: 32px; }
.side { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; padding: 8px; }
.side-toggle { display: none; margin-bottom: 10px; }
.month { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; text-align: start; border: none; background: none; color: var(--text-high); padding: 9px 12px; border-radius: var(--radius-md); font-size: 14px; line-height: 1.5; }
.month:hover { background: var(--tint-1); }
.month.active { background: rgba(121,134,203,.22); }
.month b { display: block; font-size: 11px; color: var(--gold); font-weight: 500; }
.month small { flex: none; font-size: 11px; color: var(--text-medium); background: var(--tint-2); border-radius: 99px; padding: 0 8px; }
.side hr { border: none; border-top: 1px solid var(--card-border); margin: 6px 4px; }
.pane { min-width: 0; padding: 24px; }
.pane h2 { font-size: clamp(20px, 2.6vw, 26px); font-weight: 600; margin: 2px 0 16px; }
.meta { color: var(--gold); font-size: 13px; }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.lesson-card { display: flex; flex-direction: column; gap: 3px; text-align: start; padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid var(--card-border); background: var(--inset); color: var(--text-high); transition: border-color .2s, background .2s; }
.lesson-card:hover { border-color: var(--accent); background: rgba(121,134,203,.08); }
.lesson-card span { font-size: 12px; color: var(--gold); }
.lesson-card strong { font-size: 15px; font-weight: 600; line-height: 1.6; }
.lesson-card em { font-style: normal; font-size: 13px; color: var(--text-medium); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.lesson-body { font-size: 16px; line-height: 2.05; color: var(--text-high); }
.lesson-body h3, .lesson-body h4 { color: var(--accent-hover); font-weight: 600; margin: 24px 0 6px; font-size: 17px; padding-inline-start: 10px; border-inline-start: 3px solid var(--gold); }
.lesson-body h3 { font-size: 19px; }
.lesson-body p { margin: 6px 0 10px; }
.lesson-body ul, .lesson-body ol { margin: 6px 22px 12px 0; }
.lesson-body a { text-decoration: underline; }
.table-scroll { overflow-x: auto; }
.lesson-body table { border-collapse: collapse; width: 100%; min-width: 440px; margin: 14px 0; font-size: 14px; }
.lesson-body td, .lesson-body th { border: 1px solid var(--card-border); padding: 8px 10px; vertical-align: top; }
.lesson-body tr:first-child td, .lesson-body th { background: var(--tint-1); font-weight: 600; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--card-border); }
.pager button { max-width: 48%; text-align: start; }
.pager button[hidden] { display: block !important; visibility: hidden; }
.empty { text-align: center; color: var(--text-medium); padding: 28px; }
mark { background: rgba(201,168,76,.3); color: inherit; border-radius: 3px; padding: 0 2px; }
@media (max-width: 860px) {
  .lib { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; display: none; }
  .side.open { display: block; }
  .side-toggle { display: inline-flex; }
  .pane { padding: 16px; }
}

/* ── Manage (portal editors) ── */
.mtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.mtabs a { padding: 8px 16px; border-radius: var(--radius-md); color: var(--text-medium); border: 1px solid var(--card-border); }
.mtabs a.active { color: var(--text-high); background: rgba(121,134,203,.2); border-color: rgba(121,134,203,.4); }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--card-border); }
.row:last-child { border-bottom: none; }
.row .who b { display: block; font-weight: 500; }
.row .who span { color: var(--text-medium); font-size: 13px; direction: ltr; unicode-bidi: plaintext; }
.row .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 1px 10px; border-radius: 99px; background: var(--tint-2); color: var(--text-medium); }
.badge.editor { background: rgba(201,168,76,.18); color: var(--gold); }
.badge.mentor { background: rgba(102,187,106,.15); color: var(--ok-fg); }
.form-grid { display: grid; grid-template-columns: 1fr 120px 120px; gap: 10px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span-all { grid-column: 1 / -1; } }
.form-grid .span-all { grid-column: 1 / -1; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid var(--card-border); border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0; background: var(--inset); }
.editor-bar button { border: none; background: none; color: var(--text-high); padding: 4px 10px; border-radius: var(--radius-sm); font-size: 13px; }
.editor-bar button:hover { background: var(--tint-2); }
.editor { min-height: 320px; max-height: 60vh; overflow: auto; padding: 14px 16px; border: 1px solid var(--card-border); border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--inset); }
.editor:focus { outline: none; border-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-top: 16px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(120px); z-index: 50; padding: 10px 20px; border-radius: var(--radius-md); background: var(--card-solid); border: 1px solid var(--card-border); box-shadow: var(--shadow); transition: transform .3s; font-size: 14px; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(239,83,80,.5); }

.spinner { width: 22px; height: 22px; border: 2px solid var(--text-low); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media print {
  .appbar, .lib-head, .side, .side-toggle, .toolbar, .pager, .footer { display: none !important; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
  .glass { background: none; border: none; backdrop-filter: none; }
  .lib { display: block; }
  .lesson-body, .lesson-body h3, .lesson-body h4 { color: #000; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

/* Google sign-in on the portal login */
.auth-card .google-btn { margin-top: 18px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; color: var(--text-low); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }

/* Theme toggle (added to the app bar by theme.js) */
.theme-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--tint-1); color: var(--text-high); font-size: 16px; line-height: 1; }
.theme-btn:hover { background: var(--tint-2); }

/* Lesson attachments */
.attachments { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--card-border); }
.attachments h3 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 14px; }
.att-file, .att-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--card-border); background: var(--inset); color: var(--text-high); min-width: 0; }
.att-file:hover, .att-link:hover { border-color: var(--accent); color: var(--text-high); }
.att-file b, .att-link b { display: block; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file small, .att-link small { display: block; color: var(--text-medium); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file > span:last-child, .att-link > span:last-child { min-width: 0; }
.att-link { margin-bottom: 10px; }
.att-icon { flex: none; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.att-icon.sm { width: 28px; height: 22px; border-radius: 5px; font-size: 9px; vertical-align: middle; }
.att-video { margin: 0 0 16px; }
.att-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-md); overflow: hidden; background: #000; }
.att-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.att-video figcaption { color: var(--text-medium); font-size: 13px; margin-top: 6px; }
.att-edit { border: 1px solid var(--card-border); border-radius: var(--radius-md); margin-bottom: 10px; }
.att-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.att-add label.btn { cursor: pointer; margin: 0; display: inline-flex; color: var(--text-high); font-size: 13px; }
.att-link-form .input { flex: 1 1 200px; padding: 8px 12px; }
@media print { .att-video { display: none; } }
