/* Daily Ephemeris printable observatory sheet (/ephemeris, ADR 0093)
   All-monospace, dense scientific layout with selectable visual styles:
   - [data-ep-style="spec"]    : Swiss/JPL technical observatory spec sheet
   - [data-ep-style="almanac"] : Classic USNO/HMNAO printed astronomical almanac
   Print-calibrated: Brief = 1 page (Letter/A4), Extended = 2 pages. */

.ep-shell {
  --ep-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  --ep-bg: #fcfcfa;
  --ep-surface: #ffffff;
  --ep-ink: #11151c;
  --ep-muted: #525d6d;
  --ep-rule: #cfd6df;
  --ep-rule-strong: #1e293b;
  --ep-tint: #f3f5f8;
  --ep-tint-alt: #f8f9fb;
  --ep-accent: #1d4ed8;
  --ep-accent-sun: #b45309;
  --ep-accent-moon: #334155;
  --ep-band-civ: rgba(29, 78, 216, 0.08);
  --ep-band-naut: rgba(29, 78, 216, 0.14);
  --ep-band-ast: rgba(15, 23, 42, 0.12);
  --ep-band-night: rgba(15, 23, 42, 0.18);
  --ep-epoch-bg: rgba(29, 78, 216, 0.09);

  font-family: var(--ep-mono);
  color: var(--ep-ink);
  max-width: 1120px;
  margin: 0 auto;
}

/* ---- Interactive Controls Bar (screen only) ---- */
.ep-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--ep-surface);
  border: 1px solid var(--ep-rule);
  border-radius: 6px;
  font-size: 0.74rem;
}

.ep-ctrl-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ep-ctrl-lbl {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--ep-muted);
  font-weight: 700;
}

.ep-seg {
  display: inline-flex;
  border: 1px solid var(--ep-rule);
  border-radius: 4px;
  overflow: hidden;
}

.ep-seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ep-muted);
  font-family: var(--ep-mono);
  font-size: 0.72rem;
  padding: 5px 9px;
  cursor: pointer;
  line-height: 1.2;
}

.ep-seg-btn + .ep-seg-btn {
  border-left: 1px solid var(--ep-rule);
}

.ep-seg-btn.is-active {
  background: var(--ep-rule-strong);
  color: #ffffff;
  font-weight: 600;
}

.ep-steps {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ep-input {
  font-family: var(--ep-mono);
  font-size: 0.72rem;
  padding: 4px 6px;
  border: 1px solid var(--ep-rule);
  border-radius: 4px;
  background: var(--ep-surface);
  color: var(--ep-ink);
}

.ep-input-time {
  width: 6.5rem;
}

.ep-btn {
  appearance: none;
  font-family: var(--ep-mono);
  font-size: 0.72rem;
  padding: 5px 8px;
  border: 1px solid var(--ep-rule);
  border-radius: 4px;
  background: var(--ep-surface);
  color: var(--ep-ink);
  cursor: pointer;
  line-height: 1.2;
}

.ep-btn:hover {
  background: var(--ep-tint);
  border-color: var(--ep-rule-strong);
}

.ep-btn-primary {
  background: var(--ep-accent);
  border-color: var(--ep-accent);
  color: #ffffff;
  font-weight: 600;
}

.ep-btn-primary:hover {
  opacity: 0.9;
  background: var(--ep-accent);
  border-color: var(--ep-accent);
}

.ep-ctrl-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.ep-status {
  font-size: 0.7rem;
  color: var(--ep-accent);
  min-height: 1em;
}

/* Loading state during async AJAX refresh (no visible page reload) */
.ep-shell.is-loading .ep-sheet-host {
  opacity: 0.55;
  transition: opacity 0.14s ease;
}

/* ---- Brief vs Extended visibility ---- */
.ep-shell[data-ep-mode="brief"] .ep-page-2 {
  display: none;
}

.ep-shell[data-ep-mode="brief"] .ep-pg-total-ext {
  display: none;
}

.ep-shell[data-ep-mode="extended"] .ep-pg-total-brief {
  display: none;
}

/* ---- Sheet Page Container ---- */
.ep-sheet {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ep-page {
  background: var(--ep-surface);
  border: 1px solid var(--ep-rule);
  padding: 14px 16px 12px;
  font-size: 11px;
  line-height: 1.32;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

/* ---- Masthead ---- */
.ep-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--ep-rule-strong);
}

.ep-head-p2 {
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.ep-kicker {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ep-muted);
  font-weight: 700;
}

.ep-title {
  margin: 2px 0 2px;
  font-size: 15px;
  line-height: 1.15;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.ep-title-p2 {
  margin-top: 2px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.ep-sub {
  font-size: 10px;
  color: var(--ep-muted);
}

.ep-head-right {
  text-align: right;
  font-size: 10px;
  flex: none;
}

.ep-epoch-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ep-epoch-row span {
  color: var(--ep-muted);
  font-size: 9px;
  letter-spacing: 0.06em;
}

/* ---- Grids & Boxes ---- */
.ep-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.ep-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.ep-box {
  border: 1px solid var(--ep-rule);
  background: var(--ep-bg);
  padding: 6px 8px;
  min-width: 0;
}

.ep-viz-box {
  margin-bottom: 8px;
}

.ep-sec-h {
  margin: 0 0 5px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--ep-rule);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ep-ink);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.ep-code {
  color: var(--ep-accent);
}

.ep-roman {
  display: none;
}

/* ---- Classic Almanac visual style override ([data-ep-style="almanac"]) ---- */
.ep-shell[data-ep-style="almanac"] .ep-page {
  background: #fdfcf7;
  border-color: #9ca3af;
}

.ep-shell[data-ep-style="almanac"] .ep-head {
  border-top: 2px solid var(--ep-rule-strong);
  border-bottom: 3px double var(--ep-rule-strong);
  padding-top: 6px;
}

.ep-shell[data-ep-style="almanac"] .ep-box {
  border: 0;
  border-top: 1.5px solid var(--ep-rule-strong);
  border-bottom: 1px solid var(--ep-rule-strong);
  background: transparent;
  padding: 5px 2px;
}

.ep-shell[data-ep-style="almanac"] .ep-sec-h {
  border-bottom: 1px solid var(--ep-rule-strong);
  letter-spacing: 0.1em;
  justify-content: center;
  text-align: center;
}

.ep-shell[data-ep-style="almanac"] .ep-code {
  display: none;
}

.ep-shell[data-ep-style="almanac"] .ep-roman {
  display: inline;
  color: var(--ep-ink);
}

.ep-shell[data-ep-style="almanac"] .ep-ev thead th,
.ep-shell[data-ep-style="almanac"] .ep-table thead th {
  background: transparent;
  border-top: 1px solid var(--ep-rule-strong);
  border-bottom: 1.5px solid var(--ep-rule-strong);
}

/* ---- Key-Value & Data Tables ---- */
.ep-kv,
.ep-ev,
.ep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.ep-kv th,
.ep-kv td {
  padding: 1.5px 4px;
  border-bottom: 1px dotted var(--ep-rule);
  vertical-align: baseline;
  text-align: left;
}

.ep-kv tr:last-child th,
.ep-kv tr:last-child td {
  border-bottom: 0;
}

.ep-kv th {
  color: var(--ep-muted);
  font-weight: 600;
  white-space: nowrap;
  width: 1%;
}

.ep-kv td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ep-ev {
  margin-top: 5px;
  border-top: 1px solid var(--ep-rule);
}

.ep-ev thead th,
.ep-table thead th {
  padding: 2.5px 4px;
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--ep-muted);
  background: var(--ep-tint);
  border-bottom: 1px solid var(--ep-rule);
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}

.ep-ev td,
.ep-table td {
  padding: 1.5px 4px;
  border-bottom: 1px dotted var(--ep-rule);
  white-space: nowrap;
}

.ep-ev tbody tr:nth-child(even),
.ep-table tbody tr:nth-child(even) {
  background: var(--ep-tint-alt);
}

.ep-hourly-tbl td,
.ep-hourly-tbl th {
  text-align: right;
  padding: 1.5px 5px;
}

.ep-hourly-tbl td:first-child,
.ep-hourly-tbl th:first-child,
.ep-hourly-tbl td:nth-child(2),
.ep-hourly-tbl th:nth-child(2),
.ep-hourly-tbl td:nth-child(3),
.ep-hourly-tbl th:nth-child(3) {
  text-align: left;
}

.ep-hourly-tbl tr.is-epoch {
  background: var(--ep-epoch-bg) !important;
  font-weight: 700;
}

.ep-planets-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 152px;
  gap: 10px;
  align-items: center;
}

.ep-planets-tbl td,
.ep-planets-tbl th {
  text-align: right;
  padding: 2px 3.5px;
}

.ep-planets-tbl td:first-child,
.ep-planets-tbl th:first-child,
.ep-planets-tbl td:nth-child(2),
.ep-planets-tbl th:nth-child(2) {
  text-align: left;
}

.ep-planets-tbl tr.is-down td {
  color: var(--ep-muted);
}

.ep-tide-head {
  font-size: 9.5px;
  font-weight: 700;
  margin-bottom: 3px;
}

.ep-empty {
  margin: 4px 0;
  color: var(--ep-muted);
  font-size: 9.5px;
}

.ep-prov {
  margin: 6px 0 0;
  padding-top: 4px;
  border-top: 1px dotted var(--ep-rule);
  font-size: 8.5px;
  color: var(--ep-muted);
  line-height: 1.35;
}

/* ---- Vector Diagrams ---- */
.ep-viz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(130px, 0.85fr) minmax(190px, 1.2fr);
  gap: 8px;
  align-items: center;
}

.ep-fig {
  margin: 0;
  text-align: center;
}

.ep-fig figcaption {
  font-size: 8.5px;
  color: var(--ep-muted);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.ep-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 132px;
}

.ep-band-civ { fill: var(--ep-band-civ); }
.ep-band-naut { fill: var(--ep-band-naut); }
.ep-band-ast { fill: var(--ep-band-ast); }
.ep-band-night { fill: var(--ep-band-night); }
.ep-grid { stroke: var(--ep-rule); stroke-width: 0.6; }
.ep-grid-hor { stroke: var(--ep-rule-strong); stroke-width: 1; }
.ep-frame { fill: none; stroke: var(--ep-rule-strong); stroke-width: 0.8; }
.ep-ax { fill: var(--ep-muted); font-size: 7px; font-family: var(--ep-mono); }
.ep-card { fill: var(--ep-ink); font-weight: 700; font-size: 7.5px; }
.ep-leg { fill: var(--ep-muted); font-size: 6.5px; font-family: var(--ep-mono); }
.ep-curve-sun { fill: none; stroke: var(--ep-accent-sun); stroke-width: 1.6; }
.ep-curve-moon { fill: none; stroke: var(--ep-accent-moon); stroke-width: 1.2; stroke-dasharray: 3 2; }
.ep-cursor { stroke: var(--ep-accent); stroke-width: 1; stroke-dasharray: 2 1.5; }
.ep-dot-sun { fill: var(--ep-accent-sun); stroke: var(--ep-surface); stroke-width: 0.8; }
.ep-dot-moon { fill: var(--ep-accent-moon); stroke: var(--ep-surface); stroke-width: 0.8; }
.ep-dot-planet { fill: var(--ep-accent); }
.ep-planet-lbl { fill: var(--ep-ink); font-size: 8px; font-family: var(--ep-mono); }
.ep-dome-ring { fill: none; stroke: var(--ep-rule); stroke-width: 0.7; }
.ep-dome-hor { stroke: var(--ep-rule-strong); stroke-width: 1; }
.ep-grid-earth { fill: var(--ep-rule-strong); }
.ep-spoke { stroke: var(--ep-rule); stroke-width: 0.6; stroke-dasharray: 1.5 1.5; }
.ep-disk-sun { fill: rgba(217, 119, 6, 0.14); stroke: var(--ep-accent-sun); stroke-width: 1.2; }
.ep-axis { stroke: var(--ep-ink); stroke-width: 1; stroke-dasharray: 2.5 1.5; }
.ep-eq { fill: none; stroke: var(--ep-accent-sun); stroke-width: 0.8; }
.ep-pole-dot { fill: var(--ep-ink); }
.ep-disk-moon-dark { fill: var(--ep-rule-strong); }
.ep-disk-moon-lit { fill: var(--ep-surface); }
.ep-disk-moon-rim { fill: none; stroke: var(--ep-rule-strong); stroke-width: 1.1; }
.ep-lib-mark { stroke: var(--ep-accent); stroke-width: 1; }
.ep-lib-dot { fill: var(--ep-accent); }

/* ---- Sheet Footer ---- */
.ep-sheet-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 5px;
  margin-top: 6px;
  border-top: 1px solid var(--ep-rule-strong);
  font-size: 8.5px;
  color: var(--ep-muted);
  letter-spacing: 0.04em;
}

/* ---- Responsive (tablets & phones 320px..900px) ---- */
@media (max-width: 920px) {
  .ep-grid-2,
  .ep-grid-3,
  .ep-planets-wrap {
    grid-template-columns: 1fr;
  }

  .ep-viz-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ep-fig-alt {
    grid-column: 1 / -1;
  }

  .ep-planets-tbl,
  .ep-hourly-tbl {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ep-ctrl-actions {
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .ep-page {
    padding: 10px;
    font-size: 10px;
  }

  .ep-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .ep-head-right {
    text-align: left;
  }

  .ep-epoch-row {
    justify-content: flex-start;
  }

  .ep-viz-grid {
    grid-template-columns: 1fr;
  }

  .ep-kv td,
  .ep-kv th {
    white-space: normal;
  }

  .ep-sheet-foot {
    flex-direction: column;
  }
}

/* ---- Print Calibration: Strictly 1 page (Brief) or 2 pages (Extended) ---- */
@media print {
  @page {
    size: auto;
    margin: 7mm 8mm;
  }

  .site-header,
  .site-footer,
  .circumstances,
  .ep-controls,
  .consent,
  .search-dialog {
    display: none !important;
  }

  html,
  body,
  main.page {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    filter: none !important;
  }

  .ep-shell {
    --ep-bg: #ffffff;
    --ep-surface: #ffffff;
    --ep-ink: #000000;
    --ep-muted: #333333;
    --ep-rule: #999999;
    --ep-rule-strong: #000000;
    --ep-tint: #eeeeee;
    --ep-tint-alt: #f7f7f7;
    --ep-accent: #000000;
    --ep-accent-sun: #000000;
    --ep-accent-moon: #444444;
    --ep-band-civ: rgba(0, 0, 0, 0.05);
    --ep-band-naut: rgba(0, 0, 0, 0.1);
    --ep-band-ast: rgba(0, 0, 0, 0.14);
    --ep-band-night: rgba(0, 0, 0, 0.18);
    --ep-epoch-bg: #e5e5e5;
    max-width: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ep-sheet {
    gap: 0;
  }

  .ep-page {
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: #ffffff !important;
    font-size: 7.4pt;
    line-height: 1.24;
  }

  .ep-title {
    font-size: 11.5pt;
  }

  .ep-title-p2 {
    font-size: 9.5pt;
  }

  .ep-kicker,
  .ep-sub,
  .ep-head-right {
    font-size: 7pt;
  }

  .ep-head {
    margin-bottom: 5px;
    padding-bottom: 4px;
  }

  .ep-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px;
    margin-bottom: 5px;
  }

  .ep-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px;
    margin-top: 5px;
  }

  .ep-box {
    padding: 4px 5px;
    break-inside: avoid;
  }

  .ep-sec-h {
    font-size: 7pt;
    margin-bottom: 3px;
    padding-bottom: 2px;
  }

  .ep-kv,
  .ep-ev,
  .ep-table {
    font-size: 6.8pt;
  }

  .ep-kv th,
  .ep-kv td,
  .ep-ev td,
  .ep-table td {
    padding: 1px 3px;
  }

  .ep-ev thead th,
  .ep-table thead th {
    font-size: 6.3pt;
    padding: 1.5px 3px;
  }

  .ep-viz-grid {
    grid-template-columns: minmax(0, 1.85fr) minmax(100px, 0.85fr) minmax(150px, 1.2fr) !important;
    gap: 6px;
  }

  .ep-svg {
    max-height: 98px;
  }

  .ep-planets-wrap {
    grid-template-columns: minmax(0, 1fr) 120px !important;
    gap: 6px;
  }

  .ep-planets-tbl,
  .ep-hourly-tbl {
    display: table !important;
    overflow: visible !important;
  }

  .ep-sheet-foot {
    font-size: 6.4pt;
    margin-top: 4px;
    padding-top: 3px;
  }

  .ep-shell[data-ep-mode="brief"] .ep-page-2 {
    display: none !important;
  }

  .ep-shell[data-ep-mode="extended"] .ep-page-2 {
    display: block !important;
    break-before: page;
    page-break-before: always;
  }
}
