/* ============================================================
   PVE screen (Battle + Dungeons) — "Forged Lantern". Loaded after
   ui-battle.css. The shared team bar (.teamBar, built by ui/team-bar.js) is
   written here but is a generic component: PVP screens can reuse it.
   Cursors: never a bare value (CLAUDE.md §4). No backdrop-filter here
   (scroll performance, CLAUDE.md §7).
   ============================================================ */

/* ---------- head: sub-tabs + team bar ---------- */
.pveHead{ display: flex; align-items: center; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; margin-bottom: 14px; }
.pveTabs{
  display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px;
  background-image: var(--grain), var(--glass-bg); background-color: var(--glass-fill);
  border: 1px solid var(--c-line); box-shadow: var(--sh-1);
}
.pveTab{
  min-height: 44px; padding: 0 22px; border: 0; border-radius: 999px; background: transparent; color: var(--c-dim);
  font: 600 .95rem var(--f-body); letter-spacing: 0; text-transform: none; flex: none; box-shadow: none;
  cursor: var(--cur-click, pointer); transition: background var(--t-fast), color var(--t-fast);
}
.pveTab:hover{ background: transparent; color: var(--c-text); border-color: transparent; }
.pveTab.on, .pveTab.active{ background: hsl(var(--h) 30% 92% / .1); color: var(--accent-hi); box-shadow: inset 0 0 0 1px hsl(var(--h) 40% 70% / .3); }
.pveTabs.sm{ margin-bottom: 12px; }
.pveTabs.sm .pveTab{ min-height: 40px; padding: 0 16px; font-size: .88rem; }

/* ---------- the shared team bar ---------- */
.teamBar{ display: flex; align-items: center; gap: 14px; min-width: 0; }
.teamBar .dd{ flex: 0 0 auto; width: 150px; }
.teamFaces{ display: flex; gap: 8px; }
.tf{ display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.tfFace{
  display: block; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex: none;
  border: 3px solid hsl(var(--h) 42% 56%); background: #111; box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
.tfFace .heroPortrait{ width: 100%; height: 100%; border-radius: 0; box-shadow: none; object-fit: cover; display: block; }
.tfFace.empty{ border: 2px dashed var(--c-line); background: none; box-shadow: none; }
.tfName, .tfLvl{ display: none; font-style: normal; }

/* wide: the bar is its own transparent, borderless row under the tabs, with names and levels */
@media (min-width: 901px){
  .pveHead{ display: grid; grid-template-columns: 1fr; gap: 12px; }
  .pveHead .pveTabs{ justify-self: start; }
  .teamBar{ flex-direction: column; align-items: flex-start; gap: 16px; padding: 6px 8px; }
  .teamBar .dd{ width: clamp(150px, 14vw, 210px); }
  .teamFaces{ display: flex; flex-wrap: wrap; gap: clamp(14px, 1.6vw, 24px); }
  /* each unit is exactly as wide as its portrait, so the gaps between portraits
     stay even; a long name wraps on 2 lines at most, then "…" */
  .tf{ width: calc(clamp(64px, 7.2vw, 112px) / var(--ui-zoom, 1)); }
  .tfFace{ width: 100%; height: auto; aspect-ratio: 1; }
  .tfName{
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
    width: 100%; font: 700 clamp(.8rem, 1vw, .98rem)/1.2 var(--f-display); text-align: center; overflow-wrap: break-word;
  }
  .tfLvl{ display: block; font: 600 .75rem var(--f-body); color: var(--c-dim); }
  .tf:has(.empty) .tfFace{ opacity: .6; }
}
@media (max-width: 900px){
  .pveHead{ flex-direction: column; align-items: stretch; gap: 10px; }
  .pveTabs{ align-self: flex-start; }
  .teamBar{ gap: 10px; }
  .teamBar .dd{ width: 128px; }
  .teamFaces{ flex: 1; justify-content: flex-end; gap: 6px; }
  .tfFace{ width: min(44px, calc((100vw - 220px) / 5)); height: auto; aspect-ratio: 1; border-width: 2px; }
}

/* ---------- Battle: mode tiles + launch row ---------- */
.pveBattle{ display: flex; flex-direction: column; gap: 18px; }
.modeGrid{ display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
button.modeTile{
  position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  gap: 10px; flex: none; min-height: clamp(120px, 20vh, 190px); padding: 20px 22px; border-radius: 26px; text-align: left; text-transform: none; letter-spacing: 0;
  border: 1px solid var(--c-line); color: var(--c-text); background-color: #0b0e0c; background-image: var(--art); background-size: cover; background-position: center; background-repeat: no-repeat;
  cursor: var(--cur-click, pointer); transition: transform var(--t-med) var(--ease), border-color var(--t-med), box-shadow var(--t-med);
}
.modeTile::before{
  content: ""; position: absolute; inset: 0; z-index: -1; transition: opacity var(--t-med);
  background: linear-gradient(180deg, hsl(var(--h) 25% 4% / .15) 0%, hsl(var(--h) 25% 4% / .55) 55%, hsl(var(--h) 25% 3% / .9) 100%);
}
.modeTile:hover::before, .modeTile.active::before{ opacity: .8; }
.modeTile b{ display: flex; align-items: center; gap: 8px; font: 700 clamp(1.3rem, 2vw, 1.8rem) var(--f-display); text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.modeTile > span{
  font: 600 .9rem var(--f-body); color: var(--c-text); padding: 3px 12px; border-radius: 999px;
  background: hsl(var(--h) 25% 6% / .7); border: 1px solid var(--c-line);
}
button.modeTile:hover{ transform: translateY(-4px); border-color: hsl(var(--h) 45% 64% / .6); background-image: var(--art); color: var(--c-text); }
button.modeTile.active{ border-color: var(--accent-hi); box-shadow: 0 0 0 2px hsl(var(--h) 55% 70% / .35), var(--sh-1); color: var(--c-text); }
.modeTile.active b{ color: var(--accent-hi); }
.mIcon{
  position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-style: normal;
  background: hsl(var(--h) 25% 6% / .6); border: 1px solid var(--c-line); color: var(--accent-hi);
}
.mIcon .i{ width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.modeTile.nightmare .mIcon{ color: var(--c-danger); }

.pveGo{ display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: space-between; padding: 6px 4px; }
.pveGo .battleHint{ flex: 1 1 220px; font: 400 .9rem var(--f-body); color: var(--c-dim); }
.pveGo #battleBtn{ min-width: 240px; flex: none; }
@media (min-width: 901px){
  .pveBattle{ margin-top: clamp(14px, 3vh, 36px); gap: clamp(22px, 4vh, 44px); }
}
@media (max-width: 900px){
  .pveBattle{ min-height: calc(100dvh - 255px); gap: 12px; }
  .modeGrid{ grid-template-columns: 1fr 1fr; gap: 10px; }
  .modeTile{ min-height: 96px; padding: 14px 16px; border-radius: 20px; }
  .modeTile b{ font-size: 1.1rem; }
  .mIcon{ top: 10px; right: 10px; width: 34px; height: 34px; }
  .mIcon .i{ width: 19px; height: 19px; }
  .modeTile.endless{ grid-column: 1 / -1; min-height: 76px; flex-direction: row; align-items: center; padding-right: 56px; }
  .modeTile.endless > span{ margin-left: auto; }
  .modeTile.endless .mIcon{ top: 50%; transform: translateY(-50%); }
  /* the launch row sticks to the bottom of the screen, always in thumb reach */
  .pveGo{
    position: sticky; bottom: 10px; margin-top: auto; flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; border-radius: 24px; text-align: center;
    background: hsl(var(--h) 14% 8% / .94); border: 1px solid var(--c-line); box-shadow: var(--sh-2); z-index: 5;
  }
  .pveGo .battleHint{ flex: none; text-align: center; }
  .pveGo #battleBtn{ min-width: 0; width: 100%; }
}

/* ---------- Dungeons ---------- */
.pveHint{ margin: 0 0 14px; }
.dGrid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(220px, 18vw, 300px), 1fr)); gap: 16px; }
.dEmpty{ grid-column: 1 / -1; border: 0; padding: 0; }
.dCard{
  display: flex; flex-direction: column; border-radius: 24px; overflow: hidden; border: 1px solid var(--c-line); box-shadow: var(--sh-1);
  background-image: var(--grain), var(--glass-bg); background-color: hsl(var(--h) 16% 8% / .82);
  transition: transform var(--t-med) var(--ease), border-color var(--t-med);
}
.dCard:hover{ transform: translateY(-5px); border-color: var(--accent); }
.dArt{ position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #0b0e0c; }
.dArt .dungeonThumb{ width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--ease); }
.dArt .heroArtFallback{ font-size: 3rem; }
.dCard:hover .dArt .dungeonThumb{ transform: scale(1.05); }
.dCard.locked .dArt .dungeonThumb{ filter: grayscale(.8) brightness(.55); }
.dLock{ position: absolute; inset: 0; display: grid; place-items: center; color: var(--c-text); }
.dLock .i{ width: 38px; height: 38px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dBody{ display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 18px; }
.dName{ font: 700 1.2rem/1.2 var(--f-display); color: var(--c-text); }
.dMeta{ display: flex; gap: 8px; flex-wrap: wrap; }
.dMeta .chip{
  display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font: 600 .8rem var(--f-body); color: var(--c-dim);
  background: hsl(var(--h) 25% 96% / .07); border: 1px solid var(--c-line);
}
.dMeta .d-medium{ color: var(--accent-hi); } .dMeta .d-hard{ color: #e8a05f; } .dMeta .d-nightmare{ color: var(--c-danger); } .dMeta .d-easy{ color: var(--c-ok); }
.dReq small{ display: block; font: 700 .7rem var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--c-dim); margin-bottom: 4px; }
.dReq ul{ margin: 0; padding-left: 18px; font: 500 .85rem/1.5 var(--f-body); color: var(--c-dim); }
.dNote{ font: 500 .82rem/1.45 var(--f-body); color: var(--c-dim); }
.dGo{ width: 100%; min-height: 48px; margin-top: 4px; font: 700 .95rem var(--f-display); text-transform: none; letter-spacing: 0; }
.dGo[disabled]{ opacity: .45; }

@media (prefers-reduced-motion: reduce){
  .modeTile, .dCard, .dArt .dungeonThumb, .pveTab{ transition: none; }
}
