/* Request 4: conversations (talk box), the talk prompt over people, the Adventure Log, the item popup */

/* ---------- conversation box (bottom of the screen, the world frozen above it) ---------- */
#talk {
  position: fixed; inset: 0; z-index: 32;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 12px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(rgba(10, 16, 24, 0) 40%, rgba(10, 16, 24, .6));
  cursor: pointer;
}
#talkBox {
  position: relative; width: min(92vw, 880px); min-height: 150px;
  display: flex; gap: 16px; align-items: flex-start;
  border-width: 26px;
}
#talkBox.pop { animation: talkIn .26s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes talkIn { from { transform: translateY(40px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
#talkPic {
  position: relative; flex: 0 0 auto; width: 116px; height: 116px; margin-top: -50px;
  border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #3a6274, #13212c 72%);
  border: 4px solid #e2a54a; box-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 0 3px #16202e;
}
#talkPic img { position: absolute; width: 205%; left: 50%; top: -4%; transform: translateX(-50%); }
#talkBox[data-speaker="k7"] #talkPic { border-color: var(--cyan); }
#talkBox[data-speaker="narr"] #talkPic { display: none; }
#talkBody { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#talkHead { display: flex; align-items: center; gap: 10px; min-height: 26px; }
#talkName { font-size: 22px; font-weight: 900; color: #ffd27a; line-height: 1.1; }
#talkBox[data-speaker="k7"] #talkName { color: var(--cyan); }
#talkTag {
  font-size: 12px; font-weight: 900; letter-spacing: .08em; color: #16202e;
  background: var(--cyan); padding: 2px 9px; border-radius: 6px;
  animation: radioBlink 1.2s ease-in-out infinite;
}
@keyframes radioBlink { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
#talkText {
  font-family: system-ui, sans-serif; font-size: 18px; line-height: 1.55; font-weight: 600; color: #f4f1e8;
  min-height: 3.1em; white-space: pre-line;
}
#talkBox[data-speaker="narr"] #talkText { font-style: italic; color: #d6e4ea; }
#talkNext {
  position: absolute; right: 2px; bottom: -8px; width: 0; height: 0;
  border-left: 11px solid transparent; border-right: 11px solid transparent; border-top: 15px solid #ffd27a;
  filter: drop-shadow(0 2px 0 #16202e); opacity: 0;
}
#talkNext.more { opacity: 1; animation: nextBob .7s ease-in-out infinite; }
@keyframes nextBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
#talkChoices {
  position: absolute; right: -14px; bottom: calc(100% + 12px);
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  width: max-content; max-width: min(440px, 80vw);
}
#talkChoices:empty { display: none; }
.gbtn.talkChoice {
  min-width: 230px; min-height: 48px; padding: 6px 22px;
  text-align: left; white-space: normal; font-size: 16px; line-height: 1.25;
  animation: choiceIn .26s cubic-bezier(.34, 1.56, .64, 1) both;
}
.gbtn.talkChoice.focus, .gbtn.talkChoice:hover { transform: translateX(-8px) scale(1.03); }
.gbtn.talkChoice:active { transform: scale(.95); }
@keyframes choiceIn { from { transform: translateX(36px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- the talk prompt floating over the nearest person ---------- */
#talkPrompt {
  position: fixed; left: 0; top: 0; z-index: 12;
  transform: translate(-50%, -100%);
  display: flex; align-items: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 3px 16px 3px 12px;
  font-size: 16px; white-space: nowrap; pointer-events: auto;
}
#talkPrompt.pop { animation: tpIn .3s cubic-bezier(.34, 1.56, .64, 1), tpBob 1.6s ease-in-out .3s infinite; }
@keyframes tpIn { from { transform: translate(-50%, -60%) scale(.4); opacity: 0; } to { transform: translate(-50%, -100%) scale(1); opacity: 1; } }
@keyframes tpBob { 0%, 100% { transform: translate(-50%, -100%); } 50% { transform: translate(-50%, calc(-100% - 5px)); } }
#talkPrompt:hover, #talkPrompt:active { animation: none; transform: translate(-50%, -100%) scale(1.06); }
#talkPrompt .tpKey {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 6px;
  background: #fff4dc; color: #16202e; font-size: 14px; text-shadow: none;
  box-shadow: 0 3px 0 #8a6a3a, 0 0 0 2px #16202e;
}
#talkPrompt .tpIcon {
  width: 28px; height: 28px; flex: 0 0 auto;
  background: url("assets/ui-talk.webp") center / contain no-repeat;
  filter: drop-shadow(0 2px 0 #16202e);
}

/* ---------- Adventure Log ---------- */
#journal {
  position: fixed; inset: 0; z-index: 31;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 40, 60, .55), rgba(8, 14, 22, .82));
  padding: 10px calc(10px + env(safe-area-inset-right, 0px)) 10px calc(10px + env(safe-area-inset-left, 0px));
}
#jrPanel { width: min(94vw, 980px); height: min(88vh, 600px); display: flex; flex-direction: column; gap: 8px; border-width: 26px; }
#jrPanel.pop { animation: pop .28s cubic-bezier(.34, 1.56, .64, 1); }
#jrHead { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
#jrTabs { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; }
.gbtn.jrTab {
  flex: 1 1 0; min-width: 0; min-height: 46px; padding: 4px 10px;
  font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: .7; filter: saturate(.55);
}
.gbtn.jrTab.on { opacity: 1; filter: brightness(1.12) drop-shadow(0 0 6px var(--cyan)); transform: translateY(-2px); }
.gbtn#jrClose { flex: 0 0 auto; width: 48px; height: 48px; min-width: 48px; min-height: 48px; padding: 0; font-size: 20px; }
#jrBody { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 38% 1fr; gap: 12px; }
#jrBody:has(#jrList.emptyList) { grid-template-columns: 1fr; }
#jrList.emptyList { display: none; }
#jrList { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 6px 4px 2px; }
.jrRow {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  min-height: 48px; padding: 6px 10px; border-radius: 10px;
  background: rgba(10, 22, 30, .5); border: 2px solid rgba(255, 217, 138, .2);
  font-weight: 900; font-size: 15px; line-height: 1.2; color: #fff4dc; cursor: pointer;
  text-shadow: 1.5px 0 0 #16202e, -1.5px 0 0 #16202e, 0 1.5px 0 #16202e, 0 -1.5px 0 #16202e;
  transition: transform .1s ease-out, background .12s, border-color .12s;
}
.jrRow:hover { background: rgba(95, 242, 255, .08); }
.jrRow.sel { background: rgba(95, 242, 255, .16); border-color: rgba(95, 242, 255, .85); transform: translateX(4px); box-shadow: 0 0 10px rgba(95, 242, 255, .3); }
.jrRow.locked { opacity: .5; }
.jrRow.done { opacity: .72; }
.jrRow img { width: 38px; height: 38px; object-fit: contain; flex: 0 0 auto; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .35)); }
.jrRow .num {
  flex: 0 0 auto; min-width: 30px; height: 30px; border-radius: 50%; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(95, 242, 255, .18); border: 2px solid var(--cyan);
}
.jrRow span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.jrRow .dm { width: 12px; height: 12px; flex: 0 0 auto; margin: 0 5px; transform: rotate(45deg); background: #8a96a3; box-shadow: 0 0 0 2px #16202e; }
.jrRow .dm.main { background: var(--cyan); box-shadow: 0 0 8px var(--cyan), 0 0 0 2px #16202e; }
.jrRow .dm.side { background: #ffd25a; box-shadow: 0 0 8px #ffd25a, 0 0 0 2px #16202e; }
#jrDetail {
  overflow-y: auto; min-width: 0; padding: 4px 10px 4px 14px;
  border-left: 2px solid rgba(255, 217, 138, .25);
  font-family: system-ui, sans-serif; font-size: 16px; line-height: 1.55; font-weight: 600; color: #f4f1e8;
}
#jrBody:has(#jrList.emptyList) #jrDetail { border-left: 0; }
#jrDetail.swap { animation: swapIn .22s ease-out; }
@keyframes swapIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
#jrDetail h3 { font-family: var(--font); font-weight: 900; margin: 4px 0 8px; font-size: 24px; color: #ffd27a; line-height: 1.2; }
#jrDetail p { margin: 0 0 8px; }
.jdTag {
  display: inline-block; font-family: var(--font); font-size: 12px; font-weight: 900; letter-spacing: .1em;
  padding: 2px 10px; border-radius: 6px; background: rgba(95, 242, 255, .18); color: var(--cyan);
}
.jdTag.side { background: rgba(255, 210, 90, .18); color: #ffd25a; }
.jdTag.done { background: rgba(160, 170, 180, .2); color: #c9d2da; }
.jdGiver { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-family: var(--font); font-weight: 900; font-size: 14px; color: #ffd98a; }
.gpic {
  position: relative; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; overflow: hidden;
  border: 3px solid #e2a54a; background: radial-gradient(circle at 50% 38%, #3a6274, #13212c 72%);
}
.gpic img { position: absolute; width: 205%; left: 50%; top: -4%; transform: translateX(-50%); }
.jdSteps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.jdSteps li { display: flex; align-items: flex-start; gap: 10px; font-family: var(--font); font-weight: 900; font-size: 15px; line-height: 1.3; }
.jdSteps li i { position: relative; flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; border-radius: 4px; border: 2px solid #ffd98a; background: rgba(0, 0, 0, .3); }
.jdSteps li.done { color: #9aa6ad; text-decoration: line-through; text-decoration-thickness: 2px; }
.jdSteps li.done i { background: #2dbb63; border-color: #8ff7a8; }
.jdSteps li.done i::after { content: ""; position: absolute; left: 4px; top: 0; width: 5px; height: 9px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.jdSteps li.cur { color: #fff4dc; }
.jdSteps li.cur i { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: lowhp .7s ease-in-out infinite alternate; }
.jdIconWrap { display: flex; justify-content: center; margin: 2px 0 4px; }
.jdIcon { width: 120px; height: 120px; object-fit: contain; filter: drop-shadow(0 0 14px rgba(255, 210, 90, .45)) drop-shadow(0 3px 0 rgba(0, 0, 0, .35)); }
#jrDetail .empty, #jrDetail .locked { color: #b8c4cc; font-style: italic; text-align: center; margin-top: 28px; }

/* ---------- item popup (inside the modal) ---------- */
.itemGet { display: flex; justify-content: center; margin: 2px 0 8px; }
.itemGet img {
  width: 112px; height: 112px; object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(255, 210, 90, .65)) drop-shadow(0 3px 0 rgba(0, 0, 0, .35));
  animation: itemIn .6s cubic-bezier(.34, 1.56, .64, 1) both, float2 3s ease-in-out .6s infinite;
}
@keyframes itemIn { from { transform: scale(.3) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* the quest tracker opens the log: a thumb-sized hit area */
#quests { pointer-events: auto; cursor: pointer; min-height: 44px; min-width: 44px; }
#quests .qi { transition: filter .12s, transform .1s; }
#quests:hover .qi { filter: brightness(1.12); }
#quests:active .qi { transform: scale(.97); }

@media (max-height: 460px) {
  #talk { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  #talkBox { width: min(94vw, 880px); min-height: 100px; gap: 10px; border-width: 18px; }
  #talkPic { width: 70px; height: 70px; margin-top: -30px; border-width: 3px; }
  #talkHead { min-height: 20px; }
  #talkName { font-size: 17px; }
  #talkText { font-size: 15px; line-height: 1.42; min-height: 2.84em; }
  #talkNext { bottom: -6px; }
  #talkChoices { right: -10px; bottom: calc(100% + 6px); gap: 6px; }
  .gbtn.talkChoice { min-width: 190px; min-height: 44px; padding: 3px 14px; font-size: 14px; }
  #talkChoices:has(> :nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; max-width: min(600px, 88vw); }
  #talkPrompt { font-size: 14px; padding: 2px 12px 2px 8px; }
  #talkPrompt .tpIcon { width: 24px; height: 24px; }
  #jrPanel { width: 96vw; height: 94vh; gap: 4px; border-width: 18px; }
  .gbtn.jrTab { font-size: 14px; min-height: 44px; }
  .gbtn#jrClose { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  #jrBody { gap: 8px; }
  #jrList { gap: 4px; }
  .jrRow { min-height: 44px; padding: 3px 8px; gap: 8px; font-size: 13px; }
  .jrRow img { width: 30px; height: 30px; }
  .jrRow .num { min-width: 26px; height: 26px; font-size: 13px; }
  #jrDetail { font-size: 14px; line-height: 1.45; padding-left: 10px; }
  #jrDetail h3 { font-size: 19px; margin: 2px 0 4px; }
  .jdIcon { width: 72px; height: 72px; }
  .jdSteps li { font-size: 13px; }
  .gpic { width: 38px; height: 38px; }
  .itemGet img { width: 76px; height: 76px; }
}
