.work-section {
  isolation: isolate;
}

.work-stage {
  display: flex;
  flex-direction: column;
  gap: clamp(48px, 10vw, 128px);
}

.work-case {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3vw, 26px);
}

.case-head {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: flex-start;
  column-gap: clamp(10px, 2vw, 22px);
  row-gap: 10px;
}
.case-no {
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--muted);
  padding-top: 6px;
}
.case-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.case-name {
  margin: 0;
  padding: 0;
  font-family: var(--sans-vf);
  font-variation-settings: "wght" 540;
  letter-spacing: -0.04em;
  color: var(--ink);
  line-height: 0.92;
  font-size: clamp(48px, 13vw, 172px);
  transform-origin: left top;
  transition: font-size var(--dur-slow) var(--ease-out),
              letter-spacing var(--dur-slow) var(--ease-out),
              font-variation-settings var(--dur-slow) var(--ease-out),
              opacity var(--dur) var(--ease-out),
              transform var(--dur-slow) var(--ease-out),
              color var(--dur) var(--ease-out);
  will-change: font-size, letter-spacing, transform;
  cursor: pointer;
}
.case-tag {
  margin: 0;
  color: var(--fg-2);
  font-size: clamp(14px, 2.4vw, 20px);
  line-height: 1.3;
  max-width: 26ch;
  padding-left: 2px;
}

.case-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--rule-soft);
  border-radius: 999px;
  color: var(--fg-2);
  align-self: start;
  margin-top: 8px;
  transition: background-color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out);
}
.case-toggle:hover { background: var(--paper); color: var(--ink); }
.case-toggle[aria-expanded="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ct-plus {
  display: inline-block;
  position: relative;
  width: 12px;
  height: 12px;
}
.ct-plus::before, .ct-plus::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  transition: transform var(--dur) var(--ease-out);
}
.ct-plus::before { width: 12px; height: 1px; }
.ct-plus::after { width: 1px; height: 12px; }
.case-toggle[aria-expanded="true"] .ct-plus::after { transform: translate(-50%, -50%) scaleY(0); }
.ct-label {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: currentColor;
}

/* Preview area – morphing container */
.case-preview {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: clamp(14px, 3vw, 24px);
  padding: 0 clamp(4px, 1vw, 10px);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-8px);
  transition: max-height var(--dur-slow) var(--ease-spring),
              opacity var(--dur) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}
.work-case.is-open .case-preview {
  max-height: 1200px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height var(--dur-xl) var(--ease-spring),
              opacity var(--dur) var(--ease-out) 120ms,
              transform var(--dur-slow) var(--ease-out);
}

.case-note {
  margin: 0;
  font-size: clamp(13.5px, 2.2vw, 16px);
  line-height: 1.55;
  color: var(--fg-2);
  max-width: 52ch;
  padding-left: clamp(6px, 1.5vw, 16px);
  border-left: 1px solid var(--rule-soft);
}

/* === Morphing state when open: name shrinks and shifts === */
.work-case.is-open .case-name {
  font-size: clamp(20px, 3.2vw, 34px);
  letter-spacing: -0.02em;
  font-variation-settings: "wght" 600;
  transform: translateY(2px);
  color: var(--ink);
}
.work-case.is-open .case-tag {
  color: var(--muted);
  transform: translateY(1px);
  transition: color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}

/* ==== NEXIO mini terminal ==== */
.nexio-mini {
  position: relative;
  border: 1px solid var(--rule-soft);
  background:
    linear-gradient(180deg, #F6F4EE 0%, #F0EDE4 100%);
  box-shadow: 0 22px 60px -40px rgba(23,23,20,0.5);
  overflow: hidden;
}
.nm-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule-soft);
  background: rgba(246,244,238,0.9);
}
.nm-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nm-dots i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--rule-soft);
  background: #F6F4EE;
}
.nm-dots i:nth-child(1) { background: #E8C1BA; border-color: #D8B0A8; }
.nm-dots i:nth-child(2) { background: #E7D9A8; border-color: #D5C285; }
.nm-dots i:nth-child(3) { background: #C5D6BE; border-color: #AEC6A4; }

.nm-screen {
  padding: clamp(14px, 2.6vw, 22px);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--fg-2);
  letter-spacing: 0.01em;
  min-height: 260px;
  overflow: hidden;
  position: relative;
  background-image: linear-gradient(0deg, rgba(23,23,20,0.025) 0, rgba(23,23,20,0.025) 1px, transparent 1px);
  background-size: 100% 1.7em;
  background-attachment: local;
}
.nm-path { color: #7A5D8C; }
.nm-line { white-space: pre-wrap; word-break: break-word; }
.nm-caret { position: relative; }
.nm-caret-cursor {
  display: inline-block;
  width: 7px;
  height: 1.2em;
  vertical-align: -0.2em;
  background: var(--ink);
  margin-left: 2px;
  animation: nm-blink 1.08s steps(2, start) infinite;
  transform-origin: center;
}
@keyframes nm-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* ==== SKYPKA mini device manager (Work section) ====
   NOTE: structure reuses the .sk-* class set defined in desktop.css (Skypka console table).
   Here we keep only the shell sizing / shadow for .skypka-mini and small Work-specific tweaks. */
.skypka-mini {
  position: relative;
  max-width: none;
}
@media (min-width: 768px) {
  .skypka-mini { max-width: 960px; }
}
@media (min-width: 1024px) {
  .skypka-mini { max-width: 1080px; }
}

/* End skypka */

/* Mobile tweaks */
@media (max-width: 430px) {
  .work-stage { gap: 30px; }
  .work-case { gap: 12px; }
  .case-head { grid-template-columns: auto 1fr; row-gap: 6px; column-gap: 10px; }
  .case-toggle { grid-column: 2 / 3; justify-self: end; margin-top: 2px; padding: 7px 9px; gap: 7px; }
  .ct-label { font-size: 9.5px; letter-spacing: 0.16em; }
  .ct-plus { width: 10px; height: 10px; }
  .ct-plus::before { width: 10px; } .ct-plus::after { height: 10px; }
  .case-no { padding-top: 3px; font-size: 10px; letter-spacing: 0.22em;}
  .case-name { font-size: clamp(40px, 17vw, 72px); line-height: 0.94; }
  .case-tag { font-size: 13.5px; max-width: 22ch; padding-left: 1px; }
  .case-preview { row-gap: 12px; padding: 0 4px; }
  .case-note { font-size: 13px; line-height: 1.5; padding-left: 10px; }
  .nm-screen { padding: 12px; font-size: 11px; line-height: 1.7; min-height: 220px; }
  .sm-list { padding: 6px; min-height: 220px; }
  .sm-row { grid-template-columns: 14px 1fr 70px; column-gap: 8px; padding: 9px 7px; }
  .sm-rname { font-size: 13px; }
  .sm-rmeta { font-size: 10px; }
}

@media (max-width: 390px) {
  .work-stage { gap: 26px; }
  .case-name { font-size: clamp(36px, 16.5vw, 66px); }
  .case-tag { font-size: 13px; }
}
@media (max-width: 375px) {
  .work-stage { gap: 22px; }
  .work-case { gap: 10px; }
  .case-name { font-size: clamp(32px, 16vw, 60px); }
  .case-tag { font-size: 12.5px; }
  .case-note { font-size: 12.5px; }
}

@media (min-width: 768px) {
  .case-head { align-items: center; }
  .case-preview {
    padding: 0 clamp(16px, 2.6vw, 40px) 0 clamp(6px, 1.2vw, 18px);
  }
  .nexio-mini, .skypka-mini {
    max-width: 840px;
  }
}
