/* =============================================================
 * #abō — Base styles
 * ============================================================= */

body {
  background: var(--ivoire);
  color: var(--encre);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-weight: 400;
  touch-action: pan-y;
  overscroll-behavior-y: none;
}

.app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ivoire);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--ivoire);
  z-index: var(--z-base);
  animation: screenIn var(--d-slow) var(--ease-out-expo);
}

.screen[hidden] { display: none; }

.app-bar {
  flex-shrink: 0;
  padding: 14px var(--page-pad) 12px;
  padding-top: calc(14px + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  background: var(--ivoire);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
}

.app-logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  color: var(--nuit);
  letter-spacing: var(--ls-heading);
}

.app-logo-img {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 4px 0;
}

.app-logo-img img {
  height: 22px;
  width: auto;
  display: block;
}

.app-logo[data-nav] {
  cursor: pointer;
  transition: opacity var(--d-fast) var(--ease-soft), transform var(--d-fast) var(--ease-spring);
}

.app-logo[data-nav]:active {
  opacity: 0.7;
  transform: scale(0.96);
}

.app-logo .hash { color: var(--boow); }

.app-logo-small {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: var(--ls-heading);
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-action {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--nuit-soft);
  padding: 10px 14px;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--d-fast) var(--ease-soft), transform var(--d-fast) var(--ease-spring);
}

.app-action:active {
  color: var(--boow);
  transform: scale(0.94);
}

.app-action-spacer { width: 44px; }

.back-btn {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  color: var(--nuit);
  line-height: 1;
  padding: 10px 14px;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--d-fast) var(--ease-soft), transform var(--d-fast) var(--ease-spring);
}

.back-btn:active {
  color: var(--boow);
  transform: translateX(-3px) scale(0.94);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.app-content::-webkit-scrollbar { width: 0; display: none; }

.tabbar {
  flex-shrink: 0;
  padding: 8px 0;
  padding-bottom: calc(8px + var(--safe-bottom));
  background: var(--ivoire-pure);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: relative;
  z-index: 2;
}

.tab {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  font-weight: 500;
  color: var(--nuit-soft);
  padding: 8px 12px;
  min-height: var(--tap-min);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--d-fast) var(--ease-soft);
}

.tab:active .tab-icon { transform: scale(0.88); }
.tab.active { color: var(--boow); }

.tab-icon {
  width: 22px;
  height: 22px;
  position: relative;
  transition: transform var(--d-fast) var(--ease-spring);
}

.tab-icon-dashboard::before,
.tab-icon-dashboard::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 1px;
}
.tab-icon-dashboard::before { left: 3px; right: 3px; top: 7px; height: 2px; }
.tab-icon-dashboard::after { left: 3px; right: 8px; top: 13px; height: 2px; }

.tab.tab-add .tab-icon {
  background: var(--boow);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px -2px var(--boow-shadow);
}
.tab.tab-add .tab-icon::before,
.tab.tab-add .tab-icon::after {
  content: "";
  position: absolute;
  background: var(--ivoire);
  border-radius: 1px;
}
.tab.tab-add .tab-icon::before { top: 50%; left: 25%; right: 25%; height: 2px; transform: translateY(-50%); }
.tab.tab-add .tab-icon::after { left: 50%; top: 25%; bottom: 25%; width: 2px; transform: translateX(-50%); }

.tab-icon-stats::before,
.tab-icon-stats::after {
  content: "";
  position: absolute;
  background: currentColor;
  bottom: 3px;
  width: 3px;
  border-radius: 1px;
}
.tab-icon-stats::before { left: 5px; height: 8px; }
.tab-icon-stats::after { right: 5px; height: 14px; }

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 26px;
  min-height: var(--tap-min);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1.5px solid;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: transform var(--d-fast) var(--ease-spring), background-color var(--d-fast) var(--ease-soft), border-color var(--d-fast) var(--ease-soft), box-shadow var(--d-fast) var(--ease-soft);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease-soft);
}

.btn:active::before { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--boow);
  color: var(--ivoire);
  border-color: var(--boow);
  box-shadow: var(--shadow-boow);
}

.btn-primary:active {
  background: var(--boow-dark);
  border-color: var(--boow-dark);
  box-shadow: 0 4px 12px -4px var(--boow-shadow);
}

.btn-dark {
  background: var(--nuit);
  color: var(--ivoire);
  border-color: var(--nuit);
  box-shadow: 0 8px 20px -8px rgba(26, 40, 69, 0.4);
}

.btn-dark:active { background: var(--nuit-deep); }

.btn-ghost {
  background: transparent;
  color: var(--nuit);
  border-color: var(--nuit);
}

.btn-ghost:active {
  background: var(--nuit);
  color: var(--ivoire);
}

.btn-text {
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--nuit-soft);
  padding: 14px 18px;
  min-height: var(--tap-min);
  transition: color var(--d-fast) var(--ease-soft);
  cursor: pointer;
}

.btn-text:active { color: var(--boow); }

.btn-block { width: 100%; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* Animations globales */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

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

@keyframes drop {
  0% { transform: translateY(-20px) scale(0.9); opacity: 0; }
  60% { transform: translateY(2px) scale(1.02); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes checkmark {
  0% { transform: scale(0) rotate(45deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(45deg); opacity: 1; }
  100% { transform: scale(1) rotate(45deg); opacity: 1; }
}

.stagger-in > * {
  opacity: 0;
  animation: slideUp var(--d-slow) var(--ease-out-expo) forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 40ms; }
.stagger-in > *:nth-child(2) { animation-delay: 80ms; }
.stagger-in > *:nth-child(3) { animation-delay: 120ms; }
.stagger-in > *:nth-child(4) { animation-delay: 160ms; }
.stagger-in > *:nth-child(5) { animation-delay: 200ms; }
.stagger-in > *:nth-child(6) { animation-delay: 240ms; }
.stagger-in > *:nth-child(7) { animation-delay: 280ms; }
.stagger-in > *:nth-child(8) { animation-delay: 320ms; }
.stagger-in > *:nth-child(9) { animation-delay: 360ms; }
.stagger-in > *:nth-child(10) { animation-delay: 400ms; }
.stagger-in > *:nth-child(n+11) { animation-delay: 440ms; }

/* =============================================================
 * PAGE TRANSITIONS - slide horizontal type iOS
 * ============================================================= */
@keyframes pageEnterForward {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.page-enter-forward {
  animation: pageEnterForward 360ms var(--ease-out-expo);
}

.page-enter-back {
  animation: pageEnterBack 360ms var(--ease-out-expo);
}

/* =============================================================
 * CONFETTI (subtil, pour first kill uniquement)
 * ============================================================= */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  pointer-events: none;
  z-index: var(--z-toast);
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  opacity: 0;
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) rotate(0);
  }
  10% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translateY(110vh) translateX(var(--drift-x)) rotate(var(--rotation));
  }
}

/* =============================================================
 * TROPHY CELEBRATE — overlay festive quand un badge se debloque
 * ============================================================= */
.trophy-celebrate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 23, 41, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 24px;
}

.trophy-celebrate-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.trophy-celebrate-card {
  background: linear-gradient(180deg, var(--nuit) 0%, var(--nuit-deep) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 36px 28px 32px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  transform: scale(0.7) translateY(40px);
  transition: transform 520ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 24px 60px -12px rgba(248, 85, 88, 0.35),
              0 8px 24px -8px rgba(14, 23, 41, 0.6),
              inset 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
}

.trophy-celebrate-overlay.visible .trophy-celebrate-card {
  transform: scale(1) translateY(0);
}

.trophy-celebrate-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 200%;
  height: 100%;
  background: radial-gradient(ellipse, rgba(248, 85, 88, 0.18) 0%, transparent 60%);
  pointer-events: none;
}

.trophy-celebrate-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--boow-soft);
  font-weight: 600;
  margin-bottom: 20px;
  position: relative;
}

.trophy-celebrate-icon-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trophy-celebrate-icon {
  font-size: 70px;
  line-height: 1;
  position: relative;
  z-index: 2;
  animation: trophyPulse 1400ms ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.trophy-celebrate-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--boow) 0%, transparent 70%);
  opacity: 0.4;
  animation: trophyGlow 1800ms ease-in-out infinite;
}

@keyframes trophyPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes trophyGlow {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.trophy-celebrate-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  color: var(--ivoire);
  letter-spacing: var(--ls-heading);
  line-height: 1.2;
  margin: 0 0 8px;
  position: relative;
}

.trophy-celebrate-desc {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  color: rgba(245, 239, 224, 0.78);
  margin: 0;
  position: relative;
}

/* =============================================================
 * REFINED SPRING BUTTONS (Apple Wallet-like feedback)
 * ============================================================= */
.btn,
.tab,
.sub-card,
.cat-item,
.menu-item,
.cat-add-btn,
.app-action,
.back-btn,
.followed-card,
.duplicate-action-btn,
.keepone-option,
.trophy-badge,
.datepicker-day,
.datepicker-preset {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Press states avec spring physics naturel */
.btn-primary:active,
.btn-dark:active {
  transition: transform 80ms cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 100ms ease,
              box-shadow 100ms ease;
}

/* =============================================================
 * TAB INDICATOR (glisse entre onglets)
 * ============================================================= */
.tabbar {
  position: relative;
}

.tabbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 33.333%;
  height: 2px;
  background: var(--boow);
  border-radius: 0 0 2px 2px;
  transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  opacity: 0.85;
}

.tabbar[data-active-tab="0"]::before { transform: translateX(0); }
.tabbar[data-active-tab="1"]::before { transform: translateX(100%); }
.tabbar[data-active-tab="2"]::before { transform: translateX(200%); }

/* Tab active : nouveau style sans pull bottom */
.tab.active {
  color: var(--boow);
}

.tab.active .tab-label {
  font-weight: 700;
}

/* =============================================================
 * COUNTER (count-up classes)
 * ============================================================= */
.dash-counter,
.recap-big,
.trophy-level-name {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* =============================================================
 * CARD PRESS - subtle scale + shadow change
 * ============================================================= */
.sub-card:active,
.cat-item:active,
.followed-card:active,
.menu-item:active,
.keepone-option:active,
.trophy-badge:active {
  transition: transform 80ms cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 100ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  font-weight: 500;
}

.italic { font-style: italic; }
.text-boow { color: var(--boow); }
.text-nuit { color: var(--nuit); }
.text-mousse { color: var(--mousse); }
.text-center { text-align: center; }
