/* Sol Clock web (sol.html): app-style shell, independent of the main site theme. */
:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --border: rgba(255,255,255,0.09);
  --accent: #f5a623;
  --accent2: #e8c87a;
  --text: #e8e4d8;
  --text-dim: rgba(232,228,216,0.62);
  --tab-h: 56px;
  --banner-h: 64px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* set by the script from the sky colour on the Clock tab */
  --sky: #0a0a0f;
  --clock-text: #e8e4d8;
  --clock-text-dim: rgba(232,228,216,0.62);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; background: var(--bg); color: var(--text); font-family: Georgia, serif; overflow: hidden; }
button { font-family: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ── App Store banner ── */
#banner {
  position: fixed; top: 0; left: 0; right: 0; height: var(--banner-h);
  background: linear-gradient(135deg, #1a1206, #2a1e0a);
  border-bottom: 1px solid rgba(245,166,35,0.25);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; z-index: 100;
}
#banner .b-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
#banner .b-icon {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; font-size: 22px;
  background: radial-gradient(circle at 35% 35%, #ffe066, #f5a623 60%, #b36b00);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(245,166,35,0.4);
}
#banner .b-text { line-height: 1.2; min-width: 0; }
#banner .b-title { font-size: 15px; font-weight: 700; color: var(--accent2); letter-spacing: .02em; }
#banner .b-sub { font-size: 11px; color: var(--text-dim); font-family: var(--sans); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#banner .b-btn {
  background: var(--accent); color: #1a0e00; font-size: 13px; font-weight: 800; padding: 8px 18px; border-radius: 20px;
  text-decoration: none; letter-spacing: .04em; white-space: nowrap; font-family: var(--sans); box-shadow: 0 2px 12px rgba(245,166,35,0.4);
  transition: transform .15s, box-shadow .15s; margin-left: 12px;
}
#banner .b-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(245,166,35,0.6); }

/* ── Layout ── */
#app { position: fixed; top: var(--banner-h); left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; }
#content { flex: 1; overflow: hidden; position: relative; }
.tab-panel { position: absolute; inset: 0; display: none; overflow-y: auto; overflow-x: hidden; }
.tab-panel.active { display: block; }

#tabbar { height: var(--tab-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: stretch; }
.tab-btn {
  flex: 1; background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-dim); transition: color .2s; font-family: var(--sans);
}
.tab-btn .t-icon { font-size: 20px; line-height: 1; }
.tab-btn .t-label { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.tab-btn.active { color: var(--accent); }

/* ── Panel body: stacked (dial, then text) or wide (text | dial) ── */
.panel-body { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 8px 8px 12px; }
.dial-col { order: 1; width: 100%; display: flex; flex-direction: column; align-items: center; }
.text-col { order: 2; width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; }
.dial-box { position: relative; flex-shrink: 0; }
canvas.dial { display: block; }

/* Wide layout: any landscape-shaped area that is wide enough (the app's WideLayout rule). */
@media (min-width: 560px) and (min-aspect-ratio: 5/4) {
  .panel-body { flex-direction: row; align-items: flex-start; gap: 16px; padding: 12px 16px; height: 100%; }
  .text-col { order: 1; width: 280px; flex-shrink: 0; align-items: flex-start; max-width: none; align-self: center; }
  .dial-col { order: 2; flex: 1; min-width: 0; height: 100%; justify-content: flex-start; }
}

/* ── Clock tab: sky-coloured background, text colour chosen for contrast ── */
#clock-panel {
  background-color: var(--sky);
  background-image: linear-gradient(to bottom, rgba(10,10,15,0), rgba(10,10,15,0.4));
  background-attachment: local;
  transition: background-color 60s ease-in-out;
  color: var(--clock-text);
}
#clock-panel .event-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; max-width: 100%; margin-bottom: 12px; }
#clock-panel .event-row .bell { background: none; border: none; cursor: pointer; font-size: 18px; min-width: 28px; min-height: 28px; color: var(--clock-text-dim); }
#clock-panel .event-row.is-alarm .bell { color: var(--clock-text); }
#clock-panel .event-name { font-size: 20px; font-weight: 700; color: var(--clock-text); }
#clock-panel .event-time { font-size: 17px; color: var(--clock-text-dim); font-variant-numeric: tabular-nums; font-family: var(--sans); }
.time-rows { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 6px; font-family: var(--sans); font-size: 15px; font-variant-numeric: tabular-nums; }
.time-rows .k { color: var(--clock-text-dim); }
.time-rows .v { color: var(--clock-text); }

/* ── Sky Map tab ── */
#skymap-panel { background: #080810; }
#skymap-panel .event-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 2px 8px; margin: 6px 0; max-width: 100%; }
#skymap-panel .event-name { font-size: 20px; font-weight: 600; color: var(--text); }
#skymap-panel .event-time { font-size: 16px; font-weight: 600; color: var(--text-dim); font-family: var(--sans); }
#skymap-panel .event-day { font-size: 14px; color: var(--text-dim); font-family: var(--sans); }

.seg { display: flex; width: 100%; max-width: 640px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-family: var(--sans); flex-shrink: 0; margin: 4px 0; }
.seg button {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 13px; padding: 9px 6px;
  border-left: 1px solid var(--border); transition: background .15s, color .15s;
}
.seg button:first-child { border-left: none; }
.seg button[aria-selected="true"] { background: var(--accent); color: #1a0e00; font-weight: 700; }
@media (min-width: 560px) and (min-aspect-ratio: 5/4) {
  .seg { flex-direction: column; max-width: 240px; }
  .seg button { border-left: none; border-top: 1px solid var(--border); text-align: left; padding: 10px 14px; }
  .seg button:first-child { border-top: none; }
}

.info-cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; width: 100%; max-width: 640px; padding: 12px 6px 0; font-family: var(--sans); }
.info-cols .col { display: flex; flex-direction: column; gap: 8px; }
.info-row { font-size: 14px; line-height: 1.3; }
.info-row .lbl { color: var(--text-dim); }
.info-row .val { color: var(--text); font-weight: 600; margin-left: 4px; }
@media (min-width: 560px) and (min-aspect-ratio: 5/4) {
  .info-cols { grid-template-columns: 1fr; padding-top: 10px; }
}

/* ── Location bar ── */
.loc-bar {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 0; padding: 6px 14px; border-radius: 16px;
  background: none; border: none; color: var(--text-dim); font-size: 12px; font-family: var(--sans); cursor: pointer; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.loc-bar .pin, .loc-bar .refresh { color: #4da3ff; }
#clock-panel .loc-bar { color: var(--clock-text-dim); }

/* ── Planisphere tab ── */
#planis-panel { background: #070a14; }
.pl-controls { gap: 10px; padding-top: 6px; font-family: var(--sans); }
.pl-controls select, .pl-controls input[type="datetime-local"] {
  font: inherit; font-size: 14px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: #0c0c12; color: var(--text);
  width: 100%; max-width: 420px; color-scheme: dark;
}
.pl-controls select[size] { padding: 4px; }
.pl-controls select option { padding: 6px 8px; }
.pl-controls select option:checked { background: var(--accent); color: #1a0e00; }
.pl-when { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 420px; flex-wrap: wrap; }
.pl-when input { flex: 1; min-width: 190px; }
.pl-live { background: none; border: 1px solid var(--border); color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 8px 14px; border-radius: 18px; white-space: nowrap; }
.pl-live[aria-pressed="true"] { color: var(--accent); border-color: rgba(245,166,35,0.45); }
.pl-caption { font-size: 12px; line-height: 1.5; color: var(--text-dim); max-width: 420px; }
@media (min-width: 560px) and (min-aspect-ratio: 5/4) {
  .pl-controls { align-items: stretch; width: 280px; }
  .pl-controls select, .pl-when { max-width: none; }
  .pl-controls select[size] { height: min(46vh, 380px); }
}

/* ── Alarms tab ── */
#notif-panel { background: var(--bg); }
#notif-wrap { max-width: 520px; margin: 0 auto; padding: 22px 20px 28px; font-family: var(--sans); }
#notif-wrap h2 { font-size: 18px; font-weight: 400; color: var(--accent2); margin-bottom: 8px; text-align: center; font-family: Georgia, serif; }
#notif-wrap p.sub { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 14px; line-height: 1.5; }
.alarm-status { font-size: 12px; text-align: center; margin: 0 0 14px; color: var(--accent2); min-height: 1.2em; }
.alarm-status.warn { color: #ffb4a8; }
.notif-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.notif-row .nr-main { min-width: 0; }
.notif-row .nr-name { font-size: 14.5px; color: var(--text); }
.notif-row .nr-time { font-size: 12px; color: var(--text-dim); margin-top: 2px; font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: rgba(255,255,255,0.18); border-radius: 24px; transition: background .2s; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--accent2); outline-offset: 2px; }
.notif-cta { display: block; margin: 22px auto 0; text-align: center; font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.notif-cta a { color: var(--accent); text-decoration: underline; }

/* ── First-run location prompt ── */
#loc-prompt { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px; text-align: center; background: var(--bg); }
#loc-prompt h2 { font-size: 20px; font-weight: 400; color: var(--accent2); }
#loc-prompt p { font-size: 14px; color: var(--text-dim); line-height: 1.6; font-family: var(--sans); max-width: 420px; }
.primary-btn {
  background: var(--accent); color: #1a0e00; border: none; cursor: pointer; padding: 12px 28px; border-radius: 24px; font-size: 14px; font-weight: 700;
  font-family: var(--sans); letter-spacing: .04em; box-shadow: 0 2px 16px rgba(245,166,35,0.4);
}
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: 12px; font-family: var(--sans); }
.prompt-alt { font-size: 12px; color: var(--text-dim); font-family: var(--sans); display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* ── Location dialog ── */
dialog.sheet { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; font-family: var(--sans); }
dialog.sheet::backdrop { background: rgba(0,0,0,0.6); }
dialog.sheet h2 { font-size: 18px; font-weight: 400; color: var(--accent2); font-family: Georgia, serif; margin-bottom: 14px; }
dialog.sheet .field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 12px; color: var(--text-dim); }
dialog.sheet input, dialog.sheet select { font: inherit; font-size: 14px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: #0c0c12; color: var(--text); width: 100%; }
dialog.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog.sheet .err { color: #ffb4a8; font-size: 12px; min-height: 1.2em; margin-top: 6px; }
dialog.sheet .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
dialog.sheet .ghost { background: none; border: 1px solid var(--border); color: var(--text); cursor: pointer; padding: 10px 18px; border-radius: 22px; font-size: 13px; }
dialog.sheet hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
dialog.sheet .primary-btn { width: 100%; }

@media (max-width: 520px) { #banner .b-sub { display: none; } }
@media (prefers-reduced-motion: reduce) { #clock-panel { transition: none; } }
