/* ============================================================
   18 — גליונות אור הגנוז: קורא הגליון (inc/gilyonot.php + js/gilyonot.js)
   עמודי ה-PDF מוצגים כדפי נייר, סרגל פעולות (הורדה / מסך מלא / שיתוף),
   מעבר לגליון הקודם/הבא, ורשימת כל הגיליונות מהחדש לישן.
   דסקטופ: קורא + רשימה צדדית דביקה. מובייל: קורא, ואחריו שורת שערים נגללת.
   ============================================================ */

/* התבנית (hello-elementor) מגבילה את רוחב התוכן — הקורא מנהל את הרוחב בעצמו */
body.brz-gil-page main.site-main {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}
body.brz-gil-page main.site-main > .page-content { margin: 0; }
body.brz-gil-page .post-tags,
body.brz-gil-page #comments { display: none; }

.brz-gil {
  --navy: #1b2662;
  --navy-2: #26377a;
  --gold: #d9a12b;
  --gold-hi: #f7d466;
  --line: #ebe2cf;
  --ink: #1d2433;
  --muted: #6d7180;
  --pink: #e52f6a;
  direction: rtl;
  font-family: 'Heebo', 'Rubik', 'Segoe UI', Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 420px at 50% -160px, rgba(255, 238, 190, .75), rgba(255, 238, 190, 0) 70%),
    linear-gradient(180deg, #fbf7ee 0%, #f5f0e4 100%);
  padding: clamp(18px, 3vw, 40px) clamp(12px, 3vw, 32px) clamp(30px, 4.5vw, 64px);
}
.brz-gil *,
.brz-gil *::before,
.brz-gil *::after { box-sizing: border-box; }

.brz-gil__wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 23vw, 310px);
  gap: clamp(18px, 2.4vw, 34px);
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
}
.brz-gil__main { min-width: 0; }

/* ---- סרגל הגליון ---- */
.brz-gil__bar {
  position: sticky;
  top: calc(var(--brz-bar-h, 62px) + 10px);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 18px;
  padding: 10px 12px 10px 10px;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(27, 38, 98, .05), 0 16px 34px -24px rgba(27, 38, 98, .4);
}
.brz-gil__id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brz-gil__chip {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: 62px;
  padding: 0 10px;
  border-radius: 16px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, var(--navy-2), #121a46);
  box-shadow: inset 0 0 0 1.5px rgba(247, 212, 102, .6), 0 10px 20px -10px rgba(18, 26, 70, .75);
}
.brz-gil__chip span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.2;
  color: var(--gold-hi);
}
.brz-gil__chip b {
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.05;
}
.brz-gil__id-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brz-gil__name {
  overflow: hidden;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: clamp(17px, 1.5vw, 21px);
  font-weight: 800;
  line-height: 1.25;
  color: var(--navy);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.brz-gil__meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}
.brz-gil__meta svg { width: 15px; height: 15px; fill: var(--gold); }

.brz-gil__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.brz-gil .brz-gil__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}
.brz-gil .brz-gil__btn svg { width: 19px; height: 19px; fill: currentColor; flex: 0 0 auto; }
.brz-gil .brz-gil__btn:hover {
  transform: translateY(-1px);
  border-color: #dccba3;
  box-shadow: 0 10px 18px -12px rgba(27, 38, 98, .45);
  color: var(--navy);
}
.brz-gil .brz-gil__btn:focus-visible { outline: 3px solid rgba(217, 161, 43, .55); outline-offset: 2px; }
.brz-gil .brz-gil__btn--gold {
  border-color: transparent;
  background: linear-gradient(180deg, #ffe285 0%, #f2c13f 55%, #e2a72c 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 8px 16px -10px rgba(190, 128, 20, .9);
  color: #1b2662;
}
.brz-gil .brz-gil__btn--gold:hover { border-color: transparent; color: #1b2662; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 12px 20px -10px rgba(190, 128, 20, .95); }
.brz-gil .brz-gil__btn--wa svg { fill: #1faa53; }

/* ---- טעינה ---- */
.brz-gil__progress {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.brz-gil__progress[hidden] { display: none; }
.brz-gil__progress span {
  position: relative;
  flex: 1;
  height: 5px;
  overflow: hidden;
  border-radius: 5px;
  background: #e9dfc9;
}
.brz-gil__progress span::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--p, 4%);
  border-radius: inherit;
  background: linear-gradient(90deg, #e2a72c, #f7d466);
  transition: width .3s ease;
}
.brz-gil__progress em { font-style: normal; }

/* ---- דפי הגליון ---- */
.brz-gil__sheets {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
}
.brz-gil__sheet {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0;
  overflow: hidden;
  aspect-ratio: 1 / 1.414;
  border-radius: 6px;
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(27, 38, 98, .05),
    0 2px 4px rgba(27, 38, 98, .06),
    0 22px 44px -26px rgba(27, 38, 98, .55);
}
.brz-gil__sheet img,
.brz-gil__sheet canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.brz-gil__sheet img { object-fit: cover; }
.brz-gil__sheet canvas { animation: brz-gil-in .45s ease-out both; }
/* שלד עד שהעמוד מצויר */
.brz-gil__sheet:not(.is-ready):not(.is-cover)::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, 0) 70%) 0 0 / 220% 100% no-repeat,
    repeating-linear-gradient(180deg, #f4efe4 0 14px, #fff 14px 26px);
  animation: brz-gil-shimmer 1.6s linear infinite;
}
.brz-gil.is-loading .brz-gil__sheet.is-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, .5) 50%, rgba(255, 255, 255, 0) 65%) 0 0 / 220% 100% no-repeat;
  animation: brz-gil-shimmer 1.8s linear infinite;
}
.brz-gil__num {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 2;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(18, 26, 70, .72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  direction: ltr;
  opacity: .0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.brz-gil__sheet:hover .brz-gil__num,
.brz-gil__sheet:focus-within .brz-gil__num { opacity: 1; }

.brz-gil__fallback {
  max-width: 1000px;
  margin: 16px auto 0;
  padding: 14px 18px;
  border: 1px dashed #dccba3;
  border-radius: 14px;
  background: #fffaf0;
  font-size: 15.5px;
  text-align: center;
}
.brz-gil__fallback[hidden] { display: none; }
.brz-gil__fallback a { color: var(--navy); font-weight: 700; }

/* ---- הגליון הקודם / הבא ---- */
.brz-gil__nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 1000px;
  margin: clamp(18px, 2.4vw, 30px) auto 0;
}
.brz-gil__nav-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 48%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--navy);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.brz-gil__nav-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -18px rgba(27, 38, 98, .55);
  color: var(--navy);
}
.brz-gil__nav-link.is-next { margin-inline-start: auto; }
.brz-gil__nav-link svg { flex: 0 0 auto; width: 22px; height: 22px; fill: var(--gold); }
.brz-gil__nav-link span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.brz-gil__nav-link small {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
}

/* ---- כל הגיליונות ---- */
.brz-gil__aside {
  position: sticky;
  top: calc(var(--brz-bar-h, 62px) + 10px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--brz-bar-h, 62px) - 24px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(27, 38, 98, .05), 0 16px 34px -24px rgba(27, 38, 98, .4);
}
.brz-gil__aside-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid #f1eadb;
  background: linear-gradient(180deg, #fffaf0, #fff);
}
.brz-gil__aside-head h2 {
  margin: 0;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--navy);
}
.brz-gil__aside-head span { font-size: 13px; color: var(--muted); }
.brz-gil__list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: #e2d6bb transparent;
}
.brz-gil__item { margin: 0; }
.brz-gil__item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color .15s ease;
}
.brz-gil__item a:hover { background: #fbf6ea; color: var(--ink); }
.brz-gil__item.is-current a {
  background: linear-gradient(90deg, #fff7df, #fdf0cc);
  box-shadow: inset -3px 0 0 var(--gold);
}
.brz-gil__thumb {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  aspect-ratio: 1 / 1.414;
  overflow: hidden;
  border-radius: 5px;
  background: #f1ece0;
  box-shadow: 0 0 0 1px rgba(27, 38, 98, .08), 0 4px 10px -6px rgba(27, 38, 98, .5);
}
.brz-gil__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brz-gil__item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brz-gil__item-text b {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy);
}
.brz-gil__item-text small {
  overflow: hidden;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.brz-gil__item.is-current b { color: #a8741a; }

@keyframes brz-gil-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes brz-gil-shimmer { from { background-position: 120% 0, 0 0; } to { background-position: -120% 0, 0 0; } }

/* ---- טאבלט ומובייל ---- */
@media (max-width: 1023px) {
  .brz-gil__wrap { grid-template-columns: minmax(0, 1fr); }
  .brz-gil__aside {
    position: static;
    max-height: none;
  }
  .brz-gil__list {
    display: flex;
    gap: 10px;
    padding: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
  }
  .brz-gil__item { flex: 0 0 auto; scroll-snap-align: center; }
  .brz-gil__item a {
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    width: 104px;
    padding: 6px;
    text-align: center;
  }
  .brz-gil__item.is-current a { box-shadow: inset 0 -3px 0 var(--gold); }
  .brz-gil__thumb { width: 100%; border-radius: 6px; }
  .brz-gil__item-text small { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
}

@media (max-width: 640px) {
  .brz-gil { padding: 14px 10px 30px; }
  .brz-gil__bar {
    position: static;
    padding: 10px;
    border-radius: 18px;
  }
  .brz-gil__id { width: 100%; }
  .brz-gil__chip { min-width: 54px; height: 54px; border-radius: 14px; }
  .brz-gil__chip b { font-size: 22px; }
  .brz-gil__actions {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr;
    width: 100%;
  }
  .brz-gil .brz-gil__btn { height: 46px; padding: 0 10px; font-size: 14.5px; }
  .brz-gil__sheets { gap: 12px; }
  .brz-gil__sheet { border-radius: 4px; }
  .brz-gil__num { opacity: .9; }
  .brz-gil__nav-link { padding: 10px 12px; }
  .brz-gil__nav-link span { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .brz-gil__sheet canvas,
  .brz-gil__sheet::before,
  .brz-gil__sheet::after { animation: none !important; }
}
