/* ==========================================================================
   Macam module switcher — the Macam mark opens a rounded panel of every module
   (Travel, Cleaning, Handyman, Renovation, GroupBuy). Self-contained: any header
   can include _MacamSwitcher + this file + js/macam-switcher.js.

   Open on: hover (only where a real pointer hovers), keyboard focus inside it,
   or .is-open (first tap on touch, set by the script). .is-closed (Esc) wins.
   ========================================================================== */

.mx-switch { position: relative; display: inline-flex; flex: none; }

[data-mx-trigger] {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px;
    color: #4B5A67; font-weight: 700; text-decoration: none; transition: background-color .18s ease, color .18s ease;
}
[data-mx-trigger]:hover { text-decoration: none; }
.mx-chev { transition: transform .22s ease; opacity: .7; }

.mx-panel {
    position: absolute; left: 0; top: 100%; margin-top: 12px; z-index: 90;
    width: min(580px, calc(100vw - 32px));
    background: #fff; border: 1px solid #E3EAF1; border-radius: 24px; padding: 14px;
    box-shadow: 0 2px 6px rgba(15, 34, 51, .06), 0 24px 60px -20px rgba(15, 34, 51, .38);
    opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); transform-origin: 28px 0;
    transition: opacity .16s ease, transform .18s ease, visibility 0s linear .18s;
}
/* An invisible bridge over the gap, so moving the mouse from the mark to the panel never closes it. */
.mx-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 14px; }

@media (hover: hover) and (pointer: fine) {
    .mx-switch:hover [data-mx-trigger] { background: #EEF3F8; color: #0F2233; }
    .mx-switch:hover .mx-chev { transform: rotate(180deg); }
    .mx-switch:hover .mx-panel { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
}
.mx-switch:focus-within [data-mx-trigger], .mx-switch.is-open [data-mx-trigger] { background: #EEF3F8; color: #0F2233; }
.mx-switch:focus-within .mx-chev, .mx-switch.is-open .mx-chev { transform: rotate(180deg); }
.mx-switch:focus-within .mx-panel, .mx-switch.is-open .mx-panel { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.mx-switch.is-closed .mx-panel { opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); }
.mx-switch.is-closed .mx-chev { transform: none; }

.mx-head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 4px 8px 12px; margin-bottom: 8px; border-bottom: 1px solid #EEF2F6;
    font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6B7A88;
}
.mx-head a { text-transform: none; letter-spacing: 0; font-size: 13.5px; color: #1E5A85; text-decoration: none; white-space: nowrap; }
.mx-head a:hover { text-decoration: underline; }

.mx-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.mx-item {
    position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 12px;
    border-radius: 18px; color: #0F2233; text-decoration: none; border: 1px solid transparent;
    transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
a.mx-item:hover { background: #F4F8FB; border-color: #E3EAF1; text-decoration: none; transform: translateY(-1px); }
a.mx-item:focus-visible { outline: 3px solid #4391C2; outline-offset: 2px; }
.mx-item.is-current { background: #EAF3FA; border-color: #CFE2F0; }

.mx-ico {
    flex: none; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
    background: var(--mx-tint, #EEF2F6); color: var(--mx-ink, #4B5A67);
}
.mx-ico .cx-ico { width: 22px; height: 22px; }
.mx-text { display: flex; flex-direction: column; min-width: 0; }
.mx-text b { font-size: 15px; line-height: 1.25; }
.mx-text small { font-size: 12.5px; color: #6B7A88; line-height: 1.35; }

/* Each module keeps its own colour, so the panel reads at a glance. */
.mx-travel { --mx-tint: #E3F6EF; --mx-ink: #1E6A54; }
.mx-cleaning { --mx-tint: #EAF3FA; --mx-ink: #1E5A85; }
.mx-handyman { --mx-tint: #FDF1E3; --mx-ink: #A0601A; }
.mx-renovation { --mx-tint: #F1ECFB; --mx-ink: #6A4BB0; }
.mx-groupbuy { --mx-tint: #FCEBEF; --mx-ink: #A23A55; }

.mx-item.is-soon { cursor: default; }
.mx-item.is-soon .mx-ico, .mx-item.is-soon .mx-text { opacity: .55; }
.mx-soon, .mx-here {
    margin-left: auto; flex: none; font-style: normal; font-size: 11.5px; font-weight: 700;
    padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.mx-soon { background: #F1F3F6; color: #6B7A88; }
.mx-here { background: #1E5A85; color: #fff; }

@media (max-width: 560px) {
    .mx-grid { grid-template-columns: 1fr; }
    .mx-item { min-height: 56px; }
}

/* A finger-sized target for the mark itself. */
[data-mx-trigger] { min-height: 44px; }

/* "You're here" sits in the card's corner so the module name keeps its one line. */
.mx-here { position: absolute; top: 7px; right: 8px; font-size: 10.5px; padding: 2px 8px; }

/* The trigger's own look, so the control is identical in every header (it used to borrow
   .cx-home from cleaning.css, which travel pages do not load). */
.mx-switch [data-mx-trigger] { font-size: 14px; }
.mx-switch .brand-mark { width: 26px; height: 26px; }
@media (max-width: 960px) { .mx-switch [data-mx-trigger] > span { display: none; } }

@media (prefers-reduced-motion: reduce) {
    .mx-panel, .mx-chev, .mx-item, [data-mx-trigger] { transition: none; }
}
