/* =============================================================
   Case studies: shared shell
   Same drawing-sheet language as the Work page: a title block of facts,
   framed figures, plain sections, a paper close and a link to the next case.
   ============================================================= */
.cs2-page { --cs-g: #5dd2a6; --cs-a: #e9a566; --cs-b: #8ec5ff; --cs-sheet: #0f1720; }
.cs2-h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 3.4vw, 48px); line-height: 1.06; letter-spacing: -0.03em; text-wrap: balance; max-width: 16em; }
.cs2-h2 em { font-style: normal; color: var(--copper-hi); }
.cs2-lead { text-wrap: pretty; margin-top: 16px; max-width: 40em; font-size: clamp(16px, 1.4vw, 18px); line-height: 1.55; color: var(--text-mute); }

/* ---------- Hero ---------- */
.cs2-hero { position: relative; overflow: hidden; isolation: isolate; padding: clamp(40px, 5vw, 64px) 0 clamp(56px, 7vw, 96px);
  background: radial-gradient(60% 70% at 90% 20%, rgba(201,123,61,0.10), transparent 60%), var(--ink); border-bottom: 1px solid var(--line); }
.cs2-hero::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(142,197,255,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(142,197,255,0.035) 1px, transparent 1px),
                    linear-gradient(rgba(142,197,255,0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(142,197,255,0.02) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  -webkit-mask-image: radial-gradient(90% 80% at 60% 40%, #000 30%, transparent 85%); mask-image: radial-gradient(90% 80% at 60% 40%, #000 30%, transparent 85%); }
.cs2-hg { margin-top: clamp(30px, 4vw, 56px); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(32px, 5vw, 80px); align-items: center; }
.cs2-hc .section-label .live { width: 7px; height: 7px; border-radius: 50%; background: var(--cs-g); animation: csBlink 2s ease infinite; }
.cs2-hc .section-label.has-dot::before { display: none; }
.cs2-hc h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(34px, 4.4vw, 62px); line-height: 1.04; letter-spacing: -0.035em; text-wrap: balance; }
.cs2-hc h1 em { font-style: normal; color: var(--copper-hi); }
.cs2-sub { text-wrap: pretty; margin-top: 22px; max-width: 34em; font-size: clamp(17px, 1.45vw, 19.5px); line-height: 1.55; color: var(--text-mute); }
.cs2-btns { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 14px; }
.cs2-btns .btn-ghost { color: var(--text); border-color: var(--line-2); }
.cs2-btns .btn-ghost:hover { color: var(--ink); }

/* title block of facts */
.cs2-tb { position: relative; margin: 0; background: var(--cs-sheet); border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 10px; }
.cs2-tb::before { content: ''; position: absolute; inset: 10px; border: 1px solid rgba(142,197,255,0.08); border-radius: 10px; pointer-events: none; }
.cs2-tb > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.cs2-tb > div:last-child { border-bottom: 0; }
.cs2-tb dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); }
.cs2-tb dd { margin: 0; font-size: 14.5px; line-height: 1.4; color: var(--text); }
.cs2-tb dd.no { font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--copper-hi); }
.cs2-tb dd.live { color: var(--cs-g); }
.cs2-tb dd.live::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-inline-end: 8px; border-radius: 50%; background: var(--cs-g); vertical-align: 1px; animation: csBlink 2s ease infinite; }
.cs2-tb dd.ok { color: var(--cs-g); }
.cs2-tb dd.ok svg, .cs2-ok svg { display: inline-block; width: 15px; height: 15px; margin-inline-end: 8px; vertical-align: -2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Sections ---------- */
.cs2-sec { padding: clamp(72px, 9vw, 120px) 0; background: var(--ink); }
.cs2-sec.alt { background: var(--ink-2); border-block: 1px solid var(--line); }
.cs2-fig { margin-top: clamp(30px, 4vw, 48px); background: #0a1017; border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: clamp(14px, 2vw, 26px); }
.cs2-fig svg { display: block; width: 100%; height: auto; }
.cs2-fig.scroll { direction: ltr; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; }
.cs2-swipe { display: none; }
.cs2-cap { margin-top: 12px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }

.cs2-steps { list-style: none; margin-top: clamp(30px, 4vw, 48px); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.cs2-steps li { display: flex; flex-direction: column; gap: 10px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 20px; }
.cs2-steps b { font-family: var(--font-mono); font-weight: 500; font-size: 12px; color: var(--copper-hi); }
.cs2-steps h3 { font-family: var(--font-display); font-weight: 500; font-size: 18.5px; line-height: 1.25; letter-spacing: -0.01em; }
.cs2-steps p { font-size: 14.5px; line-height: 1.55; color: var(--text-mute); }
.cs2-steps.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cs2-ok { margin-top: auto; padding-top: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cs-g); }

.cs2-tiles { margin-top: clamp(30px, 4vw, 48px); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.cs2-tile { display: flex; flex-direction: column; gap: 12px; background: var(--cs-sheet); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 16px 16px 20px; }
.cs2-tile svg { width: 100%; height: auto; display: block; background: #0a1017; border-radius: 10px; border: 1px solid rgba(255,255,255,0.06); }
.cs2-tile h3 { font-family: var(--font-display); font-weight: 500; font-size: 17.5px; line-height: 1.25; margin-top: 4px; }
.cs2-tile p { font-size: 14px; line-height: 1.55; color: var(--text-mute); }
.mf-g { fill: none; stroke: var(--cs-g); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mf-a { fill: none; stroke: var(--cs-a); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mf-b { fill: none; stroke: var(--cs-b); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mf-m { fill: none; stroke: rgba(232,229,223,0.25); stroke-width: 1.2; stroke-linecap: round; }
.mf-d { stroke-dasharray: 4 4; }
.mf-n { fill: var(--cs-g); } .mf-na { fill: var(--cs-a); }
.mf-th { stroke-width: 1.4; }
.cs2-ftag { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--copper-hi); margin-top: 2px; }
.cs2-tile .cs2-ftag + h3 { margin-top: -4px; }
.cs2-dels { row-gap: 30px; }
.mf-draw { stroke-dasharray: 1; stroke-dashoffset: 0; }
.reveal:not(.in) .mf-draw { stroke-dashoffset: 1; }
.reveal.in .mf-draw { animation: csDraw 1.5s var(--ease) both; animation-delay: calc(0.3s + var(--d, 0s)); }

.cs2-ctx { margin-top: clamp(26px, 3vw, 40px); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cs2-ctx > div { border-top: 1px solid rgba(255,255,255,0.14); padding-top: 16px; }
.cs2-ctx .fl { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cs-b); }
.cs2-ctx h3 { margin-top: 8px; font-family: var(--font-display); font-weight: 500; font-size: 18px; }
.cs2-ctx p { margin-top: 6px; font-size: 14.5px; line-height: 1.55; color: var(--text-mute); }
.cs2-note { margin-top: 10px; font-size: 14px; color: var(--text-dim); }
.cs2-refs { margin-top: clamp(40px, 5vw, 64px); border-top: 1px solid rgba(255,255,255,0.12); }
.cs2-refs a { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.08); text-decoration: none; color: var(--text); transition: color .3s; }
.cs2-refs a:hover { color: var(--copper-hi); }
.cs2-refs span:first-child { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.cs2-refs span:nth-child(2) { font-size: 16px; }
.cs2-refs i { font-style: normal; color: var(--copper-hi); }

/* ---------- Model explorer: pick a part and its block lights up ---------- */
.gx { margin-top: clamp(30px, 4vw, 48px); display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: 'tabs fig' 'panel fig'; grid-template-rows: auto 1fr; gap: 0 clamp(20px, 3vw, 40px); align-items: start; }
.gx-tabs { grid-area: tabs; }
.gx-stage { grid-area: fig; }
.gx-panels { grid-area: panel; }
.gx-tabs { display: flex; flex-direction: column; gap: 6px; }
.gx-tabs button { display: flex; align-items: center; gap: 12px; text-align: start; padding: 11px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.02); color: var(--text-mute); font: 500 15px/1.25 var(--font-sans); cursor: pointer; transition: border-color .25s, background .25s, color .25s; }
.gx-tabs button b { font: 500 11px/1 var(--font-mono); color: var(--text-dim); min-width: 20px; }
.gx-tabs button:hover { border-color: rgba(201,123,61,0.5); color: var(--text); }
.gx-tabs button[aria-selected="true"] { background: rgba(201,123,61,0.12); border-color: rgba(201,123,61,0.6); color: var(--text); }
.gx-tabs button[aria-selected="true"] b { color: var(--copper-hi); }
.gx-stage { min-width: 0; }
.gx-stage .cs2-fig { margin-top: 0; }
.gx-panel { margin-top: 26px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,0.1); }
.gx-panel:not([hidden]) { animation: gxIn .45s var(--ease) both; }
.gx-panel h3 { font-family: var(--font-display); font-weight: 500; font-size: clamp(20px, 1.8vw, 23px); line-height: 1.2; letter-spacing: -0.015em; }
.gx-panel p { margin-top: 10px; max-width: 40em; font-size: 15px; line-height: 1.6; color: var(--text-mute); }
.gx-specs { list-style: none; margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.gx-specs li { font-family: var(--font-mono); font-size: 11.5px; line-height: 1; letter-spacing: 0.04em; color: var(--text); padding: 8px 12px; border-radius: 40px; border: 1px solid rgba(255,255,255,0.14); }
@keyframes gxIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* block diagram */
.bd-frame { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 1.2; stroke-dasharray: 6 5; }
.bd-w { fill: none; stroke: rgba(232,229,223,0.42); stroke-width: 1.6; }
.bd-c { fill: none; stroke: var(--cs-a); stroke-width: 1.6; }
.bd-f { fill: none; stroke: var(--cs-g); stroke-width: 1.5; stroke-dasharray: 5 4; }
.bd-bx { fill: #0f1720; stroke: rgba(255,255,255,0.22); stroke-width: 1.4; transition: fill .35s, stroke .35s; }
.bd-gb { fill: rgba(255,255,255,0.015); stroke: rgba(255,255,255,0.18); stroke-width: 1.3; stroke-dasharray: 6 5; transition: fill .35s, stroke .35s; }
.bd-tx { fill: none; stroke: rgba(232,229,223,0.7); stroke-width: 1.6; transition: stroke .35s; }
.bd-bus { stroke: var(--text); stroke-width: 3; }
.bd-n { fill: var(--text); }
.bd-brk { fill: var(--copper); stroke: var(--text); stroke-width: 1.2; }
.bd-t { fill: var(--text); font-size: 14.5px; font-weight: 600; letter-spacing: 0.04em; transition: fill .35s; }
.bd-s { fill: rgba(232,229,223,0.62); font-size: 11.5px; }
.bd-l { fill: rgba(232,229,223,0.82); font-size: 12px; }
.bd-k { fill: var(--copper-hi); font-size: 11.5px; letter-spacing: 0.12em; }
.bd-kc { fill: var(--cs-a); font-size: 11.5px; }
.bd-kg { fill: var(--cs-g); font-size: 11.5px; }
.bd-g { cursor: pointer; transition: opacity .35s; }
.has-sel .bd-g:not(.on) { opacity: 0.42; }
.bd-g.on .bd-bx, .bd-g.on .bd-gb { fill: rgba(201,123,61,0.16); stroke: var(--copper-hi); }
.bd-g.on .bd-tx { stroke: var(--copper-hi); }
.bd-g.on .bd-t { fill: var(--copper-hi); }

/* ---------- Test picker with redrawn waveforms ---------- */
.tm { margin-top: clamp(40px, 5vw, 64px); }
.tm-h { font-family: var(--font-display); font-weight: 500; font-size: clamp(20px, 2vw, 26px); line-height: 1.2; letter-spacing: -0.015em; }
.tm-g { margin-top: 20px; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: clamp(18px, 2.4vw, 32px); align-items: start; }
.tm-chips { display: flex; flex-direction: column; gap: 8px; }
.tm-chips button { text-align: start; font-family: var(--font-mono); font-size: 12px; line-height: 1.3; letter-spacing: 0.02em; color: var(--text); background: none; border: 1px solid rgba(255,255,255,0.16); border-radius: 40px; padding: 10px 16px; cursor: pointer; transition: border-color .2s, background .2s, color .2s; }
.tm-chips button:hover { border-color: var(--copper); }
.tm-chips button[aria-pressed="true"] { background: var(--copper); border-color: var(--copper); color: #1a0f06; font-weight: 500; }
.tm-detail { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr); gap: clamp(18px, 2.4vw, 30px); background: var(--cs-sheet); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: clamp(14px, 2vw, 24px); min-height: 340px; }
.tm-plot { background: #0a1017; border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; padding: 12px 12px 8px; }
.tm-plot svg { display: block; width: 100%; height: auto; }
.tm-cap { margin-top: 8px; font-family: var(--font-mono); font-size: 10px; line-height: 1.4; letter-spacing: 0.04em; color: var(--text-dim); }
.tm-tag { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--copper-hi); }
.tm-txt h3 { margin-top: 10px; font-family: var(--font-display); font-weight: 500; font-size: clamp(19px, 1.8vw, 23px); line-height: 1.2; }
.tm-txt p { margin-top: 10px; font-size: 15px; line-height: 1.55; color: var(--text-mute); }
.tm-txt .tm-res { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.1); color: var(--text); }
.tm-res b { display: block; margin-bottom: 6px; font-family: var(--font-mono); font-weight: 500; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cs-g); }

/* ---------- Checklist with a progress ring ---------- */
.gc { margin-top: clamp(30px, 4vw, 48px); display: grid; grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.gc-ring { position: relative; max-width: 280px; }
.gc-ring svg { display: block; width: 100%; height: auto; transform: rotate(-90deg); }
.gc-ring .tr { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 9; }
.gc-ring .pr { fill: none; stroke: var(--cs-g); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.reveal:not(.in) .gc-ring .pr { stroke-dashoffset: 1; }
.reveal.in .gc-ring .pr { animation: csDraw 2.4s var(--ease) .3s both; }
.gc-mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gc-mid b { font-family: var(--font-display); font-weight: 500; font-size: clamp(44px, 5vw, 64px); line-height: 1; letter-spacing: -0.03em; direction: ltr; }
.gc-mid span { margin-top: 10px; max-width: 9em; font-family: var(--font-mono); font-size: 10.5px; line-height: 1.4; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.gc-note { margin-top: 26px; max-width: 26em; font-size: 14.5px; line-height: 1.6; color: var(--text-mute); }
.gc-list { list-style: none; border-top: 1px solid rgba(255,255,255,0.12); }
.gc-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: baseline; padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.gc-list .n { font-family: var(--font-mono); font-weight: 500; font-size: 12px; color: var(--copper-hi); }
.gc-list h3 { font-family: var(--font-display); font-weight: 500; font-size: 17px; line-height: 1.3; }
.gc-list p { margin-top: 4px; font-size: 14.5px; line-height: 1.5; color: var(--text-mute); }
.gc-met { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-weight: 500; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cs-g); }
.gc-met svg { width: 16px; height: 16px; fill: none; stroke: var(--cs-g); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gc-met path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.reveal:not(.in) .gc-met path { stroke-dashoffset: 1; }
.reveal.in .gc-met path { animation: csDraw .5s var(--ease) both; animation-delay: calc(.45s + var(--i, 0) * .3s); }

/* ---------- Close ---------- */
.cs2-close .cta-c { background: transparent; padding: clamp(80px, 10vw, 130px) 0; }
.cs2-close .cta-c .cta-sub { margin: 20px auto 0; max-width: 34em; font-size: clamp(16px, 1.4vw, 18px); line-height: 1.55; color: var(--tp-mute); text-wrap: pretty; }

@keyframes csBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes csDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .cs2-hc .section-label .live, .cs2-tb dd.live::before { animation: none; } .gx-panel:not([hidden]) { animation: none; } }

/* ---------- Arabic ---------- */
html[dir="rtl"] :is(.cs2-tb dt, .cs2-cap, .cs2-ctx .fl, .cs2-refs span:first-child, .cs2-ok, .tm-tag, .tm-res b, .gc-mid span, .gc-met) { letter-spacing: 0; font-size: 12px; }
html[dir="rtl"] :is(.bd-k, .bd-t) { letter-spacing: 0; }
html[dir="rtl"] :is(.gx-specs li, .tm-chips button, .cs2-ftag) { letter-spacing: 0; }
html[dir="rtl"] .cs2-hc h1 { line-height: 1.3; }
html[dir="rtl"] .cs2-h2 { line-height: 1.35; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .cs2-steps, .cs2-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tm-detail { grid-template-columns: minmax(0, 1fr); min-height: 0; } }
@media (max-width: 900px) {
  .gx, .tm-g, .gc { grid-template-columns: minmax(0, 1fr); }
  .gx { grid-template-areas: 'tabs' 'fig' 'panel'; grid-template-rows: auto; }
  .gx-stage { margin-top: 18px; }
  .gx-panel { margin-top: 18px; padding-top: 0; border-top: 0; }
  .gx-tabs, .tm-chips { flex-direction: row; flex-wrap: wrap; }
  .gx-tabs button { padding: 10px 14px; font-size: 14px; }
  .gc-ring { max-width: 220px; }
}
@media (max-width: 980px) { .cs2-hg { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .cs2-fig.scroll svg { width: 720px; max-width: none; } .cs2-swipe { display: inline; } }
@media (max-width: 760px) { .cs2-ctx { grid-template-columns: minmax(0, 1fr); } .cs2-refs a { grid-template-columns: minmax(0, 1fr) auto; } .cs2-refs span:first-child { grid-column: 1 / -1; } }
@media (max-width: 600px) {
  .cs2-steps, .cs2-steps.two, .cs2-tiles { grid-template-columns: minmax(0, 1fr); }
  .cs2-tiles.f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cs2-tiles.f2 .cs2-tile { padding: 10px 10px 14px; gap: 8px; }
  .cs2-tiles.f2 .cs2-tile h3 { font-size: 15.5px; }
  .cs2-tiles.f2 .cs2-tile p { font-size: 13px; }
  .gc-list li { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; }
  .gc-met .t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .gc { gap: 24px; }
  .gc > div:first-child { display: flex; align-items: center; gap: 20px; }
  .gc-ring { flex: 0 0 132px; }
  .gc-mid b { font-size: 34px; }
  .gc-mid span { display: none; }
  .gc-note { margin-top: 0; }
  .cs2-tb > div { grid-template-columns: 92px minmax(0, 1fr); padding: 10px 12px; }
}
