/* whentopray — оформление.

   Направление: сутки как измеримая полоса. Всё второстепенное — тихое,
   вся яркость отдана одному элементу: шкале намазов (.dial), где градиент
   повторяет ход света от ночи к полудню и обратно, а точки стоят на своих
   фактических позициях внутри суток.
*/

:root {
  --ink: #14172b;
  --ink-soft: #3a3f57;
  --muted: #6e7183;
  --paper: #fcfbf8;
  --surface: #ffffff;
  --line: #e4e1d8;
  --line-strong: #cfcbbe;

  --sun: #d9a125;
  --dusk: #b8552e;
  --night: #171b3d;

  --band-night: #1b2050;
  --band-dawn: #7a6099;
  --band-day: #6ea8d8;
  --band-dusk: #d1854a;

  --radius: 10px;
  --shell: 1120px;

  --font-display: "Amiri", "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.shell {
  width: min(100% - 32px, var(--shell));
  margin-inline: auto;
}

.skip {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus {
  width: auto;
  height: auto;
  clip-path: none;
  inset-inline-start: 8px;
  top: 8px;
  z-index: 20;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius);
}

:focus-visible {
  outline: 2px solid var(--dusk);
  outline-offset: 2px;
}

/* ---------- Хэдер ---------- */

.masthead {
  background: var(--night);
  color: #f4f2ec;
}

.masthead__row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand__mark { color: var(--sun); display: inline-flex; }

.brand__text { display: flex; flex-direction: column; line-height: 1.15; }

.brand__name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand__tagline {
  font-size: 14px;
  color: #b9b6c9;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.finder {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.finder__field {
  position: relative;
  width: min(46vw, 320px);
}

.finder__field input {
  width: 100%;
  height: 40px;
  padding-inline: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
}
.finder__field input::placeholder { color: rgba(255, 255, 255, 0.6); }

.finder__results {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  width: 100%;
  min-width: 260px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 23, 43, 0.22);
  z-index: 30;
  max-height: 320px;
  overflow-y: auto;
}

.finder__results a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 7px;
  text-decoration: none;
}
.finder__results a:hover,
.finder__results a:focus { background: #f2efe7; }

.finder__results .muted { color: var(--muted); font-size: 15px; }

.langs { display: flex; gap: 2px; }

.langs__item {
  padding: 5px 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: #b9b6c9;
  border-radius: 6px;
}
.langs__item.is-active { color: var(--night); background: var(--sun); }

/* ---------- Блоки ---------- */

.block { padding-block: 30px; }
.block--tight { padding-block: 22px 12px; }

.block__title { font-size: clamp(22px, 3vw, 30px); }
.block__subtitle { color: var(--muted); margin: 6px 0 16px; }

.block__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.block__actions { display: flex; align-items: end; gap: 12px; }

.block--prose { max-width: 74ch; }
.block--prose p { color: var(--ink-soft); }

.link { color: var(--dusk); font-weight: 500; }

.crumbs {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--dusk); }

/* ---------- Первый экран ---------- */

.hero {
  background: linear-gradient(180deg, #fdfcf9 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
  padding-block: 34px 30px;
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 28px;
  align-items: center;
}

.hero__title { font-size: clamp(26px, 4vw, 40px); }
.hero__intro { color: var(--ink-soft); margin: 10px 0 0; max-width: 46ch; }

.beacon {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.beacon__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.beacon__title { font-size: 19px; }
.beacon__title a { text-decoration: none; border-bottom: 2px solid var(--sun); }

.beacon__clock { margin: 0; font-size: 15px; color: var(--muted); }
.beacon__clock time { font-family: var(--font-mono); }
.beacon__tz { display: block; font-size: 13px; color: var(--muted); }

/* ---------- Шкала намазов (R-2405) ---------- */

.dial { --dot: 11px; }

.dial__labels {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  text-align: center;
}

.dial__label { display: flex; flex-direction: column; gap: 1px; }

.dial__time {
  font-family: var(--font-mono);
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.dial__name {
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.dial__label.is-fallback .dial__time::after {
  content: "*";
  font-size: 0.8em;
  vertical-align: super;
}

.dial__track {
  position: relative;
  height: 14px;
  border-radius: 7px;
  background-color: var(--band-night);
  box-shadow: inset 0 0 0 1px rgba(20, 23, 43, 0.12);
}

.dial__dot {
  position: absolute;
  top: 50%;
  width: var(--dot);
  height: var(--dot);
  margin-top: calc(var(--dot) / -2);
  margin-inline-start: calc(var(--dot) / -2);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(20, 23, 43, 0.55);
  cursor: pointer;
}


/* Тултип с точным временем: наведение на десктопе, фокус с клавиатуры,
   класс .is-open — тап на сенсорных экранах (переключается в dial-tooltip.js). */
.dial__dot::after,
.dial__dot::before {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%; /* физическая сторона: translate(-50%) центрирует и в RTL */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  transform: translate(-50%, 4px);
}

.dial__dot::after {
  content: attr(data-label) "\a" attr(data-time);
  white-space: pre;
  text-align: center;
  background: var(--night);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  padding: 5px 10px;
  border-radius: 6px;
  z-index: 6;
}

.dial__dot::before {
  content: "";
  bottom: calc(100% + 5px);
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-top-color: var(--night);
  border-bottom-width: 0;
  z-index: 6;
}

.dial__dot:hover::after,
.dial__dot:hover::before,
.dial__dot:focus-visible::after,
.dial__dot:focus-visible::before,
.dial__dot.is-open::after,
.dial__dot.is-open::before {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dial__now {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  margin-inline-start: -1.5px;
  background: var(--sun);
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(252, 251, 248, 0.85);
  cursor: pointer;
}

.dial__now::after,
.dial__now::before {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%; /* физическая сторона: translate(-50%) центрирует и в RTL */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  transform: translate(-50%, 4px);
}

.dial__now::after {
  content: attr(data-label) "\a" attr(data-time);
  white-space: pre;
  text-align: center;
  background: var(--sun);
  color: var(--night);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 5px 10px;
  border-radius: 6px;
  z-index: 7;
}

.dial__now::before {
  content: "";
  bottom: calc(100% + 5px);
  width: 0; height: 0;
  border: 5px solid transparent;
  border-top-color: var(--sun);
  border-bottom-width: 0;
  z-index: 7;
}

.dial__now:hover::after, .dial__now:hover::before,
.dial__now:focus-visible::after, .dial__now:focus-visible::before,
.dial__now.is-open::after, .dial__now.is-open::before {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dial__scaleline {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.dial--compact .dial__time { font-size: clamp(14px, 2vw, 17px); }


/* ---------- Обратный отсчёт до ближайшего намаза ---------- */

.countdown {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--paper);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.countdown__label {
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.countdown__timer {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--dusk);
}

.countdown:empty, .countdown[hidden] { display: none; }

/* ---------- Панель города ---------- */

.board {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.board__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.board__title { font-size: 19px; }
.board__clock { margin: 0; font-size: 15px; color: var(--muted); }
.board__clock time { font-family: var(--font-mono); }

.notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--dusk);
  background: #fdf3ec;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
  color: #7d3a1d;
}
.notice.is-hidden { display: none; }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end; /* подпись в две строки не сдвигает поле ниже соседних */
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.control { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.control--wide { grid-column: span 2; }
.control--inline { flex-direction: column; }

.control__label {
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.control input,
.control select {
  height: 38px;
  padding-inline: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  width: 100%;
  min-width: 0;
}

.control.is-flagged input,
.control.is-flagged select {
  border-color: var(--dusk);
  box-shadow: 0 0 0 3px rgba(184, 85, 46, 0.16);
}

.summary { margin: 16px 0 0; font-size: 15px; color: var(--ink-soft); }

.pin {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: #1f6b45;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dashed currentColor;
}

.button {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding-inline: 16px;
  border-radius: 8px;
  background: var(--night);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.button:hover { background: #232a56; }

/* ---------- Каталоги ---------- */

.atlas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* «Города рядом»: короткий список, поэтому колонки не растягиваются на всю
   ширину секции — иначе длинные названия городов обрезаются многоточием. */
.atlas--nearby { grid-template-columns: repeat(auto-fill, minmax(200px, 300px)); }

.atlas__item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.atlas__item a:hover {
  border-color: var(--sun);
  transform: translateY(-1px);
}

.atlas__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.atlas--regions .atlas__item a {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  height: auto;
  min-height: 58px;
  padding-block: 8px;
}
.atlas__region {
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas__count {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}

.alphabet { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }

.alphabet__item {
  min-width: 32px;
  padding: 5px 8px;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.alphabet__item.is-active { background: var(--night); color: #fff; border-color: var(--night); }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 22px; font-size: 15px; }
.pager__item {
  min-width: 38px;
  height: 38px;
  padding-inline: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
a.pager__item:hover { border-color: var(--line-strong); background: #f2efe7; }
.pager__item.is-active { background: var(--night); border-color: var(--night); color: #fff; }
.pager__gap { color: var(--muted); padding-inline: 2px; }

.empty { color: var(--muted); }

/* ---------- Таблица месяца ---------- */

.sheet {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.sheet__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.sheet__table th,
.sheet__table td {
  padding: 7px 10px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.sheet__table thead th {
  position: sticky;
  top: 0;
  background: var(--night);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.sheet__table tbody tr:nth-child(even) { background: #faf8f3; }
.sheet__table tbody tr.is-today { background: #fff4dd; box-shadow: inset 3px 0 0 var(--sun); }
.sheet__table .is-start { text-align: start; font-family: var(--font-body); }

/* ---------- Кибла ---------- */

.qibla {
  height: 380px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #eef0ea;
}

/* Библиотека Leaflet с версии 1.9 добавляет в контроль атрибуции маленькую
   цветную иконку флага. Прячем только её — обязательную по лицензии
   подпись "Leaflet | © OpenStreetMap contributors" не трогаем. */
/* leaflet.css сам задаёт `.leaflet-control-attribution svg { display: inline !important }`,
   поэтому селектор должен быть специфичнее. */
.leaflet-control-attribution svg.leaflet-attribution-flag {
  display: none !important;
}

.qibla__fallback {
  display: grid;
  place-items: center;
  height: 100%;
  align-content: center;
  gap: 4px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.qibla__fallback p { margin: 0; }
.qibla__hint { font-size: 14px; }

/* ---------- Футер ---------- */

.footer {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-block: 18px;
  font-size: 14px;
  color: var(--muted);
}

.footer__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  justify-content: space-between;
}

.footer__links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer__links a { text-decoration: none; }
.footer__links a:hover { color: var(--dusk); }

/* ---------- Адаптив ---------- */

@media (max-width: 880px) {
  .hero__grid { grid-template-columns: 1fr; }
  .control--wide { grid-column: span 1; }
}

@media (max-width: 620px) {
  .masthead__row { flex-wrap: wrap; min-height: 0; padding-block: 10px; }
  .finder { order: 3; width: 100%; margin-inline-start: 0; }
  .finder__field { width: 100%; }
  .dial__labels { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .dial__scaleline { display: none; }
  .block__bar { flex-direction: column; align-items: stretch; }
  .qibla { height: 300px; }
  .sheet__table th,
  .sheet__table td { padding: 5px 4px; font-size: 13px; }
  .sheet__table thead th { font-size: 12px; letter-spacing: 0; }
  .atlas { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .controls { grid-template-columns: minmax(0, 1fr); }
  .control--wide { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------- Печать ---------- */

@media print {
  .masthead, .footer, .controls, .qibla, .block--prose, .finder, .pager { display: none !important; }
  body { background: #fff; }
  .sheet { border: 0; }
  .sheet__table thead th { background: #fff; color: #000; border-bottom: 2px solid #000; }
}

/* ---------- RTL ---------- */

[dir="rtl"] .crumbs { direction: ltr; unicode-bidi: plaintext; }
[dir="rtl"] .brand { flex-direction: row-reverse; }
[dir="rtl"] .masthead__row { flex-direction: row-reverse; }
[dir="rtl"] .footer__row { flex-direction: row-reverse; }

main { flex: 1 0 auto; }

/* ---------- Страница «Как рассчитывается время» ---------- */

.prose__heading { font-size: 24px; margin: 32px 0 12px; }
.prose__heading--small { font-size: 19px; margin-top: 24px; }
.block--prose .sheet { margin-bottom: 8px; }
.formula { font-family: var(--font-mono); font-size: 16px; }
.vars { margin: 0 0 16px; padding-inline-start: 22px; }
.vars li { margin-bottom: 8px; }
