/* ============================================================
   CSS CUSTOM PROPERTIES
   Edit everything here to control the look of the site.
   ============================================================ */
:root {

  /* — Colors — */
  --bg:           #f2f2f2;
  --bg-card:      #ffffff;
  --bg-raised:    #e8e8e8;
  --bg-video:     #000000;
  --bg-pdf:       #e0e0e0;
  --border:       #d0d0d0;
  --border-light: #bbbbbb;
  --accent:       #b83232;
  --accent-hover: #991f1f;
  --text:         #111111;
  --text-muted:   #444444;
  --text-dim:     #777777;

  /* — Layout — */
  --side-width:   240px;
  --header-h:     64px;

  /* — Fonts — */
  --font-display: 'Rubik', sans-serif;
  --font-body:    'Rubik', sans-serif;
  --font-latin:   'Rubik', sans-serif;

  /* — Font sizes — */
  --fs-hero:          clamp(2rem, 5vw, 3.2rem);
  --fs-page-title:    clamp(1.6rem, 4vw, 2.4rem);
  --fs-nav:           0.95rem;
  --fs-nav-mobile:    1.15rem;
  --fs-nav-identity:  1rem;
  --fs-nav-mobile-id: 1.05rem;
  --fs-about:         1.05rem;
  --fs-lang-label:    0.7rem;
  --fs-date:          1rem;
  --fs-card-title:    1.3rem;
  --fs-card-speaker:  1rem;
  --fs-footer:        0.78rem;
  --fs-footer-sep:    0.7rem;
  --fs-label:         0.7rem;
  --fs-pdf-btn:       0.75rem;
  --fs-error:         0.9rem;
  --fs-error-icon:    1.2rem;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ============================================================
   LOADING
   ============================================================ */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}
.loading-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MOBILE HEADER
   ============================================================ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  min-height: var(--header-h);
  height: auto;
  background: var(--bg-card);
  border-bottom: 2px solid var(--text);
  z-index: 200;
  transition: transform 0.3s ease;
}
.mobile-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding: 12px 16px;
  direction: ltr; /* burger on right, identity on left */
}
.site-identity-small {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  direction: rtl;
}
.site-identity-small img {
  height: 36px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.site-identity-small .site-title-small {
  font-family: var(--font-display);
  font-size: var(--fs-nav-mobile-id);
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Burger button */
.burger {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}
.burger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  transition: transform 0.25s, opacity 0.25s;
}
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   MOBILE NAV OVERLAY
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-card);
  z-index: 190;
  overflow-y: auto;
  padding: 16px 0;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.mobile-nav.open { transform: translateX(0); }

.mobile-nav ul li a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 24px;
  font-family: var(--font-display);
  font-size: var(--fs-nav-mobile);
  font-weight: 400;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  transition: color 0.2s;
  line-height: 1.3;
}
.mobile-nav ul li a:hover,
.mobile-nav ul li a.active { color: var(--text); }
.mobile-nav ul li a.active {
  border-right: 4px solid var(--accent);
  color: var(--text);
  font-weight: 700;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 100vh;
}

/* ============================================================
   DESKTOP SIDE NAV
   ============================================================ */
.side-nav {
  width: var(--side-width);
  min-height: 100vh;
  background: var(--bg-card);
  border-left: 2px solid var(--text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 32px 0 24px;
  flex-shrink: 0;
}

.side-nav-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 20px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.side-nav-identity img {
  height: 52px;
  width: auto;
  object-fit: contain;
}
.side-nav-identity .site-title-nav {
  font-family: var(--font-display);
  font-size: var(--fs-nav-identity);
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  color: var(--text);
}

#side-nav-list li {
  border-bottom: 1px solid var(--border);
}
#side-nav-list li a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 20px;
  font-family: var(--font-display);
  font-size: var(--fs-nav);
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s;
  border-right: 4px solid transparent;
  line-height: 1.3;
}
#side-nav-list li a:hover { color: var(--text); }
#side-nav-list li a.active {
  color: var(--text);
  border-right-color: var(--accent);
  font-weight: 700;
}

.nav-label-sub {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text);
  opacity: 1;
  line-height: 1.2;
}
#side-nav-list li a.active .nav-label-sub,
.mobile-nav ul li a.active .nav-label-sub {
  font-weight: 700;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  padding: 48px 40px 64px;
  min-width: 0;
}

/* ============================================================
   HOMEPAGE
   ============================================================ */
.homepage-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 0 56px;
  border-bottom: 2px solid var(--text);
  margin-bottom: 52px;
}
.homepage-hero img.hero-logo {
  height: 100px;
  width: auto;
  object-fit: contain;
  margin-bottom: 20px;
}
.homepage-hero .hero-title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}

.about-section {
  max-width: 680px;
  margin: 0 auto;
}
.about-block {
  margin-bottom: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}
.about-block:last-child { border-bottom: none; }
.about-block[dir="rtl"] { text-align: right; }
.about-block[dir="ltr"] { text-align: left; }

.about-block .lang-label {
  font-size: var(--fs-lang-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
  font-family: var(--font-body);
  font-weight: 700;
}
.about-block p {
  font-size: var(--fs-about);
  line-height: 1.85;
  color: var(--text-muted);
  margin-bottom: 1em;
}
.about-block p:last-child { margin-bottom: 0; }

/* ============================================================
   PAGE TITLE
   ============================================================ */
.page-title {
  font-family: var(--font-display);
  font-size: var(--fs-page-title);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 36px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--text);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.page-title-sub {
  font-size: var(--fs-page-title);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.page-title::after {
  content: '';
  position: absolute;
  bottom: -2px; right: 0;
  width: 48px; height: 3px;
  background: var(--accent);
}

/* ============================================================
   LECTURE GRID
   ============================================================ */
.lecture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px 28px;
}

.lecture-card.full-width {
  grid-column: 1 / -1;
}

.lecture-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.lecture-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* Multi-video column wrapper */
.video-col {
  display: flex;
  flex-direction: column;
}

.lecture-card.full-width .video-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0;
}
.lecture-card.full-width .video-group .video-col {
  border-left: none;
}
.lecture-card.full-width .video-group .video-col:last-child {
  border-left: none;
}
.lecture-card.full-width .video-group .video-col .video-wrapper {
  border-left: 1px solid var(--border);
}
.lecture-card.full-width .video-group .video-col:last-child .video-wrapper {
  border-left: none;
}

.video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--bg-video);
}
.video-wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}
.video-part-label {
  position: absolute;
  bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 2px;
  font-family: var(--font-body);
  pointer-events: none;
}

/* Date shown below each video in multi-video cards */
.video-date {
  font-size: var(--fs-date);
  color: var(--accent);
  font-weight: 700;
  padding: 8px 12px;
  background: var(--bg-card);
  text-align: center;
}

/* Title shown above videos in multi-video cards */
.lecture-meta-top {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 0;
}

/* ============================================================
   LECTURE CARD META
   ============================================================ */
.lecture-meta {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  align-items: center;
  text-align: center;
}

.lecture-date {
  font-size: var(--fs-date);
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 2px;
}

.section-date {
  font-size: var(--fs-date);
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}

.lecture-lang-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: center;
}
.lecture-lang-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.lecture-lang-block .lang-title {
  font-family: var(--font-display);
  font-size: var(--fs-card-title);
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.lecture-lang-block .lang-speaker {
  font-size: var(--fs-card-speaker);
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}
.lecture-lang-block.rtl {
  direction: rtl;
}
.lecture-lang-block.ltr {
  direction: ltr;
}

/* ============================================================
   TEXTS PAGE
   ============================================================ */
.texts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px 28px;
}

.text-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.text-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.pdf-thumb-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--bg-pdf);
  overflow: hidden;
}
.pdf-thumb-wrapper a.pdf-thumb-link {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}
.pdf-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}
.pdf-thumb-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to bottom, transparent, white);
  pointer-events: none;
}
.pdf-open-btn {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  z-index: 1;
}
.pdf-open-btn:hover { color: var(--accent); border-color: var(--accent); }
.pdf-open-btn svg { width: 14px; height: 14px; flex-shrink: 0; }



.pdf-open-btn {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  z-index: 1;
}
.pdf-open-btn:hover { color: var(--accent); border-color: var(--accent); }
.pdf-open-btn svg { width: 14px; height: 14px; flex-shrink: 0; }



.text-meta {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  text-align: center;
}
.text-date {
  font-size: var(--fs-date);
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 2px;
}
.text-title-heb,
.text-title-arb { direction: rtl; text-align: center; }
.text-title-eng { direction: ltr; text-align: center; }

.text-title-heb {
  font-family: var(--font-display);
  font-size: var(--fs-card-title);
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.text-title-arb {
  font-family: var(--font-display);
  font-size: var(--fs-card-title);
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}
.text-title-eng {
  font-size: var(--fs-card-title);
  color: var(--text-muted);
  line-height: 1.4;
}

/* ============================================================
   SKELETON SHIMMER
   ============================================================ */
@keyframes shimmer {
  from { background-position: 600px 0; }
  to   { background-position: -600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-raised) 50%, var(--border) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
  display: block;
}

/* Homepage skeleton */
.sk-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px 56px;
}

/* Rows skeleton (lectures / texts / links) */
.sk-rows-list { border-top: 1px solid var(--border); }
.sk-row {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sk-row-title { height: 18px; }
.sk-row-sub   { height: 13px; }

/* ============================================================
   LINKS PAGE
   ============================================================ */
.links-list {
  list-style: none;
  border-top: 1px solid var(--border);
}

.link-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.link-item[dir="rtl"] { flex-direction: row; }
.link-item[dir="ltr"] { flex-direction: row; }

.link-author {
  font-size: 0.88rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.link-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  transition: color 0.2s;
}
a.link-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.link-source {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.link-date {
  font-size: 0.82rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.skeleton-link-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.sk-line { display: block; }

/* ============================================================
   IMAGES (MASONRY) PAGE
   ============================================================ */
.masonry-grid {
  column-count: 3;
  column-gap: 12px;
}
.masonry-item {
  break-inside: avoid;
  margin-bottom: 12px;
}
.masonry-item img {
  width: 100%;
  display: block;
  border-radius: 4px;
  transition: opacity 0.2s;
}
.masonry-item img:hover { opacity: 0.88; }

/* Images section heading (Task 5) */
.images-section { margin-bottom: 72px; }
.images-section-title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.images-section-title .page-title-sub { font-size: inherit; }
.images-section-title::after {
  content: '';
  position: absolute;
  bottom: -1px; right: 0;
  width: 32px; height: 2px;
  background: var(--accent);
}

/* ============================================================
   IMAGE MODAL
   ============================================================ */
.img-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.img-modal.open { display: flex; }

.img-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.img-modal-img {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 3px;
  display: block;
  animation: modal-fade-in 0.2s ease;
}

.img-modal-close {
  position: absolute;
  top: 16px; left: 16px;
  z-index: 2;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.img-modal-close:hover { background: rgba(0,0,0,0.85); }

.img-modal-prev,
.img-modal-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  z-index: 2;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 50%;
  width: 48px; height: 48px;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.img-modal-prev:hover,
.img-modal-next:hover { background: rgba(0,0,0,0.85); }
.img-modal-prev { right: 16px; }
.img-modal-next { left:  16px; }
.img-modal-prev[hidden],
.img-modal-next[hidden] { display: none; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 2px solid var(--text);
  padding: 24px 40px;
  background: var(--bg-card);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: center;
}
.footer-item {
  font-size: var(--fs-footer);
  color: var(--text-dim);
  letter-spacing: 0.04em;
  transition: color 0.2s;
  text-align: center;
}
.footer-item a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.footer-item a:hover { color: var(--accent); }
.footer-sep {
  color: var(--border-light);
  font-size: var(--fs-footer-sep);
}

/* ============================================================
   ERROR STATE
   ============================================================ */
.error-msg {
  color: var(--text-muted);
  font-size: var(--fs-error);
  padding: 48px 0;
  text-align: center;
}
.error-msg span {
  color: var(--accent);
  display: block;
  margin-bottom: 8px;
  font-size: var(--fs-error-icon);
}

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 960px) {
  .masonry-grid { column-count: 2; }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .mobile-nav    { display: block; }
  .side-nav      { display: none; }

  .layout { flex-direction: column; padding-top: var(--header-h); }

  .main-content { padding: 28px 16px 48px; }

  .lecture-grid,
  .texts-grid {
    grid-template-columns: 1fr;
  }
  .masonry-grid { column-count: 1; }
  .lecture-card.full-width { grid-column: auto; }
  .lecture-card.full-width .video-group {
    grid-template-columns: 1fr;
  }
  .lecture-card.full-width .video-group .video-col {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .lecture-card.full-width .video-group .video-col:first-child {
    border-top: none;
  }

  .site-footer {
    padding: 20px 16px;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .footer-sep { display: none; }
}
