/* Targets Chrome 49+: no grid, flex gap, inset, min() or clamp(). */
@font-face { font-family: Jakarta; font-weight: 400; src: url(../fonts/jakarta-400.woff2) format('woff2'); }
@font-face { font-family: Jakarta; font-weight: 600; src: url(../fonts/jakarta-600.woff2) format('woff2'); }
@font-face { font-family: Jakarta; font-weight: 800; src: url(../fonts/jakarta-800.woff2) format('woff2'); }
@font-face { font-family: AmiriLatin; font-weight: 700; src: url(../fonts/amiri-latin-700.woff2) format('woff2'); }
@font-face { font-family: Amiri; font-weight: 400; src: url(../fonts/amiri-400.woff2) format('woff2'); }

@font-face { font-family: Poppins; font-weight: 400; src: url(../fonts/poppins-400.woff2) format('woff2'); }
@font-face { font-family: Poppins; font-weight: 600; src: url(../fonts/poppins-600.woff2) format('woff2'); }
@font-face { font-family: Poppins; font-weight: 800; src: url(../fonts/poppins-800.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 400; src: url(../fonts/inter-400.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; src: url(../fonts/inter-600.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 800; src: url(../fonts/inter-800.woff2) format('woff2'); }
@font-face { font-family: NotoNaskh; font-weight: 400; src: url(../fonts/naskh-400.woff2) format('woff2'); }
@font-face { font-family: Scheherazade; font-weight: 400; src: url(../fonts/scheherazade-400.woff2) format('woff2'); }

:root {
  --primary: #0f2147; --secondary: #1a336b; --accent: #e8c46a; --glow: #3d8bff;
  --highlight: #e8c46a; --background2: #12306b;
  --font-body: Jakarta, sans-serif; --font-head: AmiriLatin, serif; --font-arabic: Amiri, serif;
  --slide-speed: 1s;
  --background: #06102a; --text: #f8f4e8;
  --quiet-bg: #02050c; --quiet-text: #8d95a6;
  --scale: 1;
  --safe-x: 5vw; --safe-y: 5vh; /* TV overscan margins */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body {
  width: 100%; height: 100%; overflow: hidden; cursor: none;
  -webkit-user-select: none; user-select: none;
  background: var(--background); color: var(--text);
  font-family: var(--font-body); font-size: 2vw;
}
.screen {
  display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  padding: var(--safe-y) var(--safe-x); flex-direction: column;
}
body[data-screen='normal'] #normal,
body[data-screen='azan'] #azan,
body[data-screen='countdown'] #countdown,
body[data-screen='quiet'] #quiet,
body[data-screen='black'] #black,
body[data-screen='alert'] #alert,
body[data-screen='nodata'] #nodata { display: flex; }
.centered { align-items: center; justify-content: center; text-align: center; }

body:not(.no-pattern) .patterned { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96'%3E%3Cg fill='none' stroke='%23d9b45b' stroke-opacity='.11'%3E%3Cpath d='M30 30h36v36H30zM48 22.5L73.5 48 48 73.5 22.5 48z'/%3E%3Cpath d='M48 0v22.500M48 73.500V96M0 48h22.500M73.500 48H96'/%3E%3C/g%3E%3C/svg%3E"); }

.stage { flex: 1; display: flex; min-height: 0; }
#photo { width: 27vw; margin-right: 3vw; display: flex; }
#photo svg { width: 100%; height: 100%; }
.arch-line { fill: none; stroke: var(--accent); stroke-width: 6; }
.arch-line.thin { stroke-width: 2; opacity: 0.7; }
.info { flex: 1; display: flex; flex-direction: column; min-width: 0; text-align: center; }

h1, .surau, #slide h2, #azan h2, #countdown h2 { font-family: var(--font-head); font-weight: 700; }
h1 { font-size: calc(3.1vw * var(--scale)); color: var(--accent); line-height: 1.25; }
.ornament { display: flex; align-items: center; justify-content: center; margin: 0.6vh 0 1vh; }
.ornament i { width: 9vw; height: 1px; background: var(--accent); opacity: 0.6; }
.ornament b { position: relative; width: 0.8vw; height: 0.8vw; margin: 0 1.4vw; background: var(--accent); }
.ornament b::after {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--accent); transform: rotate(45deg);
}
.datetime { display: flex; align-items: center; justify-content: space-between; text-align: left; }
.datetime p { font-size: calc(1.7vw * var(--scale)); line-height: 1.6; }
.datetime p + p { color: var(--accent); }
.clock { font-size: calc(6.4vw * var(--scale)); font-weight: 800; line-height: 1; white-space: nowrap; }
.clock small { font-size: 32%; margin-left: 0.3vw; color: var(--accent); }

main { flex: 1; position: relative; margin-top: 1.5vh; min-height: 0; }
#slide {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; background: var(--primary); border: 1px solid var(--accent);
  border-radius: 1.5vw; padding: 2vw;
}
#slide { position: relative; overflow: hidden; }
#slide.enter-fade { animation: fade var(--slide-speed) ease-in; }
#slide.enter-slide { animation: slide-in var(--slide-speed) ease-out; }
#slide h2:empty, #slide p:empty, #slide-rows:empty { display: none; }
#slide-image { max-width: 100%; max-height: 100%; min-height: 0; border-radius: 1vw; }
#slide.type-image { padding: 0.6vw; }
#slide.type-caption #slide-image { flex: 1; width: 100%; object-fit: contain; margin-bottom: 1vh; }
#slide.type-caption h2 { font-size: calc(2.4vw * var(--scale)); margin: 0; }
#slide.type-caption p { font-size: calc(1.6vw * var(--scale)); }
#slide p { white-space: pre-line; }
#slide.type-list { justify-content: flex-start; padding: 1vh 2vw; }
#slide.type-list h2 { font-size: calc(2.6vw * var(--scale)); margin-bottom: 0.5vh; }
#slide-rows { width: 100%; }
#slide-rows div { padding: 0.8vh 0; border-top: 1px solid var(--secondary); line-height: 1.3; }
#slide-rows span { display: block; }
#slide-rows .head { font-size: calc(1.3vw * var(--scale)); color: var(--accent); }
#slide-rows .main { font-size: calc(2vw * var(--scale)); font-weight: 600; }
#slide-rows .sub { font-size: calc(1.4vw * var(--scale)); }
#slide h2 { font-size: calc(4vw * var(--scale)); color: var(--accent); margin-bottom: 1vh; line-height: 1.3; }
#slide p { font-size: calc(2.1vw * var(--scale)); line-height: 1.5; }
#pre-azan {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 1.2vh 2vw; text-align: center;
  background: var(--accent); color: var(--background); border-radius: 0 0 1.5vw 1.5vw; font-weight: 800;
  font-size: calc(2.5vw * var(--scale));
}
#pre-azan strong { margin-left: 1vw; font-size: 140%; }

.next-line { text-align: center; font-size: calc(1.8vw * var(--scale)); margin: 1.2vh 0; }
.next-line strong { color: var(--accent); margin-left: 0.6vw; font-weight: 800; }
#prayer-bar { display: flex; }
#prayer-bar div {
  flex: 1; margin: 0 0.4vw; padding: 1.8vh 0 1vh; text-align: center;
  background: var(--secondary); border: 1px solid var(--accent);
  border-radius: 6vw 6vw 0.8vw 0.8vw; /* arched tiles */
}
#prayer-bar div:first-child { margin-left: 0; }
#prayer-bar div:last-child { margin-right: 0; }
#prayer-bar span { display: block; font-size: calc(1.5vw * var(--scale)); font-weight: 600; }
#prayer-bar strong { display: block; font-size: calc(2.9vw * var(--scale)); font-weight: 800; }
#prayer-bar .current { border: 0.3vw solid var(--accent); }
#prayer-bar .next { background: var(--highlight); color: var(--background); }

.ticker { overflow: hidden; white-space: nowrap; margin-top: 1.2vh; font-size: calc(1.7vw * var(--scale)); }
#ticker-text { display: inline-block; padding-left: 100%; animation: ticker 35s linear infinite; }

.surau { font-size: calc(2.6vw * var(--scale)); color: var(--accent); }
#azan h2, #countdown h2 { font-size: calc(5vw * var(--scale)); color: var(--accent); line-height: 1.3; }
.huge { font-size: calc(16vw * var(--scale)); font-weight: 800; line-height: 1.15; }
.note { font-size: calc(2.6vw * var(--scale)); }

/* Glow: static shadows (cheap on old boxes) plus one slow opacity pulse.
   None of it applies to the prayer-in-progress screen. */
body.glow h1, body.glow .surau, body.glow #slide h2, body.glow #azan h2, body.glow #countdown h2 { text-shadow: 0 0 0.6vw var(--accent), 0 0 2.2vw var(--glow); }
body.glow .clock, body.glow .huge { text-shadow: 0 0 1vw var(--glow), 0 0 2.8vw var(--glow); }
body.glow .next-line strong { text-shadow: 0 0 1vw var(--accent); }
body.glow .ornament i, body.glow .ornament b { box-shadow: 0 0 0.9vw var(--accent); }
body.glow #slide { box-shadow: 0 0 2.2vw var(--glow), inset 0 0 3vw var(--glow); }
body.glow #slide p { text-shadow: 0 1px 4px var(--background); }
body.glow #prayer-bar div { position: relative; box-shadow: 0 0 1.2vw var(--glow), inset 0 0 1.4vw var(--glow); }
body.glow #prayer-bar span, body.glow #prayer-bar strong { text-shadow: 0 1px 4px var(--background); }
body.glow #prayer-bar .next { box-shadow: 0 0 1.6vw var(--highlight); }
body.glow #prayer-bar .next span, body.glow #prayer-bar .next strong { text-shadow: none; }
body.glow #prayer-bar .next::after {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border-radius: inherit; box-shadow: 0 0 3vw 0.5vw var(--highlight);
  animation: breathe 4s ease-in-out infinite;
}
body.glow #pre-azan { box-shadow: 0 0 2vw var(--accent); }
body.glow .arch-line.halo { stroke-linejoin: round; stroke: var(--glow); stroke-width: 34; opacity: 0.18; }
body.glow .arch-line.halo.mid { stroke-width: 20; opacity: 0.35; }
body.glow .arch-line.halo.near { stroke: var(--accent); stroke-width: 12; opacity: 0.4; }
.arch-line.halo { display: none; }
body.glow .arch-line.halo { display: inline; }
#photo svg { overflow: visible; }

/* Prayer in progress: calm, dim, no motion except one slow fade-in. */
#quiet { color: var(--quiet-text); background: var(--quiet-bg); animation: fade 4s ease-in; }
.arabic { font-family: var(--font-arabic); font-size: calc(4vw * var(--scale)); line-height: 2; }
.source { font-size: 1.2vw; opacity: 0.7; margin-bottom: 5vh; }
#quiet h2 {
  font-size: calc(4.6vw * var(--scale)); font-weight: 600; text-transform: uppercase;
  line-height: 1.3; margin-bottom: 3vh;
}
#quiet-silence { font-size: calc(2.4vw * var(--scale)); }
#quiet-indicator { font-size: 1.5vw; opacity: 0.6; margin-top: 6vh; min-height: 1.5em; }

#nodata h2 { font-size: 4vw; color: var(--accent); margin-bottom: 2vh; }

#notice {
  position: fixed; top: 1vh; left: var(--safe-x); font-size: 1.1vw; opacity: 0.75;
}
body[data-screen='quiet'] #notice, body[data-screen='black'] #notice { display: none; }
#sound-overlay {
  position: fixed; left: 25%; right: 25%; top: 40%; padding: 4vh 2vw; border: 0;
  border-radius: 1.5vw; background: var(--accent); color: var(--background);
  font: 800 2.4vw var(--font-body); cursor: pointer; z-index: 5;
}
#debug {
  position: fixed; top: 1vh; left: 50%; transform: translateX(-50%); z-index: 10; cursor: auto;
  background: rgba(0, 0, 0, 0.85); color: #fff; padding: 6px; font: 12px monospace;
  border-radius: 6px; text-align: center; white-space: nowrap;
}
#debug button, #debug input { margin: 2px; padding: 3px 6px; font: inherit; cursor: pointer; }

/* ---- Theme options ---- */
#backdrop, #shade, #dimmer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
#backdrop { background: var(--background); }
body.bg-gradient #backdrop { background: linear-gradient(160deg, var(--background), var(--background2)); }
#backdrop { background-size: cover; background-position: center; }
#shade { background: var(--background); opacity: 0; }
#dimmer { background: #000; opacity: 0; pointer-events: none; z-index: 4; transition: opacity 5s; }
.screen { transition: transform 5s linear; } /* burn-in drift */
#black { background: #000; }
body[data-screen='quiet'] #backdrop,
body.calm-iqamah[data-screen='countdown'] #backdrop { background: var(--quiet-bg) !important; }
body[data-screen='black'] #backdrop { background: #000 !important; }
body[data-screen='quiet'] #shade, body[data-screen='black'] #shade,
body.calm-iqamah[data-screen='countdown'] #shade { display: none; }
body.calm-iqamah #countdown.patterned { background-image: none; }

#content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; justify-content: center; }
/* Sans headings are wider: keep the full surau name on one line. */
body.head-sans h1 { font-size: calc(2.4vw * var(--scale)); }
#logo { height: 4.6vw; max-width: 12vw; margin-right: 1.2vw; }
body.hide-name h1, body.hide-name .ornament, body.hide-date #date-gregorian,
body.hide-hijri #date-hijri, body.hide-clock #clock, body.hide-imsak #prayer-bar .row-imsak,
body.hide-syuruk #prayer-bar .row-syuruk { display: none; }
.datetime .clock { margin-left: auto; }
body.clock-biasa .clock { text-shadow: none; }
body.clock-kotak .clock {
  text-shadow: none; background: var(--primary); border: 0.2vw solid var(--accent);
  border-radius: 1vw; padding: 0.4vw 1.4vw;
}

/* Layout: prayer times at the side */
body.layout-tepi #content { flex-direction: row; }
body.layout-tepi .stage { min-width: 0; }
body.layout-tepi #photo { display: none; }
body.layout-tepi .times { width: 26vw; margin-left: 2vw; display: flex; flex-direction: column; }
body.layout-tepi .next-line { margin: 0 0 1vh; line-height: 1.4; }
body.layout-tepi #prayer-bar { flex: 1; flex-direction: column; min-height: 0; }
body.layout-tepi #prayer-bar div {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0.45vh 0; padding: 0 1.6vw; border-radius: 3vw 0.8vw 3vw 0.8vw;
}

/* Layout: prayer times fill the screen */
body.layout-penuh #photo, body.layout-penuh #slide { display: none; }
body.layout-penuh .stage { flex: none; }
body.layout-penuh main { flex: none; min-height: 9vh; }
body.layout-penuh #pre-azan { position: static; border-radius: 1.2vw; }
body.layout-penuh .datetime .clock { font-size: calc(8vw * var(--scale)); }
body.layout-penuh .times { flex: 1; display: flex; flex-direction: column; min-height: 0; }
body.layout-penuh .next-line { font-size: calc(3vw * var(--scale)); }
body.layout-penuh #prayer-bar { flex: 1; min-height: 0; }
body.layout-penuh #prayer-bar div { display: flex; flex-direction: column; justify-content: center; }
body.layout-penuh #prayer-bar span { font-size: calc(2.1vw * var(--scale)); margin-bottom: 2vh; }
body.layout-penuh #prayer-bar strong { font-size: calc(3.3vw * var(--scale)); }

/* Calm iqamah countdown (same colours as the prayer screen) */
body.calm-iqamah #countdown { background: var(--quiet-bg); color: var(--quiet-text); }
body.calm-iqamah #countdown * { color: var(--quiet-text); text-shadow: none; }
body.calm-iqamah #countdown .ornament { display: none; }

/* ---- Remote control ---- */
#alert { background: #4a0b0b; color: #fff; z-index: 3; }
body[data-screen='alert'] #backdrop { background: #4a0b0b !important; }
body[data-screen='alert'] #shade { display: none; }
.alert-label { font-size: 2.2vw; font-weight: 800; letter-spacing: 0.4vw; color: #ffd36b; margin-bottom: 3vh; }
#alert h2 { font-size: calc(5.5vw * var(--scale)); line-height: 1.25; margin-bottom: 3vh; }
#alert-body { font-size: calc(3vw * var(--scale)); line-height: 1.5; white-space: pre-line; }
#stream { position: fixed; z-index: 3; overflow: hidden; background: #000; }
#stream-host { transform-origin: 0 0; }
#stream-host iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
#stream-message, #silent-note, #pair { position: fixed; z-index: 3; background: rgba(0, 0, 0, 0.8); color: #fff; border-radius: 0.8vw; }
#stream-message { left: 20%; right: 20%; top: 5vh; padding: 1.5vh 2vw; text-align: center; font-size: 1.8vw; }
#silent-note { right: var(--safe-x); top: 1vh; padding: 0.4vh 1vw; font-size: 1.4vw; }
#pair { right: 1vw; bottom: 1vh; padding: 0.8vh 1vw; font-size: 1.1vw; line-height: 1.5; text-align: right; }
#pair strong { font-size: 1.5vw; letter-spacing: 0.1vw; font-family: monospace; }
body[data-screen='quiet'] #silent-note, body[data-screen='black'] #silent-note,
body[data-screen='quiet'] #pair, body[data-screen='black'] #pair,
body[data-screen='countdown'] #pair, body[data-screen='azan'] #pair { display: none; }

/* Nothing peeks out from behind a large stream. */
body[data-stream='window'] .stage { visibility: hidden; }

/* Screen mode: slides only */
body[data-mode='slides'] header, body[data-mode='slides'] #photo,
body[data-mode='slides'] .times { display: none; }
body[data-mode='slides'] #slide { display: flex; }
body[data-mode='slides'] .stage { flex: 1; }
body[data-mode='slides'] main { flex: 1; margin-top: 0; }

@keyframes breathe { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-100%); } }
