/* =============================================================================
   Midnight-Molad Calendar page.
   Styled as a sibling of the church books (see books/epiphanes/style.css):
   same palette, 11pt/1.4 Palatino, 700px column, centred bold-caps h2,
   Source Serif 4 Display h1, 48px emblem, 50%-width picture frames.
   style.css (shared with the main site) is left alone; this file overrides it.
   ============================================================================= */

:root {
  --font-serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --font-display: "Source Serif 4 Display", serif;
  --c-bg: #fbf9f3;
  --c-text: #2c2a2e;
  --c-text-soft: #6d6a70;
  --c-note: #4f4c54;
  --c-link: #3a5c8d;
  --c-link-hover: #1e3250;
  --c-border: #e0dce5;
  --c-border-strong: #bfbac9;
  --c-bg-offset: #f2f0f5;
  --c-king: #942939;
  --c-wisdom: #2b6a73;
  --c-exit: #1f7a4d;
  --c-exit-hover: #14573a;
  --c-fade: rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #191c23;
    --c-text: #d1d1d6;
    --c-text-soft: #888ca0;
    --c-note: #b4b8c8;
    --c-link: #82aaff;
    --c-link-hover: #b3c5ff;
    --c-border: #333644;
    --c-border-strong: #4d5163;
    --c-bg-offset: #222630;
    --c-king: #ff7b8c;
    --c-wisdom: #63d9e8;
    --c-exit: #7AFFBD;
    --c-exit-hover: #9AFFCD;
    --c-fade: rgba(255, 255, 255, 0.2);
  }
}

/* ---- page frame: body is a plain block; header, main and footer share one 700px column ---- */
.calendar-page {
  display: block;
  font-family: var(--font-serif);
  font-size: 11pt;
  line-height: 1.4;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.calendar-page > header,
.calendar-page > main,
.calendar-page > footer {
  max-width: 700px;
  width: 90%;
  margin: 0 auto;
}

.calendar-page > header { padding: 1rem 0 0; }
.calendar-page > main { padding: 1rem 0; }

.calendar-page img { max-width: 100%; height: auto; }

.calendar-page p {
  margin: 0 0 8.5pt 0;
}

/* ---- headings ---- */
.calendar-page h1 {
  font-family: var(--font-display);
  font-size: min(10vw, 4.2rem);
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--c-text);
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.25);
  margin: 0 auto;
  max-width: 90vw;
  overflow-wrap: break-word;
}

.calendar-page h2,
.calendar-page h3 {
  font-family: var(--font-serif);
  font-size: 11pt;
  font-weight: bold;
  margin: 12pt 0 8.5pt 0;
  text-align: center;
}

.date-midnight-molad {
  font-family: var(--font-display);
  font-size: 64pt;
  font-weight: regular;
  margin: 12pt 0 8.5pt 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 18pt;
}


.calendar-page h2 {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 18pt;
}

.calendar-page h3 { font-style: italic; }

/* ---- links ---- */
.calendar-page a {
  color: var(--c-link);
  text-decoration: underline dotted;
}

.calendar-page a:hover,
.calendar-page a:focus {
  color: var(--c-link-hover);
  text-decoration: underline;
}

/* ---- title page: 48px emblem, framed picture ---- */
.calendar-page .site-mark {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 0.5rem;
}

.calendar-page figure { margin: 1.5em auto; text-align: center; }

.calendar-page figure picture {
  display: block;
  margin: auto;
  width: clamp(360px, 80%, 580px);
  max-width: 100%;
}

.calendar-page figure figcaption {
  font-size: 8.5pt;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin: 4px auto;
  max-width: 90%;
}

/* ---- the Stromata quotation, as in On Justice ---- */
.greek-source {
  display: block;
  font-style: italic;
  color: var(--c-note);
  max-width: 650px;
  margin: 2rem auto;
  padding: 1rem;
  border: 1px solid var(--c-border);
  background: var(--c-bg-offset);
  border-radius: 8px;
}

.greek-source .verse-ref,
.greek-source .verse-num-ref { font-style: normal; }
.greek-source .verse-ref { font-variant: small-caps; font-weight: bold; margin: 0 2px 0 4px; }
.greek-source .verse-num-ref { font-size: 0.85em; vertical-align: super; margin: 0 6px 0 2px; }

/* ---- the seven days ---- */
.weekdays-section { margin: 0; }

.weekday-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.weekday-list li {
  background: var(--c-bg-offset);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 0.5rem 0.25rem;
  font-size: 9.5pt;
  line-height: 1.25;
  text-align: center;
}

.weekday-list li span {
  color: var(--c-note);
  font-size: 0.85em;
}

/* ---- footer: no panel, same column, as in the books ---- */
.calendar-page > footer {
  background: none;
  border: 0;
  color: var(--c-text);
  text-align: center;
  padding: 1.25rem 0;
}

.calendar-page > footer p {
  text-align: center;
  padding: 1.25rem 0;
  margin: 0;
}

.calendar-page > footer picture {
  display: block;
  margin: 0.75rem auto 0;
  width: 50%;
}

.calendar-page > footer img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  padding: 0;
}

.calendar-page > footer p a { margin: 0 0.25rem; text-decoration: none; }
.calendar-page > footer a.fire { color: var(--c-king); }
.calendar-page > footer a.water { color: var(--c-wisdom); }
.calendar-page > footer a.green { color: var(--c-exit); }
.calendar-page > footer a.green:hover { color: var(--c-exit-hover); }
.calendar-page > footer p a:hover { text-decoration: underline; }

/* ==================== CALENDAR TOOLS ==================== */
.tool-section { margin: 0 0 0.5rem; }
.tool-section:last-of-type { margin-bottom: 0; }
.calendar-page > main { padding-bottom: 0; }

.calendar-page .tool-section h3 { margin: 1.25rem 0 8.5pt; }

.calendar-page .tool-intro {
  text-align: center;
  margin: 0 0 0.75rem;
}

.tool-message,
.calendar-page .tool-note {
  font-size: 9pt;
  color: var(--c-note);
  text-align: center;
  max-width: none;
  margin: 0.5rem 0;
}

.tool-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.tool-group-title {
  font-size: 9pt;
  color: var(--c-note);
  margin-bottom: 0.25rem;
  text-align: center;
}

.tool-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  justify-content: center;
  align-items: flex-start;
}

.tool-field {
  display: flex;
  flex-direction: column;
  font-size: 9pt;
}

.tool-hint {
  font-size: 9pt;
  color: var(--c-note);
  margin-top: 0.2rem;
}

.calendar-page .tool-field input {
  padding: 0.4rem 0.6rem;
  font-size: 16px;
  font-family: var(--font-serif);
  border: 1px solid var(--c-border-strong);
  border-radius: 4px;
  background: var(--c-bg);
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.calendar-page .tool-field input:focus {
  outline: none;
  border-color: var(--c-link);
  box-shadow: 0 0 0 2px var(--c-border);
}

.tool-field .w-year { width: 6.5rem; }
.tool-field .w-small { width: 4.5rem; }
.tool-field .w-and { width: 9rem; }

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0.5rem 0;
}

.tool-button {
  font-family: var(--font-serif);
  font-size: 9pt;
  padding: 0.3rem 0.7rem;
  background: var(--c-bg-offset);
  border: 1px solid var(--c-border-strong);
  border-radius: 6px;
  color: var(--c-text);
  cursor: pointer;
}

.tool-button:hover {
  border-color: var(--c-link);
  color: var(--c-link);
}

.tool-button:focus-visible,
.tool-table-wrap:focus-visible {
  outline: 2px solid var(--c-link);
  outline-offset: 2px;
}

.tool-error:empty { display: none; }

.tool-error {
  color: var(--c-king);
  text-align: center;
  margin: 0.25rem 0;
  font-size: 10pt;
}

.tool-result {
  margin: 0.75rem 0;
  max-width: none;
  padding: 0.75rem 1rem;
  background: var(--c-bg-offset);
  border: 1px solid var(--c-border);
  border-radius: 8px;
}

.tool-headline {
  font-size: 13pt;
  margin-bottom: 0.5rem;
}

.tool-headline strong { color: var(--c-text); }

.tool-row {
  display: grid;
  grid-template-columns: minmax(10rem, 15rem) 1fr;
  gap: 0.15rem 1rem;
  padding: 0.25rem 0;
  border-top: 1px solid var(--c-border);
  font-size: 10pt;
}

.tool-row.stack { grid-template-columns: 1fr; }
.tool-row dt { color: var(--c-note); }
.tool-row dd { margin: 0; font-variant-numeric: tabular-nums; }

.tool-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
  /* edge fades that appear only while there is more to scroll to */
  background:
    linear-gradient(to right, var(--c-bg) 30%, transparent) left center / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--c-bg) 30%, transparent) right center / 2.5rem 100% no-repeat local,
    linear-gradient(to right, var(--c-fade), transparent) left center / 0.9rem 100% no-repeat scroll,
    linear-gradient(to left, var(--c-fade), transparent) right center / 0.9rem 100% no-repeat scroll;
  scrollbar-width: thin;
}

.tool-table-wrap::-webkit-scrollbar { height: 8px; -webkit-appearance: none; }
.tool-table-wrap::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 4px; }
.tool-table-wrap::-webkit-scrollbar-track { background: var(--c-bg-offset); }

.tool-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 auto;
  border-bottom: 1px solid var(--c-border-strong);
  font-size: 8.5pt;
  font-variant-numeric: tabular-nums;
}

.tool-table th,
.tool-table td {
  padding: 4px 0.4rem;
  text-align: left;
  white-space: nowrap;
  font-size: 8.5pt;
}

.tool-table th {
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.2;
}

.tool-table th {
  font-weight: bold;
  border-bottom: 1px solid var(--c-border-strong);
}

.tool-table tr.changed td { background: var(--c-bg-offset); }

.calendar-page .tool-summary {
  text-align: center;
  margin: 0.75rem 0 0.25rem;
}

.tool-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 520px) {
  .tool-row { grid-template-columns: 1fr; }
  .tool-form,
  .tool-group { width: 100%; }
  .tool-fields { flex-wrap: nowrap; gap: 0.5rem; }
  .tool-field { flex: 1 1 0; min-width: 0; }
  .tool-field:first-child { flex: 1.6 1 0; }
  .calendar-page .tool-field input,
  .tool-field .w-year, .tool-field .w-small, .tool-field .w-and { width: 100%; }
  .tool-table .narrow-hide { display: none; }
  .tool-table th, .tool-table td { padding: 4px 0.45rem; }
  .tool-table th { white-space: nowrap; }
}

.date-midnight-molad {
  font-family: var(--font-display);
  font-size: 36pt;

/* a tall portrait plate should not push the whole page below the fold */
.calendar-page figure picture img {
  max-height: 75vh;
  width: auto;
  margin: 0 auto;
}

.calendar-page .greek-source { text-align: left; }

.author { 
  text-align: center; 
  margin-bottom: 1em; 
}

.sibyl { text-align: center; font-size: 1.5rem; font-variant: small-caps; font-weight: normal; }

/* Clean advertisement banner spacing */
.ad-container {
  margin: 1.75rem 0;
  text-align: center;
}

.ad-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 8pt;
  font-weight: bold;
  letter-spacing: 0.1em;
  color: var(--c-note);
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.ad-container img {
  border-radius: 6px;
  border: 1px solid var(--c-border);
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.ad-container a:hover img {
  border-color: var(--c-border-strong);
  opacity: 0.95;

/* Increase tap targets on mobile screens */
@media (max-width: 520px) {
  .tool-button {
    padding: 0.55rem 1rem;
    font-size: 10pt;
    min-height: 44px; /* Standard accessible touch height */
  }

  .tool-section {
    margin-bottom: 1.5rem;
  }
}
}