/**
 * PhotoXED Message Sheet — THE SINGLE SHEET TEMPLATE (per spec)
 * 
 * This is the ONLY sheet container used app-wide.
 * All info, warnings, menus, forms, upload flows, share details, etc.
 * MUST go through window.PhotoXED.openSheet() which uses this .px-msCard.
 * 
 * Width rules here are the source of truth for consistency across
 * Upload, Shared, More, Notices, Warnings, etc.
 * 
 * Header: eyebrow + title left, close right
 * Footer: 50/50 full-width Back + Next that loops (or custom)
 * No inline styles. Ever.
 */

.px-ms {
  display: none;
  align-items: flex-end;
}
.px-ms[aria-hidden="false"] {
  display: flex;
}

/* Backdrop fades in a bit slower and softer to enhance the "emerging from tab bar" feeling */
.px-ms-backdrop {
  opacity: 0;
  transition: opacity 420ms var(--ease-out);
}
.px-ms[aria-hidden="false"] .px-ms-backdrop {
  opacity: 0.98;
}

.px-msCard {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: calc(100% - 5vh);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
  box-shadow: 0 -24px 64px rgba(0, 0, 0, 0.38);

  background: var(--chrome-glass-bg);
  backdrop-filter: var(--chrome-glass-filter);
  -webkit-backdrop-filter: var(--chrome-glass-filter);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  opacity: 1;

  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  margin-bottom: 0;
}

/* Tablet and up: dynamic half-width + emerging from segbar */
@media (min-width: 768px) {
  .px-msCard {
    width: 100%;
    max-width: 50vw;           /* dynamically half the viewport width (portrait + landscape) */
    margin-left: auto;
    margin-right: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: none;
    max-height: calc(100% - 5vh);
    margin-bottom: 0;
  }
}

.px-msHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  background: transparent;
}

.px-msHeaderLeft {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: var(--sp-4);
}

.px-msEyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tx3);
}

.px-msTitle {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--tx);
}

.px-msClose {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tx2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  margin-top: -4px;
  margin-right: -4px;
}
.px-msClose:active {
  background: var(--glass-highlight);
  color: var(--tx);
}

.px-msToolbar {
  flex-shrink: 0;
  padding: 0 var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--glass-border);
  background: transparent;
}

.px-msToolbar:empty {
  display: none;
}

.px-msBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-5);
  -webkit-overflow-scrolling: touch;
  font-size: 15px;
  line-height: 1.55;
}

/* Menu sheets (More tab) — size to content, don't flex-shrink labels away */
.px-msCard:has(.more-menu) {
  height: auto;
}

.px-msCard:has(.more-menu) .px-msBody {
  flex: 0 0 auto;
  overflow: visible;
}

/* Footer — 50/50 full width, large, per spec */
.px-msFooter {
  display: flex;
  flex-shrink: 0;
  border-top: 1px solid var(--glass-border);
  background: transparent;
  margin-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

/* PWA: seg already owns home-indicator inset — don't lift sheet footer again */
html.pwa-standalone .px-msFooter {
  padding-bottom: 0;
}

html.pwa-standalone .px-ms {
  bottom: var(--sheet-bottom, var(--segbar-height));
}

/* Faint vertical divider between Back and Next */
.px-msBtn + .px-msBtn {
  border-left: 1px solid rgba(255, 255, 255, 0.08); /* faint divider */
}

/* PREV / NEXT icons (from purulink, merged into icons.svg) */
.px-msFooter .ms-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}



.px-msBtn {
  flex: 1 1 50%;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--tx);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}



.px-msBtnBack {
  color: var(--tx2);
}

.px-msBtnNext {
  color: var(--tx);
  font-weight: 700;
}

.px-msBtn:active {
  background: var(--glass-highlight);
}

.px-msBtn.px-msBtnNext:active {
  background: var(--accent);
  color: white;
}

/* iPad larger targets */
@media (min-width: 768px) {
  .px-msBtn {
    padding: 18px 24px;
    font-size: 16px;
  }
}