/* ═══════════════════════════════════════════════════════════════════════════
   Case study — v2 reading format
   Layered on top of project-pages.css (shared template). Each project keeps
   its own --primary / --gradient, so per-project branding still applies.
   ═══════════════════════════════════════════════════════════════════════════ */

body.is-case,
body:has(> section.hero) {
    background: var(--bg-secondary);
}

body.dark-mode.is-case {
    background: #121212;
}

/* The section-level fade is replaced by per-element reveals in motion-ui.js */
.m-on .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */

section.hero {
    min-height: 100vh;
    min-height: 100svh;
    padding: 8rem 0 7rem;
    border-radius: 0 0 clamp(28px, 4vw, 56px) clamp(28px, 4vw, 56px);
    isolation: isolate;
}

section.hero::before {
    background:
        radial-gradient(40% 50% at 85% 15%, rgba(255, 0, 110, 0.22), transparent 70%),
        radial-gradient(45% 55% at 10% 90%, rgba(255, 255, 255, 0.14), transparent 70%);
    opacity: 1;
}

section.hero::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 64px 64px;
    -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000, transparent 75%);
    mask-image: radial-gradient(70% 60% at 50% 40%, #000, transparent 75%);
}

.hero-container {
    width: 100%;
}

.hero-content {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(2rem, 5vw, 5rem);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
}

.hero-title {
    font-size: clamp(3.2rem, 8.5vw, 7rem);
    font-weight: 800;
    letter-spacing: -0.055em;
    line-height: 0.95;
    margin-bottom: 1.5rem;
    background: none;
    color: #fff;
    -webkit-text-fill-color: #fff;
}

.hero-subtitle {
    font-size: 1.2rem;
    max-width: 46ch;
    opacity: 0.92;
}

.hero-stats {
    gap: 0;
    margin-bottom: 2.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.hero-stats .stat {
    flex: 1;
    padding: 1.1rem 1.25rem 1.1rem 0;
    text-align: left;
}

.hero-stats .stat + .stat {
    padding-left: 1.25rem;
    border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.stat-number {
    font-size: clamp(1.6rem, 2.8vw, 2.3rem);
    letter-spacing: -0.04em;
    line-height: 1.1;
    text-shadow: none;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    line-height: 1.35;
}

.btn {
    min-height: 52px;
    padding: 0 1.6rem;
    border-radius: 999px;
}

.btn-primary {
    box-shadow: 0 16px 40px rgba(2, 8, 23, 0.25);
}

.hero-visual {
    perspective: 1200px;
}

.hero-image,
.hero-image:hover {
    border-radius: 22px;
    transform: none;
    box-shadow: 0 50px 100px -20px rgba(2, 8, 23, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.18);
    will-change: transform;
}

.floating-element {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    box-shadow: 0 18px 40px rgba(2, 8, 23, 0.25);
    animation: none;
}

.floating-element i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--gradient);
    color: #fff;
    font-size: 0.8rem;
}

.floating-element small {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

html:not(.m-on) .floating-element {
    animation: float 6s ease-in-out infinite;
}

/* ── Sections ──────────────────────────────────────────────────────────────── */

.section {
    padding: clamp(5rem, 9vw, 8rem) 0;
}

.section.problem,
.section.process,
.section.gallery {
    background: transparent;
}

.section-header {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: end;
    gap: 1.25rem 4rem;
    text-align: left;
    margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.cs-eyebrow {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.cs-eyebrow__num {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.cs-eyebrow__line {
    width: 48px;
    height: 1px;
    background: var(--border);
}

body.dark-mode .cs-eyebrow__line {
    background: rgba(255, 255, 255, 0.16);
}

.section-badge {
    margin: 0;
    padding: 0;
    background: none;
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    border-radius: 0;
}

.section-title {
    margin: 0;
    font-size: clamp(2.3rem, 5vw, 4.25rem);
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 1.02;
    background: none;
    color: var(--text);
    -webkit-text-fill-color: currentColor;
}

.section-subtitle {
    margin: 0;
    max-width: 48ch;
    font-size: 1.1rem;
    line-height: 1.65;
}

.section-header > :only-child,
.section-header .section-subtitle:first-child {
    grid-column: 1 / -1;
}

/* ── Meta: one spec strip ──────────────────────────────────────────────────── */

.project-meta-grid {
    gap: 0;
    margin-top: 0;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg);
    overflow: hidden;
}

.meta-card,
.meta-card:hover {
    border-radius: 0;
    box-shadow: none;
    transform: none;
    background: transparent;
    padding: 1.6rem 1.75rem;
    grid-template-columns: 1fr;
    gap: 0.9rem;
    align-items: start;
}

.meta-card + .meta-card {
    border-left: 1px solid var(--border);
}

.meta-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 0.9rem;
}

.meta-content h3 {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
}

.meta-content p {
    font-size: 1rem;
    font-weight: 600;
}

body.dark-mode .project-meta-grid {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .meta-card + .meta-card {
    border-color: rgba(255, 255, 255, 0.08);
}

/* ── Overview: editorial lead ──────────────────────────────────────────────── */

.overview-content {
    max-width: none;
}

.overview-text,
body.dark-mode .overview-text {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem 4rem;
    padding: 0;
    background: none;
    box-shadow: none;
}

.overview-text p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.8;
}

.overview-text p:first-child {
    grid-column: 1 / -1;
    max-width: 30ch;
    font-size: clamp(1.3rem, 2.1vw, 1.8rem);
    font-weight: 500;
    letter-spacing: -0.025em;
    line-height: 1.3;
    color: var(--text);
}

@media (min-width: 900px) {
    .overview-text p:first-child { max-width: 52ch; }
}

/* The spec strip sits right under the hero */
section.hero + .section {
    padding: 3.5rem 0 0;
}

/* ── Problem cards ─────────────────────────────────────────────────────────── */

.problem-grid {
    margin-top: 0;
    gap: 1.25rem;
    counter-reset: problem;
}

.problem-card {
    counter-increment: problem;
    position: relative;
    padding: 2rem;
    border: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg);
    box-shadow: none;
    overflow: hidden;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.5s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.3s ease;
}

.problem-card::before {
    content: counter(problem, decimal-leading-zero);
    position: absolute;
    top: 1.5rem;
    right: 1.75rem;
    font-size: 3.4rem;
    font-weight: 800;
    letter-spacing: -0.06em;
    line-height: 1;
    color: transparent;
    -webkit-text-stroke: 1.2px var(--border);
}

.problem-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 30px 60px -20px rgba(2, 8, 23, 0.2);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

.problem-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 1.15rem;
    margin-bottom: 1.5rem;
}

.problem-title {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

body.dark-mode .problem-card {
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .problem-card::before {
    -webkit-text-stroke-color: rgba(255, 255, 255, 0.12);
}

/* ── Solution ──────────────────────────────────────────────────────────────── */

.solution-grid {
    margin-top: 0;
    align-items: start;
}

.solution-content {
    padding: 0;
}

.solution-content > h3 {
    font-size: clamp(1.6rem, 2.6vw, 2.1rem) !important;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-top: 0;
}

.solution-features li {
    align-items: flex-start;
    padding: 1.1rem 1.25rem;
    border: 1px solid transparent;
    background: var(--bg);
    border-radius: 16px;
    transition: border-color 0.3s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.solution-features li:hover {
    background: var(--bg);
    color: inherit;
    border-color: color-mix(in srgb, var(--primary) 35%, transparent);
    transform: translateX(6px);
}

.solution-features li span {
    color: var(--text-light);
}

.solution-image {
    position: sticky;
    top: 7rem;
}

.solution-image img {
    border-radius: 22px;
    box-shadow: 0 40px 80px -24px rgba(2, 8, 23, 0.35);
}

body.dark-mode .solution-features li {
    background: #1a1a1a;
}

/* ── Process: scroll-drawn rail ────────────────────────────────────────────── */

.process-steps {
    margin-top: 0;
}

.process-steps.has-rail {
    position: relative;
    gap: 2rem;
}

.cs-rail {
    position: absolute;
    top: 30px;
    bottom: 30px;
    left: 29px;
    width: 2px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.cs-rail__fill {
    position: absolute;
    inset: 0;
    background: var(--gradient);
    transform-origin: 50% 0;
    transform: scaleY(0);
}

html:not(.m-on) .cs-rail__fill { transform: none; }

body.dark-mode .cs-rail { background: rgba(255, 255, 255, 0.1); }

.has-rail .process-step,
.has-rail .process-step:hover {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: clamp(1.25rem, 3vw, 2.5rem);
    padding: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    transform: none;
}

body.dark-mode .has-rail .process-step {
    background: transparent;
}

.has-rail .process-step::before {
    display: none;
}

.has-rail .step-number {
    position: sticky;
    top: 42vh;
    z-index: 1;
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text-light);
    font-size: 1.2rem;
    transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.has-rail .step-number.is-lit {
    background: var(--gradient);
    border-color: transparent;
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 14%, transparent);
}

body.dark-mode .has-rail .step-number {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.12);
}

.has-rail .step-content {
    position: relative;
    padding: clamp(1.75rem, 3vw, 2.5rem);
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--bg);
}

body.dark-mode .has-rail .step-content {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
}

.step-title {
    font-size: clamp(1.35rem, 2.2vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.step-description {
    font-size: 1.02rem;
    line-height: 1.8;
}

/* ── Results ───────────────────────────────────────────────────────────────── */

.results-grid {
    margin-top: 0;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.result-card,
.result-card:hover {
    text-align: left;
    padding: 2rem 1.75rem;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--bg);
    box-shadow: none;
    overflow: hidden;
}

.result-card {
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.5s ease;
}

.result-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 30px 60px -20px rgba(2, 8, 23, 0.2);
}

.result-number {
    font-size: clamp(2.4rem, 4.4vw, 3.6rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
    margin-bottom: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.result-label {
    font-size: 0.85rem;
    font-weight: 600;
}

body.dark-mode .result-card {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
}

/* Outcomes: two-up cards */
.outcomes-detailed {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.outcome-item {
    padding: 2rem;
    border-radius: 22px;
    border: 1px solid var(--border);
    border-left: 1px solid var(--border);
    background: var(--bg);
    box-shadow: none;
}

.outcome-item h3 {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.outcome-item h3 strong::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0.6rem;
    border-radius: 50%;
    background: var(--gradient);
    vertical-align: middle;
}

body.dark-mode .outcome-item {
    border-color: rgba(255, 255, 255, 0.08);
}

/* ── Gallery: bento ────────────────────────────────────────────────────────── */

.gallery-grid {
    gap: 1.25rem;
}

.gallery-item {
    border-radius: 22px;
}

@media (min-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: 260px;
    }

    .gallery-grid .gallery-item:first-child {
        grid-column: span 2;
        grid-row: span 2;
    }

    .gallery-grid .gallery-item img {
        height: 100%;
    }
}

.gallery-overlay {
    background: linear-gradient(180deg, transparent 30%, rgba(2, 8, 23, 0.85));
    justify-content: flex-end;
    align-items: flex-start;
    text-align: left;
    padding: 1.5rem;
}

.gallery-overlay .expand-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    border-radius: 50%;
    background: #fff;
    color: #0f172a;
    font-size: 0.9rem;
}

/* ── CTA: a framed panel instead of a full-bleed band ──────────────────────── */

.section.cta,
body.dark-mode .section.cta {
    background: transparent;
    color: inherit;
    padding-bottom: 2rem;
}

.cta-content {
    position: relative;
    max-width: none;
    padding: clamp(3.5rem, 8vw, 6.5rem) clamp(1.5rem, 5vw, 4rem);
    border-radius: clamp(28px, 4vw, 44px);
    background: var(--gradient);
    color: #fff;
    overflow: hidden;
    isolation: isolate;
}

.cta-content::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(45% 60% at 90% 10%, rgba(255, 0, 110, 0.3), transparent 70%),
        radial-gradient(50% 60% at 0% 100%, rgba(255, 255, 255, 0.15), transparent 70%);
}

.cta-title {
    font-size: clamp(2.4rem, 6vw, 4.75rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
    color: #fff;
    -webkit-text-fill-color: #fff;
}

.cta-subtitle {
    max-width: 52ch;
    margin-left: auto;
    margin-right: auto;
    font-size: 1.15rem;
}

/* ── Floating chapter navigator ────────────────────────────────────────────── */

.cs-nav {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 1250;
    transform: translate(-50%, 140%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, visibility 0s linear 0.6s;
}

.cs-nav.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, visibility 0s;
}

.cs-nav button.cs-nav__pill {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 52px;
    max-width: min(78vw, 380px);
    padding: 0 1.1rem 0 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 20px 50px rgba(2, 8, 23, 0.3);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.cs-nav__ring {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    transform: rotate(-90deg);
}

.cs-nav__ring circle {
    fill: none;
    stroke-width: 2.5;
}

.cs-nav__ring-bg { stroke: rgba(255, 255, 255, 0.15); }

.cs-nav__ring-fg {
    stroke: #3a86ff;
    stroke-linecap: round;
}

.cs-nav__idx {
    position: absolute;
    left: 0.45rem;
    width: 38px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cs-nav__pill {
    position: relative;
}

.cs-nav__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-nav__chev {
    flex-shrink: 0;
    transition: transform 0.35s ease;
}

.cs-nav.is-open .cs-nav__chev {
    transform: rotate(180deg);
}

.cs-nav__panel {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.6rem);
    width: min(88vw, 320px);
    margin-left: calc(min(88vw, 320px) / -2);
    padding: 0.5rem;
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 30px 70px rgba(2, 8, 23, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transform-origin: 50% 100%;
}

.cs-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cs-nav__list a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 44px;
    padding: 0 0.85rem;
    border-radius: 14px;
    border-bottom: none !important;
    color: rgba(255, 255, 255, 0.72) !important;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.cs-nav__list a:hover,
.cs-nav__list a.is-current {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
    color: #fff !important;
}

.cs-nav__n {
    font-size: 0.72rem;
    font-weight: 700;
    color: #3a86ff;
    font-variant-numeric: tabular-nums;
}

/* ── Lightbox polish ───────────────────────────────────────────────────────── */

.lightbox {
    background: rgba(2, 8, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.lightbox.active {
    animation: none;
}

.lightbox-image {
    border-radius: 16px;
    touch-action: pan-y;
}

.lightbox-close,
.lightbox-nav {
    width: 48px;
    height: 48px;
}

.lightbox-counter {
    position: absolute;
    left: 50%;
    top: -2.75rem;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .project-meta-grid { grid-template-columns: repeat(2, 1fr); }
    .meta-card:nth-child(3) { border-left: none; }
    .meta-card:nth-child(n + 3) { border-top: 1px solid var(--border); }
}

@media (max-width: 900px) {
    .hero-content { grid-template-columns: 1fr; }
    .hero-subtitle { max-width: none; }
}

@media (max-width: 860px) {
    .section-header {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .overview-text { grid-template-columns: 1fr; }

    .solution-image { position: static; }
}

@media (max-width: 768px) {
    section.hero { padding: 7rem 0 4rem; min-height: 0; }
    .hero-stats .stat { padding-right: 0.75rem; }
    .hero-stats .stat + .stat { padding-left: 0.75rem; }
    .floating-element small { font-size: 0.72rem; }

    .has-rail .process-step,
    .has-rail .process-step:hover { grid-template-columns: 44px minmax(0, 1fr); gap: 1rem; }
    .has-rail .step-number { width: 44px; height: 44px; font-size: 1rem; top: 45vh; }
    .cs-rail { left: 21px; top: 22px; }
}

@media (max-width: 600px) {
    /* Sit next to the theme/language dock instead of under it */
    .cs-nav { left: 1rem; transform: translate(0, 140%); }
    .cs-nav.is-visible { transform: translate(0, 0); }
    .cs-nav button.cs-nav__pill { max-width: calc(100vw - 11.5rem); }
    .cs-nav__panel { left: 0; margin-left: 0; width: calc(100vw - 2rem); transform-origin: 0 100%; }
}

@media (max-width: 560px) {
    .project-meta-grid { grid-template-columns: 1fr; }
    .meta-card + .meta-card { border-left: none; border-top: 1px solid var(--border); }
    .hero-stats { flex-wrap: wrap; }
}
