@import "https://esm.sh/tailwindcss/index.css";
/* @import "tailwindcss"; */
@import "./styles/colors.css";
@import "./styles/global-styles.css";

@theme {
  /* Color definitions - these will be available as bg-midnight, text-tahiti, etc. */
  --color-midnight: #333;
  --color-tahiti: #999;
  --color-bermuda: #ccc;

  /* Light mode colors */
  --color-light-primary: #333;
  --color-light-secondary: #333;
  --color-light-decorative-00: #eee;
  --color-light-decorative-01: #ddd;
  --color-light-decorative-02: #333;
  --color-light-background-00: #fff;
  --color-light-background-01: #eee;
  --color-light-background-02: #ddd;

  /* Dark mode colors */
  --color-dark-primary: #fff;
  --color-dark-secondary: #fff;
  --color-dark-decorative-00: #333;
  --color-dark-decorative-01: #444;
  --color-dark-decorative-02: #fff;
  --color-dark-background-00: #111;
  --color-dark-background-01: #222;
  --color-dark-background-02: #222;

  /* Accent colors - Light mode */
  --color-accent-00-light: #aaa;
  --color-accent-01-light: #999;
  --color-accent-02-light: #888;
  --color-accent-03-light: #777;

  /* Accent colors - Dark mode */
  --color-accent-00-dark: #bbb;
  --color-accent-01-dark: #aaa;
  --color-accent-02-dark: #777;
  --color-accent-03-dark: #666;

  --font-sans:
    "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

html {
  margin: 0;
  padding: 0;
}

body {
  @apply bg-light-background-00 dark:bg-dark-background-00 text-light-primary dark:text-dark-primary;
  margin: 0;
  padding: 0;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Roboto",
    "Oxygen",
    "Ubuntu",
    "Cantarell",
    "Fira Sans",
    "Droid Sans",
    "Helvetica Neue",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 100%;
  height: 100%;

  @media (prefers-color-scheme: dark) {
    color-scheme: dark;
  }
}

hr {
  opacity: 0.5;
}

/* Force dark mode based on system preference, regardless of class strategy */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }

  html,
  body {
    background-color: var(--color-dark-background-00);
    color: var(--color-dark-primary);
  }

  /* This adds all the standard dark mode styles that would normally require the 'dark' class */
  .text-accent-02 {
    color: var(--color-dark-secondary);
  }

  .text-accent-00 {
    color: var(--color-dark-accent-01);
  }
}

/* iOS-specific fix for dark mode */
@supports (-webkit-touch-callout: none) {
  @media (prefers-color-scheme: dark) {
    html,
    body {
      /* Force background color on iOS Safari */
      background-color: var(--color-dark-background-00);
      color: var(--color-dark-primary);
    }
  }
}

#root {
  height: 100%;
}

button {
  font-family: inherit;
}

/* Prevent auto-zoom on input focus in mobile Safari */
input,
textarea,
select {
  font-size: 16px; /* prevents auto-zoom */
}

/* Ensure all buttons and links show pointer cursor on hover */
button,
a,
[role="button"],
[type="button"],
[type="submit"],
[type="reset"] {
  cursor: pointer;
}

.light {
  --sp-layout-height: 100vh !important;
}

/* Animation for share status message */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Animation for new chat bounce effect */
@keyframes bounceIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

.animate-bounce-in {
  animation: bounceIn 0.5s ease-out forwards;
}

/* Add the color utility classes */
.accent-00 {
  @apply bg-accent-00-light dark:bg-accent-00-dark;
}

.accent-01 {
  @apply bg-accent-01-light dark:bg-accent-01-dark;
}

.accent-02 {
  @apply bg-accent-02-light dark:bg-accent-02-dark;
}

.accent-03 {
  @apply bg-accent-03-light dark:bg-accent-03-dark;
}

.text-accent-00 {
  @apply text-accent-00-light dark:text-accent-00-dark;
}

.text-accent-01 {
  @apply text-accent-01-light dark:text-accent-01-dark;
}

.text-accent-02 {
  @apply text-accent-02-light dark:text-accent-02-dark;
}

.text-accent-03 {
  @apply text-accent-03-light dark:text-accent-03-dark;
}

.decorative-00 {
  @apply bg-light-decorative-00 dark:bg-dark-decorative-00;
}

.decorative-01 {
  @apply bg-light-decorative-01 dark:bg-dark-decorative-01;
}

.decorative-02 {
  @apply bg-light-decorative-02 dark:bg-dark-decorative-02;
}

.bg-primary {
  @apply bg-light-background-00 dark:bg-dark-background-00;
}

.bg-secondary {
  @apply bg-light-background-01 dark:bg-dark-background-01;
}

.bg-tertiary {
  @apply bg-light-background-02 dark:bg-dark-background-02;
}

/* Button glimmer animation */
@keyframes buttonGlimmer {
  0% {
    background-position: -100% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Gradient animation for glimmer */
@keyframes gradientGlimmer {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

/* Simple glimmer without positioning for button backgrounds */
.bg-glimmer {
  position: relative;
  overflow: hidden;
  z-index: 0;
}

.bg-glimmer::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: -1;
  background-image: linear-gradient(
    -45deg,
    #f2f2f2 0%,
    #f7f7f7 40%,
    #e0e0e0 42%,
    #ffffff 50%,
    #e0e0e0 52%,
    #f7f7f7 60%,
    #f2f2f2 100%
  );
  background-size: 300% 300%;
  animation: gradientGlimmer 30s ease infinite;
  transition: filter 0.2s ease;
}

/* Hover state for light mode - darken and pause */
button:hover .bg-glimmer::before,
.bg-glimmer:hover::before {
  animation-play-state: paused;
}

button:hover .bg-glimmer,
.bg-glimmer:hover {
  filter: brightness(0.95);
}

/* Dark mode variant */
.dark .bg-glimmer::before {
  background-image: linear-gradient(
    -45deg,
    #363636 0%,
    #404040 40%,
    #303030 42%,
    #4a4a4a 50%,
    #303030 52%,
    #404040 60%,
    #363636 100%
  );
  background-size: 300% 300%;
}

/* Hover state for dark mode - lighten and pause */
.dark button:hover .bg-glimmer::before,
.dark .bg-glimmer:hover::before {
  animation-play-state: paused;
}

.dark button:hover .bg-glimmer,
.dark .bg-glimmer:hover {
  filter: brightness(1.1);
}

/* Monochrome glimmer effect for borders */
.border-glimmer {
  position: absolute;
  overflow: visible;
  border: none;
}

.border-glimmer::before {
  content: "";
  position: absolute;
  inset: -2px; /* Slightly larger than the button */
  border-radius: inherit;
  padding: 2px; /* Border thickness */
  background: linear-gradient(
    120deg,
    transparent 0%,
    transparent 10%,
    rgba(175, 175, 175, 0.2) 15%,
    rgba(186, 186, 186, 0.3) 23%,
    rgba(145, 145, 145, 0.4) 32%,
    rgba(216, 216, 216, 0.5) 35%,
    rgba(255, 255, 255, 0.6) 40%,
    transparent 70%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  background-position: -100% 0;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: buttonGlimmer 8.5s infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Dark mode adjustment */
@media (prefers-color-scheme: dark) {
  .border-glimmer::before {
    background: linear-gradient(
      120deg,
      transparent 0%,
      transparent 10%,
      rgba(100, 100, 100, 0.3) 20%,
      rgba(150, 150, 150, 0.4) 33%,
      rgba(200, 200, 200, 0.5) 34%,
      rgba(220, 220, 220, 0.6) 36%,
      rgba(255, 255, 255, 0.4) 40%,
      transparent 70%
    );
    background-size: 200% 100%;
    background-repeat: no-repeat;
    background-position: -100% 0;
    animation: buttonGlimmer 11s infinite;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Keep the original glimmer-overlay class */
.glimmer-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 0%,
    transparent 10%,
    rgba(255, 145, 0, 0.2) 15%,
    rgba(255, 166, 0, 0.2) 20%,
    rgba(255, 185, 30, 0.2) 34%,
    rgba(255, 216, 107, 0.2) 35%,
    rgba(255, 255, 255, 0.2) 40%,
    transparent 70%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  background-position: -100% 0;
  animation: buttonGlimmer 4.5s infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode adjustment */
@media (prefers-color-scheme: dark) {
  .glimmer-overlay {
    background: linear-gradient(
      120deg,
      transparent 0%,
      transparent 10%,
      rgba(255, 140, 0, 0.2) 20%,
      rgba(253, 158, 6, 0.2) 33%,
      rgba(255, 185, 30, 0.2) 34%,
      rgba(255, 186, 0, 0.2) 36%,
      rgba(255, 136, 0, 0.2) 40%,
      transparent 70%
    );
    background-size: 200% 100%;
    background-repeat: no-repeat;
    background-position: -100% 0;
    animation: buttonGlimmer 4.5s infinite;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Default (Light Mode) Button Gradients */
.light-gradient {
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255, 255, 255, 1) 45%,
    white 89%
  );
}

/* Dark Mode Button Gradients */
@media (prefers-color-scheme: dark) {
  .light-gradient {
    background: linear-gradient(
      110deg,
      transparent 0%,
      rgba(0, 0, 0, 1) 45%,
      black 89%
    );
  }
}

.pulsing {
  width: 100%;
  height: auto;
  transform: rotate(-5deg) scale(6);
  animation: pulse 8s infinite;
}

@keyframes pulse {
  0% {
    transform: rotate(-5deg) scale(1);
  }
  50% {
    transform: rotate(0deg) scale(1.05);
  }
  100% {
    transform: rotate(-5deg) scale(1);
  }
}
.logo-pulse {
  transform: rotate(-5deg) scale(3);
  animation:
    logo-rotate 1410s ease-in-out infinite,
    logo-pulse-height 711s ease-in-out infinite;
}

@keyframes logo-rotate {
  0% {
    transform: rotate(45deg) scale(5.5);
  }
  66% {
    transform: rotate(0deg) scale(1);
  }
  100% {
    transform: rotate(45deg) scale(5.5);
  }
}

@keyframes logo-pulse-height {
  0% {
    width: 200%;
  }
  50% {
    width: 20%;
  }
  100% {
    width: 200%;
  }
}

.ai-markdown p {
  margin-bottom: 0.5rem;
}

.ai-markdown ul {
  list-style-type: disc;
  padding-left: 1rem;
  padding-top: 0.5rem;
}

.ai-markdown ol {
  list-style-type: decimal;
  padding-left: 1rem;
  padding-top: 0.5rem;
}

.ai-markdown li {
  margin-bottom: 0.5rem;
}

.ai-markdown h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.ai-markdown h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

.ai-markdown h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

/* Animated gradient background utility */
@keyframes gradient-x {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
.animate-gradient-x {
  background-size: 200% auto;
  animation: gradient-x 3s linear infinite;
}

/* === Loading stripes overlay === */
@keyframes moving-stripes {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 0;
  }
}

.stripes-overlay {
  position: relative;
  overflow: hidden; /* ensure stripes clipped to element */
}

.stripes-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.35) 0px,
    rgba(255, 255, 255, 0.35) 12px,
    transparent 12px,
    transparent 24px
  );
  background-size: 40px 40px;
  animation: moving-stripes 1s linear infinite;
}

@media (prefers-color-scheme: dark) {
  .stripes-overlay::after {
    background-image: repeating-linear-gradient(
      135deg,
      rgba(0, 0, 0, 0.4) 0px,
      rgba(0, 0, 0, 0.4) 12px,
      transparent 12px,
      transparent 24px
    );
  }
}

/* Grid background pattern inspired by catalog title page */
.grid-background {
  background-color: #d4d4d4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: scroll;
}

@media (min-width: 768px) {
  .grid-background {
    background-attachment: fixed;
  }
}

@media (prefers-color-scheme: dark) {
  .grid-background {
    background-color: #2a2a2a;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
  }
}

/* Page-specific body background for create page */
.page-grid-background {
  /* This class on a page root will apply grid to body for over-scroll areas */
}

body:has(.page-grid-background) {
  background-color: #d4d4d4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: scroll;
}

@media (min-width: 768px) {
  body:has(.page-grid-background) {
    background-attachment: fixed;
  }
}

@media (prefers-color-scheme: dark) {
  body:has(.page-grid-background) {
    background-color: #2a2a2a;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
  }
}

/* Vibes Login Button - themed button with interactive states */
.vibes-login-button {
  width: 100%;
  padding: 1rem 2rem;
  background: var(--color-light-background-00);
  color: var(--color-light-primary);
  border: 3px solid var(--color-light-primary);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  transform: translate(0px, 0px);
  box-shadow: 4px 5px 0px 0px #009ace;
}

.vibes-login-button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 3px 0px 0px #009ace;
}

.vibes-login-button:active {
  transform: translate(4px, 5px);
  box-shadow: none;
}

.vibes-login-button:focus-visible {
  outline: 3px solid #009ace;
  outline-offset: 4px;
}

@media (prefers-color-scheme: dark) {
  .vibes-login-button {
    background: var(--color-dark-background-00);
    color: var(--color-dark-primary);
    border-color: var(--color-dark-primary);
  }
}
