/* Zmanim page. Builds on styles.css (colors, .btn, .ghost-btn) and home.css (.home, h2). */

.zm-lede { color: var(--ink-soft); line-height: 1.65; max-width: 640px; margin: 0 0 22px; }
.home h1.zm-title { font-size: clamp(1.8rem, 4.6vw, 2.6rem); line-height: 1.15; margin: 14px 0 10px; }

.zm-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 8px; }
.zm-controls label { font-weight: 600; }
.zm-controls select,
.zm-controls input[type="date"] {
  font: inherit;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 40px;
}
.zm-controls input[type="number"] {
  font: inherit;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 40px;
  width: 6.2em;
}
.zm-controls .zm-row select { width: auto; }
.zm-controls select:focus-visible,
.zm-controls input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.zm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.zm-note { color: var(--ink-dim); font-size: 0.88rem; min-height: 1.3em; margin: 0 0 14px; }

.zm-day {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px 20px 8px;
}
.zm-day h2 { margin: 0 0 2px; font-size: 1.35rem; }
.zm-day .zm-date { color: var(--ink-soft); margin: 0 0 12px; }
#times { margin: 0; }
.zman { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-top: 1px solid var(--border); }
.zman dt { color: var(--ink); }
.zman dt small { color: var(--ink-dim); font-size: 0.82rem; }
.zman dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.08rem; direction: ltr; }
.zman-key dt, .zman-key dd { color: var(--gold-deep); font-weight: 700; }
.zman-key dt small { font-weight: 400; }
.zman[hidden] { display: none; }
.zm-day dl { margin: 0; }
.zm-plain { padding-top: 4px; }
.zm-plain .zman:first-child { border-top: 0; }
.zman dd { white-space: nowrap; }
#calendar dd, #moonFacts dd { direction: inherit; text-align: end; }
#moonFacts dd { white-space: normal; font-size: 1rem; }
.zm-about a { color: var(--gold-deep); }
select.zm-mini {
  display: inline-block;
  width: auto;
  min-height: 0;
  font: inherit;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 4px;
}
select.zm-mini:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* The moon: one large drawing, a strip with every day of the Hebrew month, a slider under it. */
.zm-moon { padding-top: 18px; }
.moon-main { display: flex; align-items: center; gap: 22px; }
.moon-big { width: 124px; height: 124px; flex: none; }
.moon-dark { fill: oklch(0.31 0.03 275); }
.moon-lit { fill: oklch(0.955 0.04 95); }
.moon-name { margin: 0 0 4px; font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.moon-meta { margin: 0; color: var(--ink-soft); line-height: 1.6; }
.moon-strip { display: flex; margin-top: 14px; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.moon-cell { flex: 1 1 0; min-width: 0; padding: 10px 1px; border-radius: 8px; }
.moon-strip svg { display: block; width: 100%; max-width: 22px; margin: 0 auto; pointer-events: none; }
.moon-cell:hover { background: rgba(139, 92, 246, 0.14); }
.moon-cell.current { background: rgba(139, 92, 246, 0.3); }
#moonRange {
  display: block;
  /* the handle's centre travels from the first small moon to the last */
  width: calc(100% - 100% / var(--n, 30) + 18px);
  height: 26px;
  margin: 2px auto 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
#moonRange::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--border); }
#moonRange::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
#moonRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 0;
  border-radius: 50%;
  background: var(--gold-deep);
}
#moonRange::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--gold-deep); }
#moonRange:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.moon-hint { color: var(--ink-dim); font-size: 0.85rem; margin: 6px 0 12px; }

/* Month calendar: both dates in every day. */
.zm-month { padding-top: 16px; }
.mc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mc-title { margin: 0; font-weight: 700; font-size: 1.1rem; text-align: center; color: var(--ink); }
.mc-mode { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0 14px; }
.mc-mode [aria-pressed="true"] { border-color: var(--gold-deep); color: var(--gold-deep); font-weight: 700; }
.mc-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mc-dow { text-align: center; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); padding-bottom: 4px; }
.mc-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  min-width: 0;
  padding: 6px 2px;
  font: inherit;
  color: var(--ink);
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.mc-day:hover { background: rgba(139, 92, 246, 0.14); }
.mc-day:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mc-main { font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mc-other { font-size: 0.78rem; color: var(--ink-soft); line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.mc-shabbat { background: rgba(139, 92, 246, 0.08); }
.mc-day.today { border-color: var(--ink-soft); }
.mc-day.current { border-color: var(--gold-deep); background: rgba(139, 92, 246, 0.26); }
.mc-day.current .mc-main, .mc-day.current .mc-other { color: var(--gold-deep); }
@media (max-width: 520px) {
  .mc-grid { gap: 2px; }
  .mc-day { min-height: 54px; padding: 5px 1px; border-radius: 8px; }
  .mc-main { font-size: 1rem; }
  .mc-other { font-size: 0.68rem; }
  .mc-title { font-size: 0.98rem; }
}
@media (max-width: 520px) {
  .zm-day { padding: 14px 14px 6px; }
  .zman dt small { display: block; }
  .moon-main { gap: 14px; }
  .moon-big { width: 92px; height: 92px; }
  .moon-name { font-size: 1.2rem; }
}
/* Fingers: a bigger slider handle, and form text of 16px so iPhones do not zoom in on focus. */
@media (pointer: coarse) {
  #moonRange { height: 40px; }
  #moonRange::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -12px; }
  #moonRange::-moz-range-thumb { width: 28px; height: 28px; }
  .zm-controls select, .zm-controls input, select.zm-mini { font-size: 16px; }
  select.zm-mini { padding: 6px 6px; }
  .zm-controls .ghost-btn, .mc-head .ghost-btn, .mc-mode .ghost-btn, .zm-note .ghost-btn { min-height: 42px; }
}

/* Which place the times are for. */
.zm-place { margin: 0 0 14px; line-height: 1.35; }
.zm-place-label { display: block; color: var(--ink-soft); font-size: 0.88rem; }
.zm-place strong { display: block; font-size: clamp(1.5rem, 5vw, 1.9rem); font-weight: 800; color: var(--gold-deep); }
.zm-place-detail { display: block; color: var(--ink-soft); font-size: 0.92rem; }
.zm-note .ghost-btn { margin-inline-start: 6px; }

.zm-week-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.zm-week { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.zm-week th, .zm-week td { padding: 9px 12px; text-align: start; white-space: nowrap; border-top: 1px solid var(--border); }
.zm-week thead th { border-top: 0; color: var(--ink-soft); font-weight: 600; font-size: 0.85rem; }
.zm-week td { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.zm-week tbody th { font-weight: 600; color: var(--ink); }
.zm-week tbody tr { cursor: pointer; }
.zm-week tbody tr:hover td, .zm-week tbody tr:hover th { background: rgba(139, 92, 246, 0.1); }
.zm-week tr.current th, .zm-week tr.current td { color: var(--gold-deep); font-weight: 700; }

.zm-about ul { padding-inline-start: 22px; margin: 0; }
.zm-about li { margin-bottom: 6px; }
.zm-warning { border: 1px solid var(--gold-deep); border-radius: var(--radius); padding: 12px 16px; margin-top: 16px; }
.zm-warning p { margin: 0; color: var(--ink); }

@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .aurora, .topbar, .zm-controls, .zm-note, .zm-about, .footer, .zm-lede, #moonRange, .moon-hint, .mc-mode, .mc-head button { display: none !important; }
  .mc-head { justify-content: center; }
  .mc-day, .mc-main, .mc-other, .mc-title, .mc-dow { color: #000 !important; background: #fff !important; border-color: #999; }
  .zm-day, .zm-week-wrap { border-color: #999; background: #fff; }
  .zman dt, .zman dd, .zman dt small, .zm-week th, .zm-week td, .zm-day h2, .zm-day .zm-date, .home h1, .home h2, .moon-name, .moon-meta { color: #000 !important; }
  .moon-dark { fill: #bbb; }
  .moon-lit { fill: #fff; stroke: #666; stroke-width: 0.5; }
}

/* Fold-out sections (moon, month, week, how it is calculated). On wide screens they are
   opened by the script under </main> and look like plain headed sections. */
.zm-fold > summary { list-style: none; }
.zm-fold > summary::-webkit-details-marker { display: none; }
.zm-fold > summary h2 { display: block; }
@media (min-width: 641px) {
  .zm-fold > summary { pointer-events: none; }
}

/* Phones: straight to the times. One line per control, no repeated place line or intro,
   the long sections folded into tappable rows. Screen only, so printing is unchanged. */
@media screen and (max-width: 640px) {
  .home h1.zm-title { font-size: 1.6rem; margin: 6px 0 12px; }
  /* The day's times come first, right under the pickers; the day's info card follows them. */
  .home { display: flex; flex-direction: column; }
  .home > .zm-day:not(.zm-plain) { order: 1; margin-top: 18px; }
  .home > .zm-fold { order: 2; }
  .home > .zm-warning { order: 3; }
  .zm-lede, .zm-place, #print, .zman.zm-zone { display: none; }

  .zm-controls { gap: 8px; margin-bottom: 4px; }
  .zm-row { flex-wrap: nowrap; gap: 6px; width: 100%; }
  .zm-controls label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .zm-controls .zm-row select, .zm-controls input[type="date"] { flex: 1 1 0; min-width: 0; }
  .zm-controls .zm-row #hebDay { flex: 0 0 auto; }
  .zm-controls input[type="number"] { width: 5.2em; flex: none; }
  .zm-controls .ghost-btn { flex: none; padding: 8px 12px; }
  .zm-note:empty { min-height: 0; margin: 0 0 8px; }

  .home h2 { margin: 26px 0 10px; }
  .zm-fold { border-top: 1px solid var(--border); margin-top: 6px; }
  .zm-fold:last-of-type { border-bottom: 1px solid var(--border); }
  .zm-fold > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 2px; cursor: pointer;
  }
  .zm-fold > summary h2 { margin: 0; font-size: 1.1rem; }
  .zm-fold > summary::after { content: "▾"; color: var(--ink-soft); transition: transform 0.15s ease; }
  .zm-fold[open] > summary::after { transform: rotate(180deg); }
  .zm-fold[open] { padding-bottom: 14px; }

  /* The week fits the screen: day, sunrise, Shema, sunset and nightfall. */
  .zm-week th:nth-child(2), .zm-week td:nth-child(2),
  .zm-week th:nth-child(5), .zm-week td:nth-child(5) { display: none; }
  .zm-week th, .zm-week td { padding: 8px 5px; }
  .zm-week { font-size: 0.88rem; }
  .zm-week thead th { white-space: normal; font-size: 0.78rem; }
}
