/* Due Draghi Emporium - Encounters Calculator Styles */
/* Extends site.css with calculator-specific styles */

/* Page title styling */
.page-title {
  font-size: 2.5rem;
  margin: 2rem 0;
  text-align: center;
  font-weight: 700;
  color: var(--bittersweet-shimmer);
  border-bottom: 2px solid var(--bittersweet-shimmer);
  padding-bottom: 1rem;
}

@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
}

/* Minimal logo styling */
.minimal-logo {
  font-size: 2rem;
  text-align: center;
  color: var(--bittersweet-shimmer);
  padding: 1rem 0;
}

/* Site banner styling */
.site-banner {
  background: linear-gradient(135deg, var(--celestial-blue), var(--bittersweet-shimmer));
  color: white;
  text-align: center;
  padding: 2rem;
  margin: 3rem 0 0 0;
  border-radius: 1rem;
  box-shadow: 0 8px 25px rgba(36, 147, 208, 0.15);
}

.site-banner p {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.site-banner p:last-child {
  margin-bottom: 0;
  opacity: 0.9;
  font-size: 1rem;
}

.site-banner a {
  color: white;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  transition: border-color 0.3s ease;
}

.site-banner a:hover {
  border-bottom-color: white;
}

/* Info tiles compact grid */
.info-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin: 2rem 0;
}

@media (max-width: 768px) {
  .info-tiles {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.info-tiles .tile {
  background: var(--surface-color);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(36, 147, 208, 0.1);
}

.info-tiles .tile:hover {
  border-color: var(--celestial-blue);
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(36, 147, 208, 0.2);
}

.info-tiles .tile h3 {
  color: var(--celestial-blue);
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.info-tiles .tile p {
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.95rem;
}

/* Elegant description styling */
.elegant-description {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  padding: 2rem;
  margin: 2rem 0;
  border: 1px solid var(--border-color);
}

.elegant-description h3 {
  color: var(--celestial-blue);
  font-size: 1.4rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.elegant-description p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

.elegant-description em {
  color: var(--text-secondary);
  font-style: italic;
}

/* Calculator layout */
.calculator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin: 3rem 0;
  align-items: start;
}

@media (max-width: 1024px) {
  .calculator-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

/* Form panels */
.form-panel {
  background: var(--surface-color);
  border-radius: 1.5rem;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(36, 147, 208, 0.1);
}

.form-panel:hover {
  border-color: var(--celestial-blue);
  transform: translateY(-2px);
}

.form-panel h2 {
  color: var(--bittersweet-shimmer);
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  border-bottom: 2px solid var(--bittersweet-shimmer);
  padding-bottom: 0.5rem;
}

/* Radio group styling */
.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.75rem 1.5rem;
  border-radius: 2rem;
  background: var(--background-color);
  border: 2px solid var(--border-color);
  transition: all 0.3s ease;
  font-weight: 500;
}

.radio-option:hover {
  border-color: var(--celestial-blue);
  background: rgba(36, 147, 208, 0.05);
}

.radio-option input[type="radio"]:checked + span {
  color: var(--bittersweet-shimmer);
  font-weight: 600;
}

.radio-option:has(input[type="radio"]:checked) {
  border-color: var(--bittersweet-shimmer);
  background: rgba(207, 76, 86, 0.05);
}

.radio-option input[type="radio"] {
  accent-color: var(--bittersweet-shimmer);
}

/* Party configuration */
.party-config {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Form actions */
.form-actions {
  text-align: center;
  padding: 2rem 0;
}

/* Calculator results - sticky within its container */
.calculator-results {
  position: sticky;
  top: 1rem;
  z-index: 100;
  max-height: calc(100vh - 2rem);
  align-self: flex-start;
}

/* Enhanced result visibility */
#result-content {
  transition: all 0.3s ease;
}

#result-content .result-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
  border-radius: 1.5rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Enhanced styling only when result is active */
#result-content .result-card.success {
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid var(--celestial-blue);
  box-shadow:
    0 8px 32px rgba(36, 147, 208, 0.25),
    0 4px 16px rgba(0, 0, 0, 0.1);
}

/* Result card content styling */
.result-card h3 {
  margin: 0 0 1rem 0;
  color: var(--primary-color);
  font-size: 1.25rem;
  text-align: center;
}

.result-card .xp-display {
  background: rgba(36, 147, 208, 0.1);
  padding: 1rem;
  border-radius: 0.75rem;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
}

.result-card .encounter-details {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.result-card .encounter-details p {
  margin: 0.5rem 0;
  word-break: break-word;
}

.result-card .difficulty-display {
  background: rgba(207, 76, 86, 0.1);
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin-top: 0.75rem;
}

.result-card .usage-tips {
  background: rgba(104, 181, 74, 0.1);
  padding: 1rem;
  border-radius: 0.75rem;
  border-left: 4px solid var(--reseda-green);
}

.result-card .usage-tips h4 {
  margin: 0 0 0.75rem 0;
  color: var(--reseda-green);
  font-size: 1rem;
}

.result-card .usage-tips ul {
  margin: 0;
  padding-left: 1.25rem;
}

.result-card .usage-tips li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

/* Indicator that results are sticky */
.result-card.sticky-active::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  height: 4px;
  background: linear-gradient(90deg, var(--celestial-blue), var(--bittersweet-shimmer));
  border-radius: 1.5rem 1.5rem 0 0;
}

/* Visual hint for sticky behavior */
.calculator-results::after {
  content: "📌 Risultato sempre visibile durante lo scorrimento";
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.5rem;
  margin-top: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.calculator-results:has(.result-card)::after {
  opacity: 1;
}

/* Dark mode support for sticky results */
@media (prefers-color-scheme: dark) {
  #result-content .result-card {
    background: rgba(18, 18, 18, 0.95);
    border-color: var(--celestial-blue);
  }
}

/* Mobile: disable sticky behavior */
@media (max-width: 1024px) {
  .calculator-results {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  #result-content .result-card {
    position: static;
    backdrop-filter: none;
    background: var(--surface-color);
    box-shadow: none;
  }

  #result-content .result-card.success {
    box-shadow: 0 4px 15px rgba(36, 147, 208, 0.1);
  }

  .result-card.sticky-active::before {
    display: none;
  }

  .calculator-results::after {
    display: none;
  }
}

.result-placeholder {
  background: var(--surface-color);
  border-radius: 1.5rem;
  padding: 3rem;
  text-align: center;
  border: 2px dashed var(--border-color);
  transition: all 0.3s ease;
}

.result-placeholder h3 {
  color: var(--celestial-blue);
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.result-placeholder p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Calculator-specific form styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 500;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--background-color);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--shadow-color);
}

/* Difficulty colors */
.difficulty-trivial {
  color: var(--reseda-green);
  font-weight: 600;
}

.difficulty-easy {
  color: var(--celestial-blue);
  font-weight: 600;
}

.difficulty-medium {
  color: var(--earth-yellow);
  font-weight: 600;
}

.difficulty-hard {
  color: var(--butterscotch);
  font-weight: 600;
}

.difficulty-deadly {
  color: var(--bittersweet-shimmer);
  font-weight: 600;
}

/* Calculator result styles */
.result-card {
  background: var(--surface-color);
  border: 2px solid var(--primary-color);
  box-shadow: 0 8px 32px var(--shadow-color);
}

.xp-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 1rem 0;
}

.difficulty-display {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.5rem 0;
}

/* Party configuration styles */
.party-member {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: var(--surface-color);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.party-member-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

/* Monster configuration styles */
.monster-group {
  background: var(--surface-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

.monster-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.cr-display {
  font-weight: 600;
  color: var(--primary-color);
}

/* Loading states and feedback */
.loading-spinner {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(36, 147, 208, 0.05);
  border-radius: 0.75rem;
  border: 1px dashed var(--celestial-blue);
  margin-top: 1rem;
  animation: fadeIn 0.3s ease;
}

.loading-spinner.htmx-request {
  display: flex;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top: 2px solid var(--celestial-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Enhanced button states */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-loading {
  display: none;
}

.btn.htmx-request .btn-text {
  display: none;
}

.btn.htmx-request .btn-loading {
  display: inline;
}

.btn.htmx-request {
  opacity: 0.8;
  cursor: not-allowed;
  transform: scale(0.98);
}

/* Result animations */
.result-card {
  animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form help and validation styles */
.form-help {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.ruleset-desc {
  display: none;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  padding-left: 0.75rem;
  margin-left: 0.5rem;
  transition: all 0.3s ease;
}

.ruleset-desc.active {
  display: block;
  border-left-color: var(--celestial-blue);
  color: var(--text-primary);
  background: rgba(36, 147, 208, 0.05);
  border-radius: 0 0.5rem 0.5rem 0;
}

/* Form validation styles */
.form-input:invalid {
  border-color: var(--bittersweet-shimmer);
  box-shadow: 0 0 0 3px rgba(207, 76, 86, 0.1);
}

.form-input:valid {
  border-color: var(--reseda-green);
}

.form-group.has-error .form-input {
  border-color: var(--bittersweet-shimmer);
  background-color: rgba(207, 76, 86, 0.05);
}

.form-error {
  color: var(--bittersweet-shimmer);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: none;
}

.form-group.has-error .form-error {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* Enhanced hover and focus states */
.form-panel {
  transition: all 0.3s ease;
}

.form-panel:focus-within {
  border-color: var(--celestial-blue);
  box-shadow: 0 0 0 3px rgba(36, 147, 208, 0.1);
  transform: translateY(-1px);
}

.radio-option {
  transition: all 0.2s ease;
}

.radio-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(36, 147, 208, 0.15);
}

/* Success states */
.result-card.success {
  border: 2px solid var(--reseda-green);
  box-shadow: 0 0 0 3px rgba(104, 181, 74, 0.1);
}

/* Touch improvements for mobile */
@media (hover: none) and (pointer: coarse) {
  .radio-option {
    min-height: 48px;
    padding: 1rem 1.5rem;
  }

  .form-input, .form-select {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .btn {
    min-height: 48px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
  }
}

/* Calculator-specific responsive adjustments */
@media (max-width: 768px) {
  .party-member {
    flex-direction: column;
    gap: 0.75rem;
  }

  .monster-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .party-member-controls {
    justify-content: center;
  }
}