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

/* Global focus ring for accessibility */
:root {
  --ring-color: 0 0 0;
}

:focus-visible {
  outline: 2px solid rgb(59 130 246 / 0.8);
  outline-offset: 2px;
}

/* Readable measure for long-form content */
.prose-measure {
  max-width: 75ch;
}

/* Typography clamps */
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
p, li { font-size: clamp(1rem, 2.5vw, 1.125rem); line-height: 1.7; }

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@layer base {
  p,
  li,
  div {
    line-height: 1.5;
  }
}

@layer utilities {
  .bg-page {
    background-color: var(--aw-color-bg-page);
  }
  .bg-dark {
    background-color: var(--aw-color-bg-page-dark);
  }
  .bg-light {
    background-color: var(--aw-color-bg-page);
  }
  .text-page {
    color: var(--aw-color-text-page);
  }
  .text-muted {
    color: var(--aw-color-text-muted);
  }
  
  /* Responsive subtitle utility */
  .subtitle-responsive {
    @apply text-base md:text-lg lg:text-xl;
  }
}

@layer components {
  /* Shared glass and card utilities */
  .glass {
    @apply bg-white/80 dark:bg-slate-900/80 backdrop-blur-lg border border-white/20 dark:border-white/10 shadow-lg;
  }

  .glass-strong {
    @apply bg-white/90 dark:bg-slate-900/90 backdrop-blur-xl border border-white/30 dark:border-white/10 shadow-xl;
  }

  .card-panel {
    @apply rounded-2xl glass p-6 transition-shadow duration-200 hover:shadow-xl;
  }

  .btn {
    @apply inline-flex items-center justify-center rounded-full border-gray-400 border bg-transparent font-medium text-center text-base text-page leading-snug transition py-3.5 px-6 md:px-8 ease-in duration-200 focus:ring-blue-500 focus:ring-offset-blue-200 focus:ring-2 focus:ring-offset-2 hover:bg-gray-100 hover:border-gray-600 dark:text-slate-300 dark:border-slate-500 dark:hover:bg-slate-800 dark:hover:border-slate-800 cursor-pointer;
    /* Enhanced visibility for light mode */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }

  .btn-primary {
    @apply btn font-semibold bg-primary text-white border-primary hover:bg-secondary hover:border-secondary hover:text-white dark:text-white dark:bg-primary dark:border-primary dark:hover:border-secondary dark:hover:bg-secondary;
  }

  .btn-secondary {
    @apply btn;
    /* Enhanced visibility for light mode secondary buttons */
    color: rgb(16 16 16);
    border-color: rgb(156 163 175);
  }

  /* Light mode specific enhancements for secondary buttons */
  html:not(.dark) .btn-secondary {
    color: rgb(16 16 16) !important;
    border-color: rgb(156 163 175) !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  }

  html:not(.dark) .btn-secondary:hover {
    background-color: rgb(243 244 246) !important;
    border-color: rgb(107 114 128) !important;
    color: rgb(16 16 16) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }

  .btn-tertiary {
    @apply btn border-none shadow-none text-muted hover:text-gray-900 dark:text-gray-400 dark:hover:text-white;
  }
}

#header.scroll > div:first-child {
  @apply bg-page md:bg-white/90 md:backdrop-blur-md;
  box-shadow: 0 0.375rem 1.5rem 0 rgb(140 152 164 / 13%);
}

.dark #header.scroll > div:first-child,
#header.scroll.dark > div:first-child {
  @apply bg-page md:bg-[#030621e6] border-b border-gray-500/20;
  box-shadow: none;
}

#header.expanded nav {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 70px !important;
  padding: 0 5px;
}

.dropdown:focus .dropdown-menu,
.dropdown:focus-within .dropdown-menu,
.dropdown:hover .dropdown-menu {
  display: block;
}

[astro-icon].icon-light > * {
  stroke-width: 1.2;
}

[astro-icon].icon-bold > * {
  stroke-width: 2.4;
}

[data-aw-toggle-menu] path {
  @apply transition;
}

[data-aw-toggle-menu].expanded g > path:first-child {
  @apply -rotate-45 translate-y-[15px] translate-x-[-3px];
}

[data-aw-toggle-menu].expanded g > path:last-child {
  @apply rotate-45 translate-y-[-8px] translate-x-[14px];
}

/* Custom Tippy.js theme for light/dark mode */
.tippy-box[data-theme~='devnet'] {
  background-color: #fff;
  color: #222;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  font-size: 1rem;
  padding: 0.75rem 1rem;
}

.dark .tippy-box[data-theme~='devnet'] {
  background-color: #23272f;
  color: #f3f4f6;
  box-shadow: 0 4px 24px rgba(0,0,0,0.40);
}

.tippy-box[data-theme~='devnet'] .tippy-arrow {
  color: inherit;
}
