/* Food Log case study: screenshots, data-flow diagram, trend explainer and stack graphic. Uses the site tokens from bundle.css. */

/* ---------- Figures: one frame, one caption style ---------- */

.fl-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.fl-figure,
.fl-shots {
    margin: var(--s6) 0;
}

.fl-figure figcaption,
.fl-shots figcaption {
    max-width: none;
    margin-top: var(--s3);
    font-family: var(--mono);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--fg-muted);
}

.fl-figure .fl-panel {
    position: relative;
    padding: var(--s5);
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-sunk);
}

/* One icon style for every diagram: 1.5px outline in the link colour. */
.fl-ico {
    flex: none;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: var(--tone, var(--link));
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- Screenshots ---------- */

.fl-shot-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s5);
}

.fl-shot {
    margin: 0;
}

.fl-shot img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--bg-sunk);
}

.fl-shot-label {
    display: block;
    margin-top: var(--s2);
    font-family: var(--mono);
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-muted);
}

@media (max-width: 520px) {
    .fl-shot-row {
        gap: var(--s3);
    }
}

/* ---------- Tiers: one tone each, shared by the flow diagram and the stack graphic ---------- */

.fl-figure {
    --tone-phone: #80dbe9;
    --tone-cf: #b9aef2;
    --tone-pc: #e6cf9a;
}

.fl-t-phone { --tone: var(--tone-phone); }
.fl-t-cf { --tone: var(--tone-cf); }
.fl-t-pc { --tone: var(--tone-pc); }

/* ---------- Data flow: three zones and the plan ---------- */

.fl-figure .fl-arch {
    --fl-gutter: 0px;
    padding-left: calc(var(--s5) + var(--fl-gutter));
}

.fl-figure .fl-arch[data-layout="stack"] {
    --fl-gutter: 22px;
}

.fl-nodes {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 3rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fl-zone {
    display: flex;
    flex-direction: column;
    gap: var(--s4);
    padding: var(--s4);
    border: 1px solid color-mix(in srgb, var(--tone) 38%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--tone) 9%, var(--bg-color));
}

.fl-zone-head {
    display: flex;
    align-items: center;
    gap: var(--s3);
    margin: 0;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
}

.fl-zone-head .fl-ico {
    box-sizing: content-box;
    width: 28px;
    height: 28px;
    padding: 8px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--tone) 18%, var(--bg-color));
    stroke-width: 1.4;
}

.fl-zone-nodes {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fl-n {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s2) var(--s3);
    border-radius: 999px;
    background: color-mix(in srgb, var(--tone) 16%, var(--bg-color));
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
}

.fl-n code {
    font-size: inherit;
    padding: 0;
    background: none;
}

.fl-n--agent {
    background: transparent;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 55%, transparent);
}

/* The plan comes back to me: a plain band, no tone. */
.fl-plan {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--bg-lighter);
}

.fl-plan .fl-ico {
    stroke: var(--fg-color);
}

.fl-plan-name {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1rem;
}

.fl-plan-note {
    display: block;
    font-size: 0.875rem;
    color: var(--fg-muted);
}

.fl-wires {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.fl-wire {
    fill: none;
    stroke: var(--fg-muted);
    stroke-width: 1.5;
}

.fl-wire--inner {
    stroke: var(--border-strong);
}

.fl-wire--loop {
    stroke-dasharray: 4 5;
}

.fl-arrow {
    fill: var(--fg-muted);
}

.fl-wire-label {
    fill: var(--fg-body);
    font-family: var(--mono);
    font-size: 12px;
}

.fl-wire-label--inner {
    fill: var(--fg-muted);
    font-size: 11px;
}

/* Wide: a clockwise cycle. Phone, Cloudflare, then down to my computer, then the plan back to the phone. */
.fl-arch[data-layout="grid"] .fl-nodes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 5.5rem;
}

.fl-arch[data-layout="grid"] .fl-t-phone { grid-area: 1 / 1; }
.fl-arch[data-layout="grid"] .fl-t-cf { grid-area: 1 / 2; }
.fl-arch[data-layout="grid"] .fl-t-pc { grid-area: 2 / 2; }
.fl-arch[data-layout="grid"] .fl-plan { grid-area: 2 / 1; align-self: center; }

.fl-arch[data-layout="stack"] .fl-zone-nodes {
    flex: none;
}

/* ---------- Trend explainer ---------- */

#fl-trend:not(.fl-ready) .fl-panel {
    display: none;
}

#fl-trend svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.fl-grid {
    stroke: var(--border);
    stroke-width: 1;
}

.fl-label {
    fill: var(--fg-muted);
    font-family: var(--mono);
    font-size: 12px;
}

.fl-note {
    fill: var(--fg-muted);
    font-family: var(--mono);
    font-size: 12px;
}

.fl-note--trend {
    fill: var(--link);
}

.fl-gap {
    fill: var(--bg-lighter);
    stroke: var(--border-strong);
    stroke-width: 1;
    stroke-dasharray: 2 3;
}

.fl-dot {
    fill: var(--role);
}

.fl-ring {
    fill: none;
    stroke: var(--fg-color);
    stroke-width: 1.5;
}

.fl-stem {
    stroke: var(--role);
    stroke-opacity: 0.45;
    stroke-width: 1;
}

.fl-line {
    fill: none;
    stroke: var(--link);
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.fl-readout {
    margin: var(--s3) 0 0;
    max-width: none;
    min-height: 4.5em;
    font-family: var(--mono);
    font-size: 0.875rem;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.fl-readout span {
    display: block;
}

.fl-readout span + span {
    color: var(--fg-muted);
}

.fl-controls {
    margin-top: var(--s3);
}

.fl-controls .button {
    min-height: 44px;
}

@media (max-width: 480px) {
    .fl-figure .fl-panel {
        padding: var(--s4);
    }

    .fl-figure .fl-arch {
        padding-left: calc(var(--s4) + var(--fl-gutter));
    }

    .fl-readout {
        min-height: 6em;
    }
}

/* ---------- Stack ---------- */

.fl-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s4);
}

.fl-tier {
    padding: var(--s4);
    border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--tone) 14%, var(--bg-color));
}

.fl-tier-head {
    display: flex;
    align-items: center;
    gap: var(--s2);
    margin: 0;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.fl-tier-head .fl-ico {
    box-sizing: content-box;
    width: 22px;
    height: 22px;
    padding: 5px;
    flex: none;
    border-radius: 9px;
    background: color-mix(in srgb, var(--tone) 28%, var(--bg-color));
}

.fl-tier-sub {
    margin: var(--s2) 0 var(--s3);
    font-size: 0.875rem;
    color: var(--fg-muted);
}

.fl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.fl-chips li {
    padding: 2px var(--s3);
    border-radius: 999px;
    background: color-mix(in srgb, var(--tone) 30%, var(--bg-color));
    color: var(--fg-color);
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* Shared code is not a fourth place: a band under all three, striped with their tones. */
.fl-shared {
    grid-column: 1 / -1;
    margin: 0;
    padding: var(--s4) var(--s4) var(--s3);
    max-width: none;
    border-radius: 4px;
    background:
        linear-gradient(90deg, var(--tone-phone), var(--tone-cf), var(--tone-pc)) top / 100% 4px no-repeat,
        var(--bg-lighter);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--fg-body);
}

.fl-shared span {
    margin-right: var(--s2);
    font-family: var(--mono);
    font-weight: 600;
    color: var(--fg-color);
}

.fl-legal {
    margin-top: var(--s6);
    font-size: 0.8125rem;
    color: var(--fg-muted);
}

@media (max-width: 720px) {
    .fl-stack {
        grid-template-columns: minmax(0, 1fr);
    }
}
