/* Shared modal / <dialog> overlay (GitHub issue #74). Partial: app/views/shared/components/_modal.html.erb
   Loaded after application.css so --space-*, --color-*, etc. resolve. */
@layer components {

.modal:not([open]) {
  display: none;
}

.modal[open] {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--space-4);
  border: none;
  background: transparent;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.modal::backdrop {
  background: var(--backdrop-color);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
}

.modal--animated::backdrop {
  animation: modal-backdrop-enter var(--duration-slow) var(--ease-out);
}

@keyframes modal-backdrop-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal__content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  max-height: calc(100dvh - 2 * var(--space-4));
  margin: auto;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid color-mix(in srgb, var(--color-text) 6%, transparent);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal--animated .modal__content {
  animation: modal-content-enter var(--duration-slow) var(--ease-spring);
}

@keyframes modal-content-enter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-shrink: 0;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 6%, transparent);
  position: relative;
}

.modal--with-header-gradient .modal__header {
  background: linear-gradient(180deg, var(--color-surface-muted) 0%, var(--color-surface-subtle) 100%);
}

.modal--with-header-gradient .modal__header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--space-6);
  right: var(--space-6);
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--color-primary) 20%, transparent) 50%, transparent 100%);
  opacity: 0.6;
}

.modal__title {
  margin: 0;
  font-family: "Outfit", var(--font-sans);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.modal__title .wifi-icon {
  width: 1.375rem;
  height: 1.375rem;
  flex-shrink: 0;
  color: var(--color-primary, #ea580c);
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-default), color var(--duration-normal) var(--ease-default), transform var(--duration-fast) var(--ease-default);
}

.modal__close:hover {
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
  color: var(--color-text);
  transform: scale(1.05);
}

.modal__close:active {
  transform: scale(0.98);
}

.modal__close:focus-visible {
  outline: 2px solid var(--color-primary, #ea580c);
  outline-offset: 2px;
}

.modal__body {
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--color-surface);
}

@media (max-width: 640px) {
  .modal--fullscreen[open] {
    padding: 0;
    align-items: stretch;
  }

  .modal--fullscreen .modal__content {
    max-width: 100%;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal--animated::backdrop,
  .modal--animated .modal__content {
    animation: none;
  }
}
}
