/**
 * Dream Navigation Menu — Front-end styles
 * CSS-driven hover dropdowns; JS adds click-to-toggle for touch devices.
 * BEM-like naming: .dnm__*
 */

/* ── Reset & base ──────────────────────────────────────────────────────── */
.dnm {
  position: relative;
  z-index: 1000;
}

.dnm__list,
.dnm__dropdown {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ── Top-level list ────────────────────────────────────────────────────── */
.dnm__list {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

/* ── Menu item ─────────────────────────────────────────────────────────── */
.dnm__item {
  position: relative;
}

/* ── Main button / link ────────────────────────────────────────────────── */
.dnm__link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
  border: 1px solid transparent;
}

.dnm__link:hover,
.dnm__item.is-open > .dnm__link {
  text-decoration: none;
}

/* ── Arrow indicator ───────────────────────────────────────────────────── */
.dnm__arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.dnm__item.is-open > .dnm__link .dnm__arrow,
.dnm__item:hover > .dnm__link .dnm__arrow {
  transform: rotate(180deg);
}

/* ── Dropdown panel ────────────────────────────────────────────────────── */
.dnm__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background-color: #fff;
  border-top: 3px solid transparent;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 1001;
}

/* Show on hover (desktop) */
.dnm__item--has-dropdown:hover > .dnm__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Show when JS adds .is-open (mobile / touch) */
.dnm__item.is-open > .dnm__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ── Sub-item ──────────────────────────────────────────────────────────── */
.dnm__subitem {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dnm__subitem:last-child {
  border-bottom: none;
}

.dnm__sublink {
  display: block;
  padding: 9px 18px;
  color: #333;
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, padding-left 0.15s ease;
}

.dnm__sublink:hover {
  background-color: rgba(0, 0, 0, 0.04);
  padding-left: 24px;
  text-decoration: none;
}

/* ── Accessibility: keyboard focus ────────────────────────────────────── */
.dnm__link:focus,
.dnm__sublink:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ── Mobile: stack vertically under ~768px ─────────────────────────────── */
@media (max-width: 767px) {
  .dnm__list {
    flex-direction: column;
  }

  .dnm__dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border-top: none;
    border-left: 3px solid transparent;
    display: none;
  }

  .dnm__item.is-open > .dnm__dropdown {
    display: block;
  }

  .dnm__sublink {
    padding-left: 28px;
  }
}
