/* ============================================================
   Direction B — Add Availability Type modal
   A dark "command" hero echoes the console header.
   ============================================================ */

.add-modal {
  /* Bottom sheet: the dialog fills the viewport as a transparent
     backdrop layer; the sheet itself (.am-inner) is anchored to the
     bottom edge and slides up. The global `* { margin: 0 }` reset
     would kill UA centering anyway, so we drive layout with flex. */
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  overflow: hidden;
}
.add-modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-modal::backdrop {
  background: oklch(0.18 0.03 264 / 0.62);
  backdrop-filter: blur(5px);
  opacity: 0;
}
.add-modal[open]::backdrop {
  animation: am-fade var(--dur-slow) var(--ease-out) forwards;
}
@keyframes am-fade {
  to { opacity: 1; }
}

.am-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Centered modal: at least 32px clear of every screen edge on
     small/medium screens, capped to a comfortable max on large ones
     (a definite height is still needed so the flex:1 body can scroll). */
  --am-px: 64px; /* generous, consistent content inset */
  width: calc(100vw - 64px);
  max-width: 1080px;
  height: calc(100vh - 64px);
  max-height: 860px;
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.add-modal[open] .am-inner {
  animation: am-pop var(--dur-slow) var(--ease-out-quint) both;
}
.add-modal[data-closing] .am-inner {
  animation: am-pop var(--dur-mid) var(--ease-out) reverse both;
}
@keyframes am-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* head + hero share the dark command surface */
.am-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-8) var(--am-px) var(--sp-5);
  background: var(--surface);
}
.am-head .eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ai-ink);
  margin-bottom: 6px;
}
.am-head h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.am-close {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  font-size: 22px;
  line-height: 1;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast);
}
.am-close:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.am-hero {
  padding: var(--sp-8) var(--am-px) var(--sp-6);
  background: var(--ai-wash);
  border-bottom: 1px solid color-mix(in oklab, var(--ai) 20%, var(--border));
}
.am-lead {
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: var(--sp-4);
}
.am-prompt {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 54px;
  padding: 0 8px 0 var(--sp-4);
  background: var(--surface);
  background-image: linear-gradient(var(--surface), var(--surface)), var(--ai-grad);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  box-shadow: var(--sh-2), 0 0 0 4px color-mix(in oklab, var(--ai) 14%, transparent);
}
.am-prompt__spark {
  width: 20px;
  height: 20px;
  color: var(--ai);
}
.am-prompt__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--text-md);
  color: var(--ink);
}
.am-prompt__input::placeholder {
  color: var(--ink-3);
}
.am-prompt__go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast);
}
.am-prompt__go .ic {
  width: 17px;
  height: 17px;
}
.am-prompt__go:hover {
  background: var(--primary-hover);
}
.am-prompt__go:active {
  transform: scale(0.97);
}
.am-suggest {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.am-suggest__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-3);
}
.am-pill {
  height: 28px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease-out);
}
.am-pill:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--ink);
}

/* tabs */
.am-tabs {
  display: flex;
  gap: var(--sp-5);
  padding: var(--sp-5) var(--am-px) 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.am-tabs::-webkit-scrollbar {
  display: none;
}
.am-tab {
  position: relative;
  padding: var(--sp-4) 2px;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}
.am-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform var(--dur-mid) var(--ease-out);
}
.am-tab:hover {
  color: var(--ink-2);
}
.am-tab.is-active {
  color: var(--ink);
}
.am-tab.is-active::after {
  transform: scaleX(1);
}

/* body */
.am-body {
  flex: 1;
  min-height: 0;
  padding: var(--sp-6) var(--am-px) var(--am-px);
  overflow-y: auto;
  background: var(--bg);
  scroll-behavior: smooth;
}
/* stacked category sections (scroll-spy target) */
.am-cat {
  scroll-margin-top: var(--sp-4);
}
.am-cat + .am-cat {
  margin-top: var(--sp-8);
}
.am-cat__title {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: var(--sp-4);
}
.am-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}
.am-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-mid) var(--ease-out),
    box-shadow var(--dur-mid) var(--ease-out), border-color var(--dur-mid) var(--ease-out);
}
.am-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-2);
  border-color: var(--border-strong);
}
.am-card__media {
  position: relative;
  height: 124px;
  overflow: hidden;
}
.am-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.45) contrast(1.03) brightness(0.96);
  transition: filter var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out-quint);
}
.am-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, oklch(0.25 0.04 264 / 0.08), oklch(0.22 0.04 264 / 0.4));
  opacity: 1;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.am-card:hover .am-card__media img {
  filter: none;
  transform: scale(1.05);
}
.am-card:hover .am-card__media::after {
  opacity: 0;
}
.am-card__rank {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  background: oklch(0.2 0.03 264 / 0.7);
  backdrop-filter: blur(4px);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  z-index: 1;
}
.am-card__body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.am-card__title {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.am-card__desc {
  font-size: var(--text-sm);
  color: var(--ink-2);
  line-height: var(--lh-snug);
  flex: 1;
}
.am-card__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-2);
}
.stat .ic {
  width: 13px;
  height: 13px;
  color: var(--ok-line);
}
.am-card__cta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur-mid) var(--ease-out), transform var(--dur-mid) var(--ease-out);
}
.am-card__cta .ic {
  width: 15px;
  height: 15px;
}
.am-card:hover .am-card__cta {
  opacity: 1;
  transform: translateX(0);
}

/* step the generous content inset down with the viewport so it never
   crowds the cards (it drives head top + all sides + body bottom) */
@media (max-width: 960px) {
  .am-inner {
    --am-px: var(--sp-8);
  }
}
@media (max-width: 720px) {
  .am-grid {
    grid-template-columns: 1fr 1fr;
  }
  .am-inner {
    --am-px: var(--sp-5);
  }
}
@media (max-width: 520px) {
  .am-grid {
    grid-template-columns: 1fr;
  }
  .am-inner {
    --am-px: var(--sp-4);
  }
}
@media (prefers-reduced-motion: reduce) {
  .add-modal[open] .am-inner,
  .add-modal[data-closing] .am-inner,
  .add-modal[open]::backdrop {
    animation: none;
  }
  .add-modal::backdrop {
    opacity: 1;
  }
  .am-card:hover .am-card__media img {
    transform: none;
  }
  .am-body {
    scroll-behavior: auto;
  }
}
