/* ===== לוח שנה - מקדש ישראל והזמנים — דפדוף בספר ===== */

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/rubik-hebrew-400-normal.woff2") format("woff2");
  unicode-range: U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/rubik-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/rubik-hebrew-500-normal.woff2") format("woff2");
  unicode-range: U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/rubik-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/rubik-hebrew-700-normal.woff2") format("woff2");
  unicode-range: U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/rubik-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215;
}


/* פלטה עזה על בסיס הכריכה: ירוק־קטיפה עמוק, זהב בוהק, ואזמרגד רענן.
   ברירת המחדל היא המצב הכהה — הדפים הלבנים בולטים עליו. */

:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08201a;
  --bg-2: #0d3128;
  --surface: #16241e;
  --surface-2: #1f332a;
  --ink: #f4f0e2;
  --ink-2: #b6c6b8;
  --ink-3: #86988a;
  --line: #2b4238;
  --accent: #f5b62b;
  --accent-ink: #12190e;
  --gold: #ffd35c;
  --gold-soft: #f5b62b;
  --emerald: #14d18a;
  --shadow-book: 0 28px 74px -16px rgba(0, 0, 0, .85), 0 4px 16px rgba(0, 0, 0, .6);
  --radius: 12px;
  --bar: rgba(14, 26, 21, .93);
  --font: "Rubik", "Segoe UI", "Arial Hebrew", system-ui, sans-serif;
  --serif: "Rubik", "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1e5;
  --bg-2: #e6e0cd;
  --surface: #fffdf6;
  --surface-2: #f3eee0;
  --ink: #17251d;
  --ink-2: #4d5c50;
  --ink-3: #7f8c81;
  --line: #d5cfba;
  --accent: #0d6b45;
  --accent-ink: #ffffff;
  --gold: #a97a10;
  --gold-soft: #d9a323;
  --emerald: #0d9a63;
  --shadow-book: 0 24px 60px -18px rgba(20, 34, 24, .42), 0 4px 14px rgba(20, 34, 24, .16);
  --bar: rgba(255, 253, 246, .92);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1150px 700px at 50% -16%,
      color-mix(in srgb, var(--emerald) 34%, transparent), transparent 68%),
    radial-gradient(820px 660px at 8% 106%,
      color-mix(in srgb, var(--accent) 30%, transparent), transparent 66%),
    radial-gradient(820px 660px at 92% 106%,
      color-mix(in srgb, var(--emerald) 26%, transparent), transparent 66%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

button, select, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

/* ---------- סרגל עליון ---------- */

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--gold-soft) 30%, transparent);
  z-index: 30;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-end: 6px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.brand .logo {
  width: 44px;
  height: 44px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(28, 36, 22, .18));
}

:root:not([data-theme="light"]) .brand .logo { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .7)); }

.brand-txt {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1.2;
}

/* שם בית המדרש — המילים שבלוגו, בגודל שאפשר לקרוא */
.brand .org {
  font-size: 11px;
  font-weight: 500;
  color: var(--gold-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .95;
}

.brand .org i {
  font-style: normal;
  color: var(--ink-3);
  margin-inline-start: 7px;
}

/* שורת הנשיאות — מתחת לשם הישיבה */
.brand .nasi {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.brand b {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18.5px;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gold);
}

:root[data-theme="light"] .brand b { color: var(--accent); }





.spacer { flex: 1 1 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  color: var(--ink-2);
  font-size: 14px;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn.primary {
  background: linear-gradient(150deg, var(--gold), var(--accent));
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 2px 10px -2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.btn.primary:hover { filter: brightness(1.1) saturate(1.1); }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-label { display: inline; }

/* אייקון מצב יום/לילה מתחלף לפי הערכה הפעילה */
.ico-sun { display: none; }
:root:not([data-theme="light"]) .ico-moon { display: none; }
:root:not([data-theme="light"]) .ico-sun { display: block; }

/* ---------- במה ---------- */

.stage-wrap {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  min-height: 0;
}

.stage {
  flex: 1 1 auto;
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 18px;
  scrollbar-width: thin;
  touch-action: pan-x pan-y;
}

.stage.zoomed { cursor: grab; }
.stage.zoomed.dragging { cursor: grabbing; }

.book {
  position: relative;
  transform-style: preserve-3d;
  perspective: 2400px;
  flex: none;
  transition: transform .5s cubic-bezier(.4, 0, .2, 1);
}

.slot {
  position: absolute;
  top: 0;
  height: 100%;
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-book);
}

.slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.slot.right {
  right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
}

.slot.left {
  left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.book.single .slot {
  border-radius: var(--radius);
}

/* גב הכריכה — צל בשדרה */
.spine {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(90deg,
      rgba(0, 0, 0, 0) 0%,
      rgba(38, 44, 30, .16) 42%,
      rgba(38, 44, 30, .30) 50%,
      rgba(38, 44, 30, .16) 58%,
      rgba(0, 0, 0, 0) 100%);
}

.book.single .spine { display: none; }

/* ---------- חבילות הדפים משני הצדדים ---------- */

.stack {
  position: absolute;
  top: 5px;
  bottom: 5px;
  z-index: 0;
  pointer-events: none;
  transition: opacity .3s;
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, .10), rgba(0, 0, 0, 0) 12%,
                            rgba(0, 0, 0, 0) 88%, rgba(0, 0, 0, .12)),
    repeating-linear-gradient(90deg,
      #c8c1a8 0 .5px, #f5f1e4 .5px 1.6px, #e7e0ca 1.6px 2.4px);
}

.stack.right {
  right: 0;
  transform: translateX(100%);
  border-radius: 0 5px 5px 0;
  box-shadow: 5px 8px 20px -8px rgba(28, 36, 22, .55);
}

.stack.left {
  left: 0;
  transform: translateX(-100%);
  border-radius: 5px 0 0 5px;
  box-shadow: -5px 8px 20px -8px rgba(28, 36, 22, .55);
}

.book.single .stack { top: 8px; bottom: 8px; }

/* ---------- הדף המתקפל ---------- */

.leaf {
  position: absolute;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  z-index: 10;
  pointer-events: none;
}

.leaf.hidden { display: none; }

/* פרוסה אנכית אחת של הדף */
.seg {
  position: absolute;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}

.leaf.fwd .seg { right: 0; transform-origin: 100% 50%; }
.leaf.bwd .seg { left: 0; transform-origin: 0% 50%; }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-color: #fff;
  background-repeat: no-repeat;
  overflow: hidden;
}

.face.back { transform: rotateY(180deg); }

.face .shade {
  position: absolute;
  inset: 0;
  background: #241a0e;
  opacity: 0;
  pointer-events: none;
}

/* צל רך של הדף המתרומם על הכפולה שמתחתיו */
.book.flipping .slot { box-shadow: var(--shadow-book), inset 0 0 40px -18px rgba(26, 34, 20, .5); }

/* ---------- סרגל תחתון ---------- */

.footbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bar);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--gold-soft) 30%, transparent);
  z-index: 20;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: background .15s, color .15s, transform .1s;
}

.nav-btn:hover:not(:disabled) {
  background: linear-gradient(150deg, var(--gold), var(--accent));
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: 0 3px 12px -3px color-mix(in srgb, var(--accent) 60%, transparent);
}
.nav-btn:active:not(:disabled) { transform: scale(.94); }
.nav-btn:disabled { opacity: .35; cursor: default; }
.nav-btn svg { width: 20px; height: 20px; }

.dayline {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  line-height: 1.25;
}

.dayline .heb {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dayline .sub {
  font-size: 12px;
  color: var(--ink-3);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dayline .today-chip {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--emerald);
  color: #04140d;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 2px;
}

.slider-wrap {
  flex: 0 0 auto;
  width: min(30vw, 260px);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagebox {
  flex: 0 0 auto;
  width: min(30vw, 260px);
  display: flex;
  align-items: center;
  justify-content: center;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  direction: rtl;
}

.pagenum {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-3);
  min-width: 62px;
  text-align: center;
}

/* ---------- חלוניות ---------- */

.sheet {
  position: absolute;
  top: 100%;
  left: 10px;
  margin-top: 6px;
  width: min(420px, calc(100vw - 20px));
  max-height: min(70dvh, 560px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px -12px rgba(26, 34, 20, .38);
  padding: 14px;
  z-index: 40;
}

.sheet[hidden] { display: none; }
.sheet h3 { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.sheet h3 + h3 { margin-top: 16px; }

.field {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.field input[type="date"],
.field input[type="search"],
.field select {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.months {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}

.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: linear-gradient(150deg, var(--gold), var(--accent));
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 5px;
}

.dcell {
  height: 46px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  font-size: 14px;
  font-family: var(--serif);
  font-weight: 700;
}

.dcell small {
  font-family: var(--font);
  font-weight: 400;
  font-size: 10px;
  color: var(--ink-3);
}

.dcell:hover { border-color: var(--gold); }
.dcell.cur {
  background: linear-gradient(150deg, var(--gold), var(--accent));
  color: var(--accent-ink);
  border-color: transparent;
}
.dcell.cur small { color: inherit; opacity: .8; }
.dcell.today { box-shadow: inset 0 0 0 2px var(--emerald); }

/* חיפוש */

.result {
  display: block;
  width: 100%;
  text-align: start;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.result:hover { background: var(--surface-2); border-color: var(--line); }
.result b { display: block; font-size: 12.5px; color: var(--accent); margin-bottom: 2px; font-weight: 600; }
:root[data-theme="dark"] .result b { color: var(--gold); }
.result span { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.result mark { background: color-mix(in srgb, var(--emerald) 40%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

.muted { color: var(--ink-3); font-size: 13px; padding: 6px 2px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 6px 0;
  cursor: pointer;
}

.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- מסך טעינה ---------- */

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--bg);
  z-index: 50;
  text-align: center;
  padding: 20px;
}

.loading[hidden] { display: none; }

.spin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.load-logo {
  width: 140px;
  height: 140px;
  object-fit: contain;
  opacity: 0;
  animation: logoIn .6s ease-out forwards;
}

@keyframes logoIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}

.loading p { margin: 0; color: var(--ink-2); font-size: 14px; }
.loading .err { color: var(--accent); max-width: 34em; line-height: 1.6; }

.toast {
  position: fixed;
  bottom: 74px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 13.5px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.toast.show { opacity: .96; }

/* ---------- אזורי הקשה לדפדוף ---------- */

.tapzone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 5;
  border: none;
  background: transparent;
  padding: 0;
}

.tapzone.next { left: 0; cursor: w-resize; }
.tapzone.prev { right: 0; cursor: e-resize; }
.tapzone:disabled { cursor: default; }
.stage-wrap.zoomed .tapzone { display: none; }

/* ---------- חץ הסמן ---------- */

.cursor-arrow {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;      /* ממורכז על נקודת הסמן */
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .3));
  will-change: transform, opacity;
}

.cursor-arrow svg { width: 100%; height: 100%; display: block; }
.cursor-arrow.flip svg { transform: scaleX(-1); }   /* חץ שמאלה = קדימה */

.cursor-arrow.on { opacity: .95; }

.stage-wrap.hide-cursor .tapzone { cursor: none; }

/* ---------- רמז ראשוני ---------- */

.hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .45);
  pointer-events: none;
  opacity: 0;
  transition: opacity .45s;
}

.hint svg { width: 19px; height: 19px; flex: none; }
.hint.show { opacity: .95; }
.hint[hidden] { display: none; }

@media (max-width: 660px) {
  .hint { font-size: 12.5px; padding: 8px 13px; top: 10px; }
}

/* במסכי מגע אין ריחוף — החץ לא רלוונטי */
@media (hover: none) {
  .cursor-arrow { display: none; }
}

/* ---------- רספונסיבי ---------- */

@media (max-width: 900px) {
  .btn-label { display: none; }
  .brand .org { display: none; }
  .brand .nasi { display: none; }
  .slider-wrap { display: none; }
  .pagebox { width: auto; }
}

@media (max-width: 660px) {
  .bar { padding: 6px 6px; gap: 1px; }
  .brand-txt { display: none; }
  .brand { margin-inline-end: 2px; }
  .brand .logo { width: 34px; height: 34px; }
  .btn { height: 34px; min-width: 34px; padding: 0 5px; }
  .btn svg { width: 17px; height: 17px; }
  .stage { padding: 10px; }
  .footbar { padding: 6px 8px; gap: 6px; }
  .dayline .heb { font-size: 15px; }
  .pagenum { font-size: 11px; min-width: 0; }
  .nav-btn { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .leaf { transition: none !important; }
}
