/* static/css/layout.css */

html {
    scroll-padding-top: var(--header-height);
}

/* --- 1. 기본 레이아웃 컨테이너 --- */
.header-container {
    position: fixed;
    top: 0; left: 0; right: 0;
    width: 100%;
    height: var(--header-height);
    z-index: 1020;
    background-color: var(--color-content-bg);
    border-bottom: 0px solid var(--color-border);
}
.header-content-wrapper {
    max-width: var(--content-max-width);
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    position: relative;
}
.app-container {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    position: relative;
    padding-top: var(--header-height);
    padding-bottom: var(--footer-height);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* --- 2. 조건부 레이아웃 --- */
.layout-body-scroll .app-container {
    background-color: var(--color-content-bg);
}

.layout-fixed-content {
    overflow: hidden;
    background-color: #000;
}
.layout-fixed-content .app-container {
    height: 100dvh;
    background-color: transparent;
}
.layout-fixed-content .app-container.full-width {
    max-width: none;
}
.layout-fixed-content .content-container {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    scroll-padding-top: var(--header-height);
}
.layout-fixed-content .content-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    width: 100%;
    margin: 0 auto;
    padding: 0 8px;
    box-sizing: border-box;
}

/* --- 3. 푸터 레이아웃 --- */
.footer-container {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: var(--footer-height);
    z-index: 1010;
    background: var(--color-content-bg);
    border-top: 1px solid var(--color-border);
    box-sizing: border-box;
}
.footer-content-wrapper {
    max-width: var(--content-max-width);
    height: 100%;
    margin: 0 auto;
    position: relative;
}

.footer-main-app-content-wrapper,
.footer-nav-items-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0 24px;
    box-sizing: border-box;
}

.footer-main-app-content-wrapper {
}

.footer-logo-area {
    position: absolute;
    top: 9px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--color-text-primary);
}
.footer-main-logo {
    width: auto;
    height: 24px;
}
.figma-nav-item {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    top: 9px;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
}
.figma-icon {
    width: 100%;
    height: 100%;
    margin-bottom: 0;
}
.nav-item-home  { left: 12%; }
.nav-item-bible { left: 31%; }
.nav-item-hymns { left: 50%; }
.nav-item-ccm   { left: 69%; }
.nav-item-menu  { left: 88%; }

/* --- 4. 푸터 컨텍스트 메뉴 --- */
.menu-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0);
    z-index: 1029;
}

.user-context-menu {
    display: none;
    position: fixed;
    bottom: calc(var(--footer-height) + 8px);
    right: 50%;
    margin-right: calc(-1 * var(--content-max-width) / 2 + 16px);
    width: 180px;
    background-color: var(--color-content-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1030;
    overflow: hidden;
}

.menu-backdrop.active,
.user-context-menu.active {
    display: block;
}

.context-menu-item {
    display: block;
    padding: 12px 16px;
    font-size: 16px;
    color: var(--color-text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border-light);
    text-align: center;
}
.context-menu-item:last-child {
    border-bottom: none;
}
.context-menu-item:hover {
    background-color: var(--color-hover-bg);
}

.footer-container {
    transition: transform 0.3s ease-in-out;
}
.footer-container.footer--hidden {
    transform: translateY(100%);
}

.layout-body-centered {
    background-color: var(--color-content-bg);
}
.layout-body-centered .app-container {
    background-color: transparent;
}

.sticky-header-content {
    position: -webkit-sticky;
    position: sticky;
    top: var(--header-height);
    background-color: var(--color-content-bg);
    z-index: 1000;
    border-bottom: 1px solid var(--color-border-light);
}

.body-scroll-lock {
    overflow: hidden;
}

/* --- 프리 로더 스타일 --- */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-content-bg);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

body.loaded #preloader {
    opacity: 0;
    visibility: hidden;
}

#preloader .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;

    /* [핵심 수정] 스피너를 기본적으로 숨기고, 전환 효과를 추가합니다. */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* [핵심 수정] 이 클래스가 추가되면 스피너가 나타납니다. */
#preloader.show-spinner .spinner {
    opacity: 1;
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}