/* Custom styles on top of Tailwind */

:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --brand-teal: #0d9488;
  --brand-teal-deep: #0f766e;
  --brand-teal-bright: #2dd4bf;
  --brand-glow: rgba(20, 184, 166, 0.24);
}

.safe-bottom {
  padding-bottom: var(--safe-bottom);
}

.math-expression {
  font-family: Georgia, 'Times New Roman', serif;
  white-space: nowrap;
}

.math-display {
  display: block;
  margin: 0.4rem 0;
  overflow-x: auto;
  text-align: center;
}

.math-frac {
  display: inline-flex;
  vertical-align: middle;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  margin: 0 0.12em;
}

.math-frac > span:first-child {
  border-bottom: 1px solid currentColor;
  padding: 0 0.18em 0.08em;
}

.math-frac > span:last-child {
  padding: 0.08em 0.18em 0;
}

.math-root > span {
  border-top: 1px solid currentColor;
  padding: 0 0.12em;
}

/* Shared brand treatment: a soft teal atmosphere with luminous primary actions. */
body {
  background-image: radial-gradient(circle at 12% 0%, rgba(45, 212, 191, 0.12), transparent 34rem);
}

.dark body {
  background-image: radial-gradient(circle at 12% 0%, rgba(20, 184, 166, 0.12), transparent 34rem);
}

.bg-primary-600 {
  background-color: var(--brand-teal);
  background-image: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-deep) 100%);
  box-shadow: 0 8px 20px var(--brand-glow);
}

.hover\:bg-primary-700:hover {
  background-color: var(--brand-teal-deep);
  background-image: linear-gradient(135deg, #14b8a6 0%, var(--brand-teal-deep) 100%);
  box-shadow: 0 10px 24px rgba(13, 148, 136, 0.32);
}

.floating-action-button {
  position: fixed;
  right: 1rem;
  bottom: calc(5rem + var(--safe-bottom));
  z-index: 30;
  display: inline-flex;
  width: 3.5rem;
  height: 3.5rem;
  align-items: center;
  justify-content: center;
  color: #fff;
  background-color: var(--brand-teal);
  background-image: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-deep) 100%);
  border-radius: 9999px;
  box-shadow: 0 8px 20px var(--brand-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(13, 148, 136, 0.36);
}

.bg-gradient-to-br.from-primary-600.to-primary-800 {
  background-image: linear-gradient(135deg, #0d9488 0%, #0f766e 58%, #115e59 100%);
  box-shadow: inset 0 -24px 70px rgba(4, 47, 46, 0.16);
}

.bg-primary-50 {
  background-image: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
}

button.bg-primary-600,
a.bg-primary-600 {
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button.bg-primary-600:hover,
a.bg-primary-600:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
}

/* Shared feedback for slow writes and external AI requests */
#network-loader {
  position: fixed;
  top: 4.25rem;
  left: 50%;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  color: #115e59;
  background: linear-gradient(135deg, #ecfeff, #ccfbf1, #d1fae5);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.16);
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#network-loader.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.network-loader-spinner {
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(13, 148, 136, 0.25);
  border-top-color: #0f766e;
  border-radius: 50%;
  animation: networkSpin 0.75s linear infinite;
}

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

.ai-generation-progress {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem;
  color: #134e4a;
  background: #f0fdfa;
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 0.85rem;
}

.ai-generation-progress__heading,
.ai-generation-progress__details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.ai-generation-progress__details {
  color: #475569;
  font-size: 0.7rem;
  font-weight: 500;
}

.ai-generation-progress__track {
  height: 0.5rem;
  overflow: hidden;
  background: #ccfbf1;
  border-radius: 9999px;
}

.ai-generation-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #2dd4bf);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.ai-generation-progress__track[data-indeterminate="true"] .ai-generation-progress__bar {
  animation: aiGenerationIndeterminate 1.4s ease-in-out infinite alternate;
}

.ai-generation-progress__note {
  margin: 0;
  color: #64748b;
  font-size: 0.65rem;
}

.dark .ai-generation-progress {
  color: #ccfbf1;
  background: rgba(15, 118, 110, 0.16);
  border-color: rgba(45, 212, 191, 0.25);
}

.dark .ai-generation-progress__details,
.dark .ai-generation-progress__note {
  color: #cbd5e1;
}

.dark .ai-generation-progress__track {
  background: rgba(45, 212, 191, 0.16);
}

@keyframes aiGenerationIndeterminate {
  from { transform: translateX(-110%); }
  to { transform: translateX(310%); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-generation-progress__track[data-indeterminate="true"] .ai-generation-progress__bar {
    animation: none;
    opacity: 0.55;
  }
}

.loading-skeleton {
  height: 5.25rem;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, rgba(226, 232, 240, 0.7) 25%, rgba(241, 245, 249, 0.95) 37%, rgba(226, 232, 240, 0.7) 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.3s ease-in-out infinite;
}

.dark .loading-skeleton {
  background: linear-gradient(90deg, rgba(31, 41, 55, 0.8) 25%, rgba(55, 65, 81, 0.95) 37%, rgba(31, 41, 55, 0.8) 63%);
  background-size: 400% 100%;
}

@keyframes skeletonShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Antique white gradient background for main content areas */
.bg-antique-gradient {
  background:
    radial-gradient(circle at 92% 8%, rgba(45, 212, 191, 0.14), transparent 24rem),
    linear-gradient(160deg, #faf8f5 0%, #f5f0e8 40%, #ebe3d5 100%);
}

.dark .bg-antique-gradient {
  background:
    radial-gradient(circle at 92% 8%, rgba(20, 184, 166, 0.12), transparent 24rem),
    linear-gradient(160deg, #111827 0%, #1f2937 50%, #111827 100%);
}

/* Smooth page transitions */
.page-enter {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bottom nav active state */
.nav-item.active {
  color: #0d9488;
}
.dark .nav-item.active {
  color: #2dd4bf;
}

/* Form focus rings */
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.22), 0 0 18px rgba(45, 212, 191, 0.16);
}

/* Hide splash after load */
#splash.fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.onboarding-art {
  background: linear-gradient(145deg, rgba(204, 251, 241, 0.9), rgba(240, 253, 250, 0.55));
  border: 1px solid rgba(13, 148, 136, 0.16);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.72), 0 18px 45px rgba(15, 118, 110, 0.12);
}

.dark .onboarding-art {
  background: linear-gradient(145deg, rgba(19, 78, 74, 0.86), rgba(17, 24, 39, 0.72));
  border-color: rgba(45, 212, 191, 0.18);
}

.onboarding-slide {
  animation: onboardingSlideIn 0.35s ease both;
}

@keyframes onboardingSlideIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.pb-builder-dialog {
  width: 100%;
}

.pb-question-order-item {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pb-question-order-item.is-drop-target {
  border-color: #0d9488;
  background-color: rgba(13, 148, 136, 0.08);
}

.dark .pb-question-order-item.is-drop-target {
  background-color: rgba(13, 148, 136, 0.16);
}

[data-question-drag-handle] {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

[data-question-drag-handle]:active {
  cursor: grabbing;
}

.pb-step-panel {
  display: none;
}

.pb-step-panel.is-active {
  display: block;
}

.pb-mobile-stepper {
  display: flex;
  gap: 0.5rem;
  padding: 0.15rem 0 0.35rem;
}

.pb-mobile-stepper button {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.45rem 0.35rem;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
}

.pb-mobile-stepper button span {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: #e2e8f0;
  font-size: 0.65rem;
}

.pb-mobile-stepper button[aria-current="step"] {
  color: #0f766e;
  border-color: #0d9488;
}

.pb-mobile-stepper button[aria-current="step"] span {
  color: #fff;
  background: #0d9488;
}

.pb-mobile-nav {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  margin: 0 -0.75rem -0.75rem;
  padding: 0.75rem;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.dark .pb-mobile-nav {
  background: #111827;
  border-color: #1f2937;
}

.pb-desktop-save {
  display: none;
}

@media (min-width: 640px) {
  .pb-builder-dialog {
    width: min(96vw, 72rem);
  }

  .pb-mobile-nav {
    margin-right: -1rem;
    margin-bottom: -1rem;
    margin-left: -1rem;
  }
}

@media (min-width: 1024px) {
  .pb-step-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: start;
    gap: 1rem;
  }

  .pb-step-panel {
    display: block !important;
  }

  .pb-mobile-stepper,
  .pb-mobile-nav {
    display: none;
  }

  .pb-desktop-save {
    display: block;
  }

  #pb-q-list {
    max-height: 65vh;
  }
}
