/* ============================================================
   SIMPLE MODAL
============================================================ */
/* Add this class to ANY image that needs to open in a simple modal */
.simplemodalimage {
  cursor: pointer;
  transition: transform 0.2s ease;
  position: relative;
  z-index: 1;
}
.simplemodalimage:hover {
  transform: scale(1.02);
}

/* --- THE MODAL CONTAINER --- */
.simple-modal {
  position: fixed;
  inset: 0;
  z-index: 200000; /* Highest layer */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.simple-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- BACKDROP --- */
.simple-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8); /* Parent opacity handles the color fade */

  /* Explicit zero starting point */
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);

  /* Force the browser to interpolate the blur continuously */
  transition: backdrop-filter 0.25s ease, -webkit-backdrop-filter 0.25s ease;
}

/* When the parent gets the visible class, trigger the 4px target */
.simple-modal.visible .simple-modal-backdrop {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* --- CONTENT WRAPPER --- */
.simple-modal-content {
  position: relative;
  z-index: 2;
  /* Allow the image to move during swipe */
  will-change: transform;
  /* Center the image */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* --- THE IMAGE ITSELF --- */
.simple-modal-content img {
  max-width: 85dvw;
  max-height: 85dvh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  user-select: none;
  /* Prevent browser dragging so our JS handles it */
  -webkit-user-drag: none;
}

/* --- CLOSE BUTTON --- */
.simple-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 40px;
  line-height: 1;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.simple-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}
/* ============================================================
   MODAL (DESKTOP)
============================================================ */
body.modal-open {
  overflow: hidden;
  position: fixed;
  touch-action: none;
  width: 100%;
}

/* MODAL BACKDROP */
.packet-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast),
    backdrop-filter var(--transition-fast);
  pointer-events: none;
  display: block;
  z-index: 100;
}

.packet-modal.visible {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 1;
  pointer-events: auto;
}

.packet-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  cursor: pointer;
  color: var(--packet-text-muted);
  z-index: 20;
  padding: 0 0 25px 25px;
}
.packet-modal-close:hover {
  color: var(--packet-text);
}

.packet-modal-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  color: var(--packet-text);
  cursor: pointer;
  z-index: 30;
  opacity: 0.7;
  user-select: none;
}
.packet-modal-arrow:hover {
  opacity: 1;
}

.packet-modal-arrow.left {
  left: 12px;
  padding: 20px 20px 20px 0;
}
.packet-modal-arrow.right {
  right: 12px;
  padding: 20px 0 20px 20px;
}

.packet-modal-content {
  position: absolute;
  top: calc(50dvh + (var(--titlebar-height) / 2) + (var(--saucemenu-top) / 2));
  left: calc(50dvw + (var(--saucemenu-left) / 2));
  width: calc(90dvw - var(--saucemenu-left));
  height: 70dvh;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: var(--radius-lg);
  transform: translate(-50%, -50%);
  overflow: hidden;

  touch-action: pan-x;

  display: grid;
  grid-template-columns: 1fr min(60%, 700px);
}

@media (max-width: 768px) {
  #packetModal {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }
  .packet-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    top: calc(50dvh + (var(--titlebar-height) / 2));
    left: 50dvw;
    height: calc(100dvh - var(--titlebar-height-mobile));
    width: 100dvw;
    overflow: hidden;
  }
}

/* ============================================================
   PSUEDO PACKET PAGE MODE (sans arrows and close)
============================================================ */
/* Single packet modal: hide carousel affordances*/
.packet-modal.single-packet .packet-modal-arrow {
  display: none !important;
}

/*.packet-modal.single-packet #slidePrev,
.packet-modal.single-packet #slideNext {
  display: none !important;
}*/

/* Optional: make center slide use full width cleanly */
.packet-modal.single-packet #packetImageSlider {
  transform: translateX(-33.3333%); /* keep CUR_OFFSET behavior */
}

/* ============================================================
   PACKET PAGE MODE (reuse modal layout sans arrows and close)
============================================================ */
.packet-page-mode {
  position: absolute;
  top: calc(50dvh - (var(--titlebar-height) / 2) - (var(--saucemenu-top) / 2));
  left: calc(50dvw + (var(--saucemenu-left) / 2));
  width: calc(90dvw - var(--saucemenu-left));
  height: 70dvh;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: var(--radius-lg);
  transform: translate(-50%, -50%);
  overflow: hidden;

  touch-action: pan-x;

  /* grid: left image shell + right info panel */
  display: grid;
  /*grid-template-columns: minmax(0, 1fr) 340px;*/
  grid-template-columns: 1fr min(60%, 700px);
}

.packet-page-mode .packet-modal-close,
.packet-page-mode .packet-modal-arrow {
  display: none !important;
}

@media (max-width: 768px) {
  .packet-page-mode {
    display: flex;
    position: relative !important;
    width: 100dvw !important;
    height: calc(
      100dvh - var(--titlebar-height-mobile) - var(--footer-height)
    ) !important;

    /* kill modal centering */
    top: auto !important;
    left: auto !important;
    transform: none !important;

    /* keep modal visuals */
    border-radius: 0;
    grid-template-columns: 1fr min(60%, 700px);
  }
}

/* ============================================================
 IMAGE SHELL + SLIDER
============================================================ */
.packet-image-shell {
  position: relative;
  overflow: hidden;
  background: var(--thumb-bg);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

@media (max-width: 768px) {
  .packet-image-shell {
    height: var(--image-shell-height, 50%);
  }

  .packet-image-slide img {
    max-height: 90%;
  }
}

/* =========================================
   HIJACKED SLOT BREADCRUMB
   ========================================= */
#packet-breadcrumb {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 4px;
  border-radius: 30px;
  color: white;
  cursor: pointer;
  z-index: 100;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#packet-breadcrumb:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.03);
}

#packet-breadcrumb:active {
  transform: scale(0.97);
}

.breadcrumb-thumb {
  width: 24px;
  border-radius: 4px;
  object-fit: cover;
}

.breadcrumb-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.breadcrumb-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: #aaa;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.breadcrumb-name {
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================
   MULTITOUCH PINCH LOUPE
   ========================================= */
.packet-loupe {
  position: fixed;
  pointer-events: none; /* Crucial: lets fingers touch the screen through the lens */
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;

  /* Creates a heavy shadow below, and a subtle "glass curve" shadow inside */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.5);

  background-color: var(--general-black, #111);
  background-repeat: no-repeat;

  z-index: 999999;

  /* Centers the loupe exactly on the X/Y coordinates we feed it */
  transform: translate(-50%, -50%);

  opacity: 0;
  transition: opacity 0.15s ease-out;
  will-change: left, top, width, height, background-position;
}

/* =========================================
   LOUPE GLASS EFFECTS (Vignette, CA & Edge Blur)
   ========================================= */
.packet-loupe::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  pointer-events: none;

  /* 1. Vignette + Chromatic Aberration */
  /* We stack inset shadows: a deep black one for depth, and offset RGB values for the color split */
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.6),
    /* Dark depth vignette */ inset 4px 0 8px rgba(255, 0, 0, 0.5),
    /* Red fringe on the left */ inset -4px 0 8px rgba(0, 255, 255, 0.5); /* Cyan fringe on the right */

  /* 2. The Edge Blur */
  /* 8px to 10px creates a realistic out-of-focus lens edge. */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  /* 3. The Mask (The Magic Filter) */
  /* Because the mask makes the center transparent, it hides the blur AND seamlessly fades out the colored shadows so the center stays perfectly crisp! */
  -webkit-mask-image: radial-gradient(
    circle at center,
    transparent 55%,
    black 95%
  );
  mask-image: radial-gradient(circle at center, transparent 55%, black 95%);
}

.packet-loupe.visible {
  opacity: 1;
}

/* =========================================
   3D CARD FLIP ANIMATION
========================================= */
#packet-flip-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  width: 35px;
  height: 35px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0; /* Replaces display: none */
  pointer-events: none; /* Prevents clicking while invisible */

  /* Add opacity to the transition list! */
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    background 0.2s, opacity 0.2s ease;
}
#packet-flip-btn:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: scale(1.1);
}
#packet-flip-btn.flipped {
  transform: rotate(180deg);
}
#packet-flip-btn.flipped:hover {
  transform: rotate(180deg) scale(1.1);
}
/* 🔥 THE LABEL (Floating above the button) */
#packet-flip-btn::after {
  content: "FRONT";
  position: absolute;
  top: -19px; /* Pushes the text completely above the button */
  left: 50%;
  transform: translateX(-50%); /* Centers the text perfectly */
  color: white;
  font-family: sans-serif;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none; /* Ensures the text doesn't block clicks */
}

/* Change the text to BACK when flipped */
#packet-flip-btn.flipped::after {
  content: "BACK";
  /* Counter-rotate by -180deg to keep the text perfectly upright while it swoops! */
  transform: translateX(-50%) rotate(-180deg);
}

/* 🔥 ROTATE THE ICON INSTEAD OF THE BUTTON */
#packet-flip-btn i {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#packet-flip-btn.flipped i {
  transform: rotate(180deg);
}
.flip-transitioning {
  opacity: 0 !important;
  filter: blur(4px) brightness(1.2) !important;
  transition: opacity 0.15s ease-in, filter 0.15s ease-in !important;
}
.flip-ready {
  opacity: 1 !important;
  filter: blur(0px) brightness(1) !important;
  transition: opacity 0.15s ease-out, filter 0.15s ease-out !important;
}

/* 1. Add perspective to the parent containers to create 3D space */
.packet-image-slide,
.standalone-packet-image-shell {
  perspective: 1200px;
}

/* 2. Base state for the image */
.packet-image-slide img,
.packet-page-mode img {
  rotate: y 0deg;
  transform-style: preserve-3d; /* Tells the browser to render this in 3D */
}

/* 3. The 3 Phases of the Flip */
.flip-out {
  rotate: y 90deg !important;
  filter: brightness(0.6) drop-shadow(0px 0px 0px rgba(0, 0, 0, 0)) !important;
  transition: rotate 0.1s ease-in, filter 0.1s ease-in !important;
}

.flip-in-prep {
  rotate: y -90deg !important;
  filter: brightness(0.6) drop-shadow(0px 0px 0px rgba(0, 0, 0, 0)) !important;
  transition: none !important;
}

.flip-in {
  rotate: y 0deg !important;
  filter: brightness(1) drop-shadow(0px 10px 15px rgba(0, 0, 0, 0.4)) !important;
  transition: rotate 0.1s ease-out, filter 0.1s ease-out !important;
}

/* 3-panel slider (prev | current | next) */
.packet-image-slider {
  width: 300%;
  height: 100%;
  display: flex;
  touch-action: none;
}

/* Each slide */
.packet-image-slide {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.packet-image-slide img {
  max-width: min(60%, 700px);
  width: 75dvw;
  max-height: 90%;
  object-fit: contain;
}

.packet-image-slide img,
.chart-overlay-image,
.chart-overlay-canvas {
  transition: transform 0.25s ease;
  transform-origin: center center;
}

/* Base state for landscape images (smooth transition) */
.packet-image-slide img.is-landscape {
  transition: transform 0.25s ease;
  transform: rotate(0deg) scale(1);
}

/* ============================================================
 INFO PANEL
============================================================ */
/* INFO PANEL */
.packet-info-panel {
  background: var(--modal-bg);
  /*background: linear-gradient(0deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),
    var(--packet-accent-medium, var(--modal-bg));*/
  /*background: linear-gradient(
    to bottom,
    var(--modal-bg) 0%,
    var(--packet-accent-dark) 100%
  );*/
  border-left: 1px solid var(--modal-border);
  padding: 0 16px 16px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  container-type: inline-size;
}

.home-info-panel {
  background: var(--modal-bg);
  /*background: linear-gradient(0deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),
    var(--packet-accent-medium, var(--modal-bg));*/
  /*background: linear-gradient(
    to bottom,
    var(--modal-bg) 0%,
    var(--packet-accent-dark) 100%
  );*/
  border-left: 1px solid var(--modal-border);
  padding: 0 4px 4px 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  container-type: inline-size;
}

@media (max-width: 768px) {
  .packet-info-panel,
  .home-info-panel {
    padding: 0 8px 8px 8px;
    border-left: none;
  }
}
.packet-info-panel,
.home-info-panel {
  font-size: clamp(12px, 1.2cqw, 16px);
}

.packet-info-panel h3,
.home-info-panel h3 {
  font-size: clamp(14px, 1.6cqw, 20px);
}

.packet-info-panel table td,
.home-info-panel table td {
  font-size: clamp(9px, 1.1cqw, 12px);
}

.packet-info-panel td,
.home-info-panel td {
  padding: 1.5px 0px;
  /*border-bottom: 1px solid var(--packet-border);*/
  box-shadow: inset 0 -1px 0 0 #555555;
}

.packet-info-panel td:first-child,
.home-info-panel td:first-child {
  color: var(--packet-accent-light);
  width: 40px;
  min-width: 40px;
}
.packet-info-panel td:nth-child(2) {
  color: white;
  width: calc(45dvw - 40px - 70px);
}
.packet-info-panel td:nth-child(3),
.home-info-panel td:nth-child(3) {
  color: var(--packet-accent-light);
  width: 70px;
  min-width: 70px;
}
.packet-info-panel td:nth-child(4) {
  color: white;
  width: calc(45dvw - 40px - 70px);
}

@media (max-width: 768px) {
  .packet-info-panel td:first-child,
  .home-info-panel td:first-child {
    color: var(--packet-accent-light);
    width: 30px;
    min-width: 30px;
  }
  .packet-info-panel td:nth-child(2),
  .home-info-panel td:nth-child(2) {
    color: white;
    width: calc(50dvw - 30px - 52px);
  }
  .packet-info-panel td:nth-child(3),
  .home-info-panel td:nth-child(3) {
    color: var(--packet-accent-light);
    width: 52px;
    min-width: 52px;
  }
  .packet-info-panel td:nth-child(4),
  .home-info-panel td:nth-child(4) {
    color: white;
    width: calc(50dvw - 30px - 52px);
  }
}

.packet-info-panel .orientation-tag,
.home-info-panel .orientation-tag {
  opacity: 0.75;
  font-style: italic;
}

@media (max-width: 768px) {
  .packet-info-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    will-change: transform;
    overflow: hidden;
  }
  .packet-info-panel.collapsed,
  .home-info-panel.collapsed {
    transform: translateY(calc(100% - 36px));
  }

  .packet-details-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    user-select: none;
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 16px;
  }

  .packet-details-handle .handle-bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #aaa;
  }
}

/* ============================================================
 Tear Here + Perforation (modal rendering)
============================================================ */
.tearhere-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tearhere-status {
  font-size: clamp(9px, 1.1cqw, 12px);
  line-height: 1;
}

.tearhere-text {
  font-size: clamp(9px, 1.1cqw, 12px);
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.perforation-icon {
  width: 100%;
  /*max-width: 100px; /* tweak this */
}

/* Layout wrapper */
.perf-wrap {
  display: flex;
  /*flex-direction: column;*/
  align-items: center;
  gap: 8px;
}
.perf-svg-inline {
  height: 14px;
  width: 45px;
}

/* Label */
.perf-label {
  /*position: absolute;*/
  letter-spacing: 0.06em;
  color: white;
  white-space: nowrap;
  font-size: clamp(9px, 1.1cqw, 12px);
}

/* SVG sizing */
.perf-svg {
  /*width: 100%;
    max-width: 160px;  /*tweak independently*/
  height: 12px;
}

@media (max-width: 768px) {
  .perf-svg {
    height: 10px;
  }
}

/* Stroke styling */
.perf-zigzag path,
.perf-slit line {
  stroke: white;
  stroke-width: 1.5;
  fill: none;
  vector-effect: non-scaling-stroke;
}

/*footer*/

.footer-card-header {
  font-size: 0.65rem;
  text-align: center;
  white-space: nowrap;
  padding: 2px clamp(0px, 0.75dvw, 0.75dvw);
  margin-right: auto;
  background-color: #333;
  z-index: 1;
  border-radius: var(--radius-sm);
  color: var(--packet-accent-light);
}

@media (max-width: 768px) {
  .footer-card-header {
    padding: 2px clamp(0px, 1dvw, 1dvw) 2px clamp(0px, 1.5dvw, 1.5dvw);
  }
}
/*TearHere/Perf*/
/* --------------------------------------------
   PHENOTYPE GRID
-------------------------------------------- */
.footer-card-pheno,
.footer-card-color,
.footer-card-qr {
  --pheno-perf-pattern: none;
  --pheno-perf-single: none;
  min-width: calc((var(--qr-size) * 1px) + 4px);
  position: relative;
}

.footer-card-pheno::after,
.footer-card-color::after,
.footer-card-qr::after {
  content: "";
  position: absolute;
  width: clamp((calc(var(--qr-size) * 1px) - 4px), 90%, 100%);
  top: 8px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  left: 50%;
  transform: translate(-50%, 0%);
}

.footer-card-pheno {
  position: relative;
  background: white;
  /* transition: border-radius 0.2s ease; */
}

.footer-card-pheno::after {
  content: "";
  position: absolute;

  /* Reset properties from the shared rule */
  width: auto;
  height: auto;
  transform: none;
  border-radius: 0; /* Let the inset handle shape, or match parent */

  /* Fill the container */
  inset: 4px;
  pointer-events: none;

  /* Use the generated SVG */
  background-image: var(--pheno-border-source);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.footer-card-color::after {
  border: 1.5px solid #777777;
}
.footer-card-qr::after {
  border: 1.5px solid #777777;
}

.footer-pheno-grid,
.footer-color-pie,
.footer-qr {
  display: flex;
  justify-content: center;
  width: clamp(calc((var(--qr-size) * 1px) - 10px), 90%, 120px);
  height: calc((var(--qr-size) * 1px) + 5px);
  cursor: pointer;
}

.footer-card-pheno .footer-pheno-grid {
  padding: 0 4px;
  height: calc((var(--qr-size) * 1px) + 4px);
  width: clamp(calc((var(--qr-size) * 1px) - 10px), 75%, 120px);

  display: flex;
  flex-direction: column;
  justify-content: space-between;

  background: var(--modal-bg);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------
   ROWS
-------------------------------------------- */

.footer-card-pheno .footer-pheno-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* visual-only perforation row */
.footer-card-pheno .footer-perf-visual-row {
  margin-top: 2px;
}

/* --------------------------------------------
   TOP / BOTTOM GROUPS
-------------------------------------------- */

.footer-card-pheno .footer-pheno-top,
.footer-card-pheno .footer-pheno-bottom {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.footer-card-pheno .footer-pheno-top {
  padding-top: 2px;
}

.footer-card-pheno .footer-pheno-bottom {
  padding-bottom: 2px;
}

/* --------------------------------------------
   LABELS
-------------------------------------------- */

.footer-card-pheno .footer-pheno-label,
.footer-card-pheno .footer-perf-label {
  font-size: 0.5rem;
  color: var(--packet-text-muted);
  white-space: nowrap;
}

/* --------------------------------------------
   VALUES (right-aligned)
-------------------------------------------- */

.footer-card-pheno .footer-tear-value,
.footer-card-pheno .footer-perf-value,
.footer-card-pheno .footer-size-value,
.footer-card-pheno .footer-orient-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  font-size: 0.5rem;
}

/* --------------------------------------------
   RIGHT-HAND STACKS
-------------------------------------------- */

.footer-card-pheno .footer-pheno-right,
.footer-card-pheno .footer-perf-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
  font-size: 0.5rem;
}

/* --------------------------------------------
   PERFORATION SVG WRAP
-------------------------------------------- */

.footer-card-pheno .perf-wrap {
  width: calc(var(--qr-size) * 1px);
}

/* --------------------------------------------
   OPTIONAL TEXT (future use)
-------------------------------------------- */

.footer-card-pheno .footer-tear-text {
  font-size: 0.5rem;
  font-weight: 500;
  white-space: nowrap;
}

.footer-pheno-label {
  font-size: 0.5rem;
  color: var(--packet-text-muted);
  white-space: nowrap;
}

/* ======================================================
   FOOTER - PHENO TEAR HERE INDICATOR
====================================================== */
.footer-tear-indicator-wrap {
  /* Ensure the wrap itself doesn't grow to fit the image */
  height: 100%;
  min-height: 45px;
  max-height: 80px; /* Adjust this to the max height you want for that middle gap */

  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; /* Safety fallback */
}

.footer-tear-icon {
  /* Force the container to be the size of the wrap */
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.pheno-indicator-visual {
  /* THE FIX: Force the image to stay inside the wrap */
  max-height: 90%; /* 90% gives it a little breathing room from the dashed border */
  max-width: 90%;
  width: auto;
  height: auto;

  /* This ensures it scales down proportionally without clipping */
  object-fit: contain;

  /* Optional: Ensure white icons pop */
  filter: brightness(0) invert(1);
}
/* ======================================================
   FOOTER - CLICKABLE QR CODE (COPY LINK)
====================================================== */
.packet-modal-title {
  color: var(--packet-accent-full);
  margin: 0;
  line-height: 1;
  font-size: clamp(10px, 22px, 4.5vw);
  /*-webkit-text-stroke: 2px white;
  paint-order: stroke fill;*/
}
/* tight box that matches the QR size */
#qrFrame {
  position: relative;
  width: calc(var(--qr-size) * 1px);
  height: calc(var(--qr-size) * 1px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
}

/* the animated “copied” border */
#qrFrame.copied::after {
  content: "";
  position: absolute;
  inset: 0; /* hugs the frame */
  border-radius: var(--radius-sm);
  pointer-events: none;

  /* whatever animation you already use */
  animation: copyPulse 0.4s ease-out;
}

.footer-qr {
  position: relative;
  cursor: pointer;
  min-width: calc((var(--qr-size) * 1px) + 24px);
}

.footer-qr canvas {
  display: block;
}

.qr-frame .qr-overlay-text {
  width: calc(var(--qr-size) * 1px);
  height: calc(var(--qr-size) * 1px);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--transition-xfast);
  pointer-events: none;
  border-radius: var(--radius-sm);
}

.qr-frame.copied .qr-overlay-text {
  opacity: 1;
  border-radius: var(--radius-sm);
}

.qr-overlay-text,
.color-swatch-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: #fff;
  text-align: center;
  user-select: none;
  pointer-events: none;

  /* 👇 Your outline */
  text-shadow: -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000,
    1px 1px 1px #000;
}

.qr-overlay-text {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  pointer-events: none;
  transition: all var(--transition-xfast) ease;
  border-radius: var(--radius-sm);
}

/* To organize */

/* ============================================================
   PACKET PAGE MODE (reuse modal layout)
============================================================ */
/* packetInfoPanel */
/* Base table: 4 columns */
.packet-info-table {
  table-layout: fixed;
}

.packet-info-table col.label-col {
  width: 160px;
}

.packet-info-table col.value-col {
  width: auto;
}

/* Paired rows */
.packet-info-table .paired-label {
  font-weight: 600;
  color: var(--packet-text-muted);
  white-space: nowrap;
}

.packet-info-table .paired-value {
  padding-right: 20px;
}

.packet-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 16px;
  row-gap: 4px;
}

.packet-pair > div {
  white-space: nowrap;
}

.packet-pair strong {
  color: var(--packet-text-muted);
  font-weight: 600;
  margin-right: 4px;
}
.packet-paired-row td:first-child {
  width: 0;
  padding: 0;
}

/* ============================================================
   AVERAGE COLOR BLOCK
============================================================ */

.footer-color-pie {
  position: relative;
  height: 100%;
  min-height: calc(var(--qr-size) * 1px);
  max-height: calc(var(--qr-size) * 1px);
}

.footer-color-pie canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: pointer;
}
/* ============================================================
   PHENOTYPE OVERLAY
============================================================ */
/* 1. When hidden, it MUST NOT block clicks */
.chart-overlay[aria-hidden="true"] {
  display: none !important;
  pointer-events: none !important;
}

/* 2. When active, it captures clicks */
.chart-overlay[aria-hidden="false"] {
  display: block !important;
  pointer-events: auto !important;
}

/* =========================================
   BASE STYLES (Applies to ALL screen sizes)
   ========================================= */
.pheno-blueprint-container {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  background-image: linear-gradient(
      rgba(77, 166, 255, 0.1) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(77, 166, 255, 0.1) 1px, transparent 1px);
  background-size: 10px 10px;
}

/* Base SVG Box */
.bp-layer-svg {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
}

.bp-drawing {
  display: block;
  filter: drop-shadow(0 0 4px rgba(77, 166, 255, 0.3));
  pointer-events: none;
  max-width: 95%;
  max-height: 95%;
  height: auto;
  width: auto;
}

/* Base Legend Box */
.bp-layer-legend {
  position: relative;
  box-sizing: border-box;
}

/* Base Stat Box */
.bp-stat-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  border-bottom: 2px solid rgba(77, 166, 255, 0.5);
}

.bp-stat-box .bp-label {
  color: #4da6ff;
  font-weight: bold;
  text-transform: uppercase;
  white-space: nowrap;
}

.bp-stat-box .bp-val {
  color: #fff;
  text-align: right;
  word-break: break-word;
}

.bp-stat-image {
  justify-content: center;
  border-bottom: none;
}

.bp-stat-image img {
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

/* =========================================
   DESKTOP STYLES (Protected Grid)
   ========================================= */
@media (min-width: 769px) {
  .bp-layer-legend {
    display: flex;
    flex-direction: column;
    /*background: rgba(13, 27, 42, 0.25);
    border: 1px solid #4da6ff;*/
    height: 100%;
    min-height: 0;
  }

  .bp-stat-box {
    padding: 2px 12px;
    font-size: 0.7rem;
    flex: 0 0 auto; /* Keeps text snug at top */
  }

  .bp-stat-box .bp-label {
    margin-right: 12px;
  }

  /* 🔥 RESHUFFLE THE DESKTOP ORDER */
  .bp-stat-id {
    order: 1;
  }
  .bp-stat-format {
    order: 2;
  }
  .bp-stat-size {
    order: 3;
  }
  .bp-stat-orient {
    order: 4;
  }
  .bp-stat-perf {
    order: 5;
    border-bottom: 2px solid rgba(77, 166, 255, 0.5);
  }

  /* Tear Here moves to the bottom above the image */
  .bp-stat-tear {
    order: 6;
    border-bottom: none;
  }

  /* Desktop Ghost Image */
  .bp-stat-image {
    order: 7;
    flex: 1; /* Absorbs remaining height */
    min-height: 150px;
    position: relative;
    padding: 0;
  }

  .bp-stat-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 3vw;
    box-sizing: border-box;
  }
}
/* =========================================
   MOBILE STYLES (Protected Grid/Flex)
   ========================================= */
@media (max-width: 768px) {
  .pheno-blueprint-container {
    display: grid !important;
    gap: 0;
    padding: 0;
  }

  /* OVERRIDE: Let the drawing use 100% of the space on small screens! */
  .bp-drawing {
    max-width: 100%;
    max-height: 100%;
  }

  .bp-layer-svg {
    background: rgba(0, 0, 0, 0.25);
    padding: 0px 10px;
  }

  .bp-layer-legend {
    border: none;
    background: transparent;
  }

  .bp-stat-box {
    padding: 2px 6px;
    font-size: 0.55rem;
  }

  .bp-stat-box .bp-label {
    margin-right: 8px;
  }

  /* MOBILE PORTRAIT & CIRCULAR */
  .pheno-blueprint-container[data-orientation="portrait"] {
    grid-template-columns: 1.4fr 1.6fr;
    grid-template-rows: 1fr;
  }

  .pheno-blueprint-container[data-orientation="portrait"] .bp-layer-svg {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    border-right: 1px solid #4da6ff;
  }

  .pheno-blueprint-container[data-orientation="portrait"] .bp-layer-legend {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-id {
    order: 1;
  }
  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-format {
    order: 2;
  }
  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-size {
    order: 3;
  }
  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-orient {
    order: 4;
  }
  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-perf {
    order: 5;
  }
  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-tear {
    order: 6;
    border-bottom: none;
  }

  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-image {
    order: 7;
    flex: 1;
    min-height: 0;
    position: relative;
    padding: 0;
  }

  .pheno-blueprint-container[data-orientation="portrait"] .bp-stat-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 6px;
    box-sizing: border-box;
  }

  /* MOBILE LANDSCAPE */
  .pheno-blueprint-container[data-orientation="landscape"] {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) max-content;
  }

  .pheno-blueprint-container[data-orientation="landscape"] .bp-layer-svg {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    border-bottom: 1px solid #4da6ff;
  }

  .pheno-blueprint-container[data-orientation="landscape"] .bp-layer-legend {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    display: grid;
    grid-template-columns: max-content max-content max-content 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    min-height: 65px; /* Gives the webp icon breathing room */
  }

  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-id {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    border-right: 2px solid rgba(77, 166, 255, 0.5);
  }
  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-format {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    border-right: 10px solid rgba(77, 166, 255, 0.5);
  }
  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-size {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    border-right: 2px solid rgba(77, 166, 255, 0.5);
  }
  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-orient {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    border-right: 10px solid rgba(77, 166, 255, 0.5);
  }
  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-perf {
    grid-column: 1 / 3;
    grid-row: 3 / 4;
    border-right: 10px solid rgba(77, 166, 255, 0.5);
    border-bottom: none;
  }

  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-tear {
    grid-column: 3 / 4;
    grid-row: 1 / 4;
    /*border-right: 2px solid rgba(77, 166, 255, 0.5);*/
    border-bottom: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }

  .pheno-blueprint-container[data-orientation="landscape"]
    .bp-stat-tear
    .bp-label {
    margin: 0;
  }
  .pheno-blueprint-container[data-orientation="landscape"]
    .bp-stat-tear
    .bp-val {
    font-size: 1.6rem;
    line-height: 1;
  }

  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-image {
    grid-column: 4 / 5;
    grid-row: 1 / 4;
    position: relative;
    padding: 0;
  }

  .pheno-blueprint-container[data-orientation="landscape"] .bp-stat-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 6px;
    box-sizing: border-box;
  }
}
/* ============================================================
   PIE CHART OVERLAY
============================================================ */
/* Chart overlay container */
#chartOverlay,
#phenoOverlay {
  top: 60px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  overflow: hidden;
  border-top: 1px solid gray;
}
@media (max-width: 768px) {
  #chartOverlay,
  #phenoOverlay {
    top: 36px; /* HANDLE HEIGHT — matches modal.js - const HANDLE_HEIGHT */
  }
}

/* chart-visible is the "fade in" state */
.packet-modal-content.chart-visible #chartOverlay,
.packet-modal-content.chart-visible #phenoOverlay {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#packetModal.is-page-mode {
  position: static; /* Remove the fixed overlay behavior */
  background: none;
  display: block;
  opacity: 1 !important;
  transform: none !important;
}
.chart-overlay {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  padding: 12px 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.chart-overlay-close {
  position: absolute;
  top: 4px;
  right: 10px;
  width: 45px;
  height: 45px;
  padding: 0 0 4px 12px;
  border: none;
  background: rgba(255, 255, 255, 0);
  color: #fff;
  font-size: 30px;
  line-height: 32px;
  cursor: pointer;
}

.chart-overlay-title {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.4px;
  padding-left: 15px;
  margin-bottom: 4px;
}
.avg-color-title,
.palette-title {
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.chart-overlay-body {
  display: grid;
  grid-template-columns: 1fr minmax(100px, 200px);
  width: 100%;
  height: calc(100% - 18px); /*minus half the size of the drag handle*/
  box-sizing: border-box;
}

/* LEFT */
.chart-overlay-left {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  padding: 12px;
}

/* RIGHT */
.chart-overlay-right {
  display: flex;
  flex-direction: column;
  padding: 0 10px 0 0;
  /*background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;*/
  min-width: 0;
  font-size: 0.75rem;
}

.chart-overlay-canvas-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-center-title {
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.chart-center-title.copied {
  transform: scale(1.25);
  letter-spacing: 0.04em;

  font-size: 0.7rem;
  font-weight: bold;
  text-align: center;
  color: rgba(0, 0, 0, 1);
  -webkit-text-stroke: 3px white;
  paint-order: stroke fill;

  animation: none;
}

.chart-center-wrap {
  position: relative;
  width: 100% !important;
  height: 100% !important;
  cursor: pointer;
}

.chart-center-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  cursor: pointer;
}

.avg-color-panel {
  display: grid;
  grid-template-columns: 14px auto auto;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: #fff;
  margin-bottom: 4px;
}

.avg-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  cursor: pointer;
  margin: 0 4px;
}

.avg-color-hex {
  font-family: monospace;
  font-size: 1rem;
  color: #fff;
}

.avg-color-controls {
  font-size: 0.6rem;
  color: #ddd;
  display: flex;
  justify-content: flex-end;
}

.neutral-swatch {
  display: inline-block;
  cursor: pointer;
  user-select: none;
  padding: 2px;
}

/* Hide the real checkbox */
.neutral-swatch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* The swatch itself */
.neutral-swatch-box {
  width: 48px;
  height: 18px;
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  /* Diagonal black / white split */
  background: linear-gradient(115deg, #eee 0%, #eee 50%, #111 50%, #111 100%);
  background-size: 400% 400%;
  background-position: 100% 50%; /* default = ON */

  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.75);

  transition: background-position 260ms cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 150ms ease, transform 120ms ease;
}

/* Text inside the swatch */
.neutral-swatch-text {
  font-size: 0.45rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8), 0 0 2px rgba(0, 0, 0, 0.8);
  mix-blend-mode: difference; /* ensures readability on both halves */
  pointer-events: none;
}

/* Default (unchecked = INCLUDE neutrals) */
.neutral-swatch-text::before {
  content: "Neutrals Included";
}

/* Checked = EXCLUDE neutrals */
.neutral-swatch
  input:checked
  + .neutral-swatch-box
  .neutral-swatch-text::before {
  content: "Neutrals Excluded";
}

/* ON → slide right */
.neutral-swatch input:checked + .neutral-swatch-box {
  background-position: 100% 50%;
  opacity: 0.75;
}

/* OFF → slide left */
.neutral-swatch input:not(:checked) + .neutral-swatch-box {
  background-position: 50% 50%;
  opacity: 1;
}

@keyframes neutral-swatch-toggle {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 100% 50%;
  }
}

.chart-overlay-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.chart-overlay-side {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}

.legend-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.legend-name {
  display: flex;
  justify-content: flex-start;
  color: white;
  font-size: 0.6rem;
}

.legend-pct {
  display: flex;
  justify-content: flex-end;
  color: white;
  font-size: 0.6rem;
}

.chart-overlay-legend-hint {
  margin-top: 8px;
  opacity: 0.7;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px auto auto;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: #fff;
  box-sizing: border-box;
  padding: 2px;
}

.legend-row:last-child {
  margin-bottom: 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
  margin: 0 4px;
}

/* When chart overlay is open, hide lower UI (table + footer) */
.packet-modal-content.chart-mode #packetDetailsTable,
.packet-modal-content.chart-mode .packet-footer {
  pointer-events: none;
}

.visual-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: gray;
  border-radius: 30px;
  padding: 3px;
  justify-content: center;
}

/* The bar itself */
.visual-bar-track {
  display: flex;
  height: 14px;
  border-radius: 6px;
  overflow: hidden;
  width: 97%;
}

/* Individual color segment */
.visual-bar-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Percent labels ontop of the bar */
.visual-bar-pct {
  font-size: 8px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000,
    1px 1px 1px #000;
  pointer-events: none;
  white-space: nowrap;
}

/* Label text */
.visual-bar-labels span {
  white-space: nowrap;
}

/* Percentage emphasis */
.visual-bar-labels em {
  font-style: normal;
  opacity: 0.7;
  margin-left: 2px;
}

.color-swatch {
  width: 64px;
  height: 16px;
  background: inherit;
  border-radius: 6px;
  background: var(--swatch-color, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition-xfast);
}

.chart-center-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 0.7rem;
  text-align: center;
  color: rgba(255, 255, 255, 1);
  -webkit-text-stroke: 2px black;
  paint-order: stroke fill;
}

.chart-center-hex {
  font-family: monospace;
  margin-top: 2px;
}

.copied {
  animation: copyPulse 0.4s ease-out;
}

@keyframes copyPulse {
  0% {
    outline: 1px solid rgba(255, 255, 255, 1);
    outline-offset: 2px;
    z-index: 9999;
  }
  5% {
    outline: 5px solid rgba(255, 255, 255, 1);
    outline-offset: 2px;
    z-index: 9999;
  }
  15% {
    outline: 2px solid rgba(255, 255, 255, 1);
    outline-offset: 2px;
    z-index: 9999;
  }
  50% {
    outline: 2px solid rgba(255, 255, 255, 1);
    outline-offset: 2px;
    z-index: 9999;
  }
  100% {
    outline: 2px solid rgba(255, 255, 255, 0);
    outline-offset: 4px;
    z-index: 9999;
  }
}

.color-pie {
  display: block;
}

.color-pie path {
  stroke: rgba(0, 0, 0, 1);
  stroke-width: 0.5;
}

.color-pie text {
  font-weight: 600;
  text-shadow: -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000,
    1px 1px 1px #000;
}

/* ========================
   QR CODE INSIDE INFO PANEL
======================== */

.qr-wrapper {
  padding-top: 10px;

  position: relative; /* <---- anchor for share button */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#qrCanvas {
  background: white;
  border-radius: 6px;
  padding: 4px;
  border: 1px solid #999;
}

.qr-label {
  font-size: 12px;
  opacity: 0.7;
  text-align: center;
}

/* ======================================================
   DETAILS FOOTER LAYOUT
====================================================== */

.packet-footer {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
}

.packet-footer-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.packet-footer-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.footer-section h4 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  opacity: 0.7;
}

.footer-avg-color,
.footer-color-pie,
.footer-palette {
  display: flex;
  align-items: center;
  gap: 8px;
}

.packet-share-btn {
  cursor: pointer;
  border: none;
  background: transparent;
  z-index: 5;
}

.footer-card {
  background: #333333;
  /*background: linear-gradient(
    to bottom,
    #333333 0%,
    var(--packet-accent-dark) 100%
  );*/
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  padding-bottom: 8px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.footer-card-qr canvas,
.packet-modal .footer-avg-color .color-swatch,
.packet-page-mode .footer-avg-color .color-swatch {
  width: calc(var(--qr-size) * 1px);
  height: calc(var(--qr-size) * 1px);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

/* Center hex text nicely in the larger swatch */
.packet-modal .footer-avg-color .color-swatch-text,
.packet-page-mode .footer-avg-color .color-swatch-text {
  font-size: 1.1rem;
}

.packet-share-btn {
  font-size: 0.75rem;
  padding: 2px 8px;
  cursor: pointer;
}

.footer-card-body {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.packet-footer.footer-three-up {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1dvw;
  padding-top: 0px;
}

.footer-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: flex-start;
}

.footer-block h4 {
  margin-bottom: 8px;
  font-size: 0.8rem;
  opacity: 0.7;
  text-transform: uppercase;
}

/* TearHere & Perforation */
/* DELETE? */
.tearhere-stack {
  position: relative;
  width: 14px;
  height: 14px;
}
/* =========================================
   MASK LAYERS (Background & Foreground)
========================================= */
.packet-mask-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  /* Match packet image constraints */
  max-width: min(60%, 700px);
  width: 75dvw;
  max-height: 90%;

  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  display: block !important;
  opacity: 0;
  visibility: hidden;

  /* Smooth transition */
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#packet-mask-bg {
  z-index: 100;
}

#packet-mask-fg {
  z-index: 101;
}

.packet-mask-layer.is-visible {
  opacity: 1;
  visibility: visible;
}

/* =========================================
   UNIVERSAL SCRUB BAR
========================================= */
.chart-universal-scrub-bar {
  display: none; /* Hidden by default on Desktop */
  width: 100%;
  grid-column: 1 / -1;
  height: 50px;
  padding: 0 8px 0 8px;
  box-sizing: border-box;

  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.scrub-swatch {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease;
  position: relative;
}

/* Round the left corners of the first swatch */
.scrub-swatch:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

/* Round the right corners of the last swatch */
.scrub-swatch:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Haptic visual feedback on press */
.scrub-swatch:active {
  transform: scaleY(1.1);
  z-index: 2;
}

/* Inner Text Styling */
/* The Name is now the BIG text on top */
.scrub-swatch-name {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  color: #fff;
  -webkit-text-stroke: 1.5px black;
  paint-order: stroke fill;
  pointer-events: none;
  text-align: center;
  line-height: 1;
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* The Percentage is now the SMALL text on the bottom */
.scrub-swatch-pct {
  font-size: 10px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0px 1px 3px rgba(0, 0, 0, 1), 0px 0px 2px rgba(0, 0, 0, 1);
  pointer-events: none;
  margin-top: 3px;
  line-height: 1;
}

/* "Copied" Flash State */
.scrub-swatch.copied .scrub-swatch-pct,
.scrub-swatch.copied .scrub-swatch-name {
  opacity: 0;
}

.scrub-swatch.copied::after {
  content: "COPIED";
  position: absolute;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  -webkit-text-stroke: 1px black;
  paint-order: stroke fill;
}

/* =========================================
   MOBILE RESPONSIVE SWITCH
========================================= */
@media (max-width: 768px) {
  /* 1. Show the Mobile Scrub Bar */
  .chart-mode .chart-universal-scrub-bar {
    display: flex;
    flex-shrink: 0;
  }

  /* 2. Hide the Desktop Legend */
  .chart-overlay-right .palette-title,
  .chart-overlay-right .legend-divider,
  .chart-overlay-right .chart-overlay-legend {
    display: none;
  }

  /* 3. Keep existing grid rules */
  .chart-overlay-body {
    grid-template-columns: 1fr minmax(100px, 175px);
  }

  /* 4. Stack and protect the left column / pie chart */
  .chart-overlay-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0px;
  }

  .chart-overlay-left .chart-center-wrap {
    flex: 1;
    min-height: 0;
    height: auto !important;
  }

  /* 5. Spread out the Average Color Panel */
  .chart-overlay-right .avg-color-title {
    text-align: center;
    font-size: 1rem;
    margin-bottom: 12px;
  }

  .avg-color-panel {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 50px auto; /* Row 1 is the 50px Swatch, Row 2 is Controls */
    justify-items: center;
    align-items: center;
    gap: 0;
  }

  .avg-color-swatch {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    margin: 0;
  }

  .avg-color-hex {
    grid-column: 1;
    grid-row: 1;
    font-size: 1rem;
    font-weight: bold;
    z-index: 2;
    pointer-events: none;

    /* Make sure it's readable on both bright yellow and dark brown packets */
    color: #fff;
    -webkit-text-stroke: 1.5px black;
    paint-order: stroke fill;
    text-shadow: 0px 1px 4px rgba(0, 0, 0, 0.8);
  }

  .avg-color-controls {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 8px;
  }

  .neutral-swatch {
    display: block;
    width: 100%;
    padding: 0;
  }

  .neutral-swatch-box {
    width: 100%;
    height: 36px;
    border-radius: 6px;
  }

  .neutral-swatch-text {
    font-size: 0.75rem;
  }
}
