/* =============================================================================
   System landing page.

   The page a domain shows before anything is built on it: the title from that
   domain's own settings, the date, and a live clock in its own timezone.

   Self-contained on purpose, like the sign-in sheet — it is reached before the
   dashboard loads and must not depend on style.css or admin-modern.css.

   Every colour comes from the custom properties the page puts on .cstore-landing,
   which index.php fills in from settings.websiteColor and settings.headerButton
   (see caBrandPalette()). The page is always a dark, lit room, so the scrim
   layers below matter: a store whose accent colour is pale would otherwise leave
   white text on a pale green background.
   ============================================================================= */

:root {
    /* The page is its own dark theme rather than one that follows the system. */
    color-scheme: dark;
}

.cstore-landing {
    --cstore-accent: #4ccfae;
    --cstore-accent-dark: #37997f;
    --cstore-accent-deep: #1d5949;
    --cstore-accent-soft: #eaf9f4;
    --cstore-accent-tint: #f5fdfa;
    --cstore-on-accent: #10221d;
    --cstore-on-accent-soft: rgba(16, 34, 29, .32);
    --cstore-ring: rgba(76, 207, 174, .45);
    --cstore-glow: rgba(76, 207, 174, .35);

    /* Neutrals: this page is always dark, so they are not themed. */
    --cstore-ink: #f4f8fc;
    --cstore-ink-soft: rgba(244, 248, 252, .78);
    --cstore-muted: rgba(244, 248, 252, .56);
    --cstore-line: rgba(255, 255, 255, .16);
    --cstore-field: rgba(255, 255, 255, .07);
    --cstore-radius: 18px;

    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(18px, 3vh, 30px);
    padding: clamp(24px, 5vh, 54px) clamp(20px, 5vw, 48px);
    overflow-x: hidden;
    color: var(--cstore-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    text-align: center;
    /* Four layers, and the order is the whole design: the dark scrim goes first because the first
       layer is the top one, and it has to sit *over* the brand colour and its glow. A store whose
       accent is pale teal would otherwise flood the page with it and take the clock down with it. */
    background:
        linear-gradient(rgba(4, 16, 14, .8), rgba(2, 8, 8, .93)),
        radial-gradient(900px 620px at 78% 10%, var(--cstore-glow) 0%, transparent 60%),
        radial-gradient(760px 520px at 14% 88%, var(--cstore-glow) 0%, transparent 58%),
        linear-gradient(140deg, var(--cstore-accent) 0%, var(--cstore-accent-deep) 58%, #04070c 100%);
}

/* The body is in this list as well as its children. Without it its own padding sits outside
   min-height: 100dvh and the page scrolls by exactly that padding, for no content at all. */
.cstore-landing,
.cstore-landing *,
.cstore-landing *::before,
.cstore-landing *::after {
    box-sizing: border-box;
}

.cstore-landing img {
    max-width: 100%;
    display: block;
}

/* A faint grid, masked so it fades out toward the middle and never competes with the clock. */
.cstore-landing::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 78%);
    pointer-events: none;
    animation: ca-landing-fade 1.4s ease-out both;
}

/* -------------------------------------------------------------------- orbs ---- */

.ca-landing-orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Light, not paint: these are the room's glow, and at any strength above a whisper they start to
   compete with the clock they are supposed to be lighting. */
.ca-landing-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(30px);
    opacity: .16;
}

.ca-landing-orb-a {
    width: 460px;
    height: 460px;
    left: -120px;
    top: -80px;
    background: radial-gradient(circle, var(--cstore-accent-soft) 0%, transparent 66%);
    animation: ca-landing-drift-a 22s ease-in-out infinite;
}

.ca-landing-orb-b {
    width: 380px;
    height: 380px;
    right: -90px;
    bottom: -110px;
    opacity: .26;
    background: radial-gradient(circle, var(--cstore-glow) 0%, transparent 70%);
    animation: ca-landing-drift-b 26s ease-in-out infinite;
}

.ca-landing-orb-c {
    width: 220px;
    height: 220px;
    right: 16%;
    top: 10%;
    opacity: .1;
    background: radial-gradient(circle, rgba(255, 255, 255, .6) 0%, transparent 68%);
    animation: ca-landing-drift-a 31s ease-in-out infinite reverse;
}

/* ----------------------------------------------------------------- language ---- */

.ca-landing-lang {
    position: fixed;
    top: 22px;
    inset-inline-end: 24px;
    z-index: 3;
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: var(--cstore-field);
    border: 1px solid var(--cstore-line);
    backdrop-filter: blur(8px);
}

.ca-landing-lang a {
    display: block;
    padding: 5px 12px;
    border-radius: 999px;
    color: var(--cstore-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-decoration: none;
    transition: background .18s, color .18s;
}

.ca-landing-lang a:hover {
    color: var(--cstore-ink);
}

.ca-landing-lang a.is-active {
    background: #fff;
    color: #101520;
}

.ca-landing-lang a:focus-visible {
    outline: 2px solid var(--cstore-ring);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------- brand ---- */

.ca-landing {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(14px, 2.4vh, 24px);
    width: 100%;
    max-width: 760px;
}

.ca-landing-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    animation: ca-landing-rise .7s cubic-bezier(.2, .8, .25, 1) both;
}

.ca-landing-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    border-radius: 15px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .32);
    backdrop-filter: blur(6px);
    box-shadow: 0 12px 30px rgba(3, 12, 10, .34);
}

/* A slow halo, so the mark is where the eye lands first. */
.ca-landing-mark::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 19px;
    border: 1px solid rgba(255, 255, 255, .4);
    animation: ca-landing-halo 3.6s ease-out infinite;
    pointer-events: none;
}

.ca-landing-mark img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.ca-landing-monogram {
    font-size: 19px;
    font-weight: 650;
    letter-spacing: .04em;
}

.ca-landing-title {
    margin: 0;
    font-size: clamp(17px, 2.4vw, 21px);
    font-weight: 600;
    letter-spacing: .01em;
    text-align: start;
}

/* ------------------------------------------------------------------- clock ---- */

.ca-landing-clock {
    position: relative;
    animation: ca-landing-rise .7s cubic-bezier(.2, .8, .25, 1) .08s both;
}

/* The glow sits behind the digits rather than on them: text-shadow on a thin face
   smudges the strokes, a blurred disc does not. */
.ca-landing-clock::before {
    content: "";
    position: absolute;
    inset: -14% -18%;
    border-radius: 50%;
    background: radial-gradient(closest-side, var(--cstore-glow), transparent 72%);
    filter: blur(26px);
    animation: ca-landing-breathe 6.5s ease-in-out infinite;
    pointer-events: none;
}

.ca-landing-time {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: .05em;
    /* A clock reads left to right in Arabic too (٠٢:٠٧:٠٨), so the row itself must not be mirrored
       with the rest of the page: without this the seconds land to the left of the minutes. */
    direction: ltr;
    unicode-bidi: isolate;
    font-size: clamp(58px, 15vw, 152px);
    font-weight: 250;
    line-height: 1;
    letter-spacing: -.035em;
    /* Equal-width digits: without this the whole line shifts every time a 1 arrives. */
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    text-shadow: 0 18px 60px rgba(2, 8, 7, .45);
}

.ca-landing-seconds {
    font-size: .3em;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--cstore-muted);
    font-variant-numeric: tabular-nums;
}

/* One pulse per second, driven by the script adding .is-tick for the length of the animation. */
.ca-landing-seconds.is-tick {
    animation: ca-landing-tick .55s ease-out;
}

/* -------------------------------------------------------------------- date ---- */

.ca-landing-date {
    margin: 0;
    font-size: clamp(14px, 1.8vw, 17px);
    font-weight: 500;
    letter-spacing: .01em;
    color: var(--cstore-ink-soft);
    animation: ca-landing-rise .7s cubic-bezier(.2, .8, .25, 1) .14s both;
}

/* -------------------------------------------------------------------- zone ---- */

.ca-landing-zone {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 7px 15px;
    border-radius: 999px;
    border: 1px solid var(--cstore-line);
    background: var(--cstore-field);
    backdrop-filter: blur(8px);
    color: var(--cstore-muted);
    font-size: 12.5px;
    letter-spacing: .04em;
    animation: ca-landing-rise .7s cubic-bezier(.2, .8, .25, 1) .2s both;
}

.ca-landing-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: var(--cstore-accent-soft);
    box-shadow: 0 0 0 3px var(--cstore-glow);
    animation: ca-landing-beat 2.4s ease-in-out infinite;
}

/* ------------------------------------------------------------------ status ---- */

.ca-landing-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--cstore-field);
    border: 1px solid var(--cstore-line);
    color: var(--cstore-ink-soft);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    animation: ca-landing-rise .7s cubic-bezier(.2, .8, .25, 1) .26s both;
}

.ca-landing-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cstore-accent-soft);
}

.ca-landing-status.is-maintenance {
    border-color: rgba(255, 205, 150, .4);
    color: #ffd9a8;
}

.ca-landing-status.is-maintenance::before {
    background: #ffd9a8;
}

/* No settings row to read: the domain is serving a page but has nothing configured yet. */
.ca-landing-status.is-unset {
    border-color: rgba(255, 255, 255, .14);
    color: var(--cstore-muted);
}

.ca-landing-status.is-unset::before {
    background: transparent;
    border: 1px solid var(--cstore-muted);
}

/* ------------------------------------------------------------------ footer ---- */

.ca-landing-foot {
    position: fixed;
    inset-inline: 0;
    bottom: clamp(18px, 3.4vh, 32px);
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 16px;
    padding: 0 20px;
    font-size: 12.5px;
    color: var(--cstore-muted);
    animation: ca-landing-rise .7s cubic-bezier(.2, .8, .25, 1) .3s both;
}

.ca-landing-host {
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid var(--cstore-line);
    background: var(--cstore-field);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    letter-spacing: .02em;
    color: var(--cstore-ink-soft);
}

.ca-landing-foot a {
    color: var(--cstore-ink-soft);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color .18s, border-color .18s;
}

.ca-landing-foot a:hover {
    color: #fff;
    border-bottom-color: var(--cstore-ring);
}

.ca-landing-foot a:focus-visible {
    outline: 2px solid var(--cstore-ring);
    outline-offset: 3px;
    border-radius: 4px;
}

/* -------------------------------------------------------------- animations ---- */

@keyframes ca-landing-rise {
    from { opacity: 0; transform: translateY(14px) scale(.99); }
    to { opacity: 1; transform: none; }
}

@keyframes ca-landing-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ca-landing-halo {
    0% { opacity: .65; transform: scale(1); }
    70%, 100% { opacity: 0; transform: scale(1.24); }
}

@keyframes ca-landing-breathe {
    0%, 100% { opacity: .4; transform: scale(1); }
    50% { opacity: .68; transform: scale(1.05); }
}

@keyframes ca-landing-beat {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .55; transform: scale(.82); }
}

@keyframes ca-landing-tick {
    0% { opacity: 1; transform: none; }
    45% { opacity: .45; transform: translateY(-2px); }
    100% { opacity: 1; transform: none; }
}

@keyframes ca-landing-drift-a {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(46px, 34px, 0) scale(1.08); }
}

@keyframes ca-landing-drift-b {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-52px, -30px, 0) scale(1.12); }
}

/* -------------------------------------------------------------- responsive ---- */

@media (max-width: 720px) {
    .cstore-landing {
        gap: 16px;
        padding-bottom: 96px;
    }

    .ca-landing-mark {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
        border-radius: 13px;
    }

    .ca-landing-mark img {
        width: 26px;
        height: 26px;
    }

    .ca-landing-title {
        font-size: 16px;
    }

    .ca-landing-time {
        font-size: clamp(52px, 19vw, 84px);
    }

    .ca-landing-lang {
        top: 16px;
        inset-inline-end: 16px;
    }

    .ca-landing-foot {
        gap: 8px 14px;
    }
}

/* A very short window (landscape phone) must not push the clock off the page. */
@media (max-height: 560px) {
    .cstore-landing {
        gap: 12px;
        padding-top: 60px;
        padding-bottom: 80px;
    }

    .ca-landing-time {
        font-size: clamp(40px, 9vh, 72px);
    }

    .ca-landing-status,
    .ca-landing-zone {
        display: none;
    }
}

/* Motion is decoration here, so it is the first thing to go when asked. */
@media (prefers-reduced-motion: reduce) {
    .cstore-landing *,
    .cstore-landing *::before,
    .cstore-landing *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
