/* ==========================================================================
   V2.4 — Targeted mobile fixes
   Malaysia Cost, Academic Evidence, and Incident Monitoring.
   ========================================================================== */

html.mobile-project-menu-open,
body.mobile-project-menu-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* ---------------- Malaysia Cost / Living Planner ---------------- */
@media (max-width: 767px) {
  body.project-malaysia-cost {
    overflow-x: clip;
  }

  body.project-malaysia-cost .mc-topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 90 !important;
    height: auto !important;
    min-height: 0 !important;
    background: color-mix(in srgb, hsl(var(--card)) 94%, transparent) !important;
    box-shadow: 0 10px 30px rgba(23, 23, 23, .08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  body.project-malaysia-cost .mc-topbar-inner {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 10px 12px !important;
  }

  body.project-malaysia-cost .mc-topbar-row {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 9px !important;
  }

  body.project-malaysia-cost .mc-brand {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    padding-inline: 2px;
    font-size: 14px !important;
  }

  body.project-malaysia-cost .mc-nav {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 2px 1px 7px !important;
    scroll-snap-type: x proximity;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  body.project-malaysia-cost .mc-nav a {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    width: auto !important;
    max-width: none !important;
    padding: 8px 11px !important;
    border: 1px solid hsl(var(--border)) !important;
    border-radius: 999px !important;
    background: hsl(var(--background) / .82) !important;
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    font-size: 11px !important;
    line-height: 1 !important;
    scroll-snap-align: start;
  }

  body.project-malaysia-cost .mc-nav a[aria-current="page"],
  body.project-malaysia-cost .mc-nav a[data-active="true"] {
    border-color: hsl(var(--primary) / .45) !important;
    background: hsl(var(--primary) / .12) !important;
    color: hsl(var(--primary)) !important;
  }

  body.project-malaysia-cost main,
  body.project-malaysia-cost #root > div,
  body.project-malaysia-cost .min-h-screen {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.project-malaysia-cost h1 {
    max-width: 100% !important;
    font-size: clamp(2.25rem, 12vw, 3.7rem) !important;
    line-height: .98 !important;
    letter-spacing: -.045em !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }

  body.project-malaysia-cost .mc-page-heading {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.project-malaysia-cost .mc-page-actions {
    width: 100% !important;
    align-items: stretch !important;
  }

  body.project-malaysia-cost .mc-page-actions > div {
    width: 100% !important;
    max-width: 100% !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
  }

  body.project-malaysia-cost .mc-page-actions button {
    min-height: 42px;
  }

  body.project-malaysia-cost .grid {
    min-width: 0 !important;
  }

  body.project-malaysia-cost [class*="max-w-"] {
    max-width: 100% !important;
  }

  body.project-malaysia-cost [class*="px-5"] {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  body.project-malaysia-cost [class*="p-6"] {
    padding: 18px !important;
  }

  body.project-malaysia-cost select,
  body.project-malaysia-cost input,
  body.project-malaysia-cost button {
    min-width: 0 !important;
  }
}

/* ---------------- Academic Evidence / AI Portfolio ---------------- */
@media (max-width: 767px) {
  body.project-academic-evidence {
    overflow-x: clip;
  }

  body.project-academic-evidence .ae-mobile-header {
    height: 58px !important;
    min-height: 58px !important;
    padding: 0 12px !important;
    background: hsl(var(--background) / .94) !important;
    border-bottom-color: hsl(var(--primary) / .22) !important;
    box-shadow: 0 8px 28px rgba(8, 8, 8, .2);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
  }

  body.project-academic-evidence .ae-mobile-header h1 {
    min-width: 0 !important;
    max-width: calc(100vw - 120px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 14px !important;
    line-height: 1.1 !important;
    letter-spacing: 0 !important;
    word-break: normal !important;
  }

  body.project-academic-evidence .ae-mobile-header button {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    padding: 8px !important;
  }

  body.project-academic-evidence .ae-mobile-menu {
    top: 58px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: max(20px, env(safe-area-inset-bottom)) !important;
  }

  body.project-academic-evidence .ae-hero {
    min-height: auto !important;
    padding-top: 58px !important;
    overflow: hidden !important;
  }

  body.project-academic-evidence .ae-hero-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 48px 16px 42px !important;
  }

  body.project-academic-evidence .ae-status-badge {
    display: block !important;
    width: fit-content !important;
    max-width: 100% !important;
    margin-inline: auto !important;
    padding: 9px 12px !important;
    font-size: 10px !important;
    line-height: 1.45 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: anywhere !important;
  }

  body.project-academic-evidence .ae-hero h1 {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto 18px !important;
    font-size: clamp(2.3rem, 11vw, 3.6rem) !important;
    line-height: 1.02 !important;
    letter-spacing: -.045em !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }

  body.project-academic-evidence .ae-hero h1 br {
    display: none;
  }

  body.project-academic-evidence .ae-hero h1 span {
    display: block;
    margin-top: 4px;
  }

  body.project-academic-evidence .ae-hero p {
    width: 100% !important;
    max-width: 38rem !important;
    font-size: 14px !important;
    line-height: 1.65 !important;
    letter-spacing: .01em !important;
    overflow-wrap: normal !important;
  }

  body.project-academic-evidence .ae-hero-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 430px !important;
    gap: 10px !important;
  }

  body.project-academic-evidence .ae-hero-actions > * {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.project-academic-evidence main,
  body.project-academic-evidence main > div {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.project-academic-evidence .container {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ---------------- Incident Monitoring ---------------- */
.incident-mobile-button,
.incident-mobile-backdrop,
.incident-sidebar-close {
  display: none;
}

@media (max-width: 767px) {
  body.project-incident-monitoring {
    overflow: hidden !important;
    background: #070707;
  }

  body.project-incident-monitoring #root,
  body.project-incident-monitoring #root > div {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100dvh !important;
  }

  body.project-incident-monitoring .incident-sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 1200 !important;
    width: min(84vw, 310px) !important;
    max-width: calc(100vw - 32px) !important;
    height: 100dvh !important;
    min-width: 0 !important;
    transform: translate3d(-105%, 0, 0);
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
    box-shadow: 28px 0 90px rgba(0, 0, 0, .56);
    overflow: hidden !important;
    border-right-color: rgba(156, 156, 156, .3) !important;
  }

  body.project-incident-monitoring .incident-sidebar.is-open {
    transform: translate3d(0, 0, 0);
  }

  body.project-incident-monitoring .incident-sidebar nav {
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.project-incident-monitoring .incident-sidebar-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(156, 156, 156, .38);
    border-radius: 12px;
    background: rgba(65, 65, 65, .28);
    color: #e8e8e8;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  body.project-incident-monitoring .incident-mobile-button {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1050;
    display: flex;
    align-items: center;
    gap: 9px;
    width: auto;
    max-width: calc(100vw - 20px);
    height: 44px;
    padding: 0 13px;
    border: 1px solid rgba(156, 156, 156, .42);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(65, 65, 65,.96), rgba(96, 96, 96,.92));
    color: #fff;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .34);
    font: 700 12px/1 system-ui, sans-serif;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  body.project-incident-monitoring .incident-mobile-button svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
  }

  body.project-incident-monitoring .incident-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: block;
    visibility: hidden;
    opacity: 0;
    border: 0;
    background: rgba(6, 6, 6, .7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: opacity .25s ease, visibility .25s ease;
    pointer-events: none;
  }

  body.project-incident-monitoring .incident-mobile-backdrop.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  body.project-incident-monitoring main {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-top: 58px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.project-incident-monitoring main > * {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.project-incident-monitoring main h1 {
    max-width: 100% !important;
    font-size: clamp(1.7rem, 8vw, 2.5rem) !important;
    line-height: 1.08 !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }

  body.project-incident-monitoring main h2 {
    font-size: clamp(1.25rem, 6vw, 1.8rem) !important;
    line-height: 1.15 !important;
  }

  body.project-incident-monitoring main .grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.project-incident-monitoring main [class*="px-"],
  body.project-incident-monitoring main [class*="p-"] {
    min-width: 0 !important;
  }

  body.project-incident-monitoring main .p-6 {
    padding: 16px !important;
  }

  body.project-incident-monitoring main .p-8 {
    padding: 18px !important;
  }

  body.project-incident-monitoring main button,
  body.project-incident-monitoring main input,
  body.project-incident-monitoring main select {
    min-width: 0 !important;
  }
}
