/* ═══ themes/megila/megila-v1.css — ערכת "מגילה · עצי חיים" (megila) ═══
   THEMES-WAVE-1 שלב 3: יבוא במת המסך מ-feature/display-themes-r1
   (armon-yehuda/public/theme-stages.css שורות 1406-1480, קומיט c19afeb),
   מנותקת מתשתית הבמות של ארמון ומחוברת לדפוס הערכות של אהל דב.
   THEMES-WAVE-1 שלב 5: סקאלת הקריאות של המסך בבית הכנסת (TCL 32", ‏1366×768,
   נצפה מרחוק) — כל רכיב טקסט ‎≥30px‎, בדפוס ה-vh×‎--dm-type-scale של הבית;
   פרקי המגילה נפרשים לרוחב הקלף המלא ("הקלף נגלל לפרק"); וחמשת מסכי-העל
   (הלכות · נוראים · הושבה · תרומה · זיכרון) לבושים בשפת הקלף והבורדו.

   מסמך הבמה: docs/design/theme-stages/07-megila.md.
   השפה: מגילת קלף פתוחה בין שני עצי-חיים — רקע יין-בורדו, יריעת קלף אחת
   רציפה עם וינייטות-גלילה בצדדים, ומוטות עץ עם מכסי-קצה. לא פאנלים — מגילה.

   ניתוקי התלות מארמון (מתועדים גם ב-report-w3-megila-import.md):
   1. ניתוב: html[data-stage="megila"] → #display-mode.megila (הבורר של אהל דב).
   2. namespace: ‏.stg-megila-* → ‏.mg-* (בדפוס kir-/vc-/pr- הקיים בבית).
   3. פלטה: גווני ארמון ‎#8a6d3b/#5f4a24‎ → הבורדו של אהל דב דרך שני משתנים
      (הכרעת יאיר 14.09.2026; זהה להצהרה שכבר קיימת בענף themes-r1 לאהל דב).
   4. גופן: 'Frank Ruhl Libre' מ-Google Fonts → 'KeterFrank' ‏self-hosted
      (אותו גופן בדיוק — fonts/keter-frank-var-hebrew.woff2, רישיון OFL).
   5. חלק רמת-האתר של הבמה (שורות 1350-1405 במקור) לא יובא — מחוץ להיקף הגל. */

#display-mode.megila{
  --mg-accent:#8B1A1A;        /* בורדו אהל דב — היה #8a6d3b (חום ארמון) */
  --mg-accent-deep:#5e0f0f;   /* היה #5f4a24 */
  --mg-parch-ink:#312516;     /* דיו על הקלף — של הבמה, נשאר */
  --mg-parch-dim:#6d5a3e;     /* טקסט משני על הקלף — נשאר */
  --mg-line:#b7a077;          /* קווי עיטור והפרדה — נשאר */
  --mg-frame:#c7b48c;         /* מסגרות שבבים — נשאר */
  background:radial-gradient(120% 105% at 50% 45%, #3d1522 0%, #240a13 62%, #16060c 100%);
}

/* שורש הערכה — דפוס ערכות הקיר: absolute, z:5, מוצג רק במסך 2, מוסתר בספירה
   (mg-cd, מסונכרן מ-dm2-takeover ע"י ההדבק ב-index.html) ובחשיפת מסכי-התוכן
   (wall-reveal — מנגנון WALL-SCREENS המשותף). */
#mg-root{position:absolute;inset:0;z-index:5;display:none;font-family:'KeterFrank','Frank Ruhl Libre',Georgia,serif;}
#display-mode.megila.dm-mode-2 #mg-root{display:block;}
#display-mode.megila.mg-cd #mg-root{display:none;}
#display-mode.megila.wall-reveal #mg-root{display:none;}
#display-mode.megila.dm-mode-2 .dm2-root{visibility:hidden;}
#display-mode.megila.dm-mode-2 .dm2-root.dm2-takeover{visibility:visible;}
#display-mode.megila.dm-mode-2.wall-reveal .dm2-root{visibility:visible;}

/* חותמת הדיוק — מוסתרת בכל הערכות (הכרעת יאיר בליטוש NIGHT-THEMES) */
#display-mode.megila #accuracy-seal{display:none;}

/* לוח הרקע של מסכי-התוכן הנחשפים (wall-reveal) — קלף ממוסגר ברוח הבמה */
#display-mode.megila #wall-reveal-panel{
  background:
    repeating-linear-gradient(0deg, rgba(120,95,55,.045) 0 2px, transparent 2px 6px),
    radial-gradient(110% 100% at 50% 0%, rgba(36,10,19,.92) 0%, rgba(22,6,12,.95) 100%);
  border:2px solid var(--mg-line);
  box-shadow:inset 24px 0 28px -18px rgba(70,45,15,.5), inset -24px 0 28px -18px rgba(70,45,15,.5), 0 14px 36px rgba(0,0,0,.55);
}

/* ── שני המוטות (עצי החיים) — גרדיאנט עץ + מכסי-קצה, מעל הקלף ── */
#display-mode.megila .mg-rod{
  position:absolute;top:-2.5%;bottom:-2.5%;width:5%;border-radius:12px;z-index:2;
  background:linear-gradient(90deg, #2c1a0c 0%, #6e421e 26%, #c98a4a 50%, #6e421e 74%, #241408 100%);
  box-shadow:0 10px 26px #00000090;
}
#display-mode.megila .mg-rod::before,
#display-mode.megila .mg-rod::after{
  content:'';position:absolute;left:50%;transform:translateX(-50%);width:170%;height:5.5%;border-radius:50%;
  background:radial-gradient(circle at 42% 36%, #8a5a2c, #4a2c12 70%);
}
#display-mode.megila .mg-rod::before{top:-2.5%;}
#display-mode.megila .mg-rod::after{bottom:-2.5%;}
#display-mode.megila .mg-rod-r{inset-inline-end:2.2%;}
#display-mode.megila .mg-rod-l{inset-inline-start:2.2%;}

/* ── יריעת הקלף — יריעה אחת רציפה, וינייטות-גלילה בצדדים ── */
#display-mode.megila .mg-sheet{
  position:absolute;top:5.5%;bottom:5.5%;inset-inline-end:8%;inset-inline-start:8%;z-index:1;
  background:
    repeating-linear-gradient(0deg, rgba(120,95,55,.045) 0 2px, transparent 2px 6px),
    radial-gradient(110% 100% at 50% 0%, #f8f1de 0%, #efe4c8 60%, #e4d3ac 100%);
  color:var(--mg-parch-ink);border-radius:8px;
  box-shadow:inset 30px 0 30px -18px rgba(70,45,15,.55), inset -30px 0 30px -18px rgba(70,45,15,.55), 0 16px 40px rgba(0,0,0,.5);
  padding:2vh 4% 1.4vh;display:flex;flex-direction:column;overflow:hidden;
}

/* ── שלב 5: סקאלת המסך הרחוק — כל רכיב ‎≥30px‎ ב-1366×768 ──
   הבסיס: ‎2.75vh × 1.45 = 30.6px‎. הבמה המקורית (12.5-14px) תוכננה למסך קרוב. */
#display-mode.megila .mg-clock{
  position:absolute;top:2vh;inset-inline-start:3.4%;color:var(--mg-accent-deep);background:#ffffff70;
  border:1px solid var(--mg-frame);border-radius:999px;padding:.3vh 1.2vw;
  font-size:calc(2.75vh * var(--dm-type-scale));font-variant-numeric:tabular-nums;
}
#display-mode.megila .mg-head{text-align:center;flex:0 0 auto;}
#display-mode.megila .mg-title{font-weight:900;font-size:calc(4.4vh * var(--dm-type-scale));line-height:1.1;color:var(--mg-accent-deep);}
#display-mode.megila .mg-ornament{display:flex;align-items:center;justify-content:center;gap:1vw;color:var(--mg-parch-dim);
  font-size:calc(2.75vh * var(--dm-type-scale));margin-top:.4vh;}
#display-mode.megila .mg-ornament::before,
#display-mode.megila .mg-ornament::after{content:'';width:14%;height:1.5px;background:linear-gradient(90deg, transparent, var(--mg-line), transparent);flex:0 0 auto;}
#display-mode.megila .mg-body{flex:1 1 auto;min-height:0;display:grid;grid-template-columns:1fr 1.15fr 1fr;gap:0 2vw;align-items:stretch;padding:.8vh 0 0;}
#display-mode.megila .mg-col{display:flex;flex-direction:column;min-height:0;justify-content:center;}
#display-mode.megila .mg-col-title{text-align:center;color:var(--mg-accent-deep);border-bottom:1.5px solid var(--mg-line);
  padding-bottom:.4vh;margin-bottom:.6vh;font-size:calc(3vh * var(--dm-type-scale));font-weight:700;flex:0 0 auto;}
#display-mode.megila .mg-list{display:flex;flex-direction:column;justify-content:space-evenly;min-height:0;overflow:hidden;}
#display-mode.megila .mg-row{display:flex;justify-content:space-between;align-items:baseline;gap:1vw;padding:.35vh .2vw;
  font-size:calc(2.75vh * var(--dm-type-scale));line-height:1.25;}
#display-mode.megila .mg-val{font-weight:700;color:var(--mg-accent-deep);font-variant-numeric:tabular-nums;white-space:nowrap;}
#display-mode.megila .mg-row-next .mg-val{color:var(--mg-accent);}
#display-mode.megila .mg-mid{text-align:center;align-self:stretch;display:flex;flex-direction:column;justify-content:center;overflow:hidden;min-height:0;}
#display-mode.megila .mg-mid-label{letter-spacing:.08em;color:var(--mg-parch-dim);font-size:calc(3vh * var(--dm-type-scale));}
#display-mode.megila .mg-mid-time{font-weight:900;font-size:calc(9vh * var(--dm-type-scale));color:var(--mg-accent-deep);line-height:1.05;font-variant-numeric:tabular-nums;}
#display-mode.megila .mg-mid-armed .mg-mid-time{color:var(--mg-accent);}
#display-mode.megila .mg-mid-sub{color:var(--mg-parch-dim);font-size:calc(2.75vh * var(--dm-type-scale));}
#display-mode.megila .mg-announce{
  flex:0 0 auto;text-align:center;color:var(--mg-parch-dim);font-size:calc(2.75vh * var(--dm-type-scale));line-height:1.3;
  padding-top:.7vh;border-top:1.5px dotted var(--mg-line);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  opacity:0;transition:opacity .6s;
}
#display-mode.megila .mg-announce-in{opacity:1;}

/* ── שלב 5: פרקי המגילה — "הקלף נגלל לפרק": הפרק תופס את רוחב הקלף המלא ──
   כשפרק-תוכן מוצג, שתי העמודות הקבועות מתקפלות והפרק נפרש על היריעה כולה —
   כך תוכן ארוך (ענייני היום, לוח שבת/חג) נקרא בגדול, בשתי עמודות-קלף עם
   קו-מפריד דק, ככתוב על גבי מגילה. */
#display-mode.megila .mg-body.mg-body-chapter{grid-template-columns:1fr;}
#display-mode.megila .mg-body.mg-body-chapter .mg-col{display:none;}
#display-mode.megila .mg-slide{display:flex;flex-direction:column;min-height:0;overflow:hidden;align-items:center;}
#display-mode.megila .mg-next-line{text-align:center;color:var(--mg-parch-dim);font-size:calc(2.75vh * var(--dm-type-scale));margin-bottom:.2vh;flex:0 0 auto;}
#display-mode.megila .mg-next-line b{color:var(--mg-accent-deep);font-variant-numeric:tabular-nums;font-weight:700;}
/* כותרת הפרק — בדפוס שורת-העיטור: קווי גרדיאנט משני צידי השם, פתיחת פרק במגילה */
#display-mode.megila .mg-slide-head{flex:0 0 auto;display:flex;align-items:center;justify-content:center;gap:1.2vw;width:92%;
  color:var(--mg-accent-deep);font-size:calc(3.4vh * var(--dm-type-scale));font-weight:800;margin-bottom:.7vh;}
#display-mode.megila .mg-slide-head::before,
#display-mode.megila .mg-slide-head::after{content:'';flex:1 1 auto;height:1.5px;background:linear-gradient(90deg, transparent, var(--mg-line), transparent);}
/* WAVE1-FIX (סעיף 9): הגוף הוא חלון-הגזירה של הגלילה — תופס את יתרת הפרק,
   והתוכן עצמו יושב בעטיפה פנימית (.mg-si) שהאנימציה מזיזה. העמודות (mg-cols2)
   עברו לעטיפה — אותה התנהגות בדיוק, רק שכעת אפשר גם לגלול כשיש צורך. */
#display-mode.megila .mg-slide-body{flex:1 1 auto;overflow:hidden;min-height:0;width:92%;align-self:center;}
#display-mode.megila .mg-si{will-change:transform;backface-visibility:hidden;transform:translate3d(0,0,0);}
#display-mode.megila .mg-slide-body.mg-cols2 .mg-si{column-count:2;column-gap:3vw;column-rule:1px solid var(--mg-line);}
#display-mode.megila .mg-slide-body .mg-row{break-inside:avoid;}
#display-mode.megila .mg-sec{text-align:center;color:var(--mg-accent);font-weight:800;font-size:calc(2.9vh * var(--dm-type-scale));
  margin:.7vh 0 .2vh;break-inside:avoid;break-after:avoid;}
#display-mode.megila .mg-card{border:1px solid var(--mg-frame);border-radius:.8vh;padding:.5vh 1vw;margin:.5vh 0;background:#ffffff50;break-inside:avoid;}
#display-mode.megila .mg-card.mg-hi{border-color:var(--mg-accent);}
#display-mode.megila .mg-card-t{font-weight:700;color:var(--mg-parch-ink);font-size:calc(2.75vh * var(--dm-type-scale));line-height:1.3;}
#display-mode.megila .mg-card-m{color:var(--mg-parch-dim);font-size:calc(2.75vh * var(--dm-type-scale));line-height:1.3;}
#display-mode.megila .mg-note{color:var(--mg-parch-ink);font-size:calc(2.75vh * var(--dm-type-scale));padding:.15vh .2vw;line-height:1.35;break-inside:avoid;}

/* תוספת ההיקף (שלב 4): שורת "התפילה הבאה" ברצועת הספירה — 27.84px → ‎≥30px‎.
   מסויג לערכת הגל בלבד; ‎.dm-strip בלבד — לא נוגע בצד-השעון של מסך ההלכות. */
#display-mode.megila .dm-strip .hl-next{font-size:calc(2.8vh * var(--dm-type-scale));}

/* ═══ שלב 5: חמשת מסכי-העל בשפת המגילה ═══ */

/* מסך ההלכות — עמוד קלף: הטקסט התורני נקרא כדף מן המגילה עצמה */
#display-mode.megila #halachot-root{
  background:
    repeating-linear-gradient(0deg, rgba(120,95,55,.05) 0 2px, transparent 2px 6px),
    radial-gradient(110% 100% at 50% 0%, #f8f1de 0%, #efe4c8 60%, #e4d3ac 100%);
  color:var(--mg-parch-ink,#312516);
}
#display-mode.megila #halachot-root .hl-clock,
#display-mode.megila #halachot-root .hl-day-title,
#display-mode.megila #halachot-root .hl-z-time,
#display-mode.megila #halachot-root .hl-nx-t{color:#8B1A1A;}
#display-mode.megila #halachot-root .hl-head,
#display-mode.megila #halachot-root .hl-sec-t{color:#5e0f0f;}
#display-mode.megila #halachot-root .hl-kicker{background:#8B1A1A;color:#f8f1de;}
#display-mode.megila #halachot-root .hl-sec-x{color:#312516;}
#display-mode.megila #halachot-root .hl-next{color:#312516;}
#display-mode.megila #halachot-root .hl-z-name{color:#5a4630;}
#display-mode.megila #halachot-root .hl-note{color:#6d5a3e;border-right-color:rgba(139,26,26,.3);}
#display-mode.megila #halachot-root .hl-side{border-inline-start-color:rgba(139,26,26,.3);background:rgba(120,95,55,.10);}

/* הודעת הימים הנוראים — "כרוז על הקלף": אותו מבנה, לוח צבעי קלף-ודיו */
#display-mode.megila #noraim-root{
  --nr-ink:#312516; --nr-gold:#8B1A1A; --nr-dim:#6d5a3e; --nr-bg1:#f8f1de; --nr-bg2:#e4d3ac;
}

/* מפת ההושבה — נפרשת על קלף; המסגרות בדיו-בורדו (smFit לא נגעה — הגדלים שלה) */
#display-mode.megila #seating-root{
  --sm-ink:#312516; --sm-gold:#8B1A1A; --sm-bg1:#f8f1de; --sm-bg2:#e4d3ac;
  --sm-line:rgba(139,26,26,.30); --sm-tint:rgba(139,26,26,.10);
  --sm-edge:rgba(94,15,15,.65); --sm-edge-dim:rgba(94,15,15,.35);
}

/* מודעת הברכה (RAV-KETER-COLORS, 16.09.2026) — כרוז על הקלף, דיו ובורדו;
   --rk-gold2 שואל את גוון העץ החם של המוטות (mg-rod, שורה 59) כמבטא שני. */
#display-mode.megila #rk-root{
  --rk-bg1:#f8f1de; --rk-bg2:#e4d3ac; --rk-gold:#8B1A1A; --rk-gold2:#c98a4a;
  --rk-ink:#312516; --rk-ink2:#6d5a3e;
}

/* מסך התרומה — הקדשה על הקלף, דיו ובורדו */
#display-mode.megila #dedication-root{
  background:
    repeating-linear-gradient(0deg, rgba(120,95,55,.05) 0 2px, transparent 2px 6px),
    radial-gradient(110% 100% at 50% 0%, #f8f1de 0%, #efe4c8 60%, #e4d3ac 100%);
  color:#312516;
}
#display-mode.megila #dedication-root .ded-l1{color:#312516;}
#display-mode.megila #dedication-root .ded-l2{color:#8B1A1A;}
#display-mode.megila #dedication-root .ded-sep{color:rgba(139,26,26,.55);}

/* עץ הזיכרון — נשאר חשוך (סצנת נר-התמיד והזהב דורשת רקע כהה); הגוון מוסב ליין */
#display-mode.megila #memorial-root{--mtr-bg1:#33121d;--mtr-bg2:#190810;}

/* שלב 5 — הרמות סף-30 נקודתיות במסכי-העל (מסויג לערכה; הפונקציות עצמן לא נגעו):
   hl-next/hl-note במסך ההלכות, פסוק ותחתית עץ הזיכרון, ותוויות סימוני המפה
   (הנגזרות ×.85/.95 מ---sm-name — המשתנה עצמו ו-smFit לא נגעו). */
#display-mode.megila #halachot-root .hl-next{font-size:calc(2.8vh * var(--dm-type-scale));}
#display-mode.megila #halachot-root .hl-note{font-size:calc(2.1vh * var(--dm-type-scale,1) * var(--hl-scale,1));}
#display-mode.megila #memorial-root .mtr-verse,
#display-mode.megila #memorial-root .mtr-foot{font-size:calc(2.8vh * var(--dm-type-scale));}
#display-mode.megila #seating-root .sm-mark .sm-mtxt{font-size:var(--sm-name);}
#display-mode.megila #seating-root .sm-bar .sm-mtxt{font-size:var(--sm-name);}

/* ── פר-פוזיציה (מהבמה): עומד 9:16 — המוטות מסתובבים לאופקיים; שוכב 4:3 ── */
@media (orientation:portrait){
  #display-mode.megila .mg-rod{top:auto;bottom:auto;inset-inline:2.5%;width:auto;height:5%;}
  #display-mode.megila .mg-rod-r{top:-2.5%;}
  #display-mode.megila .mg-rod-l{bottom:-2.5%;top:auto;}
  #display-mode.megila .mg-rod::before,
  #display-mode.megila .mg-rod::after{top:50%;left:auto;transform:translateY(-50%);width:5.5%;height:170%;}
  #display-mode.megila .mg-rod::before{inset-inline-start:-2.5%;}
  #display-mode.megila .mg-rod::after{inset-inline-start:auto;inset-inline-end:-2.5%;}
  #display-mode.megila .mg-sheet{
    top:8%;bottom:8%;inset-inline-end:5.5%;inset-inline-start:5.5%;
    box-shadow:inset 0 30px 30px -18px rgba(70,45,15,.55), inset 0 -30px 30px -18px rgba(70,45,15,.55), 0 16px 40px rgba(0,0,0,.5);
  }
  #display-mode.megila .mg-body{grid-template-columns:1fr;grid-auto-rows:auto;gap:.8vh;padding:0;}
  #display-mode.megila .mg-mid{padding:1.5vh 0;}
  #display-mode.megila .mg-mid-time{font-size:clamp(36px,11vw,58px);}
  #display-mode.megila .mg-slide-body.mg-cols2 .mg-si{column-count:1;}
}
@media (orientation:landscape) and (max-aspect-ratio:3/2){
  #display-mode.megila .mg-sheet{inset-inline-end:9%;inset-inline-start:9%;}
  #display-mode.megila .mg-body{grid-template-columns:1fr 1fr 1fr;}
}
