/**
 * Stat Block Image Export Styles
 * Optimized for PNG rendering with html2canvas
 * Classic D&D book aesthetic
 */

/* Hidden container for capture */
.stat-block-export-container {
  position: fixed;
  left: -9999px;
  top: 0;
  z-index: -1;
  pointer-events: none;
}

/* Preview frame shows it inline */
.export-preview-frame .stat-block-export {
  position: relative;
}

.stat-block-export {
  width: 816px; /* Letter width at 96dpi */
  min-height: 400px;
  background:
    /* Subtle vignette */
    radial-gradient(ellipse at center, transparent 50%, rgba(139, 90, 43, 0.15) 100%),
    /* Warm parchment gradient */
    linear-gradient(180deg,
      #FDF5E6 0%,
      #F5E6D3 30%,
      #EBD9C0 70%,
      #E0CCAA 100%
    );
  color: #1A1A1A;
  font-family: 'Spectral', 'Georgia', serif;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  padding: 0;
  box-sizing: border-box;
}

/* Paper texture overlay */
.stat-block-export::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
}

/* Decorative border */
.stat-block-export-border {
  position: absolute;
  inset: 8px;
  border: 2px solid #8B4513;
  border-radius: 2px;
  pointer-events: none;
}

.stat-block-export-border::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(139, 69, 19, 0.3);
}

/* Main content wrapper */
.stat-block-export-content {
  position: relative;
  z-index: 1;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ═══════════════════════════════════════════════════════════
   HEADER WITH MONSTER IMAGE
   ═══════════════════════════════════════════════════════════ */

.export-header {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.export-header-text {
  flex: 1;
  min-width: 0;
}

.export-monster-image {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  border: 3px solid #7A200D;
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 0 20px rgba(0, 0, 0, 0.1);
  background: #E8DBC5;
}

.export-monster-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.export-monster-name {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 36px;
  font-weight: 700;
  color: #7A200D;
  margin: 0 0 4px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.export-monster-meta {
  font-style: italic;
  font-size: 16px;
  color: #333;
  margin: 0;
  line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════
   DECORATIVE DIVIDERS
   ═══════════════════════════════════════════════════════════ */

.export-divider {
  height: 4px;
  background: linear-gradient(90deg,
    #7A200D 0%,
    #C9A227 10%,
    #E6B800 50%,
    #C9A227 90%,
    #7A200D 100%
  );
  margin: 12px 0;
  border-radius: 2px;
}

.export-divider-thin {
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    #922610 20%,
    #922610 80%,
    transparent 100%
  );
  margin: 8px 0;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════
   CORE STATS
   ═══════════════════════════════════════════════════════════ */

.export-core-stats {
  margin-bottom: 8px;
}

.export-core-stats p {
  margin: 2px 0;
  font-size: 14px;
  line-height: 1.4;
}

.export-stat-label {
  font-weight: 700;
  color: #7A200D;
}

/* ═══════════════════════════════════════════════════════════
   ABILITY SCORES
   ═══════════════════════════════════════════════════════════ */

.export-abilities {
  display: flex;
  justify-content: space-between;
  text-align: center;
  padding: 10px 0;
  margin: 8px 0;
  border-top: 1px solid rgba(122, 32, 13, 0.3);
  border-bottom: 1px solid rgba(122, 32, 13, 0.3);
  background: rgba(139, 90, 43, 0.03);
}

.export-ability {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-ability-label {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 11px;
  font-weight: 700;
  color: #7A200D;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.export-ability-score {
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1A;
}

.export-ability-mod {
  font-size: 13px;
  color: #444;
}

/* ═══════════════════════════════════════════════════════════
   PROPERTIES (Saves, Skills, etc.)
   ═══════════════════════════════════════════════════════════ */

.export-properties {
  margin-bottom: 8px;
}

.export-properties p {
  margin: 2px 0;
  font-size: 14px;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   SECTIONS (Traits, Actions, etc.)
   ═══════════════════════════════════════════════════════════ */

.export-section {
  margin-top: 12px;
}

.export-section-title {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 18px;
  font-weight: 400;
  color: #7A200D;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 2px solid #7A200D;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

.export-trait,
.export-action {
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.45;
  text-indent: -0.7em;
  padding-left: 0.7em;
}

.export-trait-name,
.export-action-name {
  font-weight: 700;
  font-style: italic;
}

/* Legendary description */
.export-legendary-desc {
  font-style: normal;
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
}

/* Lair lists */
.export-lair-list {
  margin: 4px 0 8px 20px;
  padding: 0;
  font-size: 14px;
  line-height: 1.45;
}

.export-lair-list li {
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════
   SPELLCASTING
   ═══════════════════════════════════════════════════════════ */

.export-spellcasting {
  margin: 8px 0;
}

.export-spell-intro {
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.45;
}

.export-spell-list {
  margin-left: 16px;
}

.export-spell-level {
  margin: 2px 0;
  font-size: 14px;
  line-height: 1.45;
}

.export-spell-freq {
  font-weight: 600;
  color: #7A200D;
}

.export-spell-name {
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   FOOTER / BRANDING
   ═══════════════════════════════════════════════════════════ */

.export-footer {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid rgba(122, 32, 13, 0.2);
}

.export-cr-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #7A200D 0%, #922610 100%);
  color: #F5E6D3;
  padding: 8px 16px;
  border-radius: 4px;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.export-cr-badge .cr-value {
  font-size: 20px;
  font-weight: 700;
}

.export-branding {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #7A200D;
  font-size: 12px;
  opacity: 0.8;
}

.export-branding-logo {
  width: 24px;
  height: 24px;
}

.export-branding-text {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.export-branding-url {
  font-size: 10px;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════
   LORE/DESCRIPTION SECTION
   ═══════════════════════════════════════════════════════════ */

.export-lore {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(139, 90, 43, 0.05);
  border-left: 3px solid #C9A227;
  font-style: italic;
  font-size: 13px;
  line-height: 1.5;
  color: #444;
}

.export-lore p {
  margin: 0 0 8px;
}

.export-lore p:last-child {
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════════
   TWO-COLUMN LAYOUT FOR COMPLEX CREATURES
   ═══════════════════════════════════════════════════════════ */

.stat-block-export.export-two-column {
  width: 1056px; /* Wider for two columns */
}

.stat-block-export.export-two-column .export-body {
  column-count: 2;
  column-gap: 32px;
  column-rule: 1px solid rgba(122, 32, 13, 0.2);
}

.stat-block-export.export-two-column .export-section,
.stat-block-export.export-two-column .export-properties {
  break-inside: avoid;
}

/* ═══════════════════════════════════════════════════════════
   ENVIRONMENT TAGS
   ═══════════════════════════════════════════════════════════ */

.export-environments {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.export-env-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(122, 32, 13, 0.1);
  border: 1px solid rgba(122, 32, 13, 0.3);
  border-radius: 3px;
  font-size: 11px;
  color: #7A200D;
  text-transform: capitalize;
}

/* ═══════════════════════════════════════════════════════════
   PREVIEW CONTAINER STYLES (for show page)
   ═══════════════════════════════════════════════════════════ */

.export-preview-container {
  padding: var(--qm-space-lg);
}

.export-preview-header {
  text-align: center;
  margin-bottom: var(--qm-space-lg);
}

.export-preview-header h3 {
  font-size: 1.5rem;
  color: var(--qm-gold);
  margin-bottom: var(--qm-space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--qm-space-sm);
}

.export-preview-header p {
  color: var(--qm-text-muted);
  margin: 0;
}

.export-preview-actions {
  display: flex;
  gap: var(--qm-space-sm);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--qm-space-lg);
}

.export-preview-wrapper {
  background: var(--qm-charcoal);
  border-radius: var(--qm-radius-lg);
  padding: var(--qm-space-lg);
  margin-bottom: var(--qm-space-lg);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-preview-frame {
  max-width: 100%;
  overflow: auto;
}

.statblock-image-preview {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--qm-radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.export-preview-placeholder {
  text-align: center;
  padding: var(--qm-space-xl);
  color: var(--qm-text-muted);
}

.export-preview-placeholder .placeholder-icon {
  font-size: 4rem;
  margin-bottom: var(--qm-space-md);
  opacity: 0.5;
}

.export-preview-placeholder p {
  margin-bottom: var(--qm-space-md);
}

.export-preview-info {
  background: rgba(var(--qm-midnight-blue-rgb), 0.5);
  border-radius: var(--qm-radius-md);
  padding: var(--qm-space-md);
  font-size: 0.875rem;
}

.export-preview-info p {
  margin: var(--qm-space-xs) 0;
  color: var(--qm-text-muted);
}

.export-preview-info strong {
  color: var(--qm-gold);
}

/* Loading state for generation */
.export-preview-loading {
  text-align: center;
  padding: var(--qm-space-xl);
}

.export-preview-loading p {
  color: var(--qm-text-muted);
  margin-top: var(--qm-space-md);
}
