/* ============================================================
   KINTSU — app-extra.css
   Complementos visuais: splash, task form, desktop, print
   ============================================================ */

/* ============================================================
   SPLASH / LOADING
   ============================================================ */
.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 52px;
  color: var(--brand);
  animation: splashPulse 1.5s ease-in-out infinite;
}
.splash-tagline {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--space-sm);
  letter-spacing: 0.5px;
}
.splash-dots {
  display: flex;
  gap: 6px;
  margin-top: var(--space-xl);
}
.splash-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: splashDot 1.2s ease-in-out infinite;
}
.splash-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes splashPulse {
  0%, 100% { opacity: 0.7; transform: scale(0.97); }
  50%       { opacity: 1;   transform: scale(1.03); }
}
@keyframes splashDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ============================================================
   DESKTOP REFINEMENTS
   ============================================================ */
@media (min-width: 768px) {
  .app-shell {
    max-width: none;
    width: 100%;
    margin: 0;
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-sidebar {
    display: flex;
    width: 280px;
    /* Sidebar sticky: fixa enquanto rola o conteúdo */
    height: 100dvh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-xl) 0;
    position: sticky;
    top: 0;
    overflow: hidden;
    flex-shrink: 0;
    flex-direction: column;
  }

  .app-main {
    flex: 1 1 auto;
    max-width: none;
    min-height: 0;
    height: 100dvh;
    padding: clamp(28px, 4vw, 48px);
    padding-bottom: clamp(32px, 5vw, 56px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .greeting-section__title { font-size: 30px; }

  .checkin-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }

  /* Desktop: cards mais largos */
  .task-card { padding: var(--space-md) var(--space-xl); }
  .card { border-radius: var(--radius-xl); }

  /* Desktop: bottom sheet vira modal centralizado */
  .bottom-sheet {
    bottom: 50%;
    transform: translateX(-50%) translateY(50%) scale(0.95);
    border-radius: var(--radius-xl);
    max-width: 480px;
    max-height: 80dvh;
  }
  .bottom-sheet.active {
    transform: translateX(-50%) translateY(50%) scale(1);
  }
  .bottom-sheet__handle { display: none; }

  /* Impulse modal centralizado */
  .impulse-modal {
    align-items: center;
  }
}

/* ============================================================
   TASK CARD SWIPE HINT (mobile)
   ============================================================ */
@media (max-width: 767px) {
  .task-card {
    position: relative;
    overflow: hidden;
  }
  .task-card::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--brand), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
  }
  .task-card:active::after { opacity: 1; }
}

/* ============================================================
   CHECKIN FLOW — Mood emoji feedback
   ============================================================ */
.mood-emoji-display {
  font-size: 36px;
  text-align: center;
  display: block;
  margin: var(--space-sm) 0;
  animation: emojiPop 0.2s var(--transition-spring);
}
@keyframes emojiPop {
  0%   { transform: scale(0.7); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ============================================================
   INSIGHTS — Line chart tooltip
   ============================================================ */
.chart-tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 10;
  transform: translateX(-50%);
}

/* ============================================================
   RETURN MISSION — Special card
   ============================================================ */
.return-mission-card {
  background: linear-gradient(135deg,
    rgba(139,127,255,0.10) 0%,
    rgba(93,216,192,0.06) 100%
  );
  border: 1px solid var(--brand-glow);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  position: relative;
  overflow: hidden;
}
.return-mission-card::after {
  content: '🔄';
  position: absolute;
  right: var(--space-xl);
  top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  opacity: 0.12;
}
.return-mission-card__title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}
.return-mission-card__steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: var(--space-md) 0 var(--space-lg);
}
.return-step {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 14px;
  color: var(--text-secondary);
}
.return-step__number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  flex-shrink: 0;
}

/* ============================================================
   JOURNAL / DESCARGA MENTAL
   ============================================================ */
.journal-input-area {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.journal-input-area:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-subtle);
}
.journal-textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.7;
  resize: none;
  min-height: 120px;
}
.journal-textarea::placeholder { color: var(--text-muted); }
.journal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}
.journal-char-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   IMPULSE GUARD — Freeze progress bar
   ============================================================ */
.impulse-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}
.impulse-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--state-crisis), var(--brand));
  border-radius: var(--radius-full);
  transition: width 1s linear;
}

/* ============================================================
   VERSION COMPLETE ANIMATION
   ============================================================ */
@keyframes versionComplete {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.08); }
  60%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.task-card.just-completed {
  animation: versionComplete 0.4s ease;
  border-color: var(--brand);
}

/* ============================================================
   SURVIVAL MODE — Checklist done state
   ============================================================ */
.survival-item.done .survival-item__emoji::after {
  content: ' ✓';
  font-size: 14px;
  color: var(--state-full);
}
.survival-item.done .survival-item__label {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ============================================================
   SCROLL INDICATORS
   ============================================================ */
.scroll-fade-top {
  position: sticky;
  top: 0;
  height: 20px;
  background: linear-gradient(to bottom, var(--bg-base), transparent);
  pointer-events: none;
  z-index: 1;
}
.scroll-fade-bottom {
  position: sticky;
  bottom: var(--bottom-nav-height);
  height: 32px;
  background: linear-gradient(to top, var(--bg-base), transparent);
  pointer-events: none;
  z-index: 1;
}

/* ============================================================
   FOCUS VISIBLE — Acessibilidade
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

/* ============================================================
   PRINT — Ocultar nav, mostrar conteúdo
   ============================================================ */
@media print {
  .bottom-nav,
  .app-sidebar,
  .app-header,
  .pwa-install-banner,
  .bottom-sheet,
  .impulse-modal { display: none !important; }
  .app-main { padding: 0 !important; }
  body { background: white; color: black; }
}

/* ============================================================
   DARK THEME SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .breathing-animation { animation: none; }
  .splash-dot { animation: none; }
}

/* ============================================================
   DESKTOP HOVER STATES — micro-interações com mouse
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
  .task-card:hover {
    background: var(--bg-elevated);
    border-color: var(--border-default);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }
  .card--interactive:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
  }
  .btn--primary:hover {
    background: var(--brand-dim);
    box-shadow: 0 4px 20px rgba(139, 127, 255, 0.35);
    transform: translateY(-1px);
  }
  .btn--secondary:hover {
    background: var(--bg-overlay);
    border-color: var(--border-default);
  }
  .sidebar-nav__item:hover:not(.active) {
    background: var(--brand-subtle);
    color: var(--text-primary);
  }
  .bottom-nav__item:hover {
    color: var(--brand);
  }
  .app-header__action:hover {
    background: var(--bg-overlay);
    color: var(--brand);
  }
  .checkin-option:hover {
    border-color: var(--brand);
    background: var(--brand-subtle);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--brand-glow);
  }
  .anchor-card:hover {
    border-color: var(--brand-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
  }
  .survival-item:hover {
    background: var(--bg-elevated);
    transform: translateX(3px);
  }
}

/* ============================================================
   ANIMAÇÕES APRIMORADAS — page transitions e stagger
   ============================================================ */

/* Entrada suave para itens em lista (stagger via nth-child) */
.task-list .task-card,
.anchor-list .anchor-card,
.insight-list > * {
  animation: listItemEnter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.task-list .task-card:nth-child(1)  { animation-delay: 0.04s; }
.task-list .task-card:nth-child(2)  { animation-delay: 0.08s; }
.task-list .task-card:nth-child(3)  { animation-delay: 0.12s; }
.task-list .task-card:nth-child(4)  { animation-delay: 0.16s; }
.task-list .task-card:nth-child(5)  { animation-delay: 0.20s; }
.task-list .task-card:nth-child(6)  { animation-delay: 0.24s; }
.task-list .task-card:nth-child(n+7){ animation-delay: 0.28s; }

@keyframes listItemEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Entrada da página principal */
.app-main > *:first-child {
  animation: pageEnterMain 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
@keyframes pageEnterMain {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Toast aprimorado */
.toast {
  animation: toastSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.toast.removing {
  animation: toastSlideOut 0.22s ease-in both;
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(100%) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.95); }
}

/* Ambient layers — movimento mais suave e visível */
.app-ambient__layer--one {
  animation: ambientDrift1 18s ease-in-out infinite alternate;
}
.app-ambient__layer--two {
  animation: ambientDrift2 24s ease-in-out infinite alternate;
}
.app-ambient__layer--three {
  animation: ambientDrift3 30s ease-in-out infinite alternate;
}
@keyframes ambientDrift1 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(20px, 30px, 0) scale(1.1); }
}
@keyframes ambientDrift2 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-15px, 20px, 0) scale(1.06); }
}
@keyframes ambientDrift3 {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to   { transform: translate3d(10px, -15px, 0) scale(0.98); }
}

/* Shimmer para loading states */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-overlay) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* Bottom nav active indicator melhorado */
.bottom-nav__item.active .bottom-nav__icon-wrapper {
  position: relative;
}
.bottom-nav__item.active .bottom-nav__icon-wrapper::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand);
  animation: navDotPulse 2s ease-in-out infinite;
}
@keyframes navDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 127, 255, 0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(139, 127, 255, 0); }
}

/* ============================================================
   TABLET — breakpoint intermediário (768px - 1024px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1024px) {
  .app-sidebar {
    width: 240px;
  }
  .app-main {
    padding: clamp(20px, 3vw, 36px);
  }
  .checkin-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 168px) and (max-width: 624px) {
  .app-sidebar{
    display: none;
  }
}

/* ============================================================
   LARGE DESKTOP — conteúdo centrado com max-width
   ============================================================ */
@media (min-width: 1440px) {
  .app-sidebar {
    width: 300px;
    height: 100%;
  }
  .app-main {
    max-width: calc(100vw - 300px);
  }
  .app-main > * {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }
}
