@font-face { font-family: "SFSultan"; src: url("../fonts/SFSultan-Black.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Amiri"; src: url("../fonts/Amiri-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "STC"; src: url("../fonts/STC-Regular.woff2") format("woff2"); font-display: swap; }

:root {
  --ar-font: "SFSultan";
  --ink: #ffffff;
  --gold: #ffd966;
  --beige: #dfcdb1;
  --panel-bg: #f7f1e5;
  --panel-ink: #2b2418;
  --panel-muted: #6b6154;
  --panel-selected: #e9dcc2;
  --panel-field: #fffbf3;
  --panel-line: #d8ccb6;
  --accent: #9a6b12;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--ink); }
body { font-family: var(--ar-font), "Segoe UI", Roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }

.background { position: fixed; inset: 0; background: #000 center / cover no-repeat; transition: background-image 0.6s; }

.stage { position: fixed; inset: 0; }
.stage > * { position: absolute; }

.header { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; text-shadow: var(--shadow); gap: 0.15em; }
/* Not clipped: SF Sultan's dots hang below its line box. Lines are shrunk to fit instead (fitHeader). */
.header > * { max-width: 100%; white-space: nowrap; line-height: 1.4; }
.title { margin: 0; font-weight: normal; color: #fff; }
.hijri { color: var(--gold); }
.gregorian { color: #e6e6e6; }
.sun-line { color: #d6d6d6; }
.time { font-family: "Segoe UI", Roboto, Arial, sans-serif; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.1; }
.time span { display: inline-block; vertical-align: middle; }
.time .period { font-family: var(--ar-font), "Segoe UI", Arial, sans-serif; font-weight: normal; font-size: 0.45em; margin: 0 0.35em; }

.mosque { display: flex; align-items: center; justify-content: center; }
.mosque img { width: 100%; height: 100%; object-fit: contain; }
.mosque.photo img { object-fit: cover; border-radius: 50%; border: solid #f0b86a; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }

.clocks { inset: 0; pointer-events: none; }
.clock { position: absolute; }
.clock.tappable { pointer-events: auto; cursor: pointer; }
.header, .main-clock { cursor: pointer; }
.clock canvas { display: block; }
.pill { position: absolute; left: 50%; transform: translate(-50%, -18%); top: 0; padding: 0.05em 0.55em; border-radius: 999px; color: #fff; font-family: "Segoe UI", Roboto, Arial, sans-serif; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45); font-variant-numeric: tabular-nums; }

.weather { display: flex; align-items: flex-end; text-shadow: var(--shadow); line-height: 1.15; direction: ltr; }
.weather.stacked { flex-direction: column; align-items: center; }
.gauge-item { display: flex; flex-direction: column; align-items: center; }
.gauge-item canvas { display: block; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45)); }
.gauge-value { font-family: "Segoe UI", Roboto, Arial, sans-serif; font-weight: 700; color: #fff; white-space: nowrap; }
.gauge-caption { color: #bfbfbf; white-space: pre; text-align: center; line-height: 1.1; }

/* Above the clocks: the big clock's square can reach under the gear in the corner, and would take its clicks. */
.gear { z-index: 5; background: none; border: 0; color: rgba(230, 230, 230, 0.85); text-shadow: var(--shadow); cursor: pointer; padding: 0.15em 0.3em; line-height: 1; }
.gear:hover, .gear:focus-visible { color: #fff; }

.ticker { overflow: hidden; display: flex; align-items: center; color: var(--beige); text-shadow: var(--shadow); }
.ticker-track { display: flex; white-space: nowrap; will-change: transform; }
.ticker-track span { flex: none; }
@keyframes ticker-rtl { from { transform: translateX(0); } to { transform: translateX(50%); } }
@keyframes ticker-ltr { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Full-screen prayer views */
.screen { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9); display: flex; align-items: center; justify-content: center; text-align: center; z-index: 10; }
.screen.solid { background: #000; }
.screen-body { display: flex; flex-direction: column; align-items: center; gap: 0.5em; width: 90%; }
.screen-body .digits { font-family: "Segoe UI", Roboto, Arial, sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
.screen-body .red { color: #ff5252; }
.screen-body canvas.seconds { position: fixed; inset: 0; pointer-events: none; }
.screen-close { z-index: 1; }
.screen-body .urgent { animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.screen-close { position: absolute; top: 0.4em; inset-inline-start: 0.5em; background: none; border: 0; color: rgba(255, 255, 255, 0.4); font-size: 2rem; cursor: pointer; }
.screen-close:hover { color: #fff; }

/* Settings and the mosque picker */
.panel-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.panel { background: var(--panel-bg); color: var(--panel-ink); width: min(640px, 100%); max-height: 100%; display: flex; flex-direction: column; border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); font-size: 17px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--panel-line); }
.panel-head h2 { margin: 0; font-size: 1.3em; font-weight: normal; }
.panel-body { overflow-y: auto; padding: 6px 18px 18px; }
.panel h3 { font-size: 1em; font-weight: normal; color: var(--panel-ink); margin: 18px 0 8px; }
.panel button { background: var(--panel-field); color: var(--panel-ink); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.panel button:hover { border-color: var(--accent); }
.panel :focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.panel button.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.panel-done { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.theme-number { min-width: 3em; text-align: center; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { color: var(--panel-muted); font-size: 0.85em; margin: 4px 0; }
.iqama-inputs { display: flex; flex-direction: column; gap: 8px; }
.iqama-row { display: grid; grid-template-columns: 5.5em 1fr 1fr; gap: 8px; align-items: center; }
.iqama-row select, .iqama-row input { background: var(--panel-field); color: var(--panel-ink); border: 1px solid var(--panel-line); border-radius: 8px; padding: 6px 8px; width: 100%; font: inherit; }
.iqama-row input { font-family: "Segoe UI", Roboto, Arial, sans-serif; }
.mosque-row { display: flex; align-items: center; gap: 12px; }
.mosque-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--panel-selected); flex: none; }
.mosque-text { flex: 1; min-width: 0; }
.mosque-name { font-size: 1.1em; }
.export-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.export-controls label { display: flex; align-items: center; gap: 6px; }
.export-controls input { background: var(--panel-field); color: var(--panel-ink); border: 1px solid var(--panel-line); border-radius: 8px; padding: 4px 6px; }
.export-message { color: #b3261e; }
.table-wrap { max-height: 320px; overflow: auto; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 0.85em; font-family: "Segoe UI", Roboto, Arial, sans-serif; }
.table-wrap th, .table-wrap td { border-bottom: 1px solid var(--panel-line); padding: 4px 6px; text-align: center; white-space: nowrap; }
.table-wrap th { position: sticky; top: 0; background: var(--panel-bg); font-family: var(--ar-font), sans-serif; font-weight: normal; }
.version { color: var(--panel-muted); font-size: 0.85em; margin-top: 22px; text-align: center; }

.mosque { cursor: pointer; }
.mosque-info .panel-body { padding-top: 14px; }
.info-top { display: flex; gap: 16px; align-items: center; }
.info-image { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-selected); border: 3px solid #f0b86a; }
.info-image.icon { object-fit: contain; border: 0; border-radius: 0; background: none; }
.info-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; flex: 1; min-width: 0; }
.info-facts dt { color: var(--panel-muted); }
.info-facts dd { margin: 0; overflow-wrap: anywhere; }
.info-map { margin-top: 16px; border-radius: 12px; overflow: hidden; background: var(--panel-selected); aspect-ratio: 16 / 10; }
.info-map iframe { width: 100%; height: 100%; border: 0; display: block; }
.info-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.panel .info-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; background: var(--panel-field); color: var(--panel-ink); border: 1px solid var(--panel-line); border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; }
.panel .info-button.primary { background: #1a73e8; border-color: #1a73e8; color: #fff; }
@media (max-width: 480px) { .info-top { flex-direction: column; } .info-image { width: 110px; height: 110px; } }

.picker { height: 100%; }
.picker-search { margin: 12px 18px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--panel-line); background: var(--panel-field); color: var(--panel-ink); }
.picker-list { list-style: none; margin: 0; padding: 0 10px 12px; overflow-y: auto; flex: 1; }
.picker-list li { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; cursor: pointer; }
.picker-list li:hover, .picker-list li:focus-visible { background: var(--panel-selected); outline: none; }
.picker-list img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--panel-selected); flex: none; }
.picker-list .info { flex: 1; min-width: 0; }
.picker-list .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-list .meta { color: var(--panel-muted); font-size: 0.85em; }
.picker-list .mins { color: var(--panel-muted); font-size: 0.8em; font-family: "Segoe UI", Roboto, Arial, sans-serif; direction: ltr; }

@media (prefers-reduced-motion: reduce) {
  .screen-body .urgent { animation: none; }
}

/* The iqama gauge beside its words on a wide screen. */
.screen-body .gauge-row { display: flex; align-items: center; justify-content: center; width: auto; }
.screen-body .gauge-side { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.screen-body .gauge-side > div { width: 100%; }

/* ---- Settings: a list of sections down the side and the chosen section beside it, as in the apps ---- */
.settings-backdrop { background: rgba(0, 0, 0, 0.25); -webkit-backdrop-filter: blur(18px) brightness(0.9); backdrop-filter: blur(18px) brightness(0.9); padding: 4vh 3vw; }
.settings-panel { width: min(1100px, 100%); height: 100%; max-height: none; flex-direction: row; overflow: hidden; border-radius: 24px; background: rgba(247, 241, 229, 0.96); }
.settings-rail { flex: none; width: min(250px, 34%); background: rgba(233, 220, 194, 0.55); display: flex; flex-direction: column; padding: 16px 10px; overflow-y: auto; }
.settings-rail h2 { margin: 0 8px 8px; font-size: 1.25em; font-weight: normal; }
.section-list { display: flex; flex-direction: column; gap: 2px; }
.panel .section-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; background: transparent; border: 3px solid transparent; border-radius: 12px; padding: 6px 10px; color: var(--panel-muted); }
.panel .section-item:hover { border-color: transparent; background: rgba(154, 107, 18, 0.1); }
.panel .section-item.selected { background: rgba(154, 107, 18, 0.2); color: var(--panel-ink); }
.panel .section-item:focus-visible { outline: none; border-color: var(--accent); }
.section-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-chevron { display: none; color: var(--panel-muted); font-size: 1.4em; line-height: 1; }
.panel .rail-done, .panel .head-done, .panel .link-button, .panel .section-back { background: none; border-color: transparent; color: var(--accent); }
.rail-done { align-self: flex-start; margin-top: 8px; font-size: 1.05em; }
.settings-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.section-head { display: flex; align-items: center; gap: 6px; padding: 18px 24px 4px; }
.section-title { flex: 1; margin: 0; font-size: 1.45em; font-weight: normal; color: var(--accent); }
.section-back, .head-done { display: none; }
.section-back { font-size: 1.5em; line-height: 1; padding: 2px 10px; border-radius: 999px; }
.section-body { flex: 1; padding: 0 24px 20px; }
.section > h3:first-child { margin-top: 10px; }
.panel .link-button { white-space: nowrap; font-size: 1.05em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.panel .tile { position: relative; padding: 0; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; border: 1px solid rgba(107, 97, 84, 0.4); }
.panel .tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.panel .tile.selected { border: 3px solid var(--panel-ink); background: #000; }
.panel .tile.selected::after { content: "\2713"; position: absolute; top: 4px; inset-inline-end: 4px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 700; font-size: 15px; }
.tile-black { display: flex; align-items: center; justify-content: center; height: 100%; color: #c9c2b6; }
.panel .choices button.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Short screens (a phone held sideways, a 1080p TV at 100%): a tighter list without its heading; Done beside the title. */
@media (max-height: 560px) and (min-width: 641px) {
  .settings-backdrop { padding: 2vh 3vw; }
  .settings-rail { padding: 8px 10px; }
  .settings-rail h2, .rail-done { display: none; }
  .panel .section-item { padding: 3px 10px; }
  .head-done { display: inline-block; }
  .section-head { padding-top: 8px; }
}

/* Narrow screens (a phone held upright): the list and a section take turns at full width. */
@media (max-width: 640px) {
  .settings-backdrop { padding: 12px; }
  .settings-rail { width: 100%; background: none; padding: 16px; }
  .settings-rail h2 { font-size: 1.4em; margin-bottom: 10px; }
  .panel .section-item { padding: 12px; font-size: 1.1em; color: var(--panel-ink); }
  .panel .section-item.selected { background: transparent; }
  .section-chevron { display: inline; }
  .settings-panel.open .settings-rail, .settings-panel:not(.open) .settings-content { display: none; }
  .section-back { display: inline-block; }
  .section-head { padding: 12px 12px 4px 8px; }
  .section-body { padding: 0 16px 16px; }
  .mosque-row { flex-wrap: wrap; }
  .mosque-row .link-button { flex-basis: 100%; text-align: start; padding-inline-start: 68px; }
}

/* ---- The background's video and shade ---- */
.bg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bg-shade { position: absolute; inset: 0; pointer-events: none; transition: background 0.4s; }
.panel .tile { background-size: cover; }
.tile-name { position: absolute; inset-inline: 0; bottom: 4px; text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.video-current { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; color: var(--panel-muted); overflow-wrap: anywhere; }
.video-link { display: flex; gap: 8px; align-items: center; }
.video-link input { flex: 1; min-width: 0; background: var(--panel-field); color: var(--panel-ink); border: 1px solid var(--panel-line); border-radius: 8px; padding: 8px 10px; font-family: "Segoe UI", Roboto, Arial, sans-serif; }
.video-message { color: var(--accent); margin: 10px 0 0; }
.tile-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }

/* The sky now beside the outdoor gauge's tube (left of it, clear of the scale). */
.gauge-top { display: flex; align-items: flex-start; gap: 0.4em; }
.sky-icon { display: block; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }

/* The mosque's announcements: a small button, and a full-screen viewer (the whole poster, never stretched). */
.slides-btn { position: fixed; left: 12px; bottom: 11vh; z-index: 6; border: 1px solid rgba(255, 244, 214, 0.5); border-radius: 999px;
  background: rgba(14, 59, 51, 0.85); color: #fff4d6; font: inherit; font-size: clamp(14px, 1.6vw, 20px); padding: 0.35em 0.9em; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
.slides-btn:hover, .slides-btn:focus-visible { background: rgba(14, 59, 51, 1); }
.slides-viewer { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
.slides-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.slides-stage img { position: relative; max-width: 100%; max-height: 100%; object-fit: contain; }
.slides-back { position: absolute; inset: -40px; background: center / cover no-repeat; filter: blur(24px) brightness(0.45); }
.slides-text { width: min(88vw, 1200px); min-height: 50vh; display: flex; align-items: center; justify-content: center; white-space: pre-line;
  text-align: center; padding: 6vh 5vw; border: 3px solid #c9a44c; border-radius: 24px; color: #fff4d6; font-family: "Amiri", serif;
  font-size: clamp(22px, 4.2vw, 56px); line-height: 1.6; background: linear-gradient(#0e3b33, #06201c); }
.slides-nav, .slides-close { position: absolute; z-index: 1; border: 0; background: rgba(0, 0, 0, 0.45); color: #fff; cursor: pointer; border-radius: 999px; }
.slides-nav { top: 50%; transform: translateY(-50%); font-size: 44px; width: 1.4em; height: 1.4em; line-height: 1; }
.slides-nav.prev { right: 12px; }
.slides-nav.next { left: 12px; }
[dir="ltr"] .slides-nav.prev { right: auto; left: 12px; }
[dir="ltr"] .slides-nav.next { left: auto; right: 12px; }
.slides-close { top: 12px; right: 12px; font-size: 24px; width: 1.8em; height: 1.8em; }
.slides-dots { direction: ltr; position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, 0.8); font-size: 16px; }