:root {
    --ink: #17323a;
    --muted: #5f7f86;
    --accent: #0b7f6f;
    --accent-soft: #dff2ed;
    --screen-bg: #f4fbf9;
    --night: #0f1630;
    --night-screen: #10172e;
    --night-ink: #dfe4fa;
    --night-muted: #8e98c4;
    --moon: #f2c94c;
    --battery-ok: #2bb673;
    --battery-warn: #f2a900;
    --battery-low: #e5484d;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    overscroll-behavior: none;
    background: #fff;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Scene ---------- */

.viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #a4a09b;
    touch-action: manipulation;
}

/* Blurred copy of the photo: fills the sides on screens wider than the photo */
.backdrop {
    position: absolute;
    inset: -40px;
    background: url("../images/normal.jpg") center top / cover no-repeat;
    filter: blur(24px) brightness(.9);
    transition: filter 1.2s ease;
}

.stage {
    position: absolute;
    transform-origin: 0 0;
    opacity: 0;
    transition: opacity .5s ease;
}

.is-ready .stage {
    opacity: 1;
}

.stage.is-zooming {
    transition: opacity .5s ease, transform 1.1s cubic-bezier(.65, 0, .35, 1);
}

.mood {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.mood-smile,
.mood-sad {
    opacity: 0;
    transition: opacity .35s ease;
}

.stage[data-mood="smile"] .mood-smile,
.stage[data-mood="sad"] .mood-sad {
    opacity: 1;
}

.night {
    position: absolute;
    inset: 0;
    background: var(--night);
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s ease;
}

.is-asleep .backdrop {
    filter: blur(24px) brightness(.35) saturate(.6);
}

.is-asleep .night {
    opacity: .62;
}

.zzz {
    position: absolute;
    left: 58%;
    top: 6%;
    color: #e3e8ff;
    font-size: calc(var(--s, 1) * 40px);
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 0 .35em rgba(150, 170, 255, .8);
    pointer-events: none;
    opacity: 0;
    transition: opacity .8s ease;
}

.zzz span {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
}

.zzz span:nth-child(2) {
    font-size: 1.3em;
    animation-delay: 1.2s;
}

.zzz span:nth-child(3) {
    font-size: 1.65em;
    animation-delay: 2.4s;
}

.is-asleep .zzz {
    opacity: 1;
}

.is-asleep .zzz span {
    animation-name: zzz;
    animation-duration: 3.6s;
    animation-timing-function: ease-in;
    animation-iteration-count: infinite;
}

@keyframes zzz {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(-12deg) scale(.6);
    }
    15% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(1.4em, -2.4em) rotate(12deg) scale(1.15);
    }
}

/* ---------- Laptop screen ---------- */

.screen {
    position: absolute;
    left: calc(100% * 445 / 1294);
    top: calc(100% * 468 / 1942);
    width: calc(100% * 404 / 1294);
    height: calc(100% * 246 / 1942);
    overflow: hidden;
    border-radius: 1.5% / 2.5%;
    container-type: size;
    background-color: transparent;
    transition: background-color .6s ease, box-shadow .6s ease;
}

.screen.is-on {
    background-color: var(--screen-bg);
    box-shadow: 0 0 calc(var(--s, 1) * 14px) rgba(140, 225, 205, .45);
}

.is-asleep .screen {
    background-color: var(--night-screen);
    box-shadow: 0 0 calc(var(--s, 1) * 22px) rgba(120, 140, 255, .45);
    transition-duration: 1.2s;
}

.boot,
.ui {
    position: absolute;
    inset: 0;
    font-size: 14px;
    font-size: clamp(11px, 4.556cqw, 18px);
    line-height: 1.32;
}

.boot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35em;
    padding: 0 1em;
    color: var(--accent);
    text-align: center;
    opacity: 0;
    transition: opacity .4s ease, visibility .4s;
}

.screen.is-on .boot {
    opacity: 1;
}

.screen.is-booted .boot {
    opacity: 0;
    visibility: hidden;
}

.boot-logo {
    font: 700 2.3em/1 var(--mono);
    letter-spacing: .06em;
}

.boot-name {
    color: var(--muted);
    font-size: .72em;
}

.boot-bar {
    width: 48%;
    height: .38em;
    margin-top: .5em;
    overflow: hidden;
    border-radius: 1em;
    background: var(--accent-soft);
}

.boot-bar i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.screen.is-on .boot-bar i {
    animation: boot 1.3s ease-in-out forwards;
}

@keyframes boot {
    to {
        width: 100%;
    }
}

.ui {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity .3s ease, color 1.2s ease;
}

.screen.is-booted .ui {
    opacity: 1;
}

/* Status bar */

.statusbar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    height: 2.15em;
    padding: 0 .95em;
    background: var(--accent-soft);
    color: var(--muted);
    font: 600 .68em/1 var(--mono);
    font-size: max(9px, .68em);
    letter-spacing: .04em;
    transition: background-color 1.2s ease, color 1.2s ease;
}

.status-name {
    display: flex;
    align-items: center;
    gap: .5em;
}

.dot {
    width: .6em;
    height: .6em;
    border-radius: 50%;
    background: var(--battery-ok);
    box-shadow: 0 0 0 .2em rgba(43, 182, 115, .18);
}

.battery {
    display: flex;
    align-items: center;
    gap: .5em;
}

.battery-icon {
    position: relative;
    width: 2.2em;
    height: 1.1em;
    padding: .14em;
    border: .12em solid currentColor;
    border-radius: .28em;
}

.battery-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -.36em;
    width: .2em;
    height: .45em;
    border-radius: 0 .12em .12em 0;
    background: currentColor;
    transform: translateY(-50%);
}

.battery-icon i {
    display: block;
    width: calc(var(--level, .17) * 100%);
    height: 100%;
    border-radius: .1em;
    background: var(--battery-color, var(--battery-ok));
    transition: width .5s ease, background-color .5s ease;
}

.battery.is-warn {
    --battery-color: var(--battery-warn);
}

.battery.is-low {
    --battery-color: var(--battery-low);
    color: var(--battery-low);
    animation: blink 1s steps(2, start) infinite;
}

.battery.is-empty {
    opacity: .6;
}

/* Message */

.message {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    padding: .6em .85em .35em;
    overflow-y: auto;
    scrollbar-width: none;
}

.message::-webkit-scrollbar {
    display: none;
}

.text {
    flex: none;
    margin: 0;
    white-space: pre-line;
    overflow-wrap: break-word;
}

.caret {
    display: inline-block;
    width: .45em;
    height: 1.05em;
    margin-left: .1em;
    vertical-align: -.17em;
    background: var(--accent);
    animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
    to {
        visibility: hidden;
    }
}

.extra {
    flex: none;
    opacity: 0;
    transition: opacity .3s ease;
}

.screen.show-extra .extra {
    opacity: 1;
}

/* Buttons */

.options {
    display: grid;
    flex: none;
    grid-template-columns: 1fr 1fr;
    gap: .42em;
    padding: .3em .85em .7em;
}

.options:empty {
    display: none;
}

.option {
    min-height: 2.35em;
    margin: 0;
    padding: .4em .55em;
    border: 1.5px solid var(--accent);
    border-radius: .7em;
    background: #fff;
    color: var(--accent);
    font: inherit;
    font-size: .88em;
    font-weight: 650;
    line-height: 1.15;
    cursor: pointer;
    touch-action: manipulation;
    opacity: 0;
    pointer-events: none;
    transform: translateY(.35em);
    transition: opacity .25s ease, transform .25s ease, background-color .15s ease, color .15s ease;
    transition-delay: calc(var(--i, 0) * 70ms);
}

.option:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.screen.show-options .option {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

@media (hover: hover) {
    .option:hover {
        background: var(--accent-soft);
    }
}

.option:active,
.option.is-pressed {
    background: var(--accent);
    color: #fff;
    opacity: 1;
    transition-delay: 0s;
}

.option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Effects */

.chart {
    margin: .25em auto 0;
    color: #102a30;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 700;
    line-height: 1.05;
    text-align: center;
}

.chart div {
    padding-left: .2em; /* balances the trailing letter-spacing */
    font-size: calc(var(--size) * 1em);
    letter-spacing: .2em;
}

.chart div:last-child {
    padding-left: 0;
    font-weight: 400;
    letter-spacing: .02em;
}

.progress {
    display: flex;
    align-items: center;
    gap: .6em;
    margin-top: .6em;
}

.progress-bar {
    flex: 1;
    height: .55em;
    overflow: hidden;
    border-radius: 1em;
    background: var(--accent-soft);
}

.progress-bar i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.progress-value {
    min-width: 3.2ch;
    color: var(--muted);
    font: 600 .8em/1 var(--mono);
    text-align: right;
}

.progress.is-stuck .progress-bar i {
    animation: stuck .9s ease-in-out infinite alternate;
}

@keyframes stuck {
    to {
        opacity: .45;
    }
}

/* Asleep */

.is-asleep .ui {
    color: var(--night-ink);
}

.is-asleep .statusbar {
    background: rgba(255, 255, 255, .06);
    color: var(--night-muted);
}

.is-asleep .dot {
    background: var(--night-muted);
    box-shadow: none;
}

.is-asleep .caret {
    display: none;
}

.is-asleep .extra {
    margin-block: auto;
}

.is-asleep .option {
    border-color: var(--moon);
    background: transparent;
    color: var(--moon);
}

.is-asleep .option:active,
.is-asleep .option.is-pressed {
    background: var(--moon);
    color: var(--night-screen);
}

.saver {
    text-align: center;
}

.saver-moon {
    font-size: 2em;
    line-height: 1.1;
    animation: float 3s ease-in-out infinite alternate;
}

.saver-title {
    color: #fff;
    font: 700 1.3em/1.2 var(--mono);
    letter-spacing: .12em;
}

.saver-sub {
    color: var(--moon);
    font-size: .85em;
}

.saver-note {
    margin-top: .35em;
    color: var(--night-muted);
    font-size: .62em;
}

@keyframes float {
    to {
        transform: translateY(-.15em) rotate(-8deg);
    }
}

/* ---------- Misc ---------- */

.rotate {
    display: none;
}

@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
    .rotate {
        position: fixed;
        inset: 0;
        z-index: 10;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 24px;
        background: #fff;
        font-size: 17px;
        line-height: 1.4;
        text-align: center;
    }

    .rotate p {
        max-width: 22em;
        margin: 0;
    }

    .rotate-icon {
        font-size: 44px;
        animation: rotate-hint 2s ease-in-out infinite;
    }
}

@keyframes rotate-hint {
    0%,
    30% {
        transform: rotate(-90deg);
    }
    60%,
    100% {
        transform: rotate(0);
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        transition-delay: 0s !important;
    }
}
