/* DEEPMINE v11.4 — 任务 partner quests (public/tasks-panel.mjs; docs/v11-4-tasks-lottery-notify.md §4.1, §6.7).
   One card per task: logo (48 px rounded square on a light plate, monogram when there is none) | English title + reward
   chip; the action sits full width below under 400 px and in a fixed-width column from 400 px. States: todo (jade
   去完成), checking (spinner, no seconds), ready (gold 领取奖励, one pulse), claiming, done (muted 已完成 ✓), full /
   ended (muted). Fits 320 px with the 16 px gutter; long ru/de labels wrap, numbers never break. */
@layer pages {
  #sheet[data-mode="tasks"] { --sheet-art: url(/art/ui-v4/banners/tasks.webp); }

  .tasks-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
  .tasks-panel > * { min-width: 0; }
  .tasks-panel :is(p, strong, .btn > span, .task-status > span) { overflow-wrap: anywhere; }
  :root:not(:lang(zh)) .tasks-panel :is(p, strong, .btn > span, .task-status > span) { hyphens: auto; -webkit-hyphens: auto; }
  .tasks-note, .tasks-stale { margin: 0; }
  .tasks-note > span, .tasks-stale > span { flex: 1 1 auto; min-width: 0; }
  .tasks-stale { flex-wrap: wrap; align-items: center; }
  .tasks-stale .btn { flex: none; margin-left: auto; }
  .tasks-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }

  /* ───────── card ───────── */
  .task-card {
    --task-plate: #eef1ea;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-areas: "logo copy" "action action";
    align-items: center;
    gap: 10px 12px;
    min-width: 0;
    padding: 12px;
    border-radius: var(--r-md);
    transition: border-color var(--dur-3) var(--ease-out), background var(--dur-3) var(--ease-out);
  }
  .task-card.is-checking { border-color: rgb(80 200 140 / .3); }
  .task-card.is-ready {
    border-color: var(--line-gold);
    background: radial-gradient(120% 90% at 100% 0%, rgb(245 200 105 / .15), transparent 60%), var(--grad-panel), var(--surface-2);
  }
  .task-card:is(.is-done, .is-muted) { background: var(--grad-panel), rgb(18 51 38 / .55); box-shadow: none; }
  .task-card:is(.is-done, .is-muted) .task-title { color: var(--text-3); }
  .task-card:is(.is-done, .is-muted) :is(.task-logo, .task-reward) { filter: saturate(.45) brightness(.9); }

  /* logo plate: partner logos are square app icons — they fill the rounded plate edge to edge on a dark backing (no white rim) */
  .task-logo {
    grid-area: logo;
    position: relative;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--task-plate);
    border: 0;
    box-shadow: 0 0 0 1px rgb(0 0 0 / .45), 0 4px 10px -5px rgb(0 0 0 / .7);
    cursor: pointer;
  }
  .task-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
  .task-logo.has-logo { background: var(--surface-inset, #0f1d17); }   /* the light plate stays for the monogram only */
  .task-logo:active { transform: translateY(1px); }
  .task-mono { --mono: #1d6e4f; font: 800 24px/1 var(--font-display); color: var(--mono); padding-top: 2px; }
  .task-mono[data-tone="1"] { --mono: #7a4f17; }
  .task-mono[data-tone="2"] { --mono: #2c5f8f; }
  .task-mono[data-tone="3"] { --mono: #6f3d8c; }
  .task-mono[data-tone="4"] { --mono: #a3412a; }
  .task-mono[data-tone="5"] { --mono: #3f5f24; }
  .task-mono.is-glyph { padding: 0; line-height: 0; }

  /* title + reward */
  .task-copy { grid-area: copy; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 6px; min-width: 0; }
  .task-title {
    position: relative;
    display: block;
    max-width: 100%;
    padding: 0;
    text-align: start;
    color: var(--text-1);
    font-size: var(--fs-15);
    font-weight: 800;
    line-height: 1.3;
    background: none;
    border: 0;
    cursor: pointer;
  }
  /* the title is a re-open button: a 44 px hit area without growing the card */
  .task-title::before { content: ''; position: absolute; inset: -13px -6px; }
  .task-title > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
  /* a long item name drops under the art and count as a whole (a rounded rectangle, not a pill) instead of breaking mid-word */
  .task-reward { flex-wrap: wrap; min-height: 26px; max-width: 100%; padding: 2px 9px 2px 5px; gap: 0 5px; border-radius: 10px; font-size: var(--fs-12); white-space: normal; }
  .task-reward .currency-icon { flex: none; }
  .task-reward img { flex: none; width: 22px; height: 22px; margin: -4px 0; object-fit: contain; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .45)); }
  .task-reward .icon { flex: none; }
  .task-reward-num { flex: none; font: 800 var(--fs-14)/1 var(--font-display); white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 2px; }
  .task-reward-unit { flex: none; font-weight: 700; white-space: nowrap; }
  .task-reward-name { min-width: 0; font-weight: 700; line-height: 1.25; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }

  /* action */
  .task-action { grid-area: action; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .task-action > .btn { width: 100%; min-width: 0; gap: 5px; padding-inline: 8px; white-space: normal; line-height: 1.2; }
  .task-action > .btn > span { min-width: 0; }
  .task-go .icon { flex: none; width: 16px; height: 16px; }
  .task-action > .task-checking:disabled {
    color: var(--jade-200);
    background: var(--surface-inset);
    border-color: rgb(80 200 140 / .28);
    box-shadow: inset 0 2px 6px rgb(0 0 0 / .35);
    cursor: progress;
  }
  .task-action > .task-claim.is-busy:disabled { color: var(--text-on-gold); background: var(--grad-gold-pressed); border-color: #e7ad48; opacity: .85; cursor: progress; }
  .task-spinner {
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgb(255 255 255 / .2);
    border-top-color: currentColor;
    animation: dm-spin .9s linear infinite;
  }
  /* 领取奖励: one gold pulse when the card turns ready (not a loop) */
  .task-card.is-ready .task-claim:not(:disabled) { animation: task-pulse 1.2s var(--ease-out) 1; }
  @keyframes task-pulse {
    0% { box-shadow: var(--sh-plate-gold), 0 0 0 0 rgb(245 200 105 / .7); }
    70% { box-shadow: var(--sh-plate-gold), 0 0 0 10px rgb(245 200 105 / 0); }
    100% { box-shadow: var(--sh-plate-gold), 0 0 0 0 rgb(245 200 105 / 0); }
  }
  .task-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 12px;
    text-align: center;
    font-size: var(--fs-13);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-3);
    background: rgb(255 255 255 / .03);
    border: 1px dashed var(--line-2);
  }
  .task-status.is-done { color: var(--jade-300); background: rgb(80 200 140 / .07); border: 1px solid rgb(80 200 140 / .2); }
  .task-status .icon { flex: none; width: 16px; height: 16px; }
  /* a failed claim: the message spans the whole card under the row (its own grid row only when present) */
  .task-card.has-error { grid-template-areas: "logo copy" "action action" "error error"; }
  .task-error { grid-area: error; display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: var(--fs-12); line-height: 1.4; color: var(--danger); }
  .task-error .icon { flex: none; width: 14px; height: 14px; margin-top: 1px; }
  /* a claim that just landed: a short jade glow on the card */
  .task-card.is-just-done { animation: task-done 1s var(--ease-out) 1; }
  @keyframes task-done { 0% { border-color: rgb(120 230 170 / .7); box-shadow: 0 0 0 2px rgb(80 200 140 / .35), 0 0 22px rgb(80 200 140 / .35); } 100% { border-color: var(--line-1); box-shadow: none; } }

  /* ───────── from 400 px: logo | copy | fixed-width action ───────── */
  /* the longest single words (es "Recolectando…", de "geprüft…") plus the spinner fit 140 px; every zh label (≤ 5
     characters + icon) fits 108 px, which leaves the English title ~30 px more before the 2-line clamp */
  .task-card { --task-action-w: 140px; }
  :root:lang(zh) .task-card { --task-action-w: 108px; }
  @media (min-width: 400px) {
    .task-card { grid-template-columns: 48px minmax(0, 1fr) var(--task-action-w); grid-template-areas: "logo copy action"; }
    .task-action > .btn { gap: 4px; padding-inline: 6px; font-size: var(--fs-13); }
    .task-card.has-error { grid-template-areas: "logo copy action" "error error error"; }
    .task-status { min-height: 44px; padding-inline: 8px; }
  }

  /* ───────── loading, error, empty ───────── */
  .task-card.is-skeleton { pointer-events: none; }
  .task-sk { display: block; border-radius: 8px; background: rgb(206 228 196 / .08); animation: task-sk 1.4s ease-in-out infinite; }
  .task-sk-logo { grid-area: logo; width: 48px; height: 48px; border-radius: 12px; }
  .task-sk-copy { grid-area: copy; display: grid; gap: 8px; min-width: 0; }
  .task-sk-line { width: 78%; height: 14px; }
  .task-sk-chip { width: 88px; height: 22px; border-radius: 999px; }
  .task-sk-action { grid-area: action; height: 44px; border-radius: 12px; }
  @keyframes task-sk { 50% { opacity: .45; } }
  .tasks-error { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 8px; padding: 22px 16px; text-align: center; }
  .tasks-error > .icon { width: 24px; height: 24px; color: var(--warn); }
  .tasks-error strong { font-size: var(--fs-15); font-weight: 800; color: var(--text-1); }
  .tasks-error p { margin: 0; max-width: 32ch; font-size: var(--fs-13); line-height: 1.5; color: var(--text-2); }
  .tasks-error .btn { min-width: 128px; margin-top: 4px; }
  .tasks-empty .empty-icon .gi { width: 34px; height: 34px; }

  @media (max-width: 359px) {
    .task-card { gap: 10px; padding: 10px; }
    .task-title { font-size: var(--fs-14); }
  }

  /* motion: the pulse, the done glow and the skeleton stop. The spinner slows under .low-quality; under reduced motion
     base.css's 1 ms / 1-iteration rule wins and it stays a static ring (检查中… still says what is happening). */
  html:is(.reduce-motion, .low-quality) :is(.task-card.is-ready .task-claim, .task-card.is-just-done, .task-sk) { animation: none; }
  html.low-quality .task-spinner { animation-duration: 2.4s; }
  html:is(.reduce-motion, .low-quality) .task-card { transition: none; }
  @media (prefers-reduced-motion: reduce) {
    :is(.task-card.is-ready .task-claim, .task-card.is-just-done, .task-sk) { animation: none; }
    .task-spinner { animation-duration: 2.4s; }
    .task-card { transition: none; }
  }
}
