/* SPDX-License-Identifier: Apache-2.0 */
/* A phone on the page: a display of an iPhone's proportions (390 by 844 points) in a thin bezel, centred; on a
   small screen the display is the whole window. Home is drawn by home.js; what is here is the frame, the card an
   app runs in, the alert and the status toast. */
:root {
    color-scheme: dark;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: radial-gradient(ellipse at 50% 30%, #1b2030, #08090c 70%) fixed;
    color: #f4f7fb;
    --display-height: min(100dvh - 3rem, 860px);
    --display-width: calc(var(--display-height) * 390 / 844);
    --bezel: 11px;
}
html, body { height: 100%; }
body {
    margin: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
#device {
    position: relative;
    width: var(--display-width);
    height: var(--display-height);
    border-radius: calc(var(--display-width) * 0.1205 + var(--bezel));
    border: var(--bezel) solid #050506;
    box-shadow: 0 0 0 1.5px #3a3d46, 0 0 0 3px #15171c, 0 2.5rem 5rem #000a;
    overflow: hidden;
    background: #000;
    isolation: isolate;
    user-select: none;
    -webkit-user-select: none;
    --display-corner: 47; /* points: the card's corners when it is the whole display */
}
#device > * { border-radius: calc(var(--display-width) * 0.1205); }
@media (max-width: 520px), (max-height: 560px) {
    #device {
        width: 100vw;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        --display-corner: 0;
    }
    #device > * { border-radius: 0; }
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid #9bd2ff; outline-offset: 3px; }

/* Home. */
#launcher {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
    outline: none;
}
#home-layers, #home-layers canvas, #home-dim { position: absolute; inset: 0; width: 100%; height: 100%; }
#home-dim { background: #000; opacity: 0; pointer-events: none; }
#installed {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: clip;
    pointer-events: none;
}
.app {
    position: absolute;
    padding: 0;
    border: 0;
    border-radius: 22%;
    background: transparent;
    color: transparent;
    pointer-events: none;
}
.app .icon, .app img { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.app-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#empty {
    position: absolute;
    inset: 40% 12% auto;
    margin: 0;
    text-align: center;
    font-size: 15px;
    line-height: 1.45;
    color: #ffffffd9;
    text-shadow: 0 1px 3px #0006;
    pointer-events: none;
}

/* The card an app grows into from its icon, and then runs in. */
#card {
    position: absolute;
    z-index: 2;
    overflow: hidden;
    contain: strict;
}
#card-icon, #card-fill { position: absolute; inset: 0; width: 100%; height: 100%; }
#card-fill { background: #fff; }
#screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    touch-action: none;
    background: #fff;
}
/* The home indicator: tap it, swipe up on it, or press Escape to leave the app. */
#leave {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 46%;
    height: 26px;
    translate: -50% 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    touch-action: none;
}
#leave i {
    position: absolute;
    left: 50%;
    bottom: 8px;
    width: 134px;
    max-width: 100%;
    height: 5px;
    translate: -50% 0;
    border-radius: 3px;
    background: #000;
    opacity: 0.8;
    transition: scale 0.15s, opacity 0.15s, background-color 0.2s;
}
#leave.light i { background: #fff; opacity: 0.9; } /* over a dark foot of the app, as iOS changes it */
#leave:hover i { scale: 1.08 1.2; }
#leave:disabled { cursor: wait; }
#leave:disabled i { opacity: 0.3; }

/* The alert, as iOS 26 has them: a pane of glass, the text at its leading edge, two buttons side by side. */
#alert {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    background: #00000052;
    animation: fade-in 0.22s ease-out;
}
#alert .pane {
    width: min(300px, 82%);
    padding: 24px 16px 16px;
    box-sizing: border-box;
    border-radius: 36px;
    background: #f6f6fabd;
    color: #000;
    -webkit-backdrop-filter: blur(14px) saturate(1.5);
    backdrop-filter: blur(14px) saturate(1.5);
    box-shadow: inset 0 0 0 0.5px #ffffff80, 0 4px 24px #0000001a;
    animation: alert-in 0.22s ease-out;
}
#alert h2 { margin: 0 8px 6px; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
#alert p { margin: 0 8px 20px; font-size: 15px; line-height: 20px; color: #3c3c43d9; }
#alert .actions { display: flex; gap: 10px; }
#alert button {
    flex: 1;
    height: 48px;
    border: 0;
    border-radius: 24px;
    background: #78788029;
    color: #1c1c1e;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
}
#alert button:active { background: #78788052; }
#alert #alert-confirm { color: #ff3b30; font-weight: 600; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes alert-in { from { opacity: 0; scale: 1.12; } }

/* What the page has to say: a capsule of glass under the status bar, for a while. */
#status {
    position: absolute;
    z-index: 5;
    top: 54px;
    left: 50%;
    width: max-content;
    max-width: 82%;
    height: auto;
    margin: 0;
    padding: 9px 16px;
    box-sizing: border-box;
    translate: -50% 0;
    border-radius: 20px;
    background: #2a2a2e9c;
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    backdrop-filter: blur(16px) saturate(1.6);
    box-shadow: inset 0 0 0 0.5px #ffffff38, 0 6px 20px #0004;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, translate 0.25s;
}
#status.shown { opacity: 1; translate: -50% 4px; }

/* The first visit: the system is fetched and prepared. */
#preparation {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 3;
    background: #000;
    transition: opacity .4s ease;
}
#preparation.leaving { opacity: 0; pointer-events: none; }
#preparation.idle .preparation-mark i { animation: none; transform: none; opacity: 1; }
.preparation-mark { display: flex; gap: .4rem; align-items: center; height: 3rem; }
.preparation-mark i {
    width: .3rem;
    height: 1.9rem;
    border-radius: .2rem;
    background: #f2f2f7;
    animation: prepare-pulse 1.3s ease-in-out infinite alternate;
}
.preparation-mark i:nth-child(2) { animation-delay: -.6s; height: 2.7rem; }
.preparation-mark i:nth-child(3) { animation-delay: -1s; }
@keyframes prepare-pulse {
    from { opacity: .35; transform: scaleY(.46); }
    to { opacity: 1; transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
    .preparation-mark i { animation: none; }
    #alert, #alert .pane { animation: none; }
}
.preparation-status {
    position: absolute;
    inset: auto 1.5rem 3.5rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
#preparation-stage { margin: 0 0 .8rem; font-size: .95rem; color: #f2f2f7; text-wrap: balance; }
#preparation-meter {
    appearance: none;
    width: min(60%, 11rem);
    height: .3rem;
    border: 0;
    border-radius: .2rem;
    overflow: hidden;
    background: #ffffff33;
}
#preparation-meter::-webkit-progress-bar { background: #ffffff33; }
#preparation-meter::-webkit-progress-value { background: #f2f2f7; border-radius: .2rem; }
#preparation-meter::-moz-progress-bar { background: #f2f2f7; }
#preparation-bytes { margin: .5rem 0 0; color: #8e8e93; font-size: .76rem; }
#prepare-retry, #prepare-start {
    margin-top: 1rem;
    padding: .55rem 1.3rem;
    border: 0;
    border-radius: 1.2rem;
    background: #ffffff26;
    cursor: pointer;
}
