/* Palette + component tokens: shared/css/theme.css (load first). */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-dim);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition:
    background 0.22s var(--ease-smooth),
    transform 0.18s var(--ease-smooth),
    box-shadow 0.22s var(--ease-smooth),
    border-color 0.22s var(--ease-smooth),
    filter 0.22s var(--ease-smooth);
  font-family: inherit;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  box-shadow: var(--btn-primary-shadow);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--btn-primary-shadow-hover);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-fg);
  text-shadow: var(--gold-trim-shadow);
  border: 1px solid var(--btn-secondary-border);
  box-shadow: inset 0 0 0 0 transparent;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--btn-secondary-bg-hover);
  border-color: var(--accent-bright);
  box-shadow: var(--btn-secondary-shadow-hover);
}

.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-fg);
  border: 1px solid var(--btn-ghost-border);
}

.btn-ghost:not(:disabled):hover {
  background: var(--btn-ghost-bg-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-fg);
  box-shadow: var(--btn-danger-shadow);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-lg {
  padding: 0.8rem 1.65rem;
  font-size: 0.9rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.loading-card {
  background: var(--card);
  padding: 1.75rem 2.25rem;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  max-width: min(24rem, 92vw);
}

.loading-card #loading-message {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.loading-detail {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-height: 1.1em;
  line-height: 1.35;
}

.loading-progress {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.loading-progress.hidden {
  display: none;
}

.loading-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent, #d9ae42), #f0d78c);
  transition: width 0.15s ease-out;
}

.loading-progress-pct {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--type-gold, #d9ae42);
  min-width: 2.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 0.85rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* —— Insights hub (top layer) —— */
.insights-hub {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(240, 193, 74, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 80%, rgba(90, 127, 196, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #080e1a 0%, #030508 100%);
  overflow: hidden;
}

.insights-hub.hidden {
  display: none;
}

.insights-hub-glow {
  position: absolute;
  width: min(36rem, 90vw);
  height: min(36rem, 90vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 193, 74, 0.18) 0%, transparent 68%);
  filter: blur(28px);
  pointer-events: none;
  animation: hub-glow-pulse 6s ease-in-out infinite;
}

.insights-hub-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 28rem;
  animation: hub-in 0.55s var(--ease-smooth) both;
}

.insights-hub-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.insights-hub-mark {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(240, 193, 74, 0.4),
    0 0 22px rgba(240, 193, 74, 0.45),
    0 0 48px rgba(217, 174, 66, 0.28),
    0 4px 20px rgba(0, 0, 0, 0.4);
}

.insights-hub-mark::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 193, 74, 0.35) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

.insights-hub-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 50%;
}

.insights-hub-title {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 5vw, 2.75rem);
  letter-spacing: 0.02em;
  color: var(--type-gold);
  text-shadow:
    var(--gold-trim-shadow-brand),
    0 0 22px rgba(240, 193, 74, 0.45),
    0 0 44px rgba(217, 174, 66, 0.28);
  line-height: 1.1;
}

.insights-hub-tagline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--type-gold);
  text-shadow: var(--gold-trim-shadow-soft);
  letter-spacing: 0.04em;
}

.insights-hub-lead {
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 22rem;
}

.insights-hub-cta {
  min-width: 11rem;
  animation: welcome-cta-in 0.55s var(--ease-smooth) 0.12s both;
}

@keyframes welcome-cta-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hub-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hub-glow-pulse {
  0%,
  100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

/* —— Sign in (before hub) —— */
.signin-screen {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(240, 193, 74, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 80%, rgba(90, 127, 196, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #080e1a 0%, #030508 100%);
  overflow: hidden;
}

.signin-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(24rem, 100%);
  animation: hub-in 0.55s var(--ease-smooth) both;
}

.signin-card {
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(240, 193, 74, 0.22);
  background: #0c1322;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.signin-card-head {
  padding: 0.7rem 1rem;
  background: #101a2e;
  border-bottom: 1px solid rgba(240, 193, 74, 0.18);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--type-gold);
  text-shadow: var(--gold-trim-shadow-soft);
}

.signin-card-body {
  padding: 1.25rem 1.35rem 1.2rem;
}

.signin-lead {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.signin-error {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--accent-red);
}

.signin-ms-btn {
  width: 100%;
  margin-top: 1.15rem;
  gap: 0.55rem;
}

.signin-ms-mark {
  flex-shrink: 0;
}

.signin-foot {
  margin: 0.85rem 0 0;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.hub-user {
  position: absolute;
  top: 1.15rem;
  right: 1.15rem;
  z-index: 2;
}

.hub-user-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(240, 193, 74, 0.35);
  border-radius: 50%;
  background: #101a2e;
  color: var(--type-gold);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(240, 193, 74, 0.18);
}

.hub-user-btn:hover {
  border-color: var(--accent-bright);
  filter: brightness(1.08);
}

.hub-user-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 14rem;
  padding: 0.65rem 0 0.35rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0c1322;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  text-align: left;
}

.hub-user-name {
  margin: 0;
  padding: 0 0.85rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text);
}

.hub-user-email {
  margin: 0.15rem 0 0.55rem;
  padding: 0 0.85rem 0.55rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.hub-user-signout {
  display: block;
  width: 100%;
  padding: 0.5rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.hub-user-signout:hover {
  background: rgba(240, 193, 74, 0.1);
  color: var(--type-gold);
}

/* —— Portal main menu popup —— */
.portal-menu {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.portal-menu.hidden {
  display: none;
}

.portal-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 8, 0.65);
  backdrop-filter: blur(8px);
}

.portal-menu-card {
  position: relative;
  z-index: 1;
  width: min(20rem, 100%);
  padding: 0.85rem 0.75rem 0.75rem;
  border-radius: 14px;
  background: #0c1322;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: dialog-in 0.2s var(--ease-smooth) both;
}

.portal-menu-header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.35rem 0.4rem 0.95rem;
  margin-bottom: 0.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-menu-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.portal-menu-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1px rgba(240, 193, 74, 0.3),
    0 0 14px rgba(240, 193, 74, 0.35);
}

.portal-menu-brand-name {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--type-gold);
  letter-spacing: 0.02em;
  text-shadow:
    var(--gold-trim-shadow-soft),
    0 0 16px rgba(240, 193, 74, 0.3);
  line-height: 1.15;
}

.portal-menu-prompt {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: var(--gold-trim-shadow-soft);
}

.portal-menu-x {
  display: none;
}

.portal-menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: stretch;
}

.portal-menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 0.75rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 560;
  letter-spacing: 0.02em;
  text-align: center;
  cursor: pointer;
  transition:
    background 0.15s var(--ease-smooth),
    color 0.15s var(--ease-smooth);
}

.portal-menu-item:hover {
  background: rgba(240, 193, 74, 0.1);
  color: var(--type-gold, var(--accent-bright));
}

.portal-menu-item:focus-visible {
  outline: 2px solid rgba(240, 193, 74, 0.5);
  outline-offset: 1px;
}

.portal-menu-item-text,
.portal-menu-item-label,
.portal-menu-item-desc,
.portal-menu-chevron {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .insights-hub-inner,
  .insights-hub-cta,
  .insights-hub-glow,
  .signin-inner,
  .portal-menu-card {
    animation: none;
  }
}

/* —— Themed modal dialog —— */
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.app-dialog.hidden {
  display: none;
}

.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 8, 0.72);
  backdrop-filter: blur(5px);
}

.app-dialog-card {
  position: relative;
  z-index: 1;
  width: min(26rem, 100%);
  padding: 1.35rem 1.5rem 1.4rem;
  border-radius: var(--radius, 14px);
  background: linear-gradient(165deg, #101a2e 0%, #0c1322 55%, #080e1a 100%);
  border: 1px solid var(--card-border-gold);
  box-shadow:
    0 0 0 1px rgba(217, 174, 66, 0.08),
    0 24px 48px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(240, 193, 74, 0.08);
  animation: dialog-in 0.22s var(--ease-smooth, ease) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.app-dialog-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.app-dialog-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.app-dialog-brand-name {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--type-gold);
  text-shadow: var(--gold-trim-shadow-soft);
  letter-spacing: 0.02em;
}

.app-dialog-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.01em;
}

.app-dialog-message {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 1.35rem;
}

.app-dialog[data-mode="alert"] .app-dialog-actions {
  justify-content: center;
}

.app-dialog-actions .btn-ghost {
  min-width: 5.5rem;
}

.app-dialog-actions .btn-primary {
  min-width: 6.5rem;
}

.app-dialog-actions .hidden {
  display: none;
}

.boot-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: #8b0000;
  color: #fff;
  padding: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.boot-banner code {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}


#portal-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

#portal-root.active {
  display: block;
}

#portal-root > .app,
#portal-root > .gb-app {
  height: 100%;
  background: var(--bg-main, var(--bg));
  color: var(--text);
}

.portal-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(240, 193, 74, 0.1) 0%, transparent 55%),
    linear-gradient(180deg, #080e1a 0%, #030508 100%);
}

.portal-placeholder-card {
  width: min(26rem, 100%);
  text-align: center;
  padding: 2rem 1.5rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0c1322;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.portal-placeholder-title {
  margin: 0 0 0.4rem;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--type-gold);
}

.portal-placeholder-desc {
  margin: 0 0 1.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
