/* ══════════════════════════════════════════════════════════════════
   Dashboard — Observatory Command Deck
   Celestial alignment. Orbital precision. Instrument-grade layouts.
   ══════════════════════════════════════════════════════════════════ */

/* ── Entrance animations ───────────────────────────────────────── */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.stagger-0 { animation: riseIn 0.55s var(--ease-spring) 0ms both; }
.stagger-1 { animation: riseIn 0.55s var(--ease-spring) 60ms both; }
.stagger-2 { animation: riseIn 0.55s var(--ease-spring) 120ms both; }
.stagger-3 { animation: riseIn 0.55s var(--ease-spring) 180ms both; }
.stagger-4 { animation: riseIn 0.55s var(--ease-spring) 240ms both; }
.stagger-5 { animation: riseIn 0.55s var(--ease-spring) 300ms both; }
.stagger-6 { animation: riseIn 0.55s var(--ease-spring) 340ms both; }

/* ── Cosmos backdrop ──────────────────────────────────────────── */
.obs-cosmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Coordinate grid overlay ──────────────────────────────────── */
.obs-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  animation: fadeIn 1.2s var(--ease-spring) 0.5s forwards;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 30%, transparent 70%);
}

/* ══════════════════════════════════════════════════════════════════
   LOGIN — Access Gate
   ══════════════════════════════════════════════════════════════════ */

.login-chamber {
  min-height: calc(100vh - var(--nav-h, 56px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 64px;
  position: relative;
  text-align: center;
}

.login-portal {
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.login-portal .hero-kicker {
  animation: riseIn 0.55s var(--ease-spring) 80ms both;
}

.login-portal .hero-h1 {
  margin-top: 16px;
  font-size: clamp(1.7rem, 3.2vw, 2.3rem);
  font-weight: 500;
  line-height: 1.10;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  animation: riseIn 0.55s var(--ease-spring) 140ms both;
}

.login-portal .hero-lede {
  margin-top: 16px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.65;
  animation: riseIn 0.55s var(--ease-spring) 200ms both;
}

/* ── Discord gate button ──────────────────────────────────────── */
.gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: clamp(32px, 4vw, 48px) 0 0;
  padding: 14px 28px;
  background: rgba(14, 14, 20, 0.85);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  animation: riseIn 0.55s var(--ease-spring) 260ms both;
  transition: background 0.3s var(--ease-spring),
              border-color 0.3s var(--ease-spring),
              transform 0.3s var(--ease-spring),
              box-shadow 0.3s var(--ease-spring);
}
.gate-btn:hover,
.gate-btn:focus-visible {
  background: rgba(20, 20, 30, 0.92);
  border-color: rgba(88, 101, 242, 0.28);
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 36px rgba(88, 101, 242, 0.12);
}
.gate-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-disclaimer {
  margin: 28px auto 0;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.55;
  max-width: 36ch;
  text-align: center;
  animation: riseIn 0.55s var(--ease-spring) 320ms both;
}

/* ── Metadata constellation ───────────────────────────────────── */
.login-constellation {
  margin: clamp(60px, 8vw, 88px) auto 0;
  max-width: 640px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(40px, 6vw, 80px);
  text-align: left;
  animation: riseIn 0.55s var(--ease-spring) 380ms both;
}

.login-constellation dl { margin: 0; }

.login-constellation .meta-row {
  padding: 12px 0;
}
.login-constellation .meta-row + .meta-row {
  border-top: 1px solid var(--rule-subtle);
}

@media (max-width: 560px) {
  .login-constellation { grid-template-columns: 1fr; }
  .login-chamber { padding: 32px 20px 48px; }
}

/* Compatibility for the previous login markup still cached/deployed on some VPS builds. */
body > #mainNav + #mainNav {
  display: none;
}

.hero-centered {
  min-height: calc(100vh - var(--nav-h, 56px) - 120px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 24px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-centered .hero-kicker {
  animation: riseIn 0.55s var(--ease-spring) 80ms both;
}

.hero-centered .hero-h1 {
  margin-top: 16px;
  animation: riseIn 0.55s var(--ease-spring) 140ms both;
}

.hero-centered .hero-lede {
  margin-top: 16px;
  animation: riseIn 0.55s var(--ease-spring) 200ms both;
}

.op-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: clamp(32px, 4vw, 48px) 0 0;
  padding: 14px 28px;
  background: rgba(14, 14, 20, 0.85);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  animation: riseIn 0.55s var(--ease-spring) 260ms both;
  transition: background 0.3s var(--ease-spring),
              border-color 0.3s var(--ease-spring),
              transform 0.3s var(--ease-spring),
              box-shadow 0.3s var(--ease-spring);
}

.op-discord:hover,
.op-discord:focus-visible {
  background: rgba(20, 20, 30, 0.92);
  border-color: rgba(88, 101, 242, 0.28);
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 36px rgba(88, 101, 242, 0.12);
}

.op-discord svg,
.op-discord .discord-glyph {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.op-discord .arrow {
  font-size: 11px;
  opacity: 0.6;
}

.op-disclaimer {
  margin-top: 28px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.55;
  max-width: 42ch;
  animation: riseIn 0.55s var(--ease-spring) 320ms both;
}

.op-metadata {
  margin: clamp(24px, 5vw, 52px) auto 0;
  max-width: 640px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(40px, 6vw, 80px);
  padding: 0 24px;
  position: relative;
  z-index: 1;
  text-align: left;
  animation: riseIn 0.55s var(--ease-spring) 380ms both;
}

.op-metadata dl {
  margin: 0;
}

.op-metadata .meta-row {
  padding: 12px 0;
}

@media (max-width: 560px) {
  .hero-centered {
    min-height: calc(100vh - 52px);
    padding: 32px 20px 24px;
  }

  .op-metadata {
    grid-template-columns: 1fr;
    padding: 0 20px;
  }
}

/* ══════════════════════════════════════════════════════════════════
   COMMAND DECK — Main Dashboard
   ══════════════════════════════════════════════════════════════════ */

.deck-shell {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - var(--nav-h, 56px));
  display: grid;
  grid-template-columns: 1fr minmax(360px, 520px) 1fr;
  /* Center: instrument column (command panel centered), sides used for breathing room. */
  align-items: start;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--content-gutter);
  gap: clamp(28px, 6vw, 72px);
}

.deck-primary {
  /* Left column - visual anchor, anomaly lives here */
  padding-top: clamp(40px, 8vh, 80px);
}

.deck-command {
  /* Right column - instrument cluster */
  display: flex;
  flex-direction: column;
  gap: var(--g-5);
  padding-top: clamp(40px, 8vh, 72px);
  padding-bottom: var(--g-8);
  max-width: 520px;
  grid-column: 2;
  justify-self: center;
  width: 100%;
  align-self: start;
}

/* ── Identity banner ──────────────────────────────────────────── */
.identity-banner {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 24px);
}

.identity-avatar {
  width: clamp(52px, 6vw, 64px);
  height: clamp(52px, 6vw, 64px);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  box-shadow: 0 0 0 3px var(--signal-soft);
  flex-shrink: 0;
}

.identity-meta {
  flex: 1;
  min-width: 0;
}

.identity-greeting {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
}

.identity-name {
  margin: 2px 0 0;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.035em;
  color: var(--text-primary);
  word-break: break-word;
}

.identity-sub {
  margin: 6px 0 0;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* ── Instrument panel shell ───────────────────────────────────── */
.instrument {
  position: relative;
  border: 1px solid var(--rule-default);
  border-radius: var(--radius-lg);
  background: linear-gradient(170deg,
    rgba(17, 17, 24, 0.88) 0%,
    rgba(10, 10, 14, 0.94) 100%);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 8px 32px rgba(0, 0, 0, 0.4);
}

.instrument::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
  opacity: 0.5;
  z-index: 1;
}

.instrument-head {
  padding: clamp(18px, 2vw, 24px) clamp(20px, 2.4vw, 28px) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.instrument-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.instrument-title {
  margin: 6px 0 0;
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.instrument-body {
  padding: clamp(16px, 2vw, 20px) clamp(20px, 2.4vw, 28px) clamp(18px, 2vw, 24px);
}

/* ── Sections inside instruments ──────────────────────────────── */
.inst-section {
  padding-top: clamp(14px, 1.6vw, 18px);
  border-top: 1px solid var(--rule-subtle);
}
.inst-section:first-child {
  padding-top: 0;
  border-top: none;
}

.inst-section-label {
  margin: 0 0 10px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ── Data rows ────────────────────────────────────────────────── */
.inst-rows { margin: 0; padding: 0; }

.inst-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--rule-subtle);
}
.inst-rows > .inst-row:first-child {
  border-top: none;
  padding-top: 0;
}

.inst-row dt {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.inst-row dd {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.inst-mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px !important;
  font-weight: 400 !important;
  letter-spacing: 0.02em;
}

.inst-ok { color: var(--green) !important; }
.inst-warn { color: var(--signal) !important; font-size: 11px !important; text-transform: uppercase; letter-spacing: 0.05em; }
.inst-dim { color: var(--text-tertiary) !important; font-weight: 400 !important; }

/* ── Licence blocks ───────────────────────────────────────────── */
.inst-licence {
  padding: 13px 0;
  border-top: 1px solid var(--rule-subtle);
}
.inst-licence:first-child {
  padding-top: 0;
  border-top: none;
}

.inst-licence-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.inst-licence-name {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.inst-licence-badge {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.inst-licence-badge--active { color: var(--green); }
.inst-licence-badge--idle { color: var(--signal); }

/* ── Flash messages ───────────────────────────────────────────── */
.inst-flash {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.45;
  border: 1px solid var(--rule-subtle);
  background: rgba(255, 255, 255, 0.02);
}
.inst-flash--ok { color: var(--green); border-color: var(--green-dim); }
.inst-flash--warn { color: var(--signal); border-color: var(--signal-soft); }

.inst-empty {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: 1.55;
}

/* ── Action cluster ───────────────────────────────────────────── */
.inst-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: clamp(14px, 1.6vw, 18px);
  padding-top: clamp(12px, 1.5vw, 16px);
  border-top: 1px solid var(--rule-subtle);
}

.inst-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: min(100%, 130px);
  padding: 10px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: transparent;
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-spring);
}
.inst-action:hover:not(:disabled),
.inst-action:focus-visible:not(:disabled) {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--rule-strong);
  outline: none;
}
.inst-action:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}

.inst-action--primary {
  border-color: var(--signal-border);
  color: var(--signal);
}
.inst-action--primary:hover:not(:disabled),
.inst-action--primary:focus-visible:not(:disabled) {
  background: var(--signal-soft);
  border-color: var(--signal);
  color: #fff;
}

/* ── Sign out link ────────────────────────────────────────────── */
.identity-signout {
  font: inherit;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(255, 255, 255, 0.10);
  transition: color var(--dur-base) var(--ease-spring);
  margin-top: 4px;
}
.identity-signout:hover,
.identity-signout:focus-visible {
  color: var(--text-primary);
  outline: none;
}

/* ── Pending dot ──────────────────────────────────────────────── */
.pending-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal);
  animation: pulseDot 1.6s ease-in-out infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.32; transform: scale(0.85); }
  50%      { opacity: 0.80; transform: scale(1); }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — Command Deck
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 860px) {
  .deck-shell {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 calc(var(--content-gutter) / 1.5);
  }

  .deck-primary { display: none; }

  .deck-command {
    max-width: 100%;
    justify-self: stretch;
    padding-top: clamp(24px, 6vh, 48px);
    padding-bottom: var(--g-7);
  }

  .identity-name {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
  }
}

@media (max-width: 480px) {
  .deck-shell { padding: 0 16px; }

  .inst-actions { flex-direction: column; }
  .inst-action { width: 100%; min-width: 0; }

  .inst-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .inst-row dd { text-align: left; }
}

/* ══════════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════════ */

.ch-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--g-7) 20px var(--g-8);
  color: var(--text-tertiary);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.ch-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-spring);
}
.ch-footer a:hover { color: var(--text-primary); }
