/* Minimal Essential Styles - Clean Slate */
/* Only critical styles needed for the app to function */

@font-face {
    font-family: 'Morebi Rounded Black';
    src: url('../fonts/bb820f8532d929719198f5676948aec3.woff2') format('woff2'),
         url('../fonts/bb820f8532d929719198f5676948aec3.woff') format('woff'),
         url('../fonts/bb820f8532d929719198f5676948aec3.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Global Styles */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
}

/* Ensure all elements use our custom font */
*,
*::before,
*::after {
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

img {
    pointer-events: none;
    -webkit-touch-callout: none;
}

input, 
textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    background-image: linear-gradient(to left bottom, #212317, #232519, #25281b, #282a1e, #2a2d20, #333720, #3e4120, #4a4b1f, #675d17, #8b6c0a, #b67900, #e68200);
    color: #d2cfb2;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Orientation Lock Message */
.rotate-device-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #212317;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    color: #f3f2e7;
    flex-direction: column;
    gap: 20px;
}

.rotate-device-message svg {
    width: 64px;
    height: 64px;
    animation: rotate 1.5s ease-in-out infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-90deg); }
    75% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

@media screen and (orientation: landscape) and (max-width: 900px) {
    .rotate-device-message {
        display: flex;
    }
    
    body > *:not(.rotate-device-message) {
        display: none !important;
    }
}

/* Menu Styles */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 9998;
    display: none;
}

.menu-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    display: block;
}

.menu-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background-color: #212317;
    padding: 2rem;
    box-sizing: border-box;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
}

.menu-sidebar.is-visible {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.menu-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #f3f2e7;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.menu-close-button {
    font-size: 2rem;
    color: #f3f2e7;
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
}

.menu-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-links li {
    padding: 0;
    margin: 0;
}

.menu-links li:not(:last-child) {
    border-bottom: 1px solid #d2cfb2;
}

.menu-links a {
    display: block;
    padding: 1rem;
    color: #d2cfb2;
    text-decoration: none;
    font-size: 1.1rem;
    transition: background-color 0.3s ease;
}

.menu-links a:hover {
    background-color: rgba(210, 207, 178, 0.1);
}

.menu-links li.home-button-offline {
    display: none !important;
}

/* Language selector at bottom of menu - styled like activation page buttons */
.menu-language-selector {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 2rem;
}

.menu-lang-container {
    display: flex;
    align-items: center;
    background-color: rgba(42, 42, 42, 0.6);
    border-radius: 2rem;
    padding: 0.5rem;
    border: 1px solid rgba(255, 145, 0, 0.3);
}

.menu-lang-btn {
    padding: 0.5rem 1.25rem;
    background-color: transparent;
    color: white;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 1.5rem;
}

.menu-lang-btn:hover {
    background-color: rgba(255, 145, 0, 0.2);
}

.menu-lang-btn.active {
    background-color: #ff9100;
    color: #2a2d20;
    font-weight: 700;
}

.menu-lang-divider {
    width: 1px;
    height: 24px;
    background-color: rgba(255, 145, 0, 0.4);
}

@media (max-width: 400px) {
    .menu-sidebar {
        width: 100%;
    }
}

.mma-hamburger {
    position: relative;
    z-index: 9997;
    cursor: pointer;
}

.menu-hamburger {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

/* ============================================
   PWA STANDALONE MODE STYLES
   ============================================ */

/* Base standalone mode - applies to all platforms */
.pwa-standalone {
    /* Add any universal standalone styles here */
}

/* iOS-specific standalone mode styles */
.pwa-ios {
    /* iOS standalone mode has more screen space due to no browser chrome */
    
    /* Define safe area variables */
    --status-bar-height: env(safe-area-inset-top, 44px);
    --bottom-safe-area: env(safe-area-inset-bottom, 0px);
}

/* === STANDALONE MODE: HEADERS === */
/* CRITICAL: Safari reports safe-area-inset-top inconsistently:
   - Map/POI pages: 59px (correct for Dynamic Island)
   - Home page: 0px (incorrect!)
   Solution: Use margin-top for home, max() for others */

/* Home page header - use margin-top to push down (keeps Tailwind positioning) */
html.pwa-ios #homeheader,
html.pwa-standalone #homeheader {
    margin-top: 50px !important;
}

/* Map and POI page headers - use fixed positioning */
html.pwa-ios body:not(:has(.start-page-container)) header,
html.pwa-ios body:not(:has(.start-page-container)) header.sticky {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: linear-gradient(135deg, #4a4b1f, #2a2d20);
    top: -30px;
    padding-top: 80px;
}

/* Map container positioning in standalone mode */
.pwa-standalone #map-container {
    top: 70px !important;
}

/* Map UI panels positioning in standalone mode */
.pwa-standalone #search-panel {
    top: 140px !important;
}

.pwa-standalone #filter-panel {
    top: 140px !important;
}

.pwa-standalone #route-controls {
    top: 140px !important;
}

/* Toast notifications positioning in standalone mode */
.pwa-standalone .toast-container,
.pwa-standalone #toast-container,
.pwa-standalone [class*="toast"] {
    top: 130px !important;
}

/* POI detail gallery close button in standalone mode */
.pwa-standalone #gallery-close-btn {
    top: 80px !important;
}

/* Activation page popups in standalone mode */
.pwa-standalone #what-includes-popup > div,
.pwa-standalone #how-to-acquire-popup > div {
    top: 17% !important;
}

/* Reception pages: Date input calendar icon color */
input[type="date"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(58%) sepia(89%) saturate(2476%) hue-rotate(360deg) brightness(102%) contrast(104%);
    cursor: pointer;
}

/* Download language page titles - push down in standalone mode */
.pwa-standalone .title-font.text-3xl.font-bold.mma-guide-main {
    padding-top: 30px;
}

/* QR scanner page title - push down in standalone mode */
.pwa-standalone #qr-instruction-text {
    padding-top: 30px;
}

/* Content detail page - push down to avoid header cropping image */
.pwa-standalone .min-h-screen.flex.flex-col.relative.overflow-hidden {
    top: 100px;
}

/* Back button positioning in standalone mode */
.pwa-standalone .flex.items-center.gap-3 {
    /* Ensure back button doesn't get hidden under system UI */
    padding-top: 0;
}

/* QR page header - ensure it's visible in standalone */
.pwa-standalone #qr-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 99999 !important;
    background: linear-gradient(180deg, rgba(33, 35, 23, 0.95) 0%, rgba(33, 35, 23, 0.7) 100%) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    padding-top: 50px !important;
}

/* Push QR scanner content down to avoid header overlap */
.pwa-standalone .qr-scanner-container,
.pwa-standalone #qr-scanner-container {
    margin-top: 100px !important;
}

/* Ensure main content on QR page has enough top padding in standalone */
.pwa-standalone .language-selection-bg main {
    padding-top: 180px !important;
}

/* Menu sidebar: Same 59px minimum */
html.pwa-ios .menu-sidebar,
html.pwa-standalone .menu-sidebar {
    padding-top: calc(max(env(safe-area-inset-top, 0px), 59px) + 2rem) !important;
}

html.pwa-ios .menu-header,
html.pwa-standalone .menu-header {
    margin-top: 0 !important;
}

/* Adjust bottom navigation/buttons for iOS home indicator */
.pwa-ios .bottom-nav,
.pwa-ios .fixed-bottom {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* Map home page - adjust button positioning for iOS standalone */
.pwa-ios #map-home-bottom-nav {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* Adjust QR button on content pages */
.pwa-ios #show-qr-button {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* Android-specific standalone mode styles */
.pwa-android {
    /* Android standalone typically doesn't need as much adjustment */
    /* But you can add specific styles if needed */
}

/* Browser mode styles (when NOT in standalone) */
.pwa-browser {
    /* Styles that only apply when running in regular browser */
    /* This is the default behavior, so usually no changes needed */
}

/* Hide install prompts when already in standalone mode */
.pwa-standalone .install-prompt,
.pwa-standalone .add-to-home-prompt {
    display: none !important;
}

/* Standalone mode benefits - hide browser-specific elements */
.pwa-standalone .browser-only {
    display: none;
}

/* Show standalone-only elements */
.standalone-only {
    display: none;
}

.pwa-standalone .standalone-only {
    display: block;
}

/* ============================================
   PWA VIEWPORT ADJUSTMENTS
   ============================================ */

/* Maximize available screen space in standalone mode */
.pwa-standalone body {
    /* Remove any artificial margins that were needed for browser chrome */
    min-height: 100vh;
}

/* iOS notched devices - ensure content doesn't overlap with notch */
/* DISABLED: This was causing layout issues because safe-area-inset-top is inconsistent
@supports (padding: env(safe-area-inset-top)) {
    .pwa-ios {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
*/

/* ============================================
   DEBUG MODE (remove in production)
   ============================================ */

/* Uncomment to visually debug standalone mode */
/*
.pwa-standalone::before {
    content: 'PWA: Standalone Mode';
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(255, 145, 0, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    z-index: 99999;
    pointer-events: none;
}

.pwa-ios::after {
    content: 'iOS';
    position: fixed;
    top: 0;
    right: 0;
    background: rgba(0, 122, 255, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    z-index: 99999;
    pointer-events: none;
}
*/
