/* ═══════════════════════════════════════════════════════════════
   zakiram.css — 여신의 자리

   영상 두 겹을 겹쳐 놓고 불투명도로만 건너뛴다. 한 겹이 끝나 갈
   때쯤 다른 겹이 이미 재생 중이므로, 화면에는 끊긴 자리가 없다.
   자세한 것은 js/zakiram/stage.js.
   ═══════════════════════════════════════════════════════════════ */

.zak {
  position: relative;
  margin: 0;
  display: grid;
  gap: var(--s-3);
}

/* ── 후광 ── 기분에 따라 색이 아주 천천히 변한다 ── */
.zak__halo {
  position: absolute;
  inset: -14% -14% -6%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--halo, rgba(208, 171, 99, .22)), transparent 72%);
  filter: blur(26px);
  opacity: .9;
  transition: background 2.4s var(--ease);
  animation: breathe 9s var(--ease-in-out) infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: .78; }
  50%      { transform: scale(1.07); opacity: 1; }
}

/* ── 틀 ── */
.zak__frame {
  position: relative;
  z-index: 1;
  aspect-ratio: 612 / 828;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--ink-850) center/cover no-repeat;
  box-shadow: var(--lift), inset 0 0 60px rgba(0, 0, 0, .5);
  isolation: isolate;
}

/* 바닥의 정지 초상 — 영상이 무엇 때문에든 못 뜰 때 남는 마지막 그림 */
.zak__still {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.zak__layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* 겹침 시간은 stage.js 가 --xfade 로 정한다 */
  transition: opacity var(--xfade, 520ms) linear;
  will-change: opacity;
  backface-visibility: hidden;
}
.zak__layer.is-on { opacity: 1; }

/* 영상을 아예 못 불러왔을 때 — 정지 초상만 남는다는 것을 알려 준다 */
.zak.is-videoless .zak__layer { display: none; }
.zak.is-videoless .zak__frame::after {
  content: "영상을 불러오지 못했습니다";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 6;
  padding: 6px;
  text-align: center;
  background: rgba(140, 54, 38, .88);
  color: var(--gold-100);
  font-size: var(--t-xs);
  letter-spacing: .02em;
}

/* ── 색조 ── 기분에 따라 그림 전체가 살짝 물든다 ── */
.zak__tone {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: soft-light;
  background: var(--tone, transparent);
  opacity: .55;
  transition: background 2.4s var(--ease);
}

/* ── 어스름 ── 아래를 눌러 글자가 얹히게 ── */
.zak__scrim {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(96% 72% at 50% 38%, transparent 52%, rgba(6, 4, 16, .55) 100%),
    linear-gradient(to top, rgba(6, 4, 16, .82), transparent 34%);
}

/* ── 입 ── 음소를 따라 움직인다 (js/zakiram/mouth.js) ──

   자리와 크기는 설정에서 정한다. 얼굴 위에 겹치는 것이라 조금만
   어긋나도 눈에 거슬리므로, 입술을 흉내 내는 대신 금빛 획 하나로
   짚는다. 어긋나도 그저 빛이고, 맞으면 말을 한다. */
.zak__mouth {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  aspect-ratio: 1 / 1;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 6px rgba(224, 196, 137, .55));
}
.zak__mouth svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* 입 안 — 벌어진 것이 보이려면 안쪽이 어두워야 한다 */
.zak__mouth-in {
  fill: rgba(38, 10, 16, .5);
}
/* 입술 — 획 하나 */
.zak__mouth-lip {
  fill: none;
  stroke: var(--gold-200, #efd9a8);
  stroke-width: 3.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* 맞추는 동안에는 어디에 있는지 또렷하게 보여 준다 */
.zak.is-aligning .zak__mouth {
  mix-blend-mode: normal;
  outline: 1px dashed rgba(224, 196, 137, .5);
  outline-offset: 6px;
}
.zak.is-aligning .zak__frame { cursor: crosshair; }

/* ── 말결 ── 말할 때만 아래에서 흔들린다 ── */
.zak__wave {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 4;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.zak.is-speaking .zak__wave { opacity: .85; }
.zak__wave i {
  display: block;
  width: 2px;
  height: 4px;
  border-radius: 2px;
  background: var(--gold-300);
  box-shadow: 0 0 8px rgba(224, 196, 137, .7);
  animation: sing 1s var(--ease-in-out) infinite;
}
.zak__wave i:nth-child(1) { animation-delay: 0s;    }
.zak__wave i:nth-child(2) { animation-delay: .13s;  }
.zak__wave i:nth-child(3) { animation-delay: .26s;  }
.zak__wave i:nth-child(4) { animation-delay: .39s;  }
.zak__wave i:nth-child(5) { animation-delay: .52s;  }
@keyframes sing {
  0%, 100% { height: 4px;  opacity: .5; }
  50%      { height: 17px; opacity: 1; }
}

/* ── 말할 때 테두리가 살아난다 ── */
.zak.is-speaking .zak__frame {
  border-color: rgba(224, 196, 137, .38);
  box-shadow: var(--lift), inset 0 0 60px rgba(0, 0, 0, .5),
              0 0 46px -10px rgba(208, 171, 99, .42);
}

/* ── 멈춰 섰을 때 ──
   자동 재생이 막히면 자키람이 정지 화면처럼 보인다. 그냥 두면
   고장인지 원래 그런 것인지 알 수가 없으므로 눌러 달라고 말한다. */
.zak__wake {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  padding: var(--s-3);
  text-align: center;
  background: rgba(6, 4, 16, .62);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  color: var(--gold-200);
  font-size: var(--t-xs);
  line-height: 1.6;
  letter-spacing: .04em;
  cursor: pointer;
}
.zak.is-stalled .zak__wake { display: grid; }
.zak__wake b {
  display: block;
  font-family: var(--f-greek);
  font-size: var(--t-lg);
  margin-bottom: 4px;
  font-weight: 400;
}

/* ── 이름표 ── */
.zak__id {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 0 2px;
}
.zak__name {
  font-family: var(--f-greek);
  font-size: 1.14rem;
  color: var(--gold-300);
  letter-spacing: .1em;
}
.zak__mood {
  font-size: var(--t-xs);
  letter-spacing: .18em;
  color: var(--tx-500);
  transition: color var(--dur-slow) var(--ease);
}

/* 기분별 색조 — data-mood 로 갈린다 */
.zak[data-mood="serene"]  { --halo: rgba(120, 132, 190, .22); --tone: rgba(96, 112, 178, .16); }
.zak[data-mood="talk"]    { --halo: rgba(208, 171, 99, .22);  --tone: transparent; }
.zak[data-mood="bright"]  { --halo: rgba(226, 158, 86, .28);  --tone: rgba(232, 176, 104, .18); }
.zak[data-mood="elated"]  { --halo: rgba(232, 132, 92, .34);  --tone: rgba(236, 154, 96, .24); }
.zak[data-mood="grave"]   { --halo: rgba(74, 108, 168, .26);  --tone: rgba(64, 96, 168, .22); }
.zak[data-mood="sorrow"]  { --halo: rgba(58, 78, 142, .30);   --tone: rgba(48, 72, 148, .30); }
.zak[data-mood="alert"]   { --halo: rgba(207, 90, 65, .38);   --tone: rgba(210, 88, 62, .22); }
.zak[data-mood="intense"] { --halo: rgba(184, 69, 92, .30);   --tone: rgba(178, 72, 96, .18); }

.zak[data-mood="alert"] .zak__halo { animation-duration: 3.4s; }

@media (prefers-reduced-motion: reduce) {
  .zak__halo { animation: none; }
  .zak__wave i { animation: none; height: 9px; }
}

.rail__controls { display: grid; gap: var(--s-2); }

.rail__meta { padding: 0 2px; }

.meter {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-xs);
  color: var(--tx-500);
}
.meter__label { letter-spacing: .1em; }
.meter__bar {
  position: relative;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--down), var(--ink-500) 50%, var(--up));
  opacity: .5;
}
.meter__bar i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--gold-200);
  box-shadow: 0 0 12px rgba(224, 196, 137, .8);
  transition: left 1.4s var(--ease);
}
.meter__val {
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  color: var(--tx-300);
  min-width: 3.4em;
  text-align: right;
}
