@font-face {
    font-family: "Apercu";
    src: url("font/apercu-medium-webfont.woff") format("woff");
    font-weight: medium;
    font-style: normal;
}

body {
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;      /* allow vertical scroll */
    /*background: #e4dfd7;*/
    font-family: "Apercu";
    perspective: 1200px;
    width: 100%;
    min-height: 100vh;     /* content can grow taller than viewport */
    position: relative;
}

h2{
    font-weight: 500;
    letter-spacing: 0.1em;
    font-size: .9em;
}
/* canvases */
/* canvases: sit at the top of the page, scroll with content */
#bgCanvas,
#fgCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;   /* one viewport tall “hero” */
    /*display: none!important;  /* hide canvases until JS enables them */
}

#bgCanvas {
    z-index: 0;
    pointer-events: none;
}

#fgCanvas {
    z-index: 101;      /* above iframe */
    pointer-events: none;
}

/* if you still have these child rules, keep them */
#bgCanvas canvas,
#fgCanvas canvas {
    width: 100%;
    height: 100%;
    display: block;
}


/* iframe wrapper in the middle – lifted a bit for balance */
#iframeWrapper {
    position: fixed;
    top: 54%;
    left: 50%;
    transform-style: preserve-3d;
    transform-origin: center center;
    z-index: 1;
    z-index: 100;
    overflow: visible;
}

/* Rotate the iframe content itself */
#liveFrame {
    position: absolute;
    top: 50%;
    left: 50%;
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transform-origin: center center;
    transform: translate(-50%, -50%) rotate(-90deg);
    width: 177%;
    height: 56%;
    display: none;      /* JS will enable it on non-iOS */
    pointer-events: none;
}

#liveFrameIos {
    position: absolute;
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transform-origin: center center;
    transform:  translate(calc(41vw - 50%),115px) rotate(-90deg);
    width: 533px;
    height: 300px;
    z-index: 1;         /* above bg spheres, below UI/overlay if needed */
    display: none;      /* JS will enable it on iOS */
    pointer-events: none;
}

/* overlay that blocks interaction and centers text */
#liveFrameOverlay {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    animation: bgColorCycleTransparent 12s linear infinite;
    z-index: 10;
    color: #e4dfd7;
    font-size: 14px;
    letter-spacing: 0.08em;
    padding: 48px;
    backdrop-filter: blur(5px);
}

#liveFrameOverlay p {
    width: 75%;
}


/* === UI overlay – on the right of frame (desktop), below on mobile === */

/* Desktop / default: position relative to viewport, right of center */
.ui {
    position: fixed;
    top: 46%;                         /* align vertically with frame (same as iframeWrapper top) */
    left: 50%;
    transform: translate(40%, -50%);
    z-index: 10;
}

.ui-blocker {
    position: absolute;
    inset: 0;
    background: rgb(228 223 215 / 12%);
    backdrop-filter: blur(1.5px);
    z-index: 50;
    pointer-events: auto;
    display: block;
    border-radius: 16px;
}


.ui .relative {
    padding: 14px 24px;
    border-radius: 16px;
    background: rgba(228, 223, 215, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

@media (max-width: 450px) {
    .ui {
        max-width: 90vw;
    }
    .ui button {
        padding: 10px 12px;
    }
}

.ui-title {
    font-size: 14px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.ui-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.ui button {
    padding: 10px 18px;
    border-radius: 3rem;
    border: none;
    background: #cebebe40;
    color: #000000;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
    border: 1px solid var(--c1);
    animation: borderColorCycle 12s linear infinite;
}

.ui button:active {
    transform: translateY(1px);
    box-shadow: 0 0 0 rgba(0,0,0,0);
}


@media (hover: hover) {
    .ui button:hover {
        animation: bgColorCycle 12s linear infinite;
    }
    
}


/* Debug log */
#debugLog {
    position: fixed;
    bottom: 10px;
    left: 10px;
    right: 10px;
    max-height: 35vh;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.75);
    color: #eee;
    font-family: monospace;
    font-size: 11px;
    line-height: 1.4;
    overflow-y: auto;
    z-index: 9999;
    border-radius: 6px;
    box-sizing: border-box;
}
#debugLog .log-entry {
    margin-bottom: 4px;
}
#debugLog .log-entry.log  { color: #c8e6ff; }
#debugLog .log-entry.warn { color: #ffe08a; }
#debugLog .log-entry.error{ color: #ff9a9a; }

/* Title attached to the top-left of the frame */
#sceneTitle {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-25%, -130%);
    margin: 0;
    padding: 0;
    font-family: "Apercu";
    font-size: clamp(24px, 3.2vw, 38px);
    line-height: 1.15;
    letter-spacing: 0.05em;
    text-transform: none;
    pointer-events: none;
    color: #807e7e;
    transition: all 1s ease;
}
#sceneTitle.Ios {
    transform: translate(-85%, -40%);
    border-radius: 19px;
    padding: 12px 24px;
    border: 1px solid #807e7e;
    background: color(srgb 0.795 0.7712 0.7433 / 0.29);
}


#sceneTitle span {
    color: var(--c1);
    animation: titleColorCycle 12s linear infinite;
    font-weight: bold;
}

#mobileBottomSpacer {
    width: 100%;
    height: 0;
}

#eventOverlay {
    position: fixed;
    inset: 0;
    display: none;                  /* hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 10000;                 /* above everything, even debugLog */
    pointer-events: auto;
}

.event-overlay-box {
    min-width: 220px;
    max-width: 80vw;
    padding: 18px 22px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    font-family: "Apercu", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #000;
    animation: bgColorCycleTransparent 12s linear infinite;
}


.event-overlay-text {
    font-size: 14px;
    line-height: 1.4;
    letter-spacing: 0.04em;
}

/* was input, now is a textarea for multi-line */
#LedText {
  width: 100%;
  min-height: 2.4em;   /* just a nice minimum */
  height: auto;
  resize: none;        /* user can't drag the corner */
  overflow: hidden;    /* no scrollbars, we grow instead */
  box-sizing: border-box;
      border-radius: 12px;
    padding: 8px 16px;
}


/* Slightly smaller on mobile */
@media (max-width: 768px) {
    .event-overlay-box {
        min-width: 0;
        width: 80vw;
        padding: 14px 18px;
    }
    
    .event-overlay-text {
        font-size: 13px;
    }
}


#logoOverlay {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 99999; /* above canvases, iframe, UI, overlay, debugLog */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px 6px 12px;
    border-radius: 999px;
    background: rgba(228, 223, 215, 0.96);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    text-decoration: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

#logoOverlay img {
    display: block;
    height: 36px;        /* tweak size */
    width: auto;
}

/* Optional: slight hover feedback on desktop */
@media (hover: hover) {
    #logoOverlay:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
    }
}


.safariHint {
    padding: 8px 10px;
    border-radius: 10px;
    color: #908778;
    font-family: "Apercu", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 9px;
    line-height: 1.4;
    letter-spacing: 0.03em;
    display: none; /* hidden by default */
    margin-top: 8px;
}


.safariHint.fixed {
    position: fixed;
    left: 14px;
    bottom: 8px;
    z-index: 9998;
    margin-top: 0px;
}

.safariHint.Ios {
    display: block; 
}

.safariHint.Ios.mobile {
    display: none; 
}


/* optional: a tiny tweak on mobile */
@media (max-width: 768px) {
    #safariHint {
        left: 10px;
        bottom: 10px;
        max-width: 80vw;
        font-size: 10px;
    }
}


:root {
    --c1: #db495d;
    --c2: #f4af79;
    --c3: #f6d385;
    --c4: #a0b49b;
    --c5: #467a95;
    --c6: #786180;
    --c7: #8d5575;
}

@keyframes titleColorCycle {
    0%   { color: var(--c1); }
    14%  { color: var(--c2); }
    28%  { color: var(--c3); }
    42%  { color: var(--c4); }
    57%  { color: var(--c5); }
    71%  { color: var(--c6); }
    85%  { color: var(--c7); }
    100% { color: var(--c1); }
}

@keyframes bgColorCycle {
    0%   { background: var(--c1); }
    14%  { background: var(--c2); }
    28%  { background: var(--c3); }
    42%  { background: var(--c4); }
    57%  { background: var(--c5); }
    71%  { background: var(--c6); }
    85%  { background: var(--c7); }
    100% { background: var(--c1); }
}

@keyframes borderColorCycle {
    0%   { border-color: var(--c1); }
    14%  { border-color: var(--c2); }
    28%  { border-color: var(--c3); }
    42%  { border-color: var(--c4); }
    57%  { border-color: var(--c5); }
    71%  { border-color: var(--c6); }
    85%  { border-color: var(--c7); }
    100% { border-color: var(--c1); }
}


:root {
    /* same colors, but as RGB triplets */
    --c1-rgb: 219, 73, 93;
    --c2-rgb: 244, 175, 121;
    --c3-rgb: 246, 211, 133;
    --c4-rgb: 160, 180, 155;
    --c5-rgb: 70, 122, 149;
    --c6-rgb: 120, 97, 128;
    --c7-rgb: 141, 85, 117;
    
    /* control opacity here */
    --bg-alpha: 0.75; /* 0 = fully transparent, 1 = solid */
}

@keyframes bgColorCycleTransparent {
    0%   { background: rgba(var(--c1-rgb), var(--bg-alpha)); }
    14%  { background: rgba(var(--c2-rgb), var(--bg-alpha)); }
    28%  { background: rgba(var(--c3-rgb), var(--bg-alpha)); }
    42%  { background: rgba(var(--c4-rgb), var(--bg-alpha)); }
    57%  { background: rgba(var(--c5-rgb), var(--bg-alpha)); }
    71%  { background: rgba(var(--c6-rgb), var(--bg-alpha)); }
    85%  { background: rgba(var(--c7-rgb), var(--bg-alpha)); }
    100% { background: rgba(var(--c1-rgb), var(--bg-alpha)); }
}

@media (max-width: 1150px) {
    
    /* allow vertical scroll and keep background */
    html, body {
        overflow-y: auto;
        height: auto;
        min-height: 100dvh;
    }
    
    /* frame sits near the top of the page, centered horizontally */
    #iframeWrapper {
        position: relative;        /* no longer fixed on mobile */
        margin-top: 24%;          /* distance from top */
        transform-origin: top center;
        z-index: 1;               /* redundant but explicit */
        
    }
    
    /* UI: absolute below the frame, can be wider than the frame */
    .ui {
        position: absolute;
        top: 96%;    
        left: 50%;
        transform: translateX(-50%);
        width: 90vw;               /* almost full viewport width */
        max-width: 600px;           /* don't limit to frame width */
        margin: 0;                 /* let top positioning handle spacing */
    }    
    
    .ui.Ios {
        top: 390px;    
    }
    
    .ui .relative {
        padding: 8px 12px;
    }
    .ui-buttons {
        flex-wrap: wrap;
    }
    
    /* title still attached to the frame, slightly adjusted for mobile */
    #sceneTitle {
        transform: translate(20%, -150%);
        font-size: clamp(20px, 4vw, 32px);
    }
    #sceneTitle.Ios {
        transform: translate(70%, -150%);
    }
    
    
    #mobileBottomSpacer {
        height: 84px;    /* or 10vh, or whatever bottom margin you like */
    }
    
    
    /* On mobile: avoid fixed canvases, kill perspective to avoid Safari bugs */
    body {
        perspective: none;         /* disable 3D context on mobile */
    }
    
    #bgCanvas,
    #fgCanvas {
        position: absolute;        /* no longer fixed on iOS mobile */
        inset: 0;
        top: -100px;
    }
    
    #bgCanvas {
        z-index: 0;                /* background */
    }
    
    #fgCanvas {
        z-index: 2;                /* still on top of iframe */
    }
    
    
    .safariHint.Ios {
        display: none; 
    }
    
    .safariHint.Ios.mobile {
        display: block; 
    }
    
    
    #liveFrameIos {
        transform:  translate(calc(50vw - 50%),115px) rotate(-90deg);
    }
    
}


@media (max-width: 600px) {
    
    #sceneTitle {
        transform: translate(20%, -150%);
    }
    #sceneTitle.Ios {
        transform: translate(-10vw, -100%);
        background: color(srgb 0.795 0.7712 0.7433 / 0.85);
    }
    
    #liveFrameOverlay {
        padding: 24px;
    }
    
    #liveFrameOverlay p {
        width: 100%;
    }
    
    
}