/**
 * Print Styles
 * 
 * Optimized styles for printing playing cards and decks
 * Professional print quality at 300 DPI
 * Standard poker card dimensions: 2.5" × 3.5"
 */

@media print {
  /* ============================================
     GLOBAL PRINT SETTINGS
     ============================================ */
  
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  
  body {
    margin: 0;
    padding: 0;
    background: white;
    color: black;
  }
  
  /* Hide non-printable elements */
  nav,
  header,
  footer,
  .no-print,
  .btn,
  .navbar,
  .sidebar {
    display: none !important;
  }
  
  /* Remove shadows and transitions for print */
  *,
  *::before,
  *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    transition: none !important;
    animation: none !important;
  }
  
  /* Prevent page breaks inside elements */
  img,
  pre,
  blockquote,
  table,
  figure {
    page-break-inside: avoid;
  }
  
  /* ============================================
     PLAYING CARD PRINT LAYOUT
     ============================================ */
  
  .print-card {
    width: var(--card-width);
    height: var(--card-height);
    position: relative;
    page-break-inside: avoid;
    page-break-after: always;
    overflow: hidden;
  }
  
  /* Bleed area for professional printing */
  .print-card-with-bleed {
    width: calc(var(--card-width) + 2 * var(--card-bleed));
    height: calc(var(--card-height) + 2 * var(--card-bleed));
    padding: var(--card-bleed);
  }
  
  /* Safe area - keep important content inside */
  .print-card-safe-area {
    position: absolute;
    top: calc(var(--card-bleed) + var(--card-safe-area));
    left: calc(var(--card-bleed) + var(--card-safe-area));
    right: calc(var(--card-bleed) + var(--card-safe-area));
    bottom: calc(var(--card-bleed) + var(--card-safe-area));
  }
  
  /* ============================================
     CARD SHEET LAYOUT (9 cards per page)
     ============================================ */
  
  @page {
    size: letter portrait;
    margin: 0.25in;
  }
  
  .print-sheet {
    width: 8.5in;
    height: 11in;
    display: grid;
    grid-template-columns: repeat(3, var(--card-width));
    grid-template-rows: repeat(3, var(--card-height));
    gap: 0.125in;
    page-break-after: always;
  }
  
  .print-sheet-landscape {
    width: 11in;
    height: 8.5in;
    grid-template-columns: repeat(4, var(--card-width));
    grid-template-rows: repeat(2, var(--card-height));
  }
  
  /* ============================================
     CUT GUIDES AND REGISTRATION MARKS
     ============================================ */
  
  .print-cut-guides {
    position: relative;
  }
  
  .print-cut-guides::before,
  .print-cut-guides::after {
    content: "";
    position: absolute;
    background: black;
  }
  
  /* Horizontal cut guide */
  .print-cut-guides::before {
    width: 0.25in;
    height: 1px;
    top: 0;
    left: -0.125in;
  }
  
  /* Vertical cut guide */
  .print-cut-guides::after {
    width: 1px;
    height: 0.25in;
    top: -0.125in;
    left: 0;
  }
  
  /* Registration marks (corners) */
  .print-registration-mark {
    position: absolute;
    width: 0.125in;
    height: 0.125in;
    border: 1px solid black;
  }
  
  .print-registration-mark.top-left {
    top: -0.25in;
    left: -0.25in;
  }
  
  .print-registration-mark.top-right {
    top: -0.25in;
    right: -0.25in;
  }
  
  .print-registration-mark.bottom-left {
    bottom: -0.25in;
    left: -0.25in;
  }
  
  .print-registration-mark.bottom-right {
    bottom: -0.25in;
    right: -0.25in;
  }
  
  /* ============================================
     CARD FRONT PRINT STYLES
     ============================================ */
  
  .card-front-print {
    width: 100%;
    height: 100%;
    background: white;
    border: 2px solid black;
    border-radius: 0.125in;
    overflow: hidden;
  }
  
  .card-header-print {
    padding: 0.125in;
    font-size: 10pt;
    font-weight: bold;
    border-bottom: 1px solid black;
  }
  
  .card-body-print {
    padding: 0.25in;
  }
  
  .card-ascii-print {
    font-family: 'Courier New', monospace;
    font-size: 4pt;
    line-height: 1;
    white-space: pre;
    text-align: center;
    overflow: hidden;
  }
  
  .card-title-print {
    font-size: 12pt;
    font-weight: bold;
    margin-bottom: 0.1in;
    text-align: center;
  }
  
  .card-code-print {
    font-family: 'Courier New', monospace;
    font-size: 6pt;
    line-height: 1.2;
    white-space: pre-wrap;
    background: #f5f5f5;
    padding: 0.1in;
    border-radius: 0.05in;
  }
  
  /* ============================================
     CARD BACK PRINT STYLES
     ============================================ */
  
  .card-back-print {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid black;
    border-radius: 0.125in;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }
  
  .card-back-pattern {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.1;
    background-image: repeating-linear-gradient(
      45deg,
      transparent,
      transparent 0.125in,
      rgba(255, 255, 255, 0.5) 0.125in,
      rgba(255, 255, 255, 0.5) 0.25in
    );
  }
  
  .card-back-logo {
    position: relative;
    z-index: 1;
    color: white;
    font-size: 18pt;
    font-weight: bold;
    text-align: center;
  }
  
  /* ============================================
     QR CODE PRINT STYLES
     ============================================ */
  
  .qr-code-print {
    width: 0.75in;
    height: 0.75in;
    background: white;
    padding: 0.05in;
    border: 1px solid black;
    border-radius: 0.05in;
  }
  
  .qr-code-print img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }
  
  /* ============================================
     PLAYING CARD SUITS
     ============================================ */
  
  .suit-spade::before { content: "♠"; color: black; }
  .suit-heart::before { content: "♥"; color: #dc143c; }
  .suit-diamond::before { content: "♦"; color: #dc143c; }
  .suit-club::before { content: "♣"; color: black; }
  
  .suit-icon {
    font-size: 14pt;
    line-height: 1;
  }
  
  /* ============================================
     DECK SHEET LAYOUT
     ============================================ */
  
  .deck-sheet-print {
    page-break-after: always;
  }
  
  .deck-sheet-front {
    /* Front side of cards */
  }
  
  .deck-sheet-back {
    /* Back side of cards - needs to be mirrored for duplex printing */
    transform: scaleX(-1);
  }
  
  /* ============================================
     ALIGNMENT GUIDES FOR DUPLEX PRINTING
     ============================================ */
  
  .duplex-alignment-mark {
    position: absolute;
    width: 0.0625in;
    height: 0.0625in;
    background: black;
    border-radius: 50%;
  }
  
  .duplex-alignment-mark.top {
    top: 0.125in;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .duplex-alignment-mark.bottom {
    bottom: 0.125in;
    left: 50%;
    transform: translateX(-50%);
  }
  
  /* ============================================
     PRINT QUALITY SETTINGS
     ============================================ */
  
  .high-quality-print {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
  
  /* Force high quality for images and QR codes */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
  
  /* ============================================
     TEXT OPTIMIZATION FOR PRINT
     ============================================ */
  
  .print-text {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* Ensure black text is pure black for printing */
  .print-text-black {
    color: #000000 !important;
  }
  
  /* ============================================
     LINKS FOR PRINT
     ============================================ */
  
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
  }
  
  /* Don't show URLs for anchor links or javascript */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }
  
  /* ============================================
     TABLE PRINT STYLES
     ============================================ */
  
  table {
    border-collapse: collapse;
    width: 100%;
  }
  
  thead {
    display: table-header-group;
  }
  
  tr {
    page-break-inside: avoid;
  }
  
  th, td {
    border: 1px solid #000;
    padding: 0.1in;
  }
  
  /* ============================================
     UTILITY CLASSES FOR PRINT
     ============================================ */
  
  .page-break {
    page-break-after: always;
  }
  
  .page-break-before {
    page-break-before: always;
  }
  
  .avoid-break {
    page-break-inside: avoid;
  }
  
  .print-only {
    display: block !important;
  }
  
  .screen-only {
    display: none !important;
  }
}

/* ============================================
   PRINT PREVIEW MODE (for screen)
   ============================================ */

.print-preview-mode {
  background: #ddd;
  padding: 1in;
}

.print-preview-mode .print-card {
  width: var(--card-width);
  height: var(--card-height);
  background: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5in;
}

.print-preview-mode .print-sheet {
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.25in;
  margin-bottom: 1in;
}
