/* projects.css: the Projects section. A scroll-driven 3D flight over the four flagship
   platforms (projects-flight.js) and a living visual for every other project (projects-cards.js).
   Colours and fonts come from the tokens in system.css. */

#projects { --radius-card: 14px; padding: 0 0 var(--section-pad); background-color: var(--band); }

#projects .eyebrow {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 10px;
}

/* The flight is full-bleed, so drop the shared section padding at the top; the heading supplies it */
body > section#projects[id] { padding-top: 0; }

/* Line the flight's heading, panels and progress up with the site container */
#projects .flight-head { top: 96px; }
#projects .flight-head,
#projects .flight-panels { left: max(var(--gutter), calc((100% - 1200px) / 2 + var(--gutter))); }
#projects .flight-progress { right: max(var(--gutter), calc((100% - 1200px) / 2 + var(--gutter))); }
#projects .flight-title { font-size: var(--fs-h2); line-height: 1.2; letter-spacing: -0.01em; }

.panel-more,
.case-link {
    font: inherit;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.panel-more {
    margin-left: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: rgba(60, 214, 240, 0.6);
}
.panel-more:hover { color: var(--accent); }
.case-link { color: var(--text); font-size: 13px; font-weight: 600; margin-left: auto; }
.case-link i { color: var(--accent); margin-left: 4px; transition: transform 0.2s ease; }
.case-link:hover i { transform: translateX(3px); }
.viz-content .links { align-items: center; }

#projects .projects-packages { margin-top: 80px; }

/* ==========================================================================
   Part 1: flight
   ========================================================================== */
.flight { position: relative; height: 520vh; }

.flight-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
}

.flight-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.flight-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(11, 22, 41, 0.92) 0%, rgba(11, 22, 41, 0.55) 34%, transparent 60%),
        linear-gradient(180deg, rgba(11, 22, 41, 0.7) 0%, transparent 18%, transparent 80%, rgba(11, 22, 41, 0.9) 100%);
}

.flight-head {
    position: absolute;
    top: 84px;
    left: clamp(20px, 6vw, 88px);
    z-index: 2;
}
.flight-title {
    font-family: var(--font-head);
    font-weight: 650;
    font-size: clamp(28px, 3.4vw, 44px);
    line-height: 1.1;
    margin: 0;
}

.flight-panels {
    position: absolute;
    left: clamp(20px, 6vw, 88px);
    top: 50%;
    transform: translateY(-44%);
    width: min(440px, calc(100vw - 40px));
    z-index: 2;
}

.flight-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    transform: translateY(28px);
    filter: blur(6px);
    pointer-events: none;
    transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.6s ease;
}
.flight-panel.is-active { opacity: 1; transform: none; filter: none; pointer-events: auto; }

.panel-kicker {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 12px;
}
.panel-kicker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.flight-panel h3 {
    font-family: var(--font-head);
    font-weight: 650;
    font-size: clamp(44px, 6vw, 76px);
    line-height: 0.95;
    letter-spacing: -0.02em;
    margin: 0;
}
.panel-sub { color: var(--accent); font-size: 17px; margin: 10px 0 16px; }
.panel-body { color: var(--muted); line-height: 1.65; font-size: 16px; margin: 0 0 18px; }
.panel-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 20px; }
.panel-tags li {
    font-family: var(--font-mono);
    font-size: 11.5px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    background: rgba(11, 22, 41, 0.6);
}
.panel-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    color: var(--accent-ink);
    background: var(--accent);
    padding: 10px 16px;
    border-radius: 8px;
}
.panel-link:hover { background: #7ae4f5; }

.flight-progress {
    position: absolute;
    right: clamp(16px, 4vw, 56px);
    top: 50%;
    transform: translateY(-50%);
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 2;
    display: grid;
    gap: 18px;
}
.flight-progress li {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    opacity: 0.55;
    transition: opacity 0.3s ease, color 0.3s ease;
}
.flight-progress li::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--muted);
    transition: all 0.3s ease;
}
.flight-progress li.is-active { opacity: 1; color: var(--text); }
.flight-progress li.is-active::after { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent); }

.flight-hint {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    z-index: 2;
    margin: 0;
    animation: hint 2.4s ease-in-out infinite;
}
@keyframes hint { 50% { transform: translate(-50%, 6px); opacity: 0.5; } }

/* Static fallback: no pinning, panels in a column, canvas as a backdrop */
.flight.is-static { height: auto; }
.flight.is-static .flight-sticky { position: relative; height: auto; padding: 120px 0 64px; }
.flight.is-static .flight-head { position: relative; top: 0; padding: 0 clamp(20px, 6vw, 88px); margin-bottom: 32px; }
.flight.is-static .flight-panels { position: relative; top: 0; transform: none; width: auto; padding: 0 clamp(20px, 6vw, 88px); display: grid; gap: 48px; }
.flight.is-static .flight-panel { position: relative; opacity: 1; transform: none; filter: none; pointer-events: auto; max-width: 560px; }
.flight.is-static .flight-progress, .flight.is-static .flight-hint { display: none; }
.flight.is-static .flight-canvas { opacity: 0.35; }

@media (max-width: 760px) {
    .flight-vignette {
        background: linear-gradient(180deg, rgba(11, 22, 41, 0.85) 0%, rgba(11, 22, 41, 0.2) 30%, rgba(11, 22, 41, 0.3) 45%, rgba(11, 22, 41, 0.95) 70%);
    }
    .flight-head { top: 72px; }
    .flight-panels { top: auto; bottom: 64px; transform: none; }
    .flight-panel { top: auto; bottom: 0; }
    .flight-panel h3 { font-size: 44px; }
    .panel-body { font-size: 15px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
    .flight-progress { top: auto; bottom: 26px; right: auto; left: 50%; transform: translateX(-50%); grid-auto-flow: column; gap: 14px; }
    .flight-progress li span { display: none; }
    .flight-panels { bottom: 72px; }
    .flight-hint { display: none; }
}

/* ==========================================================================
   Part 2: a living visual per project
   ========================================================================== */

.stacks-head { margin: 0 0 40px; padding-top: 96px; }
.stacks-title { font-family: var(--font-head); font-weight: 650; font-size: clamp(26px, 3vw, 36px); line-height: 1.2; color: var(--text); margin: 0 0 10px; }
.stacks-lead { color: var(--muted); margin: 0; }

.viz-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.viz-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.3s ease, box-shadow 0.3s ease;
}
.viz-card.is-wide { grid-column: span 2; }
.viz-card:hover {
    transform: translateY(-4px);
    border-color: rgba(60, 214, 240, 0.45);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}
.viz-card::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(500px circle at var(--mx, 50%) var(--my, 0%), rgba(60, 214, 240, 0.08), transparent 45%);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.viz-card:hover::after { opacity: 1; }

.viz {
    position: relative;
    height: 260px;
    border-bottom: 1px solid var(--line);
    background: var(--ink);
    touch-action: pan-y;
}
.viz svg { width: 100%; height: 100%; display: block; }
.viz-hint {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text);
    background: rgba(11, 22, 41, 0.8);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.viz-hint i { color: var(--accent); margin-right: 4px; }
.viz-card:hover .viz-hint { opacity: 1; transform: none; }
@media (hover: none) { .viz-hint { opacity: 1; transform: none; } }

.viz-content { padding: 22px 24px 24px; display: flex; flex-direction: column; flex: 1; }
.viz-content .kicker { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin: 0 0 8px; }
.viz-content h3 { font-family: var(--font-head); font-weight: 650; font-size: 21px; line-height: 1.25; margin: 0 0 8px; }
.viz-card.is-wide .viz-content h3 { font-size: 26px; }
.viz-content p { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0 0 14px; }
.viz-content .links { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; margin-top: auto; }
.viz-content .links a { color: var(--accent); text-decoration: none; }
.viz-content .links a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Entrance */
.js-motion .viz-card { opacity: 0; translate: 0 30px; transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.7s ease, translate 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.js-motion .viz-card.is-in { opacity: 1; translate: 0 0; }

@media (max-width: 1024px) {
    .viz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    .viz-grid { grid-template-columns: minmax(0, 1fr); }
    .viz-card.is-wide { grid-column: auto; }
    .viz { height: 230px; }
    .viz-card.is-wide .viz { height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
    #projects *, #projects *::before, #projects *::after { transition: none !important; animation: none !important; }
}

/* Shorter laptop screens: tighten the panel so its buttons stay on screen */
@media (min-width: 761px) and (max-height: 760px) {
    .flight-panel h3 { font-size: 52px; }
    .panel-body { font-size: 15px; margin-bottom: 14px; }
    .flight-hint { display: none; }
}

/* ==========================================================================
   Client websites: web work outside GIS. Deliberately quieter than the GIS projects
   above: neutral colours, no glow, no 3D; just a slow scroll preview of each site.
   ========================================================================== */
.client-work { margin-top: 96px; }

.client-divider {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 0;
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}
.client-divider::-webkit-details-marker { display: none; }
.client-divider::before,
.client-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); transition: background 0.3s ease; }
.client-divider:hover::before,
.client-divider:hover::after { background: rgba(232, 238, 246, 0.25); }
.client-divider:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 6px; }

/* The "Show / Hide" pill in the middle of the divider */
.client-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    letter-spacing: 0.08em;
    transition: border-color 0.25s ease, background 0.25s ease;
}
.client-divider:hover .client-toggle { border-color: rgba(232, 238, 246, 0.35); background: rgba(232, 238, 246, 0.04); }
.client-toggle i { font-size: 10px; transition: transform 0.3s ease; }
.client-work[open] .client-toggle i { transform: rotate(180deg); }
.client-work .when-open { display: none; }
.client-work[open] .when-open { display: inline; }
.client-work[open] .when-closed { display: none; }

.client-panel { padding-top: 40px; }
.client-work[open] .client-panel { animation: client-open 0.5s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes client-open { from { opacity: 0; transform: translateY(-10px); } }

.client-head { max-width: 760px; margin: 0 0 28px; }
.client-title {
    font-family: var(--font-head);
    font-weight: 650;
    font-size: 24px;
    line-height: 1.25;
    color: var(--text);
    margin: 0 0 8px;
}
.client-lead { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0; }

.client-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.client-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(232, 238, 246, 0.02);
    overflow: hidden;
    transition: border-color 0.3s ease, background 0.3s ease;
}
.client-card:hover { border-color: rgba(232, 238, 246, 0.22); background: rgba(232, 238, 246, 0.035); }

/* Browser frame with a full-page screenshot that scrolls on hover */
.client-shot { display: block; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.client-chrome {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 10px;
    background: #0d1626;
}
.client-chrome i { width: 7px; height: 7px; border-radius: 50%; background: #2b3a52; }
.client-url {
    flex: 1;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 5px;
    background: rgba(232, 238, 246, 0.05);
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.client-frame { display: block; aspect-ratio: 16 / 11; overflow: hidden; background: #0a1120; }
.client-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 0%;
    transition: object-position 7s cubic-bezier(0.45, 0, 0.55, 1);
}
.client-shot:hover .client-frame img,
.client-shot:focus-visible .client-frame img,
.client-card.is-previewing .client-frame img { object-position: 50% 100%; }

.client-body { display: flex; flex-direction: column; flex: 1; padding: 18px 18px 20px; }
.client-kicker { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin: 0 0 6px; }
.client-name { font-family: var(--font-body); font-weight: 600; font-size: 17px; color: var(--text); margin: 0 0 10px; }
.client-roles, .client-stack { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.client-roles li {
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid rgba(232, 238, 246, 0.28);
    white-space: nowrap;
}
.client-desc { flex: 1; color: var(--muted); font-size: 14px; line-height: 1.6; margin: 12px 0 18px; text-align: left; hyphens: manual; -webkit-hyphens: manual; }

/* "Built with": even chips instead of a dotted line that wraps unevenly */
.client-stack-label {
    margin: 0 0 8px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6f83a0;
}
.client-stack { gap: 5px; margin-bottom: 18px; align-content: flex-start; }
/* Room for three rows of chips, so "Built with" lines up across the four cards */
@media (min-width: 1101px) { .client-stack { min-height: 68px; } }
.client-stack li {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    color: #c3cfdf;
    padding: 2px 7px;
    border-radius: 5px;
    background: rgba(232, 238, 246, 0.05);
    white-space: nowrap;
}
.client-visit {
    align-self: flex-start;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: rgba(232, 238, 246, 0.35);
}
.client-visit:hover { text-decoration-color: var(--text); }
.client-visit i { font-size: 11px; margin-left: 3px; color: var(--muted); }


@media (max-width: 1100px) { .client-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
    .client-work { margin-top: 72px; }
    .client-grid { grid-template-columns: minmax(0, 1fr); }
    .client-divider { font-size: 10.5px; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { .client-frame img { transition: none; } .client-work[open] .client-panel { animation: none; } }

/* ==========================================================================
   IoT card: real demo footage instead of an illustration
   ========================================================================== */
.viz-video {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    overflow: hidden;
    background: #05080f;
    font: inherit;
    color: inherit;
}
.viz-video img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 40%;
    transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.4s ease;
    filter: saturate(0.95) brightness(0.85);
}
.viz-video:hover img, .viz-video:focus-visible img { transform: scale(1.04); filter: saturate(1.05) brightness(1); }
.viz-play {
    position: absolute;
    left: 50%;
    top: 46%;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 20px;
    box-shadow: 0 0 0 8px rgba(60, 214, 240, 0.18), 0 12px 30px rgba(0, 0, 0, 0.45);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.viz-play i { margin-left: 4px; }
.viz-video:hover .viz-play, .viz-video:focus-visible .viz-play { transform: scale(1.08); box-shadow: 0 0 0 12px rgba(60, 214, 240, 0.16), 0 12px 30px rgba(0, 0, 0, 0.45); }
.viz-video-label {
    position: absolute;
    left: 12px;
    bottom: 12px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(7, 13, 26, 0.85);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text);
}
.viz-video:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The demo inside the project pop-up */
.project-modal-video { margin: 0 0 28px; }
.project-modal-video video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #05080f;
}
.project-modal-video figcaption { margin-top: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* UMAMI studio demos: one tab per studio above a shared player */
.project-modal-demos { margin: 0 0 28px; }
.project-modal-demos .project-modal-video { margin: 0; }
.demo-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.demo-tab {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.demo-tab span { font-family: var(--font-mono); font-size: 11px; font-weight: 400; }
.demo-tab:hover { color: var(--text); border-color: rgba(60, 214, 240, 0.5); }
.demo-tab.is-active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* "Watch demo" link inside the studio list */
.demo-link {
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(60, 214, 240, 0.1);
    border: 1px solid rgba(60, 214, 240, 0.35);
    border-radius: 999px;
    padding: 1px 9px;
    margin-left: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.demo-link i { font-size: 9px; margin-right: 3px; }
.demo-link:hover { background: rgba(60, 214, 240, 0.2); }

/* The flight panel's watch button */
.panel-watch { color: var(--accent); text-decoration-color: rgba(60, 214, 240, 0.6); }
.panel-watch i { font-size: 11px; margin-right: 4px; }
