/* ============================================================
   GLOBAL BASE
   ============================================================ */

html, body {
    margin: 0;
    padding: 0;
    background: black;
    color: white;
    font-family: system-ui, sans-serif;
    height: 100%;
}

* {
    box-sizing: border-box;
}

button {
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
}

/* ============================================================
   UNIVERSAL PAGE WRAPPER (ALL PAGES)
   ============================================================ */

.page-wrapper {
    width: 100%;
    max-width: 430px; /* desktop phone-frame width */
    margin: 0 auto;
    padding-left: 10px;
    padding-right: 10px;
    overflow-x: hidden;
}

/* Desktop phone-frame background */
/*@media (min-width: 768px) {
    .page-wrapper {
        background: url('/images/meditation_home.jpg') center/cover no-repeat;
        border-radius: 40px;
        border: 2px solid white;
        padding-top: 40px;*/ /* space for top curve */
        /*padding-bottom: 20px;
    }
}*/

@media (min-width: 768px) {
    .mainpage-wrapper {
        background: url('/images/meditation_home.jpg') center/cover no-repeat;
        border-radius: 40px;
        border: 2px solid white;
        padding-top: 40px;
        padding-bottom: 20px;
        margin-top: 40px; /* ~1cm visually depending on DPI */
        margin-bottom: 40px;
    }

}
@media (min-width: 768px) {
    .main-page {
        min-height: auto;
    }
}

@media (min-width: 768px) {
    .page-wrapper {
        height: auto !important;
        min-height: auto !important;
    }
}



.mainpage-wrapper {
    background: url('/images/meditation_home.jpg') center/cover no-repeat;
}


/* ============================================================
   LOADING SPINNER
   ============================================================ */

.loading-root {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255,255,255,0.2);
    border-top-color: #512BD4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   MAIN PAGE (Unified Layout)
   ============================================================ */

.main-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-top: 20px;
}

.mainpage-content {
    width: 100%;
    padding: 20px;
}

/* Icon grid */
.button-grid {
    display: grid;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}

@media (min-width: 768px) {
    .button-grid {
        grid-template-columns: repeat(3, 70px);
    }
}

@media (max-width: 600px) {
    .button-grid {
        grid-template-columns: repeat(3, 60px);
        gap: 4px;
        margin-top: 6px;
    }
}

/* Icon sizes */
@media (min-width: 768px) {
    .icon-button {
        width: 90px;
        height: 90px;
    }

        .icon-button img {
            width: 80px;
            height: 80px;
        }
}

@media (max-width: 600px) {
    .icon-button {
        width: 52px;
        height: 52px;
    }

        .icon-button img {
            width: 42px;
            height: 42px;
        }
}

/* Intro button */
.mainpage-bottom {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.mainpage-btn {
    padding: 10px 24px;
    background: #512BD4;
    color: white;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

/* ============================================================
   POPUPS
   ============================================================ */

.popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.popup-content {
    background: white;
    color: black;
    width: 85%;
    max-height: 80%;
    padding: 20px;
    border-radius: 12px;
    overflow-y: auto;
    font-size: 12px;
}

.popup-close {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border-radius: 8px;
    background: #0078d4;
    color: white;
}

/* ============================================================
   CHOOSE PAGE (Unified Layout)
   ============================================================ */

.choose-page {
    width: 100%;
    min-height: 100vh;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tracks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.track-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.track-image {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
}

.track-icon {
    width: 40px;
    height: 40px;
}

.back-row {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.back-btn {
    padding: 10px 22px;
    background: #512BD4;
    color: white;
    border-radius: 8px;
    font-size: 16px;
}

/* ============================================================
   PLAY PAGE (Unified Layout)
   ============================================================ */

.play-page {
    width: 100%;
    min-height: 100vh;
    padding-top: 10px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.play-inner {
    width: 100%;
    padding: 20px;
}

.play-image-row {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.play-image {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

.play-title-row {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.play-controls-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.play-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.play-column {
    margin-bottom: 20px;
}

input[type="range"] {
    width: 100%;
    accent-color: #512BD4;
}

input[type="checkbox"] {
    transform: scale(1.3);
}

.play-controls-row img,
.play-row img {
    width: 52px;
    height: 52px;
}

/* ============================================================
   HELP OVERLAY
   ============================================================ */

.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.help-content {
    background: white;
    color: black;
    width: 85%;
    max-height: 80%;
    padding: 20px;
    border-radius: 12px;
    overflow-y: auto;
    font-size: 12px;
}

@media (min-width: 768px) {
    .help-content {
        max-width: 390px;
        width: 90%;
    }
}

.help-close {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    border-radius: 8px;
    background: #0078d4;
    color: white;
}

/* ============================================================
   SAFE AREA (iOS)
   ============================================================ */

.page-wrapper {
    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);
}


/* Constrain MainPage popup width on desktop */
/*@media (min-width: 768px) {
    .popup-content {
        max-width: 390px;
        width: 90%;
        margin: 0 auto;
    }
}*/

.popup-frame {
    width: 100%;
    max-width: 430px; /* match your phone-frame width */
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}
