/* 둥이 이야기 토글: 논문(/blog/) ↔ 일기(/blog/diary/). 개발 섹션 토글(/dev-post/switch.css)과 같은 문법
   일기로: 마스킹테이프 세 줄이 지나간 자리에 일기가 붙는다. 논문으로: 월령 자의 손잡이가 화면을 훑는다 (시안 design/story-switch B안)
   방향은 /diary/switch.js 가 html 에 t-diary / t-paper 를 달아 알려 준다. 목록에서 글로 가는 이동은 짧게 겹치기만 한다. 움직임 줄이기면 바로 바뀐다 */
@property --ds-x1 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --ds-x2 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --ds-x3 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@view-transition { navigation: auto; }
.ds-sw { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); z-index: 40; transform: translateX(-50%);
  display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; view-transition-name: ds-sw; }
.ds-sw a { position: relative; z-index: 1; display: grid; place-items: center; min-width: 92px; height: 44px; padding: 0 20px;
  border-radius: 999px; font: 700 15px/1 "Pretendard Variable", Pretendard, "Gowun Dodum", sans-serif; text-decoration: none; transition: color .2s; }
.ds-sw .knob { position: absolute; top: 4px; bottom: 4px; width: calc(50% - 4px); border-radius: 999px; transition: left .35s cubic-bezier(.16, 1, .3, 1); }
.ds-sw a:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }

html[data-ds="paper"] .ds-sw { background: #fffdf6; box-shadow: inset 0 0 0 2px #1d2340, 0 12px 24px -14px rgba(29, 35, 64, .6); }
html[data-ds="paper"] .ds-sw a { color: #3d4360; }
html[data-ds="paper"] .ds-sw a[aria-current] { color: #ffffff; }
html[data-ds="paper"] .ds-sw .knob { left: 4px; background: #1d2340; }
html[data-ds="paper"] .ag-cards { padding-bottom: 88px; }

html[data-ds="diary"] .ds-sw { background: #ffffff; box-shadow: inset 0 0 0 2px #2a2630, 0 12px 24px -14px rgba(42, 38, 48, .6); }
html[data-ds="diary"] .ds-sw a { color: #5d5866; }
html[data-ds="diary"] .ds-sw a[aria-current] { color: #ffffff; }
html[data-ds="diary"] .ds-sw .knob { left: 50%; background: #2a2630; }

/* ───── 전환 ───── */
::view-transition-group(ds-sw) { animation-duration: .4s; }
::view-transition-old(root), ::view-transition-new(root) { mix-blend-mode: normal; }
::view-transition-old(root) { animation: ds-out .2s ease both; }
::view-transition-new(root) { animation: ds-in .25s ease both; }
@keyframes ds-out { to { opacity: 0; } }
@keyframes ds-in { from { opacity: 0; } }
html.t-diary .ds-sw .knob { animation: ds-knob-r .6s cubic-bezier(.23, 1, .32, 1) both; }
html.t-paper .ds-sw .knob { animation: ds-knob-l .6s cubic-bezier(.23, 1, .32, 1) both; }
@keyframes ds-knob-r { from { transform: translateX(-100%); } }
@keyframes ds-knob-l { from { transform: translateX(100%); } }

.ds-fx { display: none; position: fixed; inset: 0; z-index: 50; overflow: clip; pointer-events: none; }
.ds-tapes { view-transition-name: ds-tapes; }
.ds-ruler { view-transition-name: ds-ruler; }
::view-transition-new(ds-tapes), ::view-transition-new(ds-ruler) { animation: none; }

/* 일기로: 화면을 세 띠로 나눠 왼쪽부터 차례로 드러내고, 띠마다 테이프 한 줄이 같이 지나간다 */
html.t-diary::view-transition-old(root) { animation: none; }
html.t-diary::view-transition-new(root) {
  clip-path: polygon(0 0, var(--ds-x1) 0, var(--ds-x1) 34%, var(--ds-x2) 34%, var(--ds-x2) 67%, var(--ds-x3) 67%, var(--ds-x3) 100%, 0 100%);
  animation: ds-x1 .62s cubic-bezier(.77, 0, .175, 1) both, ds-x2 .62s cubic-bezier(.77, 0, .175, 1) .13s both, ds-x3 .62s cubic-bezier(.77, 0, .175, 1) .26s both; }
@keyframes ds-x1 { from { --ds-x1: 0%; } to { --ds-x1: 100%; } }
@keyframes ds-x2 { from { --ds-x2: 0%; } to { --ds-x2: 100%; } }
@keyframes ds-x3 { from { --ds-x3: 0%; } to { --ds-x3: 100%; } }
html.t-diary .ds-tapes { display: block; }
.ds-tapes i { position: absolute; left: -3%; width: 106%; height: 38px; margin-top: -19px; opacity: .92;
  animation: ds-slide .62s cubic-bezier(.77, 0, .175, 1) both, ds-out .22s ease .9s both; }
.ds-tapes i:nth-child(1) { top: 17%; background: #ffe27a; rotate: -1.2deg; }
.ds-tapes i:nth-child(2) { top: 50.5%; background: #9fe0cf; rotate: .9deg; animation-delay: .13s, .9s; }
.ds-tapes i:nth-child(3) { top: 83.5%; background: #cdbdf4; rotate: -.7deg; animation-delay: .26s, .9s; }
@keyframes ds-slide { from { transform: translateX(-100%); } }

/* 논문으로: 자의 손잡이가 왼쪽에서 오른쪽으로 지나가며 논문 화면을 드러낸다 */
html.t-paper::view-transition-old(root) { animation: none; }
html.t-paper::view-transition-new(root) { animation: ds-wipe .85s cubic-bezier(.77, 0, .175, 1) both; }
@keyframes ds-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
html.t-paper .ds-ruler { display: block; }
.ds-ruler i { position: absolute; inset: 0; animation: ds-slide .85s cubic-bezier(.77, 0, .175, 1) both, ds-out .12s ease .8s both; }
.ds-ruler i::before { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 26px; border-right: 4px solid #1d2340;
  background: repeating-linear-gradient(0deg, #1d2340 0 3px, transparent 3px 28px) right / 14px 100% no-repeat; }
.ds-ruler i::after { content: ""; position: absolute; right: -22px; top: 50%; width: 48px; height: 48px; margin-top: -24px; border-radius: 50%;
  background: #ff6f4f; border: 4px solid #1d2340; box-shadow: 0 6px 0 #1d2340; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .ds-sw .knob { transition: none; animation: none !important; }
  .ds-fx { display: none !important; }
}
