/* Synagogue wall screen. One fixed layout, sized in vh so it scales to any 16:9 screen.
   Every panel's font size is fitted by display.js so nothing ever overflows or scrolls. */
:root {
  --bg1: #051727;
  --bg2: #0a2d4d;
  --panel: rgba(255, 255, 255, .055);
  --line: rgba(255, 255, 255, .12);
  --text: #f6f8fb;
  --muted: #a9bdd1;
  --gold: #f2cc6b;
  --gold-2: #c99a2e;
}
* { font-variant-numeric: lining-nums tabular-nums; }
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; overflow: hidden; cursor: none; }
html { background: #000; }
body { transform-origin: 50% 50%; }
body {
  font-family: 'Bona Nova', 'David Libre', 'Times New Roman', serif;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text);
  background:
    radial-gradient(ellipse at 90% 0%, rgba(242, 204, 107, .10), transparent 45%),
    radial-gradient(ellipse at 0% 100%, rgba(95, 176, 255, .10), transparent 50%),
    linear-gradient(160deg, var(--bg2), var(--bg1));
}

.screen {
  width: 100vw; height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr) minmax(0, 1.25fr);
  grid-template-rows: 15vh minmax(0, 1fr);
  grid-template-areas: "top top top" "prayers mid media";
  gap: 1.8vh 1.4vw;
  padding: 1.6vh 1.6vw 2vh;
}
.screen.has-msg { grid-template-rows: 15vh minmax(0, 1fr) 9vh; grid-template-areas: "top top top" "prayers mid media" "msg msg msg"; }
/* No event pictures: two columns, prayers | shiurim + zmanim. */
.screen.no-media { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-areas: "top top" "prayers mid"; }
.screen.no-media.has-msg { grid-template-areas: "top top" "prayers mid" "msg msg"; }
.screen.no-media .col-media { display: none; }

/* ---------- header ---------- */
.top {
  grid-area: top; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1fr); align-items: center;
  border-bottom: .3vh solid rgba(242, 204, 107, .45);
}
.brand { display: flex; align-items: center; gap: 1.2vw; min-width: 0; }
.logo { height: 10.5vh; width: auto; filter: invert(1); flex: none; }
.name { font-size: 7vh; font-weight: 700; line-height: 1; white-space: nowrap; }
.day { text-align: center; }
.parasha { font-size: 6.4vh; font-weight: 700; color: var(--gold); line-height: 1.05; }
.dates { font-size: 3.2vh; color: var(--text); margin-top: .5vh; }
.holidays { font-size: 3vh; color: var(--gold); }
.clock { text-align: left; font-size: 11vh; font-weight: 700; line-height: 1; letter-spacing: .02em; }

/* ---------- columns + panels ---------- */
.col { min-height: 0; }
.col-prayers { grid-area: prayers; }
.col-mid { grid-area: mid; display: flex; flex-direction: column; gap: 1.8vh; }
.col-media { grid-area: media; display: flex; flex-direction: column; }
.panel {
  --fs: 6vh;
  background: var(--panel); border: .15vh solid var(--line); border-radius: 2.2vh;
  padding: 2.2vh 1.8vw; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
#shiurimPanel { flex: 1 1 auto; }
#zmanimPanel { flex: 0 0 auto; }
#shiurimPanel[hidden] + #zmanimPanel { flex: 1 1 auto; }
#zmanimFull { flex: 1; }
.panel h2 {
  font-size: clamp(3.6vh, calc(var(--fs) * .78), 5.6vh); font-weight: 700; color: var(--gold); line-height: 1.1; white-space: nowrap;
  padding-bottom: 1vh; margin-bottom: .6vh; border-bottom: .15vh solid rgba(242, 204, 107, .3);
}
.rows { display: flex; flex-direction: column; justify-content: space-evenly; flex: 1; min-height: 0; }
#zmanimPanel .rows { justify-content: flex-start; }

.row {
  display: flex; justify-content: space-between; align-items: center; gap: 1.2vw;
  font-size: var(--fs); line-height: 1.15; padding: .5vh .8vw; border-radius: 1.4vh;
}
.row .label { font-weight: 700; flex: 0 0 auto; white-space: nowrap; }
.row .label small { white-space: nowrap; }
.row .label small { display: block; font-size: .5em; font-weight: 400; color: var(--muted); line-height: 1.25; }
.row .t { font-weight: 700; white-space: nowrap; flex: 0 0 auto; }
/* Rotating shiur: the speaker's name in place of the time */
.row .t.speaker { font-size: .78em; color: var(--gold); white-space: nowrap; }
/* Free-text "time" (e.g. מיד לאחר מנחה) */
.row .t.txt { font-size: .62em; white-space: normal; text-align: left; flex: 0 1 auto; min-width: 4.5em; line-height: 1.1; }
.row.past { opacity: .38; }
.row.next { background: linear-gradient(90deg, rgba(242, 204, 107, .10), rgba(242, 204, 107, .28)); box-shadow: inset 0 0 0 .2vh rgba(242, 204, 107, .65); }
.row.next .t, .row.next .label { color: var(--gold); }
.row .soon { display: block; font-size: .48em; font-weight: 700; color: var(--text); }
.row.hl .t { color: var(--gold); }
.row.sep { font-size: calc(var(--fs) * .55); color: var(--gold); padding-top: 1vh; padding-bottom: 0; }
.rows.zmanim .row { font-size: calc(var(--fs) * .8); padding-top: .25vh; padding-bottom: .25vh; }
.rows.zmanim .row .label { font-weight: 400; }
.empty { font-size: 3.4vh; color: var(--muted); }

/* ---------- event pictures ---------- */
.media { position: relative; flex: 1; min-height: 0; border-radius: 2.2vh; overflow: hidden; background: #000; border: .15vh solid var(--line); }
.pic { position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s ease; }
.pic.on { opacity: 1; }
.pic .bg { position: absolute; inset: -6%; background-size: cover; background-position: center; filter: blur(3vh) brightness(.45) saturate(1.2); }
.pic img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }
.pic figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4vh 1.6vw 1.8vh;
  font-size: 4.2vh; font-weight: 700; line-height: 1.15;
  background: linear-gradient(transparent, rgba(0, 0, 0, .82));
}
.pic figcaption small { display: block; font-size: .7em; font-weight: 400; color: #e4ebf2; }
.pic figcaption:empty { display: none; }

/* ---------- message bar (static, changes by fading) ---------- */
.msg {
  grid-area: msg; display: flex; align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(90deg, var(--gold-2), var(--gold)); color: #1d1400; border-radius: 1.6vh; overflow: hidden;
  padding: 0 2vw;
}
.msg-text { font-size: 4.4vh; font-weight: 700; line-height: 1.1; transition: opacity .8s ease; }
.msg-text.fade { opacity: 0; }

/* ---------- light mode (/display?lite=1) for weak devices ---------- */
.lite body { background: linear-gradient(160deg, var(--bg2), var(--bg1)); }
.lite .pic { transition: none; }
.lite .pic .bg { display: none; }
.lite .pic figcaption { background: rgba(0, 0, 0, .72); padding-top: 1.8vh; }
.lite .msg-text { transition: none; }
.lite .panel { background: rgba(255, 255, 255, .06); }

/* ---------- special days: Shabbat / Yom Tov, Chanukah, fasts ---------- */
.pills { display: flex; justify-content: center; gap: 1vw; margin-top: .8vh; }
.rt {
  display: inline-flex; align-items: center; gap: .5vw; padding: .45vh 1.1vw; border-radius: 999px;
  font-size: 3vh; background: rgba(242, 204, 107, .14); border: .15vh solid rgba(242, 204, 107, .55); white-space: nowrap;
}
.rt b { color: var(--gold); font-size: 1.12em; }
.rt .ico { height: 3.5vh; width: auto; }
.rt .ico.chanukiah { height: 5.2vh; margin: -.6vh 0; }
.rt.rt-chan { padding-top: .2vh; padding-bottom: .2vh; }
.pills-3 .rt { font-size: 2.5vh; padding: .4vh .8vw; }
.has-pills .screen { grid-template-rows: 19vh minmax(0, 1fr); }
.has-pills .screen.has-msg { grid-template-rows: 19vh minmax(0, 1fr) 9vh; }
.has-pills .parasha { font-size: 6.6vh; }
.has-pills .dates { font-size: 2.4vh; color: var(--muted); margin-top: .2vh; }
.has-pills .holidays { font-size: 2.3vh; line-height: 1.1; }
.has-pills .pills { margin-top: .5vh; }

/* Chanukah: royal blue and silver, warm candle glow */
.chanukah { --bg1: #050f26; --bg2: #0f2f6b; --panel: rgba(200, 220, 255, .07); --line: rgba(190, 210, 255, .22); --muted: #b9c9e6; }
.chanukah body {
  background:
    radial-gradient(ellipse at 50% -12%, rgba(255, 200, 110, .24), transparent 50%),
    radial-gradient(ellipse at 0% 100%, rgba(120, 170, 255, .18), transparent 55%),
    linear-gradient(165deg, var(--bg2), var(--bg1));
}
.chanukah .top { border-bottom: .35vh solid transparent; border-image: linear-gradient(90deg, transparent, #cfd9ea, var(--gold), #cfd9ea, transparent) 1; }

/* Shabbat / Yom Tov: deep wine, candle-light glow (wins over Chanukah on Shabbat Chanukah) */
.shabbat { --bg1: #12081a; --bg2: #3b1230; --panel: rgba(255, 236, 210, .06); --line: rgba(242, 204, 107, .22); --muted: #d8c2b8; }
.shabbat body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 196, 100, .22), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(170, 60, 110, .18), transparent 50%),
    linear-gradient(165deg, var(--bg2), var(--bg1));
}
.shabbat .top { border-bottom: .35vh solid transparent; border-image: linear-gradient(90deg, transparent, var(--gold), transparent) 1; }

/* Public fast: sober slate, muted gold */
.fast { --bg1: #101318; --bg2: #2a313d; --panel: rgba(255, 255, 255, .05); --line: rgba(255, 255, 255, .12); --muted: #aeb7c4; --gold: #d8c9a3; }
.fast body { background: linear-gradient(165deg, var(--bg2), var(--bg1)); }
.fast .rt { background: rgba(255, 255, 255, .08); border-color: rgba(216, 201, 163, .55); }

.lite.shabbat body, .lite.chanukah body { background: linear-gradient(165deg, var(--bg2), var(--bg1)); }

/* ---------- dedication band (fixed, bottom) ---------- */
.has-dedic .screen { height: 95vh; }
.dedic {
  position: fixed; left: 0; right: 0; bottom: 0; height: 5vh; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 1.6vw; padding: 0 2vw;
  background: linear-gradient(180deg, #f6ecd2, #e9dbb6); color: #2a1d0c;
  border-top: .25vh solid #c9a85c; box-shadow: 0 -.3vh 1.2vh rgba(0, 0, 0, .3);
}
.dedic-text { font-size: 2.4vh; font-weight: 700; white-space: nowrap; overflow: hidden; max-width: 86vw; text-align: center; }
.dedic .dc { height: 4.4vh; width: auto; flex: none; overflow: visible; margin-top: -.4vh; }
.dedic .flame { transform-origin: 12px 16px; animation: dc-flicker 2.6s ease-in-out infinite; }
.dedic .glow { animation: dc-glow 2.6s ease-in-out infinite; }
.dedic .dc + .dedic-text + .dc .flame, .dedic .dc + .dedic-text + .dc .glow { animation-delay: -1.3s; }
@keyframes dc-flicker {
  0%, 100% { transform: scale(1, 1) rotate(0deg); }
  25% { transform: scale(.96, 1.06) rotate(-2deg); }
  50% { transform: scale(1.03, .95) rotate(1.5deg); }
  75% { transform: scale(.98, 1.04) rotate(-1deg); }
}
@keyframes dc-glow { 0%, 100% { opacity: .85; } 50% { opacity: .55; } }

.status { position: fixed; left: .5vw; top: .5vh; width: .8vh; height: .8vh; border-radius: 50%; background: #3ecf6e; opacity: .35; }
.status.stale { background: #ff5b5b; opacity: 1; }

/* ---------- portrait (phone held upright): vertical, scrollable, sized by the screen width ----------
   Landscape (the TV, computers) is untouched: everything below applies only when height > width. */
@media (max-aspect-ratio: 1/1) {
  html, body { height: auto; overflow: auto; cursor: auto; }
  body { transform: none !important; }
  .screen, .has-pills .screen, .has-dedic .screen, .screen.has-msg, .has-pills .screen.has-msg {
    display: flex; flex-direction: column; gap: 3.5vw; width: 100%; height: auto; padding: 4vw 4vw 6vw;
  }
  .top, .has-pills .top {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1.5vw; padding-bottom: 3vw;
  }
  .brand { justify-content: center; gap: 2.5vw; order: 1; }
  .logo { height: 11vw; }
  .name, .has-pills .name { font-size: 8vw; }
  .clock { order: 2; text-align: center; font-size: 15vw; }
  .day { order: 3; }
  .parasha, .has-pills .parasha { font-size: 7.5vw; }
  .dates, .has-pills .dates { font-size: 3.8vw; }
  .holidays, .has-pills .holidays { font-size: 3.8vw; }
  .pills { flex-wrap: wrap; gap: 2vw; margin-top: 2vw; }
  .rt, .pills-3 .rt { font-size: 4vw; padding: 1vw 3vw; gap: 1.5vw; }
  .rt .ico { height: 5.5vw; }
  .rt .ico.chanukiah { height: 7vw; margin: -1vw 0; }

  .col, .col-mid, .col-media { min-height: auto; }
  .col-mid { gap: 3.5vw; }
  .panel { padding: 4vw 4.5vw; border-radius: 4vw; }
  .col-prayers.panel, #colPrayers { --fs: 6.4vw; }
  #shiurimPanel { --fs: 5.4vw; }
  #zmanimPanel { --fs: 5.6vw; }
  .panel h2 { font-size: 5.6vw; padding-bottom: 2vw; margin-bottom: 1.5vw; }
  .rows { justify-content: flex-start; gap: 1vw; }
  .row { padding: 1.2vw 2vw; border-radius: 2.5vw; }
  .row .label { white-space: normal; flex: 1 1 auto; }
  .row .label small { white-space: normal; }
  .row .t.speaker { white-space: normal; text-align: left; }

  .media { flex: none; width: 100%; aspect-ratio: 1 / 1; border-radius: 4vw; }
  .pic figcaption { font-size: 5vw; }
  .dots { display: none; }

  .msg { border-radius: 3vw; padding: 3vw 4vw; }
  .msg-text { font-size: 4.6vw !important; white-space: normal; }
  .dedic { position: static; height: auto; padding: 3vw 4vw; gap: 3vw; border-radius: 3vw; margin: 0 4vw 6vw; }
  .dedic-text { font-size: 3.8vw !important; white-space: normal; max-width: none; line-height: 1.4; }
  .dedic .dc { height: 9vw; }
  .status { width: 2vw; height: 2vw; }
}

/* ---------- weekly shiurim (Sun-Thu) and the Shabbat card in the picture column ---------- */
.row .dtag {
  display: inline-block; min-width: 1.9em; margin-left: .45em; padding: 0 .25em; border-radius: .35em; text-align: center;
  font-size: .62em; vertical-align: .18em; background: rgba(255, 255, 255, .1); color: var(--muted);
}
.row.today { background: rgba(242, 204, 107, .08); }
.row.today .dtag { background: var(--gold); color: #1d1400; }
.row.next .dtag { background: var(--gold); color: #1d1400; }
.col-media { position: relative; }
.shabbat-card {
  position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s ease; z-index: 2;
  background: linear-gradient(165deg, #3b1230, #12081a); border-color: rgba(242, 204, 107, .35);
}
.shabbat-card.on { opacity: 1; }
.shabbat-card h2 { color: var(--gold); }
.shabbat-card .row.sep { color: var(--gold); }
.lite .shabbat-card { transition: none; }
@media (max-aspect-ratio: 1/1) {
  .shabbat-card { position: static; opacity: 1; --fs: 5.6vw; }
  .row .dtag { font-size: .7em; }
}
.row .isub { font-weight: 400; font-size: .72em; color: var(--muted); }
.row.today .isub, .row.next .isub { color: inherit; opacity: .85; }
.shabbat-card.card-week { background: linear-gradient(165deg, #0f3a6b, #071a30); }
.shabbat-card.card-week h2 { color: var(--gold); }

/* Picture column: no black bars. The picture keeps its proportions, sits centered on the screen
   background, and gets its own rounded corners. */
.media { background: transparent; border: 0; }
.pic { display: flex; align-items: center; justify-content: center; }
.pic img {
  width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 2.2vh; box-shadow: 0 1vh 3vh rgba(0, 0, 0, .45);
}
.pic .bg { display: none; }
