﻿:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --ink: #1e1b4b;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-soft: rgba(99, 102, 241, 0.1);
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.1);
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(30, 27, 75, 0.06);
  --font-heading: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

/* ── BS4→5 utility polyfills (project uses Bootstrap 4.3.1) ── */
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.me-auto { margin-right: auto !important; }
.ms-auto { margin-left: auto !important; }
.me-2 { margin-right: 0.5rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }

/* ── Global icon + text alignment ── */

/* Bootstrap Icons: optical baseline alignment for inline contexts */
[class*="bi-"] {
  vertical-align: -0.125em;
}

/* Warm journal-paper canvas with Journalyse brand orbs */
html,
body,
html.bg-texture,
body.bg-base {
  min-height: 100vh;
  background-color: #f8f7f4 !important;
  background-image:
    radial-gradient(900px 900px at 18% 18%, rgba(99, 102, 241, 0.06), transparent 55%),
    radial-gradient(850px 850px at 82% 12%, rgba(245, 158, 11, 0.04), transparent 50%),
    radial-gradient(600px 600px at 50% 85%, rgba(99, 102, 241, 0.03), transparent 40%) !important;
  background-size: auto !important;
  background-attachment: fixed !important;
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
}

body.bg-base {
  position: relative;
}

.page-shell {
  padding-top: 1.5rem;
  position: relative;
  isolation: isolate;
}

.navbar.nav-glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

/* Make collapse fill remaining space so me-auto / ms-auto work */
.navbar-collapse {
  flex-grow: 1;
}

.navbar-brand {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  transition: all 200ms ease;
}

.navbar-brand:hover {
  opacity: 1;
}

.brand-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-mark {
  display: block;
  flex-shrink: 0;
  transition: transform 300ms ease, filter 300ms ease;
  filter: drop-shadow(0 2px 6px rgba(99, 102, 241, 0.25));
}

.brand-mark circle {
  transition: transform 300ms ease;
  transform-origin: 27px 5px;
}

.navbar-brand:hover .brand-mark {
  transform: scale(1.08) rotate(-3deg);
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.35));
}

.navbar-brand:hover .brand-mark circle {
  transform: scale(1.2);
}

.nav-link-enhanced {
  position: relative;
  color: var(--ink);
  font-weight: 500;
  transition: color 200ms ease;
}

.nav-link-enhanced::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transition: transform 200ms ease;
}

.nav-link-enhanced:hover {
  color: var(--primary);
}

.nav-link-enhanced:hover::after {
  transform: scaleX(1);
}

.nav-badge {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  color: var(--ink);
  font-weight: 500;
}

.nav-link:hover {
  color: var(--primary);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  border: none;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.35);
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.4);
}

.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
  font-weight: 600;
}

.btn-ghost:hover {
  border-color: var(--primary);
}

/* Override BS4's default blue btn-outline-primary with Journalyse indigo */
.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-outline-primary:not(:disabled):not(.disabled).active,
.btn-outline-primary:not(:disabled):not(.disabled):active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.hero-section {
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.06), transparent 35%),
              radial-gradient(circle at 80% 10%, rgba(245, 158, 11, 0.05), transparent 30%),
              radial-gradient(circle at 50% 80%, rgba(99, 102, 241, 0.04), transparent 35%);
  z-index: 0;
}

.hero-section .container {
  position: relative;
  z-index: 1;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 3vw, 2.8rem);
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.lead {
  color: var(--muted);
  line-height: 1.6;
}

.badge.bg-soft {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pill {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.pill-success {
  background: #2ecc71;
}

.feature-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  border: 1px solid var(--border);
}

.check {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95em;
  min-width: 1.1em;
  text-align: center;
  line-height: 1.5;
}

.card-elevated {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface);
}

.bg-secondary-soft {
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.footer {
  background: transparent;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.text-body {
  color: var(--ink);
}

.bg-nav {
  background: #ffffff;
}

.page-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 25%, rgba(245, 158, 11, 0.04), transparent 35%),
              radial-gradient(circle at 85% 10%, rgba(99, 102, 241, 0.05), transparent 30%),
              radial-gradient(circle at 50% 80%, rgba(99, 102, 241, 0.04), transparent 32%);
  z-index: -1;
}

.nav-link-enhanced:focus-visible {
  outline: none;
  color: var(--primary);
}

.nav-link-enhanced:focus-visible::after {
  transform: scaleX(1);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.18);
}

/* ── Entrance animations ── */

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

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

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

/* Navbar slides down on load */
.nav-glass {
  animation: fadeInDown 600ms ease both;
}

/* Hero badge */
.anim-badge {
  animation: fadeInUp 500ms ease both;
  animation-delay: 150ms;
}

/* Hero heading */
.anim-title {
  animation: fadeInUp 600ms ease both;
  animation-delay: 250ms;
}

/* Hero subtitle */
.anim-subtitle {
  animation: fadeInUp 600ms ease both;
  animation-delay: 400ms;
}

/* Hero CTA buttons */
.anim-cta {
  animation: fadeInUp 600ms ease both;
  animation-delay: 550ms;
}

/* Feature card floats in */
.anim-feature {
  animation: fadeInScale 700ms ease both;
  animation-delay: 500ms;
}

/* Scroll-reveal: hidden by default, revealed by IntersectionObserver */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 600ms ease, transform 600ms ease;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children inside a reveal-group */
.reveal-group .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-group .reveal:nth-child(2) { transition-delay: 120ms; }
.reveal-group .reveal:nth-child(3) { transition-delay: 240ms; }
.reveal-group .reveal:nth-child(4) { transition-delay: 360ms; }

/* Feature-card checklist stagger */
.feature-card li {
  opacity: 0;
  transform: translateX(-10px);
  animation: fadeInListItem 400ms ease both;
}

.feature-card li:nth-child(1) { animation-delay: 650ms; }
.feature-card li:nth-child(2) { animation-delay: 780ms; }
.feature-card li:nth-child(3) { animation-delay: 910ms; }

@keyframes fadeInListItem {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Subtle ambient float for the logo spark */
.brand-mark circle {
  animation: sparkFloat 3s ease-in-out infinite;
}

@keyframes sparkFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-0.5px, -1px) scale(1.08); }
}

/* Card hover lift */
.card-elevated {
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.card-elevated:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(30, 27, 75, 0.1);
}

/* Feature card shimmer stripe on hover */
.feature-card {
  position: relative;
  overflow: hidden;
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.feature-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.5) 50%, transparent 60%);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(30, 27, 75, 0.1);
}

.feature-card:hover::after {
  opacity: 1;
  animation: shimmer 1.2s ease;
}

/* Button press micro-interaction */
.btn-primary:active {
  transform: translateY(0) scale(0.97);
  transition: transform 80ms ease;
}

.btn-ghost:active {
  transform: scale(0.97);
  transition: transform 80ms ease;
}

/* Form focus glow animation */
.form-control:focus,
.form-select:focus {
  transition: box-shadow 250ms ease, border-color 250ms ease;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.form-label {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.form-control {
  border-radius: 10px;
  border-color: var(--border);
  padding: 0.75rem 0.9rem;
}

.form-control:focus {
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
}

.form-select {
  border-radius: 10px;
  border-color: var(--border);
  padding: 0.75rem 0.9rem;
  background-color: var(--surface);
}

.form-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
}

.alert-success {
  border-radius: 10px;
  border: 1px solid rgba(46, 204, 113, 0.35);
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.12), rgba(46, 204, 113, 0.08));
  color: #1e7e4c;
  font-weight: 500;
}

.alert-animated {
  animation: slideDown 400ms ease, pulse 800ms ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-title {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  line-height: 1.4;
}

.chip-ghost {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.2);
}

.records-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 1.5rem;
}

.records-timeline::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.2), rgba(245, 158, 11, 0.15));
}

.record-card {
  position: relative;
  padding: 1.15rem 1.25rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  transition: transform 160ms ease, box-shadow 160ms ease;
  animation: floatUp 320ms ease;
}

.record-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.08);
}

.record-card.skeleton {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 24px rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

.record-dot {
  position: absolute;
  left: -0.9rem;
  top: 1.25rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

.record-body {
  display: grid;
  gap: 0.4rem;
}

.record-date {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.record-note {
  color: var(--ink);
}

.records-placeholder .placeholder {
  min-height: 12px;
  background: #e7e5e0;
}

.records-placeholder .record-dot {
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.05);
}

.records-hero {
  padding-top: 3rem;
}

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

.records-empty {
  min-height: 320px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 246, 242, 0.9));
}

.emoji-placeholder {
  font-size: 2.25rem;
}

.placeholder {
  display: inline-block;
  background-color: #e2e2e2;
  border-radius: 6px;
  width: 100%;
  min-height: 12px;
}

.placeholder-glow .placeholder {
  animation: placeholder-glow 1.5s ease-in-out infinite;
}

@keyframes placeholder-glow {
  0% { opacity: 0.45; }
  50% { opacity: 1; }
  100% { opacity: 0.45; }
}

@media (max-width: 767px) {
  .navbar.nav-glass {
    border-radius: 0;
  }

  .hero-title {
    font-size: 2rem;
  }

  .records-timeline {
    padding-left: 1rem;
  }

  .records-timeline::before {
    left: 0.35rem;
  }

  .record-dot {
    left: -0.6rem;
    width: 8px;
    height: 8px;
  }

  .chip {
    font-size: 0.85rem;
    padding: 0.45rem 0.85rem;
  }

  .records-hero {
    padding-top: 2rem;
  }

  .card-elevated {
    margin-left: 0;
    margin-right: 0;
  }

  .navbar-nav {
    padding-top: 0.75rem;
  }

  .navbar-collapse .d-flex {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
  }
}

/* ── Journalyse design refinements ── */

.navbar-brand:hover .brand-text {
  opacity: 0.9;
}

.card-elevated .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
}

.insights-content h2,
.insights-content h3,
.insights-content h4 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.insights-content ul,
.insights-content ol {
  padding-left: 1.5rem;
}

.insights-content li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.btn-check:checked + .btn-outline-primary {
  background: var(--primary);
  border-color: var(--primary);
}

/* ── Insights page ── */

.insights-page .page-title {
  font-size: 1.75rem;
  color: var(--ink);
}

.insights-page-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #e67e00);
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Cards */
.insights-card {
  overflow: hidden;
}

.insights-card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
}

.insights-card-header i {
  color: var(--primary);
}

/* Timeframe toggle group – BS4 btn-group-toggle */
.timeframe-group {
  border-radius: var(--radius);
  overflow: hidden;
  gap: 0 !important;
}

.timeframe-group .btn-outline-primary {
  color: var(--primary);
  border-color: var(--border);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 0.5rem;
  transition: all 180ms ease;
  position: relative;
  z-index: 1;
}

.timeframe-group .btn-outline-primary:hover {
  background: var(--primary-soft);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--primary);
  z-index: 2;
}

.timeframe-group .btn-outline-primary:focus,
.timeframe-group .btn-outline-primary.focus {
  box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.18);
  z-index: 3;
}

.timeframe-group .btn-outline-primary.active,
.timeframe-group .btn-outline-primary:active,
.timeframe-group .btn-outline-primary:not(:disabled):not(.disabled).active,
.timeframe-group .btn-outline-primary:not(:disabled):not(.disabled):active {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(99, 102, 241, 0.3);
  z-index: 4;
}

/* Hide the radio input inside toggle label */
.timeframe-group .btn-outline-primary input[type="radio"] {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

/* Analyse button refinement */
.insights-analyse-btn {
  padding: 0.75rem 2.25rem;
  font-size: 1.05rem;
  border-radius: 12px;
  letter-spacing: -0.01em;
}

/* Badges */
.insights-badge {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  letter-spacing: 0.01em;
}

.insights-badge-cached {
  background: var(--primary-soft);
  color: var(--primary);
}

.insights-badge-fresh {
  background: rgba(46, 204, 113, 0.12);
  color: #1a8a4a;
}

/* Metadata row */
.insights-meta {
  color: var(--muted);
}

.insights-meta i {
  color: var(--primary);
  opacity: 0.7;
}

.insights-meta-sep {
  color: var(--border);
  font-weight: 700;
}

.insights-divider {
  border-color: var(--border);
  opacity: 0.5;
}

/* Warning alert */
.insights-alert-warning {
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: var(--accent-soft);
  color: #92400e;
  font-weight: 500;
}

.insights-alert-warning i {
  color: var(--accent);
}

/* Empty state */
.insights-empty-state {
  border-style: dashed;
  border-color: rgba(99, 102, 241, 0.2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 246, 242, 0.9));
}

.insights-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--primary-soft);
  margin: 0 auto;
}

.insights-empty-icon i {
  font-size: 2.25rem;
  color: var(--primary);
  opacity: 0.6;
}

.insights-empty-state h5 {
  font-family: var(--font-heading);
  color: var(--ink);
  font-weight: 600;
}

/* Sidebar cards */
.insights-sidebar-card {
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.insights-sidebar-card .card-header i {
  color: var(--primary);
}

/* Step numbers */
.insights-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.insights-steps li span:last-child {
  padding-top: 0.15rem;
  line-height: 1.5;
}

.footer span:first-child {
  font-weight: 600;
  color: var(--ink);
}
