/* Galaxy Heart - cool, dreamy interface layered over the WebGL canvas */

:root {
    --space-0: #05080f;
    --space-1: #0d1a33;
    --space-2: #16284a;
    --galaxy:  #7aa8d4;
    --silver:  #c9d9ed;
    --blush:   #e6a8c4;
    --paper:   #f4f8ff;

    --edge: rgba(201, 217, 237, 0.22);
    --edge-lit: rgba(122, 168, 212, 0.75);
    --glass: rgba(9, 18, 36, 0.55);

    --gutter: clamp(16px, 4vw, 48px);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:
        radial-gradient(ellipse 120% 80% at 50% 45%, var(--space-1) 0%, var(--space-0) 62%, #01030a 100%);
    font-family: 'Montserrat', system-ui, sans-serif;
    color: var(--paper);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#container {
    position: absolute;
    inset: 0;
    z-index: 1;
}

#ui {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    padding:
        calc(var(--gutter) + env(safe-area-inset-top, 0px))
        var(--gutter)
        calc(var(--gutter) + env(safe-area-inset-bottom, 0px));
}

/* ==========================================
   HEADER
   ========================================== */

#topHeader {
    text-align: center;
}

#titleText {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.6rem, 5.2vw, 3.4rem);
    font-weight: 300;
    letter-spacing: clamp(3px, 1.1vw, 11px);
    line-height: 1.15;
    margin: 0 0 0.5em 0;
    color: var(--paper);
    /* Two soft halos rather than one hard one, so the glow reads as distance */
    text-shadow:
        0 0 18px rgba(122, 168, 212, 0.55),
        0 0 42px rgba(22, 40, 74, 0.8);
    opacity: 0;
    transform: translateY(-20px);
}

#subtitleText {
    font-size: clamp(0.76rem, 1.7vw, 1.02rem);
    font-weight: 300;
    letter-spacing: clamp(1px, 0.32vw, 2.4px);
    margin: 0;
    color: rgba(201, 217, 237, 0.78);
    text-shadow: 0 0 14px rgba(122, 168, 212, 0.35);
    opacity: 0;
    transform: translateY(-12px);
}

/* ==========================================
   FOOTER
   ========================================== */

#bottomContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#footerText {
    font-family: 'Great Vibes', cursive;
    font-size: clamp(1.5rem, 4.4vw, 2.7rem);
    font-weight: 400;
    line-height: 1.25;
    text-align: center;
    margin: 0 0 clamp(16px, 2.6vw, 30px) 0;
    color: var(--blush);
    text-shadow: 0 0 18px rgba(230, 168, 196, 0.45);
    opacity: 0;
    transform: translateY(20px);
    pointer-events: auto;
    transition: color 0.4s ease, text-shadow 0.4s ease;
}

#footerText:hover {
    color: var(--paper);
    text-shadow:
        0 0 22px rgba(230, 168, 196, 0.8),
        0 0 48px rgba(122, 168, 212, 0.5);
}

/* ==========================================
   CONTROLS
   ========================================== */

#controlPanel {
    display: flex;
    gap: clamp(8px, 1.2vw, 14px);
    justify-content: center;
    flex-wrap: wrap;
    opacity: 0;
    transform: translateY(20px);
}

.heart-btn {
    position: relative;
    pointer-events: auto;
    background: var(--glass);
    color: var(--silver);
    border: 1px solid var(--edge);
    padding: clamp(9px, 1.1vw, 13px) clamp(16px, 2vw, 28px);
    font-family: 'Montserrat', system-ui, sans-serif;
    font-size: clamp(0.72rem, 1.05vw, 0.86rem);
    font-weight: 500;
    letter-spacing: 1.2px;
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition:
        transform 0.32s cubic-bezier(0.22, 0.8, 0.3, 1),
        border-color 0.32s ease,
        color 0.32s ease,
        box-shadow 0.32s ease;
    box-shadow:
        0 6px 22px rgba(1, 3, 10, 0.55),
        inset 0 1px 0 rgba(201, 217, 237, 0.10);
}

/* A lit edge that fades in, instead of the whole button changing colour */
.heart-btn::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, var(--galaxy), transparent 45%, var(--blush));
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.32s ease;
    pointer-events: none;
}

.heart-btn:hover,
.heart-btn:focus-visible {
    color: var(--paper);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow:
        0 10px 30px rgba(1, 3, 10, 0.6),
        0 0 26px rgba(122, 168, 212, 0.35);
}

.heart-btn:hover::before,
.heart-btn:focus-visible::before {
    opacity: 1;
}

.heart-btn:focus-visible {
    outline: 2px solid var(--blush);
    outline-offset: 3px;
}

.heart-btn:active {
    transform: translateY(0);
}

.heart-btn.active {
    color: var(--paper);
    border-color: var(--edge-lit);
    box-shadow:
        0 6px 22px rgba(1, 3, 10, 0.55),
        0 0 24px rgba(122, 168, 212, 0.45);
}

.heart-btn.active::before {
    opacity: 0.7;
}

/* ==========================================
   FLOATING LOVE LINES
   ========================================== */

.love-popup {
    position: absolute;
    pointer-events: none;
    font-family: 'Great Vibes', cursive;
    font-size: clamp(1.5rem, 3.4vw, 2.5rem);
    color: var(--silver);
    text-shadow:
        0 0 18px rgba(122, 168, 212, 0.8),
        0 0 36px rgba(230, 168, 196, 0.45);
    transform: translate(-50%, -50%);
    white-space: nowrap;
    z-index: 999;
}

/* ==========================================
   FATAL ERROR
   ========================================== */

#fatalError {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    padding: var(--gutter);
    text-align: center;
    background: rgba(5, 8, 15, 0.92);
}

#fatalError h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    letter-spacing: 4px;
    margin: 0;
    color: var(--silver);
}

#fatalError p {
    margin: 0;
    max-width: 34ch;
    font-size: 0.92rem;
    font-weight: 300;
    line-height: 1.6;
    color: rgba(201, 217, 237, 0.75);
}

[hidden] {
    display: none !important;
}

/* ==========================================
   REDUCED MOTION
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    #titleText,
    #subtitleText,
    #footerText,
    #controlPanel {
        opacity: 1;
        transform: none;
    }

    .heart-btn,
    #footerText {
        transition: none;
    }

    .heart-btn:hover,
    .heart-btn:focus-visible {
        transform: none;
    }
}

/* ==========================================
   NARROW SCREENS
   ========================================== */

@media (max-width: 768px) {
    #controlPanel {
        gap: 8px;
    }

    .heart-btn {
        letter-spacing: 0.8px;
    }
}

@media (max-width: 420px) {
    #subtitleText {
        display: none; /* The title alone carries it at this width */
    }
}
