docs/.vitepress/theme/components/HomeFeatures.vue

dc37a0812a9971107e75ecfdb141c3d5bf0289fc
wotaku/docs/.vitepress/theme/components/HomeFeatures.vue history · blame · raw

1409 lines · 36219 bytes

   1<script setup lang="ts">
   2import { ArrowLeft } from 'lucide-vue-next'
   3import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
   4import type { HomeCard } from '../../configs/constants'
   5
   6const props = defineProps<{ cards: HomeCard[] }>()
   7
   8const STORAGE_KEY = 'wotaku-home-cards-v2'
   9const PREFS_KEY = 'wotaku-home-prefs-v1'
  10
  11interface CardState {
  12  homepage: string[]
  13}
  14
  15function defaultState(): CardState {
  16  return {
  17    homepage: props.cards.filter((c) => c.featured).map((c) => c.id)
  18  }
  19}
  20
  21function loadState(): CardState {
  22  if (typeof window === 'undefined') return defaultState()
  23  try {
  24    const raw = localStorage.getItem(STORAGE_KEY)
  25    if (!raw) return defaultState()
  26    const parsed: CardState = JSON.parse(raw)
  27    const allIds = new Set(props.cards.map((c) => c.id))
  28    return { homepage: (parsed.homepage ?? []).filter((id) => allIds.has(id)) }
  29  } catch { return defaultState() }
  30}
  31
  32const mounted = ref(false)
  33const state = ref<CardState>(defaultState())
  34
  35onMounted(() => {
  36  state.value = loadState()
  37  const prefs = loadPrefs()
  38  columnMode.value = prefs.columnMode
  39  viewMode.value = prefs.viewMode
  40  mounted.value = true
  41})
  42
  43function save() {
  44  localStorage.setItem(STORAGE_KEY, JSON.stringify(state.value))
  45}
  46
  47const cardMap = computed(() => new Map(props.cards.map((c) => [c.id, c])))
  48
  49const homepageSet = computed(() => new Set(state.value.homepage))
  50
  51const visibleCards = computed(() =>
  52  state.value.homepage.map((id) => cardMap.value.get(id)!).filter(Boolean)
  53)
  54
  55const grid = computed(() => {
  56  const n = visibleCards.value.length
  57  if (n === 0) return undefined
  58  if (columnMode.value === 'max') return 'grid-max'
  59  if (n === 2) return 'grid-2'
  60  if (n === 3) return 'grid-3'
  61  if (n % 3 === 0) return 'grid-6'
  62  if (n > 3) return 'grid-4'
  63  return undefined
  64})
  65
  66const panelGrid = computed(() => {
  67  if (columnMode.value === 'max') return 'grid-max'
  68  const n = props.cards.length
  69  if (n === 2) return 'grid-2'
  70  if (n === 3) return 'grid-3'
  71  if (n % 3 === 0) return 'grid-6'
  72  if (n > 3) return 'grid-4'
  73  return undefined
  74})
  75
  76const KNOWN_PREFIXES = /^(lucide|mdi|ic|mingcute|material-symbols|simple-icons|uil|octicon|logos|akar-icons|map|bi|streamline-logos|streamline-ultimate|streamline-sharp|iconoir)-/
  77
  78function cardIcon(card: HomeCard) {
  79  return card.icon.replace(/:([A-Za-z0-9_+-]+):/g, (_, markup) => {
  80    const cls = KNOWN_PREFIXES.test(markup) ? markup : `twemoji-${markup}`
  81    return `<span class="i-${cls}"></span>`
  82  })
  83}
  84
  85/* ── Manager panel ── */
  86const panelOpen = ref(false)
  87const dropdownOpen = ref(false)
  88
  89type HelpSection = 'view' | 'columns'
  90const activeHelpSection = ref<HelpSection | null>(null)
  91const helpPopupEl = ref<HTMLDivElement | null>(null)
  92const settingsDropdownEl = ref<HTMLDivElement | null>(null)
  93const helpPopupPos = ref({ top: -9999, left: -9999 })
  94
  95watch(dropdownOpen, (val) => {
  96  if (!val) {
  97    activeHelpSection.value = null
  98    helpPopupPos.value = { top: -9999, left: -9999 }
  99  }
 100})
 101
 102const canHoverHelp = () =>
 103  typeof window !== 'undefined' && window.matchMedia('(hover: hover)').matches
 104
 105function positionHelpPopup(btn: HTMLElement) {
 106  helpPopupPos.value = { top: -9999, left: -9999 }
 107  const rect = btn.getBoundingClientRect()
 108  // Anchor to the dropdown's left edge so the popup sits beside it, not over it.
 109  const menuRect = settingsDropdownEl.value?.getBoundingClientRect()
 110  nextTick(() => {
 111    const popupW = helpPopupEl.value?.offsetWidth || 260
 112    const popupH = helpPopupEl.value?.offsetHeight || 200
 113    const vw = window.innerWidth
 114    const margin = 8
 115    const isMobile = vw < 768
 116    if (isMobile) {
 117      const aboveTop = rect.top - popupH - margin
 118      const belowTop = rect.bottom + margin
 119      const top = aboveTop >= margin ? aboveTop : belowTop
 120      const left = Math.max(margin, Math.min((vw - popupW) / 2, vw - popupW - margin))
 121      helpPopupPos.value = { top, left }
 122    } else {
 123      const anchorLeft = menuRect ? menuRect.left : rect.left
 124      helpPopupPos.value = {
 125        left: Math.max(margin, anchorLeft - popupW - 16),
 126        top: Math.max(margin, Math.min(rect.top, window.innerHeight - popupH - margin)),
 127      }
 128    }
 129  })
 130}
 131
 132function closeHelpSection() {
 133  activeHelpSection.value = null
 134  helpPopupPos.value = { top: -9999, left: -9999 }
 135}
 136
 137function toggleHelpSection(section: HelpSection, e: MouseEvent) {
 138  // Hover devices open/close via mouseenter/leave; touch devices toggle on tap.
 139  if (canHoverHelp()) {
 140    activeHelpSection.value = section
 141    positionHelpPopup(e.currentTarget as HTMLElement)
 142    return
 143  }
 144  if (activeHelpSection.value === section) {
 145    closeHelpSection()
 146    return
 147  }
 148  activeHelpSection.value = section
 149  positionHelpPopup(e.currentTarget as HTMLElement)
 150}
 151
 152function onHelpEnter(section: HelpSection, e: MouseEvent) {
 153  if (!canHoverHelp()) return
 154  activeHelpSection.value = section
 155  positionHelpPopup(e.currentTarget as HTMLElement)
 156}
 157
 158function onHelpLeave() {
 159  if (!canHoverHelp()) return
 160  closeHelpSection()
 161}
 162
 163watch(panelOpen, (open) => {
 164  if (typeof document !== 'undefined')
 165    document.body.style.overflow = open ? 'hidden' : ''
 166})
 167
 168function onKeydown(e: KeyboardEvent) {
 169  if (e.key === 'Escape') {
 170    panelOpen.value = false
 171    cardTooltip.value = null
 172  }
 173}
 174
 175onMounted(() => document.addEventListener('keydown', onKeydown))
 176onUnmounted(() => document.removeEventListener('keydown', onKeydown))
 177
 178function loadPrefs() {
 179  if (typeof window === 'undefined') return { columnMode: 'default' as const, viewMode: 'default' as const }
 180  try {
 181    const p = JSON.parse(localStorage.getItem(PREFS_KEY) ?? '{}')
 182    return {
 183      columnMode: p.columnMode === 'max' ? 'max' as const : 'default' as const,
 184      viewMode: p.viewMode === 'mini' ? 'mini' as const : 'default' as const
 185    }
 186  } catch { return { columnMode: 'default' as const, viewMode: 'default' as const } }
 187}
 188
 189const columnMode = ref<'default' | 'max'>('default')
 190const viewMode = ref<'default' | 'mini'>('default')
 191
 192watch([columnMode, viewMode], () => {
 193  localStorage.setItem(PREFS_KEY, JSON.stringify({
 194    columnMode: columnMode.value,
 195    viewMode: viewMode.value
 196  }))
 197})
 198
 199const homepageSectionCards = computed(() =>
 200  state.value.homepage.map((id) => cardMap.value.get(id)!).filter(Boolean)
 201)
 202
 203const otherSections = computed(() => {
 204  const sectionMap = new Map<string, HomeCard[]>()
 205  for (const card of props.cards) {
 206    const s = card.section ?? 'Pages'
 207    if (!sectionMap.has(s)) sectionMap.set(s, [])
 208    if (!homepageSet.value.has(card.id)) sectionMap.get(s)!.push(card)
 209  }
 210  return Array.from(sectionMap.entries()).map(([label, cards]) => ({ label, cards }))
 211})
 212
 213function toggleCard(id: string) {
 214  if (homepageSet.value.has(id)) {
 215    state.value.homepage = state.value.homepage.filter((hid) => hid !== id)
 216  } else {
 217    state.value.homepage.push(id)
 218  }
 219  save()
 220}
 221
 222function showAll() {
 223  const current = new Set(state.value.homepage)
 224  const toAdd = props.cards.filter((c) => !current.has(c.id)).map((c) => c.id)
 225  state.value.homepage = [...state.value.homepage, ...toAdd]
 226  save()
 227}
 228
 229function hideAll() {
 230  state.value.homepage = []
 231  save()
 232}
 233
 234function resetDefaults() {
 235  state.value = defaultState()
 236  columnMode.value = 'default'
 237  viewMode.value = 'default'
 238  save()
 239}
 240
 241const cardTooltip = ref<{ text: string; x: number; y: number } | null>(null)
 242
 243function showCardTooltip(e: MouseEvent, title: string) {
 244  if (!window.matchMedia('(hover: hover)').matches) return
 245  const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
 246  cardTooltip.value = { text: title, x: rect.left + rect.width / 2, y: rect.top }
 247}
 248
 249function hideCardTooltip() {
 250  cardTooltip.value = null
 251}
 252
 253/* ── Drag-to-reorder (homepage only, pointer events) ── */
 254const dragging = ref<string | null>(null)
 255const dragTarget = ref<string | null>(null)
 256const cardListEl = ref<HTMLElement | null>(null)
 257const ghostPos = ref<{ x: number; y: number } | null>(null)
 258
 259function onHandlePointerDown(e: PointerEvent, id: string) {
 260  e.preventDefault()
 261  dragging.value = id
 262  dragTarget.value = null
 263  ghostPos.value = { x: e.clientX, y: e.clientY }
 264  ;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
 265}
 266
 267function onHandlePointerMove(e: PointerEvent) {
 268  if (!dragging.value) return
 269  ghostPos.value = { x: e.clientX, y: e.clientY }
 270  const items = cardListEl.value?.querySelectorAll<HTMLElement>('[data-card-id]')
 271  if (!items) return
 272  for (const item of items) {
 273    const rect = item.getBoundingClientRect()
 274    if (
 275      e.clientX >= rect.left && e.clientX <= rect.right &&
 276      e.clientY >= rect.top && e.clientY <= rect.bottom
 277    ) {
 278      const id = item.dataset.cardId!
 279      if (id !== dragging.value) dragTarget.value = id
 280      break
 281    }
 282  }
 283}
 284
 285function onHandlePointerUp() {
 286  if (dragging.value && dragTarget.value) {
 287    const order = [...state.value.homepage]
 288    const from = order.indexOf(dragging.value)
 289    const to = order.indexOf(dragTarget.value)
 290    if (from !== -1 && to !== -1) {
 291      order.splice(from, 1)
 292      order.splice(to, 0, dragging.value)
 293      state.value.homepage = order
 294      save()
 295    }
 296  }
 297  dragging.value = null
 298  dragTarget.value = null
 299  ghostPos.value = null
 300}
 301</script>
 302
 303<template>
 304  <!-- ── Feature Grid ── -->
 305  <div class="home-features" :class="{ 'is-mounted': mounted }">
 306    <div class="container">
 307      <div class="card-toolbar">
 308        <button class="gear-btn" aria-label="Customize cards" @click="panelOpen = true">
 309          <span class="i-lucide-ellipsis" />
 310        </button>
 311      </div>
 312      <div class="items" :class="{ 'view-mini': viewMode === 'mini' }">
 313        <div
 314          v-for="card in visibleCards"
 315          :key="card.id"
 316          class="item"
 317          :class="grid"
 318        >
 319          <a class="card" :href="card.link">
 320            <article class="box">
 321              <div class="icon" v-html="cardIcon(card)" />
 322              <h2 class="title">{{ card.title }}</h2>
 323              <p class="details">{{ card.details }}</p>
 324            </article>
 325          </a>
 326        </div>
 327      </div>
 328    </div>
 329  </div>
 330
 331  <!-- ── Manager Panel ── -->
 332  <Teleport to="body">
 333    <Transition name="fade">
 334      <div v-if="panelOpen" class="backdrop" @click.self="panelOpen = false">
 335        <Transition name="slide-up" appear>
 336          <div v-if="panelOpen" class="panel" role="dialog" aria-modal="true" aria-label="Customize cards">
 337            <div class="panel-head">
 338              <button class="panel-back" aria-label="Back" @click="panelOpen = false">
 339                <ArrowLeft :size="18" :stroke-width="2" />
 340              </button>
 341              <span class="panel-title">Customize Cards</span>
 342              <button class="close-btn" aria-label="Close" @click="panelOpen = false">
 343                <span class="i-lucide-x" />
 344              </button>
 345            </div>
 346
 347            <div class="card-sections">
 348              <!-- Homepage section (draggable) -->
 349              <div class="section-label">Homepage</div>
 350              <ul ref="cardListEl" class="card-list" :class="panelGrid">
 351                <li v-if="homepageSectionCards.length === 0" class="empty-box">
 352                  <span class="empty-hint">No cards have been selected</span>
 353                </li>
 354                <li
 355                  v-for="card in homepageSectionCards"
 356                  :key="card.id"
 357                  :data-card-id="card.id"
 358                  class="card-row"
 359                  @mouseenter="showCardTooltip($event, card.title)"
 360                  @mouseleave="hideCardTooltip"
 361                  :class="{
 362                    'is-dragging': dragging === card.id,
 363                    'is-over': dragTarget === card.id && dragging !== card.id
 364                  }"
 365                >
 366                  <span
 367                    class="row-handle"
 368                    aria-hidden="true"
 369                    @pointerdown="onHandlePointerDown($event, card.id)"
 370                    @pointermove="onHandlePointerMove"
 371                    @pointerup="onHandlePointerUp"
 372                  >
 373                    <span class="i-lucide-grip-vertical" />
 374                  </span>
 375                  <span class="row-icon" v-html="cardIcon(card)" />
 376                  <span class="row-name">{{ card.title }}</span>
 377                  <button
 378                    class="row-toggle active"
 379                    aria-label="Remove from homepage"
 380                    @click="toggleCard(card.id)"
 381                  >
 382                    <span class="i-lucide-eye" />
 383                  </button>
 384                </li>
 385              </ul>
 386
 387              <!-- Other sections (Pages, Extensions, Other…) -->
 388              <template v-for="section in otherSections" :key="section.label">
 389                <div class="section-label">{{ section.label }}</div>
 390                <ul class="card-list" :class="panelGrid">
 391                  <li v-if="section.cards.length === 0" class="empty-box">
 392                    <span class="empty-hint">All cards from this section have been selected</span>
 393                  </li>
 394                  <li
 395                    v-for="card in section.cards"
 396                    :key="card.id"
 397                    class="card-row card-row-unselected"
 398                    @mouseenter="showCardTooltip($event, card.title)"
 399                    @mouseleave="hideCardTooltip"
 400                  >
 401                    <span class="row-handle-spacer" aria-hidden="true" />
 402                    <span class="row-icon" v-html="cardIcon(card)" />
 403                    <span class="row-name">{{ card.title }}</span>
 404                    <button
 405                      class="row-toggle"
 406                      aria-label="Add to homepage"
 407                      @click="toggleCard(card.id)"
 408                    >
 409                      <span class="i-lucide-eye-off" />
 410                    </button>
 411                  </li>
 412                </ul>
 413              </template>
 414            </div>
 415
 416            <div class="panel-foot">
 417              <div class="foot-group">
 418                <button class="tool-btn" aria-label="Show all" @click="showAll">
 419                  <span class="i-lucide-eye" />
 420                </button>
 421                <button class="tool-btn" aria-label="Hide all" @click="hideAll">
 422                  <span class="i-lucide-eye-off" />
 423                </button>
 424                <button class="tool-btn" aria-label="Reset to default" @click="resetDefaults">
 425                  <span class="i-lucide-refresh-ccw" />
 426                </button>
 427              </div>
 428              <div class="foot-group">
 429                <div class="settings-wrap">
 430                  <div v-if="dropdownOpen" class="dropdown-overlay" @click="dropdownOpen = false" />
 431                  <div v-if="dropdownOpen" ref="settingsDropdownEl" class="settings-dropdown">
 432                    <div class="dropdown-section">
 433                      <div class="dropdown-section-header">
 434                        <span class="dropdown-label">
 435                          <span class="i-lucide-layout-list dropdown-label-icon" />
 436                          View
 437                        </span>
 438                        <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'view' }" aria-label="View help" @click.stop="toggleHelpSection('view', $event)" @mouseenter="onHelpEnter('view', $event)" @mouseleave="onHelpLeave">
 439                          <span class="i-carbon:help-filled settings-help-icon" />
 440                        </button>
 441                      </div>
 442                      <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'view' }">
 443                        <button class="tool-btn" :class="{ 'is-active': viewMode === 'default' }" @click="viewMode = 'default'">Default</button>
 444                        <button class="tool-btn" :class="{ 'is-active': viewMode === 'mini' }" @click="viewMode = 'mini'">Mini</button>
 445                      </div>
 446                    </div>
 447                    <div class="dropdown-section">
 448                      <div class="dropdown-section-header">
 449                        <span class="dropdown-label">
 450                          <span class="i-lucide-columns-3-cog dropdown-label-icon" />
 451                          Columns
 452                        </span>
 453                        <button type="button" class="settings-help-btn" :class="{ active: activeHelpSection === 'columns' }" aria-label="Columns help" @click.stop="toggleHelpSection('columns', $event)" @mouseenter="onHelpEnter('columns', $event)" @mouseleave="onHelpLeave">
 454                          <span class="i-carbon:help-filled settings-help-icon" />
 455                        </button>
 456                      </div>
 457                      <div class="dropdown-group" :class="{ 'is-highlighted': activeHelpSection === 'columns' }">
 458                        <button class="tool-btn" :class="{ 'is-active': columnMode === 'default' }" @click="columnMode = 'default'">Default</button>
 459                        <button class="tool-btn" :class="{ 'is-active': columnMode === 'max' }" @click="columnMode = 'max'">Max</button>
 460                      </div>
 461                    </div>
 462                  </div>
 463                  <button
 464                    class="tool-btn"
 465                    :class="{ 'is-active': dropdownOpen }"
 466                    aria-label="Display settings"
 467                    @click.stop="dropdownOpen = !dropdownOpen"
 468                  >
 469                    <span class="i-lucide-settings" />
 470                  </button>
 471                </div>
 472              </div>
 473            </div>
 474          </div>
 475        </Transition>
 476      </div>
 477    </Transition>
 478
 479    <div
 480      v-if="cardTooltip"
 481      class="card-tooltip"
 482      :style="{ left: cardTooltip.x + 'px', top: cardTooltip.y + 'px' }"
 483    >{{ cardTooltip.text }}</div>
 484
 485    <Transition name="help-popup-fade">
 486      <div
 487        v-if="activeHelpSection && dropdownOpen"
 488        ref="helpPopupEl"
 489        class="home-help-popup"
 490        :style="{ top: helpPopupPos.top + 'px', left: helpPopupPos.left + 'px' }"
 491      >
 492        <template v-if="activeHelpSection === 'view'">
 493          <h4 class="sh-title">
 494            <span class="i-lucide-layout-list sh-title-icon" />
 495            View
 496          </h4>
 497          <p class="sh-desc">Controls how cards are displayed on the homepage.</p>
 498          <div class="sh-options">
 499            <div class="sh-option">
 500              <strong>
 501                <span class="i-lucide-layout-grid sh-option-icon" />
 502                Default
 503              </strong>
 504              <span>Full card with icon, title, and description.</span>
 505            </div>
 506            <div class="sh-option">
 507              <strong>
 508                <span class="i-lucide-rows-3 sh-option-icon" />
 509                Mini
 510              </strong>
 511              <span>Compact row with icon and title only.</span>
 512            </div>
 513          </div>
 514        </template>
 515        <template v-else-if="activeHelpSection === 'columns'">
 516          <h4 class="sh-title">
 517            <span class="i-lucide-columns-3-cog sh-title-icon" />
 518            Columns
 519          </h4>
 520          <p class="sh-desc">Controls how many columns the card grid uses.</p>
 521          <div class="sh-options">
 522            <div class="sh-option">
 523              <strong>
 524                <span class="i-lucide-columns-2 sh-option-icon" />
 525                Default
 526              </strong>
 527              <span>Adapts automatically based on the number of cards.</span>
 528            </div>
 529            <div class="sh-option">
 530              <strong>
 531                <span class="i-lucide-columns-3 sh-option-icon" />
 532                Max
 533              </strong>
 534              <span>Always uses the maximum number of columns based on screen resolution.</span>
 535            </div>
 536          </div>
 537        </template>
 538      </div>
 539    </Transition>
 540
 541    <Transition name="ghost-fade">
 542      <div
 543        v-if="dragging && ghostPos"
 544        class="drag-ghost"
 545        :style="{ left: ghostPos.x + 'px', top: ghostPos.y + 'px' }"
 546      >
 547        <span class="row-icon" v-html="cardIcon(cardMap.get(dragging)!)" />
 548        <span class="drag-ghost-name">{{ cardMap.get(dragging)?.title }}</span>
 549      </div>
 550    </Transition>
 551  </Teleport>
 552</template>
 553
 554<style scoped>
 555/* ── Grid ── */
 556.home-features {
 557  position: relative;
 558  padding: 0 24px;
 559}
 560
 561.home-features .container {
 562  opacity: 0;
 563  transition: opacity 0.15s ease;
 564}
 565
 566.home-features.is-mounted .container {
 567  opacity: 1;
 568}
 569
 570@media (min-width: 640px) {
 571  .home-features { padding: 0 48px; }
 572}
 573
 574@media (min-width: 960px) {
 575  .home-features { padding: 0 64px; }
 576}
 577
 578.container {
 579  position: relative;
 580  margin: 0 auto;
 581  max-width: 1152px;
 582}
 583
 584.items {
 585  display: flex;
 586  flex-wrap: wrap;
 587  margin: -8px;
 588}
 589
 590.item {
 591  padding: 8px;
 592  width: 100%;
 593}
 594
 595@media (min-width: 640px) {
 596  .item.grid-2,
 597  .item.grid-4,
 598  .item.grid-6 { width: calc(100% / 2); }
 599}
 600
 601@media (min-width: 768px) {
 602  .item.grid-2,
 603  .item.grid-4 { width: calc(100% / 2); }
 604  .item.grid-3,
 605  .item.grid-6 { width: calc(100% / 3); }
 606}
 607
 608@media (min-width: 960px) {
 609  .item.grid-4 { width: calc(100% / 4); }
 610}
 611
 612@media (min-width: 640px) {
 613  .item.grid-max { width: calc(100% / 2); }
 614}
 615
 616@media (min-width: 768px) {
 617  .item.grid-max { width: calc(100% / 3); }
 618}
 619
 620@media (min-width: 960px) {
 621  .item.grid-max { width: calc(100% / 4); }
 622}
 623
 624/* ── Card ── */
 625.card {
 626  display: block;
 627  border: 2px solid #3d3d3d;
 628  border-radius: 12px;
 629  height: 100%;
 630  background-color: var(--vp-c-bg-soft);
 631  transition: border-color 0.25s, background-color 0.25s;
 632  text-decoration: none;
 633  color: inherit;
 634}
 635
 636.card:hover {
 637  border-color: var(--vp-c-brand-1);
 638}
 639
 640.card:active {
 641  transform: none;
 642}
 643
 644.box {
 645  display: flex;
 646  flex-direction: column;
 647  padding: 24px;
 648  height: 100%;
 649}
 650
 651.icon {
 652  display: flex;
 653  justify-content: center;
 654  align-items: center;
 655  margin-bottom: 20px;
 656  border-radius: 6px;
 657  background-color: var(--vp-c-default-soft);
 658  width: 48px;
 659  height: 48px;
 660  font-size: 27px;
 661  transition: background-color 0.25s;
 662}
 663
 664.title {
 665  line-height: 24px;
 666  font-size: 16px;
 667  font-weight: 600;
 668}
 669
 670.details {
 671  flex-grow: 1;
 672  padding-top: 8px;
 673  line-height: 24px;
 674  font-size: 14px;
 675  font-weight: 500;
 676  color: var(--vp-c-text-2);
 677}
 678
 679/* ── Mini View ── */
 680.view-mini .box {
 681  flex-direction: row;
 682  align-items: center;
 683  padding: 12px 16px;
 684  gap: 12px;
 685}
 686
 687.view-mini .icon {
 688  width: 32px;
 689  height: 32px;
 690  font-size: 18px;
 691  margin-bottom: 0;
 692  flex-shrink: 0;
 693}
 694
 695.view-mini .title {
 696  font-size: 14px;
 697  line-height: 1.3;
 698}
 699
 700.view-mini .details {
 701  display: none;
 702}
 703
 704/* ── Gear Button ── */
 705.card-toolbar {
 706  display: flex;
 707  justify-content: flex-end;
 708  margin-bottom: 4px;
 709}
 710
 711.gear-btn {
 712  background: none;
 713  border: none;
 714  padding: 4px;
 715  color: var(--vp-c-text-2);
 716  font-size: 18px;
 717  cursor: pointer;
 718  transition: color 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
 719  display: flex;
 720  align-items: center;
 721}
 722
 723.gear-btn:hover {
 724  color: var(--vp-c-text-1);
 725}
 726
 727.gear-btn:active {
 728  transform: scale(0.94);
 729}
 730
 731/* ── Backdrop ── */
 732.backdrop {
 733  position: fixed;
 734  inset: 0;
 735  z-index: 100;
 736  display: flex;
 737  align-items: center;
 738  justify-content: center;
 739  background: rgba(0, 0, 0, 0.5);
 740  backdrop-filter: blur(4px);
 741  overscroll-behavior: none;
 742  touch-action: none;
 743}
 744
 745@media (max-width: 767px) {
 746  .backdrop {
 747    align-items: stretch;
 748  }
 749}
 750
 751/* ── Panel ── */
 752.panel {
 753  width: min(520px, calc(100vw - 32px));
 754  max-height: 85vh;
 755  display: flex;
 756  flex-direction: column;
 757  border-radius: 16px;
 758  border: 2px solid #3d3d3d;
 759  background: var(--vp-c-bg);
 760}
 761
 762@media (max-width: 767px) {
 763  .panel {
 764    width: 100vw;
 765    height: 100vh;
 766    height: 100dvh;
 767    max-height: none;
 768    border-radius: 0;
 769    border: none;
 770  }
 771}
 772
 773@media (min-width: 768px) {
 774  .panel { width: min(720px, calc(100vw - 32px)); }
 775}
 776
 777@media (min-width: 960px) {
 778  .panel { width: min(940px, calc(100vw - 32px)); }
 779}
 780
 781.panel-head {
 782  display: flex;
 783  align-items: center;
 784  justify-content: space-between;
 785  padding: 10px 16px;
 786  border-bottom: 1px solid var(--vp-c-divider);
 787  flex-shrink: 0;
 788}
 789
 790.panel-title {
 791  font-size: 15px;
 792  font-weight: 600;
 793  color: var(--vp-c-text-1);
 794}
 795
 796/* Phone-only back button. */
 797.panel-back {
 798  display: none;
 799  align-items: center;
 800  justify-content: center;
 801  padding: 8px;
 802  border: none;
 803  background: transparent;
 804  color: var(--vp-c-text-1);
 805  font-size: 18px;
 806  cursor: pointer;
 807  transition: color 0.15s;
 808}
 809
 810.panel-back:hover {
 811  color: var(--vp-c-brand-1);
 812}
 813
 814.close-btn {
 815  position: relative;
 816  display: flex;
 817  align-items: center;
 818  justify-content: center;
 819  width: 28px;
 820  height: 28px;
 821  border-radius: 6px;
 822  border: none;
 823  background: transparent;
 824  color: var(--vp-c-text-2);
 825  font-size: 16px;
 826  cursor: pointer;
 827  transition: color 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
 828}
 829
 830.close-btn:hover {
 831  color: var(--vp-c-text-1);
 832}
 833
 834.close-btn:active {
 835  transform: scale(0.94);
 836}
 837
 838.close-btn::after {
 839  content: attr(aria-label);
 840  position: absolute;
 841  top: calc(100% + 6px);
 842  right: 0;
 843  background: var(--vp-c-bg-soft);
 844  color: var(--vp-c-text-1);
 845  border: 1px solid var(--vp-c-divider);
 846  border-radius: 5px;
 847  padding: 3px 8px;
 848  font-size: 11px;
 849  white-space: nowrap;
 850  pointer-events: none;
 851  opacity: 0;
 852  transition: opacity 0.15s;
 853  z-index: 10;
 854}
 855
 856@media (hover: hover) {
 857  .close-btn:hover::after {
 858    opacity: 1;
 859  }
 860}
 861
 862/* Phone: full-screen header (back arrow, no X). */
 863@media (max-width: 767px) {
 864  .panel-head {
 865    height: 49px;
 866    padding: 6px 8px;
 867    justify-content: flex-start;
 868    border-bottom-color: var(--wk-fs-header-divider);
 869  }
 870
 871  .panel-back {
 872    display: flex;
 873  }
 874
 875  .close-btn {
 876    display: none;
 877  }
 878}
 879
 880/* ── Card List ── */
 881.card-sections {
 882  overflow-y: auto;
 883  min-height: 0;
 884  padding: 8px;
 885  display: flex;
 886  flex-direction: column;
 887  gap: 2px;
 888  touch-action: pan-y;
 889  overscroll-behavior: contain;
 890}
 891
 892.section-label {
 893  font-size: 11px;
 894  font-weight: 600;
 895  text-transform: uppercase;
 896  letter-spacing: 0.06em;
 897  color: var(--vp-c-text-3, var(--vp-c-text-2));
 898  padding: 8px 10px 2px;
 899}
 900
 901.section-label:first-child {
 902  padding-top: 2px;
 903}
 904
 905.card-list {
 906  list-style: none;
 907  margin: 0;
 908  padding: 0;
 909  display: grid;
 910  grid-template-columns: 1fr;
 911  gap: 2px;
 912}
 913
 914@media (min-width: 640px) {
 915  .card-list.grid-2,
 916  .card-list.grid-4,
 917  .card-list.grid-6,
 918  .card-list.grid-max { grid-template-columns: 1fr 1fr; }
 919}
 920
 921@media (min-width: 768px) {
 922  .card-list.grid-3,
 923  .card-list.grid-6,
 924  .card-list.grid-max { grid-template-columns: 1fr 1fr 1fr; }
 925}
 926
 927@media (min-width: 960px) {
 928  .card-list.grid-4,
 929  .card-list.grid-max { grid-template-columns: 1fr 1fr 1fr 1fr; }
 930}
 931
 932.card-row {
 933  display: flex;
 934  align-items: center;
 935  gap: 8px;
 936  padding: 7px 10px;
 937  border-radius: 8px;
 938  transition: background 0.15s, opacity 0.15s;
 939  user-select: none;
 940  min-width: 0;
 941}
 942
 943.card-row:hover {
 944  background: var(--vp-c-bg-soft);
 945}
 946
 947.card-row-unselected {
 948  opacity: 0.45;
 949}
 950
 951.card-row-unselected:hover {
 952  opacity: 1;
 953}
 954
 955.empty-box {
 956  grid-column: 1 / -1;
 957  list-style: none;
 958  border-radius: 8px;
 959  padding: 14px 16px;
 960  display: flex;
 961  align-items: center;
 962  justify-content: center;
 963  background-image:
 964    linear-gradient(90deg, var(--vp-c-divider) 6px, transparent 6px),
 965    linear-gradient(90deg, var(--vp-c-divider) 6px, transparent 6px),
 966    linear-gradient(0deg,  var(--vp-c-divider) 6px, transparent 6px),
 967    linear-gradient(0deg,  var(--vp-c-divider) 6px, transparent 6px);
 968  background-size: 10px 1px, 10px 1px, 1px 10px, 1px 10px;
 969  background-position: top left, bottom left, top left, top right;
 970  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
 971}
 972
 973.empty-hint {
 974  font-size: 13px;
 975  color: var(--vp-c-text-3, var(--vp-c-text-2));
 976  font-style: italic;
 977}
 978
 979.card-tooltip {
 980  position: fixed;
 981  z-index: 9999;
 982  transform: translate(-50%, calc(-100% - 6px));
 983  background: var(--vp-c-bg-soft);
 984  color: var(--vp-c-text-1);
 985  border: 1px solid var(--vp-c-divider);
 986  border-radius: 5px;
 987  padding: 3px 8px;
 988  font-size: 11px;
 989  white-space: nowrap;
 990  pointer-events: none;
 991}
 992
 993.card-row.is-dragging {
 994  opacity: 0.25;
 995  cursor: grabbing;
 996}
 997
 998.card-row.is-over {
 999  background: var(--vp-c-brand-soft);
1000  outline: 2px solid var(--vp-c-brand-1);
1001  outline-offset: -2px;
1002}
1003
1004.row-handle {
1005  color: var(--vp-c-text-3, var(--vp-c-text-2));
1006  font-size: 16px;
1007  flex-shrink: 0;
1008  display: flex;
1009  align-items: center;
1010  cursor: grab;
1011  touch-action: none;
1012}
1013
1014.row-handle:active {
1015  cursor: grabbing;
1016}
1017
1018.row-handle-spacer {
1019  width: 16px;
1020  flex-shrink: 0;
1021}
1022
1023.row-icon {
1024  font-size: 18px;
1025  flex-shrink: 0;
1026  display: flex;
1027  align-items: center;
1028  width: 20px;
1029}
1030
1031.row-name {
1032  flex: 1;
1033  font-size: 14px;
1034  font-weight: 500;
1035  color: var(--vp-c-text-1);
1036  overflow: hidden;
1037  white-space: nowrap;
1038  text-overflow: ellipsis;
1039  min-width: 0;
1040}
1041
1042.row-toggle {
1043  display: flex;
1044  align-items: center;
1045  justify-content: center;
1046  width: 30px;
1047  height: 30px;
1048  border-radius: 6px;
1049  border: none;
1050  background: transparent;
1051  color: var(--vp-c-text-2);
1052  font-size: 16px;
1053  cursor: pointer;
1054  flex-shrink: 0;
1055  transition: color 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
1056}
1057
1058.row-toggle:hover,
1059.row-toggle.active {
1060  color: var(--vp-c-text-1);
1061}
1062
1063.row-toggle:active {
1064  transform: scale(0.94);
1065}
1066
1067/* ── Panel Footer ── */
1068.panel-foot {
1069  display: flex;
1070  align-items: center;
1071  justify-content: space-between;
1072  padding: 5px 8px;
1073  border-top: 1px solid var(--vp-c-divider);
1074  flex-shrink: 0;
1075  gap: 8px;
1076}
1077
1078.foot-group {
1079  display: flex;
1080  align-items: center;
1081  gap: 4px;
1082}
1083
1084.tool-btn {
1085  position: relative;
1086  display: flex;
1087  align-items: center;
1088  gap: 5px;
1089  font-size: 14px;
1090  font-weight: 500;
1091  color: var(--vp-c-text-2);
1092  background: transparent;
1093  border: none;
1094  border-radius: 5px;
1095  padding: 5px 6px;
1096  cursor: pointer;
1097  transition: color 0.15s, background 0.15s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
1098}
1099
1100.tool-btn[aria-label]::after {
1101  content: attr(aria-label);
1102  position: absolute;
1103  bottom: calc(100% + 6px);
1104  left: 50%;
1105  transform: translateX(-50%);
1106  background: var(--vp-c-bg-soft);
1107  color: var(--vp-c-text-1);
1108  border: 1px solid var(--vp-c-divider);
1109  border-radius: 5px;
1110  padding: 3px 8px;
1111  font-size: 11px;
1112  white-space: nowrap;
1113  pointer-events: none;
1114  opacity: 0;
1115  transition: opacity 0.15s;
1116  z-index: 10;
1117}
1118
1119@media (hover: hover) {
1120  .tool-btn[aria-label]:hover::after {
1121    opacity: 1;
1122  }
1123}
1124
1125.tool-btn:hover,
1126.tool-btn.is-active {
1127  color: var(--vp-c-text-1);
1128  background: transparent;
1129}
1130
1131.tool-btn:active {
1132  transform: scale(0.94);
1133}
1134
1135/* Respect the "effects off" preference */
1136html.effects-disabled .gear-btn,
1137html.effects-disabled .close-btn,
1138html.effects-disabled .tool-btn,
1139html.effects-disabled .row-toggle {
1140  transition: none;
1141}
1142
1143html.effects-disabled .gear-btn:active,
1144html.effects-disabled .close-btn:active,
1145html.effects-disabled .tool-btn:active,
1146html.effects-disabled .row-toggle:active {
1147  transform: none;
1148}
1149
1150/* ── Settings Help ── */
1151.dropdown-section-header {
1152  display: flex;
1153  align-items: center;
1154  justify-content: space-between;
1155  margin-bottom: 6px;
1156}
1157
1158.dropdown-section-header .dropdown-label {
1159  margin-bottom: 0;
1160}
1161
1162.settings-help-btn {
1163  display: flex;
1164  align-items: center;
1165  justify-content: center;
1166  padding: 3px;
1167  background: transparent;
1168  border: none;
1169  cursor: pointer;
1170  color: var(--vp-c-text-3);
1171  opacity: 0.5;
1172  transition: opacity 0.15s, color 0.15s;
1173  border-radius: 3px;
1174  line-height: 1;
1175}
1176
1177.settings-help-btn:hover,
1178.settings-help-btn.active {
1179  opacity: 1;
1180  color: var(--vp-c-text-1);
1181}
1182
1183.settings-help-icon {
1184  display: block;
1185  width: 16px;
1186  height: 16px;
1187}
1188
1189.home-help-popup {
1190  position: fixed;
1191  z-index: 9999;
1192  width: 280px;
1193  background: var(--vp-c-bg-elv);
1194  border: 1px solid var(--vp-c-divider);
1195  border-radius: 12px;
1196  padding: 16px;
1197  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
1198  pointer-events: none;
1199}
1200
1201.help-popup-fade-enter-active,
1202.help-popup-fade-leave-active {
1203  transition: opacity 0.15s ease;
1204}
1205
1206.help-popup-fade-enter-from,
1207.help-popup-fade-leave-to {
1208  opacity: 0;
1209}
1210
1211.sh-title {
1212  display: flex;
1213  align-items: center;
1214  gap: 6px;
1215  font-size: 1rem;
1216  font-weight: 600;
1217  color: var(--vp-c-text-1);
1218  margin: 0 0 4px;
1219}
1220
1221.sh-title-icon {
1222  flex-shrink: 0;
1223  width: 16px;
1224  height: 16px;
1225  display: block;
1226}
1227
1228.sh-desc {
1229  font-size: 0.875rem;
1230  color: var(--vp-c-text-2);
1231  margin: 0 0 6px;
1232  line-height: 1.5;
1233}
1234
1235.sh-options {
1236  display: flex;
1237  flex-direction: column;
1238  gap: 5px;
1239}
1240
1241.sh-option {
1242  display: flex;
1243  flex-direction: column;
1244  gap: 4px;
1245  background: var(--wk-c-menu-bg);
1246  border-radius: 12px;
1247  padding: 10px 12px;
1248}
1249
1250.dark .sh-option {
1251  background: var(--wk-c-menu-bg);
1252}
1253
1254.sh-option strong {
1255  display: flex;
1256  align-items: center;
1257  gap: 4px;
1258  font-size: 0.875rem;
1259  font-weight: 600;
1260  color: var(--vp-c-text-1);
1261}
1262
1263.sh-option-icon {
1264  width: 14px;
1265  height: 14px;
1266  flex-shrink: 0;
1267}
1268
1269.sh-option span {
1270  font-size: 0.875rem;
1271  color: var(--vp-c-text-2);
1272  line-height: 1.4;
1273}
1274
1275/* ── Settings Dropdown ── */
1276.settings-wrap {
1277  position: relative;
1278}
1279
1280.dropdown-overlay {
1281  position: fixed;
1282  inset: 0;
1283  z-index: 1;
1284}
1285
1286.settings-dropdown {
1287  --seg-track: var(--wk-c-menu-bg);
1288  --seg-pill-bg: var(--vp-c-bg);
1289  --seg-pill-text: var(--vp-c-text-1);
1290  --seg-pill-shadow: 0 2px 4px 0 #bababa8c;
1291  position: absolute;
1292  bottom: calc(100% + 8px);
1293  right: 0;
1294  z-index: 2;
1295  min-width: 196px;
1296  background: var(--vp-c-bg-elv);
1297  border: 1px solid var(--vp-c-divider);
1298  border-radius: 12px;
1299  padding: 12px;
1300  box-shadow: var(--vp-shadow-3);
1301}
1302
1303.dark .settings-dropdown {
1304  --seg-track: var(--wk-c-menu-bg);
1305  --seg-pill-bg: var(--vp-c-text-1);
1306  --seg-pill-text: var(--vp-c-bg-elv);
1307  --seg-pill-shadow: 0 2px 4px 0 #535353db;
1308}
1309
1310.dropdown-section + .dropdown-section {
1311  border-top: 1px solid var(--vp-c-divider);
1312  margin-top: 8px;
1313  padding-top: 8px;
1314}
1315
1316.dropdown-label {
1317  display: flex;
1318  align-items: center;
1319  gap: 6px;
1320  font-size: 14px;
1321  font-weight: 500;
1322  color: var(--vp-c-text-1);
1323  margin-bottom: 0;
1324}
1325
1326.dropdown-label-icon {
1327  width: 14px;
1328  height: 14px;
1329  flex-shrink: 0;
1330}
1331
1332.dropdown-group {
1333  display: flex;
1334  gap: 4px;
1335  background: var(--seg-track);
1336  border-radius: 8px;
1337  padding: 4px;
1338  outline: 2px dashed transparent;
1339  outline-offset: 4px;
1340  transition: outline-color 0.2s ease;
1341}
1342
1343.dropdown-group.is-highlighted {
1344  outline-color: var(--vp-c-brand-1);
1345}
1346
1347.dropdown-group .tool-btn {
1348  flex: 1;
1349  justify-content: center;
1350  border-radius: 6px;
1351  color: var(--vp-c-text-1);
1352  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
1353}
1354
1355.dropdown-group .tool-btn:hover,
1356.dropdown-group .tool-btn.is-active {
1357  color: var(--seg-pill-text);
1358  background: var(--seg-pill-bg);
1359  box-shadow: var(--seg-pill-shadow);
1360}
1361
1362.dropdown-group .tool-btn.is-active {
1363  font-weight: 700;
1364}
1365
1366/* ── Drag Ghost ── */
1367.drag-ghost {
1368  position: fixed;
1369  pointer-events: none;
1370  z-index: 9999;
1371  display: flex;
1372  align-items: center;
1373  gap: 8px;
1374  padding: 6px 12px 6px 10px;
1375  background: var(--vp-c-bg);
1376  border: 1px solid var(--vp-c-brand-1);
1377  border-radius: 8px;
1378  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
1379  opacity: 0.88;
1380  font-size: 14px;
1381  font-weight: 500;
1382  color: var(--vp-c-text-1);
1383  white-space: nowrap;
1384  user-select: none;
1385  transform: translate(12px, -50%);
1386}
1387
1388.drag-ghost-name {
1389  font-size: 14px;
1390  font-weight: 500;
1391  color: var(--vp-c-text-1);
1392}
1393
1394.ghost-fade-enter-active,
1395.ghost-fade-leave-active { transition: opacity 0.1s ease; }
1396.ghost-fade-enter-from,
1397.ghost-fade-leave-to { opacity: 0; }
1398
1399/* ── Transitions ── */
1400.fade-enter-active,
1401.fade-leave-active { transition: opacity 0.2s ease; }
1402.fade-enter-from,
1403.fade-leave-to { opacity: 0; }
1404
1405.slide-up-enter-active { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease; }
1406.slide-up-leave-active { transition: transform 0.2s ease, opacity 0.15s ease; }
1407.slide-up-enter-from { transform: translateY(20px); opacity: 0; }
1408.slide-up-leave-to { transform: translateY(10px); opacity: 0; }
1409</style>