@font-face {
  font-family: "Lato";
  src: url("../assets/lato-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Lato";
  src: url("../assets/lato-bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --primary: #3f92b5;
  --primary-dark: #303f9f;
  --accent: #ff7840;
  --topbar-height: 52px;
  --clock-height: 64px;
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-border: rgba(0, 0, 0, 0.14);
  --ink: #20242b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: "Lato", sans-serif;
  color: var(--ink);
  background: #e8eef1;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Top bar --------------------------------------------------------------- */

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  color: #fff;
  background: var(--primary-dark);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}

.brand {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  min-width: 0;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.nav-button.active,
.nav-button[aria-current="page"] {
  background: rgba(255, 255, 255, 0.22);
}

#navToggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

/* Views and map --------------------------------------------------------- */

#main {
  position: absolute;
  inset: 0;
}

.view {
  position: absolute;
  inset: 0;
}

#viewMap {
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: #dfe7eb;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
}

#placeholderView {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--topbar-height) + 16px) 16px calc(var(--clock-height) + 16px);
  background: #eef2f4;
}

.placeholder-card {
  max-width: 420px;
  padding: 22px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.placeholder-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.placeholder-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

/* Floating map controls ------------------------------------------------- */

.floating-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(6px);
}

.floating-btn:hover {
  background: #fff;
}

.floating-btn:active {
  transform: translateY(1px);
}

.top-controls {
  position: absolute;
  top: calc(var(--topbar-height) + 12px);
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: calc(100% - 24px);
}

#skyObjectChoice {
  flex: 0 0 auto;
  color: var(--accent);
}

#infoCard {
  min-width: 190px;
  max-width: min(300px, calc(100vw - 110px));
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(6px);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.info-row + .info-row {
  margin-top: 2px;
}

#infoExtra:empty {
  display: none;
}

#moonPhaseImage {
  display: block;
  width: 36px;
  height: 36px;
  margin: 6px auto 0;
  object-fit: contain;
}

#locationHint {
  position: absolute;
  top: calc(var(--topbar-height) + 14px);
  left: 50%;
  z-index: 9;
  transform: translateX(-50%);
  padding: 6px 12px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  white-space: nowrap;
}

.lower-controls {
  position: absolute;
  right: 12px;
  bottom: calc(var(--clock-height) + 12px);
  z-index: 10;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.control-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  order: 2;
}

#mapToolsPanel {
  order: 1;
  width: 220px;
  max-width: calc(100vw - 24px);
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
}

#mapToolsPanel:not([hidden]) {
  animation: panel-in 180ms ease-out both;
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.tool-row + .tool-row {
  margin-top: 10px;
}

.tool-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.tool-button {
  width: 100%;
  margin-top: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

@keyframes panel-in {
  from {
    transform: translateX(110%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Drawer ---------------------------------------------------------------- */

#drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(300px, 86vw);
  padding: 14px 12px calc(var(--clock-height) + 14px);
  background: #fff;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.28);
  transform: translateX(100%);
  overflow-y: auto;
}

#drawer:not([hidden]),
#drawer.open {
  transform: translateX(0);
}

#drawer:not([hidden]) {
  animation: drawer-in 200ms ease-out both;
}

.drawer-brand {
  padding: 6px 10px 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--primary-dark);
  font-size: 16px;
  font-weight: 700;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
}

.drawer-nav .nav-button {
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 14px;
}

.drawer-nav .nav-button.active,
.drawer-nav .nav-button[aria-current="page"] {
  background: rgba(63, 146, 181, 0.16);
  color: var(--primary-dark);
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Clock bar ------------------------------------------------------------- */

#clockBar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: var(--clock-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.16);
  background: rgba(255, 255, 255, 0.97);
  color: #111;
}

.clock-btn {
  flex: 0 0 auto;
  min-width: 48px;
  height: 40px;
  padding: 6px 9px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #fff;
  color: #111;
  font-size: 12px;
  font-weight: 700;
}

#clockModeButton {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.clock-play {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#clockStrip {
  position: relative;
  flex: 1 1 auto;
  min-width: 60px;
  height: 100%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: linear-gradient(#fafafa, #eef2f4);
  overflow: hidden;
}

#clockTicks {
  position: absolute;
  inset: 0;
  color: #111;
  overflow: hidden;
}

#clockCursor {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
}

#datePicker,
#timePicker {
  position: absolute;
  bottom: calc(100% + 8px);
  z-index: 35;
  max-width: calc(100vw - 20px);
  padding: 8px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #fff;
  color: #111;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

#datePicker {
  right: 104px;
}

#timePicker {
  right: 12px;
}

/* Height dialog --------------------------------------------------------- */

#heightDialog {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

#heightDialog:not([hidden]) {
  display: flex !important;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.46);
}

.dialog-card {
  position: relative;
  width: min(340px, 100%);
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
}

.dialog-card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--primary-dark);
}

.unit-row {
  display: flex;
  gap: 10px;
}

.unit-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

.unit-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

.height-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 700;
}

#heightValue {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 16px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.primary-btn,
.secondary-btn {
  flex: 1 1 0;
  min-height: 42px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.primary-btn {
  border: 0;
  background: var(--primary);
  color: #fff;
}

.secondary-btn {
  border: 1px solid var(--card-border);
  background: #fff;
  color: var(--ink);
}

/* Responsive ------------------------------------------------------------ */

@media (max-width: 720px) {
  :root {
    --topbar-height: 50px;
    --clock-height: 60px;
  }

  .brand {
    font-size: 15px;
  }

  .desktop-nav {
    display: none;
  }

  #navToggle {
    display: inline-flex;
  }

  .top-controls {
    top: calc(var(--topbar-height) + 8px);
    right: 8px;
    gap: 6px;
    max-width: calc(100% - 16px);
  }

  #skyObjectChoice {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
    font-size: 16px;
  }

  #infoCard {
    min-width: 0;
    max-width: calc(100vw - 70px);
    padding: 7px 8px;
    font-size: 11px;
  }

  #locationHint {
    top: calc(var(--topbar-height) + 60px);
    font-size: 11px;
  }

  .lower-controls {
    right: 8px;
    bottom: calc(var(--clock-height) + 8px);
    gap: 6px;
  }

  .control-buttons {
    gap: 6px;
  }

  .floating-btn {
    min-width: 42px;
    min-height: 42px;
    padding: 6px 8px;
    font-size: 16px;
  }

  #mapToolsPanel {
    width: min(220px, calc(100vw - 16px));
    padding: 10px;
  }

  #clockBar {
    gap: 5px;
    padding: 6px;
  }

  .clock-btn {
    min-width: 38px;
    height: 38px;
    padding: 4px 6px;
    font-size: 11px;
  }

  #datePicker {
    right: 82px;
  }

  #timePicker {
    right: 6px;
  }
}

@media (min-width: 721px) {
  #drawer {
    display: none !important;
  }
}
