/* Adventskalender (ui/advent.js): Imperial Metin2 window style, 6x4 door grid on PC, 4-column thumb grid on Touch */

#ui #advent { width: 420px; }
html:not(.touch) #ui #advent { height: 344px; max-width: calc(100% - 8px); }
#ui #advent > .win-body { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; padding: 8px; overflow: hidden; }

/* Header panel: title, live countdown/status, 24-door progress bar */
#ui #advent .av-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 7px; border-radius: 2px;
  background: linear-gradient(90deg, #2e2017, #17120e 70%);
  box-shadow: inset 0 0 0 1px #6d5a36, inset 0 1px 0 #a8844238;
}
#ui #advent .av-meta { flex: 1 1 auto; min-width: 0; }
#ui #advent .av-title { font-size: 10px; line-height: 11px; color: var(--gold); text-shadow: 1px 1px 0 var(--ink); }
#ui #advent .av-sub { margin-top: 2px; font-size: 7px; line-height: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ui #advent .av-prog { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 68px; }
#ui #advent .av-count { font-size: 8px; line-height: 9px; color: #f0dfba; text-shadow: var(--ol); }
#ui #advent .av-bar {
  width: 68px; height: 4px; background: #0c0907;
  box-shadow: inset 0 0 0 1px #52432d; overflow: hidden;
}
#ui #advent .av-bar > b {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #a86c22, #ffd24a);
}

/* 24-door grid: 6x4 on PC, fits cleanly inside fixed height with internal scrolling fallback */
#ui #advent .av-grid {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: max-content; align-content: start;
  gap: 5px; padding: 2px;
}

/* Base door button (scoped under #advent, does not inherit generic .btn padding) */
#ui #advent .av-door {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0; height: 50px; padding: 2px; border: 0; border-radius: 2px;
  font: inherit; color: var(--text); text-align: center; overflow: hidden;
  background: linear-gradient(#211a14, #130f0c);
  box-shadow: inset 0 0 0 1px #4c3e2b, inset 0 1px 0 #7a644326, 0 1px 0 #00000080;
}
#ui #advent .av-door:focus { outline: none; }

/* Festive winter-crimson & antique gold highlight on milestone days (6, 12, 18, 24) */
#ui #advent .av-door.special {
  background: linear-gradient(#341715, #180c0b);
  box-shadow: inset 0 0 0 1px #8c6b36, inset 0 1px 0 #e6bd6b33, 0 1px 0 #00000088;
}
#ui #advent .av-star {
  position: absolute; top: 2px; right: 3px; z-index: 2; font-size: 7px; line-height: 7px;
  color: #f3c85c; text-shadow: var(--ol); pointer-events: none;
}

/* Door number pinned top-left cleanly over the door tile */
#ui #advent .av-num {
  position: absolute; top: 2px; left: 4px; z-index: 2;
  font-size: 9px; line-height: 10px; color: #e6d5af; text-shadow: var(--ol); pointer-events: none;
}
#ui #advent .av-door.special .av-num { color: #ffe08a; }
#ui #advent .av-date {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); z-index: 2;
  padding: 0 3px; font-size: 6px; line-height: 8px; white-space: nowrap;
  color: #d6c5a1; background: #140f0cd9; border-radius: 1px; pointer-events: none;
}

/* Pixel-art gift box sprite (unique color combination per door 1..24) */
#ui #advent .av-gift {
  display: block; width: 34px; height: 34px; margin-top: 2px;
  image-rendering: pixelated; pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .65));
}

/* Locked / waiting / missed states */
#ui #advent .av-door.locked .av-gift { margin-top: -2px; filter: brightness(.84) saturate(.9) drop-shadow(0 1px 1px rgba(0, 0, 0, .65)); }
#ui #advent .av-door.missed {
  background: linear-gradient(#171210, #0d0a09);
  box-shadow: inset 0 0 0 1px #3b2a26;
}
#ui #advent .av-door.missed .av-num { color: #8c766e; }
#ui #advent .av-door.missed .av-star { color: #7a6648; opacity: .65; }
#ui #advent .av-door.missed .av-gift { margin-top: -2px; opacity: .55; filter: grayscale(1) brightness(.55) drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
#ui #advent .av-door.wait {
  background: linear-gradient(#292017, #16110d);
  box-shadow: inset 0 0 0 1px #8c7448;
}
#ui #advent .av-door.wait .av-num { color: #f0d799; }
#ui #advent .av-door.wait .av-gift { margin-top: -2px; }

/* Ready door: clickable right now, Imperial gold glow & sheen (opacity/transform only!) */
#ui #advent .av-door.ready {
  background: linear-gradient(#422f16, #1b130a);
  box-shadow: inset 0 0 0 1px #d4a438, 0 0 5px #f2c45a44;
}
#ui #advent .av-door.ready.special {
  background: linear-gradient(#53211a, #210e0b);
  box-shadow: inset 0 0 0 1px #f2c45a, 0 0 6px #f2c45a55;
}
#ui #advent .av-door.ready .av-gift { margin-top: -2px; transition: transform .12s ease-out; }
#ui #advent .av-door.ready:hover .av-gift { transform: scale(1.07); }
#ui #advent .av-door.ready:hover { filter: brightness(1.1); }
#ui #advent .av-door.ready .av-num { color: #fff3c7; }
#ui #advent .av-door.ready::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px #ffd24a; animation: ring-pulse 1.6s ease-in-out infinite;
}
#ui #advent .av-door.ready::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 22%, #fff4c828 50%, transparent 78%);
  animation: av-shine 3.2s ease-in-out infinite;
}
@keyframes av-shine { 0%, 42% { transform: translateX(-110%); } 100% { transform: translateX(110%); } }

/* Small bottom pill on ready / wait doors */
#ui #advent .av-tag {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); z-index: 2;
  padding: 0 4px; max-width: calc(100% - 4px); border-radius: 1px;
  font-size: 6px; line-height: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #1a1206; background: linear-gradient(#ffe39a, #d1a043);
  box-shadow: inset 0 0 0 1px #7a561c, 0 1px 2px rgba(0, 0, 0, .7); pointer-events: none;
}
#ui #advent .av-tag.wait {
  color: #f0dfc0; background: #2c2217e8; box-shadow: inset 0 0 0 1px #8c7448, 0 1px 2px rgba(0, 0, 0, .7);
}
#ui #advent .av-tag.missed {
  color: #e6a099; background: #2a1412eb; box-shadow: inset 0 0 0 1px #6e3530, 0 1px 2px rgba(0, 0, 0, .7);
}

/* Opened door: revealed sunken item slot + green check mark */
#ui #advent .av-door.opened {
  justify-content: space-between; padding: 2px 3px 4px;
  background: linear-gradient(#16120e, #0f0c0a);
  box-shadow: inset 0 0 0 1px #362d20;
}
#ui #advent .av-door.opened.special {
  background: linear-gradient(#211311, #120b0a);
  box-shadow: inset 0 0 0 1px #614b2b;
}
#ui #advent .av-top {
  width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 10px;
}
#ui #advent .av-n-sm { font-size: 7px; line-height: 9px; color: var(--green); text-shadow: var(--ol); }
#ui #advent .av-tick {
  flex: none; width: 10px; height: 10px; background: var(--ic-tick) 0 0 / 10px 10px no-repeat;
}
#ui #advent .av-slot {
  position: relative; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: #090806 url('../assets/ui/imperial/slot.webp') center / cover;
  box-shadow: inset 0 0 0 1px #776443, inset 0 0 0 2px #080705;
}
#ui #advent .av-slot img { display: block; width: 18px; height: 18px; object-fit: contain; image-rendering: pixelated; }
#ui #advent .av-amt {
  position: absolute; right: 1px; bottom: 0; font-size: 6px; line-height: 7px;
  color: #fff6dc; text-shadow: var(--ol); pointer-events: none;
}
#ui #advent .av-more {
  position: absolute; left: 1px; top: 0; font-size: 6px; line-height: 7px;
  color: var(--gold); text-shadow: var(--ol); pointer-events: none;
}

/* One-shot reveal pop on newly opened door */
#ui #advent .av-door.pop { animation: av-pop .32s ease-out 1; }
@keyframes av-pop { 0% { transform: scale(.92); } 50% { transform: scale(1.06); } 100% { transform: none; } }

/* Footer bar: last reward summary / rule + action button */
#ui #advent .av-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 28px; padding: 4px 6px; border-radius: 2px;
  background: linear-gradient(#1c1814, #110e0c);
  box-shadow: inset 0 0 0 1px #47423a;
}
#ui #advent .av-foot-l { flex: 1 1 auto; min-width: 0; max-height: 44px; overflow-y: auto; }
#ui #advent .av-msg { font-size: 7px; line-height: 9px; }
#ui #advent .av-won { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; font-size: 7px; line-height: 9px; }
#ui #advent .av-won-h { flex: none; }
#ui #advent .av-won-it { display: inline-flex; align-items: center; gap: 3px; color: #f0e4ca; }
#ui #advent .av-won-it img { width: 12px; height: 12px; display: block; object-fit: contain; image-rendering: pixelated; }
#ui #advent .av-btn { flex: none; min-width: 96px; padding: 0 8px; }

/* Weapon choice overlay for class-weapon set doors */
#ui #advent .av-pick-back {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; padding: 10px;
  background: rgba(8, 6, 4, .82);
}
#ui #advent .av-pick-back.hidden { display: none; }
#ui #advent .av-pick {
  width: 100%; max-width: 380px; max-height: 100%; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 2px;
  background: linear-gradient(#271d15, #14100d);
  box-shadow: inset 0 0 0 1px #8c6b36, inset 0 1px 0 #e6bd6b33, 0 4px 12px rgba(0, 0, 0, .75);
}
#ui #advent .av-pick-t { font-size: 10px; line-height: 12px; color: var(--gold); text-shadow: 1px 1px 0 var(--ink); text-align: center; }
#ui #advent .av-pick-h { font-size: 7px; line-height: 9px; text-align: center; }
#ui #advent .av-pick-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px;
}
#ui #advent .av-pick-card {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 5px;
  min-width: 0; padding: 8px 6px; border: 0; border-radius: 2px; font: inherit; color: var(--text);
  background: linear-gradient(#211a14, #130f0c);
  box-shadow: inset 0 0 0 1px #52432d, inset 0 1px 0 #7a644326, 0 1px 0 #00000080;
}
#ui #advent .av-pick-card:hover:not(:disabled) {
  background: linear-gradient(#2d2218, #19130d);
  box-shadow: inset 0 0 0 1px #9c7d45, 0 1px 0 #00000080;
}
#ui #advent .av-pick-card.on {
  background: linear-gradient(#3f2c15, #1c130a);
  box-shadow: inset 0 0 0 1px #f2c45a, 0 0 6px #f2c45a44;
}
#ui #advent .av-pick-card:focus { outline: none; }
#ui #advent .av-pick-slot {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #090806 url('../assets/ui/imperial/slot.webp') center / cover;
  box-shadow: inset 0 0 0 1px #776443, inset 0 0 0 2px #080705;
}
#ui #advent .av-pick-card.on .av-pick-slot {
  box-shadow: inset 0 0 0 1px #f2c45a, inset 0 0 0 2px #080705;
}
#ui #advent .av-pick-slot img { display: block; width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; }
#ui #advent .av-pick-name {
  width: 100%; font-size: 8px; line-height: 10px; text-align: center;
  color: #f0e4ca; text-shadow: var(--ol); white-space: normal; overflow-wrap: anywhere;
}
#ui #advent .av-pick-card.on .av-pick-name { color: #ffe6a1; }
#ui #advent .av-pick-err { font-size: 7px; line-height: 9px; text-align: center; }
#ui #advent .av-pick-btns { margin-top: 2px; }

/* Touch / mobile landscape layout (44 CSS-px targets, 4 columns, full height) */
html.touch #ui #advent {
  width: min(420px, calc((100% - 12px) / var(--wz)));
  height: calc((100% - 8px) / var(--wz));
}
html.touch #ui #advent .av-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
html.touch #ui #advent .av-door {
  height: max(48px, var(--finger));
}
html.touch #ui #advent .av-gift {
  width: 36px; height: 36px;
}
html.touch #ui #advent .av-btn {
  min-height: var(--finger);
}
html.touch #ui #advent .av-pick-card {
  min-height: max(68px, var(--finger));
  padding: 8px;
}
html.touch #ui #advent .av-pick-btns .btn {
  min-height: var(--finger);
}
@media (prefers-reduced-motion: reduce) {
  #ui #advent .av-door.ready::before, #ui #advent .av-door.ready::after { animation: none; }
}
