/*
 * theme.css — עיצוב משותף למרחב הלמידה הדיגיטלי.
 * מוגש מ-/shared-ui/theme.css ונטען באתר הראשי (Astro), באתר הספרים (MkDocs) וב-CSVisualizer.
 *
 * כללים:
 *   - כל המשתנים מתחילים ב---lp- וכל הרכיבים ב-.lp-, כדי לא להתנגש בעיצוב האתרים המארחים.
 *   - אין כאן כללים גלובליים על תגיות (body, a, ul...) — רק בתוך .lp-header / .lp-footer.
 *   - הסעיף האחרון מתאים את צבעי MkDocs Material לפלטת המרחב (חל רק על דפי Material).
 */

@import url("fonts/rubik.css");

/* ------------------------------------------------------------------ tokens */
:root {
  /* colors */
  --lp-bg: #f6f7f9;
  --lp-surface: #ffffff;
  --lp-surface-2: #eef1f5;
  --lp-text: #17202b;
  --lp-text-muted: #4f5b6a;
  --lp-border: #d9dee6;
  --lp-primary: #1f5fbf;
  --lp-primary-strong: #164a96;
  --lp-primary-soft: #e3ecfa;
  --lp-on-primary: #ffffff;
  --lp-accent: #f2b33d;
  --lp-accent-books: #1f7a5a;
  --lp-accent-sims: #7a4ab8;
  --lp-accent-materials: #b5651d;
  --lp-accent-tools: #0e7490;
  --lp-focus: #ffb000;

  /* typography */
  --lp-font: "Rubik", "Segoe UI", "Noto Sans Hebrew", Arial, sans-serif;
  --lp-font-mono: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Consolas, monospace;
  --lp-text-sm: 0.875rem;
  --lp-text-md: 1rem;
  --lp-text-lg: 1.125rem;

  /* spacing scale */
  --lp-space-1: 4px;
  --lp-space-2: 8px;
  --lp-space-3: 12px;
  --lp-space-4: 16px;
  --lp-space-5: 24px;
  --lp-space-6: 32px;
  --lp-space-7: 48px;

  /* shape and layout */
  --lp-radius: 14px;
  --lp-radius-sm: 8px;
  --lp-radius-pill: 999px;
  --lp-shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  --lp-shadow-hover: 0 2px 4px rgb(16 24 40 / 8%), 0 12px 28px rgb(16 24 40 / 10%);
  --lp-max-width: 1120px;
  --lp-header-height: 60px;
  /* צבע הכיתוב "abin" (הכחול-כהה של הלוגו; בהיר במצב כהה) */
  --lp-brand-ink: #0b1f4d;
  /* רקע ללוגו abin: שקוף במצב בהיר, שבב בהיר במצב כהה (הכיתוב הכחול-כהה לא נקרא על רקע כהה) */
  --lp-logo-bg: transparent;
}

/* dark: לפי העדפת המערכת, או כשמצב הכהה של Material פעיל (גובר על העדפת המערכת) */
@media (prefers-color-scheme: dark) {
  :root {
    --lp-bg: #0f141b;
    --lp-surface: #171e27;
    --lp-surface-2: #1f2833;
    --lp-text: #e8edf3;
    --lp-text-muted: #a7b3c2;
    --lp-border: #2c3744;
    --lp-primary: #6ea8ff;
    --lp-primary-strong: #94bfff;
    --lp-primary-soft: #1b2b44;
    --lp-on-primary: #0f141b;
    --lp-accent-books: #4cc495;
    --lp-accent-sims: #b892ef;
    --lp-accent-materials: #f0a35e;
    --lp-accent-tools: #4fc3d9;
    --lp-shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    --lp-shadow-hover: 0 2px 4px rgb(0 0 0 / 35%), 0 12px 28px rgb(0 0 0 / 35%);
    --lp-logo-bg: #f4f7fb;
    --lp-brand-ink: #e8edf3;
  }
}
body[data-md-color-scheme="slate"] {
  --lp-bg: #0f141b;
  --lp-surface: #171e27;
  --lp-surface-2: #1f2833;
  --lp-text: #e8edf3;
  --lp-text-muted: #a7b3c2;
  --lp-border: #2c3744;
  --lp-primary: #6ea8ff;
  --lp-primary-strong: #94bfff;
  --lp-primary-soft: #1b2b44;
  --lp-on-primary: #0f141b;
  --lp-logo-bg: #f4f7fb;
  --lp-brand-ink: #e8edf3;
}
body[data-md-color-scheme="default"] {
  --lp-bg: #f6f7f9;
  --lp-surface: #ffffff;
  --lp-surface-2: #eef1f5;
  --lp-text: #17202b;
  --lp-text-muted: #4f5b6a;
  --lp-border: #d9dee6;
  --lp-primary: #1f5fbf;
  --lp-primary-strong: #164a96;
  --lp-primary-soft: #e3ecfa;
  --lp-on-primary: #ffffff;
  --lp-logo-bg: transparent;
  --lp-brand-ink: #0b1f4d;
}

/* ------------------------------------------------------------------ shared helpers */
.lp-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

.lp-header,
.lp-footer {
  box-sizing: border-box;
  font-family: var(--lp-font);
  font-size: var(--lp-text-md);
  line-height: 1.5;
  color: var(--lp-text);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}
.lp-header *,
.lp-footer *,
.lp-header *::before,
.lp-footer *::before { box-sizing: border-box; }
.lp-header ul,
.lp-footer ul { margin: 0; padding: 0; list-style: none; }
.lp-header a:focus-visible,
.lp-footer a:focus-visible,
.lp-header button:focus-visible {
  outline: 3px solid var(--lp-focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ header */
.lp-header {
  position: relative;
  z-index: 60;
  width: 100%;
  background: var(--lp-surface);
  border-bottom: 1px solid var(--lp-border);
  box-shadow: 0 1px 0 rgb(16 24 40 / 3%);
}
.lp-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--lp-space-3) var(--lp-space-5);
  max-width: var(--lp-max-width);
  min-height: var(--lp-header-height);
  margin-inline: auto;
  padding: var(--lp-space-2) 20px;
}

.lp-header .lp-skip {
  position: absolute;
  inset-inline-start: 12px;
  top: -80px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--lp-radius-sm);
  background: var(--lp-primary);
  color: var(--lp-on-primary);
  font-weight: 600;
  text-decoration: none;
}
.lp-header .lp-skip:focus { top: 10px; }

.lp-header .lp-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--lp-text);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.lp-header .lp-brand:hover { color: var(--lp-primary-strong); }
/* סמל abin + שם + שורת תיאור. הסמל בשבב בהיר במצב כהה (--lp-logo-bg) */
.lp-brand__icon {
  display: block;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--lp-logo-bg);
}
.lp-brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.lp-header .lp-brand__name { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.01em; color: var(--lp-brand-ink); }
.lp-header .lp-brand__tag { font-size: 0.72rem; font-weight: 500; color: var(--lp-text-muted); }

/* סימון "נפתח בחלון חדש" (חץ ↗) לקישורים עם target="_blank"; הטקסט לקוראי מסך ב-.lp-visually-hidden */
.lp-ext {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-inline-start: 0.3em;
  vertical-align: -0.05em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M9 2h5v5h-1.6V4.7L7.1 10 6 8.9l5.3-5.3H9zM3 4h4v1.6H4.6v5.8h5.8V9H12v4H3z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M9 2h5v5h-1.6V4.7L7.1 10 6 8.9l5.3-5.3H9zM3 4h4v1.6H4.6v5.8h5.8V9H12v4H3z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.lp-nav__list { display: flex; flex-wrap: wrap; gap: var(--lp-space-1); }
.lp-header .lp-nav__link {
  display: block;
  padding: 7px 14px;
  border-radius: var(--lp-radius-pill);
  color: var(--lp-text-muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.lp-header .lp-nav__link:hover { background: var(--lp-surface-2); color: var(--lp-text); }
.lp-header .lp-nav__link[aria-current="page"] {
  background: var(--lp-primary-soft);
  color: var(--lp-primary-strong);
  font-weight: 600;
}

.lp-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--lp-border);
  border-radius: var(--lp-radius-sm);
  background: var(--lp-surface);
  color: var(--lp-text);
  cursor: pointer;
}
.lp-nav-toggle[hidden] { display: none !important; }
.lp-nav-toggle__icon,
.lp-nav-toggle__icon::before,
.lp-nav-toggle__icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.lp-nav-toggle__icon { position: relative; }
.lp-nav-toggle__icon::before,
.lp-nav-toggle__icon::after { content: ""; position: absolute; inset-inline-start: 0; }
.lp-nav-toggle__icon::before { top: -6px; }
.lp-nav-toggle__icon::after { top: 6px; }

@media (max-width: 760px) {
  .lp-header__inner { padding-inline: 16px; }
  /* בלי JavaScript: הניווט בשורה נפרדת עם גלילה אופקית */
  .lp-nav { width: 100%; overflow-x: auto; }
  .lp-nav__list { flex-wrap: nowrap; }
  /* עם JavaScript: תפריט נפתח */
  .lp-header.lp-js .lp-nav-toggle { display: inline-flex; }
  .lp-header.lp-js .lp-nav { display: none; overflow: visible; }
  .lp-header.lp-js .lp-nav[data-open] { display: block; padding-bottom: var(--lp-space-2); }
  .lp-header.lp-js .lp-nav__list { flex-direction: column; flex-wrap: nowrap; }
  .lp-header.lp-js .lp-nav__link { border-radius: var(--lp-radius-sm); padding: 10px 12px; }
}

/* ------------------------------------------------------------------ footer */
.lp-footer {
  width: 100%;
  background: var(--lp-surface);
  border-top: 1px solid var(--lp-border);
  color: var(--lp-text-muted);
  font-size: 0.95rem;
}
.lp-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--lp-space-3) var(--lp-space-6);
  max-width: var(--lp-max-width);
  margin-inline: auto;
  padding: var(--lp-space-5) 20px;
}
.lp-footer .lp-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lp-text);
  font-weight: 700;
  text-decoration: none;
}
.lp-footer__brand img { display: block; border-radius: 6px; background: var(--lp-logo-bg); }
.lp-footer__list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.lp-footer__list a { color: var(--lp-text-muted); text-decoration: none; }
.lp-footer__list a:hover,
.lp-footer__list a[aria-current="page"] { color: var(--lp-primary-strong); text-decoration: underline; text-underline-offset: 3px; }
.lp-footer__copy { flex-basis: 100%; margin: 0; font-size: var(--lp-text-sm); }

@media (prefers-reduced-motion: reduce) {
  .lp-header *, .lp-footer * { transition: none !important; }
}

/* ------------------------------------------------------------------ MkDocs Material: פלטת המרחב */
/* חל רק על דפי Material (התכונה data-md-color-scheme קיימת רק שם) */
[data-md-color-scheme="default"] {
  --md-primary-fg-color: #1f5fbf;
  --md-primary-fg-color--light: #4a80d1;
  --md-primary-fg-color--dark: #164a96;
  --md-typeset-a-color: #1f5fbf;
}
[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #2a5fae;
  --md-primary-fg-color--light: #6ea8ff;
  --md-primary-fg-color--dark: #1b3f78;
  --md-typeset-a-color: #8fbcff;
}
