/* Button Styling */
/* Dark mode: rainbow glow on hover | Light mode: soft neumorphic */

button,
.btn {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 50px;
  padding: 0 2rem;
  min-width: 180px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  outline: none;
  background: #151520;
  color: #fff;
  cursor: pointer;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  /* iOS rendering fix */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Dark mode glow effect */
button::before,
.btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
  background-size: 400%;
  filter: blur(5px);
  opacity: 0;
  /* Outer radius = inner radius + inset offset for smooth curves */
  border-radius: 12px;
  z-index: -1;
  transition: opacity 0.3s;
  animation: glow-cycle 20s linear infinite;
  /* iOS rendering fix for blurred elements */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

button::after,
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)), #151520;
  border-radius: 10px;
  z-index: -1;
}

button:hover::before,
.btn:hover::before,
button:focus-visible::before,
.btn:focus-visible::before {
  opacity: 1;
}

/* Rainbow fill press effect (works when glow is already visible) */
button:hover:active,
.btn:hover:active,
button:focus-visible:active,
.btn:focus-visible:active {
  color: #0a0a0a;
}

button:hover:active::after,
.btn:hover:active::after,
button:focus-visible:active::after,
.btn:focus-visible:active::after {
  background: transparent;
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes glow-cycle {

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

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

/* Touch devices: no hover, keep controls visible and cheaper to render */
@media (hover: none),
(pointer: coarse) {

  button::before,
  .btn::before {
    opacity: 0.35;
    filter: none;
    animation: none;
    inset: -1px;
  }

  button:active::before,
  .btn:active::before {
    opacity: 0.55;
  }
}

/* Icon buttons (circular) */
button.icon-btn,
.calendar-nav-btn,
.modal-close {
  min-width: unset;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

button.icon-btn::before,
button.icon-btn::after,
.calendar-nav-btn::before,
.calendar-nav-btn::after,
.modal-close::before,
.modal-close::after {
  content: none;
}

button.icon-btn:hover,
.calendar-nav-btn:hover,
.modal-close:hover {
  background: rgb(var(--accent-rgb) / 0.2);
  border-color: rgb(var(--accent-rgb) / 0.4);
  color: rgba(255, 255, 255, 0.95);
  transform: scale(1.05);
}

button.icon-btn:active,
.calendar-nav-btn:active,
.modal-close:active {
  background: rgb(var(--accent-rgb) / 0.25);
  border-color: rgb(var(--accent-rgb) / 0.5);
  color: rgba(255, 255, 255, 0.98);
}

button.icon-btn svg,
.calendar-nav-btn svg,
.modal-close svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

/* ========================================
   LIGHT MODE - Soft Neumorphic Buttons
   ======================================== */
/* ========================================
   LIGHT MODE - Flat Technical Buttons
   ======================================== */
body:has(#theme-toggle-checkbox:checked) button,
body:has(#theme-toggle-checkbox:checked) .btn {
  color: var(--text-primary);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: none;
  font-weight: 500;
}

body:has(#theme-toggle-checkbox:checked) button::before,
body:has(#theme-toggle-checkbox:checked) button::after,
body:has(#theme-toggle-checkbox:checked) .btn::before,
body:has(#theme-toggle-checkbox:checked) .btn::after {
  content: none;
}

@media (hover: hover) and (pointer: fine) {

  body:has(#theme-toggle-checkbox:checked) button:hover,
  body:has(#theme-toggle-checkbox:checked) .btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* very subtle lift */
  }
}

body:has(#theme-toggle-checkbox:checked) button:active,
body:has(#theme-toggle-checkbox:checked) .btn:active {
  color: #0f172a;
  background: #e2e8f0;
  box-shadow: none;
  transform: translateY(1px);
}

body:has(#theme-toggle-checkbox:checked) button:focus-visible,
body:has(#theme-toggle-checkbox:checked) .btn:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

/* Light mode icon buttons - flat */
body:has(#theme-toggle-checkbox:checked) button.icon-btn,
body:has(#theme-toggle-checkbox:checked) .calendar-nav-btn,
body:has(#theme-toggle-checkbox:checked) .modal-close {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #64748b;
  box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {

  body:has(#theme-toggle-checkbox:checked) button.icon-btn:hover,
  body:has(#theme-toggle-checkbox:checked) .calendar-nav-btn:hover,
  body:has(#theme-toggle-checkbox:checked) .modal-close:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
    box-shadow: none;
    transform: none;
  }
}

body:has(#theme-toggle-checkbox:checked) button.icon-btn:active,
body:has(#theme-toggle-checkbox:checked) .calendar-nav-btn:active,
body:has(#theme-toggle-checkbox:checked) .modal-close:active {
  background: #e2e8f0;
  box-shadow: none;
}

/* Mobile: larger touch targets */
@media (max-width: 768px) {

  button.icon-btn,
  .calendar-nav-btn,
  .modal-close {
    width: 44px;
    height: 44px;
  }

  button.icon-btn svg,
  .calendar-nav-btn svg,
  .modal-close svg {
    width: 22px;
    height: 22px;
  }
}