/* XEL achievements + treasures — documented incidents and the vault. */

/* ============================== shared panel bits ============================== */

.ach-panel-head,
.treasure-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.ach-panel-title,
.treasure-panel-title {
  font-size: 1.6rem;
  letter-spacing: 0.05em;
  background: linear-gradient(120deg, var(--seafoam), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ach-panel-count,
.treasure-panel-count {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.15rem;
}

.ach-close,
.treasure-close {
  /* 44x44 minimum hit area — thumbs have rights */
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.7rem;
  display: inline-grid;
  place-items: center;
  font-size: 0.95rem;
  line-height: 1;
  flex: none;
}

.ach-panel-sub,
.treasure-panel-sub {
  color: var(--ink-dim);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.ach-panel-foot {
  color: var(--ink-faint);
  font-size: 0.78rem;
  font-style: italic;
  margin: 1.1rem 0 0;
  text-align: center;
}

/* ============================== achievements grid ============================== */

.ach-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.ach-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.85rem 0.6rem 0.75rem;
  border-radius: var(--r-md);
  border: 1px solid var(--panel-border);
  background: rgba(157, 123, 255, 0.08);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.22s var(--ease-boing),
    box-shadow 0.22s,
    border-color 0.22s,
    background 0.22s;
}

.ach-cell.unlocked {
  border-color: rgba(125, 249, 224, 0.45);
  background:
    linear-gradient(160deg, rgba(125, 249, 224, 0.12), rgba(157, 123, 255, 0.10));
}

.ach-cell.unlocked:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: var(--glow-seafoam);
}

.ach-cell.unlocked:active { transform: scale(0.96); }

.ach-cell.locked {
  cursor: default;
  opacity: 0.5;
  filter: saturate(0.35);
}

.ach-cell-emoji {
  font-size: 1.9rem;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(125, 249, 224, 0.45));
}

.ach-cell-emoji.dim {
  filter: grayscale(1) brightness(0.55);
}

.ach-cell-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.2;
}

.ach-cell-desc {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-dim);
}

.ach-cell.locked .ach-cell-name { color: var(--ink-faint); }

/* unlocked cells get a slow ambient shine */
.ach-cell.unlocked::after {
  content: '';
  position: absolute;
  inset: -60% auto -60% -80%;
  width: 45%;
  background: linear-gradient(105deg, transparent, rgba(244, 241, 255, 0.16), transparent);
  transform: skewX(-18deg);
  animation: ach-shine 6s var(--ease-smooth) infinite;
  pointer-events: none;
}

@keyframes ach-shine {
  0%   { left: -80%; }
  22%  { left: 140%; }
  100% { left: 140%; }
}

/* ============================== achievement toast ============================== */

.ach-toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  overflow: hidden;
  cursor: pointer;
  border-color: rgba(255, 214, 107, 0.55);
  box-shadow: var(--glow-gold), var(--shadow-pop);
  animation: toast-in 0.5s var(--ease-boing);
}

.ach-toast::after {
  content: '';
  position: absolute;
  top: -60%;
  bottom: -60%;
  left: -70%;
  width: 40%;
  background: linear-gradient(105deg, transparent, rgba(255, 244, 214, 0.35), transparent);
  transform: skewX(-18deg);
  animation: ach-toast-sweep 1.4s var(--ease-smooth) 0.25s 2;
  pointer-events: none;
}

@keyframes ach-toast-sweep {
  from { left: -70%; }
  to   { left: 150%; }
}

.ach-toast-emoji {
  font-size: 1.7rem;
  line-height: 1;
  animation: ach-toast-pop 0.6s var(--ease-boing);
}

@keyframes ach-toast-pop {
  0%   { transform: scale(0) rotate(-30deg); }
  100% { transform: scale(1) rotate(0); }
}

.ach-toast-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ach-toast-kicker {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.ach-toast-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}

/* the share affordance is a real button now; visually it stays a quiet hint */
.ach-toast-share {
  flex: none;
  margin: -0.4rem -0.5rem -0.4rem auto; /* bigger hit area without growing the toast */
  padding: 0.45rem 0.55rem;
  font-family: var(--font-body, inherit);
  font-size: 0.75rem;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
}

.ach-toast:hover .ach-toast-share,
.ach-toast-share:hover { color: var(--seafoam); }

.ach-toast-share:focus-visible {
  color: var(--seafoam);
  outline: 2px solid var(--seafoam);
  outline-offset: 2px;
}

@keyframes toast-in {
  from { transform: translateY(24px) scale(0.85); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.toast.leaving {
  transition: opacity 0.4s, transform 0.4s var(--ease-smooth);
  opacity: 0;
  transform: translateY(14px) scale(0.94);
}

/* ============================== share modal ============================== */

.ach-share-overlay {
  position: fixed;
  inset: 0;
  z-index: 88; /* above toasts, below fx */
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(7, 3, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ach-share-overlay.open { opacity: 1; }

.ach-share-box {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: min(94vw, 620px);
  padding: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-violet), var(--shadow-pop);
  transform: translateY(16px) scale(0.94);
  transition: transform 0.35s var(--ease-boing);
}

.ach-share-overlay.open .ach-share-box { transform: none; }

.ach-share-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-md);
  border: 1px solid rgba(157, 123, 255, 0.3);
}

.ach-share-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.ach-share-close { margin-left: auto; }

/* ============================== treasures ============================== */

.treasure-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.treasure-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-faint);
  font-style: italic;
  padding: 2.4rem 1rem;
}

.treasure-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.85rem 0.6rem 0.7rem;
  border-radius: var(--r-md);
  border: 1px solid var(--ink-faint);
  background: rgba(244, 241, 255, 0.05);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.22s var(--ease-boing),
    box-shadow 0.22s,
    background 0.22s;
}

.treasure-cell:hover {
  transform: translateY(-3px) scale(1.03);
}

.treasure-cell:active { transform: scale(0.96); }

/* the cell is a wrapper now; this button carries the item + flavor toggle */
.treasure-cell-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.treasure-cell-main:focus-visible {
  outline: 2px solid var(--seafoam);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.treasure-cell-emoji { font-size: 1.9rem; line-height: 1; }

.treasure-cell-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.2;
}

.treasure-cell-rarity {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.treasure-cell-count {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--bg-deep);
  background: var(--seafoam);
  border-radius: var(--r-pill);
  padding: 0.05rem 0.4rem;
}

/* flavor text: hidden until hover / focus / tap */
.treasure-cell-flavor {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--ink-dim);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.35s var(--ease-smooth), opacity 0.3s, margin 0.3s;
}

.treasure-cell:hover .treasure-cell-flavor,
.treasure-cell:focus-within .treasure-cell-flavor,
.treasure-cell.show-flavor .treasure-cell-flavor {
  max-height: 6em;
  opacity: 1;
  margin-top: 0.25rem;
}

/* rarity borders + glows */
.treasure-cell.rarity-common { border-color: rgba(125, 116, 168, 0.55); }

.treasure-cell.rarity-uncommon {
  border-color: rgba(125, 249, 224, 0.55);
}
.treasure-cell.rarity-uncommon:hover { box-shadow: var(--glow-seafoam); }

.treasure-cell.rarity-rare {
  border-color: rgba(157, 123, 255, 0.7);
  background: rgba(157, 123, 255, 0.09);
}
.treasure-cell.rarity-rare:hover { box-shadow: var(--glow-violet); }

.treasure-cell.rarity-mythic {
  border-color: rgba(255, 214, 107, 0.8);
  background:
    linear-gradient(160deg, rgba(255, 214, 107, 0.12), rgba(157, 123, 255, 0.08));
  box-shadow: 0 0 14px rgba(255, 214, 107, 0.25);
}
.treasure-cell.rarity-mythic:hover { box-shadow: var(--glow-gold); }

.treasure-cell.rarity-mythic .treasure-cell-rarity { color: var(--gold); }

/* ============================== the wardrobe ============================== */

/* header summary: wearing N / 3 */
.treasure-wardrobe {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--seafoam);
  margin-top: 0.2rem;
}

.treasure-wardrobe.empty { color: var(--ink-faint); }

/* worn-state ring — the cell glows like something that is being worn */
.treasure-cell.worn {
  border-color: rgba(125, 249, 224, 0.9);
  box-shadow:
    0 0 0 2px rgba(125, 249, 224, 0.5),
    var(--glow-seafoam);
}

.treasure-worn-badge {
  position: absolute;
  top: 0.35rem;
  left: 0.45rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bg-deep);
  background: linear-gradient(120deg, var(--seafoam), var(--gold));
  border-radius: var(--r-pill);
  padding: 0.14rem 0.45rem;
  pointer-events: none;
  animation: worn-pop 0.45s var(--ease-boing);
}

@keyframes worn-pop {
  from { transform: scale(0) rotate(-14deg); }
  to   { transform: scale(1) rotate(0); }
}

/* wear-it / remove-it toggle */
.treasure-equip-btn {
  width: 100%;
  min-height: 44px; /* thumbs have rights here too */
  margin-top: 0.45rem;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--seafoam);
  background: rgba(125, 249, 224, 0.08);
  border: 1px dashed rgba(125, 249, 224, 0.45);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.2s var(--ease-boing);
}

.treasure-equip-btn:hover {
  background: rgba(125, 249, 224, 0.16);
  border-color: rgba(125, 249, 224, 0.8);
  transform: translateY(-1px);
}

.treasure-equip-btn:active { transform: scale(0.96); }

.treasure-equip-btn:focus-visible {
  outline: 2px solid var(--seafoam);
  outline-offset: 2px;
}

.treasure-equip-btn[aria-pressed="true"] {
  color: var(--bg-deep);
  background: var(--seafoam);
  border-style: solid;
  border-color: var(--seafoam);
}

.treasure-equip-btn[aria-pressed="true"]:hover {
  background: #a5fbec;
}

/* the attachment-point limit notice */
.wardrobe-toast {
  width: 100%;
  font-size: 0.9rem;
  border-color: rgba(125, 249, 224, 0.55);
  box-shadow: var(--glow-seafoam), var(--shadow-pop);
  animation: toast-in 0.5s var(--ease-boing);
}

/* ============================== treasure toast ============================== */

.treasure-toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  animation: toast-in 0.5s var(--ease-boing);
}

.treasure-toast-emoji {
  font-size: 1.7rem;
  line-height: 1;
  animation: ach-toast-pop 0.6s var(--ease-boing);
}

.treasure-toast-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.treasure-toast-kicker {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.treasure-toast-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}

.treasure-toast.rarity-common { border-color: rgba(125, 116, 168, 0.6); }

.treasure-toast.rarity-uncommon {
  border-color: rgba(125, 249, 224, 0.6);
  box-shadow: var(--glow-seafoam), var(--shadow-pop);
}
.treasure-toast.rarity-uncommon .treasure-toast-kicker { color: var(--seafoam); }

.treasure-toast.rarity-rare {
  border-color: rgba(157, 123, 255, 0.75);
  box-shadow: var(--glow-violet), var(--shadow-pop);
}
.treasure-toast.rarity-rare .treasure-toast-kicker { color: var(--violet); }

.treasure-toast.rarity-mythic {
  border-color: rgba(255, 214, 107, 0.9);
  box-shadow: var(--glow-gold), 0 0 48px rgba(255, 214, 107, 0.35), var(--shadow-pop);
  animation: toast-in 0.5s var(--ease-boing), mythic-throb 1.6s ease-in-out 0.5s 3;
}
.treasure-toast.rarity-mythic .treasure-toast-kicker { color: var(--gold); }

@keyframes mythic-throb {
  50% {
    box-shadow: var(--glow-gold), 0 0 72px rgba(255, 214, 107, 0.6), var(--shadow-pop);
    transform: scale(1.03);
  }
}

/* ============================== small screens ============================== */

@media (max-width: 380px) {
  .ach-grid,
  .treasure-grid { grid-template-columns: 1fr; }
}

/* ============================== reduced motion ============================== */

@media (prefers-reduced-motion: reduce) {
  .ach-cell.unlocked::after,
  .ach-toast::after { animation: none; }
  .ach-toast,
  .treasure-toast,
  .wardrobe-toast,
  .treasure-worn-badge,
  .ach-toast-emoji,
  .treasure-toast-emoji { animation: none; }
  .treasure-toast.rarity-mythic { animation: none; }
  .ach-cell,
  .treasure-cell,
  .treasure-equip-btn,
  .ach-share-box,
  .ach-share-overlay,
  .treasure-cell-flavor { transition-duration: 0.01s; }
}

/* ============================== trading cards (v3) ============================== */

/* view-card affordance on owned cells — the equip button's violet sibling */
.treasure-card-btn {
  width: 100%;
  min-height: 44px; /* thumbs retain their rights */
  margin-top: 0.45rem;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--violet);
  background: rgba(157, 123, 255, 0.08);
  border: 1px dashed rgba(157, 123, 255, 0.45);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.2s var(--ease-boing);
}

.treasure-card-btn:hover {
  background: rgba(157, 123, 255, 0.18);
  border-color: rgba(157, 123, 255, 0.85);
  transform: translateY(-1px);
}

.treasure-card-btn:active { transform: scale(0.96); }

.treasure-card-btn:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

/* unowned treasures: card backs, face down, politely withholding */
.treasure-cell.treasure-cell-unowned {
  cursor: default;
  opacity: 0.72;
  border-style: dashed;
  background: rgba(244, 241, 255, 0.03);
  box-shadow: none;
}

.treasure-cell.treasure-cell-unowned:hover {
  transform: none;
  box-shadow: none;
}

.treasure-back-img {
  width: 72%;
  max-width: 128px;
  height: auto;
  border-radius: var(--r-sm);
  filter: saturate(0.85);
}

.treasure-back-name { color: var(--ink-faint); }

/* mythic toast, upgraded: the whole thing is a door to the card */
.treasure-toast-cta { cursor: pointer; }

.treasure-toast-view {
  flex: none;
  margin: -0.4rem -0.5rem -0.4rem auto; /* bigger hit area without growing the toast */
  padding: 0.45rem 0.55rem;
  font-family: var(--font-body, inherit);
  font-size: 0.75rem;
  color: var(--gold);
  background: transparent;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
}

.treasure-toast-cta:hover .treasure-toast-view,
.treasure-toast-view:hover { color: #ffe9a8; }

.treasure-toast-view:focus-visible {
  color: #ffe9a8;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* the card modal — portrait sibling of the achievements share overlay */
.tcard-overlay {
  position: fixed;
  inset: 0;
  z-index: 88; /* above toasts' visual band, below fx — same layer as ach share */
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(7, 3, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.tcard-overlay.open { opacity: 1; }

.tcard-box {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: min(92vw, 430px);
  max-height: 96vh;
  padding: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-violet), var(--shadow-pop);
  transform: translateY(16px) scale(0.94);
  transition: transform 0.35s var(--ease-boing);
}

.tcard-overlay.open .tcard-box { transform: none; }

/* portrait 720x1000 — height auto keeps the intrinsic ratio; the width cap
   keeps the whole card (plus buttons) on screen on short viewports */
.tcard-canvas {
  display: block;
  width: min(100%, calc((96vh - 9.5rem) * 0.72));
  height: auto;
  margin: 0 auto;
  border-radius: var(--r-md);
}

.tcard-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.tcard-close { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  .tcard-overlay,
  .tcard-box,
  .treasure-card-btn { transition-duration: 0.01s; }
}
