/* Wardrobe dressing room (js/wardrobe.js): 3D stage + Trainer / Pokémon switch + category tabs + the Mall's cards
   (cosmetics.css .ml-card) + one context button.
   Desktop / tablet: stage column left, cards right. Phone portrait: stage on top (~34% of the height), the switch, tabs,
   a scrolling grid, the action bar pinned at the bottom. Short landscape phones: two columns, name over the stage. */

.wdr-panel .modal-body { display: flex; overflow: hidden; padding: 14px; }
.wdr {
  --wd-gold: #ffcf4a; --wd-cyan: #55d6ff; --wd-edge: #2e55a8;
  position: relative; flex: 1; min-width: 0; min-height: 0;
  display: grid; grid-template-columns: minmax(290px, 37%) minmax(0, 1fr); gap: 16px;
}
.wdr-left, .wdr-right { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }

/* ---------------------------------------------------------------- stage */
.wdr-show { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.wdr-stage {
  position: relative; flex: 1; min-height: 240px; border-radius: 18px; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(ellipse 60% 22% at 50% 86%, rgba(85, 214, 255, .22), transparent 70%),
    radial-gradient(ellipse 80% 70% at 50% 35%, #2a2f86 0%, #1a2163 45%, #0b1036 100%);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .45);
}
.wdr-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; cursor: grab; display: block; outline: none; }
.wdr-stage.grab .wdr-canvas { cursor: grabbing; }
/* light cones from the top corners */
.wdr-cone {
  position: absolute; top: -6%; width: 46%; height: 98%; z-index: 2; pointer-events: none; mix-blend-mode: screen; opacity: .3;
  clip-path: polygon(44% 0, 56% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(214, 170, 255, .75), rgba(150, 110, 255, .12) 70%, transparent);
  transform-origin: 50% 0; animation: wdr-sway 7s ease-in-out infinite;
}
.wdr-cone.l { left: 2%; transform: rotate(-24deg); }
.wdr-cone.r { right: 2%; transform: rotate(24deg); animation-delay: -3.5s; background: linear-gradient(180deg, rgba(150, 225, 255, .7), rgba(85, 214, 255, .12) 70%, transparent); }
@keyframes wdr-sway { 0%, 100% { rotate: 0deg; } 50% { rotate: 6deg; } }
.wdr-cone.r { animation-name: wdr-sway-r; }
@keyframes wdr-sway-r { 0%, 100% { rotate: 0deg; } 50% { rotate: -6deg; } }
.wdr-loading[hidden] { display: none; }
.wdr-loading { position: absolute; left: 50%; top: 45%; margin: -12px 0 0 -12px; width: 24px; height: 24px; z-index: 4; }
.wdr-hint {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 4; pointer-events: none;
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; white-space: nowrap;
  font-size: 12px; font-weight: 800; color: #dfe8ff; background: rgba(6, 12, 40, .55); transition: opacity .5s;
}
.wdr-hint .ic { width: 15px; height: 15px; }
.wdr-stage.used .wdr-hint { opacity: 0; }
.wdr-zoom { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 4; display: flex; flex-direction: column; gap: 6px; }
.wdr-zoom button {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; color: #fff;
  background: rgba(10, 20, 60, .65); border: 1.5px solid rgba(160, 190, 255, .35);
}
.wdr-zoom button:hover { background: rgba(30, 50, 120, .85); }
.wdr-zoom .ic { width: 18px; height: 18px; }

/* name + subtitle + colours under the stage */
.wdr-info { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; min-height: 52px; }
.wdr-name { font: 400 24px/1.1 'Lilita One', Nunito, sans-serif; letter-spacing: .5px; color: var(--wd-gold); text-shadow: 0 2px 0 #7a4a00; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wdr-sub { color: #cfdaf7; font-size: 13px; font-weight: 700; }
.wdr-swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 0; margin-top: 2px; }
.wdr-sw { position: relative; width: 38px; height: 38px; padding: 0; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.wdr-sw::before {
  content: ''; width: 26px; height: 26px; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 0 0 2px rgba(255, 255, 255, .25); transition: transform .12s, box-shadow .12s;
}
.wdr-sw[style*="#ffffff"]::before { background: conic-gradient(#ff8c8c, #ffd36b, #8de38d, #7cc7ff, #c59bff, #ff8c8c); }
.wdr-sw:hover::before { transform: scale(1.1); }
.wdr-sw.on::before { box-shadow: 0 0 0 3px var(--wd-gold), 0 0 10px rgba(255, 207, 74, .7); transform: scale(1.08); }
.wdr-sw.custom::before { background: radial-gradient(circle at 50% 50%, var(--c) 0 45%, transparent 47%), conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.wdr-sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* ---------------------------------------------------------------- actions */
.wdr-actions { display: flex; flex-direction: column; gap: 8px; }
.wdr-go {
  min-height: 52px; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 16px;
  border-radius: 14px; font: 900 18px/1.1 Nunito, sans-serif; color: #3a2400; cursor: pointer;
  background: linear-gradient(#ffe07a, var(--gold-2)); border: 2px solid rgba(255, 238, 180, .9);
  box-shadow: 0 4px 0 #a86a00, 0 8px 18px rgba(0, 0, 0, .35); transition: transform .1s, filter .15s;
}
.wdr-go:hover:not(:disabled) { filter: brightness(1.06); }
.wdr-go:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #a86a00; }
.wdr-go .ic { width: 22px; height: 22px; }
.wdr-go .dia { width: 20px; height: 20px; vertical-align: -4px; }
.wdr-go b { font-weight: 900; }
.wdr-go.buy { background: linear-gradient(#7fe3ff, #2fa8e8); color: #04213a; border-color: #c9f3ff; box-shadow: 0 4px 0 #136a9c, 0 8px 18px rgba(0, 0, 0, .35); }
.wdr-go.confirm { background: linear-gradient(#7ef0a4, #22b860); color: #052a14; border-color: #c7ffd9; box-shadow: 0 4px 0 #11703a; animation: wdr-pulse 0.9s ease-in-out infinite; }
@keyframes wdr-pulse { 50% { filter: brightness(1.12); transform: scale(1.015); } }
.wdr-go.short { background: #10224f; color: #bfefff; border: 2px dashed var(--wd-cyan); box-shadow: none; font-size: 16px; }
.wdr-go:disabled { background: #1a2a58; color: #a9b8de; border-color: #33508f; box-shadow: none; cursor: default; }
.wdr-go .spin.sm { border-color: currentColor; border-top-color: transparent; }
.wdr-extra { display: flex; gap: 8px; }
.wdr-extra .btn { min-height: 44px; }
.wdr-extra [data-act="base"] { flex: 1; }
.wdr-extra .btn.icon-only:first-child { margin-left: auto; }
.wdr-extra .btn.icon-only { width: 44px; padding: 0; }
.wdr-extra .btn .ic { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- Trainer / Pokémon switch + tabs + tools */
.wdr-tabwrap { display: flex; flex-direction: column; gap: 8px; }
/* the two worlds: one big segmented switch (same names and icons as the Mall's sidebar groups) */
.ap-worlds { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.ap-world {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 0; border-radius: 11px; cursor: pointer;
  background: none; color: var(--muted); font: 900 15px Nunito, sans-serif; transition: background .15s, color .15s;
}
.ap-world .ic { width: 22px; height: 22px; }
.ap-world:hover { color: var(--text); }
.ap-world.on { background: linear-gradient(#ffe07a, var(--gold-2)); color: #3a2400; box-shadow: 0 2px 0 #a86a00; }
.ap-world:focus-visible { outline: none; box-shadow: var(--focus); }
/* the world's categories in one row */
.wdr-tabs { --n: 4; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
.wdr-tab {
  position: relative; min-width: 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 5px 4px; border-radius: 12px; cursor: pointer;
  font: 800 14px Nunito, sans-serif; color: var(--muted); background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .08);
  transition: background .15s, color .15s, border-color .15s;
}
.wdr-tab:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.wdr-tab .ic { width: 20px; height: 20px; }
.wdr-tab span { font-size: 12.5px; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wdr-tab.on { color: var(--text); background: var(--surface-2); border-color: var(--wd-gold); box-shadow: inset 0 -3px 0 var(--wd-gold); }
.wdr-tab:focus-visible { outline: none; box-shadow: var(--focus); }
.wdr-tab.link { border-style: dashed; }
.wdr-tab.link .go { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; opacity: .7; }
.wdr[data-world="pokemon"] .wdr-tab { flex-direction: row; gap: 8px; }
.wdr[data-world="pokemon"] .wdr-tab span { font-size: 14px; }

.wdr-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wdr-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.wdr-seg button { min-height: 34px; padding: 0 14px; border-radius: 9px; border: 0; background: none; color: var(--muted); font: 800 13px Nunito, sans-serif; cursor: pointer; }
.wdr-seg button.on { background: var(--surface-2); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.wdr-count { color: var(--muted); font-size: 13px; font-weight: 700; }
.wdr-count b { color: #fff; }
.wdr-sort { margin-left: auto; position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; min-height: 36px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.wdr-sort .ic { width: 18px; height: 18px; }
.wdr-sort select { appearance: none; -webkit-appearance: none; background: none; border: 0; color: #fff; font: 800 13px Nunito, sans-serif; padding: 6px 2px; cursor: pointer; }
.wdr-sort select option { background: #121c3a; }

/* ---------------------------------------------------------------- cards: the Mall's .ml-card + try-on states */
.wdr-grid {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; align-content: start;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 10px; padding: 4px 4px 8px;
}
.wdr-grid .wdr-gh { margin: 8px 2px 0; }
.wdr-grid .wdr-gh:first-child { margin-top: 2px; }
.wdr-pic img { -webkit-user-drag: none; user-select: none; }
.wdr-none { display: grid; place-items: center; width: 46%; aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(190, 210, 255, .4); color: rgba(210, 225, 255, .6); }
.wdr-none .ic { width: 60%; height: 60%; }
.wdr-card.sel { border-color: var(--wd-cyan); box-shadow: 0 0 0 2px var(--wd-cyan), 0 0 16px rgba(85, 214, 255, .35); }
.wdr-card.locked .ml-pic img { filter: grayscale(.55) brightness(.72); }
.wdr-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 12px; text-align: center; color: var(--muted); }
.wdr-empty b { color: #fff; }

/* ---------------------------------------------------------------- change base sheet */
.wdr-sheet { position: absolute; z-index: 10; top: 0; right: 0; bottom: 0; width: calc(63% - 8px); display: flex; }
.wdr-sheet[hidden] { display: none; }
.wdr-sheet-card {
  flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 14px; overflow: auto; border-radius: 16px;
  background: linear-gradient(180deg, #1a2b5e, #101a3c); border: 1.5px solid var(--line-2); box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  animation: wdr-in .2s var(--ease);
}
@keyframes wdr-in { from { opacity: 0; transform: translateY(10px); } }
.wdr-sheet-head { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
.wdr-sheet-head b { font: 400 22px 'Lilita One', Nunito, sans-serif; color: var(--wd-gold); }
.wdr-sheet-head small { grid-column: 1; color: var(--muted); font-weight: 700; }
.wdr-sheet-head .modal-x { grid-column: 2; grid-row: 1 / span 2; }
.wdr-sheet-head .modal-x .ic { width: 20px; height: 20px; }
.wdr-rows { display: flex; flex-direction: column; gap: 8px; }
.wdr-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: var(--surface); }
.wdr-row > span { font-weight: 900; color: #dbe5ff; }
.wdr-row .wdr-swatches { justify-content: flex-start; }
.wdr-note { color: var(--muted); font-weight: 700; margin: 6px 0; }
.wdr-sheet-foot { display: flex; gap: 8px; margin: auto -14px -14px; padding: 10px 14px 14px; flex-wrap: wrap; position: sticky; bottom: -14px; background: linear-gradient(rgba(16, 26, 60, 0), #101a3c 35%); }
.wdr-sheet-foot .btn { min-height: 44px; }
.wdr-sheet-foot .btn.primary { margin-left: auto; min-width: 140px; }

/* ---------------------------------------------------------------- touch */
html.touch .wdr-sw { width: 44px; height: 44px; }
html.touch .wdr-zoom button { width: 44px; height: 44px; }
html.touch .wdr-tab, html.touch .wdr-seg button, html.touch .wdr-sort { min-height: 44px; }
html.touch .ap-world { min-height: 40px; }
html.touch .wdr-panel .modal-body { padding: 8px 10px calc(var(--sab) + 8px); }

/* ---------------------------------------------------------------- phones (portrait + short landscape): name over the stage */
@media (max-width: 640px), (max-height: 500px) {
  .wdr-show { gap: 0; }
  .wdr-stage { min-height: 0; }
  .wdr-info {
    position: absolute; left: 3px; right: 3px; bottom: 3px; z-index: 5; min-height: 0; padding: 18px 0 2px; pointer-events: none;
    border-radius: 0 0 15px 15px; background: linear-gradient(180deg, transparent, rgba(6, 10, 34, .82) 45%);
  }
  .wdr-info .wdr-swatches { pointer-events: auto; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; justify-content: safe center; }
  .wdr-info .wdr-swatches::-webkit-scrollbar { display: none; }
  .wdr-name { font-size: 20px; }
  .wdr-sub { font-size: 12px; }
  .wdr-hint { bottom: auto; top: 10px; }
  .wdr-zoom { top: 12px; transform: none; }
  .wdr-actions { flex-direction: row; align-items: stretch; gap: 6px; }
  .wdr-go { order: 2; flex: 1; width: auto; min-height: 50px; font-size: 16px; padding: 4px 10px; }
  .wdr-extra { order: 1; gap: 6px; }
  .wdr-extra [data-act="base"] { flex: none; width: 44px; padding: 0; }
  .wdr-extra [data-act="base"] span { display: none; }
  .wdr-extra .btn.icon-only:first-child { margin-left: 0; }
}

/* phone portrait: one column — stage, tabs, tools, grid, sticky action bar */
@media (max-width: 640px) and (orientation: portrait) {
  .wdr { display: flex; flex-direction: column; gap: 6px; }
  .wdr-left, .wdr-right { display: contents; }
  .wdr-show { order: 1; flex: none; height: clamp(200px, calc(31 * var(--udvh, 1dvh)), 320px); }
  .wdr-tabwrap { order: 2; gap: 6px; }
  .wdr-toolwrap { order: 3; }
  .wdr-grid { order: 4; flex: 1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 6px; padding: 2px 0 8px; }
  .wdr-actions { order: 5; flex: none; padding-top: 2px; }
  .wdr-tab { min-height: 48px; padding: 4px 2px; }
  .wdr-tab span { font-size: 11px; }
  .wdr[data-world="pokemon"] .wdr-tab span { font-size: 13px; }
  .wdr-count { display: none; }
  .wdr-tools { flex-wrap: nowrap; gap: 8px; }
  .wdr-seg { flex: 1; }
  .wdr-seg button { flex: 1; padding: 0 6px; }
  .wdr-sort { width: 44px; justify-content: center; padding: 0; }
  .wdr-sort select { position: absolute; inset: -1px; opacity: 0; width: calc(100% + 2px); height: calc(100% + 2px); }
  .wdr-card { padding: 5px 5px 6px; border-radius: 13px; }
  .wdr-card .ml-pic { margin-bottom: 3px; border-radius: 9px; aspect-ratio: 6 / 5; }
  .wdr-card .ml-nm { font-size: 12px; }
  .wdr-card .ml-ty { font-size: 10.5px; }
  .wdr-card .ml-foot { padding-top: 5px; }
  .wdr-card .ml-pr, .wdr-card .ml-st { min-height: 28px; font-size: 12px; gap: 3px; border-radius: 8px; }
  .wdr-card .ml-pr .dia { width: 13px; height: 13px; }
  .wdr-card .ml-pr s { display: none; }
  .wdr-card .ml-st .ic { width: 13px; height: 13px; }
  .wdr-card .ml-badge { top: 9px; left: 9px; font-size: 9px; padding: 1px 5px; }
  .wdr-sheet { top: auto; left: 0; width: auto; max-height: 72%; }
  .wdr-sheet-card { border-radius: 18px 18px 12px 12px; }
  .wdr-row { grid-template-columns: 1fr; gap: 0; padding: 6px; }
}

/* short landscape phones: two columns, compact chrome */
@media (max-height: 500px) and (orientation: landscape) {
  .wdr { grid-template-columns: minmax(230px, 40%) minmax(0, 1fr); gap: 10px; }
  .wdr-left, .wdr-right { gap: 6px; }
  .wdr-tabs { gap: 4px; }
  .wdr-tab { min-height: 42px; padding: 3px 2px; }
  .wdr-tab span { font-size: 11px; }
  .wdr-tools { flex-wrap: nowrap; gap: 8px; }
  .wdr-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px 6px; padding: 2px 0 6px; }
  .wdr-card .ml-pic { aspect-ratio: 4 / 3; margin-bottom: 2px; }
  .wdr-card { padding: 5px 5px 6px; }
  .wdr-card .ml-nm { font-size: 12px; }
  .wdr-card .ml-ty { font-size: 10.5px; }
  .wdr-card .ml-foot { padding-top: 4px; }
  .wdr-card .ml-pr, .wdr-card .ml-st { min-height: 26px; font-size: 12px; }
  .wdr-card .ml-pr s { display: none; }
  .wdr-card .ml-badge { top: 8px; left: 8px; font-size: 9px; padding: 1px 5px; }
  /* the switch shrinks to two icons beside the categories */
  .wdr-tabwrap { flex-direction: row; gap: 6px; }
  .ap-worlds { flex: none; padding: 3px; }
  .ap-world { min-height: 36px; width: 42px; }
  .ap-world span { display: none; }
  .wdr-tabs { flex: 1; min-width: 0; }
  .wdr-count { display: none; }
  .wdr-sort { margin-left: auto; }
  .wdr-panel .modal-head { padding-top: 2px; padding-bottom: 4px; }
  .wdr-panel .mh-icon .ic-tile { width: 28px; height: 28px; }
  .wdr-panel .mh-title { font-size: 17px; }
  .wdr-sheet { width: calc(60% - 6px); }
  .wdr-cone { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
  .wdr-cone, .wdr-go.confirm { animation: none; }
}
html.reduce-motion .wdr-cone, html.reduce-motion .wdr-go.confirm { animation: none; }

