/*!
 * Math Lesson CSS for Cocoon WordPress Theme
 * 和差算解説ページ専用スタイル
 * Version: 1.0.0
 */

/* ==========================================================================
   CSS Variables - Cocoon Theme Integration
   ========================================================================== */
:root {
  /* Cocoon theme color integration */
  --cocoon-primary: #3498db;
  --cocoon-secondary: #2ecc71;
  --cocoon-accent: #e74c3c;
  --cocoon-text: #333333;
  --cocoon-text-light: #666666;
  --cocoon-bg: #ffffff;
  --cocoon-bg-light: #f8f9fa;
  --cocoon-border: #dee2e6;
  
  /* Math lesson specific colors */
  --math-primary: #4a90e2;
  --math-secondary: #7ed321;
  --math-warning: #f5a623;
  --math-danger: #d0021b;
  --math-success: #50e3c2;
  
  /* Typography */
  --font-family-math: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --line-height-base: 1.6;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;
  
  /* Border radius */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
.wasazan-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  font-family: var(--font-family-math);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--cocoon-text);
  background-color: var(--cocoon-bg);
}

.wasazan-container * {
  box-sizing: border-box;
}

/* ==========================================================================
   Problem Box Component
   ========================================================================== */
.problem-box {
  background: linear-gradient(135deg, var(--cocoon-bg-light) 0%, #ffffff 100%);
  border: 2px solid var(--math-primary);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.problem-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--math-primary) 0%, var(--math-secondary) 100%);
}

.problem-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-normal);
}

/* Problem Title */
.problem-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--math-primary);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--cocoon-border);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.problem-title::before {
  content: '📝';
  font-size: 1.2em;
}

/* Problem Content */
.problem-content {
  font-size: var(--font-size-lg);
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md);
  background-color: rgba(74, 144, 226, 0.05);
  border-radius: var(--border-radius-md);
  border-left: 4px solid var(--math-primary);
}

/* ==========================================================================
   Calculation Steps Component
   ========================================================================== */
.calculation-steps {
  background-color: var(--cocoon-bg);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  margin: var(--spacing-xl) 0;
  border: 1px solid var(--cocoon-border);
}

.calculation-steps-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--math-secondary);
  margin-bottom: var(--spacing-lg);
  text-align: center;
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--math-secondary);
}

.calculation-steps-title::before {
  content: '🔢 ';
}

/* Individual Step */
.step {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md);
  background-color: var(--cocoon-bg-light);
  border-radius: var(--border-radius-md);
  border-left: 4px solid var(--math-secondary);
  transition: all var(--transition-fast);
}

.step:hover {
  background-color: rgba(126, 211, 33, 0.1);
  transform: translateX(4px);
}

.step:last-child {
  margin-bottom: 0;
}

/* Step Number */
.step-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--math-secondary) 0%, #5cb85c 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

/* Step Content */
.step-content {
  flex: 1;
  font-size: var(--font-size-base);
  line-height: 1.7;
}

.step-description {
  margin-bottom: var(--spacing-sm);
  color: var(--cocoon-text);
}

.step-calculation {
  font-family: 'Courier New', monospace;
  background-color: var(--cocoon-bg);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--cocoon-border);
  font-size: var(--font-size-base);
  margin: var(--spacing-sm) 0;
}

/* ==========================================================================
   Visual Elements
   ========================================================================== */
.visual-element {
  background-color: var(--cocoon-bg-light);
  border: 2px dashed var(--math-primary);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  margin: var(--spacing-xl) 0;
  text-align: center;
  position: relative;
}

.visual-element::before {
  content: '👁️';
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  font-size: 1.2em;
}

/* Diagram Container */
.diagram-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-lg);
  margin: var(--spacing-lg) 0;
  flex-wrap: wrap;
}

.diagram-box {
  background: linear-gradient(135deg, #ffffff 0%, var(--cocoon-bg-light) 100%);
  border: 2px solid var(--math-primary);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-lg);
  min-width: 120px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.diagram-box:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.diagram-label {
  font-weight: 600;
  color: var(--math-primary);
  margin-bottom: var(--spacing-sm);
  font-size: 14px;
}

.diagram-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--cocoon-text);
}

/* ==========================================================================
   Answer Box Component
   ========================================================================== */
.answer-box {
  background: linear-gradient(135deg, var(--math-success) 0%, #4dd0e1 100%);
  color: white;
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  margin: var(--spacing-xl) 0;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.answer-box::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.answer-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.answer-title::before {
  content: '✅';
  font-size: 1.3em;
}

.answer-value {
  font-size: 2.5rem;
  font-weight: 800;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  margin-bottom: var(--spacing-sm);
}

.answer-explanation {
  font-size: var(--font-size-base);
  opacity: 0.9;
  line-height: 1.6;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--spacing-xs) !important; }
.mb-2 { margin-bottom: var(--spacing-sm) !important; }
.mb-3 { margin-bottom: var(--spacing-md) !important; }
.mb-4 { margin-bottom: var(--spacing-lg) !important; }

.font-weight-bold { font-weight: 700; }
.font-weight-normal { font-weight: 400; }

.text-primary { color: var(--math-primary) !important; }
.text-secondary { color: var(--math-secondary) !important; }
.text-success { color: var(--math-success) !important; }
.text-warning { color: var(--math-warning) !important; }
.text-danger { color: var(--math-danger) !important; }

/* Highlight Classes */
.highlight-blue {
  background-color: rgba(74, 144, 226, 0.2);
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  color: var(--math-primary);
  font-weight: 600;
}

.highlight-green {
  background-color: rgba(126, 211, 33, 0.2);
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  color: var(--math-secondary);
  font-weight: 600;
}

.highlight-yellow {
  background-color: rgba(245, 166, 35, 0.2);
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  color: var(--math-warning);
  font-weight: 600;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
  .wasazan-container {
    padding: var(--spacing-md);
  }
  
  .problem-box,
  .calculation-steps {
    padding: var(--spacing-md);
  }
  
  .problem-title {
    font-size: var(--font-size-lg);
  }
  
  .step {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .step-number {
    align-self: flex-start;
  }
  
  .diagram-container {
    flex-direction: column;
  }
  
  .answer-value {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .wasazan-container {
    padding: var(--spacing-sm);
  }
  
  .problem-title {
    font-size: var(--font-size-base);
    flex-direction: column;
    text-align: center;
  }
  
  .answer-value {
    font-size: 1.5rem;
  }
  
  .diagram-box {
    min-width: 100px;
    padding: var(--spacing-md);
  }
}

/* ==========================================================================
   Accessibility Features
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for keyboard navigation */
.step:focus-within,
.problem-box:focus-within,
.answer-box:focus-within {
  outline: 2px solid var(--math-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .problem-box,
  .calculation-steps,
  .visual-element {
    border-width: 3px;
  }
  
  .step-number {
    border: 2px solid currentColor;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  .wasazan-container {
    max-width: none;
    padding: 0;
    color: black;
    background: white;
  }
  
  .problem-box,
  .calculation-steps,
  .visual-element,
  .answer-box {
    box-shadow: none;
    border: 2px solid black;
    background: white;
    break-inside: avoid;
  }
  
  .step:hover,
  .problem-box:hover,
  .diagram-box:hover {
    transform: none;
  }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */
.problem-box,
.calculation-steps,
.visual-element,
.answer-box {
  contain: layout style;
}

.step-number {
  will-change: transform;
}

/* Font loading optimization */
@font-face {
  font-family: 'Noto Sans JP';
  font-display: swap;
}