﻿/* ==========================================================================
   LOSER KINGDOM - mobile home, based on approved concept A.
   ========================================================================== */

body:has(.welcome-screen) {
    overflow: hidden;
}

body:has(.welcome-screen) #app-shell {
    display: none;
}

.welcome-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    margin: auto;
    overflow: auto;
    background: #09121c;
    color: #f7dfaa;
    font-family: 'EB Garamond', Georgia, serif;
    box-shadow: 0 0 110px #000;
}

/* --------------------------------------------------------------------------
   Scenery Artboard & Coordinates (911 x 1728)
   -------------------------------------------------------------------------- */
.kingdom-map {
    position: relative;
    flex: 1 0 440px;
    min-height: 440px;
    overflow: hidden;
}

.kingdom-artboard {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    aspect-ratio: 911 / 1728;
    isolation: isolate;
}

.kingdom-scenery {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.world-wind-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.kingdom-map::after {
    content: '';
    position: absolute;
    inset: auto 0 0;
    height: 55px;
    background: linear-gradient(transparent, #070d14);
    pointer-events: none;
    z-index: 5;
}

/* Brand Title */
.kingdom-brand {
    position: absolute;
    top: 20px;
    left: 28px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    background: none;
}

.kingdom-brand svg {
    width: 27px;
    height: 22px;
    fill: #e8c476;
    stroke: #fff0c5;
    stroke-width: 0.5;
}

.kingdom-brand h1 {
    font: 600 22px/1.08 'Playfair Display', Georgia, serif;
    letter-spacing: 2.8px;
    text-align: center;
    color: #f4d28c;
    text-shadow: 0 2px 9px #000;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Isolated Motion Layers (Flags & Traveler Cloak Flutter)
   Zero background distortion, zero GPU crash on Android!
   -------------------------------------------------------------------------- */
.banner-layer {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.65));
}

.banner-flag-svg, .cloak-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.left-royal-banner {
    left: 7.4%;  /* x: 68 / 911 */
    top: 60.5%;  /* y: 1045 / 1728 */
    width: 9.2%; /* w: 84 / 911 */
    height: 10.1%;/* h: 175 / 1728 */
    transform-origin: 50% 5%;
    animation: royal-banner-wave 3.6s ease-in-out infinite;
}

.right-bridge-banner {
    left: 86.2%; /* x: 785 / 911 */
    top: 48.6%;  /* y: 840 / 1728 */
    width: 4.6%;  /* w: 42 / 911 */
    height: 5.5%; /* h: 95 / 1728 */
    transform-origin: 50% 5%;
    animation: bridge-banner-wave 3.2s ease-in-out infinite -1.4s;
}

.traveler-cloak-layer {
    position: absolute;
    left: 45.0%; /* x: 410 / 911 */
    top: 55.5%;  /* y: 960 / 1728 */
    width: 10.4%; /* w: 95 / 911 */
    height: 6.4%; /* h: 110 / 1728 */
    transform-origin: 75% 20%;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.7));
    animation: traveler-cloak-wave 2.8s ease-in-out infinite;
}

@keyframes royal-banner-wave {
    0%, 100% {
        transform: rotate(0deg) skewX(0deg) scaleX(1);
    }
    25% {
        transform: rotate(-1.4deg) skewX(-2.2deg) scaleX(0.98);
    }
    50% {
        transform: rotate(0.9deg) skewX(1.8deg) scaleX(1.02);
    }
    75% {
        transform: rotate(-0.7deg) skewX(-1.2deg) scaleX(0.99);
    }
}

@keyframes bridge-banner-wave {
    0%, 100% {
        transform: rotate(0deg) skewX(0deg) scaleX(1);
    }
    30% {
        transform: rotate(1.6deg) skewX(2.4deg) scaleX(1.03);
    }
    70% {
        transform: rotate(-1.2deg) skewX(-1.8deg) scaleX(0.97);
    }
}

@keyframes traveler-cloak-wave {
    0%, 100% {
        transform: rotate(0deg) skewY(0deg) scale(1);
    }
    35% {
        transform: rotate(2.8deg) skewY(3.2deg) scale(1.03, 0.98);
    }
    70% {
        transform: rotate(-1.8deg) skewY(-2.2deg) scale(0.97, 1.02);
    }
}

/* Atmosphere & Canvases */
.kingdom-atmosphere, #kingdom-magic, #kingdom-petals, .goal-beacons {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.kingdom-atmosphere, #kingdom-magic {
    z-index: 2;
}

#kingdom-petals {
    z-index: 4;
}

.goal-beacons {
    z-index: 5;
}

#kingdom-foreground-petals {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 7;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Goal Waypoint Beacons (Parchment Labels)
   -------------------------------------------------------------------------- */
.beacon {
    position: absolute;
    min-height: 44px;
    width: 22%;
    display: flex;
    align-items: center;
    pointer-events: auto;
    text-decoration: none;
    color: #30200d;
    font: 600 15px/1 'EB Garamond', Georgia, serif;
    transform: translateY(-50%);
}

.beacon span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 5px 8px;
    background: url('kingdom-label-v7.webp') center/100% 100% no-repeat;
    filter: drop-shadow(0 2px 2px #0007);
    white-space: nowrap;
    text-shadow: 0 1px #fff1;
}

.long  { left: 80.0%; top: 13.90%; width: 20.0%; }
.year  { left: 71.0%; top: 24.95%; width: 21.0%; }
.month { left: 55.0%; top: 32.30%; width: 23.0%; }
.week  { left: 80.5%; top: 40.45%; width: 19.5%; }
.day   { left: 69.0%; top: 53.10%; width: 23.0%; }

/* --------------------------------------------------------------------------
   Floating Mentor Advisor
   -------------------------------------------------------------------------- */
.floating-advisor {
    position: absolute;
    left: 0;
    top: 21.3%;
    width: 46%;
    z-index: 3;
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    isolation: isolate;
    filter: drop-shadow(3px 6px 8px #0007);
}

.floating-advisor img {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
    mask-image: linear-gradient(#000 89%, transparent 100%);
}

.advisor-halo {
    position: absolute;
    width: 96%;
    aspect-ratio: 1;
    top: -1%;
    left: 2%;
    background: url('kingdom-halo-v7.webp') center/contain no-repeat;
    z-index: 0;
    animation: halo-orbit 65s linear infinite;
}

.advisor-halo::before {
    content: '';
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    background: #0a121ab8;
}

.advisor-parchment {
    display: block;
    position: relative;
    z-index: 2;
    width: 106%;
    margin: -12% 0 0 0;
    padding: 18px 16px 18px 20px;
    background: url('kingdom-speech-v7.webp') center/100% 100% no-repeat;
    color: #312212;
    font: italic 14px/1.35 'EB Garamond', Georgia, serif;
    text-align: left;
    transform: rotate(-3deg);
    filter: drop-shadow(0 3px 4px #0005);
}

/* --------------------------------------------------------------------------
   Content Panel Container
   -------------------------------------------------------------------------- */
.kingdom-content {
    position: relative;
    z-index: 6;
    flex-shrink: 0;
    padding: 0 16px 12px;
    background: linear-gradient(180deg, transparent, #070d14 30%, #060b12 100%);
}

.today-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

/* --------------------------------------------------------------------------
   1. ORNATE DARK FILIGREE TASK CARD (100% Faithful to Mockup)
   -------------------------------------------------------------------------- */
.today-task-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 66px;
    padding: 10px 22px;
    background: linear-gradient(180deg, #1b2738 0%, #101926 50%, #080d15 100%);
    border: 1px solid #c29953;
    border-radius: 12px;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.85),
        inset 0 1px 1px rgba(255, 235, 175, 0.35),
        inset 0 0 18px rgba(0, 0, 0, 0.9);
}

.today-task-card::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(194, 153, 83, 0.38);
    border-radius: 9px;
    pointer-events: none;
}

/* Top & Bottom Fleur-de-lis Crests */
.card-crest {
    position: absolute;
    width: 36px;
    height: 18px;
    pointer-events: none;
    z-index: 3;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
}

.card-crest svg {
    width: 100%;
    height: 100%;
    display: block;
}

.crest-top {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.crest-bottom {
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
}

/* Left & Right Tapered Finials */
.card-finial {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 32px;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 3;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}

.card-finial svg {
    width: 100%;
    height: 100%;
    display: block;
}

.finial-left {
    left: -10px;
}

.finial-right {
    right: -10px;
}

.task-card-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.task-scroll-icon {
    flex-shrink: 0;
    width: 44px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-quill-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.today-task-card h2.task-title {
    margin: 0;
    font: 700 21px/1.2 'Playfair Display', Georgia, serif;
    color: #f6dfb2;
    text-align: center;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.95), 
        0 0 14px rgba(246, 223, 178, 0.35);
    letter-spacing: 0.4px;
}

/* --------------------------------------------------------------------------
   2. 3D SCULPTED ANTIQUE BRASS CTA BUTTON (100% Faithful to Mockup)
   -------------------------------------------------------------------------- */
.welcome-start.ornate-brass-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 6px 18px 6px 12px;
    border-radius: 32px;
    border: 2px solid #58370d;
    background: linear-gradient(180deg, 
        #fff7df 0%, 
        #fde29e 14%, 
        #ebb854 44%, 
        #cc8f2a 75%, 
        #976014 96%, 
        #6a3e0b 100%);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.85),
        0 2px 4px rgba(0, 0, 0, 0.6),
        0 0 22px rgba(235, 184, 84, 0.38),
        inset 0 2px 2px #ffffff,
        inset 0 -2.5px 3px rgba(50, 28, 4, 0.85);
    cursor: pointer;
    overflow: visible;
    transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.welcome-start.ornate-brass-btn:hover {
    filter: brightness(1.06);
    box-shadow: 
        0 10px 28px rgba(0, 0, 0, 0.9),
        0 0 30px rgba(235, 184, 84, 0.55),
        inset 0 2px 2px #ffffff;
}

.welcome-start.ornate-brass-btn:active {
    transform: scale(0.982) translateY(1px);
    box-shadow: 
        0 4px 14px rgba(0, 0, 0, 0.9),
        inset 0 1px 1px #ffffff,
        inset 0 -1.5px 2px rgba(50, 28, 4, 0.9);
    filter: brightness(0.96);
}

/* Metallic Winglets */
.btn-wing {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 38px;
    transform: translateY(-50%);
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}

.btn-wing svg {
    width: 100%;
    height: 100%;
    display: block;
}

.wing-left {
    left: -12px;
}

.wing-right {
    right: -12px;
}

/* Recessed Nautical Compass Medallion */
.btn-compass-box {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7));
}

.compass-rose-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Center Label Wrap */
.btn-label-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    font: 700 22px/1 'Playfair Display', Georgia, serif;
    color: #2a1705;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
    letter-spacing: 0.3px;
}

.btn-text-main {
    font-weight: 700;
}

.btn-dot {
    font-size: 18px;
    color: #4b2e0e;
    line-height: 1;
}

.btn-text-sub {
    font-weight: 700;
}

.btn-chevron {
    margin-left: auto;
    width: 12px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chevron-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* --------------------------------------------------------------------------
   3. ORNATE BOTTOM NAVIGATION BAR (100% Faithful to Mockup)
   -------------------------------------------------------------------------- */
.welcome-nav.ornate-nav-bar {
    position: relative;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    flex-shrink: 0;
    border-top: 1px solid rgba(214, 175, 95, 0.35);
    background: linear-gradient(180deg, #090e17 0%, #05080e 100%);
    padding: 8px 12px max(10px, env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.8);
}

.ornate-nav-bar .nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    border: 0;
    background: none;
    color: #7c8998;
    text-decoration: none;
    font: 500 13px/1 'Playfair Display', Georgia, serif;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.12s ease;
}

.ornate-nav-bar .nav-item:active {
    transform: scale(0.95);
}

.nav-icon-wrap {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.nav-sun-svg {
    width: 34px;
    height: 34px;
    display: block;
}

.nav-mountain-svg, .nav-sage-svg {
    width: 30px;
    height: 30px;
    display: block;
}

/* Active State: Hôm nay */
.ornate-nav-bar .nav-item.active {
    color: #fed464;
    text-shadow: 0 0 12px rgba(254, 212, 100, 0.6);
}

.ornate-nav-bar .nav-item.active .nav-icon-wrap {
    transform: scale(1.08);
}

.nav-item-glow {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(254, 212, 100, 0.35) 0%, transparent 70%);
    pointer-events: none;
}

.ornate-nav-bar .nav-item:hover {
    color: #d1dce7;
}

/* --------------------------------------------------------------------------
   Motion Controls, Star Twinkles, Atmosphere Shimmers
   -------------------------------------------------------------------------- */
.motion-toggle {
    position: absolute;
    right: 14px;
    top: 16px;
    z-index: 8;
    width: 35px;
    height: 35px;
    border: 1px solid #ba9c6066;
    border-radius: 50%;
    background: #0c1a29aa;
    color: #edcf91;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.scene-shimmer {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(ellipse, #ffe8b8aa, transparent 68%);
    mix-blend-mode: screen;
    animation: light-breathe var(--speed, 5s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

.scene-star {
    position: absolute;
    width: 1px;
    height: 1px;
    background: #fff4d5;
    box-shadow: 0 0 3px #fff4c9;
    animation: star-twinkle var(--speed, 4s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes light-breathe {
    0%, 100% { opacity: 0.08; }
    50%      { opacity: 0.48; }
}

@keyframes star-twinkle {
    0%, 100% { opacity: 0.12; }
    50%      { opacity: 0.85; }
}

@keyframes halo-orbit {
    to { transform: rotate(360deg); }
}

/* Respect Reduced Motion */
.motion-off *, .motion-off *::before, .motion-off *::after {
    animation-play-state: paused !important;
}

@media (prefers-reduced-motion: reduce) {
    .welcome-screen *, .welcome-screen *::before, .welcome-screen *::after {
        animation: none !important;
    }
}

.welcome-screen button:focus-visible, .welcome-screen a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* Modal Dialog */
#kingdom-dialog {
    margin: auto;
    width: min(88vw, 400px);
    padding: 36px 24px 24px;
    border: 1px solid #b69760;
    border-radius: 12px;
    background: #101e29;
    color: #f6e5c2;
    font-family: 'EB Garamond', Georgia, serif;
}

#kingdom-dialog::backdrop {
    background: #020811cc;
}

#kingdom-dialog h2 {
    font: 600 24px 'Playfair Display', Georgia, serif;
    margin: 0 0 20px;
    color: #f7dfaa;
}

#kingdom-dialog p {
    line-height: 1.6;
    margin: 0 0 24px;
    white-space: pre-line;
    font-size: 16px;
}

#kingdom-dialog .welcome-start {
    width: 100%;
    margin: 0;
}

.dialog-close {
    position: absolute;
    right: 10px;
    top: 8px;
    width: 36px;
    height: 36px;
    border: 0;
    background: none;
    color: #eedcb6;
    font-size: 26px;
    cursor: pointer;
}

@media (min-width: 600px) {
    .welcome-screen {
        max-width: min(520px, 58dvh);
    }
    .kingdom-map {
        flex-basis: 340px;
        min-height: 340px;
    }
    .kingdom-brand h1 {
        font-size: 19px;
    }
}

@media (max-width: 360px) {
    .kingdom-brand {
        left: 20px;
    }
    .kingdom-brand h1 {
        font-size: 19px;
    }
    .beacon {
        font-size: 13px;
    }
    .advisor-parchment {
        font-size: 13px;
    }
    .today-task-card h2.task-title {
        font-size: 18px;
    }
    .btn-label-wrap {
        font-size: 18px;
    }
}
