/**
 * Maple Design — emergency mobile readability overrides
 * OFFLINE DRAFT / PREVIEW ONLY — do not deploy without Vincent’s explicit go-live approval.
 * Strengthened for project pages 2026-11-14 (Asia/Hong_Kong). Live site must stay unchanged.
 *
 * How to apply (when approved):
 * 1) Add viewport meta from viewport-snippet.html into each page <head>
 *    (or the shared layout/template if the host uses one).
 * 2) After main.css, add:
 *    <link rel="stylesheet" type="text/css" media="screen" href="/web/css/mobile-overrides.css" />
 *    (upload this file to /web/css/ on the host, path may vary).
 *
 * Scope: additive overrides for ~375–430px phones (and generally <1024px).
 * Keeps the black desktop look; does not rewrite main.css.
 * EN / ZH share the same selectors. Logo is not replaced.
 */

/* -------------------------------------------------------------------------- */
/* Soften desktop min-width as soon as the viewport is phone/tablet sized     */
/* -------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    font-size: 15px;
    line-height: 1.45;
  }

  /* maxImage adds this class and otherwise locks page scroll */
  html.mc-hide-scrolls,
  body.mc-hide-scrolls,
  .mc-hide-scrolls {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  p,
  .text p,
  .text ul li,
  .text ol li,
  table tr td,
  table tr th,
  #footer p {
    font-size: 15px !important;
    line-height: 1.5 !important;
  }

  h2 {
    font-size: 17px !important;
    line-height: 1.35 !important;
    letter-spacing: 2px !important;
  }

  h4 {
    font-size: 15px !important;
    line-height: 1.35 !important;
    letter-spacing: 1px !important;
    padding: 0 12px;
    box-sizing: border-box;
  }

  h5 {
    font-size: 13px !important;
    letter-spacing: 1px !important;
    padding: 0 12px;
    box-sizing: border-box;
  }

  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Allow page scroll instead of a locked desktop stage */
  #content {
    overflow: visible !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100vh;
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Homepage: keep a full-viewport hero; contain maxImage (it uses position:fixed by default) */
  #content.homepage,
  #holder.main {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: none;
    overflow: hidden !important;
  }

  #content.homepage #maximage,
  #content.homepage #maximage .mc-cycle,
  #content.homepage #maximage .mc-image,
  #content.homepage .caption {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    z-index: 0;
  }

  #content.homepage #maximage .mc-cycle {
    z-index: 0 !important;
  }

  /* Inner-page photo stage: in-flow, not a fixed full-screen layer */
  #holder.subpage {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  #holder.subpage #maximage,
  #holder.subpage #maximage1 {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 42vh !important;
    min-height: 220px !important;
    max-height: 48vh !important;
    overflow: hidden !important;
  }

  #content.project #holder.subpage #maximage1 {
    /* Goodman / project stills are 1200×895 in the CMS */
    height: auto !important;
    min-height: 200px !important;
    max-height: none !important;
    aspect-ratio: 1200 / 895;
  }

  #holder.subpage #maximage .mc-cycle,
  #holder.subpage #maximage1 .mc-cycle,
  #holder.subpage #maximage .mc-image,
  #holder.subpage #maximage1 .mc-image,
  #holder.subpage #maximage .caption,
  #holder.subpage #maximage1 .caption {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    z-index: 0 !important;
    overflow: hidden !important;
  }

  /* Do not let the global img rule collapse maxImage / logo-sized controls */
  #maximage img,
  #maximage1 img,
  #maximage .mc-image img,
  #maximage1 .mc-image img {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
  }

  /* Homepage logo: centre without fixed 155px negative margin */
  .home-logo {
    position: absolute !important;
    top: 42% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    margin: 0 !important;
    width: min(280px, 72vw) !important;
    height: auto !important;
    max-width: 72vw !important;
    z-index: 50;
  }

  .sub_page.home-logo {
    position: absolute !important;
    top: 18px !important;
    left: 76px !important;
    transform: none !important;
    height: auto !important;
    width: min(160px, 40vw) !important;
    max-width: 45vw !important;
  }

  /* Language switcher — ≥44px tap targets */
  #holder.main .lang,
  .lang.right,
  .lang {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    z-index: 60;
    font-size: 14px !important;
    margin: 0 0 16px !important;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 2px 4px;
    min-height: 44px;
    float: none !important;
    width: auto;
    max-width: 100%;
  }

  #holder.main .lang {
    position: absolute !important;
    top: 10px !important;
    right: 8px !important;
    margin: 0 !important;
  }

  .lang a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 8px 10px !important;
    margin: 0 !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    box-sizing: border-box;
  }

  /* Hamburger stays tappable — 56px, approved 2026-11-16 */
  #nav-btn {
    top: 12px !important;
    left: 12px !important;
    width: 56px !important;
    height: 56px !important;
    z-index: 160 !important;
  }

  #nav-btn span {
    left: 18px !important;
    top: 27px !important;
  }

  /* Full-screen menu: stack nav + project grid.
     Keep the existing texture, but sit it on near-black so page thumbs
     do not show through CONTACT US / the footer. */
  #black-cover {
    background-color: #000 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #black-cover > .content,
  .content {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin-top: 72px !important;
    margin-bottom: 24px !important;
    padding: 0 16px 96px !important;
    box-sizing: border-box !important;
    height: auto !important;
  }

  .navigation {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin-left: 0 !important;
    margin-bottom: 24px !important;
  }

  .navigation li a {
    font-size: 16px !important;
    line-height: 1.4 !important;
    margin-bottom: 4px !important;
    padding: 10px 0 !important;
    min-height: 44px;
    box-sizing: border-box;
    display: block !important;
  }

  .navigation li.submenu a span {
    right: 8px !important;
    top: 16px !important;
  }

  .navigation li.submenu > ul {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 40vh !important;
    padding-right: 8px !important;
  }

  #black-cover > .content > ul.navigation + div {
    float: none !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  #black-cover > .content > ul.navigation + div a {
    float: left !important;
    width: calc(50% - 8px) !important;
    height: auto !important;
    margin-right: 8px !important;
    margin-bottom: 16px !important;
  }

  #black-cover > .content > ul.navigation + div a img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    object-fit: cover;
  }

  #black-cover > .content > ul.navigation + div a span {
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  #footer {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    margin-top: 32px !important;
    padding-bottom: 24px !important;
  }

  .social {
    position: relative !important;
    bottom: auto !important;
    margin-bottom: 12px !important;
  }

  /* Inner pages: stack photo first, then full-width details (not 50/50) */
  .subcontent {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 16px 16px 32px !important;
    box-sizing: border-box !important;
    /* Defeat the expand/minimize JS which animates inline right: -50% */
    transform: none !important;
  }

  .subcontent .text,
  .text {
    height: auto !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  a.expand {
    position: relative !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    margin: 0 16px 28px auto !important;
    padding: 10px 36px 10px 12px !important;
    min-height: 44px;
    min-width: 44px;
    font-size: 14px !important;
    line-height: 1.2 !important;
    z-index: 20;
    opacity: 1;
    box-sizing: border-box;
  }

  a.expand span {
    top: 50% !important;
    margin-top: -7px;
  }

  /* Project detail table + slideshow */
  .subcontent.project table,
  .subcontent.project table tr,
  .subcontent.project table tr th,
  .subcontent.project table tr td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .subcontent.project table tr th {
    padding-bottom: 2px !important;
    opacity: 0.75;
  }

  .subcontent.project table tr td {
    padding-bottom: 14px !important;
  }

  /* Project thumbs: wrap so all 8 are visible (no clipped 08) */
  #content.project #cycle-nav {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0;
    padding: 0;
    z-index: 5;
    background: #000;
  }

  #content.project #cycle-nav ul,
  #holder.subpage #content.project #cycle-nav ul {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100% !important;
    max-width: 100% !important;
    text-align: left !important;
    padding: 10px 12px 12px !important;
    box-sizing: border-box;
    white-space: normal !important;
    overflow: visible !important;
    overflow-x: visible !important;
  }

  #content.project #cycle-nav ul li {
    display: block !important;
    flex: 0 0 auto;
    vertical-align: top;
    margin: 0 8px 8px 0 !important;
  }

  #content.project #cycle-nav ul a {
    width: 58px !important;
    height: 58px !important;
    min-width: 44px;
    min-height: 44px;
  }

  #content.project #cycle-nav ul a img,
  #content.project #cycle-nav img {
    width: 58px !important;
    height: 58px !important;
    max-width: none !important;
    object-fit: cover;
  }

  #content.project #cycle-nav ul a span {
    width: 58px !important;
    line-height: 58px !important;
  }

  /* About / services / contact: pager dots stay under the photo stage */
  #holder.subpage #cycle-nav {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    z-index: 5;
  }

  #holder.subpage #cycle-nav ul {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    width: 100% !important;
    padding: 8px 12px 10px !important;
    box-sizing: border-box;
    text-align: center !important;
  }

  #content.project #holder.subpage #cycle-nav ul {
    text-align: left !important;
    padding: 10px 12px 12px !important;
  }

  #arrow_left,
  #arrow_right {
    width: 44px !important;
    height: 44px !important;
    margin-top: -22px !important;
    z-index: 40;
  }

  #arrow_left {
    left: 8px !important;
  }

  #arrow_right {
    right: 8px !important;
  }

  /* Contact form */
  .contact_us .subcontent form input[type=text],
  .contact_us .subcontent form textarea {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px !important; /* reduces iOS zoom-on-focus */
    box-sizing: border-box;
  }

  .contact_us .subcontent form input[type=submit] {
    width: 100%;
    max-width: 100%;
    padding: 0 16px !important;
    line-height: 44px !important;
    min-height: 44px;
    font-size: 15px !important;
  }

  .contact_us .subcontent table {
    width: 100% !important;
  }

  /* Services page */
  .text .service-nav ul li {
    float: none !important;
    width: 100% !important;
    margin-bottom: 8px !important;
  }

  .text .service-nav ul li a,
  .text .service-nav.zh ul li a {
    width: 100% !important;
    height: auto !important;
    min-height: 44px;
    padding: 12px 8px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
    box-sizing: border-box;
  }

  .text .license {
    width: 100% !important;
    max-width: 100% !important;
    margin: 24px auto !important;
  }

  .text .license > div {
    float: none !important;
    width: 100% !important;
    margin-bottom: 16px;
  }

  .text ul li a {
    width: auto !important;
    max-width: 100% !important;
    margin-right: 0 !important;
  }

  .service .btn {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 12px !important;
    box-sizing: border-box;
    letter-spacing: 1px !important;
    font-size: 14px !important;
  }

  /* Homepage caption / pager sit above the fold but stay readable */
  #maximage h4 {
    bottom: 100px !important;
  }

  #maximage h5 {
    bottom: 48px !important;
  }

  #content.homepage #cycle-nav ul {
    position: absolute !important;
    bottom: 24px !important;
    top: auto !important;
    padding: 0 8px;
    box-sizing: border-box;
    width: 100% !important;
  }
}

/* Extra-narrow phones (~375 and below) */
@media screen and (max-width: 400px) {
  body {
    font-size: 14px;
  }

  .home-logo {
    width: min(240px, 78vw) !important;
  }

  #black-cover > .content > ul.navigation + div a {
    width: 100% !important;
    margin-right: 0 !important;
  }
}
