/* ==========================================================================
   Shared clear-glass UI
   One material for the time page and the Stickies page: pale frosted glass,
   a pointer-following sheen, a hairline rim, and tone-aware ink.
   Page stylesheets add layout and typography on top of .glass-surface.
   ========================================================================== */

:root {
    --glass-fill-top: rgba(232, 236, 240, 0.30);
    --glass-fill-bottom: rgba(232, 236, 240, 0.17);
    --glass-blur: 12px;
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-border-soft: rgba(255, 255, 255, 0.28);
    --glass-shadow: 0 8px 40px rgba(0, 0, 0, 0.28);
    --glass-sheen: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    --hairline: rgba(255, 255, 255, 0.22);

    /* Clear glass: white type unless the backdrop is too bright. */
    --ink: #ffffff;
    --ink-soft: rgba(255, 255, 255, 0.84);
    --ink-muted: rgba(255, 255, 255, 0.66);
    --ink-faint: rgba(255, 255, 255, 0.46);
    --label: #ffffff;
    --placeholder: rgba(255, 255, 255, 0.55);
    --accent: #e0b07a;
    --accent-hero: #e0b07a;
    --dot: rgba(255, 255, 255, 0.4);
    --dot-strong: rgba(255, 255, 255, 0.65);

    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
        "Songti SC", STSong, "Noto Serif CJK SC", SimSun, serif;
}

/* Bright glass: warm espresso type. */
html[data-tone="light"] {
    --hairline: rgba(52, 42, 33, 0.16);
    --ink: #342a21;
    --ink-soft: rgba(52, 42, 33, 0.86);
    --ink-muted: rgba(52, 42, 33, 0.72);
    --ink-faint: rgba(52, 42, 33, 0.62);
    --label: #43362a;
    --placeholder: #6b5d4f;
    --accent: #8a5230;
}

/* Chinese headings read better in a modern sans than in the Latin serif. */
html[lang^="zh"] {
    --font-display: "Source Han Serif SC", "Noto Serif CJK SC",
        "Songti SC", STSong, SimSun, "Songti TC", serif;
}

/* A reusable glass panel. Page CSS controls size, spacing and radius. */
.glass-surface {
    --mx: 50%;
    --my: 50%;
    --glass-radius: 26px;
    position: relative;
    isolation: isolate;
    border-radius: var(--glass-radius);
    background: linear-gradient(160deg, var(--glass-fill-top) 0%,
            var(--glass-fill-bottom) 100%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
    backdrop-filter: blur(var(--glass-blur)) saturate(150%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow), var(--glass-sheen);
}

/* The moving sheen only exists while a surface is hovered. */
.glass-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        radial-gradient(620px circle at var(--mx, 50%) var(--my, 50%),
            rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.015) 55%,
            rgba(255, 255, 255, 0) 82%),
        radial-gradient(1100px circle at var(--mx, 50%) var(--my, 50%),
            rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 78%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: -1;
}

.glass-surface.is-lit::before {
    opacity: 1;
}

/* A specular rim that follows the pointer, clipped to the 1px border. */
.glass-surface::after {
    content: '';
    position: absolute;
    inset: -1px;
    padding: 1.5px;
    border-radius: inherit;
    background:
        radial-gradient(90px circle at var(--mx, 50%) var(--my, 50%),
            rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 60%),
        radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%),
            var(--accent-hero, #d8b080), transparent 78%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    z-index: 2;
}

.glass-surface.is-lit::after {
    opacity: 0.6;
}

@supports not ((mask-composite: exclude) or (-webkit-mask-composite: xor)) {

    .glass-surface::after {
        display: none;
    }
}

/* Without backdrop-filter the glass would read as an almost-empty box. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {

    .glass-surface {
        background: rgba(28, 32, 38, 0.86);
    }

    html[data-tone="light"] .glass-surface {
        background: rgba(240, 239, 236, 0.95);
    }
}

/* Close button shared by both pages. */
.stickies_icon {
    display: block;
    position: absolute;
    top: calc(1rem + env(safe-area-inset-top));
    right: calc(1rem + env(safe-area-inset-right));
    z-index: 300;
    width: 4rem;
    height: 4rem;
    cursor: pointer;
    text-indent: 4rem;
    overflow: hidden;
    white-space: nowrap;
    background-size: 20px 20px;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

.stickies_icon:before {
    -moz-transition: background-color 0.2s ease-in-out;
    -webkit-transition: background-color 0.2s ease-in-out;
    -ms-transition: background-color 0.2s ease-in-out;
    transition: background-color 0.2s ease-in-out;
    content: '';
    display: block;
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 100%;
    background-color: var(--background-color);
}

.stickies_icon:hover:before {
    background-color: rgba(255, 255, 255, 0.15);
}

.stickies_icon:active:before {
    background-color: rgba(255, 255, 255, 0.3);
}

@media screen and (max-width: 736px) {

    .stickies_icon:before {
        top: 0.875rem;
        left: 0.875rem;
        width: 2.25rem;
        height: 2.25rem;
        background-size: 14px 14px;
    }
}
