/* The Highlands - Misty Moors Interface */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Pixel Art Rendering */
* {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* CSS Variables - Misty Moor Palette */
:root {
    --moor-night: #232b36;
    --moor-dusk: #2e3845;
    --moor-grass: #3a4a38;
    --stone-dark: #363c45;
    --stone-grey: #8a909a;
    --accent-heather: #a984c9;
    --text-light: #e9ecf0;
    --mist-pale: #d7e0ea;
    --bothy-gold: #e8c372;
    /* Picked up by the shared map overlay so the close button matches this site. */
    --map-accent: var(--accent-heather);
    --map-accent-glow: rgba(169, 132, 201, 0.45);
}

body {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    background: var(--moor-night);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    color: var(--text-light);
}

/* Moor Canvas Container */
.scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        linear-gradient(to bottom,
            var(--moor-night) 0%,
            var(--moor-dusk) 55%,
            var(--moor-grass) 100%
        );
    overflow: hidden;
    cursor: default;
}

/* Low moor grass texture along the bottom */
.scene-container::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background:
        repeating-linear-gradient(
            0deg,
            var(--moor-grass) 0px,
            #45573f 2px,
            var(--moor-grass) 4px
        );
    animation: grassBreath 5s infinite ease-in-out;
    opacity: 0.5;
}

@keyframes grassBreath {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50%      { transform: translateY(-2px); opacity: 0.6; }
}

/* Distant ridgelines */
.moor-ridges {
    position: absolute;
    bottom: 18%;
    left: 0;
    width: 100%;
    height: 45%;
    z-index: 2;
    pointer-events: none;
}

/* The ruin on the hill — in memory of the first Highlands */
.highlands-ruin {
    position: absolute;
    right: 8%;
    top: 22%;
    width: 180px;
    height: auto;
    z-index: 5;
    opacity: 0.85;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}

.ruin-ember {
    animation: ruinEmber 4s infinite ease-in-out;
}

@keyframes ruinEmber {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 1; }
}

/* The bothy — lit windows, drifting peat smoke */
.moor-bothy {
    position: absolute;
    left: 7%;
    top: 30%;
    width: 130px;
    height: auto;
    z-index: 5;
    opacity: 0.9;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}

.bothy-smoke {
    transform-origin: 67px 18px;
    transform-box: fill-box;
    animation: bothySmoke 8s infinite ease-in-out;
}

@keyframes bothySmoke {
    0%, 100% { opacity: 0.5; transform: translateY(0); }
    50%      { opacity: 0.2; transform: translate(3px, -7px); }
}

/* Interactive Standing Stones */
.standing-stone {
    position: absolute;
    width: 34px;
    height: 72px;
    background: linear-gradient(170deg, var(--stone-grey) 0%, #5d6470 60%, var(--stone-dark) 100%);
    border-radius: 14px 10px 5px 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow:
        0 0 0 2px var(--stone-dark),
        inset 0 -12px 0 rgba(0, 0, 0, 0.25);
    z-index: 10;
}

.standing-stone.tall {
    width: 30px;
    height: 94px;
    border-radius: 12px 16px 5px 5px;
}

/* Carved spiral, revealed when the stone wakes */
.standing-stone::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-heather);
    border-radius: 50%;
    border-top-color: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.standing-stone:hover {
    transform: scale(1.06);
    box-shadow:
        0 0 0 3px var(--accent-heather),
        inset 0 -12px 0 rgba(0, 0, 0, 0.25),
        0 0 20px rgba(169, 132, 201, 0.5);
}

.standing-stone:hover::before {
    opacity: 0.5;
}

.standing-stone.active {
    box-shadow:
        0 0 0 4px var(--accent-heather),
        inset 0 -12px 0 rgba(0, 0, 0, 0.25),
        0 0 30px rgba(169, 132, 201, 0.8);
    animation: stonePulse 2s infinite;
}

.standing-stone.active::before {
    opacity: 1;
    filter: drop-shadow(0 0 6px var(--accent-heather));
}

@keyframes stonePulse {
    0%, 100% {
        box-shadow:
            0 0 0 4px var(--accent-heather),
            inset 0 -12px 0 rgba(0, 0, 0, 0.25),
            0 0 30px rgba(169, 132, 201, 0.8);
    }
    50% {
        box-shadow:
            0 0 0 6px var(--accent-heather),
            inset 0 -12px 0 rgba(0, 0, 0, 0.25),
            0 0 40px rgba(169, 132, 201, 1);
    }
}

/* Radio Element - a peat-dark wireless set on the moor */
.radio-element {
    position: absolute;
    width: 100px;
    height: 80px;
    background: var(--stone-dark);
    border: 3px solid var(--moor-night);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    animation: radioIdle 6s infinite ease-in-out;
}

.radio-element::before {
    content: '';
    position: absolute;
    top: 50%;
    left: calc(50% + 3px);
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent var(--accent-heather);
    filter: drop-shadow(0 0 10px var(--accent-heather));
    transition: all 0.3s ease;
}

.radio-element::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.radio-element.playing::before {
    content: '';
    left: 50%;
    width: 6px;
    height: 22px;
    border-style: solid;
    border-width: 0 6px 0 6px;
    border-color: transparent var(--accent-heather) transparent var(--accent-heather);
    filter: drop-shadow(0 0 10px var(--accent-heather));
}

.radio-element.playing {
    animation: radioPlaying 2s infinite ease-in-out;
    border-color: var(--accent-heather);
}

@keyframes radioIdle {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.02); }
}

@keyframes radioPlaying {
    0%, 100% {
        box-shadow:
            0 4px 0 rgba(0, 0, 0, 0.3),
            inset 0 2px 0 rgba(255, 255, 255, 0.1),
            0 0 20px rgba(169, 132, 201, 0.5);
    }
    50% {
        box-shadow:
            0 4px 0 rgba(0, 0, 0, 0.3),
            inset 0 2px 0 rgba(255, 255, 255, 0.1),
            0 0 30px rgba(169, 132, 201, 0.8);
    }
}

.radio-element:hover {
    transform: translate(-50%, -50%) scale(1.05);
    border-color: var(--accent-heather);
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        0 0 20px rgba(169, 132, 201, 0.5);
}

.radio-element:active {
    transform: translate(-50%, -50%) scale(0.95);
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

/* Pixel Art Text */
.pixel-text {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
    text-shadow:
        2px 2px 0 var(--moor-night),
        0 0 10px rgba(215, 224, 234, 0.3);
    image-rendering: pixelated;
}

/* Song Title Display */
.song-display {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: rgba(35, 43, 54, 0.9);
    border: 2px solid var(--accent-heather);
    border-radius: 4px;
    z-index: 30;
    min-width: 200px;
    max-width: 80%;
    text-align: center;
    box-shadow:
        0 0 0 1px var(--moor-night),
        0 4px 0 rgba(0, 0, 0, 0.3),
        0 0 15px rgba(169, 132, 201, 0.3);
    transition: all 0.3s ease;
    user-select: none;
}

.song-display:hover {
    transform: translateX(-50%) translateY(-5px);
    box-shadow:
        0 0 0 1px var(--moor-night),
        0 6px 0 rgba(0, 0, 0, 0.3),
        0 0 25px rgba(169, 132, 201, 0.5);
}

.song-display:active {
    transform: translateX(-50%) translateY(-3px);
}

.song-display.generating {
    animation: generatingPulse 2s infinite;
    border-color: var(--bothy-gold);
}

@keyframes generatingPulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px var(--moor-night),
            0 4px 0 rgba(0, 0, 0, 0.3),
            0 0 15px rgba(232, 195, 114, 0.4);
    }
    50% {
        box-shadow:
            0 0 0 1px var(--moor-night),
            0 4px 0 rgba(0, 0, 0, 0.3),
            0 0 25px rgba(232, 195, 114, 0.8);
    }
}

.song-display .pixel-text {
    font-size: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    display: block;
}

/* Startup Overlay */
.startup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(35, 43, 54, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease-out;
}

.startup-message {
    text-align: center;
    padding: 30px 40px;
    background: rgba(46, 56, 69, 0.9);
    border: 3px solid var(--accent-heather);
    border-radius: 8px;
    box-shadow:
        0 0 0 2px var(--moor-night),
        0 8px 0 rgba(0, 0, 0, 0.4),
        0 0 30px rgba(169, 132, 201, 0.6);
}

.startup-message .pixel-text {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--accent-heather);
    text-shadow:
        2px 2px 0 var(--moor-night),
        0 0 15px rgba(169, 132, 201, 0.8);
}

.startup-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 24px;
    color: var(--accent-heather);
}

.startup-dots span {
    animation: startupDotPulse 1.4s infinite;
    animation-delay: calc(var(--dot-index, 0) * 0.2s);
}

.startup-dots span:nth-child(1) { --dot-index: 0; }
.startup-dots span:nth-child(2) { --dot-index: 1; }
.startup-dots span:nth-child(3) { --dot-index: 2; }

@keyframes startupDotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50%      { opacity: 1; transform: scale(1.2); }
}

/* Status Indicator */
.status-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 6px 12px;
    background: rgba(35, 43, 54, 0.8);
    border: 2px solid var(--accent-heather);
    border-radius: 4px;
    z-index: 30;
    box-shadow:
        0 0 0 1px var(--moor-night),
        0 2px 0 rgba(0, 0, 0, 0.3);
}

.status-indicator.online {
    border-color: var(--accent-heather);
    animation: statusPulse 2s infinite;
}

.status-indicator.offline {
    border-color: #ff4444;
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px var(--moor-night),
            0 2px 0 rgba(0, 0, 0, 0.3),
            0 0 10px rgba(169, 132, 201, 0.5);
    }
    50% {
        box-shadow:
            0 0 0 1px var(--moor-night),
            0 2px 0 rgba(0, 0, 0, 0.3),
            0 0 20px rgba(169, 132, 201, 0.8);
    }
}

/* Sheep - woolly moor residents */
.moor-sheep {
    position: absolute;
    width: 44px;
    height: 32px;
    background: var(--mist-pale);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 15;
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.3),
        inset 0 -5px 0 rgba(0, 0, 0, 0.12);
    animation: sheepGraze 6s infinite ease-in-out;
}

.moor-sheep.small {
    width: 32px;
    height: 24px;
}

/* The head */
.moor-sheep::before {
    content: '';
    position: absolute;
    top: 38%;
    left: -10px;
    width: 16px;
    height: 13px;
    background: var(--stone-dark);
    border-radius: 6px;
    animation: sheepNibble 6s infinite ease-in-out;
}

/* Little legs */
.moor-sheep::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 8px;
    width: 5px;
    height: 7px;
    background: var(--stone-dark);
    box-shadow: 18px 0 0 var(--stone-dark);
}

@keyframes sheepGraze {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
}

@keyframes sheepNibble {
    0%, 70%, 100% { transform: translateY(0); }
    80%, 90%      { transform: translateY(4px); }
}

.moor-sheep:hover {
    transform: scale(1.15) translateY(-4px);
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.3),
        inset 0 -5px 0 rgba(0, 0, 0, 0.12),
        0 0 15px rgba(215, 224, 234, 0.6);
}

/* Fallen ruin stones, half-sunk in the heather */
.ruin-stone {
    position: absolute;
    width: 90px;
    height: 34px;
    background: linear-gradient(160deg, #5d6470, var(--stone-dark));
    border-radius: 8px 14px 6px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 12;
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Moss creeping over the old stone */
.ruin-stone::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 12px;
    width: 26px;
    height: 10px;
    background: var(--moor-grass);
    border-radius: 50%;
    opacity: 0.8;
}

.ruin-stone::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 14px;
    width: 10px;
    height: 10px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
}

.ruin-stone:hover {
    transform: translateY(-3px);
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 12px rgba(138, 144, 154, 0.5);
}

/* Heather tufts */
.heather-tuft {
    position: absolute;
    width: 26px;
    height: 44px;
    background: linear-gradient(to top, var(--moor-grass) 30%, var(--accent-heather) 100%);
    border-radius: 12px 12px 4px 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 11;
    opacity: 0.85;
    animation: heatherSway 4s infinite ease-in-out;
}

@keyframes heatherSway {
    0%, 100% { transform: rotate(-2deg); }
    50%      { transform: rotate(2deg); }
}

.heather-tuft:hover {
    transform: scale(1.1);
    animation: heatherSway 1.2s infinite ease-in-out;
    opacity: 1;
}

/* Ripple Effect on Click */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(169, 132, 201, 0.3);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
    z-index: 100;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* The mist — drifting banks over the whole moor, in front of the scenery
   but behind the radio UI (z-index between decorations ~5-15 and UI 20+). */
.mist-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 18;
    overflow: hidden;
}

.mist-layer {
    position: absolute;
    top: 0;
    left: -50%;
    width: 200%;
    height: 100%;
}

.mist-a {
    background:
        radial-gradient(ellipse 48% 16% at 28% 38%, rgba(215, 224, 234, 0.14), transparent 70%),
        radial-gradient(ellipse 55% 14% at 70% 62%, rgba(215, 224, 234, 0.12), transparent 70%),
        radial-gradient(ellipse 40% 12% at 50% 82%, rgba(215, 224, 234, 0.10), transparent 70%);
    animation: mistDrift 48s linear infinite;
}

.mist-b {
    background:
        radial-gradient(ellipse 50% 13% at 60% 28%, rgba(215, 224, 234, 0.10), transparent 70%),
        radial-gradient(ellipse 45% 15% at 35% 70%, rgba(215, 224, 234, 0.12), transparent 70%);
    animation: mistDrift 70s linear infinite reverse;
}

@keyframes mistDrift {
    from { transform: translateX(-12%); }
    to   { transform: translateX(12%); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .moor-sheep,
    .ruin-stone {
        display: none;
    }

    .standing-stone {
        width: 24px;
        height: 50px;
    }

    .standing-stone.tall {
        width: 22px;
        height: 64px;
    }

    .heather-tuft {
        height: 30px;
    }

    .highlands-ruin {
        width: 120px;
        right: 5%;
        top: 16%;
    }

    .moor-bothy {
        width: 90px;
        left: 5%;
        top: 24%;
    }

    .radio-element {
        width: 100px;
        height: 80px;
    }

    .song-display {
        bottom: max(100px, env(safe-area-inset-bottom) + 85px);
        padding: 10px 16px;
        min-width: 150px;
        max-width: 90%;
    }

    .pixel-text {
        font-size: 12px;
    }

    .status-indicator {
        top: max(15px, env(safe-area-inset-top) + 10px);
        right: 15px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Faint grid over the moor */
.moor-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(215, 224, 234, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(215, 224, 234, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.3;
}

/* ============================================================
   Map button — top-left floating link to the world map
   ============================================================ */
.map-button {
    position: absolute;
    top: max(20px, env(safe-area-inset-top) + 12px);
    left: 20px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 12px;
    background: var(--stone-dark);
    color: var(--accent-heather);
    border: 3px solid var(--moor-night);
    border-radius: 8px;
    box-shadow:
        0 4px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-decoration: none;
    z-index: 30;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.map-button:hover {
    transform: translateY(-3px);
    border-color: var(--accent-heather);
    box-shadow:
        0 7px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        0 0 20px rgba(169, 132, 201, 0.5);
}

.map-button:active {
    transform: translateY(-1px);
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

.map-button:focus-visible {
    outline: 2px solid var(--text-light);
    outline-offset: 3px;
}

.map-button-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    animation: mapNeedleBob 4s ease-in-out infinite;
    transform-origin: center;
}

@keyframes mapNeedleBob {
    0%, 100% { transform: rotate(-4deg); }
    50%      { transform: rotate(4deg); }
}

.map-button-label {
    line-height: 1;
}

@media (max-width: 600px) {
    .map-button {
        padding: 6px 10px 6px 8px;
        font-size: 10px;
        letter-spacing: 0.16em;
    }
    .map-button-icon { width: 18px; height: 18px; }
}

/* ============================================================
   News button palette — matches the map button.
   Structure + layout live in templates/_news_overlay.html.
   ============================================================ */
.news-button {
    --news-btn-bg: var(--stone-dark);
    --news-btn-fg: var(--accent-heather);
    --news-btn-border: var(--moor-night);
    --news-btn-glow: rgba(169, 132, 201, 0.5);
    --news-btn-dot: var(--accent-heather);
    --news-btn-focus: var(--text-light);
}

/* Volume control palette. Structure lives in templates/_volume_control.html. */
.volume-control {
    --vol-bg: var(--stone-dark);
    --vol-fg: var(--accent-heather);
    --vol-border: var(--moor-night);
    --vol-track: var(--moor-night);
    --vol-fill: var(--accent-heather);
    --vol-focus: var(--text-light);
}
