/* ============================================================================
   DESKTOP / TABLET GEOMETRY (≥ 40em)
   Map-first overlay model
   ============================================================================ */

@media (min-width: 40em) {

  :root {
    --rail-width: 22rem;
    --rail-inner-width: calc(var(--rail-width) - (2 * var(--app-horizontal-padding)));
  }

  body {
    overflow: hidden;
  }

  #layout {
    min-height: 100vh;
    position: relative;
    height: 100%;
  }

  /* Fixed header */
  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    padding: 0.5rem var(--app-horizontal-padding);
    display: flex;
    align-items: center;
    z-index: 20;
  }

  /* Header is a 3-column grid on desktop */
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
  }

  /* Left group: title + profile */
  .header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  /* Title grows */
  .site-title {
    white-space: nowrap;
  }

  /* Profile icon stays next to title */
  .user-menu {
    margin-left: 0;
    margin-right: 0.25rem;
  }

  /* Search (desktop: sidebar top) */
  .search-container {
    width: var(--rail-inner-width);
    padding: 0;
    background: none;
    border: none;
    box-sizing: border-box;
  }


  /* Map-first layout */
  .map-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: calc(100vh - var(--header-height));
    z-index: 1;
  }

  /* Sidebar */
  .site-main.has-results-open .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: var(--rail-width);
    height: calc(100vh - var(--header-height));
    padding: 0.5rem var(--app-horizontal-padding);
    box-sizing: border-box;
    border-left: 1px solid #ddd;
    z-index: 10;
  }


  /* Content overlay panel */
  .content {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--content-width);
    border-radius: 0;
    border-right: 1px solid #ddd;
    box-shadow: none;
    display: none;
    z-index: 15;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  }

  /* Show content panels depending on state */
  .site-main.has-editor-open #campsite-panel {
    display: block;
  }

  .site-main.has-profile-open #profile-panel {
    display: block;
  }

  .site-main.has-admin-open #admin-panel {
    display: block;
  }

  .site-main:not(.has-results-open) .content {
    right: var(--app-horizontal-padding);
  }

  .site-main.has-results-open .content {
    right: calc(var(--rail-width) + var(--app-horizontal-padding));
  }

}