/* ═══════════════════════════════════════════════════════════
   SUPER STUDY SHEETS - MODERN STYLESHEET (Clean A4 Image Version)
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   COLORS & VARIABLES
   ═══════════════════════════════════════════════════════════ */
:root {
  --dark-teal: #0B6162;
  --light-teal: #469B9D;
  --dark-gray: #2c3e50;
  --darker-gray: #1a252f;
  --medium-gray: #5a6c7d;
  --light-gray: #f8f9fa;
  --white: #ffffff;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
  --lifted-paper: 0 4px 12px rgba(0,0,0,0.15);
}

/* ═══════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--darker-gray);
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: clip;
  width: 100%;
  box-sizing: border-box;
}

html {
  overflow-x: clip;
  width: 100%;
}

main {
  flex: 1;
  display: block;
  background: #f1f1f1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 10px;
  min-height: calc(100vh - 200px);
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  overflow-x: hidden;
  box-sizing: border-box;
}

main h1, main h2, main h3 {
  padding: 0 0 10px 0;
  margin-top: 0;
}

/* ═══════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  color: var(--dark-gray);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  padding: 0 20px;
  box-sizing: border-box;
}

/* Responsive headings using clamp() */
h1 { 
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-top: 0;
}

h2 { 
  font-size: clamp(1.5rem, 3.5vw, 2rem); 
}

h3 { 
  font-size: clamp(1.25rem, 3vw, 1.5rem); 
}

h4 { 
  font-size: clamp(1.1rem, 2.5vw, 1.25rem); 
}

h5 { 
  font-size: clamp(1rem, 2vw, 1.1rem); 
}

h6 { 
  font-size: clamp(0.95rem, 1.8vw, 1rem); 
}

/* Index page titles */
.index-title,
.subjects-heading {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  text-align: center;
  margin: 2rem 0 1.5rem;
  color: var(--dark-gray);
  padding: 10px 10px;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--dark-teal);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--light-teal);
}

/* ═══════════════════════════════════════════════════════════
   HEADER & NAVIGATION
   ═══════════════════════════════════════════════════════════ */
header {
  background: var(--white);
  border-bottom: 3px solid var(--dark-teal); /* Thin branding line */
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* Mobile menu - high z-index to ensure it's above everything */
@media (max-width: 768px) {
  header nav,
  header #main-nav {
    z-index: 999;
  }
  
  header nav a,
  header #main-nav a {
    position: relative;
    z-index: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    -webkit-user-select: none;
    user-select: none;
    font-size: 1.1em;
  }
}

header .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--dark-gray);
  text-decoration: none;
}

.logo .study {
  color: var(--dark-teal);
}

.logo:hover {
  color: var(--dark-gray);
  opacity: 0.9;
}

header nav,
header #main-nav {
  display: flex;
  gap: 1.75rem;
}

header nav a,
header #main-nav a {
  color: var(--dark-gray);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

/* Only show hover on non-touch devices */
@media (hover: hover) and (pointer: fine) {
  header nav a:hover,
  header #main-nav a:hover {
    color: var(--dark-teal);
  }
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1001;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--dark-gray);
  margin: 5px 0;
}

/* ═══════════════════════════════════════════════════════════
   HOMEPAGE - Hero, Cards, Subjects
   ═══════════════════════════════════════════════════════════ */

.hero {
  background: linear-gradient(135deg, var(--dark-teal) 0%, var(--light-teal) 100%);
  color: var(--white);
  padding: 40px 20px 30px;
  text-align: center;
  margin-bottom: 30px;
  border-radius: 8px;
}

.hero h1 {
  font-size: 2.2rem;
  margin-bottom: 10px;
  color: var(--white);
  padding: 0;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.95;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.5;
}

.section-header {
  text-align: center;
  margin: 40px 0 20px;
}

.section-header h2 {
  font-size: 1.75rem;
  color: var(--dark-teal);
  margin-bottom: 8px;
  padding: 0;
}

.section-header p {
  color: var(--medium-gray);
  font-size: 1rem;
}

/* Center all category and index descriptions globally */
.category-description {
  text-align: center;      /* Centers text within its container */
  max-width: 800px;        /* Prevents text from stretching too wide on desktop */
  margin: 0 auto 30px auto; /* Centers the container and adds space before the grid */
  padding: 0 15px;         /* Prevents text from hitting the screen edges on mobile */
}

.category-description p {
  font-size: 1.1rem;       /* Makes the text slightly more prominent */
  color: #555;             /* Softens the color for a professional look */
  line-height: 1.6;        /* Increases readability */
  margin: 0;
}
/* ═══════════════════════════════════════════════════════════
   CARDS GRID
   ═══════════════════════════════════════════════════════════ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 25px;
  margin: 20px;
  padding: 0 20px;
}

.card {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 15px !important;
  text-align: center;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: auto !important;
  height: 100%;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.card-thumbnail {
  width: 100%;
  max-width: 190px;
  height: 190px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
}

.card-thumbnail-img {
  object-fit: contain !important;
  width: 100%;
  height: 100%;
  display: block;
}

.card-placeholder {
  width: 190px;
  height: 190px;
  background: var(--light-gray);
  border-radius: 8px;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--dark-gray);
  margin: 0 0 8px;
  padding: 0;
  line-height: 1.3;
}

.card-description {
  font-size: 0.9rem;
  color: var(--medium-gray);
  margin: 0 0 12px;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  min-height: 60px;
}

.card-cta {
  display: inline-block;
  padding: 10px 20px;
  background: var(--dark-teal);
  color: var(--white);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
  text-decoration: none;
  margin-top: auto;
  flex-shrink: 0;
}

.card-cta:hover {
  background: var(--light-teal);
  color: var(--white);
}

/* ═══════════════════════════════════════════════════════════
   SUBJECTS GRID
   ═══════════════════════════════════════════════════════════ */

   .subjects-grid .card-description {
    display: none !important;
  }
/* Make these cards smaller since the text is gone */
.subjects-grid .card {
  min-height: auto !important;
  padding: 15px !important;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 30px;
  margin: 20px 0;
  max-width: 100%;
}

.subject-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  transition: transform 0.2s;
}

.subject-item:hover {
  transform: scale(1.05);
}

.subject-item img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 10px;
}

.subject-name {
  font-weight: 600;
  color: var(--dark-gray);
  font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════
   SECTIONS & CONTENT
   ═══════════════════════════════════════════════════════════ */
section {
  margin: 40px 0;
}

section.printable-section {
  margin: 40px 0;
}

/* Intro and conclusion content (HTML) */
.intro-content,
.conclusion-content {
  background: transparent;
  padding: 20px;
  margin: 20px 0;
  line-height: 1.8;
  font-size: 1rem;
}

.intro-content h2,
.intro-content h3,
.conclusion-content h2,
.conclusion-content h3 {
  color: var(--dark-teal);
  margin-top: 20px;
  margin-bottom: 12px;
  padding: 0;
}

.intro-content p,
.conclusion-content p {
  margin-bottom: 1rem;
  color: var(--darker-gray);
}

/* ═══════════════════════════════════════════════════════════
   A4 WORKSHEET IMAGES
   ═══════════════════════════════════════════════════════════ */
.worksheet-image {
  text-align: center;
  margin: 20px 0;
}

.worksheet-image img.a4-worksheet {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
button, .button {
  background: var(--light-teal);
  color: var(--white);
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

button:hover, .button:hover {
  background: var(--dark-teal);
  transform: scale(1.05);
}

.print-btn {
  display: block;
  margin: 20px auto;
  text-align: center;
  padding: 12px 30px;
  background: var(--dark-teal);
  color: var(--white);
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.print-btn:hover {
  background: var(--light-teal);
}

/* Ad blocks between worksheets */
.ad-block {
  display: block;
  margin: 30px auto;
  padding: 20px;
  text-align: center;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
.support-block {
  margin: 40px auto;
  padding: 20px;
  max-width: 480px;
  text-align: center;
  background: #f4f8f8; /* very light teal/neutral */
  border: 1px solid #e1eeee;
  border-radius: 10px;
}
/* ═══════════════════════════════════════════════════════════
   BMAC BUTTON
   ═══════════════════════════════════════════════════════════ */
.support-text {
  margin-bottom: 14px;
  font-size: 0.95rem;
  color: #2f3e3e;
  line-height: 1.4;
}

.bmac-button img {
  display: inline-block;
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════ */
footer {
  background: var(--dark-teal);
  color: var(--white);
  text-align: center;
  padding: 30px 20px;
  margin-top: 0;
}

footer p {
  margin: 10px 0 0 0;
  font-size: 1rem;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.footer-nav a {
  color: var(--white);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.footer-nav a:hover {
  opacity: 0.8;
  color: var(--white);
}

/* ═══════════════════════════════════════════════════════════
   COOKIE BANNER
   ═══════════════════════════════════════════════════════════ */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dark-gray);
  color: var(--white);
  padding: 0;
  z-index: 10000;
  box-sizing: border-box;
}

.cookie-banner .container {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.cookie-banner p {
  margin: 0;
  flex: 1;
  font-size: 0.9rem;
}

.cookie-banner-link {
  color: var(--light-teal);
  text-decoration: underline;
}

.cookie-banner button {
  background: var(--light-teal);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s;
}

.cookie-banner button:hover {
  background: var(--dark-teal);
}

.cookie-banner.hidden {
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   AGE RECOMMENDATION BADGE
   ═══════════════════════════════════════════════════════════ */
.age-recommendation {
  background: var(--light-gray);
  border-left: 4px solid var(--light-teal);
  padding: 16px 20px;
  border-radius: 4px;
  margin: 20px 0;
}

.age-recommendation strong {
  color: var(--dark-teal);
}

/* ═══════════════════════════════════════════════════════════
   BREADCRUMBS
   ═══════════════════════════════════════════════════════════ */
.breadcrumbs {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 20px;
}

.breadcrumbs a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--dark-teal);
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   TABLE OF CONTENTS
   ═══════════════════════════════════════════════════════════ */
#table-of-contents,
.table-of-contents {
  background: var(--light-gray);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
  margin: 30px 0;
}

#table-of-contents h2,
#table-of-contents h3,
.table-of-contents h2,
.table-of-contents h3,
.toc-heading {
  margin-top: 0;
  font-size: 1.5rem;
  border-bottom: 2px solid var(--light-teal);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin: 10px 0;
  padding-left: 20px;
  position: relative;
}

.toc-list li:before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--light-teal);
  font-weight: bold;
}

.toc-list a {
  color: var(--dark-gray);
  font-weight: 500;
  transition: color 0.2s;
}

.toc-list a:hover {
  color: var(--dark-teal);
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   TABLES (Generic)
   ═══════════════════════════════════════════════════════════ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
}

table th,
table td {
  padding: 12px;
  border: 1px solid #ddd;
  text-align: left;
}

table th {
  background: var(--light-gray);
  font-weight: 700;
  color: var(--dark-teal);
}

/* ═══════════════════════════════════════════════════════════
   RELATED TOPICS
   ═══════════════════════════════════════════════════════════ */
.related-topics {
  background: var(--light-gray);
  padding: 24px;
  border-radius: 8px;
  margin: 30px 0;
}

.related-topics h3 {
  margin-top: 0;
  color: var(--dark-teal);
  padding: 0;
}

.related-topics ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-topics li {
  margin: 8px 0;
}

.related-topics a {
  color: var(--dark-gray);
  transition: color 0.2s;
}

.related-topics a:hover {
  color: var(--dark-teal);
}

/* ═══════════════════════════════════════════════════════════
   TOPIC ARTICLES SECTION
   ═══════════════════════════════════════════════════════════ */
.topic-articles {
  margin: 40px 0;
}

.topic-articles h2 {
  color: var(--dark-teal);
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════
   DIFFICULTY TABS (A4 Image System)
   ═══════════════════════════════════════════════════════════ */
.difficulty-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px;
  background: var(--light-gray);
  border-radius: 8px;
}

.difficulty-tab {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--medium-gray);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--medium-gray);
  transition: all 0.2s ease;
  text-align: center;
}

.difficulty-tab:hover {
  border-color: var(--dark-teal);
  color: var(--dark-teal);
}

.difficulty-tab.active {
  background: var(--dark-teal);
  border-color: var(--dark-teal);
  color: white;
}

/* Color-coded difficulty tabs */
.difficulty-tab[data-difficulty="easy"] {
  border-color: #38A169;
}
.difficulty-tab[data-difficulty="easy"].active {
  background: #38A169;
  border-color: #38A169;
}
.difficulty-tab[data-difficulty="easy"]:hover:not(.active) {
  border-color: #38A169;
  color: #38A169;
}

.difficulty-tab[data-difficulty="medium"] {
  border-color: #3182CE;
}
.difficulty-tab[data-difficulty="medium"].active {
  background: #3182CE;
  border-color: #3182CE;
}
.difficulty-tab[data-difficulty="medium"]:hover:not(.active) {
  border-color: #3182CE;
  color: #3182CE;
}

.difficulty-tab[data-difficulty="hard"] {
  border-color: #C05621;
}
.difficulty-tab[data-difficulty="hard"].active {
  background: #C05621;
  border-color: #C05621;
}
.difficulty-tab[data-difficulty="hard"]:hover:not(.active) {
  border-color: #C05621;
  color: #C05621;
}

.worksheet-difficulty-container {
  position: relative;
}

.worksheet-difficulty {
  text-align: center;
}

.worksheet-difficulty img.a4-worksheet {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════ */
@media print {
  @page {
    margin: 0;
  }
  
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
  }
  
  /* Hide ALL non-printable elements */
  header,
  footer,
  nav,
  .breadcrumbs,
  .age-recommendation,
  .print-btn,
  button,
  .button,
  .ad-block,
  .cookie-banner,
  .toc,
  .table-of-contents,
  .related-topics,
  .no-print,
  section.no-print,
  .intro-content,
  .conclusion-content,
  .difficulty-tabs,
  .grade-guide,
  .sidebar,
  .properties,
  .toolbar,
  .generate-btn,
  h1 {
    display: none !important;
    visibility: hidden !important;
  }
  
  /* Show only printable worksheet sections */
  
  
  /* Hide all difficulty tabs except the active one */
  .worksheet-difficulty:not(.print-active) {
    display: none !important;
    visibility: hidden !important;
  }

  /* Page setup - 0.5 inch (12.7mm) safety margin for home printers */
  @page {
    size: A4 portrait;
    margin: 0.5in; /* 0.5 inch safety margin */
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  html, body {
    overflow-x: clip; /* Fixes sticky header */
    margin: 0;
    padding: 0;
  }
  
  /* Worksheet container - scale to A4 with proper margins */
  .worksheet-container,
  .worksheet-difficulty-container,
  .worksheet-image {
    width: 100% !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
  }

  body {
    font-size: 11pt;
    line-height: 1.4;
    color: #000 !important;
    background: #fff !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Force all backgrounds to white and text to black for ink savings */
  * {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  /* Ensure worksheet images print properly */
  .a4-worksheet,
  .worksheet-image img,
  img.a4-worksheet {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid !important;
    display: block !important;
    margin: 0 auto !important;
  }

  main {
    display: block !important;
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  main {
    min-height: auto !important;
  }
  body {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  section.printable-section.print-target {
    page-break-before: auto !important;
    page-break-after: auto !important;
  }
  
  /* Also show worksheet images directly (not in sections) */
  .worksheet-image {
    display: block !important;
    visibility: visible !important;
    page-break-inside: avoid;
  }
  
  /* For difficulty-based worksheets, only show the active one */
  .worksheet-difficulty-container {
    display: block !important;
    visibility: visible !important;
    page-break-inside: avoid;
  }
  
  /* Hide all difficulty versions by default in print */
  .worksheet-difficulty {
    display: none !important;
    visibility: hidden !important;
  }
  
  /* Show only the active difficulty - check for inline style or use JavaScript class */
  /* JavaScript will add 'print-active' class to the visible difficulty before print */
  .worksheet-difficulty.print-active {
    display: block !important;
    visibility: visible !important;
    page-break-inside: avoid;
  }
  
  /* Fallback: If no class is set, show medium by default (it's usually the active one) */
  .worksheet-difficulty[data-difficulty="medium"]:not([style*="display: none"]):not([style*="display:none"]) {
    display: block !important;
    visibility: visible !important;
  }
  
  .worksheet-difficulty[data-difficulty="easy"]:not([style*="display: none"]):not([style*="display:none"]) {
    display: block !important;
    visibility: visible !important;
  }
  
  .worksheet-difficulty[data-difficulty="hard"]:not([style*="display: none"]):not([style*="display:none"]) {
    display: block !important;
    visibility: visible !important;
  }
  
  /* Hide non-printable sections */
  section.no-print {
    display: none !important;
  }
  
  /* Hide sections that are not printable, but keep printable ones */
  section:not(.printable-section):not(.no-print) {
    display: none !important;
  }

  /* A4 worksheet images print at full size */
  .worksheet-image {
    page-break-inside: avoid;
    margin: 0;
    padding: 0;
  }

  .worksheet-image img.a4-worksheet {
    width: 100%;
    max-width: 100%;
    height: auto;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  .worksheet-difficulty {
    page-break-inside: auto !important;
  }

  .worksheet-difficulty img.a4-worksheet,
  .worksheet-image img.a4-worksheet,
  img.a4-worksheet {
    width: 100% !important;
    max-width: 210mm !important;
    height: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: block !important;
    margin: 0 auto !important;
  }
  /* Hide ALL printable sections by default */
section.printable-section {
  display: none !important;
  visibility: hidden !important;
}

/* Show ONLY the clicked worksheet section */
section.printable-section.print-target {
  display: block !important;
  visibility: visible !important;
  page-break-before: avoid !important;
  page-break-after: avoid !important;
}

}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE - TABLET
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  
  /* --- Tightened Typography & Hero --- */
  h1 { font-size: 1.5rem !important; }
  h2 { font-size: 1.3rem !important; }
  h3 { font-size: 1.1rem !important; }
  
  .hero {
    padding: 12px 15px !important; /* Reduced from 20px */
    margin-bottom: 12px !important; /* Reduced from 20px */
    text-align: center;
  }

  .hero h1 {
    font-size: 1.4rem !important;
    margin-bottom: 4px !important;
  }

  .hero p {
    font-size: 0.85rem !important;
    margin: 0 !important;
    line-height: 1.3;
  }
  
  .index-title,
  .subjects-heading {
    font-size: 1.2rem !important;
    margin: 10px 0 8px !important; /* Pulls the grid up closer */
  }

  .section-header {
    margin: 15px 0 10px !important;
  }

  /* --- Subject Icons --- */
  .subject-item img, .card-thumbnail {
    width: 80px !important; /* Slimmer icons to save vertical space */
    height: 80px !important;
  }

  /* Mobile nav */
  /* --- Clean Permanent Header for Tablet/Mobile --- */
  header .container {
    flex-direction: column; 
    height: auto;
    padding: 8px 10px 5px !important; /* Heavily reduced vertical padding */
  }

  .logo {
    font-size: 1.25rem !important; /* Smaller, sleeker logo */
    font-weight: 700 !important;
    margin-bottom: 2px !important; /* Pulls links up closer */
    text-align: center;
  }

  header nav, 
  header #main-nav {
    display: flex !important; 
    justify-content: center;
    gap: 15px !important;
    padding: 0 0 5px 0 !important; /* Tightens the bottom of the header */
    margin: 0 !important;
  }

  header nav a, 
  header #main-nav a {
    font-size: 0.85rem !important; /* Smaller, cleaner links */
    padding: 4px 8px !important;
  }

  .hamburger {
    display: none !important; /* Completely hides the button */
  }


  /* Difficulty tabs responsive */
  .difficulty-tabs {
    flex-wrap: wrap;
  }
  
  .difficulty-tab {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  /* Content spacing */
  .intro-content,
  .conclusion-content {
    padding: 15px;
  }

  .table-of-contents,
  #table-of-contents {
    padding: 20px;
  }

  .ad-block {
    margin: 20px auto;
    padding: 15px;
  }

  .cookie-banner .container {
    padding: 15px 20px;
    flex-direction: column;
    text-align: center;
    gap: 15px;
  }
  
  .cookie-banner button {
    width: 100%;
  }
  
  .footer-nav {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE - SMALL PHONE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  main {
    padding: 15px;
  }

  h1 {
    font-size: clamp(1.3rem, 6vw, 2.5rem);
    padding: 0 8px;
  }
  
  h2 {
    font-size: clamp(1.2rem, 5.5vw, 2rem);
  }
  
  .index-title,
  .subjects-heading {
    font-size: clamp(1.2rem, 5.5vw, 2rem);
  }


  .card {
    padding: 12px;
  }

  .card-thumbnail {
    width: 120px;
    height: 120px;
  }

  
  .subject-item img {
    width: 80px;
    height: 80px;
  }

  .ad-block {
    margin: 15px auto;
    padding: 12px;
    max-width: calc(100vw - 16px);
  }

  /* Difficulty tabs stack on small phones */
  .difficulty-tabs {
    flex-direction: column;
    gap: 6px;
  }
  
  .difficulty-tab {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  /* Force Subjects to sit 2-per-row on phones */
  .subjects-grid {
    grid-template-columns: 1fr 1fr !important; 
    gap: 12px !important;
    padding: 10px !important;
    margin: 10px auto !important;
  }
  
  .subjects-grid .card {
    padding: 10px !important;
    min-height: auto !important;
  }

  .subjects-grid .card-thumbnail {
    max-width: 80px !important; 
    height: 80px !important;
  }

  .subjects-grid .card-title {
    font-size: 0.95rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════ */
.no-print {
  display: block;
}

@media print {
  .no-print {
    display: none !important;
  }
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

.hidden {
  display: none;
}

/* Editable cells in articles table */
.editable-cell {
  transition: all 0.2s ease;
}

.editable-cell:hover {
  background-color: #f0f0f0 !important;
  border-color: #ccc !important;
}

.editable-cell:focus {
  outline: none;
  background-color: #f0f8ff !important;
  border-color: #2196f3 !important;
}
