/* static/css/sections/system_showcase.css */
/* =========================
   SYSTEMS SCROLL-JACK SHOWCASE
   - Fix overlap (<1400px)
   - Mobile (<560px): transparent text window, no glass blur, icons reposition + responsive label
   - sys-copy is a scrollable "text window"
   UPDATED: 2026/02/11
   ========================= */

#systems.sys{
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;

  /* JS 寫入 0..1 */
  --sys-p: 0;

  /* 面板寬度（detail 計算用） */
  --sys-dock-w: 50%;

  /* 顏色 */
  --sys-white: #ffffff;
  --sys-panel: #cfd3d8;

  /* 版面控制（icons / copy） */
  --sys-icons-col-left: clamp(64px, 8vw, 140px);
  --sys-icons-col-w: clamp(220px, 22vw, 320px);
  --sys-icons-copy-gap: clamp(22px, 3vw, 56px);

  --sys-copy-left-target: calc(var(--sys-icons-col-left) + var(--sys-icons-col-w) + var(--sys-icons-copy-gap));
  --sys-copy-left-start: clamp(28px, 6vw, 92px);

  --sys-copy-shift-start: 0.55;
  --sys-copy-shift-end: 1.0;

  --sys-copy-mix: clamp(
    0,
    calc((var(--sys-p) - var(--sys-copy-shift-start)) / (var(--sys-copy-shift-end) - var(--sys-copy-shift-start))),
    1
  );

  /* Carton 放大控制 */
  --sys-carton-scale-min: 1;
  --sys-carton-scale-max: 1.22;
  --sys-carton-scale: calc(
    var(--sys-carton-scale-min) +
    (var(--sys-carton-scale-max) - var(--sys-carton-scale-min)) * var(--sys-p)
  );
}

/* 固定一屏 */
#systems.sys .sys-sticky{
  position: relative;
  width: 100%;
  height: 100%;
}

/* =========================
   背景層
   ========================= */
#systems.sys .sys-bg{
  position: absolute;
  inset: 0;
  z-index: 0;
}

#systems.sys .sys-bg-white{
  position: absolute;
  inset: 0;
  background: var(--sys-white);
  z-index: 0;
}

#systems.sys .sys-bg-grey{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--sys-panel);
  z-index: 1;
  transform: none;
  transition: none;
}

/* 前景舞台 */
#systems.sys .sys-stage{
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* =========================================================
   z-index：icons-col > copy > detail > vial > detail-media
   ========================================================= */

/* =========================
   sys-detail / sys-detail-media
   ========================= */
#systems.sys .sys-detail{
  position: absolute;
  top: 0;
  right: 0;
  width: calc(100% - var(--sys-dock-w));
  height: 100%;
  overflow: hidden;
  z-index: auto; /* 不設 z-index */

  transform: translate3d(calc((1 - var(--sys-p)) * 24%), 0, 0);
  opacity: calc(var(--sys-p) * 1);
  transition: none;

  pointer-events: none;
}

#systems.sys .sys-detail-media{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  z-index: 5;
}

/* =========================
   Vial & Carton
   ========================= */
#systems.sys .sys-vial{
  position: absolute;
  z-index: 12;

  width: min(520px, 34vw);
  height: auto;

  left: 62%;
  top: -8%;

  transform-origin: 50% 30%;
  transform:
    translate3d(
      calc(var(--sys-p) * -56vw),
      calc(var(--sys-p) * 8vh),
      0
    )
    rotate(calc((-24deg) + (var(--sys-p) * -156deg)));

  transition: none;
  filter: drop-shadow(0 24px 60px rgba(0,0,0,.12));
}

#systems.sys .sys-carton{
  position: absolute;
  z-index: 11;

  width: min(880px, 56vw);
  height: auto;

  left: 50%;
  top: 20%;

  transform-origin: 50% 50%;
  transform:
    translate3d(calc(var(--sys-p) * 55vw), 0, 0)
    rotate(22deg)
    scale(var(--sys-carton-scale));

  opacity: calc(1 - (var(--sys-p) * 1.15));
  transition: none;

  filter: drop-shadow(0 24px 70px rgba(0,0,0,.10));
}

/* =========================
   ✅ Copy（文案區）=> 文字窗 + 可滾動
   ========================= */
#systems.sys .sys-copy{
  position: absolute;
  z-index: 30;

  left: calc(
    var(--sys-copy-left-start) +
    (var(--sys-copy-left-target) - var(--sys-copy-left-start)) * var(--sys-copy-mix)
  );

  top: 50%;
  transform: translate3d(0, -50%, 0);

  width: min(640px, 38vw);

  /* ✅ 文字窗：可滾動 */
  max-height: clamp(320px, 66vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  /* 桌機：很淡的窗體（不影響你的大背景） */
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  padding: 18px 18px;

  /* 不用 blur（你沒要求桌機 blur，且 blur 容易造成效能問題） */
  backdrop-filter: none;

  transition: none;

  color: color-mix(in srgb, #111318 calc((1 - var(--sys-p)) * 100%), #41464e calc(var(--sys-p) * 100%));
}

#systems.sys .sys-h1{
  font-family: var(--font2, "Space Grotesk", system-ui);
  letter-spacing: .06em;
  font-weight: 900;
  line-height: 1.02;
  font-size: min(62px, 4.2vw);
  text-transform: uppercase;
  margin-bottom: 18px;
}

#systems.sys .sys-kicker{
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  opacity: .72;
}

#systems.sys .sys-block{
  margin-top: clamp(20px, 3.2vh, 34px);
}

#systems.sys .sys-block-title{
  font-family: var(--font2, "Space Grotesk", system-ui);
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 18px;
}

#systems.sys .sys-block-desc{
  margin-top: 12px;
  line-height: 1.55;
  letter-spacing: .02em;
  font-size: 14px;
  opacity: .92;
}

/* =========================
   Icons
   ========================= */
#systems.sys .sys-icons{
  position: absolute;
  user-select: none;
}

/* row：底部展示用 */
#systems.sys .sys-icons-row{
  z-index: 22;
  pointer-events: none;

  right: clamp(18px, 5vw, 72px);
  bottom: clamp(26px, 6vh, 64px);

  display: flex;
  gap: clamp(18px, 3vw, 44px);
  align-items: center;

  transform: translate3d(calc(var(--sys-p) * -34vw), 0, 0);
  opacity: calc(1 - (var(--sys-p) * 1.25));
}

/* col：左側直排互動用（最高層） */
#systems.sys .sys-icons-col{
  z-index: 40;
  left: var(--sys-icons-col-left);
  top: 50%;

  transform:
    translate3d(0, -50%, 0)
    translate3d(calc((1 - var(--sys-p)) * -18vw), 0, 0);

  opacity: calc(var(--sys-p) * 1);

  display: flex;
  flex-direction: column;
  gap: 18px;

  pointer-events: auto;
}

/* icon 排版 */
#systems.sys .sys-icon{
  display: flex;
  align-items: center;
  gap: 12px;
}

/* button */
#systems.sys .sys-icon-btn{
  position: relative;
  z-index: 41;

  border: 0;
  outline: none;
  background: transparent;
  padding: 0;
  margin: 0;

  cursor: pointer;
  text-align: left;

  /* ✅ 防止 label 太長撐到 copy：限制最大寬度 + 可換行 */
  max-width: var(--sys-icons-col-w);

  transform: none;
  transition: filter .16s ease, opacity .16s ease;
}

#systems.sys .sys-icon-btn:hover{
  transform: none;
  filter: drop-shadow(0 10px 26px rgba(0,0,0,.10));
}

#systems.sys .sys-icon-btn:active{
  transform: none;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,.12));
}

#systems.sys .sys-icon-btn:focus-visible .sys-icon-circle{
  box-shadow: 0 0 0 3px rgba(255,255,255,.78), 0 18px 50px rgba(0,0,0,.14);
}

#systems.sys .sys-icon-btn.is-active{
  transform: none;
  filter: drop-shadow(0 14px 34px rgba(0,0,0,.12));
}

/* circle */
#systems.sys .sys-icon-circle{
  width: 66px;
  height: 66px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  display: grid;
  place-items: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.12);

  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  flex: 0 0 auto;
}

#systems.sys .sys-icon-btn:hover .sys-icon-circle{
  transform: none;
  background: rgba(255,255,255,.98);
  box-shadow: 0 22px 62px rgba(0,0,0,.14);
}

#systems.sys .sys-icon-btn:active .sys-icon-circle{
  transform: scale(0.99);
}

#systems.sys .sys-icon-btn.is-active .sys-icon-circle{
  transform: scale(1.07);
  background: rgba(255,255,255,1);
  box-shadow: 0 26px 74px rgba(0,0,0,.16);
}

#systems.sys .sys-icon-circle img{
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  transition: transform .16s ease;
}

#systems.sys .sys-icon-btn.is-active .sys-icon-circle img{
  transform: scale(1.03);
}

/* ✅ label：可換行 + 自適應，避免壓到 copy */
#systems.sys .sys-icon-text{
  font-family: var(--font2, "Space Grotesk", system-ui);
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;

  font-size: clamp(12px, 0.92vw, 14px);
  line-height: 1.15;

  white-space: normal;
  overflow-wrap: anywhere;

  transition: opacity .18s ease;

  color: color-mix(in srgb, #111318 calc((1 - var(--sys-p)) * 100%), #41464e calc(var(--sys-p) * 100%));
}

/* =========================
   ✅ Responsive tuning
   ========================= */

/* ✅ <1400px：強制 copy 起始就在 icons 右側（避免重疊） */
@media (max-width: 1400px){
  #systems.sys{
    --sys-icons-col-left: clamp(16px, 2.6vw, 58px);
    --sys-icons-col-w: clamp(160px, 22vw, 240px);
    --sys-icons-copy-gap: clamp(14px, 1.8vw, 22px);

    --sys-copy-left-target: calc(var(--sys-icons-col-left) + var(--sys-icons-col-w) + var(--sys-icons-copy-gap));
    --sys-copy-left-start: var(--sys-copy-left-target);
  }

  #systems.sys .sys-copy{
    width: min(620px, calc(100vw - var(--sys-copy-left-start) - 24px));
  }
}

/* <1100：再收斂 */
@media (max-width: 1100px){
  #systems.sys{
    --sys-icons-col-left: clamp(14px, 3.8vw, 52px);
    --sys-icons-col-w: clamp(150px, 30vw, 230px);
    --sys-icons-copy-gap: clamp(12px, 2.2vw, 18px);

    --sys-copy-left-target: calc(var(--sys-icons-col-left) + var(--sys-icons-col-w) + var(--sys-icons-copy-gap));
    --sys-copy-left-start: var(--sys-copy-left-target);

    --sys-carton-scale-max: 1.16;
  }

  #systems.sys .sys-copy{
    width: min(560px, calc(100vw - var(--sys-copy-left-start) - 20px));
    padding: 16px 16px;
  }

  #systems.sys .sys-h1{ font-size: min(54px, 5.2vw); }
}

/* <980：調整物件 */
@media (max-width: 980px){
  #systems.sys .sys-detail{ width: 46%; }
  #systems.sys .sys-vial{ left: 58%; width: min(420px, 52vw); }
  #systems.sys .sys-carton{
    left: 54%;
    width: min(620px, 74vw);
    --sys-carton-scale-max: 1.12;
  }
}

/* =========================
   ✅ Mobile <560px
   - 背景/圖片保持存在（但退到背景層不擋字）
   - sys-copy：透明文字窗 + 可滾（不要毛玻璃）
   - icons：移到更安全位置 + label 自適應
   ========================= */
@media (max-width: 560px){
  #systems.sys{
    --sys-dock-w: 100%;
  }

  /* detail 做成背景層（避免你說的「錯位擋字」） */
  #systems.sys .sys-detail{
    display: block;
    width: 100%;
    opacity: 0.22;
    transform: none !important;
  }

  #systems.sys .sys-detail-media{
    object-position: 62% center;
    filter: saturate(1.02) contrast(0.98);
  }

  /* ✅ sys-copy：透明窗（不要毛玻璃）+ 滾動 */
  #systems.sys .sys-copy{
    left: 14px !important;
    top: 54%;
    transform: translate3d(0, -50%, 0);
    width: calc(100% - 28px);
    z-index: 30;

    max-height: clamp(320px, 62vh, 520px);
    overflow-y: auto;

    background: transparent;        /* ✅ 你要透明 */
    border: 0;                      /* 不要霧面框 */
    border-radius: 16px;
    padding: 0;                     /* 讓文字更貼近你的版面 */

    backdrop-filter: none !important; /* ✅ 明確移除毛玻璃 */
  }

  /* 文字可讀性：用 text-shadow，不用霧面 */
  #systems.sys .sys-copy *{
    text-shadow: 0 2px 14px rgba(0,0,0,.22);
  }

  /* 內文的間距在手機縮小 */
  #systems.sys .sys-h1{
    font-size: clamp(32px, 8.6vw, 44px);
    margin-bottom: 12px;
  }

  #systems.sys .sys-block-title{
    font-size: 16px;
  }

  #systems.sys .sys-block-desc{
    font-size: 13px;
    line-height: 1.5;
  }

  /* ✅ icons-col：移到更安全的位置（左上偏中），避免壓到 sys-copy */
  #systems.sys .sys-icons-col{
    left: 12px;
    top: 22%;
    transform: translate3d(0,0,0) !important;
    gap: 12px;
    z-index: 40;
    opacity: 1; /* 手機不要隨 p 才出現，不然你會覺得「沒啟動」 */
  }

  #systems.sys .sys-icon-circle{ width: 54px; height: 54px; }
  #systems.sys .sys-icon-circle img{ width: 28px; height: 28px; }

  /* ✅ 手機 label 自適應，避免重疊到內容 */
  #systems.sys .sys-icon-btn{
    max-width: 170px;
  }

  #systems.sys .sys-icon-text{
    font-size: clamp(10px, 2.9vw, 12px);
    line-height: 1.12;
    max-width: 120px;
  }

  /* 保留 vial/carton 但退到更背景（淡） */
  #systems.sys .sys-vial{
    display: block;
    opacity: 0.14;
    z-index: 9;
    left: 64%;
    top: -6%;
    width: min(340px, 74vw);
    transform: translate3d(calc(var(--sys-p) * -22vw), calc(var(--sys-p) * 3vh), 0)
               rotate(calc((-18deg) + (var(--sys-p) * -90deg)));
    filter: drop-shadow(0 14px 40px rgba(0,0,0,.06));
  }

  #systems.sys .sys-carton{
    display: block;
    opacity: 0.10;
    z-index: 8;
    left: 58%;
    top: 34%;
    width: min(520px, 94vw);
    transform: translate3d(calc(var(--sys-p) * 26vw), 0, 0) rotate(16deg) scale(var(--sys-carton-scale));
    filter: drop-shadow(0 14px 44px rgba(0,0,0,.05));
  }

  /* row icons：手機可留著（不重要的話你也可以自行 display:none） */
  #systems.sys .sys-icons-row{
    right: 12px;
    left: 12px;
    justify-content: space-between;
    gap: 10px;
    opacity: 0; /* 手機就不需要底部 row，避免干擾 */
    pointer-events: none;
  }
}

/* =========================
   When locked: prevent overscroll/bounce
   ========================= */
html.sys-lock, body.sys-lock{
  overscroll-behavior: none;
}
