/* ═══════════════════════════════════════════
   HOTELA i18n — Shared language styles
   Matches book.html lang switcher design
   Used by: own-v10, residence-* pages
   ═══════════════════════════════════════════ */

/* CJK + Arabic font imports */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;600;700&family=Noto+Sans+Arabic:wght@300;400;500;600;700&display=swap');

/* Language-specific fonts */
body.lang-ja { font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; }
body.lang-zh { font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; }
body.lang-ko { font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; }
body.lang-ar { font-family: 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; }

/* RTL Support for Arabic */
body.lang-ar { direction: rtl; text-align: right; }
body.lang-ar .nav { direction: ltr; }
body.lang-ar .lang-switcher { direction: ltr; }
body.lang-ar .lang-dropdown-menu { direction: ltr; text-align: left; }
body.lang-ar .footer-links { direction: ltr; }

/* ── Language Switcher (matching book.html design) ── */
.lang-switcher {
    position: absolute;
    right: 22px;
}

.lang-dropdown-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lang-dropdown-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* Scrolled nav override — dark text on light bg */
.nav.scrolled .lang-dropdown-btn {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.12);
    color: #1d1d1f;
}

.nav.scrolled .lang-dropdown-btn:hover {
    background: rgba(0,0,0,0.1);
}

.lang-dropdown-btn svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

.lang-dropdown.open .lang-dropdown-btn svg {
    transform: rotate(180deg);
}

.lang-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    width: 320px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    z-index: 1000;
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
}

.lang-dropdown.open .lang-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9em;
    color: #1a1a1a;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.lang-option:hover {
    background: #f5f5f5;
}

.lang-option.active {
    background: #f0f0f0;
    font-weight: 600;
}

.lang-option span {
    opacity: 0.5;
    font-size: 0.75em;
    margin-top: 2px;
}

/* ── Residence pages: light nav (always scrolled look) ── */
.nav-light .lang-dropdown-btn {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.12);
    color: #1d1d1f;
}

.nav-light .lang-dropdown-btn:hover {
    background: rgba(0,0,0,0.1);
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .lang-dropdown-btn {
        padding: 8px 12px;
        font-size: 0.8em;
    }
}

/* Phone: switch from button-anchored popover to viewport-anchored sheet.
   Reason: at <= 640 a 320 px popover anchored to a right-aligned button
   always clips one column on small viewports. The sheet pattern (left:12,
   right:12, width:auto) is overflow-proof at any width. */
@media (max-width: 640px) {
    .lang-dropdown-menu {
        position: fixed !important;
        bottom: auto;
        left: 12px !important;
        right: 12px !important;
        /* Explicit calc — left+right alone do not stretch a display:grid
           box when an earlier rule set width:320px. */
        width: calc(100vw - 24px) !important;
        max-width: none !important;
        /* Position below the header. JS toggles --lang-menu-top inline based
           on header height when the menu opens, so we don't hard-code 66 px. */
        top: var(--lang-menu-top, 64px) !important;
    }

    /* When portaled to <body> the menu loses its `.lang-dropdown.open .lang-dropdown-menu`
       ancestor selector — we drive visibility off its own class instead. */
    .lang-dropdown-menu.is-portaled.open {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }

    /* Allow the two-column grid to compress; each option must accept
       narrower width or text would otherwise overflow inside the cell. */
    .lang-option {
        min-width: 0;
        padding: 12px 10px;
        font-size: 0.88em;
    }

    .lang-option span {
        font-size: 0.72em;
    }
}
