/* ── Background scene ──────────────────────────────────────────────────────
   Top-down view — you look straight down at the terrain.
   No sky. Each zone is a distinct ground texture.
   ──────────────────────────────────────────────────────────────────────── */

#background-scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: calc(100vh - 50px);
    overflow: hidden;
    z-index: 0;
}

/* ── Base terrain — always visible ──────────────────────────────────────── */
/* Five ground zones side by side, seen from above                          */

#background-base {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
    #6b6055 0%,        /* mines  — rocky grey-brown */
    #6b6055 20%,
    #3b5a2a 20%,       /* woodcutters — dark forest floor */
    #3b5a2a 40%,
    #7a6440 40%,       /* village — dirt paths, tan earth */
    #7a6440 60%,
    #5a3d1a 60%,       /* farms — dark tilled soil */
    #5a3d1a 80%,
    #4a7a2a 80%,       /* pastures — grass green */
    #4a7a2a 100%
    );
    z-index: 0;
}

/* Zone border lines — subtle separators between terrain types */
#background-base::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
            linear-gradient(90deg,
            transparent 19.8%, rgba(0,0,0,0.25) 19.8%, rgba(0,0,0,0.25) 20.2%, transparent 20.2%,
            transparent 39.8%, rgba(0,0,0,0.25) 39.8%, rgba(0,0,0,0.25) 40.2%, transparent 40.2%,
            transparent 59.8%, rgba(0,0,0,0.25) 59.8%, rgba(0,0,0,0.25) 60.2%, transparent 60.2%,
            transparent 79.8%, rgba(0,0,0,0.25) 79.8%, rgba(0,0,0,0.25) 80.2%, transparent 80.2%
            );
}

/* Terrain texture overlay — subtle noise feel via repeating pattern */
#background-base::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
            radial-gradient(circle, rgba(0,0,0,0.06) 1px, transparent 1px);
    background-size: 12px 12px;
}

/* ── Always-visible terrain details ─────────────────────────────────────── */

/* Rocky outcrops in mine zone */
#background-rocks {
    position: absolute;
    top: 0; left: 0;
    width: 20%;
    height: 100%;
    background:
            radial-gradient(ellipse 30px 20px at 20% 30%, #4a4035 80%, transparent 81%),
            radial-gradient(ellipse 20px 14px at 60% 60%, #4a4035 80%, transparent 81%),
            radial-gradient(ellipse 24px 16px at 80% 20%, #4a4035 80%, transparent 81%),
            radial-gradient(ellipse 18px 12px at 40% 80%, #4a4035 80%, transparent 81%);
    pointer-events: none;
    z-index: 1;
}

/* Tree canopies in woodcutter zone — top-down trees look like circles */
#background-trees {
    position: absolute;
    top: 0; left: 20%;
    width: 20%;
    height: 100%;
    background:
            radial-gradient(circle 22px at 15% 15%, #2a5010 80%, transparent 81%),
            radial-gradient(circle 18px at 35% 40%, #1e4008 80%, transparent 81%),
            radial-gradient(circle 24px at 55% 10%, #2a5010 80%, transparent 81%),
            radial-gradient(circle 20px at 75% 55%, #1e4008 80%, transparent 81%),
            radial-gradient(circle 16px at 20% 70%, #2a5010 80%, transparent 81%),
            radial-gradient(circle 22px at 85% 80%, #1e4008 80%, transparent 81%),
            radial-gradient(circle 18px at 45% 85%, #2a5010 80%, transparent 81%),
            radial-gradient(circle 20px at 65% 30%, #1e4008 80%, transparent 81%),
            radial-gradient(circle 14px at 10% 45%, #2a5010 80%, transparent 81%),
            radial-gradient(circle 22px at 90% 20%, #1e4008 80%, transparent 81%);
    pointer-events: none;
    z-index: 1;
}

/* Dirt path crossing the village zone */
#background-path {
    position: absolute;
    top: 0; left: 40%;
    width: 20%;
    height: 100%;
    background:
        /* Horizontal path */
            linear-gradient(180deg,
            transparent 45%,
            #8a7050 45%, #8a7050 55%,
            transparent 55%
            ),
                /* Vertical path */
            linear-gradient(90deg,
            transparent 45%,
            #8a7050 45%, #8a7050 55%,
            transparent 55%
            );
    pointer-events: none;
    z-index: 1;
}

/* Tilled soil rows in farm zone */
#background-soil {
    position: absolute;
    top: 0; left: 60%;
    width: 20%;
    height: 100%;
    background: repeating-linear-gradient(
            180deg,
            #5a3d1a 0px,
            #5a3d1a 8px,
            #6b4a22 8px,
            #6b4a22 16px
    );
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

/* Grass tufts in pasture zone */
#background-grass {
    position: absolute;
    top: 0; left: 80%;
    width: 20%;
    height: 100%;
    background:
            radial-gradient(ellipse 8px 12px at 10% 20%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 6px 10px at 30% 50%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 8px 12px at 50% 15%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 6px 10px at 70% 70%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 8px 12px at 90% 35%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 6px 10px at 20% 85%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 8px 12px at 60% 90%, #3a6a18 80%, transparent 81%),
            radial-gradient(ellipse 6px 10px at 80% 10%, #3a6a18 80%, transparent 81%);
    pointer-events: none;
    z-index: 1;
}

/* ── Layer container ─────────────────────────────────────────────────────── */

#background-layers {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ── Individual layers ───────────────────────────────────────────────────── */

.background-layer {
    position: absolute;
    top: 0;
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
}

.background-layer.background-layer-visible {
    opacity: 1;
}

/* ── Zone positioning ────────────────────────────────────────────────────── */

.background-zone-mines       { left: 0;   width: 20%; height: 100%; }
.background-zone-woodcutters { left: 20%; width: 20%; height: 100%; }
.background-zone-village     { left: 40%; width: 20%; height: 100%; }
.background-zone-farms       { left: 60%; width: 20%; height: 100%; }
.background-zone-pastures    { left: 80%; width: 20%; height: 100%; }

/* ── Placeholder styles ──────────────────────────────────────────────────── */

.background-placeholder {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
    border: 1px dashed rgba(255,255,255,0.2);
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
    padding: 4px;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    z-index: 2;
}

.background-zone-mines       .background-placeholder { background: rgba(60, 45, 30, 0.6); }
.background-zone-woodcutters .background-placeholder { background: rgba(30, 60, 20, 0.6); }
.background-zone-village     .background-placeholder { background: rgba(80, 65, 35, 0.6); }
.background-zone-farms       .background-placeholder { background: rgba(50, 30, 10, 0.6); }
.background-zone-pastures    .background-placeholder { background: rgba(30, 80, 20, 0.6); }

/* ── Placeholder sizes — staggered so layers don't stack identically ─────── */
/* In top-down, layers expand outward from the zone center as count grows    */

#village_01_campfire  { top: 40%; height: 20%; }
#village_02_huts      { top: 30%; height: 40%; }
#village_03_well      { top: 20%; height: 60%; }
#village_04_stone     { top: 10%; height: 80%; }
#village_05_longhouse { top: 5%;  height: 90%; }
#village_06_banner    { top: 50%;  height: 90%; }

#farm_01_field        { top: 35%; height: 30%; }
#farm_02_fields       { top: 25%; height: 50%; }
#farm_03_network      { top: 10%; height: 70%; }
#farm_04_plantation   { top: 55%;  height: 90%; }
#farm_05_irrigation   { top: 45%;  height: 90%; }
#farm_06_rotation     { top: 65%; height: 80%; }
#farm_07_alchsoil     { top: 75%; height: 70%; }

#pasture_01_cows      { top: 35%; height: 30%; }
#pasture_02_barn      { top: 25%; height: 50%; }
#pasture_03_herd      { top: 15%; height: 80%; }
#pasture_04_largebarn { top: 5%;  height: 90%; }
#pasture_05_sheep     { top: 45%; height: 80%; }
#pasture_06_breed     { top: 55%; height: 70%; }
#pasture_07_magicmilk { top: 65%; height: 60%; }

#mine_01_entrance     { top: 40%; height: 25%; }
#mine_02_tracks       { top: 30%; height: 45%; }
#mine_03_shafts       { top: 15%; height: 70%; }
#mine_04_excavation   { top: 5%;  height: 90%; }
#mine_05_picks        { top: 50%; height: 80%; }
#mine_06_explosives   { top: 55%; height: 70%; }
#mine_07_mithrilglow  { top: 35%; height: 60%; }
#mine_08_mithrilcart  { top: 45%; height: 50%; }

#wood_01_hut          { top: 35%; height: 30%; }
#wood_02_logpile      { top: 25%; height: 50%; }
#wood_03_yard         { top: 15%; height: 70%; }
#wood_04_clearing     { top: 5%;  height: 90%; }
#wood_05_axes         { top: 10%; height: 80%; }
#wood_06_mill         { top: 20%; height: 70%; }
#wood_07_enchant      { top: 30%; height: 60%; }