/* core.css */

:root{
  /* FORCE Light Mode for system UI (scrollbars, inputs) */
  color-scheme: light;

  /* Brand */
  --accent-primary: #ff3b4d;

  /* Focus ring */
  --focus-ring: rgba(255, 59, 77, 0.35);

  /* Header offset */
  --header-offset: 80px;

  /* ---------- THEME VARIABLES (Permanently Light) ---------- */
  --bg-primary: #fbfaf8;
  --text-primary: #0f0f14;
  --text-muted: #5b5b6a;

  /* Surfaces */
  --surface: rgba(255,255,255,0.92);
  --surface-soft: rgba(255,255,255,0.85);
  --surface-muted: rgba(255,255,255,0.78);
  --surface-solid: #ffffff;

  /* Borders */
  --border-weak: rgba(15, 15, 20, 0.08);
  --border: rgba(15, 15, 20, 0.10);
  --border-strong: rgba(15, 15, 20, 0.16);

  /* Shadows */
  --shadow-sm: 0 10px 30px rgba(0,0,0,0.06);
  --shadow-md: 0 18px 40px rgba(0,0,0,0.12);
  --shadow-lg: 0 30px 80px rgba(0,0,0,0.18);

  /* Header */
  --header-bg: rgba(251, 250, 248, 0.92);
  --header-border: rgba(15, 15, 20, 0.08);

  /* Overlay & Footer */
  --overlay-red: #ff3b4d;
  --overlay-dark: #160b22;
  --text-on-color: #ffffff;
  --text-on-dark-muted: #a0a0a0;

  --footer-bg: #0b0b10;
  --footer-text: #f2f2f5;
  --footer-muted: rgba(242, 242, 245, 0.72);
  --footer-border: rgba(242, 242, 245, 0.12);
}

/* ===================================
   GLOBAL STYLES
   =================================== */
html, body { overflow-x: clip; }

body{
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,h2,h3,h4,h5,h6,.font-heading{
  font-family: "Poppins", sans-serif;
}

.no-scroll{ overflow: hidden; }

/* ===================================
   ACCESSIBLE FOCUS (NO RED SQUARES)
   - Kill default outline
   - Add premium ring (keyboard only)
   =================================== */
:focus-visible{ outline: none; }

/* Use ring only on interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
  border-radius: 12px;
}

/* Optional: prevent ugly focus on mouse clicks in some browsers */
:focus:not(:focus-visible){
  outline: none;
}

/* ===================================
   ANIMATIONS & UTILITIES
   =================================== */
.menu-overlay{
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.slide-out-left{
  transform: translateX(-20px);
  opacity: 0;
  pointer-events: none;
}

.slide-out-fade{
  opacity: 0;
  pointer-events: none;
}

/* ===================================
   HEADER — Scroll + Fade + Nav Hide
   =================================== */
.header-nav-hidden{
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(-2px);
}

/* Fade background appears on scroll */
.header-fade-in{
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--header-border);
}

/* Premium micro-motion for logo resize */
.bf-logo-anim{
  transform-origin: left top;
  backface-visibility: hidden;
  transform: translateZ(0);
}
.bf-logo-anim.is-mini{
  transform: translateY(-1px) scale(0.98);
}

/* Invert logo for colored menu overlay */
.bf-logo-invert{ filter: brightness(0) invert(1); }

/* Make logo focus ring look premium */
#site-logo{ border-radius: 16px; }
#site-logo:focus-visible{ box-shadow: 0 0 0 3px var(--focus-ring); }

/* Hamburger appear animation */
@keyframes calm-fade-in{
  0%{ opacity: 0; transform: translateX(10px) scale(0.95); }
  100%{ opacity: 1; transform: translateX(0) scale(1); }
}
.hamburger-enter{
  animation: calm-fade-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ===================================
   INSIGHTS FILTERING (UX FIX)
   =================================== */
.insight-item{
  transition: opacity 220ms ease, transform 260ms ease, box-shadow 300ms ease;
  will-change: opacity, transform;
}

.insight-item.is-hiding{
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.insight-item.is-hidden{ display: none; }

.insight-item.is-showing{
  opacity: 0;
  transform: translateY(10px);
}

.filter-btn{
  display: inline-block;
  padding: 8px 24px;
  border-radius: 999px;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  background-color: var(--surface-solid);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 180ms ease, border-color 200ms ease, color 200ms ease, background-color 200ms ease, box-shadow 200ms ease;
  white-space: nowrap;
}

.filter-btn:hover{
  border-color: color-mix(in srgb, var(--accent-primary) 60%, var(--border));
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.filter-btn.active{
  background-color: var(--text-primary);
  color: var(--text-on-color);
  border-color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media (prefers-reduced-motion: reduce){
  .insight-item{ transition: none !important; }
  .filter-btn{ transition: none !important; }
}

/* ===================================
   Form Autofill Overrides
   =================================== */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus{
  -webkit-box-shadow: 0 0 0px 1000px var(--bg-primary) inset;
  -webkit-text-fill-color: var(--text-primary);
  transition: background-color 5000s ease-in-out 0s;
}

/* ===================================
   MOTION SYSTEM (Reveal)
   =================================== */
[data-reveal]{
  opacity: 0;
  transform: translateY(18px);
  filter: blur(2px);
  transition: opacity 700ms ease, transform 700ms ease, filter 700ms ease;
  will-change: transform, opacity, filter;
}

[data-reveal="fade"]{
  transform: none;
  filter: none;
}

.is-revealed{
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

@media (prefers-reduced-motion: reduce){
  [data-reveal]{
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
}

/* ===================================
   INSIGHTS SVG DRAW SYSTEM (Option A)
   =================================== */
#bf-insight-illustration .bf-accent path,
#bf-insights-hero-illustration .bf-accent path,
#bf-insight-illustration .bf-accent line,
#bf-insights-hero-illustration .bf-accent line,
#bf-insight-illustration .bf-accent polyline,
#bf-insights-hero-illustration .bf-accent polyline{
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
}

#bf-insight-illustration.is-revealed .bf-accent path,
#bf-insights-hero-illustration.is-revealed .bf-accent path,
#bf-insight-illustration.is-revealed .bf-accent line,
#bf-insights-hero-illustration.is-revealed .bf-accent line,
#bf-insight-illustration.is-revealed .bf-accent polyline,
#bf-insights-hero-illustration.is-revealed .bf-accent polyline{
  animation: bfDraw 1200ms ease forwards;
}

@keyframes bfDraw{ to{ stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce){
  #bf-insight-illustration .bf-accent path,
  #bf-insights-hero-illustration .bf-accent path,
  #bf-insight-illustration .bf-accent line,
  #bf-insights-hero-illustration .bf-accent line,
  #bf-insight-illustration .bf-accent polyline,
  #bf-insights-hero-illustration .bf-accent polyline{
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    animation: none !important;
  }
}

/* ===================================
   BRANFORGE CHAT WIDGET
   =================================== */
.bf-chat{
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  font-family: var(--font-body, "Inter", sans-serif);
}

/* Pulse animation */
@keyframes bf-pulse-red{
  0%{ box-shadow: 0 0 0 0 rgba(255, 59, 77, 0.7); }
  70%{ box-shadow: 0 0 0 15px rgba(255, 59, 77, 0); }
  100%{ box-shadow: 0 0 0 0 rgba(255, 59, 77, 0); }
}

.bf-chat__fab{
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid var(--border-weak);
  background: var(--surface-solid);
  color: var(--accent-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 220ms ease;
  box-shadow: var(--shadow-md);
  animation: bf-pulse-red 2s infinite;
}

.bf-chat__fab:hover,
.bf-chat__fab[aria-expanded="true"]{
  animation: none;
  transform: scale(1.05);
}

.bf-chat__fab:active{ transform: scale(1.02); }

.bf-chat__fab:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-md);
}

.bf-chat__fabIcon{ font-size: 20px; line-height: 1; }

.bf-chat__panel{
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 120px));
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-weak);
  border-radius: 20px;
  overflow: hidden;
  position: absolute;
  right: 0;
  bottom: 74px;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms ease;
  display: flex;
  flex-direction: column;
}

.bf-chat.is-open .bf-chat__panel{
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.bf-chat__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-weak);
  background: var(--surface);
  flex-shrink: 0;
}

.bf-chat__brand{ display: flex; align-items: center; gap: 10px; }

.bf-chat__dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(255,59,77,0.14);
}

.bf-chat__title{
  font-family: var(--font-display, "Poppins", sans-serif);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.bf-chat__sub{
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.bf-chat__close{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-weak);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease;
}

.bf-chat__close:hover{ transform: scale(1.02); border-color: var(--border-strong); }

.bf-chat__close:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.bf-chat__body{
  padding: 14px 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.bf-chat__msg{ display: flex; margin: 12px 0; }
.bf-chat__msg--bot{ justify-content: flex-start; }
.bf-chat__msg--user{ justify-content: flex-end; }

.bf-chat__bubble{
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-weak);
  background: var(--surface-soft);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}

.bf-chat__msg--user .bf-chat__bubble{
  background: rgba(255,59,77,0.10);
  border-color: rgba(255,59,77,0.26);
}

.bf-chat__choices{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.bf-chat__choice{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-weak);
  background: var(--surface-muted);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: transform 120ms ease, border-color 150ms ease, background 150ms ease;
}

.bf-chat__choice:hover{
  transform: translateY(-1px);
  border-color: rgba(255,59,77,0.35);
}

.bf-chat__choice:active{ transform: translateY(0); }

.bf-chat__choice:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ===================================
   CHAT CONTACT INPUT (PREMIUM)
   =================================== */
.bf-chat__inputwrap{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.bf-chat__inputwrap:focus-within{
  border-color: rgba(255,59,77,0.40);
  box-shadow:
    var(--shadow-sm),
    0 0 0 4px rgba(255,59,77,0.18);
}

.bf-chat__input{
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 10px 10px;
  font-size: 16px; /* mobile-friendly */
  line-height: 1.2;
  color: var(--text-primary);
}

.bf-chat__input::placeholder{
  color: color-mix(in srgb, var(--text-primary) 35%, transparent);
}

.bf-chat__send{
  border: 0;
  outline: 0;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-primary);
  color: var(--text-on-color);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

.bf-chat__send:hover{
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.bf-chat__send:active{ transform: translateY(0); }

.bf-chat__send:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

@media (max-width: 380px){
  .bf-chat__inputwrap{ padding: 9px; border-radius: 14px; }
  .bf-chat__send{ padding: 10px 12px; }
}

/* ===================================
   CHAT FOOTER
   =================================== */
.bf-chat__footer{
  padding: 12px 16px;
  border-top: 1px solid var(--border-weak);
  background: var(--surface);
  flex-shrink: 0;
}

.bf-chat__meta{
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.bf-chat__actions{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bf-chat__primary,
.bf-chat__secondary{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.bf-chat__primary{
  border-color: rgba(255,59,77,0.55);
  color: var(--text-on-color);
  background: var(--accent-primary);
}

.bf-chat__primary:hover{ transform: translateY(-1px); }

.bf-chat__secondary{
  background: transparent;
  color: var(--text-primary);
}

.bf-chat__secondary:hover{
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

/* ===================================
   RESPONSIVE POLISH
   =================================== */
@media (max-width: 480px){
  .bf-chat{ right: 14px; bottom: 14px; }
  .bf-chat__panel{ bottom: 68px; height: min(520px, calc(100vh - 110px)); }
}

/* ===================================
   REDUCED MOTION
   =================================== */
@media (prefers-reduced-motion: reduce){
  .bf-chat__panel,
  .bf-chat__fab,
  .bf-chat__choice,
  .bf-chat__primary,
  .bf-chat__secondary,
  .bf-chat__send{
    transition: none !important;
    animation: none !important;
  }
}