/* ═══════════════════════════════════════════════════════
   DUCKLINGS LAYOUT — Page Structure
   ═══════════════════════════════════════════════════════ */

/* ── Page Shell ──────────────────────────────────────── */
.ducklings-page {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* Account for Drupal admin toolbar when logged in */
body.toolbar-fixed .ducklings-page {
  height: calc(100dvh - 39px);
}

body.toolbar-fixed.toolbar-tray-open.toolbar-horizontal .ducklings-page {
  height: calc(100dvh - 79px);
}

/* ── Sidebar ─────────────────────────────────────────── */
.ducklings-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--pond-white);
  border-right: 1px solid var(--pond-cloud);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
}

.ducklings-sidebar__brand {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border-bottom: 1px solid var(--pond-frost);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: inherit;
}

.ducklings-sidebar__brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
}

.ducklings-sidebar__brand-text {
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--pond-green);
  font-family: var(--font-display);
  letter-spacing: -0.5px;
}

.ducklings-sidebar__brand-sub {
  font-size: 0.5625rem;
  color: var(--pond-mist);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

/* Sidebar Navigation */
.ducklings-sidebar__nav {
  padding: var(--space-sm);
  list-style: none;
}

.ducklings-sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--pond-slate);
  font-size: 0.8125rem;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.ducklings-sidebar__nav-item:hover {
  background: var(--pond-frost);
  color: var(--pond-ink);
}

.ducklings-sidebar__nav-item.is-active {
  background: rgba(27, 67, 50, 0.08);
  color: var(--pond-green);
  font-weight: 600;
}

.ducklings-sidebar__nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Sidebar Section */
.ducklings-sidebar__section {
  padding: var(--space-md) var(--space-sm) 0;
  border-top: 1px solid var(--pond-frost);
  margin-top: var(--space-sm);
}

.ducklings-sidebar__section-title {
  font-size: 0.5625rem;
  font-weight: 700;
  color: var(--pond-mist);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 var(--space-md) var(--space-sm);
}

/* Sidebar Footer — pinned to bottom */
.ducklings-sidebar__footer {
  margin-top: auto;
  padding: var(--space-sm);
  border-top: 1px solid var(--pond-frost);
}

/* ── Main Content Area ───────────────────────────────── */
.ducklings-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────────── */
.ducklings-topbar {
  background: var(--pond-white);
  border-bottom: 1px solid var(--pond-cloud);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--topbar-height);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.ducklings-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.ducklings-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Breadcrumb */
.ducklings-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--pond-mist);
  list-style: none;
}

.ducklings-breadcrumb__sep {
  color: var(--pond-cloud);
  font-size: 0.75rem;
}

.ducklings-breadcrumb a {
  color: var(--pond-green-mid);
  font-weight: 400;
  transition: color var(--transition-fast);
}

.ducklings-breadcrumb a:hover {
  color: var(--pond-duck);
}

.ducklings-breadcrumb__current {
  color: var(--pond-ink);
  font-weight: 600;
}

/* Search Bar */
.ducklings-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--pond-frost);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--pond-cloud);
  width: 280px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ducklings-search:focus-within {
  border-color: var(--pond-green-mid);
  box-shadow: var(--shadow-focus);
}

.ducklings-search__icon {
  color: var(--pond-mist);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.ducklings-search__input {
  border: none;
  background: none;
  outline: none;
  flex: 1;
  font-size: 0.75rem;
  color: var(--pond-ink);
  font-family: var(--font-body);
}

.ducklings-search__input::placeholder {
  color: var(--pond-mist);
}

/* Hide the redundant Drupal search form on the search results page */
.ducklings-content .search-form {
  display: none;
}

/* User Actions */
.ducklings-user-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ── Content Container ───────────────────────────────── */
.ducklings-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
}

.ducklings-content__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* ── Page Header ─────────────────────────────────────── */
.ducklings-page-header {
  margin-bottom: var(--space-lg);
}

.ducklings-page-header__title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--pond-ink);
  font-family: var(--font-display);
}

.ducklings-page-header__subtitle {
  font-size: 0.8125rem;
  color: var(--pond-mist);
  margin-top: var(--space-xs);
}

/* ── Pager ───────────────────────────────────────────── */
.pager__items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
  padding: var(--space-lg) 0;
  margin: 0;
}

.pager__item a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--pond-slate);
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid var(--pond-cloud);
  background: var(--pond-white);
}

.pager__item a:hover {
  background: var(--pond-frost);
  color: var(--pond-green);
  border-color: var(--pond-green-mid);
}

.pager__item.is-active a {
  background: var(--pond-green);
  color: var(--pond-white);
  border-color: var(--pond-green);
  font-weight: 700;
}

.pager__item--ellipsis {
  color: var(--pond-mist);
  padding: 0 var(--space-xs);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
  .ducklings-sidebar {
    width: 60px;
    overflow: visible;
  }
  .ducklings-sidebar__brand-text,
  .ducklings-sidebar__brand-sub,
  .ducklings-sidebar__nav-item span:not(.ducklings-sidebar__nav-icon),
  .ducklings-sidebar__section-title {
    display: none;
  }
  .ducklings-sidebar__nav-item {
    justify-content: center;
    padding: var(--space-md);
  }
}

@media (max-width: 768px) {
  .ducklings-sidebar {
    position: fixed;
    left: -220px;
    width: var(--sidebar-width);
    transition: left var(--transition-normal);
    z-index: 200;
  }
  .ducklings-sidebar.is-open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  /* Restore full sidebar content when open on mobile */
  .ducklings-sidebar__brand-text,
  .ducklings-sidebar__brand-sub,
  .ducklings-sidebar__nav-item span:not(.ducklings-sidebar__nav-icon),
  .ducklings-sidebar__section-title {
    display: revert;
  }
  .ducklings-sidebar__nav-item {
    justify-content: flex-start;
    padding: var(--space-sm) var(--space-md);
  }
  .ducklings-content {
    padding: var(--space-lg);
  }
}

/* ── Mobile Search Toggle & Overlay ────────────────── */

/* Toggle button: hidden on desktop */
.ducklings-search-toggle {
  display: none;
}

/* Close button inside search: hidden on desktop */
.ducklings-search__close {
  display: none;
}

@media (max-width: 768px) {
  /* Show the magnifying glass toggle on mobile */
  .ducklings-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--pond-cloud);
    border-radius: var(--radius-md);
    background: var(--pond-frost);
    color: var(--pond-mist);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    order: 2;
    margin-left: auto;
  }

  .ducklings-search-toggle:hover {
    border-color: var(--pond-green-mid);
    color: var(--pond-green-mid);
  }

  /* Hide the inline search form by default on mobile */
  .ducklings-search {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--topbar-height);
    z-index: 300;
    background: var(--pond-white);
    border-bottom: 1px solid var(--pond-cloud);
    border-radius: 0;
    padding: var(--space-sm) var(--space-md);
    box-shadow: var(--shadow-md);
    box-sizing: border-box;
  }

  /* When active, show as full-width overlay */
  .ducklings-search.is-open {
    display: flex;
  }

  .ducklings-search.is-open .ducklings-search__input {
    font-size: 1rem;
  }

  /* Show close button on mobile */
  .ducklings-search__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--pond-mist);
    font-size: 0.875rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
  }

  .ducklings-search__close:hover {
    background: var(--pond-frost);
    color: var(--pond-ink);
  }

  /* Backdrop overlay when search is open */
  .ducklings-search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 250;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
  }

  .ducklings-search-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Topbar adjustments for mobile */
  .ducklings-topbar {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }

  /* User actions: hide on mobile to save space */
  .ducklings-user-actions {
    display: none;
  }
}

/* Tablet tweaks (1024px) - keep search but shrink */
@media (min-width: 769px) and (max-width: 1024px) {
  .ducklings-search {
    width: 220px;
  }
}
