/* Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root {
  --ui-type-scale: clamp(0.78rem, 0.68rem + 0.5vw, 1rem);
  --ui-title-size: calc(1.125 * var(--ui-type-scale));
  --ui-label-size: calc(0.75 * var(--ui-type-scale));
  --ui-value-size: 1.125rem;
}

body {
  position: relative;
  overflow: hidden;
  background: #000;
  font-family: "Space Grotesk", sans-serif;
}

body.cursor-idle,
body.cursor-idle * {
  cursor: none !important;
}

/* Background */
@keyframes body-background-rotate {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.page-background {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: -1;
  pointer-events: none;
}

.page-background img {
  display: block;
  width: 175vmax;
  height: auto;
  transform: translate(-50%, -50%) rotate(0deg);
  transform-origin: center;
  animation: body-background-rotate 1000s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .page-background img {
    animation: none;
  }
}

/* Layout */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  gap: 16px;
  padding: 16px;
  background: transparent;
}

.left-column {
  display: flex;
  flex-direction: column;
  grid-column: 1;
  gap: 16px;
  min-height: 0;
}

.right-column {
  display: flex;
  flex-direction: column;
  justify-self: end;
  justify-content: flex-start;
  width: min(100%, calc((100dvh - 48px) * 8 / 9));
  gap: 16px;
  min-height: 0;
}

/* Shared Panels */
.panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 12px 20px -12px rgba(255, 255, 255, 0.1);
}

.panel-body {
  width: 100%;
  height: 100%;
  background: #fff;
}

.panel-title {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 2;
  padding: 10px 14px;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.33);
  backdrop-filter: blur(2px);
  color: #fff;
  font-size: var(--ui-title-size);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-transform: capitalize;
  pointer-events: auto;
  cursor: default;
  transition: opacity 200ms ease;
}

.panel-title.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.panel-title.right {
  right: 12px;
  left: auto;
}

/* Mission Clocks */
.mission-status {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.status-panel {
  padding: 14px 16px;
  border-radius: 24px;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(2px);
  color: #fff;
}

.status-label {
  display: block;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--ui-label-size);
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-transform: uppercase;
}

.status-value {
  display: block;
  white-space: nowrap;
  font-family: "Space Mono", monospace;
  font-size: var(--ui-value-size);
  font-weight: 700;
  line-height: 1.15;
}

.status-value small {
  display: inline-block;
  margin-left: 2px;
  font-size: 0.75em;
  text-transform: uppercase;
}

/* Reduce overlay and clock typography on smaller screens. */
@media (max-width: 1180px) {
  :root {
    --ui-title-size: 0.9rem;
    --ui-value-size: 0.6rem;
  }
}

/* Stack the layout for touch-device portrait phones while preserving viewport height. */
@media (max-width: 700px) and (pointer: coarse) and (orientation: portrait) {
  body {
    overflow: hidden;
  }

  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
  }

  .left-column,
  .right-column {
    grid-column: 1;
  }

  .left-column {
    height: 100%;
    min-height: 0;
  }

  .mission-status {
    order: -1;
  }

  .nasa-panel {
    min-height: 0;
    flex: 1 1 auto;
  }

  .right-column {
    justify-self: stretch;
    width: 100%;
    min-height: 0;
  }

  .panel-title.right {
    left: 12px;
    right: auto;
  }
}

/* Mission Tracker */
.nasa-panel {
  flex: 1 1 auto;
}

.nasa-panel .panel-body {
  background: rgba(0, 0, 0, 0.2);
}

.nasa {
  width: 100%;
  height: 100%;
  border: none;
}

/* Video Panels */
.video-panel {
  width: 100%;
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
}

.video-panel .panel-body {
  height: 100%;
  padding: 0;
  background: transparent;
}

.video-frame {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.yt-cell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.yt-cell iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
}
