/*
 * Blobfisch Fancy Theme Additive Overlay
 *
 * This stylesheet is layered ON TOP of static/style.css.
 * In accordance with AGENTS.md Rule 9, base components and typography
 * are strictly maintained in style.css. This file only contains
 * custom property overrides, translucency, canvas styling, and telemetry HUD.
 */

:root {
  --panel: rgba(17, 18, 21, 0.58);
  --panel-bg: linear-gradient(135deg, rgba(30, 32, 35, 0.64) 0%, rgba(15, 17, 20, 0.52) 100%);
  --accent-bright: #aeff26;
  --glass-border: rgba(255, 255, 255, 0.12);
}

body {
  position: relative;
}

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100lvh;
  pointer-events: auto;
  z-index: 0;
  transform: translateZ(0);
  will-change: transform;
}

.topbar {
  background: rgba(12, 16, 22, 0.80);
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 10;
}

/* On mobile, cards span the full viewport so the only way to see the ambient
   background cubes is through the panel itself — lower opacity slightly more here. */
@media (max-width: 600px) {
  :root {
    --panel: rgba(17, 18, 21, 0.50);
    --panel-bg: linear-gradient(135deg, rgba(30, 32, 35, 0.50) 0%, rgba(15, 17, 20, 0.38) 100%);
  }
  .topbar {
    background: rgba(11, 15, 20, 0.72);
  }
}

main {
  position: relative;
  z-index: 10;
}

a.brand-version:hover,
a.brand-version:focus-visible {
  color: #e8edf1;
  text-shadow: 0 0 6px rgba(232, 237, 241, 0.25);
}

.intro h1 {
  text-shadow: 0 0 32px rgba(143, 229, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.7);
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 0 24px 0 rgba(255, 255, 255, 0.02),
    0 12px 36px rgba(0, 0, 0, 0.40);
  contain: layout style;
}

.panel h1,
.panel h2,
.panel h3,
.panel strong,
.panel .file-name {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.dropzone {
  border-color: rgba(255, 255, 255, 0.14);
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragging {
  border-color: var(--accent);
  background: rgba(143, 229, 0, 0.08);
  box-shadow: 0 0 16px rgba(143, 229, 0, 0.25);
}

.dropzone.auth-required {
  border-color: rgba(240, 180, 41, 0.4);
}

.dropzone.auth-required:hover,
.dropzone.auth-required:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(143, 229, 0, 0.25);
}

.dropzone.disabled {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.dropzone.disabled:hover,
.dropzone.disabled:focus-visible {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.cli-snippet-wrap {
  background: rgba(8, 11, 15, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.transfer-card {
  transition: border-color .2s, box-shadow .2s;
  contain: layout style;
}

.transfer-card .file-name {
  background-image: linear-gradient(to right, var(--muted), var(--muted));
  background-repeat: no-repeat;
  background-position: left 52%;
  background-size: 0% 1.5px;
  transition:
    background-size 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.8s cubic-bezier(0.2, 0, 0, 1);
}

.transfer-card .share-link::after {
  content: '';
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: 50%;
  height: 1.5px;
  background: var(--muted);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}

.transfer-card.transfer-card-deleting {
  z-index: 0 !important;
  pointer-events: none !important;
  opacity: 0 !important;
  transform: scale(0.96) translateZ(0) !important;
  will-change: transform, opacity;
  border-color: rgba(255, 68, 68, 0.7) !important;
  box-shadow:
    inset 0 0 24px rgba(255, 68, 68, 0.12),
    0 0 28px rgba(255, 68, 68, 0.35) !important;
  transition:
    opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.25s ease,
    box-shadow 0.25s ease !important;
}

@media (hover: hover) {
  .transfer-card:hover {
    border-color: var(--accent);
    box-shadow:
      inset 0 0 24px 0 rgba(143, 229, 0, 0.06),
      0 0 28px rgba(143, 229, 0, 0.28);
  }

  .transfer-card.interrupted:hover {
    border-color: var(--warning);
    box-shadow:
      inset 0 0 24px 0 rgba(240, 180, 41, 0.06),
      0 0 28px rgba(240, 180, 41, 0.28);
  }

  .transfer-card.failed:hover {
    border-color: var(--danger);
    box-shadow:
      inset 0 0 24px 0 rgba(255, 100, 114, 0.06),
      0 0 28px rgba(255, 100, 114, 0.28);
  }

  .transfer-card.expired:hover {
    border-color: #8c98a3;
    box-shadow: 0 0 20px rgba(100, 113, 125, 0.25);
    transition: border-color .2s, box-shadow .2s;
  }
}

/* Deletion confirmation: danger tint scoped to the card under the dialog */
.transfer-card:has(.delete-confirm:open),
.transfer-card:has(.delete-confirm:open):hover {
  border-color: rgba(255, 100, 114, 0.6);
  box-shadow:
    inset 0 0 24px rgba(255, 100, 114, 0.10),
    0 0 28px rgba(255, 100, 114, 0.30);
}

.delete-confirm:open {
  background: linear-gradient(135deg, rgba(30, 32, 35, 0.92) 0%, rgba(15, 17, 20, 0.88) 100%);
  backdrop-filter: blur(12px) saturate(110%);
  -webkit-backdrop-filter: blur(12px) saturate(110%);
}

.transfer-card.focused-3d {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 24px 0 rgba(143, 229, 0, 0.06),
    0 0 28px rgba(143, 229, 0, 0.28);
}

.transfer-card.interrupted.focused-3d {
  border-color: var(--warning);
  box-shadow:
    inset 0 0 24px 0 rgba(240, 180, 41, 0.06),
    0 0 28px rgba(240, 180, 41, 0.28);
}

.transfer-card.failed.focused-3d {
  border-color: var(--danger);
  box-shadow:
    inset 0 0 24px 0 rgba(255, 100, 114, 0.06),
    0 0 28px rgba(255, 100, 114, 0.28);
}

.transfer-card.expired {
  transition:
    border-color 0.8s cubic-bezier(0.2, 0, 0, 1),
    box-shadow 0.8s cubic-bezier(0.2, 0, 0, 1);
}

.transfer-card.expired.focused-3d {
  border-color: #8c98a3;
  box-shadow: 0 0 20px rgba(100, 113, 125, 0.25);
  transition: border-color .2s, box-shadow .2s;
}

.transfer-card.expired .label,
.transfer-card.expired .badge,
.transfer-card.expired .link-kind-button.active,
.transfer-card.expired .copy-link,
.transfer-card.expired .qr-button,
.transfer-card.expired .share-link,
.transfer-card.expired .share-link .link-base,
.transfer-card.expired .share-link .link-filename {
  transition:
    color 0.8s cubic-bezier(0.2, 0, 0, 1),
    border-color 0.8s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.8s cubic-bezier(0.2, 0, 0, 1),
    opacity 0.8s cubic-bezier(0.2, 0, 0, 1);
}

.transfer-card.expired .file-name {
  text-decoration: none;
  background-size: 100% 1.5px;
  color: var(--muted);
  transition:
    background-size 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.8s cubic-bezier(0.2, 0, 0, 1);
}

.transfer-card.expired .share-link {
  text-decoration: none;
  color: var(--muted);
}

.transfer-card.expired .share-link .link-base,
.transfer-card.expired .share-link .link-filename {
  text-decoration: none;
  color: var(--muted);
}

.transfer-card.expired .share-link::after {
  transform: scaleX(1);
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}

.transfer-card.expired .progress > div {
  box-shadow: none;
  transition:
    background-color 0.8s cubic-bezier(0.2, 0, 0, 1),
    box-shadow 0.8s cubic-bezier(0.2, 0, 0, 1);
}

.transfer-card.preliminary {
  box-shadow: 0 0 14px rgba(91, 104, 115, 0.2);
}

.transfer-card.preliminary:hover {
  border-color: #8c98a3;
  box-shadow: 0 0 20px rgba(140, 152, 163, 0.3);
}

.transfer-card.preliminary .progress > div {
  opacity: .35;
  background: var(--muted);
  box-shadow: 0 0 8px rgba(140, 152, 163, 0.4);
  animation: preliminary-scan 1.8s ease-in-out infinite alternate;
}

@keyframes preliminary-scan {
  0% { opacity: .15; }
  100% { opacity: .55; }
}

.progress > div {
  box-shadow: 0 0 10px rgba(143, 229, 0, 0.4);
}

/* Active Upload Telemetry Tooltip / HUD Panel */
#active-upload-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  z-index: 1000;
  cursor: default;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--accent);
  background: rgba(12, 17, 23, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--text);
  width: 330px;
  max-width: calc(100vw - 24px);
  max-height: min(540px, calc(100vh - 40px));
  transform: translate3d(0, 0, 0);
  will-change: transform;
  transition: border-color 0.2s, box-shadow 0.2s, width 0.22s cubic-bezier(0.2, 0, 0, 1);
}

#active-upload-tooltip.matrix-expanded {
  width: 410px;
}

#active-upload-tooltip:hover,
#active-upload-tooltip.focused {
  border-color: var(--accent-bright);
  box-shadow: 0 0 28px rgba(174, 255, 38, 0.4);
}

#active-upload-tooltip.expired {
  border-color: #64717d;
  box-shadow: 0 0 16px rgba(100, 113, 125, 0.25);
}

#active-upload-tooltip.expired:hover,
#active-upload-tooltip.expired.focused {
  border-color: #8c98a3;
  box-shadow: 0 0 24px rgba(140, 152, 163, 0.35);
}

#active-upload-tooltip .tt-title {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

#active-upload-tooltip.expired .tt-title {
  color: #8c98a3;
}

#active-upload-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

#active-upload-tooltip .tt-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

#active-upload-tooltip .tt-val {
  color: var(--text);
  font-weight: 700;
  font-size: 0.68rem;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Active Transfer Telemetry Section (Speed & ETA) */
.tt-transfer-section {
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
  display: none;
}

/* Exploded Multipart Chunk Matrix */
.tt-matrix-container {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  display: none;
}

.tt-matrix-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.tt-matrix-streams {
  font-size: 0.56rem;
  font-weight: 700;
  color: var(--accent);
}

.tt-chunk-matrix {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  max-height: min(290px, 45vh);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 6px 2px 2px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 229, 0, 0.45) transparent;
}

.tt-chunk-matrix::-webkit-scrollbar {
  width: 4px;
}

.tt-chunk-matrix::-webkit-scrollbar-track {
  background: transparent;
}

.tt-chunk-matrix::-webkit-scrollbar-thumb {
  background: rgba(143, 229, 0, 0.45);
  border-radius: 2px;
}

.tt-chunk-node {
  border: 1px solid var(--line);
  background: rgba(17, 21, 26, 0.88);
  padding: 0.25rem 0.2rem;
  text-align: center;
  border-radius: 0;
  transition: border-color 0.15s, background-color 0.15s;
}

.tt-cn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1px;
}

.tt-cn-num {
  font-size: 0.58rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.tt-cn-state {
  font-size: 0.52rem;
  font-weight: 700;
  color: var(--muted);
}

.tt-cn-track {
  height: 4px;
  background: rgba(10, 14, 18, 0.95);
  border: 1px solid rgba(48, 56, 65, 0.9);
  margin-top: 3px;
  overflow: hidden;
  position: relative;
}

.tt-cn-fill {
  height: 100%;
  width: 0%;
  background: var(--muted);
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Done Chunk */
.tt-chunk-node.done {
  border-color: rgba(143, 229, 0, 0.55);
  background: rgba(143, 229, 0, 0.08);
}
.tt-chunk-node.done .tt-cn-num,
.tt-chunk-node.done .tt-cn-state {
  color: var(--accent);
}
.tt-chunk-node.done .tt-cn-fill {
  background: linear-gradient(90deg, #6bb800, #8fe500);
  box-shadow: 0 0 6px rgba(143, 229, 0, 0.6);
}

/* Uploading Chunk */
.tt-chunk-node.uploading {
  border-color: #00f0ff;
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
}
.tt-chunk-node.uploading .tt-cn-num,
.tt-chunk-node.uploading .tt-cn-state {
  color: #00f0ff;
  text-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
}
.tt-chunk-node.uploading .tt-cn-fill {
  background: linear-gradient(90deg, #0099cc, #00f0ff);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.85);
}

/* Pending Chunk */
.tt-chunk-node.pending {
  border-color: var(--line);
  opacity: 0.65;
}

/* Expired Chunk */
.tt-chunk-node.expired {
  border-color: #64717d;
  background: rgba(100, 113, 125, 0.08);
}
.tt-chunk-node.expired .tt-cn-num,
.tt-chunk-node.expired .tt-cn-state {
  color: #8c98a3;
}
.tt-chunk-node.expired .tt-cn-fill {
  background: #64717d;
}

/* High-Density Piece Grid for uploads with > 16 parts */
.tt-chunk-matrix.dense {
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 3px;
  max-height: min(290px, 45vh);
}

.tt-chunk-matrix.dense .tt-chunk-node {
  position: relative;
  padding: 0;
  aspect-ratio: 1 / 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: rgba(12, 16, 20, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  line-height: 1;
  font-weight: 800;
  overflow: hidden;
}

.tt-chunk-matrix.dense .tt-cn-dense-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.tt-chunk-matrix.dense .tt-cn-header,
.tt-chunk-matrix.dense .tt-cn-track {
  display: none;
}

.tt-chunk-matrix.dense .tt-chunk-node.done {
  background: rgba(143, 229, 0, 0.15);
  border-color: var(--accent);
}
.tt-chunk-matrix.dense .tt-chunk-node.done .tt-cn-dense-fill {
  width: 100% !important;
  background: linear-gradient(90deg, #6bb800, #8fe500);
  box-shadow: 0 0 5px rgba(143, 229, 0, 0.6);
}

.tt-chunk-matrix.dense .tt-chunk-node.uploading {
  border-color: #00f0ff;
  background: rgba(0, 240, 255, 0.12);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.45);
}
.tt-chunk-matrix.dense .tt-chunk-node.uploading .tt-cn-dense-fill {
  background: linear-gradient(90deg, #0099cc, #00f0ff);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.8);
}

.tt-chunk-matrix.dense .tt-chunk-node.pending {
  background: rgba(20, 25, 32, 0.65);
  border-color: rgba(48, 56, 65, 0.6);
}

.tt-chunk-matrix.dense .tt-chunk-node.expired {
  background: rgba(100, 113, 125, 0.15);
  border-color: #64717d;
}
.tt-chunk-matrix.dense .tt-chunk-node.expired .tt-cn-dense-fill {
  width: 100% !important;
  background: #64717d;
}

.tt-matrix-active-info {
  font-size: 0.56rem;
  color: #00f0ff;
  margin-top: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Legibility protection against background wireframes */
.intro h1 {
  text-shadow: 0 2px 8px rgba(10, 12, 14, 0.9), 0 0 16px rgba(10, 12, 14, 0.95);
}

.intro p {
  color: #a9b5c2;
  text-shadow: 0 1px 4px rgba(10, 12, 14, 0.9), 0 0 10px rgba(10, 12, 14, 0.95);
}

.qr-dialog {
  background: linear-gradient(135deg, rgba(30, 32, 35, 0.94) 0%, rgba(15, 17, 20, 0.90) 100%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 0 24px 0 rgba(255, 255, 255, 0.02),
    0 24px 60px rgba(0, 0, 0, 0.8),
    0 4px 16px rgba(0, 0, 0, 0.5);
}

.qr-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.qr-dialog .qr-display-box {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.qr-dialog .qr-close-button {
  border-color: rgba(255, 255, 255, 0.12);
}

@media (max-width: 1023px) {
  .bg-canvas {
    pointer-events: none;
  }

  /* Telemetry tooltip must NEVER render when transfer cubes are disabled (<1024px) */
  #active-upload-tooltip {
    display: none !important;
  }
}

@media (max-width: 859px) {
  .panel {
    box-shadow:
      inset 0 0 16px 0 rgba(255, 255, 255, 0.02),
      0 4px 16px rgba(0, 0, 0, 0.35);
  }
}
