:root {
  --ink: #070b1f;
  --indigo: #131a44;
  --ivory: #f6eeda;
  --brass: #e8bd6d;
  --brass-deep: #b98a3a;
  --rose: #e08a6c;
  --muted: rgba(246, 238, 218, 0.66);
  --display: "El Messiri", "Segoe UI", sans-serif;
  --body: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Keeps text readable over a bright midday sky */
.veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(7, 11, 31, 0.55), rgba(7, 11, 31, 0) 34%),
    linear-gradient(to top, rgba(7, 11, 31, 0.86), rgba(7, 11, 31, 0) 42%);
}

.app {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(16px, 2.6vw, 36px);
  gap: 12px;
}

/* ---------- top ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.place-name {
  font-family: var(--display);
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline dotted rgba(246, 238, 218, 0.45);
  text-underline-offset: 6px;
}
.place-name::after {
  /* small chevron: this opens a picker */
  content: "";
  display: inline-block;
  width: 0.38em; height: 0.38em;
  margin-left: 0.5em;
  border-right: 2px solid var(--brass);
  border-bottom: 2px solid var(--brass);
  transform: translateY(-0.2em) rotate(45deg);
}
.place-name:hover { text-decoration-color: var(--brass); }
.place-name:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; border-radius: 4px; }

/* ---------- location picker ---------- */
.place-dialog {
  color-scheme: dark;
  margin: auto;
  width: min(440px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 48px));
  padding: 22px;
  color: var(--ivory);
  background: rgba(13, 18, 48, 0.94);
  border: 1px solid rgba(246, 238, 218, 0.22);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.place-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.place-dialog::backdrop { background: rgba(7, 11, 31, 0.6); }
.place-head { display: flex; justify-content: space-between; align-items: center; }
.place-head h2 { font-family: var(--display); font-size: 1.4rem; font-weight: 600; }
.btn-main {
  justify-content: center;
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass);
  font-weight: 600;
  padding: 12px 16px;
}
.btn-main:hover { background: #f2cd86; border-color: #f2cd86; }
.geo-status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.geo-status:empty { display: none; }
.city-search { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.city-search input {
  font: 400 1rem var(--body);
  color: var(--ivory);
  background: rgba(246, 238, 218, 0.08);
  border: 1px solid rgba(246, 238, 218, 0.22);
  border-radius: 12px;
  padding: 11px 14px;
}
.city-search input::placeholder { color: rgba(246, 238, 218, 0.4); }
.city-search input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.city-list { list-style: none; overflow-y: auto; min-height: 120px; margin: 0 -8px; }
.city-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font: 400 1rem var(--body);
  color: var(--ivory);
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.city-list button span { font-size: 0.78rem; color: var(--muted); }
.city-list button:hover { background: rgba(232, 189, 109, 0.14); }
.city-list button:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }
.city-list .empty { padding: 10px 12px; font-size: 0.9rem; color: var(--muted); }

.place-date {
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  column-gap: 14px;
}

.sound { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  font: 500 0.85rem var(--body);
  color: var(--ivory);
  background: rgba(19, 26, 68, 0.55);
  border: 1px solid rgba(246, 238, 218, 0.22);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s;
}
.btn:hover { background: rgba(19, 26, 68, 0.85); border-color: var(--brass); }
.btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
.btn-quiet { background: transparent; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 10px var(--brass);
}
.btn[aria-pressed="false"] .dot { background: transparent; border: 1px solid var(--muted); box-shadow: none; }
.btn.needs-tap .dot { background: var(--rose); box-shadow: 0 0 10px var(--rose); }

/* ---------- center ---------- */
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding-top: clamp(4px, 3vh, 40px);
  text-shadow: 0 1px 2px rgba(7, 11, 31, 0.55), 0 2px 30px rgba(7, 11, 31, 0.8);
  position: relative;
}
/* soft shade behind the clock so it survives the sun passing behind it */
.center::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%; top: 0;
  width: min(900px, 130vw);
  height: clamp(260px, 46vh, 420px);
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(7, 11, 31, 0.5), rgba(7, 11, 31, 0));
  pointer-events: none;
}

.clock {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(4.2rem, 13vw, 10.5rem);
  line-height: 0.95;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 0.08em;
}
.clock-sec {
  font-size: 0.3em;
  color: var(--brass);
  min-width: 1.3em;
  text-align: left;
}

.next {
  margin-top: clamp(8px, 1.6vh, 18px);
  font-size: clamp(1rem, 1.7vw, 1.3rem);
  color: var(--muted);
}
.next-name {
  font-family: var(--display);
  font-weight: 600;
  color: var(--brass);
  font-size: 1.25em;
  margin-right: 0.3em;
}

.countdown {
  margin-top: 4px;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.azan-banner {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 22px;
  border-radius: 999px;
  background: rgba(232, 189, 109, 0.16);
  border: 1px solid var(--brass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--display);
  font-size: 1.15rem;
  animation: breathe 2.6s ease-in-out infinite;
}
.azan-banner[hidden] { display: none; }
@keyframes breathe {
  50% { box-shadow: 0 0 44px rgba(232, 189, 109, 0.45); }
}

/* ---------- bottom ---------- */
.prayers {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 1080px;
  margin: 0 auto;
  border-top: 1px solid rgba(246, 238, 218, 0.2);
}

.prayer {
  position: relative;
  padding: 16px 8px 6px;
  text-align: center;
  transition: opacity 0.6s;
}
.prayer::before {
  /* marker on the day line */
  content: "";
  position: absolute;
  top: -5px; left: 50%;
  width: 9px; height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--muted);
}
.prayer-name {
  font-family: var(--display);
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
  font-weight: 500;
}
.prayer-ar {
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: -2px;
}
.prayer-time {
  margin-top: 4px;
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.prayer.is-past { opacity: 0.48; }
.prayer.is-past::before { background: var(--muted); }

.prayer.is-next .prayer-name,
.prayer.is-next .prayer-time { color: var(--brass); }
.prayer.is-next .prayer-time { font-weight: 500; }
.prayer.is-next::before {
  background: var(--brass);
  border-color: var(--brass);
  box-shadow: 0 0 0 5px rgba(232, 189, 109, 0.2), 0 0 18px var(--brass);
}
/* how far we are between the previous prayer and this one */
.prayer.is-next::after {
  content: "";
  position: absolute;
  top: -1px; right: 50%;
  height: 1px;
  width: calc(var(--progress, 0) * 100%);
  background: var(--brass);
}
.prayer.is-next:first-child::after { width: calc(var(--progress, 0) * 50%); }

.prayer.is-now .prayer-name::after {
  content: " · sekarang";
  font-family: var(--body);
  font-size: 0.7em;
  color: var(--muted);
}

.note {
  margin-top: 10px;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(246, 238, 218, 0.5);
}

@media (max-width: 640px) {
  .top { flex-direction: column; }
  .sound { justify-content: flex-start; }
  .prayer { padding: 14px 2px 4px; }
  .prayer-ar { display: none; }
  .azan-banner { flex-direction: column; border-radius: 22px; padding: 14px 18px; gap: 10px; }
  .note { font-size: 0.68rem; }
}

@media (max-height: 560px) {
  .clock { font-size: clamp(3rem, 16vh, 6rem); }
  .note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .azan-banner { animation: none; }
}
