/* === MATHEMATICS STYLES === */

/* Math Figure Container */
.math-figure {
  margin: var(--space-xl) auto;
  text-align: center;
  max-width: 100%;
}

.math-figure img {
  max-width: 100%;
  height: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.math-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-style: italic;
  text-align: center;
}

/* Equation Figure Styling */
.equation-figure {
  margin: 1.5rem 0;
  text-align: center;
  padding: 2rem;
  background-color: var(--color-bg);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.equation-figure img {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background-color: var(--color-bg);
  padding: 1.5rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.equation-figure figcaption {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-style: italic;
  text-align: center;
  line-height: 1.4;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Graph Styling */
.graph-block {
  margin: 1.5rem 0;
  text-align: center;
}

.graph-figure {
  margin: 1.5rem 0;
  text-align: center;
  padding: 2rem;
  background-color: var(--color-bg);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.graph-image {
  max-width: 100%;
  height: auto;
  background-color: var(--color-bg);
  padding: 1.5rem;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.graph-figure figcaption {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-style: italic;
  text-align: center;
  line-height: 1.4;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Math Equations */
.math-equation {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: var(--space-lg) 0;
  padding: var(--space-lg);
  background-color: var(--color-bg);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.math-equation img {
  width: 60%;
  max-width: 60%;
  height: auto;
  display: block;
  margin: 0 auto;
  background-color: var(--color-bg);
  padding: 1rem;
  border-radius: 4px;
  min-height: 80px;
}

/* Math Figure Container */
.math-figure {
  margin: var(--space-xl) auto;
  text-align: center;
  max-width: 80%;
  background-color: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.math-figure img {
  width: 80%;
  height: auto;
  background-color: var(--color-bg);
  min-height: 200px;
}

/* Math Blocks for Special Sections */
.math-block {
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
}

.math-block__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.math-block__title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-accent);
}

.math-block__icon {
  font-size: var(--font-size-xl);
  color: var(--color-accent);
}

/* Specific Math Block Types */
.math-block--definition {
  border-left-color: var(--color-blue-500);
  background-color: var(--color-blue-50);
}

.math-block--theorem {
  border-left-color: var(--color-success);
  background-color: #f0fdf4;
}

.math-block--proof {
  border-left-color: var(--color-warning);
  background-color: #fffbeb;
}

.math-block--example {
  border-left-color: var(--color-blue-600);
  background-color: var(--color-blue-50);
}

.math-block--warning {
  border-left-color: var(--color-error);
  background-color: #fef2f2;
}

/* Proof End Symbol */
.proof-end {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-md);
  font-size: var(--font-size-xl);
  color: var(--color-accent);
}

.proof-end::after {
  content: '∎';
  background: var(--color-accent);
  color: white;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-weight: bold;
}

/* Math Steps */
.math-steps {
  list-style: none;
  padding: 0;
  counter-reset: step-counter;
}

.math-steps li {
  counter-increment: step-counter;
  position: relative;
  padding-left: var(--space-xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  line-height: 1.6;
  font-size: var(--font-size-md);
}

.math-steps li ul {
    margin-top: 25px;
}

.math-steps li ul li {
    list-style: none;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--space-sm);
}

.math-steps li:last-child {
  border-bottom: none;
}

.math-steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  background-color: var(--color-accent);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Function Table */
.function-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  background-color: var(--color-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.function-table th,
.function-table td {
  padding: var(--space-md);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

.function-table th {
  background-color: var(--color-accent);
  color: white;
  font-weight: 600;
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.function-table tbody tr:nth-child(even) {
  background-color: var(--color-bg-alt);
}

.function-table tbody tr:hover {
  background-color: var(--color-blue-50);
}

.function-table .math-cell {
  width: 200px;
}

.function-table .math-cell img {
  max-width: 100%;
  height: auto;
  max-height: 40px;
}

.function-table .comment-cell {
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Math Lightbox */
.math-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--space-lg);
}

.math-lightbox--active {
  display: flex;
}

.math-lightbox__content {
  background-color: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.math-lightbox__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  line-height: 1;
}

.math-lightbox__close:hover {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
}

.math-lightbox__image {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.math-lightbox__image img {
  max-width: 100%;
  max-height: 60vh;
  height: auto;
}

.math-lightbox__info {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-lg);
}

.math-lightbox__latex {
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: 'Courier New', monospace;
  font-size: var(--font-size-sm);
  word-break: break-all;
  margin: var(--space-md) 0;
}

.math-lightbox__copy {
  background-color: var(--color-accent);
  color: white;
  border: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  cursor: pointer;
  float: right;
  margin-top: -40px;
  margin-right: var(--space-sm);
}

.math-lightbox__copy:hover {
  background-color: var(--color-blue-700);
}

/* Exercise Section */
.exercises {
  background-color: var(--color-bg-alt);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin: var(--space-2xl) 0;
  border-left: 4px solid var(--color-accent);
}

.exercises__title {
  color: var(--color-accent);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.exercises__title::before {
  content: '✏️';
  font-size: var(--font-size-xl);
}

.exercise {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.exercise:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.exercise__question {
  font-weight: 500;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.exercise__solution {
  margin-top: var(--space-md);
}

.exercise__solution summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-accent);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background-color: var(--color-blue-50);
}

.exercise__solution summary:hover {
  background-color: var(--color-blue-100);
}

.exercise__solution[open] summary {
  margin-bottom: var(--space-md);
}

/* Applications Section */
.applications {
  background-color: #f0fdf4;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin: var(--space-2xl) 0;
  border-left: 4px solid var(--color-success);
}

.applications__title {
  color: var(--color-success);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.applications__title::before {
  content: '🔬';
  font-size: var(--font-size-xl);
}

/* Responsive Mathematics */
@media (max-width: 600px) {
  .math-figure {
    margin: var(--space-lg) 0;
  }
  
  .function-table {
    font-size: var(--font-size-sm);
  }
  
  .function-table th,
  .function-table td {
    padding: var(--space-sm);
  }
  
  .function-table .math-cell {
    width: auto;
    min-width: 120px;
  }
  
  .math-lightbox__content {
    padding: var(--space-lg);
    margin: var(--space-md);
  }
  
  .math-steps li {
    padding-left: var(--space-lg);
  }
}

/* Dark Mode Adjustments */
/* === EXERCISE HINTS AND SOLUTIONS === */

/* Exercise hints */
.exercise-hint {
  margin: var(--space-md) 0;
}

.exercise-hint summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-accent);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background-color: var(--color-blue-50);
  border: 1px solid var(--color-border);
  list-style: none;
  display: block;
}

.exercise-hint summary::-webkit-details-marker {
  display: none;
}

.exercise-hint summary::before {
  content: '💡 ';
  margin-right: var(--space-xs);
}

.exercise-hint summary:hover {
  background-color: var(--color-blue-100);
}

.exercise-hint p {
  background-color: var(--color-blue-50);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-top: none;
  padding: var(--space-md);
  margin: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Exercise solutions */
.exercise-solution {
  margin: var(--space-md) 0;
}

.exercise-solution summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-success);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background-color: var(--color-blue-50);
  border: 1px solid var(--color-success);
  list-style: none;
  display: block;
}

.exercise-solution summary::-webkit-details-marker {
  display: none;
}

.exercise-solution summary::before {
  content: '✅ ';
  margin-right: var(--space-xs);
}

.exercise-solution summary:hover {
  background-color: var(--color-blue-100);
}

.exercise-solution .solution-content {
  background-color: var(--color-blue-50);
  border: 1px solid var(--color-success);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-md);
  border-left: 4px solid var(--color-success);
}

.exercise-solution .solution-steps {
  list-style: none;
  padding: 0;
  margin: 0;
}

.exercise-solution .solution-steps li {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-success);
  position: relative;
  padding-left: var(--space-xl);
  color: var(--color-text);
}

.exercise-solution .solution-steps li:last-child {
  border-bottom: none;
}

.exercise-solution .solution-steps li::before {
  content: counter(step-counter);
  counter-increment: step-counter;
  position: absolute;
  left: 0;
  top: var(--space-sm);
  background-color: var(--color-success);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.exercise-solution .solution-steps {
  counter-reset: step-counter;
}
/* === AVSNITT CONTENT STYLES === */

/* Main content container */
.avsnitt-content {
  margin-top: 20px;
}

/* Intro text */
.intro-text {
  font-size: var(--font-size-lg);
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--color-bg-alt);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--color-accent);
}

/* Exempel boxes */
.exempel-box {
  background: #f0f9ff;
  border: 1px solid var(--color-accent-500);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
}

.exempel-box h4 {
  color: var(--color-accent-700);
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-md);
}

.exempel-box p {
  margin: 0;
  color: var(--color-text);
}

/* Mistake boxes */
.mistake-box {
  background: #fef2f2;
  border: 1px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
}

.mistake-box h4 {
  color: var(--color-error);
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-md);
}

.mistake-box p {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text);
}

.example-text {
  background: rgba(0, 0, 0, 0.05);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  font-size: var(--font-size-sm);
}

/* Applications grid */
.applications-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.application-card {
  background: #f0fdf4;
  border: 1px solid var(--color-primary-500);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.application-card h4 {
  color: var(--color-primary-700);
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-md);
}

.application-card p {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text);
}

/* Exercises */
.exercises-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.exercise-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.exercise-item--lätt {
  border-left: 4px solid var(--color-success);
}

.exercise-item--medel {
  border-left: 4px solid var(--color-warning);
}

.exercise-item--svår {
  border-left: 4px solid var(--color-error);
}

.exercise-header {
  background: var(--color-bg-alt);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.exercise-number {
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--color-accent);
}

.exercise-difficulty {
  font-size: var(--font-size-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: white;
  text-transform: uppercase;
  font-weight: 600;
}

.exercise-content {
  padding: var(--space-lg);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .applications-grid {
    grid-template-columns: 1fr;
  }
  
  .exercise-header {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }
  
  .intro-text {
    font-size: var(--font-size-md);
    padding: var(--space-md);
  }
}
