/* ══════════════════════════════════════════════════════════════
   Achievements — Cloudlog
   ══════════════════════════════════════════════════════════════ */

/* ── Nav Button ── */

.achievement-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  transition:
    color 0.3s,
    border-color 0.3s,
    background 0.3s;
  position: relative;
}
.achievement-btn:hover,
.achievement-btn.active {
  color: #fff;
  border-color: rgba(var(--theme-glow), 0.4);
  background: rgba(var(--theme-glow), 0.08);
}
.achievement-btn svg {
  width: 14px;
  height: 14px;
}

/* Nav-light variant */
nav.nav-light .achievement-btn {
  color: rgba(var(--ink-rgb), 0.5);
  border-color: rgba(0, 0, 0, 0.1);
}
nav.nav-light .achievement-btn:hover,
nav.nav-light .achievement-btn.active {
  color: var(--ink);
  border-color: rgba(26, 95, 168, 0.4);
  background: rgba(var(--theme-glow), 0.08);
}

/* Tooltip — matches appearance-toggle pattern */
.achievement-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-family: "DM Mono", monospace;
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(var(--ink-rgb), 0.92);
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.achievement-btn:hover::after {
  opacity: 1;
}
nav.nav-light .achievement-btn::after {
  color: rgba(var(--ink-rgb), 0.7);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ── Badge ── */

.achievement-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--sky-4, #378add);
  color: #fff;
  font-family: "DM Mono", monospace;
  font-size: 0.5rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}
.achievement-badge.visible {
  display: flex;
}
.achievement-badge.pulse {
  animation: achievement-badge-pulse 0.6s ease-out;
}
@keyframes achievement-badge-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.4);
  }
  100% {
    transform: scale(1);
  }
}

/* ── Panel ── */

.achievement-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(var(--ink-rgb), 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  overflow: hidden;
}
.achievement-panel.open {
  transform: translateX(0);
}

/* ── Panel Header ── */

.achievement-header {
  padding: 1.2rem 1.2rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.achievement-title-row {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.achievement-title {
  font-family: "Syne", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.achievement-points-total {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  color: var(--sky-3, #7dbfe8);
  letter-spacing: 0.05em;
}
/* "+N new" since last visit — a small theme-tinted pill; hidden when nothing's
   new so it never nags on a repeat open. */
.achievement-new-since {
  font-family: "DM Mono", monospace;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgb(var(--theme-glow));
  background: rgba(var(--theme-glow), 0.14);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.achievement-new-since:empty {
  display: none;
}
/* Overall completion strip — full-width under the title row. */
.achievement-progress-strip {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.achievement-progress-strip-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--sky-4, #378add),
    var(--sky-3, #7dbfe8)
  );
  transition: width 0.4s ease-out;
}

/* Session-context caption under the header. */
.achievement-last-unlocked {
  width: 100%;
  font-family: "DM Mono", monospace;
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.achievement-last-unlocked:empty {
  display: none;
}

.achievement-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  padding: 4px;
  transition: color 0.2s;
}
.achievement-close:hover {
  color: #fff;
}
.achievement-close svg {
  width: 14px;
  height: 14px;
}

/* Hint toggle */
.achievement-header-controls {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.3rem;
}
.achievement-hint-toggle {
  font-family: "DM Mono", monospace;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.achievement-help-level {
  font-family: "DM Mono", monospace;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 0.08rem 0.25rem;
  cursor: pointer;
}
.achievement-help-level:focus-visible {
  outline: 1px solid var(--sky-4);
}
.achievement-mark-read {
  font-family: "DM Mono", monospace;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.3);
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s;
}
.achievement-mark-read:hover {
  color: rgba(255, 255, 255, 0.6);
}
.achievement-density-btn {
  font-family: "DM Mono", monospace;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.3);
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s;
}
.achievement-density-btn:hover {
  color: rgba(255, 255, 255, 0.6);
}

/* Compact density — collapse card descriptions and tighten padding so
   more cards fit per screen.  The progress bar + title + points stay. */
.achievement-panel.compact .achievement-card-desc {
  display: none;
}
.achievement-panel.compact .achievement-card {
  padding: 0.3rem 0.5rem;
  gap: 0.45rem;
}

/* ── Tabs ── */
/* Horizontal tab row between the Cloudlog header and the scrollable body.
   Switches between the Achievements view (grouped sets) and Activity
   view (reverse-chron log of unlocks). */

.achievement-tabs {
  display: flex;
  gap: 0.2rem;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.achievement-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.4);
  font-family: "Syne", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: -1px;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}
.achievement-tab:hover {
  color: rgba(255, 255, 255, 0.7);
}
.achievement-tab.active {
  color: #fff;
  border-bottom-color: var(--sky-3);
}
.achievement-tab-badge {
  display: none;
  padding: 1px 6px;
  background: var(--sky-3);
  color: #0a1628;
  font-family: "DM Mono", monospace;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 100px;
  min-width: 16px;
  text-align: center;
}
.achievement-tab-badge.visible {
  display: inline-block;
}
.achievement-tab-badge.pulse {
  animation: achievement-badge-pulse 0.6s ease-out;
}
.achievement-tab-trash-count {
  display: none;
  font-family: "DM Mono", monospace;
  font-size: 0.48rem;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.03em;
}
.achievement-tab-trash-count.visible {
  display: inline;
}

/* Tab views — only the active one is rendered.  The default (Achievements)
   is marked .active at build time in buildPanel. */
/* Each tab view owns its own scroll position so switching tabs returns
   the user to where they were, not to a shared scrollTop carried over
   from the other tab.  Padding lives on the view, not the body, so the
   hover-halo and click-pop pseudo-elements have horizontal breathing
   room before hitting the scroll-container clip box (overflow-y: auto
   clips on both axes per spec — there is no scroll-vertical-only mode). */
.achievement-view {
  display: none;
  flex-direction: column;
  gap: 0.8rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 0.8rem;
}
.achievement-view.active {
  display: flex;
}
/* Direct children of the scroll container must not flex-shrink, or
   the column layout will compress them below their natural height
   when the content fits — collapsing the intro card and any sections
   shorter than they should be. */
.achievement-view > * {
  flex-shrink: 0;
}
.achievement-view::-webkit-scrollbar {
  width: 4px;
}
.achievement-view::-webkit-scrollbar-track {
  background: transparent;
}
.achievement-view::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}
