/* =============================================================
   Site Cover / Splash screen
   Full-screen intro shown before entering the site.
   Per-event styling via .cover-<style> classes.
   ============================================================= */

/* Prevent background scroll while the cover is visible */
html.cover-active,
html.cover-active body {
    overflow: hidden;
}

.site-cover {
    position: fixed;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    width: auto;
    height: auto;
    z-index: 99999; /* above preloader and everything else */
    text-align: center;
    background-color: #0066cc;
    overflow-y: auto; /* allow scrolling down to reach the button */
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    transition: opacity 0.6s ease;
}

.site-cover.is-leaving {
    opacity: 0;
    pointer-events: none;
}

.site-cover__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, var(--overlay-opacity, 0.55));
}

/* Content fills the cover: centered block + bottom-anchored footer/button */
.site-cover__content {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 100%; /* grow with content so the button can be scrolled to */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(16px, 4vh, 40px) clamp(14px, 4vw, 20px);
    box-sizing: border-box;
}

/* The cover image is an <img> in the flex flow (not a background), so the
   text and buttons can never overlap it: the image shrinks to whatever
   vertical space is left above them. Requires the content box to be locked
   to the viewport height (see .has-image rule below) so flex can shrink it. */
.site-cover__media {
    flex: 1 1 auto;
    min-height: 0; /* allow shrinking below the image's natural size */
    width: 100%;
}

.site-cover__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* whole image visible, no cropping */
    object-position: center top;
}

/* Lock the layout to the viewport so the image is squeezed to the space
   left over by the text/buttons instead of pushing them below the fold. */
.site-cover.has-image .site-cover__content {
    height: 100%;
    min-height: 0;
}

.site-cover__inner {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 720px;
    /* scale the headline offset with viewport height instead of a fixed
       200px that overflows small phones / short landscape screens */
    padding-top: clamp(40px, 24vh, 200px);
}

/* When an image is present it takes the flexible space, so the text block
   sits right below it instead of pushing everything down. */
.site-cover.has-image .site-cover__inner {
    flex: 0 0 auto;
    padding-top: clamp(12px, 3vh, 24px);
}

.site-cover__footer {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 24px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.site-cover__logo {
    max-width: 160px;
    height: auto;
    margin: 0 auto 28px;
    display: block;
}

.site-cover__title {
    color: #fff;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: clamp(24px, 5.5vw, 42px);
    line-height: 1.25;
    margin: 0 0 16px;
    font-weight: 700;
    overflow-wrap: break-word;
}

.site-cover__subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(15px, 2.4vw, 18px);
    line-height: 1.6;
    margin: 0 0 clamp(20px, 4vh, 34px);
}

.site-cover__btn {
    display: inline-block;
    border: 2px solid #03c3f9;
    background: var(--btn-bg-color, #0066cc);
    color: var(--btn-text-color, #ffffff);
    font-size: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 13px 34px;
    min-height: 48px; /* comfortable touch target */
    border-radius: 2px;
    cursor: pointer;
}

.site-cover__btn:hover {
    background: var(--btn-bg-color, #0066cc);
    color: var(--btn-text-color, #ffffff);
}

.site-cover__btn span {
    margin-left: 6px;
}

.site-cover__login {
    display: block;
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.25s ease;
}

.site-cover__login:hover {
    color: #fff;
    text-decoration: underline;
}

/* ---------- Event: Mourning (ไว้อาลัย) ---------- */
.cover-mourning {
    background-color: #000;
}

.cover-mourning .site-cover__overlay {
    background: rgba(0, 0, 0, 0.25);
}

/* Render any background image in grayscale for mourning */
.cover-mourning {
    filter: grayscale(100%);
}

.cover-mourning .site-cover__title {
    font-weight: 500;
    letter-spacing: 1px;
}

/* Black mourning ribbon (corner) */
.cover-mourning .site-cover__ribbon {
    position: fixed;
    top: 0;
    left: 0;
    width: 140px;
    height: 140px;
    overflow: hidden;
    z-index: 3;
}

.cover-mourning .site-cover__ribbon::before {
    content: "";
    position: absolute;
    top: 28px;
    left: -42px;
    width: 180px;
    height: 26px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    transform: rotate(-45deg);
}

/* ---------- Event: New Year ---------- */
.cover-newyear {
    background-color: #0b1f3a;
    background-image: linear-gradient(135deg, #0b1f3a 0%, #14375f 100%);
}

.cover-newyear .site-cover__overlay {
    background: rgba(11, 31, 58, 0.35);
}

.cover-newyear .site-cover__title {
    color: #ffd86b;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.cover-newyear .site-cover__btn {
    border-color: #ffd86b;
    color: #ffd86b;
}

.cover-newyear .site-cover__btn:hover {
    background: #ffd86b;
    color: #0b1f3a;
}

/* ---------- Responsive ----------
   Typography and spacing scale fluidly via clamp() above; the
   breakpoints below only handle layout changes. */
@media (max-width: 600px) {
    .site-cover__logo { max-width: 120px; margin-bottom: 20px; }
    .site-cover__footer {
        padding-top: 18px;
        flex-direction: column; /* stack the login link under the button */
        align-items: center;
    }
    .site-cover__btn {
        width: 100%;
        max-width: 320px;
        padding: 14px 20px;
    }
    .site-cover__login {
        padding: 10px; /* larger touch target */
        margin-top: 8px;
    }
    .cover-mourning .site-cover__ribbon { width: 100px; height: 100px; }
}

/* Portrait / narrow screens: center the image in the free space */
@media (orientation: portrait), (max-width: 600px) {
    .site-cover__media { align-items: center; }
    .site-cover__media img { object-position: center center; }
}

/* Short / landscape screens (e.g. phone rotated): compact everything */
@media (max-height: 480px) {
    .site-cover__inner { padding-top: clamp(16px, 10vh, 48px); }
    .site-cover.has-image .site-cover__inner { padding-top: 8px; }
    .site-cover__logo { max-width: 90px; margin-bottom: 12px; }
    .site-cover__title { font-size: 22px; margin-bottom: 8px; }
    .site-cover__subtitle { font-size: 14px; margin-bottom: 12px; }
    .site-cover__footer { padding-top: 12px; }
    .site-cover__btn { width: auto; }
}
