/* solar.css v2.2 February 03 2026 */

/* ===== Base SVG styling ===== */
path { fill:none; stroke-linecap:round; stroke-linejoin:round; }
text { font: 12px sans-serif; }

/* ===== Theme variables (single source) ===== */
:root{
  --bg:#fff;
  --fg:#111;
  --stroke:#000;
  --panel:transparent;
  --panel-2:transparent;
  --border:rgba(0,0,0,0.25);
  --focus:#4994ec;
  --halo:rgba(255,255,255,0.85);
  --sun:#f00;
  --moon:#666;
  --sun-time: #d9822b;
  --moon-time: #bfa84a;
  --sun-halo: rgba(255,255,255,0.85);
  --solar-hue:#c94a4a;
  --sidereal-hue:#3f6fd8;
  color: var(--fg);
  background: var(--bg);
}

/* Auto dark unless forced light */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#444444;
    --fg:#dddddd;
    --stroke:#bbb;
    --panel:rgba(255,255,255,0.06);
    --panel-2:rgba(255,255,255,0.12);
    --border:rgba(255,255,255,0.25);
    --focus:#7fb0ff;
    --halo:rgba(0,0,0,0.85);
    --sun:#ff6a6a;
    --moon:#bbb;
    --sun-time: #ffb74d;
    --moon-time: #ffe082;
    --sun-halo: rgba(0,0,0,0.85);
    --solar-hue:#ff8a80;
    --sidereal-hue:#82b1ff;
    color-scheme: dark;
  }
}

/* Manual overrides */
:root[data-theme="light"]{ color-scheme: light; }
:root[data-theme="dark"]{
  --bg:#444444;
  --fg:#dddddd;
  --stroke:#bbb;
  --panel:rgba(255,255,255,0.06);
  --panel-2:rgba(255,255,255,0.12);
  --border:rgba(255,255,255,0.25);
  --focus:#7fb0ff;
  --halo:rgba(0,0,0,0.85);
  --sun:#ff6a6a;
  --moon:#bbb;
  --sun-time: #ffb74d;
  --moon-time: #ffe082;
  --sun-halo: rgba(0,0,0,0.85);
  --solar-hue:#ff8a80;
  --sidereal-hue:#82b1ff;
  color-scheme: dark;
}

/* ===== Controls layout ===== */
#header{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  padding-top:6px;
}

#controls{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  padding:0 10px 8px;
  background: var(--bg);
}

.controls-row{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  align-items:center;
  gap:10px;
  background: var(--bg);
}

.ctrl-group{
  display:flex;
  gap:8px;
  align-items:center;
  flex:0 1 auto;
}

.field{
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.field label{ opacity:0.7; }

#groupTheme {
  display:none;
  /*align-self:end;
  margin-bottom:1px; */
}

@media (orientation: landscape){
  #header{ gap:4px; }
  #controls{ padding-bottom:4px; }
  #controlsBottom label{ font-size:10px; }
}

/* ===== Bottom toggles row ===== */
#controlsBottom{
  padding-top:2px;
  border-top:1px solid rgba(0,0,0,0.08);
  gap:10px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) #controlsBottom{
    border-top-color: rgba(255,255,255,0.12);
  }
}
:root[data-theme="dark"] #controlsBottom{
  border-top-color: rgba(255,255,255,0.12);
}

#controlsBottom .field{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:4px;
}
#controlsBottom label{ font-size:11px; opacity:0.85; }
#controlsBottom input[type="checkbox"]{ transform:translateY(1px); }

/* ===== Time readouts ===== */
.time-info{ font-size:12px; opacity:0.85; white-space:nowrap; }
.time-solar{ color:var(--solar-hue); font-variant-numeric:tabular-nums; }
.time-sidereal{ color:var(--sidereal-hue); font-variant-numeric:tabular-nums; }
.time-rise i.wi { margin-right: 4px; vertical-align: -1px; }
.time-rise { font-variant-numeric: tabular-nums; }
.time-sunrise,
/* .time-sunset { color: var(--sun-time); }
.time-moonrise,
.time-moonset { color: var(--moon-time); } */
#sunRiseSet { color: var(--sun-time); }
#moonRiseSet { color: var(--moon-time); }

/* ===== Collapsable more menu ===== */
#groupMore{ position: relative; }

.menu{
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 8px;
  display: none;
  z-index: 9999;
}

.menu.is-open{ display: block; }

.menu__item{
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

.menu__item:hover{ background: var(--hover); }

.menu__sep{
  height: 1px;
  background: var(--stroke-soft);
  margin: 6px 0;
}

.menu__section{ margin-bottom: 6px; }
.menu__label{
  font-size: 11px;
  opacity: 0.75;
  padding: 4px 6px 6px;
}

/* Theme segment buttons */
.menu__seg{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 0 2px 6px;
}

.menu__seg .menu__item{
  text-align: center;
  padding: 6px 0;
  border: 1px solid var(--border);
  background: var(--panel);
}

.menu__seg .menu__item.is-active{
  outline: 1px solid var(--focus);
  outline-offset: 1px;
}

.menu__danger{ color: #e53935; }


/* ===== Buttons + inputs (single unified system) ===== */
button, select, input, textarea { font: 12px sans-serif; }

button,
select,
input[type="number"],
input[type="date"],
input[type="time"],
.icon-btn{
  -webkit-appearance:none;
  appearance:none;
  padding:6px 10px;
  border:1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  border-radius:8px;
}

button, .icon-btn{ cursor:pointer; }
button:hover, .icon-btn:hover{ background: var(--panel-2); }
button:active, .icon-btn:active{ transform: translateY(1px); }

/* Export buttons */
#export-controls{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:10px;
  padding:8px 0 12px;
}

select,
input[type="number"],
input[type="date"],
input[type="time"]{
  padding:6px 8px;
  field-sizing: content;
  outline:none;
}

/* Consistent checkbox colour */
input[type="checkbox"]{ accent-color: var(--fg); }

/* Disabled coord fields (consistent across desktop + iOS) */
.field input:disabled{
  opacity:0.45;
  cursor:not-allowed;
  background: rgba(0,0,0,0.04);
}
:root[data-theme="dark"] .field input:disabled{
  background: rgba(255,255,255,0.04);
  opacity:0.5;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .field input:disabled{
    background: rgba(255,255,255,0.04);
    opacity:0.5;
  }
}

/* Remove number spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button{ -webkit-appearance:none; margin:0; }
input[type=number]{ -moz-appearance:textfield; }

/* Focus + invalid */
:focus{ outline:none; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible{
  outline: 1px solid var(--focus);
  outline-offset: 1px;
}
input:invalid{ border-color:#e53935; }
input:invalid:focus-visible{ box-shadow: 0 0 0 2px rgba(229,57,53,0.25); }

/* ===== Waiting overlay ===== */
#waiting{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  text-align:center;
  pointer-events:none;
  opacity:0;
}
#waiting > div{
  pointer-events:auto;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,0.18);
  background: rgba(255,255,255,0.85);
  max-width:360px;
}
#waiting b{ font-size:18px; line-height:1.35em; }

/* Theme-aware waiting panel */
:root[data-theme="dark"] #waiting > div{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) #waiting > div{
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.10);
  }
}

/* ===== Chart strokes / labels ===== */
.horizon{ stroke: var(--stroke); stroke-width:1.5px; }
.graticule{ stroke: var(--stroke); stroke-opacity:.15; }

.solar-path{ stroke: var(--sun); stroke-width:2px; }
.moon-path{ stroke: var(--moon); stroke-width:2px; stroke-dasharray:8 6; opacity:0.9; }

.ticks line{ stroke: var(--stroke); }
.ticks text{ text-anchor: middle; }

.azimuth-cardinal{ font-weight:bold; font-size:14px; }
.azimuth-degree{ font-size:10px; }

.ticks--azimuth text,
.ticks--elevation text{
  fill: var(--fg) !important;
}

/* Sun marker + halo */
.sun circle{ fill: var(--sun); stroke: var(--stroke); }
.sun text{
  text-anchor: middle;
  paint-order: stroke fill;
  stroke: var(--sun-halo);
  stroke-width: 3px;
  stroke-linejoin: round;
  fill: var(--fg) !important;
}

/* Tick label halos */
.ticks--sun text,
.ticks--moon text{
  paint-order: stroke fill;
  stroke: var(--halo);
  stroke-width:3px;
  stroke-linejoin:round;
  fill: var(--fg);
}

/* Moon labels + icon */
.moon text{
  paint-order: stroke fill;
  stroke: var(--sun-halo);
  stroke-width:3px;
  stroke-linejoin:round;
  fill: var(--fg);
}
.moon .moon-label{ font-size:11px; }
.moon-label--altitude{ font-variant-numeric: tabular-nums; }

/* Tick marker circles */
.ticks--sun circle{ fill: var(--sun); stroke: var(--stroke); stroke-width:1px; }
.ticks--moon circle{ fill: var(--moon); stroke: var(--stroke); stroke-width:1px; opacity:0.9; }

/* Twilight rings */
.civil-twilight{ stroke: var(--stroke); stroke-opacity:0.35; stroke-width:1px; stroke-dasharray:6 6; }
.nautical-twilight{ stroke: var(--stroke); stroke-opacity:0.25; stroke-width:1.2px; stroke-dasharray:4 6; }
.astronomical-twilight{ stroke: var(--stroke); stroke-opacity:0.18; stroke-width:1px; stroke-dasharray:2 6; }

/* ===== Modal ===== */
.modal{ position:fixed; inset:0; display:none; z-index:9999; }
.modal.is-open{ display:block; }
.modal__backdrop{ position:absolute; inset:0; background: rgba(0,0,0,0.45); }
.modal__panel{
  position:relative;
  width: min(640px, calc(100vw - 24px));
  margin: 10px auto;
  top: 6vh;
  background: var(--bg);
  color: var(--fg);
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  overflow:hidden;
}
.modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  background: var(--panel);
  border-bottom:1px solid var(--border);
}
.modal__title{ font:14px sans-serif; font-weight:600; }
.modal__body{ padding:12px; overflow:auto; max-height: calc(80vh - 96px); }
.modal__footer{
  padding:10px 12px;
  border-top:1px solid var(--border);
  background: var(--panel);
  display:flex;
  justify-content:flex-end;
  gap:8px;
}
.modal .btn{
  -webkit-appearance:none;
  appearance:none;
  padding:6px 12px;
  border:1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  border-radius:8px;
  cursor:pointer;
}
.modal .btn:hover{ background: var(--panel-2); }
.modal .btn:active{ transform: translateY(1px); }
