/* ============================================================
   JamSholatku — layar TV masjid (landscape 16:9, desain utk 1080p)
   Fondasi Desain: Royal Emerald & Amber Gold dengan Dot-Matrix
   ============================================================ */
:root {
  --bg1: #04150f;
  --bg2: #063b2c;
  --bg-emerald: #062316;
  --panel: rgba(11, 51, 32, 0.82);
  --panel-border: rgba(16, 185, 129, 0.26);
  --txt: #f8fafc;
  --dim: rgba(226, 232, 240, 0.75);
  --accent: #34d399;
  --mint: #10b981;
  --gold: #e5a93c;
  --gold-bg: #e5a93c;
  --gold-txt: #062316;
  --danger: #f87171;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --sh-card: 0 12px 34px rgba(0, 0, 0, 0.35);       /* bayangan kartu (Fase C) */
  --dur: 300ms;                                      /* transisi standar (Fase C) */
}
body[data-theme="light"] {
  --bg1: #f3f8f6;
  --bg2: #dcefe7;
  --bg-emerald: #f3f8f6;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(6, 78, 59, 0.18);
  --txt: #052e22;
  --dim: rgba(5, 46, 34, 0.75);
  --accent: #047857;
  --mint: #059669;
  --gold: #d97706;
  --gold-bg: #f59e0b;
  --gold-txt: #062316;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* atribut hidden harus selalu menang (selektor ID/label di bawah mengatur display) */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--txt);
  background-color: var(--bg-emerald);
  background-image:
    radial-gradient(rgba(52, 211, 153, 0.15) 1.5px, transparent 1.5px),
    radial-gradient(1200px 700px at 75% -10%, rgba(52, 211, 153, 0.22), transparent 60%),
    linear-gradient(155deg, var(--bg1) 0%, var(--bg2) 100%);
  background-size: 24px 24px, auto, auto;
  background-attachment: fixed;
  overflow: hidden;
}
body.kiosk #gearBtn { display: none; }

#screen {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto auto auto auto;
  padding: 2.2vh 2.4vw 0;
  gap: 1.6vh;
}

/* anak grid harus boleh menyusut di bawah min-content */
#topbar, #center, #prayers, #agenda, #announcements, #ticker { min-width: 0; }

/* ---------- baris atas ---------- */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.4vh;
  border-bottom: 1px solid var(--panel-border);
}
.mosque { display: flex; align-items: center; gap: 14px; font-weight: 800; font-size: clamp(16px, 2.1vw, 34px); letter-spacing: .04em; }
#mosqueLogo { font-size: 1.25em; }
.dates { text-align: right; }
.dates span { display: block; }
#hijriDate { font-size: clamp(15px, 1.9vw, 30px); font-weight: 700; color: var(--gold); }
#gregDate { font-size: clamp(12px, 1.3vw, 21px); color: var(--dim); }

/* ---------- tengah: jam + countdown ---------- */
#center {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: 2.5vw;
}
.clockbox {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 3vh 2vw;
  box-shadow: var(--sh-card);
  backdrop-filter: blur(8px);
}
.clock-main-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
}
#clock {
  font-size: clamp(56px, 9vw, 150px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.clock-tz {
  font-size: clamp(20px, 2.8vw, 44px);
  font-weight: 800;
  color: var(--gold);
}
.clock-sub-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 1.2vh;
}
#dayName {
  font-size: clamp(16px, 2vw, 32px);
  font-weight: 700;
  color: var(--accent);
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: clamp(10px, 1vw, 14px);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: pulseDot 1.8s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Banner Countdown Emas + Progress Bar */
.countdown {
  background: var(--gold-bg);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 3vh 2vw;
  text-align: center;
  color: var(--gold-txt);
  box-shadow: 0 16px 40px rgba(229, 169, 60, 0.28), var(--sh-card);
  transition: transform var(--dur) ease;
}
.cd-label {
  font-size: clamp(14px, 1.5vw, 24px);
  color: rgba(6, 35, 22, 0.85);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 800;
}
.cd-time {
  font-size: clamp(48px, 6.8vw, 115px);
  font-weight: 900;
  color: var(--gold-txt);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 1vh 0;
  transition: color var(--dur) ease;
}
.cd-time.iqamah {
  color: #047857;
  animation: cdPulse 1.6s ease-in-out infinite;
}
@keyframes cdPulse { 50% { opacity: .72; } }
.cd-next {
  font-size: clamp(13px, 1.4vw, 22px);
  color: rgba(6, 35, 22, 0.9);
  font-weight: 600;
}
.cd-next b { color: #04150f; }

/* Progress Bar Menuju Adzan / Iqamah */
.cd-progress-track {
  width: 100%;
  height: 10px;
  background: rgba(6, 35, 22, 0.22);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 1.6vh;
  position: relative;
}
.cd-progress-bar {
  height: 100%;
  background: #062316;
  border-radius: 999px;
  transition: width 1s linear;
}

/* ---------- jadwal sholat ---------- */
#prayers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1vw;
}
.pcard {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  text-align: center;
  padding: 1.6vh 0.6vw;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(6px);
  transition: background var(--dur) ease, border-color var(--dur) ease,
              box-shadow var(--dur) ease, opacity var(--dur) ease;
}
.pcard .pinfo {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pcard .pname {
  font-size: clamp(12px, 1.3vw, 22px);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
}
.pcard .pperiod {
  font-size: clamp(10px, 0.9vw, 15px);
  color: rgba(240, 253, 249, 0.55);
  margin-top: 2px;
}
.pcard .ptime {
  font-size: clamp(20px, 2.3vw, 42px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: .6vh;
  color: #fff;
}
.pcard.active {
  background: linear-gradient(160deg, rgba(229, 169, 60, 0.32), rgba(11, 51, 32, 0.9));
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(229, 169, 60, 0.4);
}
.pcard.active .pname { color: var(--gold); font-weight: 800; }
.pcard.active .ptime { color: var(--gold); }
.pcard.past { opacity: 0.5; }

/* ---------- agenda kajian ---------- */
#agenda {
  display: flex;
  align-items: stretch;
  gap: 1vw;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-left: 6px solid var(--gold);
  border-radius: 14px;
  padding: 1.2vh 1vw;
  min-height: 9vh;
  backdrop-filter: blur(6px);
}
.agenda-label {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: clamp(13px, 1.3vw, 22px);
  letter-spacing: .08em;
  color: var(--gold);
  border-right: 1px solid var(--panel-border);
  padding-right: 1vw;
}
.agenda-items {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 1.4vw;
  overflow: hidden;
}
.a-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn var(--dur) ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.a-title { font-weight: 700; font-size: clamp(13px, 1.35vw, 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.a-meta { font-size: clamp(11px, 1.05vw, 18px); color: var(--dim); margin-top: .2vh; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-meta b { color: var(--gold); }

/* ---------- pengumuman ---------- */
#announcements {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
}
.ann-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.4vh 1.4vw;
  display: flex;
  align-items: center;
  gap: 1.4vw;
  backdrop-filter: blur(6px);
}
.ann-title {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: clamp(13px, 1.3vw, 24px);
  letter-spacing: .12em;
  color: var(--gold);
  border-right: 1px solid var(--panel-border);
  padding-right: 1.4vw;
}
.ann-body {
  font-size: clamp(13px, 1.4vw, 26px);
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ann-image img { max-height: 12vh; border-radius: 8px; object-fit: contain; }

/* ---------- running text (ticker) ---------- */
#ticker {
  display: flex;
  align-items: center;
  background: rgba(6, 35, 22, 0.95);
  border-top: 1px solid var(--panel-border);
  margin: 0 -2.4vw;
  padding: 1vh 2.4vw;
  overflow: hidden;
}
.ticker-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: clamp(12px, 1.2vw, 20px);
  color: #fff;
  background: #047857;
  padding: 4px 12px;
  border-radius: 6px 0 0 6px;
  letter-spacing: .1em;
}
.ticker-viewport {
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  background: var(--gold-bg);
  color: var(--gold-txt);
  padding: 4px 14px;
  border-radius: 0 6px 6px 0;
  font-weight: 700;
  font-size: clamp(13px, 1.3vw, 22px);
}
.ticker-move {
  display: inline-block;
  padding-left: 100%;
  animation: tickerSlide 40s linear infinite;
}
@keyframes tickerSlide {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

/* ---------- tombol gear pengaturan ---------- */
#gearBtn {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  color: var(--txt);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.15;
  transition: opacity var(--dur) ease;
}
#gearBtn:hover { opacity: 1; background: rgba(0, 0, 0, 0.85); }

/* ---------- panel pengaturan modal ---------- */
#settings {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}
#settings .panel {
  background: #062316;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  width: min(620px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  color: var(--txt);
}
#settings h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 20px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}
#settings .close {
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 20px;
  cursor: pointer;
}
#settings .row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
#settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--dim);
}
#settings input, #settings select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 14px;
}
#settings .actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
#settings button.save {
  flex: 1;
  background: var(--gold-bg);
  color: var(--gold-txt);
  font-weight: 800;
  border: none;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}
#settings button.ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--panel-border);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
#settings .hint {
  font-size: 12px;
  color: var(--dim);
  margin-top: 14px;
}

/* ============================================================
   FLYER SPONSOR LAYAR PENUH (Screensaver Pasca-Adzan)
   ============================================================ */
#flyerStage {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  background: #000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 700ms ease, visibility 0s linear 700ms;
}
#flyerStage.on {
  opacity: 1;
  visibility: visible;
  transition: opacity 700ms ease;
}
.fs-frame {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 350ms ease;
}
.fs-frame.fading { opacity: 0; }
.fs-kicker {
  position: absolute;
  top: 20px;
  left: 24px;
  z-index: 10;
  font-size: clamp(10px, 1vw, 14px);
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.fs-media {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fs-media img {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.fs-text {
  font-size: clamp(30px, 5vw, 76px);
  font-weight: 800;
  text-align: center;
  line-height: 1.25;
  color: #ffffff;
  padding: 0 8vw;
  max-width: 1100px;
}
.fs-name {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 10;
  font-size: clamp(11px, 1.1vw, 15px);
  font-weight: 700;
  color: #f1f5f9;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.fs-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}
.fs-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: all 250ms ease;
}
.fs-dots span.on {
  width: 24px;
  border-radius: 999px;
  background: var(--gold);
}

/* ---------- adaptif (uji di HP / tablet) ---------- */
@media (max-width: 900px), (orientation: portrait) {
  body { overflow: auto; }
  #screen { height: auto; min-height: 100vh; grid-template-rows: none; }
  #center { grid-template-columns: 1fr; }
  #prayers { grid-template-columns: repeat(4, 1fr); }
  #agenda { flex-direction: column; }
  .agenda-label { border-right: none; border-bottom: 1px solid var(--panel-border); padding: 0 0 .8vh; }
  .agenda-items { flex-wrap: wrap; }
  .a-item { flex: 1 1 45%; }
  #announcements { grid-template-columns: 1fr; }
  #ticker { margin: 0 -2.4vw; }
}

/* ---------- Fase C: hormati preferensi kurangi animasi ---------- */
@media (prefers-reduced-motion: reduce) {
  .cd-time.iqamah, .a-item { animation: none !important; }
  * { transition-duration: .01ms !important; }
}
