@font-face {
  font-family: 'Baloo 2';
  src: url("/fonts/Baloo2-VariableFont_wght.ttf") format('truetype');
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: 'Nunito Sans';
  src: url("/fonts/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf") format('truetype');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Nunito Sans';
  src: url("/fonts/NunitoSans-Italic-VariableFont_YTLC,opsz,wdth,wght.ttf") format('truetype');
  font-weight: 200 1000;
  font-style: italic;
  font-display: swap;
}

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

/* Accessibility: Global focus-visible styles */
@layer base {
  a:focus-visible,
  button:focus-visible,
  [role="button"]:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    @apply outline-none ring-2 ring-amber-500 ring-offset-2;
  }
}

/* Cropper.js styles */
.cropper-container {
  direction: ltr;
  font-size: 0;
  line-height: 0;
  position: relative;
  touch-action: none;
  user-select: none;
}

.cropper-container img {
  display: block;
  height: 100%;
  image-orientation: 0deg;
  max-height: none !important;
  max-width: none !important;
  min-height: 0 !important;
  min-width: 0 !important;
  width: 100%;
}

.cropper-wrap-box,
.cropper-canvas,
.cropper-drag-box,
.cropper-crop-box,
.cropper-modal {
  bottom: 0;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.cropper-wrap-box,
.cropper-canvas {
  overflow: hidden;
}

/* Solid background to prevent checkerboard transparency pattern */
.cropper-wrap-box {
  background-color: #1c1917 !important;
}

.cropper-canvas {
  background-color: #1c1917 !important;
}

.cropper-drag-box {
  background-color: #fff;
  opacity: 0;
}

.cropper-modal {
  /* Darker overlay to clearly show excluded area */
  background-color: rgba(0, 0, 0, 0.7) !important;
}

.cropper-view-box {
  display: block;
  height: 100%;
  outline: 1px solid rgba(255, 255, 255, 0.75);
  outline-offset: -1px;
  overflow: hidden;
  width: 100%;
}

.cropper-dashed {
  border: 0 dashed #eee;
  display: block;
  opacity: 0.5;
  position: absolute;
}

.cropper-dashed.dashed-h {
  border-bottom-width: 1px;
  border-top-width: 1px;
  height: calc(100% / 3);
  left: 0;
  top: calc(100% / 3);
  width: 100%;
}

.cropper-dashed.dashed-v {
  border-left-width: 1px;
  border-right-width: 1px;
  height: 100%;
  left: calc(100% / 3);
  top: 0;
  width: calc(100% / 3);
}

.cropper-center {
  display: block;
  height: 0;
  left: 50%;
  opacity: 0.75;
  position: absolute;
  top: 50%;
  width: 0;
}

.cropper-center::before,
.cropper-center::after {
  background-color: #eee;
  content: ' ';
  display: block;
  position: absolute;
}

.cropper-center::before {
  height: 1px;
  left: -3px;
  top: 0;
  width: 7px;
}

.cropper-center::after {
  height: 7px;
  left: 0;
  top: -3px;
  width: 1px;
}

.cropper-face,
.cropper-line,
.cropper-point {
  display: block;
  height: 100%;
  opacity: 0.1;
  position: absolute;
  width: 100%;
}

.cropper-face {
  background-color: #fff;
  left: 0;
  top: 0;
}

.cropper-line {
  background-color: rgba(255, 255, 255, 0.5);
}

.cropper-line.line-e {
  cursor: ew-resize;
  right: -3px;
  top: 0;
  width: 5px;
}

.cropper-line.line-n {
  cursor: ns-resize;
  height: 5px;
  left: 0;
  top: -3px;
}

.cropper-line.line-w {
  cursor: ew-resize;
  left: -3px;
  top: 0;
  width: 5px;
}

.cropper-line.line-s {
  bottom: -3px;
  cursor: ns-resize;
  height: 5px;
  left: 0;
}

.cropper-point {
  background-color: #f59e0b;
  height: 10px;
  opacity: 0.75;
  width: 10px;
}

.cropper-point.point-e {
  cursor: ew-resize;
  margin-top: -3px;
  right: -3px;
  top: 50%;
}

.cropper-point.point-n {
  cursor: ns-resize;
  left: 50%;
  margin-left: -3px;
  top: -3px;
}

.cropper-point.point-w {
  cursor: ew-resize;
  left: -3px;
  margin-top: -3px;
  top: 50%;
}

.cropper-point.point-s {
  bottom: -3px;
  cursor: s-resize;
  left: 50%;
  margin-left: -3px;
}

.cropper-point.point-ne {
  cursor: nesw-resize;
  right: -3px;
  top: -3px;
}

.cropper-point.point-nw {
  cursor: nwse-resize;
  left: -3px;
  top: -3px;
}

.cropper-point.point-sw {
  bottom: -3px;
  cursor: nesw-resize;
  left: -3px;
}

.cropper-point.point-se {
  bottom: -3px;
  cursor: nwse-resize;
  height: 20px;
  opacity: 1;
  right: -3px;
  width: 20px;
}

@media (min-width: 768px) {
  .cropper-point.point-se {
    height: 15px;
    width: 15px;
  }
}

.cropper-point.point-se::before {
  background-color: #f59e0b;
  bottom: -50%;
  content: ' ';
  display: block;
  height: 200%;
  opacity: 0;
  position: absolute;
  right: -50%;
  width: 200%;
}

.cropper-invisible {
  opacity: 0;
}

.cropper-bg {
  /* Solid dark background instead of checkerboard */
  background-color: #292524;
  background-image: none !important;
}

.cropper-hide {
  display: block;
  height: 0;
  position: absolute;
  width: 0;
}

.cropper-hidden {
  display: none !important;
}

.cropper-move {
  cursor: move;
}

.cropper-crop {
  cursor: crosshair;
}

.cropper-disabled .cropper-drag-box,
.cropper-disabled .cropper-face,
.cropper-disabled .cropper-line,
.cropper-disabled .cropper-point {
  cursor: not-allowed;
}

/* Circular avatar crop overlay */
.avatar-crop-circle .cropper-view-box,
.avatar-crop-circle .cropper-face {
  border-radius: 50%;
}

@layer components {
  .brush-button {
    @apply px-4 py-2 rounded-lg border-2 border-gray-200 bg-white text-gray-700
           transition-all duration-150 hover:border-gray-300;
  }
  .brush-button.active[data-brush="yes"] {
    @apply border-green-500 bg-green-50 text-green-800 ring-2 ring-green-200 ring-offset-1;
  }
  .brush-button.active[data-brush="maybe"] {
    @apply border-yellow-500 bg-yellow-50 text-yellow-800 ring-2 ring-yellow-200 ring-offset-1;
  }
  .brush-button.active[data-brush="clear"] {
    @apply border-gray-400 bg-gray-100 text-gray-800 ring-2 ring-gray-200 ring-offset-1;
  }

  /* Split-flap display animation */
  .split-flap-container {
    display: inline-block;
    vertical-align: baseline;
  }

  .split-flap-word {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 0.6em;
    gap: 0.08em;
    perspective: 1000px;
    /* Reserve space to prevent layout shift before JS renders */
    /* 10 chars × 0.6em + 9 gaps × 0.08em ≈ 6.7em width */
    min-width: 6.7em;
    min-height: 1.2em;
  }

  .split-flap-char {
    position: relative;
    display: block;
    width: 100%;
    height: 1.2em;
    transform-style: preserve-3d;
    font: inherit;
    text-transform: lowercase;
  }

  /* All four flaps share these base styles */
  .split-flap-char .top,
  .split-flap-char .bottom,
  .split-flap-char .top-next,
  .split-flap-char .bottom-next {
    border-radius: 4px;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: white;
    background: linear-gradient(180deg, #1c1917 0%, #292524 100%);
    backface-visibility: hidden;
  }

  /* Top halves clipped */
  .split-flap-char .top,
  .split-flap-char .top-next {
    clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
  }

  /* Bottom halves clipped */
  .split-flap-char .bottom,
  .split-flap-char .bottom-next {
    clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  }

  /* Divider line */
  .split-flap-char .divider {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #44403c;
    z-index: 10;
    transform: translateY(-50%);
  }

  /* Split-flap sound toggle button */
  .split-flap-sound-toggle {
    @apply p-1 text-stone-300 hover:text-stone-500 transition-colors rounded;
    /* Subtle appearance, doesn't distract from the animation */
  }

  .split-flap-sound-toggle:hover {
    @apply bg-stone-100;
  }

  /* When unmuted, show a subtle indicator */
  .split-flap-sound-toggle[data-active="true"] {
    @apply text-amber-500;
  }

  /* Toast animations */
  .animate-slide-up {
    animation: slideUp 0.3s ease-out forwards;
  }

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

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

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

/* Hide scrollbar but allow scrolling */
.scrollbar-hide {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Chrome, Safari, Opera */
}
