/* ----------------------------------------------------------------------
   kode.stream brand layer, shared by the landing page and the app.

   The landing page is the loud version of the brand; the app is the same voice at working
   volume. This file holds what both use. Decoration only the landing page has (drifting blobs,
   the night sky, the struck-out word, the hand-drawn underline) stays in landing.html.

   Colours come from the daisyUI theme in fragments/head.html; nothing here defines a new one.
   Everything that moves stops under prefers-reduced-motion, and every element is visible in its
   resting state, so a browser that skips the animations still shows the whole page.
   ---------------------------------------------------------------------- */

:root {
    /* Each stage of a change owns a colour, the same on the landing page's four steps,
       in badges and in the staff home's delivery flow */
    --ks-stage-describe: var(--color-primary);
    --ks-stage-agree: var(--color-secondary);
    --ks-stage-check: var(--color-info);
    --ks-stage-approve: var(--color-accent);

    /* Each of the three promises owns a colour (landing #focus, the project sidebar, pillar cards) */
    --ks-pillar-stability: var(--color-accent);
    --ks-pillar-security: var(--color-neutral);
    --ks-pillar-quality: var(--color-info);

    /* The header's height, the same signed in and out: a 4rem bar and its 4px gradient strip */
    --ks-header-h: 4.25rem;

    --ks-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ks-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Type ------------------------------------------------------------ */

/* The small uppercase label above a heading ("About us" on the landing page) */
.ks-eyebrow {
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    color: var(--color-primary);
}

/* A page in one of the three promises carries its colour, darkened to read on white (AA, 4.5:1) */
.ks-eyebrow-stability { color: color-mix(in oklab, var(--ks-pillar-stability) 65%, var(--color-base-content)); }
.ks-eyebrow-security  { color: var(--ks-pillar-security); }
.ks-eyebrow-quality   { color: color-mix(in oklab, var(--ks-pillar-quality) 70%, var(--color-base-content)); }

/* Links inside running text: an orange underline */
.ks-link {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: color 0.2s;
}
.ks-link:hover { color: var(--color-primary); }

/* Marker highlight behind a line of text */
.ks-mark {
    background-image: linear-gradient(transparent 58%, color-mix(in oklab, var(--color-accent) 50%, transparent) 58%, color-mix(in oklab, var(--color-accent) 50%, transparent) 92%, transparent 92%);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    padding-inline: 0.1em;
}

/* Links in rendered text: chat answers, docs, release notes (Markdown from marked) */
:is(.assistant-markdown, #streaming-content, #doc-body, [data-release-notes].is-rendered) a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: color 0.2s;
}
:is(.assistant-markdown, #streaming-content, #doc-body, [data-release-notes].is-rendered) a:hover { color: var(--color-primary); }

/* ---- Surfaces -------------------------------------------------------- */

/* The solid offset shadow. One element per page gets it: the thing the page is for. */
.ks-offset {
    --ks-offset-size: 6px;
    box-shadow: var(--ks-offset-size) var(--ks-offset-size) 0 0 var(--ks-offset-colour, var(--color-accent));
    transition: box-shadow 0.3s var(--ks-ease-out);
}
.ks-offset:is(:hover, :focus-within) { --ks-offset-size: 10px; }

/* An empty state: a dashed, faintly blue box. The full one (fragments/empty-state.html) adds the
   brand mark; the compact one is a sentence in the box. */
.ks-empty {
    border: 1.5px dashed color-mix(in oklab, var(--color-primary) 22%, transparent);
    background-color: color-mix(in oklab, var(--color-primary) 3%, var(--color-base-100));
}

/* Blueprint grid that fades out towards the edges, for blue surfaces */
.ks-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, color-mix(in oklab, var(--color-primary-content) 9%, transparent) 1px, transparent 1px),
        linear-gradient(to bottom, color-mix(in oklab, var(--color-primary-content) 9%, transparent) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 70% 60% at 30% 40%, black 0%, transparent 75%);
}

/* Drifting colour fields behind the blue chapters. A soft-edged gradient rather than
   filter: blur(), which made every frame re-blur a huge layer. */
.ks-blob {
    position: absolute;
    border-radius: 9999px;
    background: radial-gradient(closest-side, var(--blob) 0%, color-mix(in oklab, var(--blob) 55%, transparent) 40%, color-mix(in oklab, var(--blob) 18%, transparent) 70%, transparent 100%);
    will-change: transform;
    animation: ks-drift var(--dur, 24s) ease-in-out infinite alternate;
}
@keyframes ks-drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(var(--dx, 8%), var(--dy, -6%), 0) scale(1.1); }
    100% { transform: translate3d(calc(var(--dx, 8%) * -0.7), calc(var(--dy, -6%) * -1), 0) scale(0.94); }
}

/*
   The blue band at the top of a top-level app page: the landing hero at working volume.
   It continues the blue of the header, carries the grid and still colour fields (nothing drifts
   in the app), and the page's first card overlaps its lower edge with .ks-band-overlap.
   Decoration goes in .ks-band-deco, which clips it; the band itself doesn't clip, so a
   dropdown opened from its header can hang below it.
*/
.ks-band {
    position: relative;
    isolation: isolate;
    background-color: var(--color-primary);
    background-image:
        radial-gradient(45% 90% at 100% 0%, color-mix(in oklab, var(--color-secondary) 20%, transparent) 0%, transparent 70%),
        radial-gradient(40% 80% at 0% 100%, color-mix(in oklab, var(--color-info) 30%, transparent) 0%, transparent 70%);
    color: var(--color-primary-content);
}
.ks-band-deco { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
/* This file is unlayered, so it beats Tailwind's utilities: colours that change on the band are set here.
   Small text on the band stays at 90% white or more, and the tints stay faint, so it meets WCAG AA
   (4.5:1) even where the cyan and pink tints are strongest. */
.ks-band .ks-eyebrow { color: color-mix(in oklab, var(--color-primary-content) 90%, transparent); }
/* The breadcrumb fragment is grey on white everywhere else; on the band it stays readable */
.ks-band .breadcrumbs { color: color-mix(in oklab, var(--color-primary-content) 90%, transparent); }
.ks-band .breadcrumbs [aria-current="page"] { color: var(--color-primary-content); }
/* How far it overlaps: set --ks-overlap on the element (a margin utility would lose to this rule) */
.ks-band-overlap { position: relative; margin-top: calc(-1 * var(--ks-overlap, 3.5rem)); }

/* ---- Stages ------------------------------------------------------------ */

/* The home page's delivery flow (data-stage from HomeDashboard.kt): each stage in the colour its step
   has on the landing page. Conversations describe, agent runs build, change requests and the review
   queue wait to be approved, and merged is done. */
.ks-stage { --ks-stage: var(--color-base-content); }
.ks-stage[data-stage="conversations"] { --ks-stage: var(--ks-stage-describe); }
.ks-stage[data-stage="runs"]          { --ks-stage: var(--ks-stage-check); }
.ks-stage[data-stage="submitted"],
.ks-stage[data-stage="waiting"]       { --ks-stage: var(--ks-stage-approve); }
.ks-stage[data-stage="merged"]        { --ks-stage: var(--color-success); }
.ks-stage::before {
    content: "";
    position: absolute;
    inset: 0 1.25rem auto;
    height: 3px;
    border-radius: 0 0 9999px 9999px;
    background: var(--ks-stage);
}
/* Orange and cyan text need darkening to read on white (AA, 4.5:1), as the landing page's "04" does */
.ks-stage-number { color: color-mix(in oklab, var(--ks-stage) 65%, var(--color-base-content)); }

/* ---- The project sidebar (fragments/project-sidebar.html) ------------ */

.ks-sidebar [data-nav-pillar="stability"] { --ks-pillar: var(--ks-pillar-stability); }
.ks-sidebar [data-nav-pillar="security"]  { --ks-pillar: var(--ks-pillar-security); }
.ks-sidebar [data-nav-pillar="quality"]   { --ks-pillar: var(--ks-pillar-quality); }
/* Desktop: a pillar's pages hang off a line in its colour */
.ks-sidebar .menu:not(.menu-horizontal) > li[data-nav-pillar] {
    margin-inline-start: 0.75rem;
    padding-inline-start: 0.375rem;
    border-inline-start: 2px solid var(--ks-pillar);
}
/* Phone strip: each pillar's page is underlined in its colour */
.ks-sidebar .menu-horizontal > li[data-nav-pillar] > a:not(.menu-active) {
    background-image: linear-gradient(var(--ks-pillar), var(--ks-pillar));
    background-size: calc(100% - 1.5rem) 2px;
    background-position: center bottom 2px;
    background-repeat: no-repeat;
}
.ks-sidebar li[data-nav-pillar] > a > svg { color: var(--ks-pillar); }
.ks-sidebar .menu a:not(.menu-active):hover { background-color: color-mix(in oklab, var(--color-primary) 8%, transparent); }
.ks-sidebar .menu a.menu-active {
    background-color: var(--color-primary);
    color: var(--color-primary-content);
    box-shadow: 3px 3px 0 0 var(--color-accent);
}
.ks-sidebar .menu a.menu-active > svg { color: currentColor; }

/* ---- Motion ---------------------------------------------------------- */

/* Entrance: plays from first paint, staggered with --d. Not again once the page has talked to the
   server (app.js sets .ks-settled), so a boosted navigation doesn't replay it. */
.ks-rise { animation: ks-rise 0.7s var(--ks-ease-out) var(--d, 0s) both; }
.ks-settled .ks-rise { animation: none; }
@keyframes ks-rise { from { opacity: 0; transform: translate3d(0, 8px, 0); } }

/* Something just happened: a check mark, a confirmation */
/* .ks-pop keeps a fixed delay: it sits inside .ks-rise elements, whose --d it would inherit */
.ks-pop { display: inline-block; animation: ks-pop 0.5s var(--ks-ease-spring) 1.4s both; }
.ks-joined { animation: ks-pop 0.5s var(--ks-ease-spring) both; }
/* An inline badge or icon needs a box to scale */
span.ks-joined, svg.ks-joined { display: inline-flex; }
@keyframes ks-pop { from { opacity: 0; transform: translateY(0.3em) scale(0.6); } }

/* A slightly tilted card that straightens up when you reach for it (landing only, by convention) */
.ks-tilt { transform: rotate(var(--tilt, 1.5deg)); transition: transform 0.5s var(--ks-ease-spring), box-shadow 0.5s; }
.ks-tilt:hover, .ks-tilt:focus-within { transform: rotate(0deg) translateY(-4px); }

/* Cards that lift on hover. The landing page leans them too; the app's .ks-lift-sm lifts only. */
.ks-lift { transition: transform 0.4s var(--ks-ease-spring), box-shadow 0.4s, border-color 0.2s, background-color 0.2s; }
.ks-lift:hover { transform: translateY(var(--lift, -6px)) rotate(var(--lean, -1deg)); }
.ks-lift-sm { --lift: -2px; --lean: 0deg; }

/* A suggested scenario glows, asking to be confirmed (the landing mock-up and the chat's changeset) */
.ks-glow { animation: ks-glow 2.8s ease-in-out infinite; }
@keyframes ks-glow {
    0%, 100% { box-shadow: inset 0 0 0 0 color-mix(in oklab, var(--color-secondary) 0%, transparent); }
    50%      { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--color-secondary) 45%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
    .ks-blob, .ks-rise, .ks-pop, .ks-joined, .ks-glow { animation: none !important; }
    .ks-tilt, .ks-lift, .ks-offset { transition: none; }
    .ks-lift:hover { transform: none; }
}
