/*
 * QuickMonster D&D Stat Block Component
 */

/* ========================================
   STAT BLOCK CONTAINER
   ======================================== */

.stat-block {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(139, 90, 43, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 90, 43, 0.06) 0%, transparent 50%),
    linear-gradient(180deg,
      #FDF1DC 0%,
      #F0E6D2 50%,
      #E8DBC5 100%
    );
  color: #1A1A1A;
  border: none;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  max-width: 420px;
  position: relative;
  font-family: var(--qm-font-body);
  font-size: 0.875rem;
  line-height: 1.3;
  overflow: hidden;
}

/* Classic D&D top/bottom decorative bars */
.stat-block::before,
.stat-block::after {
  content: '';
  display: block;
  height: 5px;
  background: linear-gradient(90deg,
    #7A200D 0%,
    #E69A28 15%,
    #E69A28 85%,
    #7A200D 100%
  );
}

/* Subtle paper texture overlay */
.stat-block > .stat-block-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
}

/* ========================================
   STAT BLOCK HEADER
   ======================================== */

.stat-block-header {
  padding: 0.6rem 0.6rem 0.3rem;
  background: transparent;
  position: relative;
  border-bottom: 2px solid #922610;
}

.stat-block-name {
  font-family: var(--qm-font-display);
  font-size: 1.5rem;
  color: #7A200D;
  margin: 0;
  letter-spacing: 0.01em;
  line-height: 1.1;
  font-weight: 700;
}

.stat-block-meta {
  font-style: italic;
  font-size: 0.85rem;
  color: #1A1A1A;
  margin: 0.15rem 0 0;
  line-height: 1.2;
}

/* Header with Image */
.stat-block-header-with-image {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.stat-block-image {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 2px;
  overflow: hidden;
  border: 2px solid #7A200D;
  background: #E8DBC5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.stat-block-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stat-block-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(122, 32, 13, 0.15) 0%, rgba(122, 32, 13, 0.08) 100%);
}

.stat-block-image-placeholder::before {
  content: '';
  width: 24px;
  height: 24px;
  background: #7A200D;
  opacity: 0.4;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z'/%3E%3C/svg%3E");
  mask-size: contain;
  -webkit-mask-size: contain;
}

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

/* Size-based image scaling */
.stat-block-sm .stat-block-image {
  width: 40px;
  height: 40px;
}

.stat-block-lg .stat-block-image {
  width: 60px;
  height: 60px;
}

/* Dark variant image styles */
.stat-block-dark .stat-block-image {
  border-color: var(--qm-gold);
  background: #1A1A1A;
}

.stat-block-dark .stat-block-image-placeholder {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(212, 175, 55, 0.1) 100%);
}

.stat-block-dark .stat-block-image-placeholder::before {
  background: var(--qm-gold);
}

/* ========================================
   STAT BLOCK DIVIDERS - Classic D&D orange/tan tapered
   ======================================== */

.stat-block-divider {
  height: 0;
  border: none;
  margin: 0;
  /* Use SVG for tapered line effect */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 6'%3E%3Cpath d='M0,3 Q100,0 200,3 Q300,6 400,3' stroke='%23922610' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat center;
  background-size: 100% 4px;
  height: 6px;
  margin: 0.3rem 0;
  opacity: 0.8;
}

.stat-block-divider-thin {
  height: 1px;
  background: #922610;
  margin: 0.2rem 0;
  opacity: 0.4;
}

/* ========================================
   STAT BLOCK CONTENT
   ======================================== */

.stat-block-content {
  padding: 0.5rem 0.6rem 0.6rem;
  position: relative;
}

/* Core Stats (AC, HP, Speed) */
.stat-block-core {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.stat-block-core p {
  margin: 0.1rem 0;
  font-size: 0.9rem;
  line-height: 1.35;
}

.stat-label {
  font-weight: 700;
  color: #7A200D;
  margin-right: 0.25rem;
}

/* ========================================
   ABILITY SCORES - Classic table style
   ======================================== */

.ability-scores {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  text-align: center;
  padding: 0.4rem 0;
  margin: 0.3rem 0;
  border-top: 1px solid rgba(122, 32, 13, 0.3);
  border-bottom: 1px solid rgba(122, 32, 13, 0.3);
}

.ability-score {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.ability-score-label {
  font-family: var(--qm-font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  color: #7A200D;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.ability-score-value {
  font-size: 0.9rem;
  font-weight: 400;
  color: #1A1A1A;
  line-height: 1.1;
}

.ability-score-modifier {
  font-size: 0.8rem;
  color: #1A1A1A;
  line-height: 1.2;
}

/* ========================================
   PROPERTIES & TRAITS
   ======================================== */

.stat-block-properties {
  margin: 0.3rem 0;
  padding: 0;
  border-bottom: none;
}

.stat-block-properties p {
  margin: 0.1rem 0;
  font-size: 0.9rem;
  line-height: 1.35;
}

.stat-block-section {
  margin: 0;
}

.stat-block-section:last-child {
  margin-bottom: 0;
}

.stat-block-section-title {
  font-family: var(--qm-font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: #7A200D;
  margin: 0.6rem 0 0.25rem;
  border-bottom: 1px solid #7A200D;
  padding-bottom: 0.15rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

/* Traits */
.trait {
  margin: 0.35rem 0;
  font-size: 0.9rem;
  line-height: 1.4;
  text-indent: -0.6rem;
  padding-left: 0.6rem;
}

.trait-name {
  font-weight: 700;
  font-style: italic;
  color: #1A1A1A;
}

/* Actions */
.action {
  margin: 0.35rem 0;
  font-size: 0.9rem;
  line-height: 1.4;
  text-indent: -0.6rem;
  padding-left: 0.6rem;
}

.action-name {
  font-weight: 700;
  font-style: italic;
  color: #1A1A1A;
}

.action-type {
  font-size: 0.85rem;
  color: #1A1A1A;
}

/* ========================================
   SPELLCASTING
   ======================================== */

.stat-block-spellcasting {
  background: transparent;
  margin: 0.4rem 0 0;
  padding: 0;
  border: none;
}

.stat-block-spellcasting + .stat-block-spellcasting {
  margin-top: 0;
  padding-top: 0;
}

.spellcasting-intro {
  margin-bottom: 0.2rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.spell-list {
  margin-left: 0.75rem;
  margin-top: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.spell-level {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25em;
  font-size: 0.875rem;
  line-height: 1.4;
  padding: 0;
  border-bottom: none;
}

.spell-frequency {
  font-weight: 600;
  color: #7A200D;
  min-width: 110px;
  flex-shrink: 0;
}

.spell-names {
  flex: 1;
}

.spell-name {
  font-style: italic;
  color: #1A1A1A;
}

.spell-separator {
  color: #1A1A1A;
}

/* Unified spell frequency colors */
.freq-cantrips .spell-frequency,
.freq-at-will .spell-frequency,
.freq-per-day .spell-frequency,
.freq-slot .spell-frequency {
  color: #7A200D;
}

/* Psionic styling */
.stat-block-spellcasting[data-type="psionic"] {
  background: transparent;
}

.stat-block-spellcasting[data-type="psionic"] .spell-frequency {
  color: #7A200D;
}

/* Dark theme spellcasting */
.stat-block-dark .stat-block-spellcasting {
  background: transparent;
}

.stat-block-dark .spell-frequency {
  color: var(--qm-gold);
}

.stat-block-dark .spell-name {
  color: var(--qm-parchment);
}

/* ========================================
   LEGENDARY ACTIONS
   ======================================== */

.legendary-description {
  font-style: normal;
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ========================================
   LAIR & REGIONAL EFFECTS
   ======================================== */

.lair-action-list,
.regional-effect-list {
  margin: 0.2rem 0 0.3rem 1rem;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.lair-action-list li,
.regional-effect-list li {
  margin-bottom: 0.2rem;
}


/* ========================================
   STAT BLOCK SIZES
   ======================================== */

.stat-block-sm {
  max-width: 350px;
  font-size: 0.8rem;
}

.stat-block-sm .stat-block-name {
  font-size: 1.2rem;
}

.stat-block-lg {
  max-width: 520px;
}

.stat-block-lg .stat-block-name {
  font-size: 1.6rem;
}

/* Two-column stat block for large creatures */
.stat-block-two-column {
  max-width: 800px;
}

.stat-block-two-column .stat-block-content {
  column-count: 2;
  column-gap: 1rem;
  column-rule: 2px solid #E69A28;
}

.stat-block-two-column .stat-block-section,
.stat-block-two-column .stat-block-description,
.stat-block-two-column .stat-block-footer {
  break-inside: avoid;
}

/* ========================================
   DARK STAT BLOCK
   ======================================== */

.stat-block-dark {
  background:
    linear-gradient(180deg,
      #2A2520 0%,
      #1E1A18 50%,
      #151210 100%
    );
  color: #E8DBC5;
}

.stat-block-dark::before,
.stat-block-dark::after {
  background: linear-gradient(90deg,
    #4A3728 0%,
    #D4AF37 15%,
    #D4AF37 85%,
    #4A3728 100%
  );
}

.stat-block-dark .stat-block-header {
  background: transparent;
  border-bottom-color: #D4AF37;
}

.stat-block-dark .stat-block-name {
  color: #D4AF37;
}

.stat-block-dark .stat-block-meta {
  color: #E8DBC5;
}

.stat-block-dark .stat-label,
.stat-block-dark .ability-score-label,
.stat-block-dark .stat-block-section-title {
  color: #D4AF37;
}

.stat-block-dark .stat-block-section-title {
  border-bottom-color: #D4AF37;
}

.stat-block-dark .stat-block-divider {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 6'%3E%3Cpath d='M0,3 Q100,0 200,3 Q300,6 400,3' stroke='%23D4AF37' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat center;
  background-size: 100% 4px;
}

.stat-block-dark .ability-scores {
  border-color: rgba(212, 175, 55, 0.3);
}

.stat-block-dark .ability-score-value,
.stat-block-dark .ability-score-modifier,
.stat-block-dark .action-name,
.stat-block-dark .trait-name {
  color: #E8DBC5;
}

.stat-block-dark .stat-block-image {
  border-color: #D4AF37;
}

/* ========================================
   DESCRIPTION / LORE
   ======================================== */

.stat-block-description {
  background: transparent;
  margin: 0.4rem 0 0;
  padding: 0;
  border-top: none;
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #444;
}

.stat-block-description p {
  margin: 0 0 0.3rem;
}

.stat-block-description p:last-child {
  margin-bottom: 0;
}

.stat-block-dark .stat-block-description {
  background: transparent;
  color: var(--qm-parchment);
  opacity: 0.85;
}

/* ========================================
   FOOTER (Environment, Source)
   ======================================== */

.stat-block-footer {
  background: transparent;
  margin: 0.2rem 0 0;
  padding: 0;
  border-top: none;
  font-size: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: #666;
}

.stat-block-footer-item {
  margin: 0;
}

.stat-block-footer .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #7A200D;
}

.stat-block-source {
  margin-left: auto;
  opacity: 0.7;
  font-style: italic;
}

.stat-block-dark .stat-block-footer {
  background: transparent;
  color: var(--qm-parchment);
  opacity: 0.7;
}

.stat-block-dark .stat-block-footer .stat-label {
  color: var(--qm-gold);
}

/* ========================================
   DICE ROLL HIGHLIGHTING
   ======================================== */

.dice-roll {
  color: #4a90d9;
  cursor: default;
  font-weight: 600;
}

.stat-block-dark .dice-roll {
  color: #6db3f2;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
  .stat-block {
    max-width: 100%;
    font-size: 0.8rem;
  }

  .stat-block-header,
  .stat-block-content {
    padding: 0.4rem 0.5rem;
  }

  .stat-block-name {
    font-size: 1.2rem;
  }

  .ability-scores {
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
  }

  .ability-score-label {
    font-size: 0.6rem;
  }

  .ability-score-value {
    font-size: 0.75rem;
  }

  .ability-score-modifier {
    font-size: 0.65rem;
  }

  .stat-block-two-column .stat-block-content {
    column-count: 1;
  }
}
