/* Reset and base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  position: relative;
  background: var(--sky-gradient, linear-gradient(to bottom, #87ceeb, #f0f8ff));
  transition: background 1s linear;
}

/* ---- General Section Layout ---- */
section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 15px;
}

/* ---- Headings ---- */
h1 {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  text-align: center;
  color: #2b3e50;
  margin: 20px 0;
}

h2 {
  font-size: clamp(1.2rem, 4vw, 2rem);
  margin: 15px 0;
  text-align: center;
}

/* ---- Table Section ---- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 15px 0;
  width: 100%;
  max-width: 600px;
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 300px;
  background-color: white;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  border: 1px solid #ccc;
  padding: clamp(8px, 2vw, 12px);
  text-align: center;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
}

th {
  background-color: #1976d2;
  color: white;
}

tr:nth-child(even) td {
  background-color: #f9f9f9;
}

table input {
  width: 100%;
  min-width: 80px;
  padding: 8px;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* ---- Syllabus Section ---- */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  padding: 10px;
  width: 100%;
  max-width: 100%;
}

.topic {
  background-color: white;
  border: 2px solid #2196f3;
  border-radius: 10px;
  width: 100%;
  max-width: 500px;
  padding: clamp(12px, 3vw, 18px);
  margin: 8px 0;
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 500;
  color: #333;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.25s ease;
  cursor: pointer;
  text-align: center;
  position: relative;
}

.topic:hover {
  background-color: #e3f2fd;
  transform: translateY(-2px);
}

/* Mobile: Subtopics appear below */
.subtopics {
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin-top: 10px;
  width: 100%;
  display: none;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.subtopics ul {
  list-style-type: disc;
  margin: 0;
  padding-left: 20px;
}

.subtopics li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  color: #333;
  line-height: 1.6;
  text-align: left;
}

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

.lambda {
  font-size: 1em;
  vertical-align: baseline;
  font-family: inherit;
}

/* ---- Tablet styles ---- */
@media (min-width: 768px) {
  section {
    padding: 30px 40px;
  }

  .container {
    padding: 20px;
    gap: 20px;
  }

  table {
    min-width: 500px;
  }

  .table-wrapper {
    max-width: 700px;
  }

  .topic {
    max-width: 600px;
  }

  /* Desktop: Subtopics appear on the side */
  .subtopics {
    position: absolute;
    top: 0;
    left: 105%;
    width: 280px;
    margin-top: 0;
    background-color: white;
    z-index: 10;
  }
}

/* ---- Desktop styles ---- */
@media (min-width: 1024px) {
  section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 60px;
  }

  .container {
    max-width: 900px;
  }

  .topic {
    max-width: 700px;
    font-size: 1.2rem;
  }

  .subtopics {
    width: 320px;
    font-size: 1rem;
  }

  .table-wrapper {
    max-width: 900px;
  }

  table {
    min-width: 600px;
  }

  th,
  td {
    padding: 14px;
    font-size: 1rem;
  }

  table input {
    padding: 10px;
    font-size: 1rem;
  }
}

/* ---- Large Desktop styles ---- */
@media (min-width: 1440px) {
  section {
    max-width: 1400px;
    padding: 50px 80px;
  }

  .container {
    max-width: 1000px;
  }

  .topic {
    max-width: 800px;
  }

  .table-wrapper {
    max-width: 1000px;
  }
}

/* ---- iOS specific fixes ---- */
@supports (-webkit-touch-callout: none) {
  input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* ---- Touch device optimizations ---- */
@media (hover: none) and (pointer: coarse) {
  .topic {
    padding: 16px;
    min-height: 50px;
    -webkit-tap-highlight-color: rgba(33, 150, 243, 0.2);
  }

  .topic:active {
    background-color: #e3f2fd;
    transform: scale(0.98);
  }

  a {
    -webkit-tap-highlight-color: rgba(33, 150, 243, 0.2);
  }
}

/* ---- Smooth scrolling for all devices ---- */
html {
  scroll-behavior: smooth;
}

/* ---- Print styles ---- */
@media print {
  .home-box {
    display: none;
  }

  section {
    page-break-inside: avoid;
  }

  table {
    page-break-inside: avoid;
  }
}
