/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Turbo progress bar — match theme */
.turbo-progress-bar {
  background-color: #6366f1;
  height: 2px;
}

/* === Spending Plan: provider dropdown pop-in (subtle, ease-out) === */
#sp-provider-menu { transform-origin: top left; }
@keyframes sp-pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #sp-provider-menu { animation: none !important; }
}

/* === Spending Plan: "Add provider" dialog === */
#sp-add-provider::backdrop { background: rgba(7, 7, 13, .55); }
#sp-add-provider[open] { animation: sp-pop-in 120ms ease-out; }
@media (prefers-reduced-motion: reduce) { #sp-add-provider[open] { animation: none; } }

/* === Spending Plan: line add/remove, totals pulse, view crossfade === */
@keyframes sp-row-in  { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sp-row-out { to   { opacity: 0; transform: translateX(10px); } }
@keyframes sp-pulse   { 0% { transform: scale(1); } 35% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes sp-fade-in { from { opacity: 0; } to { opacity: 1; } }
tr.sp-row-in { animation: sp-row-in 160ms ease-out; }
@media (prefers-reduced-motion: reduce) { tr.sp-row-in { animation: none; } }

/* === PCP Questionnaire Interactive Animations === */

/* Step flow: fade + slide up when a new sub-section appears */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tag chip pop-in animation */
.tag-chip {
  animation: tagPop 0.2s ease-out;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

@keyframes tagPop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Celebration checkmark bounce */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

/* Checkmark draw animation */
@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

/* Confetti particles */
@keyframes confetti {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-200px) translateX(var(--x, 0px)) rotate(var(--r, 360deg));
  }
}

/* Turbo frame content transition */
turbo-frame#questionnaire_content > div {
  animation: fadeSlideUp 0.25s ease-out;
}

/* Communication chart responsive grid */
.comm-chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .comm-chart-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr 40px;
  }
}

/* iPhone-style time wheel picker */
.time-wheel-container {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 30%, black 70%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 30%, black 70%, transparent 100%);
}
.time-wheel-highlight {
  position: absolute;
  top: 50%;
  left: 8px;
  right: 8px;
  height: 40px;
  transform: translateY(-50%);
  background: rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  pointer-events: none;
  z-index: 1;
}
.time-wheel {
  position: relative;
  z-index: 2;
}

/* Suggestion chip hover effect */
.suggestion-chip {
  transition: all 0.15s ease;
}
.suggestion-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(100, 80, 160, 0.1);
}

/* === Scroll-reveal animations ===
   Paired with reveal_controller.js. Element starts hidden and slides up a few
   pixels; .is-visible fades it in. Variants pick the entry direction.        */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
  will-change: opacity, transform;
}
.reveal.reveal-left  { transform: translateX(-24px); }
.reveal.reveal-right { transform: translateX(24px); }
.reveal.reveal-zoom  { transform: scale(0.96); }
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.reveal-left,
  .reveal.reveal-right,
  .reveal.reveal-zoom {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------------------------------------------------------------------------
   Auto-hide floating sidebar.
   The panel (the facilitator <aside>) slides off-screen by default; it's
   revealed by hovering the left-edge rail or the panel itself, and hidden again
   on leave (the sidebar-autohide controller adds a short close delay so crossing
   the rail→panel gap doesn't flicker). The CSS :hover rules below are a no-JS
   fallback that reveals it even if the controller hasn't connected. Pinning
   (html.sidebar-pinned, toggled by the controller + applied pre-paint) locks it
   open and offsets the main content.
   --------------------------------------------------------------------------- */
[data-sidebar-autohide-target="panel"] {
  transform: translateX(-120%);        /* off-screen incl. the left-4 gap + shadow */
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
}
[data-sidebar-autohide-target="panel"].is-open,
html.sidebar-pinned [data-sidebar-autohide-target="panel"],
html:not(.sidebar-pinned) .sidebar-rail:hover ~ [data-sidebar-autohide-target="panel"],
html:not(.sidebar-pinned) [data-sidebar-autohide-target="panel"]:hover,
html:not(.sidebar-pinned) [data-sidebar-autohide-target="panel"]:focus-within {
  transform: translateX(0);
}

/* Left-edge hover trigger (hidden when pinned — the panel is always out then). */
.sidebar-rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0.75rem;
  z-index: 15;
  cursor: pointer;
  background: linear-gradient(to right, rgba(19, 78, 74, 0.9), rgba(19, 78, 74, 0));
}
.sidebar-rail::after {   /* a small grab hint, vertically centered */
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 3px;
  height: 2.5rem;
  margin-top: -1.25rem;
  border-radius: 2px;
  background: rgba(94, 234, 212, 0.5);
}
html.sidebar-pinned .sidebar-rail { display: none; }

/* Pin toggle: highlight when active. */
[data-sidebar-autohide-target="pinBtn"][aria-pressed="true"] {
  color: #fff;
  background: rgba(13, 148, 136, 0.45);   /* teal-600 @ 45% */
}

/* The main column takes the sidebar's footprint only when pinned. 18rem =
   left-4 (1rem) + w-64 (16rem) + 1rem gap — keep in sync with the <aside> geometry
   in _facilitator_sidebar.html.erb. In auto-hide mode it's full-width and the
   panel floats over it. */
.facilitator-main { transition: margin-left .28s cubic-bezier(.4, 0, .2, 1); }
html.sidebar-pinned .facilitator-main { margin-left: 18rem; }

@media (prefers-reduced-motion: reduce) {
  [data-sidebar-autohide-target="panel"],
  .facilitator-main { transition: none; }
}

/* === Vendors: animated rows, add/edit dialog, OCR dropzone === */
.sp-pulse   { animation: sp-pulse 420ms ease-out; }
.sp-row-out { animation: sp-row-out 180ms ease-in forwards; }

.vendor-dialog {
  padding: 0;
  border: none;
  border-radius: 1rem;
  background: transparent;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}
.vendor-dialog::backdrop { background: rgba(7, 7, 13, 0.55); }
.vendor-dialog[open] { animation: sp-pop-in 180ms cubic-bezier(0.4, 0, 0.2, 1); }
.vendor-ocr-over { border-color: #14b8a6 !important; background: rgba(20, 184, 166, 0.08); }

@media (prefers-reduced-motion: reduce) {
  .sp-pulse, .sp-row-out, .vendor-dialog[open] { animation: none; }
}
