/* OONITE page-frame contract, 2026-08-25.
   The App Shell owns the available canvas. Route roots own content, but their
   outer rails must not reintroduce a second page width or gutter. */

/* Desktop and tablet: keep one outer frame and let route interiors use the
   full shell canvas. Reading columns and media proportions remain owned by
   their route components. */
@media (min-width:720px) {
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'] {
    max-width:none;
    margin-inline:var(--oonite-page-frame-margin,0);
  }

  /* Calendar and Browse share the wide Web frame when switching views. */
  :root:not([data-native-platform="ios"]) #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true']:is(.tonight-app-page,.event-browser-page) {
    --oonite-content-width-wide:inherit;
    max-width:var(--oonite-content-width-wide);
    margin-inline:auto;
  }

  :root:not([data-native-platform="ios"]) #app .tonight-app-page .tonight-month {
    padding-inline:0;
  }

  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-hero,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-flow-panel,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-dashboard,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-lower,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-plan-cta,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].places-page > .places-filter-section,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].places-page > .places-results-section,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].notifications-page > .notification-shortcuts,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].notifications-page > .notification-messages,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].notifications-page > .account-notification-groups,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].venue-detail-page > .venue-hero,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].venue-detail-page > .venue-story,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].venue-detail-page > .owner-update-link,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].account-passport-main {
    width:100%;
    max-width:none;
    margin-inline:0;
  }

  /* The public detail sheet is the outer detail surface. Its internal copy
     column still keeps its intentional reading width. */
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].night-card-detail-page:not(.night-card-route-owner):not(.night-card-complete-page) .night-detail-sheet {
    width:100%;
    max-width:none;
    margin-inline:0;
  }

  /* Tonight's dashboard panels share the same outer rail as the Flow panel.
     The legacy section rule supplied a second horizontal inset here, which
     made Now & Next and the pulse panel stop short of the section edges. */
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-dashboard,
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'].tonight-page > .tonight-lower {
    padding-right:0;
    padding-left:0;
  }
}

@media (min-width:1200px) {
  :root:not([data-native-platform="ios"]) #app .tonight-app-page:has(> .tonight-app-controls) {
    display:grid;
    grid-template-columns:min(42%,460px) minmax(0,1fr);
    column-gap:clamp(24px,3vw,48px);
    align-content:start;
    align-items:start;
  }

  :root:not([data-native-platform="ios"]) #app .tonight-app-desktop-heading {
    grid-column:1 / -1;
  }
}

/* Mobile: one page-frame contract owns scroll clearance. Route styles choose
   root, standard, or immersive presentation through body data; they do not
   recreate viewport height or fixed-navigation math. */
@media (max-width:719px) {
  body[data-oonite-mobile-nav='shown'] {
    --oonite-route-content-bottom:var(--oonite-content-bottom-with-nav);
  }

  body[data-oonite-mobile-nav='hidden'] {
    --oonite-route-content-bottom:var(--oonite-content-bottom-without-nav);
  }

  #app > [data-oonite-page-frame='true'],
  #app > .app-shell .app-shell-main-content > [data-oonite-page-frame='true'] {
    width:100%;
    max-width:100%;
    min-width:0;
    margin-inline:0;
    padding-bottom:var(--oonite-route-content-bottom, var(--oonite-content-bottom-with-nav));
  }

  /* Standard routes keep their own scroll frame, including when phone Web
     extends that frame beneath the translucent header. */
  body[data-oonite-layout='standard'] #app {
    overflow:hidden !important;
  }

  body[data-oonite-layout='standard'] #app > [data-oonite-page-frame='true'] {
    height:calc(100dvh - var(--oonite-app-header-bottom)) !important;
    min-height:0;
    margin-top:var(--oonite-app-header-bottom);
    overflow-x:hidden !important;
    overflow-y:auto !important;
    overscroll-behavior-y:contain;
    -webkit-overflow-scrolling:touch;
    padding-top:var(--oonite-app-standard-gap);
    padding-bottom:var(--oonite-route-content-bottom);
    box-sizing:border-box;
  }

  /* Move the header clearance into the scroll frame so content can pass
     behind the fade without moving the first content at rest. In-flow notices
     occupy their own space above the frame. */
  :root:not([data-native-platform='ios']) body[data-oonite-layout='standard']
    #app:has(> .global-header[data-header-pilot='true']):not(:has(> [data-site-announcement]:not([data-web-home-announcement]))) > [data-oonite-page-frame='true'] {
    --oonite-web-frame-header-space:var(--oonite-app-header-bottom);
    --oonite-web-frame-content-top:var(--oonite-web-hero-start,calc(var(--oonite-web-frame-header-space) + var(--oonite-frame-content-gap,var(--oonite-app-standard-gap))));
    height:100dvh !important;
    margin-top:0;
    padding-top:var(--oonite-web-frame-content-top);
    scroll-padding-top:var(--oonite-web-frame-header-space);
  }

  /* Bangkok starts with a full-bleed photo; the other community tabs keep
     the standard clearance above their first row. */
  .my-night-route-page:has([data-night-tab-panel='city'].is-active:not([hidden])) {
    --oonite-web-hero-start:0px;
  }

  /* Mobile navigation is an explicit route decision. Hiding its links alone
     must never leave the fixed pill or its touch interception behind. */
  body[data-oonite-mobile-nav='hidden'] #app > .global-mobile-nav {
    display:none;
  }
}

/* Account subpages share the Places 16px mobile rail. The shell owns the
   vertical header gap; route content must not add another viewport inset. */
@media (max-width:719px) {
  #app > [data-oonite-page-frame='true'].account-route-page {
    width:min(calc(100% - 32px),720px);
    max-width:720px;
    margin-inline:auto;
    /* The legacy generic section rule has unusually high specificity and
       otherwise inserts a second 48px top gap after the shared Header. */
    padding-top:var(--oonite-web-frame-content-top,var(--oonite-app-standard-gap)) !important;
    padding-right:0 !important;
    padding-left:0 !important;
  }
}

/* Direct mobile route roots use the same 16px content gutter for their
   filter/list surfaces; full-bleed media remains route-owned. */
@media (max-width:719px) {
  #app > [data-oonite-page-frame='true'] > .places-filter-section,
  #app > [data-oonite-page-frame='true'] > .places-results-section,
  #app > [data-oonite-page-frame='true'] > .notification-shortcuts,
  #app > [data-oonite-page-frame='true'] > .notification-messages,
  #app > [data-oonite-page-frame='true'].notifications-page > .account-notification-groups {
    margin-right:16px;
    margin-left:16px;
    width:calc(100% - 32px);
    max-width:none;
  }
}

/* Overlay contract: normal sheets own the close-control anchor. Their wrapper
   owns safe-area padding once; no close button floats against the viewport.
   Fullscreen media details keep an explicit immersive left-anchor below. */
@media (max-width:719px) {
  body :is(
    .account-sheet,
    .community-report-sheet,
    .night-hello-sheet,
    .account-moment-create-sheet,
    .venue-share-sheet,
    .moment-share-sheet,
    .night-score-share-sheet,
    .web-app-instructions-panel
  )[role='dialog'] > .oonite-dialog-close,
  .night-action-sheet .night-checkin-sheet:not(.is-create-chooser) > .oonite-dialog-close {
    position:absolute;
    top:var(--oonite-overlay-close-inset);
    right:var(--oonite-overlay-close-inset);
    left:auto;
    z-index:4;
    width:var(--oonite-overlay-close-size);
    min-width:var(--oonite-overlay-close-size);
    height:var(--oonite-overlay-close-size);
    min-height:var(--oonite-overlay-close-size);
    padding:0;
  }

  .account-moment-create-sheet .moment-create {
    padding-top:24px;
  }

  .community-report-modal,
  .night-card-completion-modal {
    padding:var(--oonite-overlay-safe-inset) 16px max(16px, var(--oonite-safe-area-bottom));
  }

  .night-card-completion-close {
    position:absolute;
    top:var(--oonite-overlay-close-inset);
    right:var(--oonite-overlay-close-inset);
    left:auto;
    z-index:4;
    width:var(--oonite-overlay-close-size);
    min-width:var(--oonite-overlay-close-size);
    height:var(--oonite-overlay-close-size);
    min-height:var(--oonite-overlay-close-size);
    padding:0;
  }

  body[data-oonite-layout='immersive'] .night-detail-close.oonite-dialog-close {
    top:var(--oonite-overlay-close-inset);
    right:auto;
    bottom:auto;
    left:var(--oonite-overlay-close-inset);
    z-index:4;
    width:var(--oonite-overlay-close-size);
    min-width:var(--oonite-overlay-close-size);
    height:var(--oonite-overlay-close-size);
    min-height:var(--oonite-overlay-close-size);
    padding:0;
  }
}

/* One phone rail; generic editorial section padding must not create another. */
@media(max-width:719px){
 :root:not([data-native-platform="ios"]) .home-city-pulse > .home-section {padding-inline:0;}
 :root:not([data-native-platform="ios"]) .night-city-panel .night-tonight-module > .night-tonight-section {width:100%;max-width:none;margin-inline:0;padding-inline:0;box-sizing:border-box;}
}
