/* Tablet/landscape containment; field spacing lives in responsive-forms.css. */
.app-shell {
  grid-template-rows: minmax(78px, auto) minmax(0, 1fr) minmax(45px, auto);
}
.topbar { min-width: 0; gap: 16px; }
.topbar .account { flex: 0 0 auto; min-width: 0; gap: 10px; }
.topbar :is(.avatar, .login-icon, .notification-bell) { flex-shrink: 0; }
.topbar .brand-location { min-width: 0; }
.account-menu {
  max-height: calc(100dvh - 120px - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.manual-qr-panel, .manual-booked-times, .payment-instructions,
.feature-row, .manager-booking-detail { min-width: 0; overflow-wrap: anywhere; }
.chat-thread > header > div { min-width: 0; }
.chat-thread > header b { overflow-wrap: anywhere; }
.chat-thread > header { height: auto; min-height: 64px; }
.sheet-card { width: clamp(480px, 44vw, 620px); max-width: 100vw; }
.sheet-head > div { min-width: 0; padding-right: 10px; }
.sheet-head h2 { overflow-wrap: anywhere; }
.selection-bar > div { min-width: 0; }
.selection-bar :is(strong, small) { overflow-wrap: anywhere; }
.booking-dialog-head { gap: 18px; }

/* Draw the close mark geometrically so font baselines cannot shift its centre. */
.close {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 0;
  line-height: 1;
  border-radius: 50%;
  color: var(--ink);
  text-decoration: none;
}
.close.dialog-close { position: absolute; }
.close::before, .close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
  pointer-events: none;
}
.close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.close:focus-visible { outline: 3px solid var(--accent, var(--lime)); outline-offset: 3px; }
.account-menu :is(.account-menu-links, .account-menu-actions) > :is(a, button) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 14px;
  text-align: center;
  line-height: 1.35;
}
.account-menu-links, .account-menu-actions { gap: 8px; }
.swal2-close { align-items: center; justify-content: center; padding: 0; line-height: 1; }
.booking-item > div:first-child { flex-wrap: wrap; }
.booking-item .booking-status { flex: 0 0 auto; white-space: nowrap; }
.booking-item > small { display: block; margin: 8px 0; }
.booking-item > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  line-height: 1.35;
  text-align: center;
}
.booking-item > button + button { margin-top: 8px; }

@media (max-width: 1100px) {
  .topbar .brand-location {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 6px;
    flex: 1 1 0;
  }
  .topbar .brand-location .brand {
    min-width: 0;
    max-width: 100%;
    font-size: clamp(18px, 2.8vw, 23px);
    line-height: 1.1;
  }
  .topbar .brand-location .brand span {
    display: block;
    -webkit-line-clamp: unset;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
  }
  .topbar .brand-location .place {
    min-width: 0;
    margin: 0 0 0 38px;
    font-size: 12px;
    line-height: 1.3;
  }
}

/* Keep the portrait tablet on the spacious stacked landing layout. */
@media (min-width: 641px) and (max-width: 1023px) {
  .discover {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 20px 0 10px;
  }
  .discover .intro { grid-column: 1; grid-row: 1; padding: 0 28px; align-self: start; }
  .intro h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.04; max-width: 100%; }
  .intro > p:last-child { max-width: 100%; margin: 12px 0 18px; }
  .court-track {
    grid-column: 1;
    grid-row: 2;
    grid-auto-columns: min(88%, 690px);
    padding: 0 28px 4px;
  }
  .swipe-hint { grid-column: 1; grid-row: 3; padding-top: 10px; }
  .court-copy h2 { font-size: clamp(28px, 4vw, 38px); }
  .sheet-card {
    inset: auto 16px 16px auto;
    width: min(640px, calc(100vw - 32px));
    height: min(92dvh, 960px);
    border-radius: 24px;
    padding: 24px;
  }
  .trustbar { gap: 18px; padding-inline: 20px; }
}

@media (max-width: 700px) {
  .manual-payment-layout { grid-template-columns: minmax(0, 1fr); }
  .manual-payment-dialog { padding-inline: 20px; }
}

@media (max-width: 640px) {
  .app-shell { grid-template-rows: minmax(86px, auto) minmax(0, 1fr) minmax(39px, auto); }
  .topbar { gap: 10px; padding-inline: 12px; }
  .topbar .account { gap: 7px; }
  .topbar .manage-link { max-width: 84px; padding: 9px 10px; text-align: center; white-space: normal; line-height: 1.3; }
  .topbar .brand-location .brand { font-size: 18px; }
  .topbar .brand-location .place { font-size: 11px; }
  .sheet-card { width: 100%; max-width: 100%; height: min(92dvh, 850px); padding-inline: 20px; }
  .selection-bar { flex-wrap: wrap; gap: 12px; }
  .selection-bar > div { flex: 1 1 140px; }
  .selection-bar > button { flex: 0 1 auto; }
  .account-menu { max-height: calc(100dvh - 130px - env(safe-area-inset-bottom)); }
}

/* Do not let a short landscape viewport hide menus or the booking controls. */
@media (max-height: 600px) {
  .sheet-card { height: 96dvh; max-height: 96dvh; }
  .account-menu { max-height: calc(100dvh - 110px); }
  .clubhouse-dialog { height: 96dvh; max-height: 96dvh; }
  .clubhouse-head { height: 84px; padding-top: 14px; padding-bottom: 12px; }
  .clubhouse-layout { height: calc(100% - 84px); }
}

@media (min-width: 641px) and (max-width: 1023px) and (max-height: 600px) {
  .sheet-card { max-height: calc(100dvh - 32px); }
}

/* Very short screens may scroll the landing content instead of crushing a card. */
@media (max-width: 1023px) and (max-height: 600px) {
  .discover {
    grid-template-rows: auto minmax(360px, 1fr) auto;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
  .court-track { min-height: 360px; }
}
