/* AI Planter · identifier page figure, 2026-11
   Four stages of the on-device pipeline, in the order they run.
   Base state is the finished figure; the sequence only plays when the
   script adds .vi-in, so a failed script leaves a readable diagram. */

.page-identifier {
    --vi-paper: #fbfcf7;
    --vi-ink: #17281f;
    --vi-moss: #2c6248;
    --vi-line: rgba(60, 84, 66, 0.16);
    --vi-line-2: rgba(60, 84, 66, 0.3);
}

.vi-fig {
    margin: 6px 0 40px;
    padding: 30px 26px 0;
    border: 1px solid var(--vi-line);
    border-radius: 18px;
    background: var(--vi-paper);
}
.vi-rail {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}
.vi-stage {
    position: relative;
    padding: 0 18px 18px;
    border-left: 1px solid var(--vi-line);
}
.vi-stage:first-child { border-left: 0; padding-left: 4px; }
.vi-stage:last-child { padding-right: 4px; }

.vi-art {
    max-width: 190px;
    margin: 0 auto 16px;
    aspect-ratio: 1 / 1;
}
.vi-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.vi-cap {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: 210px;
    margin: 0 auto;
}
.vi-cap b {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--vi-ink);
}
.vi-cap span {
    font-size: 12.5px;
    line-height: 1.5;
    color: #66706a;
}
.vi-note {
    margin: 0 -26px;
    padding: 16px 26px 18px;
    border-top: 1px solid var(--vi-line);
    font-size: 12.5px;
    line-height: 1.6;
    color: #6b746d;
}

/* stage 1 — the photo */
.vi-photo-bg { fill: #eef2e3; }
.vi-photo-leaf { fill: #35704f; stroke: #1a2b22; stroke-width: 1; stroke-linejoin: round; }
.vi-photo-stem { fill: none; stroke: #2a6046; stroke-width: 3; stroke-linecap: round; }
.vi-crop { fill: none; stroke: #8a958c; stroke-width: 1; }

/* stage 2 — the mask */
.vi-frame { fill: #f4f6ee; stroke: var(--vi-line-2); stroke-width: 1; }
.vi-mask { fill: #1c2f24; fill-opacity: 0.88; }
.vi-bbox {
    fill: none;
    stroke: var(--vi-moss);
    stroke-width: 1;
    stroke-dasharray: 4 4;
    opacity: 0.55;
}
.vi-scan {
    fill: none;
    stroke: #6f9481;
    stroke-width: 1.2;
    opacity: 0;
    transform-box: fill-box;
}
.vi-ticks { stroke: var(--vi-line-2); stroke-width: 1; }

/* stage 3 — features */
.vi-cell { fill: var(--vi-moss); fill-opacity: calc(var(--t) / 130); }
.vi-cell-off { fill: #dfe6d9; fill-opacity: 1; }

/* stage 4 — ranking */
.vi-bars {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 13px;
    height: 100%;
    padding: 4px 2px;
}
.vi-bar {
    position: relative;
    display: block;
    padding-top: 13px;
    border-bottom: 1px solid var(--vi-line);
}
.vi-bar-fill {
    display: block;
    height: 8px;
    width: calc(var(--w) * 1%);
    background: linear-gradient(90deg, #2c6248, #4f8464);
    transform-origin: left center;
    border-radius: 0 2px 2px 0;
}
.vi-bar-name {
    position: absolute;
    left: 0;
    top: -1px;
    font-size: 10.5px;
    line-height: 1.2;
    letter-spacing: 0.01em;
    color: #4f5a53;
    white-space: nowrap;
}
.vi-bar:nth-child(1) .vi-bar-fill { background: #2c6248; }
.vi-bar:nth-child(2) .vi-bar-fill { background: #46795c; }
.vi-bar:nth-child(3) .vi-bar-fill { background: #639478; }
.vi-bar:nth-child(4) .vi-bar-fill { background: #85ab95; }

/* ---- the sequence -------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    .vi-fig.vi-in .vi-stage { animation: viStage 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
    .vi-fig.vi-in .vi-s1 { animation-delay: 40ms; }
    .vi-fig.vi-in .vi-s2 { animation-delay: 220ms; }
    .vi-fig.vi-in .vi-s3 { animation-delay: 400ms; }
    .vi-fig.vi-in .vi-s4 { animation-delay: 580ms; }

    .vi-fig.vi-in .vi-mask {
        animation: viMask 900ms cubic-bezier(0.3, 0, 0.2, 1) 300ms both;
    }
    .vi-fig.vi-in .vi-bbox {
        animation: viBox 700ms ease 900ms both;
    }
    .vi-fig.vi-in .vi-scan {
        animation: viScan 1100ms cubic-bezier(0.4, 0, 0.3, 1) 900ms both;
    }
    .vi-fig.vi-in .vi-cell {
        animation: viCell 520ms ease both;
        animation-delay: calc(560ms + var(--i) * 34ms);
    }
    .vi-fig.vi-in .vi-bar-fill {
        animation: viBar 800ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
        animation-delay: calc(640ms + var(--d, 0) * 110ms);
    }
    .vi-fig.vi-in .vi-bar:nth-child(1) .vi-bar-fill { --d: 0; }
    .vi-fig.vi-in .vi-bar:nth-child(2) .vi-bar-fill { --d: 1; }
    .vi-fig.vi-in .vi-bar:nth-child(3) .vi-bar-fill { --d: 2; }
    .vi-fig.vi-in .vi-bar:nth-child(4) .vi-bar-fill { --d: 3; }

    .vi-fig.vi-in .vi-photo-leaf {
        animation: viPhoto 800ms cubic-bezier(0.3, 0, 0.2, 1) both;
    }
}

@keyframes viStage {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes viMask {
    from { clip-path: inset(100% 0 0 0); }
    to { clip-path: inset(0 0 0 0); }
}
@keyframes viBox {
    from { opacity: 0; }
    to { opacity: 0.55; }
}
@keyframes viScan {
    0% { opacity: 0; transform: translateY(-56px); }
    12% { opacity: 0.9; }
    80% { opacity: 0.9; }
    100% { opacity: 0; transform: translateY(56px); }
}
@keyframes viCell {
    from { opacity: 0; transform: scale(0.86); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes viBar {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}
/* The leaf path carries its own transform attribute for placement inside the
   photo frame. Animate the independent `translate` property so it composes
   with that attribute instead of replacing it. */
@keyframes viPhoto {
    from { opacity: 0; translate: 0 8px; }
    to { opacity: 1; translate: 0 0; }
}

/* ---- responsive ---------------------------------------------------- */
@media (max-width: 900px) {
    .vi-fig { padding: 22px 18px 0; }
    .vi-rail { grid-template-columns: repeat(2, 1fr); gap: 0; }
    .vi-stage { padding: 0 12px 22px; }
    .vi-stage:nth-child(3) { border-left: 0; }
    .vi-stage:nth-child(n+3) { border-top: 1px solid var(--vi-line); padding-top: 22px; }
    .vi-note { margin: 0 -18px; padding: 14px 18px 16px; }
}
@media (max-width: 560px) {
    .vi-rail { grid-template-columns: 1fr; }
    .vi-stage { border-left: 0; border-top: 1px solid var(--vi-line); padding: 20px 0; }
    .vi-stage:first-child { border-top: 0; padding-top: 4px; }
    .vi-art { max-width: 160px; }
    .vi-cap { max-width: none; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    .vi-fig.vi-in .vi-stage,
    .vi-fig.vi-in .vi-mask,
    .vi-fig.vi-in .vi-bbox,
    .vi-fig.vi-in .vi-scan,
    .vi-fig.vi-in .vi-cell,
    .vi-fig.vi-in .vi-bar-fill,
    .vi-fig.vi-in .vi-photo-leaf { animation: none; }
    .vi-scan { opacity: 0; }
}
