/* ============================================================
   MidnightBot Landing Page — Linear.app Dark Theme
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-bg: #08090a;
  --color-panel: #0f1011;
  --color-surface: #191a1b;
  --color-text: #f7f8f8;
  --color-text-secondary: #d0d6e0;
  --color-text-muted: #8a8f98;
  --color-text-subtle: #62666d;
  --color-accent: #5e6ad2;
  --color-accent-hover: #828fff;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-subtle: rgba(255, 255, 255, 0.05);
  --color-ghost-bg: rgba(255, 255, 255, 0.02);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 9999px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text-secondary);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

/* --- Cosmos Background Canvas --- */
#cosmos-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
  -webkit-backface-visibility: hidden;
}

/* Ensure main content renders above the cosmos canvas */
main,
footer {
  position: relative;
  z-index: 2;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

ul {
  list-style: none;
}

/* --- Utility Classes --- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Button Styles --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.165px;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn--ghost {
  background: var(--color-ghost-bg);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--color-text);
}

.btn--primary {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(94, 106, 210, 0.35);
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--premium {
  background: linear-gradient(135deg, #c084fc, #a855f7);
  color: #fff;
  border-color: transparent;
}

.btn--premium:hover {
  background: linear-gradient(135deg, #a855f7, #9333ea);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.35);
}

.btn--premium:active {
  transform: translateY(0);
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.header__logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__link {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.header__link:hover {
  color: var(--color-text);
  background: var(--color-ghost-bg);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__status {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
  flex-shrink: 0;
}

.header__status-dot--offline {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* --- User Menu --- */
.user-menu {
  position: relative;
}
.user-menu__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-ghost-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.user-menu__trigger:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.14);
}
.user-menu__avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}
.user-menu__arrow {
  font-size: 10px;
  margin-left: 2px;
  color: var(--color-text-subtle);
}
.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  min-width: 180px;
  overflow: hidden;
  z-index: 200;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.user-menu__dropdown--open {
  display: block;
}
.user-menu__dropdown a,
.user-menu__dropdown button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-text-secondary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.user-menu__dropdown a:hover,
.user-menu__dropdown button:hover {
  background: rgba(255,255,255,0.04);
  color: var(--color-text);
}
.user-menu__dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}
.user-menu__dropdown button {
  color: #ef4444;
}
.user-menu__dropdown button:hover {
  color: #f87171;
}

/* --- Hero Section --- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  overflow: hidden;
}

.hero__glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(
    circle at center,
    rgba(94, 106, 210, 0.18),
    rgba(94, 106, 210, 0.06) 35%,
    transparent 70%
  );
  pointer-events: none;
  animation: heroPulse 6s ease-in-out infinite alternate;
}

@keyframes heroPulse {
  0% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid #23252a;
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.12px;
  margin-bottom: 28px;
}

.hero__badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.hero__headline {
  font-size: 64px;
  font-weight: 500;
  letter-spacing: -1.4px;
  line-height: 1;
  color: var(--color-text);
  margin-bottom: 16px;
}

.hero__subtitle {
  font-size: 64px;
  font-weight: 500;
  letter-spacing: -1.4px;
  line-height: 1;
  color: var(--color-accent);
  margin-bottom: 24px;
}

.hero__description {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text-muted);
  max-width: 560px;
  margin: 0 auto 40px;
}

.hero__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* --- Section Base --- */
.section {
  padding: 120px 24px;
}

.section__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.section__heading {
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.7px;
  line-height: 1.25;
  color: var(--color-text);
  margin-bottom: 16px;
}

.section__subheading {
  font-size: 17px;
  font-weight: 400;
  color: var(--color-text-muted);
  max-width: 560px;
  margin-bottom: 56px;
}

.section--centered {
  text-align: center;
}

.section--centered .section__subheading {
  margin-left: auto;
  margin-right: auto;
}

/* --- Features Section --- */
.features {
  position: relative;
}

.features__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  position: relative;
  overflow: visible;
  background: var(--color-ghost-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: transform var(--transition-base), border-color var(--transition-base),
    box-shadow var(--transition-base);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

.feature-card:nth-child(1) { animation-delay: 0.05s; }
.feature-card:nth-child(2) { animation-delay: 0.1s; }
.feature-card:nth-child(3) { animation-delay: 0.15s; }
.feature-card:nth-child(4) { animation-delay: 0.2s; }
.feature-card:nth-child(5) { animation-delay: 0.25s; }
.feature-card:nth-child(6) { animation-delay: 0.3s; }

.feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(94, 106, 210, 0.12);
}

.feature-card__icon {
  font-size: 28px;
  margin-bottom: 16px;
  display: block;
}

.feature-card__title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.2px;
  color: var(--color-text);
  margin-bottom: 8px;
}

.feature-card__desc {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.165px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.feature-card__badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.08px;
  color: #d4a84b;
  background: rgba(240, 168, 48, 0.1);
  border: 1px solid rgba(240, 168, 48, 0.2);
  border-radius: 99px;
  padding: 3px 10px;
  margin-top: 10px;
  line-height: 1.4;
}

/* --- Feature Card Hover Previews --- */
.feature-card__preview {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 40px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.08), rgba(240, 168, 48, 0.06));
  border: 1px solid rgba(88, 101, 242, 0.3);
  border-radius: var(--radius-md);
  box-shadow: 0 0 50px rgba(88,101,242,0.25), 0 0 100px rgba(88,101,242,0.1), 0 8px 32px rgba(0,0,0,0.6);
  padding: 4px;
  pointer-events: none;
}

.feature-card__preview img {
  display: block;
  max-width: 550px;
  height: auto;
  border-radius: calc(var(--radius-md) - 4px);
}

.feature-card__preview--multi {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.feature-card__preview--multi img {
  max-width: 420px;
  height: auto;
  flex-shrink: 0;
  border-radius: calc(var(--radius-md) - 4px);
}

/* Hover reveal */
.feature-card:hover .feature-card__preview {
  opacity: 1;
  visibility: visible;
}

/* 3rd-column fix: flip to right-aligned so it doesn't overflow viewport */
@media (min-width: 1025px) {
  .feature-card:nth-child(3n) .feature-card__preview {
    left: auto;
    right: 0;
    transform: none;
  }
}

/* Portaled state — preview is moved to document.body via JS */
.feature-card__preview--portaled {
  position: fixed;
  z-index: 100;
  bottom: auto;
  left: auto;
  transform: none;
}

/* --- Preview Backdrop (JS-managed, sibling of .features) --- */
.preview-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.preview-backdrop--active {
  opacity: 1;
}

/* --- How It Works Section --- */
.how {
  background: var(--color-panel);
  border-top: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
}

.how__steps {
  display: flex;
  gap: 40px;
  counter-reset: step;
}

.how__step {
  flex: 1;
  position: relative;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

.how__step:nth-child(1) { animation-delay: 0.1s; }
.how__step:nth-child(2) { animation-delay: 0.2s; }
.how__step:nth-child(3) { animation-delay: 0.3s; }

.how__step::before {
  counter-increment: step;
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  margin: 0 auto 20px;
}

.how__step-title {
  font-size: 19px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.how__step-desc {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.165px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

/* --- Large Button --- */
.btn--large {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 500;
}

/* --- Hero Permissions Note --- */
.hero__permissions-note {
  font-size: 13px;
  color: var(--color-text-subtle);
  max-width: 380px;
  text-align: center;
  line-height: 1.5;
}

/* --- Permissions List --- */
.permissions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.permissions-list li {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.permissions-list li:hover {
  border-color: var(--color-border);
}

.permissions-list__icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
}

.permissions-list li strong {
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
}

.permissions-list li p {
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* --- Form notice (shared with dashboard) --- */
.form-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

/* --- CTA Section --- */
.cta {
  text-align: center;
}

.cta__heading {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.8px;
  line-height: 1.15;
  color: var(--color-text);
  margin-bottom: 12px;
}

.cta__subtext {
  font-size: 17px;
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

.cta__footer-text {
  font-size: 14px;
  color: var(--color-text-subtle);
  margin-top: 20px;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--color-border-subtle);
  padding: 32px 24px;
}

.footer__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.footer__copyright {
  grid-column: 1;
  font-size: 14px;
  color: var(--color-text-subtle);
}

/* Community link: centered in the middle column */
.footer__link--community {
  grid-column: 2;
  text-align: center;
  justify-self: center;
}

.footer__links {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 20px;
  white-space: nowrap;
}

.footer__link {
  font-size: 14px;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.footer__link:hover {
  color: var(--color-text-secondary);
}

/* Community link: centered between copyright and links */
.footer__link--community {
  text-align: center;
}
.footer__link--community strong,
.footer__link--highlight {
  font-weight: 600;
  text-decoration: underline;
}

/* Mobile: stack vertically, community on top, centered */
@media (max-width: 768px) {
  .footer__inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  .footer__link--community {
    width: 100%;
    order: -1;
  }
}

/* --- Intersection Observer Fade-In (CSS-only fallback) --- */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive: Tablet (768px–1024px) --- */
@media (max-width: 1024px) {
  .hero__headline,
  .hero__subtitle {
    font-size: 48px;
    letter-spacing: -1px;
  }

  .features__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section {
    padding: 80px 24px;
  }
}

/* --- Responsive: Mobile (<768px) --- */
@media (max-width: 768px) {
  .header__nav {
    display: none;
  }

  .hero {
    min-height: auto;
    padding: 100px 20px 80px;
  }

  .hero__headline,
  .hero__subtitle {
    font-size: 38px;
    letter-spacing: -0.8px;
  }

  .hero__description {
    font-size: 16px;
  }

  .hero__glow {
    width: 400px;
    height: 400px;
  }

  .hero__badge {
    margin-bottom: 36px;
  }

  .features__grid {
    grid-template-columns: 1fr;
  }

  .feature-card__preview img,
  .feature-card__preview--multi img {
    max-width: 100%;
  }

  .how__steps {
    flex-direction: column;
    gap: 32px;
  }

  .how__step {
    text-align: center;
  }

  .how__step::before {
    margin-left: auto;
    margin-right: auto;
  }

  .section {
    padding: 60px 20px;
  }

  .section__heading {
    font-size: 26px;
  }

  .cta__heading {
    font-size: 28px;
  }

  .footer__inner {
    flex-direction: column;
    text-align: center;
  }

  .footer__links {
    flex-direction: column;
    align-items: center;
    white-space: normal;
  }
}
