/* ==========================================================================
   Interactive Reflection Experience
   Self-contained, additive styles. Inherits the site's theme CSS variables
   (--color-*, --border-radius) with graceful fallbacks. Scoped under
   .ire-section so nothing else on the site is affected.
   ========================================================================== */

.ire-section {
    position: relative;
    overflow: hidden;
    --ire-accent: var(--color-accent, #D4A03C);
    --ire-radius: calc(var(--border-radius, 0.875rem) + 0.35rem);
}

.ire-bg,
.ire-overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.ire-bg {
    background-size: cover;
    background-position: center;
}

/* Floating ambient light blobs -------------------------------------------- */
.ire-lights {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.ire-light {
    position: absolute;
    border-radius: 9999px;
    filter: blur(120px);
    opacity: 0.14;
    will-change: transform;
    animation: ireFloat 18s ease-in-out infinite;
}

.ire-light--a {
    width: 30rem;
    height: 30rem;
    top: -14rem;
    left: -14rem;
    background: radial-gradient(circle, color-mix(in srgb, var(--color-primary, #C45A36) 26%, transparent), transparent 72%);
}

.ire-light--b {
    width: 34rem;
    height: 34rem;
    bottom: -16rem;
    right: -14rem;
    background: radial-gradient(circle, color-mix(in srgb, var(--ire-accent) 24%, transparent), transparent 72%);
    animation-delay: -6s;
    animation-duration: 22s;
}

.ire-light--c {
    width: 20rem;
    height: 20rem;
    top: 45%;
    left: 55%;
    opacity: 0.1;
    background: radial-gradient(circle, color-mix(in srgb, var(--ire-accent) 18%, transparent), transparent 72%);
    animation-delay: -12s;
    animation-duration: 26s;
}

@keyframes ireFloat {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    33% { transform: translate3d(2.5rem, -1.75rem, 0) scale(1.08); }
    66% { transform: translate3d(-1.75rem, 1.5rem, 0) scale(0.96); }
}

.ire-inner {
    position: relative;
    z-index: 1;
}

/* Welcome-back banner ------------------------------------------------------ */
.ire-welcome {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    max-width: 40rem;
    margin: 0 auto 2.5rem;
    padding: 0.85rem 1.35rem;
    text-align: center;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: color-mix(in srgb, var(--color-surface, #151B2B) 70%, transparent);
    backdrop-filter: blur(10px);
    color: var(--color-text-secondary, #CBD5E1);
    font-size: 0.9rem;
    animation: ireFadeUp 0.7s ease both;
}

.ire-welcome.is-visible { display: flex; }

.ire-welcome__continue {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: var(--ire-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Sound / ambient controls ------------------------------------------------- */
.ire-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 2.5rem;
}

.ire-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text-secondary, #CBD5E1);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.ire-control:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--ire-accent) 55%, white);
    color: #fff;
}

.ire-control svg { width: 1.05rem; height: 1.05rem; }
.ire-control .ire-icon-off { display: none; }
.ire-control.is-muted .ire-icon-on { display: none; }
.ire-control.is-muted .ire-icon-off { display: inline; }

/* Piano (realistic) -------------------------------------------------------- */
.ire-stage { margin-top: 3rem; }
.ire-stage + .ire-stage { margin-top: 3.5rem; }

.ire-piano {
    position: relative;
    max-width: 46rem;
    margin: 0 auto;
    padding: 0.55rem 0.55rem 0.7rem;
    border-radius: 0.65rem;
    background: linear-gradient(180deg, #201f22 0%, #131215 60%, #0a090b 100%);
    border: 1px solid rgba(0, 0, 0, 0.7);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 28px 56px rgba(0, 0, 0, 0.5);
}

/* Felt / back rail above the keys */
.ire-piano-rail {
    height: 0.5rem;
    margin-bottom: 0.45rem;
    border-radius: 0.3rem;
    background: linear-gradient(180deg, color-mix(in srgb, var(--ire-accent) 45%, #2a1d17), #17110e);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) inset;
}

.ire-piano-keys {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    perspective: 1100px;
    border-radius: 0 0 0.4rem 0.4rem;
    overflow: hidden;
}

.ire-key-wrap {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
}

/* Shared key base ---------------------------------------------------------- */
.ire-key {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    cursor: pointer;
    border: none;
    transform-origin: top center;
    transition: transform 0.09s ease, box-shadow 0.16s ease, background 0.16s ease, filter 0.16s ease;
    overflow: hidden;
}

/* White keys --------------------------------------------------------------- */
.ire-key--white {
    height: 13.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    padding: 0 0.2rem 1.1rem;
    border-left: 1px solid rgba(0, 0, 0, 0.28);
    border-radius: 0 0 6px 6px;
    background: linear-gradient(180deg, #fdfdfa 0%, #ffffff 10%, #f4f4ee 82%, #e6e6dd 100%);
    color: #7b7b73;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset -2px 0 4px rgba(0, 0, 0, 0.12),
        inset 0 -10px 14px rgba(0, 0, 0, 0.1);
}

.ire-key-wrap:first-child .ire-key--white { border-left: none; }

.ire-key--white:hover {
    background: linear-gradient(180deg, #ffffff 0%, #ffffff 12%, #f7f7f1 82%, #eaeae1 100%);
}

/* Persistent "selected" colour strip at the base of a white key */
.ire-key--white::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--ire-emotion-color, var(--ire-accent));
    opacity: 0;
    transition: opacity 0.25s ease, box-shadow 0.25s ease;
}

.ire-key--white.is-active {
    background: linear-gradient(180deg, #ffffff 0%, #fbfbf6 14%, #f0f0e8 82%, #e2e2d8 100%);
}

.ire-key--white.is-active::after {
    opacity: 1;
    box-shadow: 0 0 16px var(--ire-emotion-color, var(--ire-accent));
}

/* Realistic depress */
.ire-key--white.is-pressed {
    transform: rotateX(9deg) translateY(2px);
    background: linear-gradient(180deg, #ededE5 0%, #f4f4ee 40%, #e8e8df 100%);
    box-shadow:
        inset 0 7px 14px rgba(0, 0, 0, 0.22),
        inset 0 -3px 6px rgba(0, 0, 0, 0.12);
    filter: brightness(0.99);
}

/* Non-text "today's reflection" indicator on a white key */
.ire-daily-dot {
    position: absolute;
    bottom: 0.7rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: var(--ire-emotion-color, var(--ire-accent));
    box-shadow: 0 0 10px var(--ire-emotion-color, var(--ire-accent));
    animation: ireGlowPulse 3.2s ease-in-out infinite;
}

/* Black keys (sharps) ------------------------------------------------------ */
.ire-key--black {
    position: absolute;
    top: 0;
    right: 0;
    width: 60%;
    height: 8.4rem;
    z-index: 3;
    transform: translateX(50%);
    border-radius: 0 0 4px 4px;
    background: linear-gradient(180deg, #565358 0%, #201f22 52%, #050506 100%);
    box-shadow:
        0 5px 7px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -5px 7px rgba(255, 255, 255, 0.06);
}

.ire-key--black::after {
    content: '';
    position: absolute;
    top: 0;
    left: 14%;
    right: 14%;
    height: 26%;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent);
}

.ire-key--black:hover {
    background: linear-gradient(180deg, #625f65 0%, #232225 52%, #070708 100%);
}

.ire-key--black.is-pressed {
    transform: translateX(50%) rotateX(13deg) translateY(1px);
    background: linear-gradient(180deg, #3a383c 0%, #141315 55%, #000 100%);
    box-shadow:
        0 2px 3px rgba(0, 0, 0, 0.7),
        inset 0 5px 9px rgba(0, 0, 0, 0.6);
}

/* Emotion cards ------------------------------------------------------------ */
.ire-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    max-width: 60rem;
    margin: 0 auto;
}

.ire-emotion-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.65rem;
    padding: 1.75rem 1.25rem;
    cursor: pointer;
    border-radius: var(--ire-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.08), transparent 55%),
        color-mix(in srgb, var(--color-surface, #151B2B) 55%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--color-text-primary, #F8FAFC);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s ease, box-shadow 0.4s ease;
}

.ire-emotion-card:hover {
    transform: translateY(-6px);
    border-color: color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 45%, transparent);
    box-shadow: 0 0 34px color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 24%, transparent), 0 22px 44px rgba(0, 0, 0, 0.32);
}

.ire-emotion-card.is-active {
    border-color: color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 60%, transparent);
    box-shadow: 0 0 40px color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 34%, transparent);
}

.ire-emotion-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 16%, transparent);
    color: var(--ire-emotion-color, var(--ire-accent));
}

.ire-emotion-card__icon svg { width: 1.6rem; height: 1.6rem; }

.ire-emotion-card__name {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Daily badge -------------------------------------------------------------- */
.ire-daily-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #0B0F19;
    background: var(--ire-emotion-color, var(--ire-accent));
    box-shadow: 0 0 18px color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 55%, transparent);
}

.ire-key .ire-daily-badge { top: 0.4rem; right: 0.4rem; padding: 0.15rem 0.4rem; }

/* Ripple ------------------------------------------------------------------- */
.ire-ripple {
    position: absolute;
    border-radius: 9999px;
    transform: translate(-50%, -50%) scale(0);
    background: radial-gradient(circle, color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 55%, transparent), transparent 70%);
    pointer-events: none;
    animation: ireRipple 0.7s ease-out forwards;
    z-index: 3;
}

@keyframes ireRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.55; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Reflection card ---------------------------------------------------------- */
.ire-reflection {
    max-width: 44rem;
    margin: 3rem auto 0;
    padding: 2.25rem 1.75rem;
    text-align: center;
    border-radius: var(--ire-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.06), transparent 50%),
        color-mix(in srgb, var(--color-surface, #151B2B) 88%, black);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 26px 54px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(18px) scale(0.98);
    transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    display: none;
}

.ire-reflection.is-visible {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ire-reflection__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.1rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 18%, transparent);
    color: var(--ire-emotion-color, var(--ire-accent));
    box-shadow: 0 0 30px color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 30%, transparent);
    animation: ireGlowPulse 3.2s ease-in-out infinite;
}

.ire-reflection__icon svg { width: 2rem; height: 2rem; }

@keyframes ireGlowPulse {
    0%, 100% { box-shadow: 0 0 26px color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 26%, transparent); }
    50% { box-shadow: 0 0 44px color-mix(in srgb, var(--ire-emotion-color, var(--ire-accent)) 48%, transparent); }
}

.ire-reflection__emotion {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
    color: var(--color-text-primary, #F8FAFC);
}

.ire-reflection__label {
    display: inline-block;
    margin-bottom: 1.1rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ire-emotion-color, var(--ire-accent));
}

.ire-reflection__text {
    font-size: clamp(1.05rem, 2.2vw, 1.3rem);
    line-height: 1.7;
    color: var(--color-text-secondary, #CBD5E1);
    white-space: pre-line;
}

.ire-reflection__quote {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin-top: 0;
    font-style: italic;
    color: var(--color-text-muted, #94A3B8);
    transition: max-height 0.6s ease, opacity 0.6s ease, margin-top 0.6s ease;
}

.ire-reflection__quote.is-open {
    max-height: 16rem;
    opacity: 1;
    margin-top: 1.35rem;
}

.ire-reflection__song {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--color-text-muted, #94A3B8);
}

.ire-reflection__song strong { color: var(--color-text-primary, #F8FAFC); font-weight: 600; }

.ire-reflection__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    margin-top: 1.75rem;
}

/* Reduced motion ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .ire-light,
    .ire-reflection__icon { animation: none; }
    .ire-emotion-card,
    .ire-reflection { transition: opacity 0.3s ease; }
    .ire-emotion-card:hover { transform: none; }
    .ire-key--white.is-pressed { transform: translateY(1px); }
    .ire-key--black.is-pressed { transform: translateX(50%) translateY(1px); }
    .ire-ripple { display: none; }
}

/* Responsive --------------------------------------------------------------- */
@media (min-width: 640px) {
    .ire-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
}

@media (min-width: 1024px) {
    .ire-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; }
}

@media (max-width: 640px) {
    .ire-piano { padding: 0.4rem 0.4rem 0.55rem; }
    .ire-key--white { height: 9.5rem; padding-bottom: 0.8rem; gap: 0.3rem; }
    .ire-key--white .ire-key__name { font-size: 0.72rem; }
    .ire-key--black { height: 5.8rem; }
    .ire-key__kbd { display: none; }
    .ire-reflection { padding: 1.75rem 1.25rem; }
}
