/* theme/assets/css/app.css  */

body.page-app {
    margin: 0;
    padding: 0;
}

body > header {
  font-family: none;
  pointer-events: auto;
}

main {
  margin: 0 auto;
}

h1, p, .app-nav {
  user-select: none;
}

.app-nav {
    color: var(--ff-fg);
    padding: 1rem;
    text-align: right;
    cursor: pointer;
}

body > nav ul > li:nth-last-of-type(5),
body > nav ul > li:nth-last-of-type(4),
body > nav ul > li:nth-last-of-type(3),
body > nav ul > li:nth-last-of-type(2) {
    display: none;
}

body > nav ul > li:nth-last-of-type(3) {
  display: block !important;
}

/* Profile dropdown visibility for app - only show when authenticated */
body.page-app #profile-dropdown-container {
  visibility: hidden !important;
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.page-app #profile-dropdown-container.authenticated {
  visibility: visible !important;
  opacity: 1;
}

#app-page-html {
  margin: 0;
}

#app-page-html,
.login-container {
  display: grid;
}

body.firefly-page.page-app .app-shell-head {
  margin-bottom: 0;
}

body.firefly-page.page-app .app-shell-head .overline {
  margin: 0;
}

body.firefly-page.page-app .app-shell-head h1 {
  margin: 0;
}

body.firefly-page.page-app #app-page-html {
  color: var(--ff-fg-muted);
}

body.firefly-page.page-app #app-page-html p {
  margin: 0;
  color: var(--ff-fg-muted);
}

/* Pipeline explanation section on the /app landing.
   Three cards explain the WP page → snippet → SPA view pipeline. */
body.firefly-page.page-app .pipeline-section,
body.firefly-page.page-app-login .pipeline-section {
  padding-block-start: clamp(1.5rem, 3vw, 2.5rem);
  padding-block-end: clamp(2rem, 4vw, 3rem);
}

body.firefly-page.page-app .pipeline-grid,
body.firefly-page.page-app-login .pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}

body.firefly-page.page-app .pipeline-card,
body.firefly-page.page-app-login .pipeline-card {
  border: 1px solid var(--ff-border);
  background: var(--ff-surface);
  border-radius: var(--ff-radius-lg);
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

body.firefly-page.page-app .pipeline-card .overline,
body.firefly-page.page-app-login .pipeline-card .overline {
  margin: 0;
  color: var(--ff-amber);
}

body.firefly-page.page-app .pipeline-card h3,
body.firefly-page.page-app-login .pipeline-card h3 {
  margin: 0;
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  color: var(--ff-fg);
  letter-spacing: -0.01em;
}

body.firefly-page.page-app .pipeline-card p,
body.firefly-page.page-app-login .pipeline-card p {
  margin: 0;
  color: var(--ff-fg-muted);
  line-height: 1.55;
  font-size: 0.9375rem;
}

/* PWA-specific adjustments to nav */
.offline-indicator {
    background-color: #ff4d4d;
    color: white;
    text-align: center;
    padding: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    z-index: 1000;
}

body.is-offline .offline-indicator {
    display: block;
}

/* Make sure URLs in the menu work properly in the PWA context */
body > nav a {
    text-decoration: none;
}

/* Ensure the site name is correct */
#site-name {
    color: white;
    font-weight: bold;
}

/* App login layout (dark / amber) */
body.firefly-page.page-app-login .app-auth-hero {
  padding-top: clamp(5rem, 12vh, 8rem);
  padding-bottom: clamp(2rem, 5vw, 4rem);
}

body.firefly-page.page-app-login .app-auth-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  max-width: 760px;
  margin-inline: auto;
  opacity: 1;
  transform: none;
}

body.firefly-page.page-app-login .app-auth-head {
  margin-bottom: 0;
}

body.firefly-page.page-app-login .app-auth-card {
  border: 1px solid var(--ff-border);
  background: var(--ff-surface);
  border-radius: var(--ff-radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-sizing: border-box;
}

body.firefly-page.page-app-login #login-error-msg {
  color: #ff8f8f;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}

body.firefly-page.page-app-login .form-title {
  margin: 0 0 1.25rem;
  color: var(--ff-fg);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}

body.firefly-page.page-app-login .input-group {
  margin-bottom: 0.875rem;
  text-align: left;
}

body.firefly-page.page-app-login .input-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-family: var(--ff-font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ff-fg-muted);
}

body.firefly-page.page-app-login .input-group input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-sm);
  background: var(--ff-bg);
  color: var(--ff-fg);
  box-sizing: border-box;
}

body.firefly-page.page-app-login .input-group input:focus {
  border-color: var(--ff-amber-ring);
  outline: none;
  box-shadow: 0 0 0 3px var(--ff-amber-soft);
}

body.firefly-page.page-app-login .btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}

body.firefly-page.page-app-login .divider {
  position: relative;
  text-align: center;
  margin: 1rem 0;
  font-size: 0.75rem;
  color: var(--ff-fg-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.firefly-page.page-app-login .divider::before,
body.firefly-page.page-app-login .divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--ff-border);
}

body.firefly-page.page-app-login .divider::before { left: 0; }
body.firefly-page.page-app-login .divider::after { right: 0; }

body.firefly-page.page-app-login .google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

body.firefly-page.page-app-login .google-btn img {
  width: 18px;
  height: 18px;
}

body.app-shell footer {
  width: 100vw;
  height: 20vh;
  display: grid;
  background: #1a1a1a;
  color: white;
  place-content: center;
}

/* SPA view transitions: app-root fades both ways. The transition
   sequence is choreographed in JS (getView) — old content fades out,
   loader fades in, fetch, new content fades in, loader fades out. Each
   phase is awaited so they never overlap. */
#app-root {
    transition: opacity 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#app-root.is-leaving {
    opacity: 0;
    pointer-events: none;
}

/* On-brand amber loader (matches .dash-spinner). */
#loader {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#loader.is-visible {
    opacity: 1;
}

#loader .ff-app-loader-ring {
    display: block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--ff-border);
    border-top-color: var(--ff-amber);
    border-radius: 50%;
    animation: dash-spin 720ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    #app-root,
    #loader {
        transition: none !important;
    }
    #loader .ff-app-loader-ring {
        animation: none !important;
    }
}

.offline-indicator {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #333;
  color: white;
  padding: 8px;
  text-align: center;
  font-size: 14px;
  z-index: 9999;
  display: none;
  pointer-events: none;
}

body.is-offline .offline-indicator {
  display: block;
}

[aria-hidden="true"] {
  display: none;
}

/* PWA-specific overrides for nav.css */
@media (max-width: 800px) {
    main {
        margin-top: 10vh;
    }
    
    #logo-name {
        font-size: 1.2rem;
    }
}

/* If the menu uses WordPress admin URLs, transform them to app paths */
body > nav a[href*="/wp-admin/"] {
    display: none; /* Hide admin links in the PWA */
}
