/* ====================================================================
   BASE STYLES
   ==================================================================== */

.hidden {
    display: none;
}

:root {
    /* ================================================================
       AUTOMATIC RESPONSIVE SCALING WITH BREAKPOINTS
       ================================================================
       The scale automatically adjusts based on screen width.
       Customize the breakpoints below to fit your devices.

       Current breakpoints:
       - Small (up to 1024px):     1.2x scale (mobile, tablets)
       - Medium (1025-1600px):     1.0x scale (laptops, small desktops)
       - Large (1601-2400px):      1.3x scale (large desktops)
       - Extra Large (2401-3200px): 1.6x scale (large monitors)
       - Huge (3201px+):           2.0x scale (4K TVs, huge screens)
       ================================================================ */
    --scale-multiplier: 0.6;  /* Default for mobile/small screens */
    --full-bell-max-width: 90vw;

    /* ================================================================
       ANIMATION TIMING CONFIGURATION
       ================================================================
       To adjust animation speed globally, modify these values.
       All durations are in seconds.

       To slow down by X%: multiply each value by (1 + X/100)
       To speed up by X%: multiply each value by (1 - X/100)

       Example: To slow down by 20%, multiply all values by 1.2
       ================================================================ */
    --timing-fragment-opacity: 0.36s;      /* Fragment fade in/out */
    --timing-fragment-fade-out: 0.36s;     /* Other fragments fading out */
    --timing-fragment-filter: 0.24s;       /* Fragment shadow/filter effects */
    --timing-fragment-size: 0.84s;         /* Fragment size changes */
    --timing-fragment-center: 0.72s;       /* Fragment moving to center */
    --timing-full-bell-fade: 0.48s;        /* Full bell fade in */
    --timing-text-overlay: 0.36s;          /* Text overlay fade */
    --timing-ui-hide: 0.36s;               /* UI elements hide on bell active */
    --timing-button-hover: 0.24s;          /* Button hover effects */
}

body {
    background-color: #EDEDE0;
    overflow: hidden;
}

/* Ensure title stays behind bells */
.c-title {
    z-index: 100 !important;
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* ====================================================================
   UI COMPONENTS
   ==================================================================== */

/* Instruction box */
.ui-instruction {
    border: 1px solid #000;
    background-color: #00ff00;
    color: #000;
    padding: 16px 40px 16px 16px;
    margin-top: 14px;
    position: relative;
    line-height: 1.5;
}

.ui-instruction[data-aos=fade-right] {
    opacity: 1;
    transform: scale(1.3) translate3d(-800px, 0, 0) !important;
    transition: all 4.5s cubic-bezier(0.6, 0, 0, 1) !important;
    transition-delay: 2.2s !important;
}

.ui-instruction[data-aos=fade-right].aos-animate {
    transform: scale(1) translate3d(0, 0, 0) !important;
}

.ui-instruction p {
    margin: 0;
    font-size: 13px;
}

.ui-instruction__close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    line-height: 1;
}

.ui-instruction__close:after {
    content: "\e812";
    position: relative;
    width: 20px;
    height: 20px;
    z-index: 10;
    display: inline-block;
    font-family: fontello;
    font-size: 20px;
    color: #000;
}

/* ====================================================================
   UNIFIED LAYOUT (Desktop & Mobile)
   ==================================================================== */

.c-canvas-half {
    position: relative;
    width: 100%;
    min-height: calc(100vh - 64px);
    z-index: 1;
}

body.bell-active .c-canvas-half {
    z-index: 10000;
}

#container-desktop {
    width: 100%;
    height: calc(100vh - 64px);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    --vertical-offset: 0px;
    margin-top: var(--vertical-offset);
}

/* Temporary template background - remove when done */
/* body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../img/template.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    z-index: 1;
    pointer-events: none;
    opacity: 0.5;
} */

.fragments-container {
    width: 100%;
    height: 100%;
    position: relative;
    --radius: calc(300px * var(--scale-multiplier));
}

/* Fragments - polar coordinate positioning */
.fragment {
    position: absolute;
    left: 50%;
    top: 50%;
    opacity: 1;
    z-index: 10;
    pointer-events: none;
    transition: opacity var(--timing-fragment-opacity) ease-in-out;
    --fragment-scale: var(--scale, 1);
    transform: translate3d(-50%, -50%, 0)
               translate(
                   calc(cos(var(--angle)) * var(--radius) * var(--distance)),
                   calc(sin(var(--angle)) * var(--radius) * var(--distance))
               );
    -webkit-transform: translate3d(-50%, -50%, 0)
                       translate(
                           calc(cos(var(--angle)) * var(--radius) * var(--distance)),
                           calc(sin(var(--angle)) * var(--radius) * var(--distance))
                       );
}

.fragment img {
    width: auto;
    height: calc(280px * var(--fragment-scale) * var(--scale-multiplier));
    max-width: calc(350px * var(--fragment-scale) * var(--scale-multiplier));
    object-fit: contain;
    display: block;
    filter: none;
    transition: filter var(--timing-fragment-filter) ease,
                height var(--timing-fragment-size) ease-in-out,
                max-width var(--timing-fragment-size) ease-in-out;
    pointer-events: none;
}

.fragment[data-has-full="true"] img {
    height: calc(500px * var(--fragment-scale) * var(--scale-multiplier));
    max-width: calc(600px * var(--fragment-scale) * var(--scale-multiplier));
}

/* Fragment hitbox */
.fragment-hitbox {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100px * var(--scale-multiplier));
    height: calc(100px * var(--scale-multiplier));
    pointer-events: auto;
    cursor: pointer;
    z-index: 100;
    transition: none;
}

.fragment-hitbox.debug {
    border: 2px solid red;
    background-color: rgba(255, 0, 0, 0.2);
}

.fragment-hitbox:hover~img {
    filter: none;
}

/* Fragment states */
.fragment.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--timing-fragment-fade-out) ease-in-out;
}

.fragment.active {
    position: absolute !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9998;
    transition: left var(--timing-fragment-center) cubic-bezier(0.4, 0, 0.2, 1),
                top var(--timing-fragment-center) cubic-bezier(0.4, 0, 0.2, 1),
                opacity var(--timing-fragment-opacity) ease-in-out;
    pointer-events: none;
}

.fragment.active.hide {
    opacity: 0;
}

.fragment.active img {
    width: auto;
    height: calc(700px * var(--scale-multiplier));
    max-height: 85vh;
    max-width: var(--full-bell-max-width);
    object-fit: contain;
    filter: none;
    transition: height var(--timing-fragment-center) cubic-bezier(0.4, 0, 0.2, 1),
                max-width var(--timing-fragment-center) cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================================================================
   OVERLAYS (SHARED)
   ==================================================================== */

/* Full bell container */
#full-bell-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity var(--timing-full-bell-fade) ease-in-out;
}

#full-bell-container.visible {
    opacity: 1;
    pointer-events: auto;
}

#full-bell-image {
    width: auto;
    height: calc(700px * var(--scale-multiplier));
    max-height: 85vh;
    max-width: var(--full-bell-max-width);
    object-fit: contain;
    display: block;
    filter: none;
    cursor: pointer;
}

#full-bell-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10001;
    transition: opacity var(--timing-button-hover) ease;
    padding: 0;
    line-height: 1;
}

#full-bell-close:hover {
    opacity: 0.7;
}

#full-bell-close:after {
    content: "\e812";
    font-family: fontello;
    font-size: 20px;
    color: #000;
    line-height: 1;
}

/* Bell text overlay */
#bell-text-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 401px;
    width: 90%;
    max-height: 80vh;
    background-color: #fff;
    border: 1px solid #000;
    padding: 40px 60px 40px 40px;
    opacity: 0;
    pointer-events: none;
    z-index: 10000;
    transition: opacity var(--timing-text-overlay) ease;
    overflow-y: auto;
}

#bell-text-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#bell-text-content h2 {
    font-size: 13px;
    font-weight: normal;
    margin: 0 0 20px 0;
    line-height: 1.3;
}

#bell-text-content p {
    font-size: 13px;
    line-height: 1.6;
    margin: 0 0 16px 0;
}

#bell-text-content p:last-child {
    margin-bottom: 0;
}

#bell-text-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10002;
    transition: opacity var(--timing-button-hover) ease;
    padding: 0;
    line-height: 1;
}

#bell-text-close:hover {
    opacity: 0.7;
}

#bell-text-close:after {
    content: "\e812";
    font-family: fontello;
    font-size: 20px;
    color: #000;
    line-height: 1;
}

/* Hide UI elements when bell is active */
body.bell-active .ui-meta,
body.bell-active .ui-instruction,
body.bell-active .ui-content,
body.bell-active .c-title {
    opacity: 0;
    transition: opacity var(--timing-ui-hide) ease;
}

/* ====================================================================
   RESPONSIVE BREAKPOINTS
   ==================================================================== */

@media (max-width: 768px) {
    /* Remove blank space above composition - center it properly */
    #container-desktop {
        --vertical-offset: -100px;
        margin-top: var(--vertical-offset);
    }

    /* Active fragments don't need counter-scaling anymore */
    .fragment.active {
        transform: translate(-50%, -50%) !important;
    }

    /* Anchor full bell to top on mobile to keep close button visible */
    #full-bell-container {
        position: fixed;
        top: 10vh;
        left: 50%;
        transform: translateX(-50%);
    }

    /* Increase font sizes and adjust widths for readability on mobile */
    .ui-instruction {
        max-width: 100%;
    }

    .ui-instruction p {
        font-size: 16px;
    }

    .ui-meta {
        max-width: 100%;
    }

    .ui-meta table {
        font-size: 16px;
    }

    .ui-content {
        max-width: 100%;
        font-size: 16px;
    }

    /* Bell text overlay - make it responsive on mobile */
    #bell-text-overlay {
        max-width: 90%;
        width: 90%;
        max-height: 75vh;
        padding: 30px 50px 30px 30px;
        position: fixed;
        top: 10vh;
        left: 50%;
        transform: translateX(-50%);
    }

    #bell-text-content h2 {
        font-size: 18px;
        margin-bottom: 20px;
    }

    #bell-text-content p {
        font-size: 16px;
        line-height: 1.6;
        margin-bottom: 16px;
    }

    #bell-text-close {
        top: 15px;
        right: 15px;
    }

    #bell-text-close:after {
        font-size: 20px;
    }

    /* Hide UI when bell is active */
    body.bell-active {
        overflow: hidden;
    }

    body.bell-active .ui-meta,
    body.bell-active .ui-instruction,
    body.bell-active .ui-content,
    body.bell-active .c-title {
        display: none;
    }
}

/* ====================================================================
   RESPONSIVE BREAKPOINTS - AUTOMATIC SCALING
   ==================================================================== */

/* Medium screens: laptops, small desktops (1025px - 1600px) */
@media (min-width: 1025px) {
    :root {
        --scale-multiplier: 1.0;
    }
}

/* Large screens: large desktops (1601px - 2400px) */
@media (min-width: 1601px) {
    :root {
        --scale-multiplier: 1.2;
    }
}

/* Extra Large screens: large monitors (2401px - 3200px) */
@media (min-width: 2401px) {
    :root {
        --scale-multiplier: 1.3;
    }
}

/* Huge screens: 4K TVs, very large monitors (3201px+) */
@media (min-width: 3201px) {
    :root {
        --scale-multiplier: 2.0;
    }
}
