/* ── Artifact cards ──────────────────────────────────────────────────────
   Replaces the old .file-bubble / .file-wrapper system.
   Structure: .artifact-wrapper > .artifact-card
   Card: hit-btn | sheet-icon | info-col | actions-col
   Status / progress live in .mw-status on the nearest .msg-wrapper (see save.css)
─────────────────────────────────────────────────────────────────────────── */

/* ── Outer wrapper ──────────────────────────────────────────── */
.artifact-wrapper {
  display: inline-flex;
  flex-direction: column;
  max-width: 340px;
  width: 100%;
  gap: 3px;
}

/* ── Card ───────────────────────────────────────────────────── */
.artifact-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 6px 14px 8px 20px;
  width: 100%;
  max-width: 340px;
  box-sizing: border-box;
  border-radius: var(--radius-lg);
  border: 1px solid color(srgb 1 1 1 / 0.14);
  background: linear-gradient(
    to bottom,
    var(--ak-bg, transparent),
    var(--ak-bg, transparent)
  ), var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition:
    border-color 0.18s ease,
    background   0.18s ease,
    box-shadow   0.18s ease;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  isolation: isolate;
  /* clip card background but sheet icon uses overflow:visible on its own container */
  overflow: hidden;
}
.artifact-card:hover {
  border-color: color(srgb 1 1 1 / 0.28);
  background: linear-gradient(
    to bottom,
    var(--ak-bg-hover, var(--ak-bg, transparent)),
    var(--ak-bg-hover, var(--ak-bg, transparent))
  ), var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.28);
}
@media (prefers-color-scheme: light) {
  .artifact-card { border-color: color(srgb 0 0 0 / 0.14); }
  .artifact-card:hover { border-color: color(srgb 0 0 0 / 0.28); }
}

/* Full-card invisible hit area */
.artifact-card-btn {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border-radius: inherit;
  background: transparent;
  border: none;
  outline: none;
}
.artifact-card-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ── Type palettes ──────────────────────────────────────────── */
.artifact-card[data-kind="text"],
.artifact-card[data-kind="markdown"] {
  --ak-bg:       color(srgb 1 1 1 / 0.00);
  --ak-bg-hover: color(srgb 1 1 1 / 0.04);
  --ak-page:     #1d1d1d;
  --ak-border2:  color(srgb 1 1 1 / 0.14);
  --ak-ink:      #888;
}
.artifact-card[data-kind="code"],
.artifact-card[data-kind="json"] {
  --ak-bg:       color(srgb 0.99 0.90 0.45 / 0.06);
  --ak-bg-hover: color(srgb 0.99 0.90 0.45 / 0.14);
  --ak-page:     #252009;
  --ak-border2:  #5a4e00;
  --ak-ink:      #c9a820;
}
.artifact-card[data-kind="csv"] {
  --ak-bg:       color(srgb 0.30 0.85 0.55 / 0.06);
  --ak-bg-hover: color(srgb 0.30 0.85 0.55 / 0.14);
  --ak-page:     #0e2018;
  --ak-border2:  #1a5232;
  --ak-ink:      #3aaa6a;
}
.artifact-card[data-kind="html"] {
  --ak-bg:       color(srgb 0.90 0.30 0.75 / 0.06);
  --ak-bg-hover: color(srgb 0.90 0.30 0.75 / 0.14);
  --ak-page:     #240d20;
  --ak-border2:  #6b1e5a;
  --ak-ink:      #d040a8;
}
.artifact-card[data-kind="image"] {
  --ak-bg:       color(srgb 0.60 0.45 0.98 / 0.06);
  --ak-bg-hover: color(srgb 0.60 0.45 0.98 / 0.14);
  --ak-page:     #16102a;
  --ak-border2:  #3d2878;
  --ak-ink:      #8866ee;
}
.artifact-card[data-kind="pdf"] {
  --ak-bg:       color(srgb 0.95 0.30 0.25 / 0.06);
  --ak-bg-hover: color(srgb 0.95 0.30 0.25 / 0.14);
  --ak-page:     #2a0d0d;
  --ak-border2:  #7a1a1a;
  --ak-ink:      #dd4444;
}
.artifact-card[data-kind="audio"],
.artifact-card[data-kind="video"] {
  --ak-bg:       color(srgb 0.25 0.85 0.80 / 0.06);
  --ak-bg-hover: color(srgb 0.25 0.85 0.80 / 0.14);
  --ak-page:     #0a2022;
  --ak-border2:  #115b5e;
  --ak-ink:      #2ac4bf;
}
.artifact-card[data-kind="font"],
.artifact-card[data-kind="binary"],
.artifact-card[data-kind="generic"] {
  --ak-bg:       color(srgb 0.30 0.60 0.98 / 0.06);
  --ak-bg-hover: color(srgb 0.30 0.60 0.98 / 0.14);
  --ak-page:     #0d1528;
  --ak-border2:  #1a3878;
  --ak-ink:      #4488ee;
}
@media (prefers-color-scheme: light) {
  .artifact-card[data-kind="text"],
  .artifact-card[data-kind="markdown"] { --ak-page: #f4f4f4; --ak-border2: #d0d0d0; --ak-ink: #999; }
  .artifact-card[data-kind="code"],
  .artifact-card[data-kind="json"]     { --ak-page: #fdf9e8; --ak-border2: #d4c060; --ak-ink: #a07818; }
  .artifact-card[data-kind="csv"]      { --ak-page: #edfaf3; --ak-border2: #80c8a0; --ak-ink: #228850; }
  .artifact-card[data-kind="html"]     { --ak-page: #fce8f8; --ak-border2: #d080c0; --ak-ink: #b02898; }
  .artifact-card[data-kind="image"]    { --ak-page: #f0ecff; --ak-border2: #a898e8; --ak-ink: #5540cc; }
  .artifact-card[data-kind="pdf"]      { --ak-page: #ffeaea; --ak-border2: #e09090; --ak-ink: #bb2222; }
  .artifact-card[data-kind="audio"],
  .artifact-card[data-kind="video"]    { --ak-page: #e6faf9; --ak-border2: #50b8b4; --ak-ink: #1899a0; }
  .artifact-card[data-kind="font"],
  .artifact-card[data-kind="binary"],
  .artifact-card[data-kind="generic"]  { --ak-page: #eaf0ff; --ak-border2: #80a8e8; --ak-ink: #2255cc; }
}

/* ── Sheet icon area ────────────────────────────────────────── */
/* The .artifact-sheet sits inside the card (overflow:hidden), so the
   sheet cards must stay within the card's visible area.
   We use overflow:visible on .artifact-sheet itself so the under card's
   rotation doesn't get clipped, but keep the parent card's clip for bg. */
.artifact-sheet {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
  overflow: visible;
}

.artifact-sheet-under,
.artifact-sheet-page {
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  height: 72px;
  border-radius: 5px;
  border: 0.5px solid var(--ak-border2, color(srgb 1 1 1 / 0.18));
  background: var(--ak-page, #1d1d1d);
  overflow: hidden;
}

/* Under card — hidden behind page at rest, peeks on hover */
.artifact-sheet-under {
  z-index: 0;
  filter: brightness(0.65);
  transform-origin: bottom center;
  transform: translateY(0px) rotate(0deg) translateX(0px);
  transition:
    transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity   0.2s ease;
  opacity: 0.85;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.25),
    inset 0.5px 1px 0 color(srgb 1 1 1 / 0.3);
}
.artifact-card:hover .artifact-sheet-under {
  transform: translateY(-3px) rotate(-2deg) translateX(-1px);
  opacity: 1;
}

/* Page card — static, lit top edge */
.artifact-sheet-page {
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 18px;
  color: var(--ak-ink, #888);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.35),
    inset 0.5px 1px 0 color(srgb 1 1 1 / 0.55),
    inset 0 0 0 0.5px color(srgb 1 1 1 / 0.15);
}

/* ── Marks container ────────────────────────────────────────── */
.artifact-marks {
  position: relative;
  width: 28px;
  height: 16px;
  flex-shrink: 0;
}

/* Base rule mark */
.artifact-mark {
  position: absolute;
  left: var(--mx, 3px);
  top:  var(--my, 3px);
  width:  var(--mw, 12px);
  height: var(--mh, 1.5px);
  border-radius: 2px;
  background: currentColor;
  opacity: var(--mo, 0.55);
  transform-origin: left center;
  transform: scaleX(0);
  transition: none;
}
.artifact-card:hover .artifact-mark {
  transform: scaleX(1);
  transition: transform var(--md, 240ms) var(--mdelay, 0ms) ease-out;
}

/* Dot */
.artifact-mark.is-dot {
  width:  var(--mw, 2.5px);
  height: var(--mw, 2.5px);
  border-radius: 50%;
  transform: scale(0);
}
.artifact-card:hover .artifact-mark.is-dot {
  transform: scale(1);
  transition: transform var(--md, 180ms) var(--mdelay, 0ms) ease-out;
}

/* Hash ticks */
.artifact-mark.is-hash {
  width: 1.5px;
  height: 1.5px;
  background: currentColor;
  box-shadow:
    0 3px 0 0 currentColor,
    0 6px 0 0 currentColor,
    0 9px 0 0 currentColor;
  opacity: 0.6;
  transform: scaleY(0);
  transform-origin: top center;
}
.artifact-card:hover .artifact-mark.is-hash {
  transform: scaleY(1);
  transition: transform 200ms var(--mdelay, 0ms) ease-out;
}

/* Blinking caret */
.artifact-mark.is-caret {
  width: 1.5px;
  height: var(--mh, 8px);
  opacity: var(--mo, 0.75);
  transform: scaleY(0);
  transform-origin: top center;
}
.artifact-card:hover .artifact-mark.is-caret {
  transform: scaleY(1);
  transition: transform 150ms var(--mdelay, 20ms) ease-out;
  animation: ac-blink 0.85s 0.35s step-end infinite;
}
@keyframes ac-blink {
  0%, 100% { opacity: var(--mo, 0.75); }
  50%       { opacity: 0; }
}

/* Corner brackets replaced by .artifact-mark-svg */

/* SVG corner marks (image kind) */
.artifact-mark-svg {
  position: absolute;
  overflow: visible;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.artifact-mark-svg path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: none;
}
.artifact-card:hover .artifact-mark-svg {
  opacity: 1;
}
.artifact-card:hover .artifact-mark-svg path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 180ms var(--sc-d, 0ms) ease-out;
}

/* ── Glyph ──────────────────────────────────────────────────── */
.artifact-glyph {
  line-height: 1;
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.18s ease;
  margin-top: 2px;
  color: currentColor;
}
.artifact-glyph svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* ── Text column ────────────────────────────────────────────── */
.artifact-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  padding-top: 4px;
  pointer-events: none;
}

.artifact-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.artifact-sub {
  font-size: var(--text-xs);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.15s;
}

/* ── Action buttons ─────────────────────────────────────────── */
.artifact-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  pointer-events: none;
}

/* Download — text button */
.artifact-dl-btn {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid color(srgb 1 1 1 / 0.12);
  background: color(srgb 1 1 1 / 0.07);
  color: var(--muted);
  font-size: var(--text-xs);
  font-family: var(--font);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background   0.15s ease,
    border-color 0.15s ease,
    color        0.15s ease,
    opacity      0.15s ease;
  flex-shrink: 0;
}
.artifact-dl-btn:hover {
  background:   color(srgb 1 1 1 / 0.14);
  border-color: color(srgb 1 1 1 / 0.22);
  color: var(--text);
}
/* Disabled state — grayed, non-interactive */
.artifact-dl-btn:disabled,
.artifact-dl-btn[data-disabled] {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
@media (prefers-color-scheme: light) {
  .artifact-dl-btn {
    border-color: color(srgb 0 0 0 / 0.12);
    background:   color(srgb 0 0 0 / 0.04);
  }
  .artifact-dl-btn:hover {
    background:   color(srgb 0 0 0 / 0.10);
    border-color: color(srgb 0 0 0 / 0.20);
    color: var(--text);
  }
}

/* Stream — small square icon button */
.artifact-stream-btn {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid color(srgb 1 1 1 / 0.12);
  background: color(srgb 1 1 1 / 0.05);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition:
    background   0.15s ease,
    border-color 0.15s ease,
    color        0.15s ease,
    opacity      0.15s ease;
  flex-shrink: 0;
}
.artifact-stream-btn:hover {
  background:   color(srgb 1 1 1 / 0.12);
  border-color: color(srgb 1 1 1 / 0.22);
  color: var(--text);
}
.artifact-stream-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  stroke: currentColor;
}

/* ── Audio player (legacy, still used for stream audio) ─────── */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border-md);
  padding: 0.55rem 0.75rem;
  max-width: 340px;
  border-radius: var(--radius-lg);
}
.audio-icon  { font-size: 1.2rem; flex-shrink: 0; line-height: 1; }
.audio-label { font-size: var(--text-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-col audio { width: 100%; height: 28px; accent-color: var(--accent); }
.audio-dl   { font-size: var(--text-md); color: var(--muted); text-decoration: none; flex-shrink: 0; padding: 0.15rem; transition: color 0.1s; }
.audio-dl:hover { color: var(--accent); }

/* ── PDF bubble (legacy) ────────────────────────────────────── */
.pdf-bubble {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border-md);
  padding: 0.65rem 0.85rem;
  max-width: 300px;
  cursor: pointer;
  transition: border-color 0.12s;
  border-radius: var(--radius-lg);
}
.pdf-bubble:hover { border-color: var(--accent); }
.pdf-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.pdf-info { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.pdf-name { font-size: var(--text-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.pdf-hint { font-size: var(--text-xs); color: var(--accent); }
