@tailwind base;
@tailwind components;
@tailwind utilities;

/* Montserrat - header font (used in neode present) */
@font-face {
  font-family: 'Montserrat';
  src: url('/assets/fonts/Montserrat/Montserrat-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: 'Montserrat';
  src: url('/assets/fonts/Montserrat/Montserrat-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
}

/* Controller / keyboard navigation - soft glow only (no box outline) */
*:focus-visible {
  outline: none;
  box-shadow: 0 0 16px rgba(120, 180, 255, 0.2), 0 0 32px rgba(100, 160, 255, 0.1);
  transition: box-shadow 0.2s ease;
}

/* Containers: base scale for smooth grow animation */
[data-controller-container] {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Containers get subtle grow + inner glow when focused (gamepad selection) */
[data-controller-container]:focus-visible {
  transform: scale(1.02);
  box-shadow:
    0 0 24px rgba(120, 180, 255, 0.15),
    0 0 48px rgba(100, 160, 255, 0.08),
    inset 0 0 24px rgba(255, 255, 255, 0.03);
}

/* Global glassmorphism utilities */
@layer components {
  .glass {
    background-color: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
  
  .glass-strong {
    background-color: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
  
  .glass-card {
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    border-radius: 1rem;
    overflow-x: hidden;
    overflow-y: visible;
  }

  /* Mode switcher - sidebar toggle */
  .mode-switcher {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mode-switcher-btn {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    transition: all 0.25s ease;
    cursor: pointer;
    text-align: center;
    border: none;
    background: transparent;
  }

  .mode-switcher-btn:hover {
    color: rgba(255, 255, 255, 0.75);
  }

  .mode-switcher-btn-active {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  }

  /* Chat launcher button — sidebar (desktop) */
  .chat-launcher-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.25rem;
  }

  .chat-launcher-btn:hover {
    background: rgba(251, 146, 60, 0.15);
    border-color: rgba(251, 146, 60, 0.3);
    color: #fb923c;
    transform: translateY(-1px);
  }

  /* Chat launcher button — mobile bottom bar */
  .chat-launcher-btn-mobile {
    color: rgba(255, 255, 255, 0.7);
  }

  .chat-launcher-btn-mobile:hover {
    color: #fb923c;
  }

  /* Chat close button (floating pill) */
  .chat-close-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
  }

  .chat-close-btn:hover {
    background: rgba(0, 0, 0, 0.65);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
  }

  /* Chat fullscreen layout — fills the view-wrapper container */
  .chat-fullscreen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: relative;
  }

  .chat-mode-pill {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 1.25rem);
    right: calc(env(safe-area-inset-right, 0px) + 1.25rem);
    z-index: 10;
  }
  @media (min-width: 768px) {
    .chat-mode-pill {
      top: 1.25rem;
      right: 1.25rem;
    }
  }

  .chat-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
  }

  /* On mobile, pad iframe so AIUI content ends above the tab bar */
  @media (max-width: 767px) {
    .chat-iframe-mobile {
      padding-bottom: calc(var(--mobile-tab-bar-height, 72px) + 52px);
    }
  }

  /* Chat placeholder (no AIUI URL) */
  .chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chat-placeholder-inner {
    text-align: center;
    max-width: 28rem;
    padding: 3rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .chat-placeholder-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.5rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Goal cards */
  .goal-card {
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .goal-card:hover {
    transform: translateY(-2px);
  }

  .goal-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
  }

  .goal-status-badge-not-started {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
  }

  .goal-status-badge-in-progress {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
  }

  .goal-status-badge-completed {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
  }

  /* Goal wizard steps */
  .goal-step {
    padding: 1rem 1.25rem;
    border-left: 3px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
  }

  .goal-step-active {
    border-left-color: #fb923c;
    background: rgba(251, 146, 60, 0.05);
  }

  .goal-step-completed {
    border-left-color: #4ade80;
  }

  .goal-step-pending {
    opacity: 0.5;
  }

  .glass-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 1.25rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
    border-radius: 0.75rem;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
  }

  .glass-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), transparent);
    -webkit-mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
  }

  .glass-button:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.35);
    box-shadow:
      0 12px 32px rgba(0, 0, 0, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.25);
  }

  .glass-button:hover::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
  }

  .glass-button-sm {
    padding-block: 0.375rem;
    padding-inline: 0.75rem;
    font-size: 0.875rem;
  }

  /* Toast - glassmorphic, top-right */
  .toast-glass {
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    border-radius: 0.75rem;
  }

  /* Toast transition */
  .toast-enter-active,
  .toast-leave-active {
    transition: all 0.3s ease;
  }
  .toast-enter-from,
  .toast-leave-to {
    opacity: 0;
    transform: translateX(1rem);
  }

  /* BANNED: gradient-card, gradient-card-dark, gradient-button
     Use .glass-card or .path-option-card for containers.
     Use .glass-button for all buttons.
     These gradient styles break the clean glass aesthetic. */

  /* Gradient border for logo badge */
  .logo-gradient-border {
    position: relative;
    border-radius: 9999px;
    padding: 3px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(0, 0, 0, 0.8) 100%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }

  .logo-gradient-border::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 9999px;
    background: #000;
    z-index: 0;
  }

  .logo-gradient-border img,
  .logo-gradient-border svg {
    border-radius: 9999px;
    display: block;
    position: relative;
    z-index: 1;
  }

  /* Gradient border container for large content areas */
  .gradient-border-container {
    position: relative;
    border-radius: 1.5rem;
    padding: 4px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.6) 100%);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  }

  .gradient-border-container-inner {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: 1.25rem;
  }

  /* Choose Your Path - Main Container */
  .path-glass-container {
    width: calc(100% - 48px);
    max-width: 1200px;
    margin: 40px auto;
    padding: 32px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
      0 20px 60px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-x: hidden;
  }

  /* Choose Your Path - Option Cards */
  .path-option-card {
    position: relative;
    background: rgba(0, 0, 0, 0.60);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    padding: 12px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
  }

  /* Gradient border effect using CSS mask - default is subtle */
  .path-option-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), transparent);
    -webkit-mask:
      linear-gradient(#fff 0 0) content-box,
      linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
  }

  /* Icon styling with black glass effect */
  .path-option-card svg {
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s ease;
    filter:
      drop-shadow(0 1px 1px rgba(255, 255, 255, 0.3))
      drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8))
      drop-shadow(0 -1px 2px rgba(0, 0, 0, 0.6));
    stroke-width: 2.5;
  }

  .path-option-card:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.35);
    box-shadow:
      0 12px 32px rgba(0, 0, 0, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.25);
  }

  .path-option-card:hover::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
  }

  .path-option-card:hover svg {
    color: rgba(255, 255, 255, 1);
    filter:
      drop-shadow(0 1px 2px rgba(255, 255, 255, 0.5))
      drop-shadow(0 3px 6px rgba(0, 0, 0, 0.9))
      drop-shadow(0 -1px 3px rgba(0, 0, 0, 0.7));
  }

  /* Selected state */
  .path-option-card--selected {
    background: rgba(255, 255, 255, 0.12);
    box-shadow:
      0 12px 32px rgba(0, 0, 0, 0.6),
      0 0 30px rgba(255, 255, 255, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
  }

  .path-option-card--selected::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6), transparent);
  }

  .path-option-card--selected svg {
    color: rgba(255, 255, 255, 1);
    filter:
      drop-shadow(0 1px 2px rgba(255, 255, 255, 0.6))
      drop-shadow(0 3px 8px rgba(0, 0, 0, 1))
      drop-shadow(0 0 12px rgba(255, 255, 255, 0.3));
  }

  .path-option-card--selected h3 {
    color: rgba(255, 255, 255, 1);
  }

  /* Action Buttons */
  .path-action-button {
    font-size: 18px;
  font-weight: 500;
    line-height: 1.4;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.25);
    color: rgba(255, 255, 255, 0.96);
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: none;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 0;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }

  .path-action-button--skip {
    padding: 12px 40px;
    font-size: 16px;
  }

  .path-action-button--skip::before {
    display: none;
  }

  .path-action-button--continue {
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 600;
  }

  .path-action-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), transparent);
    -webkit-mask: 
      linear-gradient(#fff 0 0) content-box, 
      linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
  }

  .path-action-button:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.35);
    box-shadow:
      0 12px 32px rgba(0, 0, 0, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

  .path-action-button:hover::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
  }

  .path-action-button:active {
    background: rgba(0, 0, 0, 0.55);
    transform: translateY(1px);
  }

  /* Active Navigation Tab Style - matches hover container */
  .nav-tab-active {
    position: relative;
    background: rgba(0, 0, 0, 0.35) !important;
    box-shadow:
      0 6px 16px rgba(0, 0, 0, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
    color: rgba(255, 255, 255, 1) !important;
    font-weight: 600 !important;
  }

  .nav-tab-active::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
    -webkit-mask: 
      linear-gradient(#fff 0 0) content-box, 
      linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
  }

  /* Sidebar nav items: grow + glow on gamepad focus (same as containers) */
  .sidebar-nav-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .sidebar-nav-item:focus-visible {
    transform: scale(1.02) !important;
    box-shadow:
      0 0 24px rgba(120, 180, 255, 0.15),
      0 0 48px rgba(100, 160, 255, 0.08),
      inset 0 0 24px rgba(255, 255, 255, 0.03) !important;
  }
}

/* Background image */
body {
  margin: 0;
  font-family: 'Avenir Next', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #000;
  color: white;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

/* Custom scrollbar for glass containers */
.custom-scrollbar::-webkit-scrollbar {
  width: 10px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, 0.2);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%);
}

/* Hide scrollbar but keep scroll functionality - applied globally to all scrollable content */
.scrollbar-hide,
.overflow-y-auto,
.overflow-auto,
.overflow-y-scroll,
.iframe-scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar,
.overflow-auto::-webkit-scrollbar,
.overflow-y-scroll::-webkit-scrollbar,
.iframe-scrollbar-hide::-webkit-scrollbar {
  display: none;
}
/* Iframe scrollbar hide - targets iframe element; inner doc scrollbars need same-origin injection */
iframe.iframe-scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Animations */
@keyframes fadeUpIn {
  0% {
    opacity: 0;
    transform: translateY(28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes caretBlink {
  0%, 100% { 
    border-right-color: #00ffff;
  }
  50% { 
    border-right-color: transparent;
  }
}

.animate-fade-up {
  animation: fadeUpIn 900ms cubic-bezier(0.22, 1, 0.36, 1) 120ms both;
}

.animate-fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.animate-fade-out {
  animation: fadeOut 0.8s ease forwards;
}

.typing-text {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 0;
  border-right: 4px solid #fbbf24;
  animation:
    typing 2s steps(30, end) forwards,
    caretBlink 0.5s step-end 3 2.6s;
}

/* Adjust typing animation to use max-width for better centering */
@keyframes typing {
  from {
    max-width: 0;
  }
  to {
    max-width: 100%;
  }
}

@keyframes caretBlink {
  0%, 100% { 
    border-right-color: #fbbf24;
  }
  50% { 
    border-right-color: transparent;
  }
}

/* Splash screen styles */
.splash-complete .login-card {
  animation: fadeUpIn 900ms cubic-bezier(0.22, 1, 0.36, 1) 120ms both;
}

/* Background glitch effect - continuous every 5s */
body::before,
body::after,
html::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

/* Subtle black glitch overlay - delay to avoid flash of partial clip-path on first paint (black crescent bug) */
body::before {
  background-image: url('/assets/img/bg.jpg');
  background-size: auto 100vh;
  background-position: center top;
  background-attachment: fixed;
  mix-blend-mode: multiply;
  filter: brightness(0.4) contrast(1.2);
  will-change: transform, clip-path, opacity;
  animation: bg-glitch-shift-repeat 5s steps(10, end) infinite;
  animation-delay: 1.5s;
  animation-fill-mode: backwards;
}

/* Second subtle black layer */
html::before {
  background-image: url('/assets/img/bg.jpg');
  background-size: auto 100vh;
  background-position: center top;
  background-attachment: fixed;
  mix-blend-mode: multiply;
  filter: brightness(0.3) contrast(1.3);
  will-change: transform, clip-path, opacity;
  animation: bg-glitch-shift-2-repeat 5s steps(9, end) infinite;
  animation-delay: 1.6s;
  animation-fill-mode: backwards;
}

/* Subtle scanline sweep */
body::after {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0) 60%),
    repeating-linear-gradient(180deg, rgba(0,0,0,0.02) 0 2px, rgba(0,0,0,0) 2px 4px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.15) 100%);
  will-change: transform, opacity;
  animation: bg-glitch-scan-repeat 5s ease-out infinite;
  animation-delay: 1.5s;
  animation-fill-mode: backwards;
}

/* Dashboard: full viewport width, no letterboxing */
body.dashboard-active {
  overflow-x: hidden;
  width: 100%;
}

body.dashboard-active .dashboard-view .bg-perspective-container {
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  min-width: 100% !important;
}

/* Disable glitch effect on dashboard */
.dashboard-view ~ body::before,
.dashboard-view ~ body::after,
.dashboard-view ~ html::before {
  animation: none !important;
  opacity: 0 !important;
}

/* Alternative approach - disable on body when dashboard is active */
body:has(.dashboard-view)::before,
body:has(.dashboard-view)::after,
html:has(.dashboard-view)::before {
  animation: none !important;
  opacity: 0 !important;
}

/* Disable glitch effect on video background screens (onboarding intro/login) */
body.video-background-active::before,
body.video-background-active::after,
html:has(body.video-background-active)::before {
  animation: none !important;
  opacity: 0 !important;
  display: none !important;
}

/* Repeating glitch animations - every 5 seconds (subtle) */
@keyframes bg-glitch-shift-repeat {
  0%, 82% { transform: translate(0,0); clip-path: inset(0% 0 0 0); opacity: 0; }
  82.1% { opacity: .08; }
  84% { transform: translate(3px,-1px); clip-path: inset(8% 0 70% 0); }
  86% { transform: translate(-3px,1px); clip-path: inset(42% 0 40% 0); }
  88% { transform: translate(2px,0); clip-path: inset(68% 0 10% 0); }
  91% { transform: translate(-2px,2px); clip-path: inset(18% 0 60% 0); }
  93% { transform: translate(3px,-2px); clip-path: inset(55% 0 20% 0); }
  95% { transform: translate(-2px,1px); clip-path: inset(10% 0 80% 0); }
  100% { transform: translate(0,0); clip-path: inset(0% 0 0 0); opacity: 0; }
}

@keyframes bg-glitch-scan-repeat {
  0%, 82% { opacity: 0; transform: translateY(-20%); }
  84% { opacity: 0.15; }
  90% { opacity: 0.10; }
  100% { opacity: 0; transform: translateY(115%); }
}

@keyframes bg-glitch-shift-2-repeat {
  0%, 82% { transform: translate(0,0); clip-path: inset(0% 0 0 0); opacity: 0; }
  82.1% { opacity: .06; }
  84% { transform: translate(-3px,1px); clip-path: inset(12% 0 65% 0); }
  86% { transform: translate(3px,-1px) skewX(0.3deg); clip-path: inset(36% 0 42% 0); }
  89% { transform: translate(-2px,1px); clip-path: inset(72% 0 8% 0); }
  92% { transform: translate(2px,-2px); clip-path: inset(22% 0 58% 0); }
  95% { transform: translate(-2px,1px); clip-path: inset(50% 0 26% 0); }
  100% { transform: translate(0,0); clip-path: inset(0% 0 0 0); opacity: 0; }
}

/* ── Cloud File Browser (AIUI-style list cards) ──── */

.cloud-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding-bottom: 1rem;
}

.cloud-file-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  align-items: center;
}
.cloud-file-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.cloud-file-item:active {
  background: rgba(255, 255, 255, 0.1);
}
.cloud-file-item:focus-visible {
  box-shadow: 0 0 16px rgba(120, 180, 255, 0.2), 0 0 32px rgba(100, 160, 255, 0.1);
}

.cloud-file-item-thumb {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  overflow: hidden;
}

.cloud-file-item-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}
.cloud-file-item:hover .cloud-file-item-actions,
.cloud-file-item:focus-within .cloud-file-item-actions {
  opacity: 1;
}

.cloud-file-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.cloud-file-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}
.cloud-file-action-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.cloud-file-badge {
  display: inline-flex;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.cloud-file-item-skeleton {
  pointer-events: none;
}

/* Toolbar */
.cloud-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cloud-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  min-width: 0;
}

.cloud-breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.25rem 0.375rem;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.5);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.cloud-breadcrumb-item:hover:not(.cloud-breadcrumb-active) {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}
.cloud-breadcrumb-active {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  cursor: default;
}

.cloud-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

/* View toggle */
.cloud-view-toggle {
  display: flex;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.cloud-view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  cursor: pointer;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  transition: all 0.15s ease;
}
.cloud-view-toggle-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.05);
}
.cloud-view-toggle-active {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

/* ── Cloud Card Grid (AIUI-style poster cards) ──── */

.cloud-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding-bottom: 1rem;
}
@media (min-width: 640px) {
  .cloud-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1024px) {
  .cloud-card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cloud-grid-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  width: 100%;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: all 0.2s ease;
  color: inherit;
  padding: 0;
}
.cloud-grid-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}
.cloud-grid-card:active {
  transform: translateY(0);
}
.cloud-grid-card:focus-visible {
  box-shadow: 0 0 16px rgba(120, 180, 255, 0.2), 0 0 32px rgba(100, 160, 255, 0.1);
}

.cloud-grid-card-cover {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 0.625rem;
}

.cloud-grid-card-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent 60%);
  pointer-events: none;
}

.cloud-grid-card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  z-index: 1;
}

.cloud-grid-card-badges {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  display: flex;
  gap: 0.25rem;
  z-index: 1;
}
.cloud-grid-card-badge {
  font-size: 0.625rem;
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: rgba(255, 255, 255, 0.7);
}

/* Play button overlay (audio/video) */
.cloud-grid-card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  backdrop-filter: blur(2px);
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.cloud-grid-card:hover .cloud-grid-card-play {
  opacity: 1;
}
.cloud-grid-card-play-btn {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease;
}
.cloud-grid-card:hover .cloud-grid-card-play-btn {
  transform: scale(1.1);
}

/* Actions overlay (top-left, on hover) */
.cloud-grid-card-actions {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  display: flex;
  gap: 0.25rem;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.cloud-grid-card:hover .cloud-grid-card-actions {
  opacity: 1;
}

/* Grid skeleton */
.cloud-grid-card-skeleton {
  border-radius: 0.75rem;
  overflow: hidden;
}

/* Playing state — keep play overlay visible */
.cloud-grid-card-play-active {
  opacity: 1 !important;
  background: rgba(0, 0, 0, 0.4);
}

/* ── Mobile floating back/close button (always 8px above tab bar) ──── */
.mobile-back-btn {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(var(--mobile-tab-bar-height, 72px) + 8px);
  z-index: 40;
  filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.5));
}

/* ── Cloud Audio Player (mini bar) ──── */

.cloud-audio-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  flex-shrink: 0;
}
.cloud-audio-player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  padding: 0;
}
.cloud-audio-player-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.cloud-audio-progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 0.375rem;
  overflow: hidden;
}
.cloud-audio-progress-bar {
  height: 100%;
  background: #fb923c;
  border-radius: 2px;
  transition: width 0.3s linear;
}

/* ── Cloud Drag-and-Drop Overlay ──── */

.cloud-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 0.75rem;
  border: 2px dashed rgba(251, 146, 60, 0.6);
  animation: drop-overlay-in 0.2s ease-out;
}
.cloud-drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem;
}
@keyframes drop-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
