/* ============================================================
   Schoolep Resource Portal Pages
   File: /pages/resources/resources.css
   Scope: category/resource portal pages only.
   This file does not restyle global navbar/sidebar/footer icons.
   ============================================================ */

/* 01) Stage color variables
   ------------------------------------------------------------ */
html[data-stage="p"] .resources-content {
  --resource-accent: #16a34a;
  --resource-accent-rgb: 22, 163, 74;
  --resource-accent-dark: #15803d;
}

html[data-stage="m"] .resources-content {
  --resource-accent: #f59e0b;
  --resource-accent-rgb: 245, 158, 11;
  --resource-accent-dark: #d97706;
}

html[data-stage="s"] .resources-content {
  --resource-accent: #9333ea;
  --resource-accent-rgb: 147, 51, 234;
  --resource-accent-dark: #7e22ce;
}

html[data-resource-hub] .resources-content {
  --resource-accent: #2563eb;
  --resource-accent-rgb: 37, 99, 235;
  --resource-accent-dark: #1d4ed8;
}

/* 02) Page shell
   ------------------------------------------------------------ */
.resources-page {
  align-items: flex-start;
}

.resources-content {
  --resource-accent: #f59e0b;
  --resource-accent-rgb: 245, 158, 11;
  --resource-text: #0f172a;
  --resource-muted: #64748b;
  --resource-card: rgba(255, 255, 255, 0.92);
  --resource-card-solid: #ffffff;
  --resource-border: rgba(15, 23, 42, 0.10);
  --resource-soft: rgba(var(--resource-accent-rgb), 0.10);
  --resource-soft-strong: rgba(var(--resource-accent-rgb), 0.16);
  --resource-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --resource-radius: 22px;
  color: var(--resource-text);
  min-height: calc(100vh - var(--header-h, 70px) - 160px);
}

html.dark-mode .resources-content {
  --resource-text: #f8fafc;
  --resource-muted: #cbd5e1;
  --resource-card: rgba(15, 23, 42, 0.82);
  --resource-card-solid: #111827;
  --resource-border: rgba(255, 255, 255, 0.12);
  --resource-soft: rgba(var(--resource-accent-rgb), 0.18);
  --resource-soft-strong: rgba(var(--resource-accent-rgb), 0.25);
  --resource-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.resources-content *,
.resources-content *::before,
.resources-content *::after {
  box-sizing: border-box;
}

.resources-content a {
  text-decoration: none;
}

/* 03) Breadcrumb
   ------------------------------------------------------------ */
.resources-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--resource-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.resources-breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.resources-breadcrumb a:hover,
.resources-breadcrumb a:active,
.resources-breadcrumb a:focus-visible {
  color: var(--resource-accent);
  text-decoration: none;
  outline: none;
}

.resources-breadcrumb a i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-inline-end: 2px;
  font-size: 0.95em;
  line-height: 1;
  position: relative;
  top: -2px;
}

.resources-breadcrumb .resources-crumb-stage {
  color: inherit;
}

.resources-breadcrumb .resources-crumb-current {
  color: var(--resource-text);
  font-weight: 800;
}

.resources-breadcrumb .resources-crumb-sep {
  color: inherit;
  opacity: 0.6;
  font-size: 14px;
  font-weight: 700;
  margin-top: -1px;
  user-select: none;
}

html.dark-mode .resources-breadcrumb {
  color: #94a3b8;
}

html.dark-mode .resources-breadcrumb .resources-crumb-current {
  color: #f8fafc;
}

@media (max-width: 720px) {
  .resources-breadcrumb {
    gap: 6px;
    font-size: 12px;
  }

  .resources-breadcrumb a i {
    top: -3px;
  }
}

/* 04) Hero
   ------------------------------------------------------------ */
.resources-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  padding: 28px 26px;
  border: 1px solid var(--resource-border);
  border-radius: var(--resource-radius);
  background:
    radial-gradient(circle at top right, rgba(var(--resource-accent-rgb), 0.22), transparent 36%),
    linear-gradient(135deg, var(--resource-card-solid), var(--resource-card));
  box-shadow: var(--resource-shadow);
  isolation: isolate;
}

html[dir="ltr"] .resources-hero {
  background:
    radial-gradient(circle at top left, rgba(var(--resource-accent-rgb), 0.22), transparent 36%),
    linear-gradient(135deg, var(--resource-card-solid), var(--resource-card));
}

.resources-hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -70px;
  top: -70px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(var(--resource-accent-rgb), 0.16);
  filter: blur(2px);
  z-index: -1;
}

.resources-hero-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

.resources-hero-icon {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  box-shadow: 0 14px 28px rgba(var(--resource-accent-rgb), 0.28);
  font-size: 1.45rem;
}

.resources-title {
  margin: 0;
  color: var(--resource-text);
  font-size: clamp(1.55rem, 2.2vw, 2.2rem);
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: -0.02em;
}

html[dir="rtl"] .resources-title {
  letter-spacing: 0;
}

.resources-subtitle {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--resource-muted);
  font-size: 1.02rem;
  line-height: 1.8;
  font-weight: 600;
}

.resources-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.resources-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  border-radius: 999px;
  color: var(--resource-accent-dark);
  background: var(--resource-soft);
  font-size: 0.88rem;
  font-weight: 900;
}

html.dark-mode .resources-pill {
  color: #fff;
}

/* 05) Grid and cards
   ------------------------------------------------------------ */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.resources-level-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--resource-border);
  border-radius: var(--resource-radius);
  background: var(--resource-card);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.resources-level-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--resource-accent-rgb), 0.32);
  box-shadow: var(--resource-shadow);
}

.resources-level-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--resource-border);
}

.resources-level-title-wrap {
  min-width: 0;
}

.resources-level-title {
  margin: 0;
  color: var(--resource-text);
  font-size: 1.08rem;
  line-height: 1.35;
  font-weight: 900;
}

.resources-level-caption {
  margin: 3px 0 0;
  color: var(--resource-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.resources-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(var(--resource-accent-rgb), 0.24);
}

.resources-subject-stack {
  display: grid;
  gap: 14px;
  padding: 14px 16px 16px;
}

.resources-subject-group {
  display: grid;
  gap: 10px;
}

.resources-subject-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.resources-subject-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px 16px;
}

.resources-subject-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--resource-border);
  border-radius: 16px;
  color: var(--resource-text);
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.94rem;
  font-weight: 850;
  line-height: 1.35;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.resources-subject-link--header {
  flex: 1 1 auto;
  min-width: 0;
}

html.dark-mode .resources-subject-link {
  background: rgba(255, 255, 255, 0.04);
}

.resources-subject-link:hover,
.resources-subject-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--resource-accent-rgb), 0.45);
  background: var(--resource-soft-strong);
  color: var(--resource-accent-dark);
  outline: none;
}

html.dark-mode .resources-subject-link:hover,
html.dark-mode .resources-subject-link:focus-visible {
  color: #fff;
}

.resources-subject-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--resource-accent-dark);
  background: var(--resource-soft);
  font-size: 0.98rem;
}

html.dark-mode .resources-subject-icon {
  color: #fff;
}

.resources-subject-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 78px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  border-radius: 14px;
  color: var(--resource-accent-dark);
  background: var(--resource-soft);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
}

html.dark-mode .resources-subject-count-badge {
  color: #fff;
}

.resources-subject-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resources-resource-list {
  display: grid;
  gap: 12px;
}

.resources-resource-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.22);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.62)),
    var(--resource-card-solid);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

html.dark-mode .resources-resource-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(15, 23, 42, 0.78);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.22);
}

.resources-resource-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.resources-resource-card-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 10px 20px rgba(var(--resource-accent-rgb), 0.22);
}

.resources-resource-card-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.resources-resource-card-title {
  margin: 0;
  color: var(--resource-text);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.6;
}

.resources-resource-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.resources-resource-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  border-radius: 14px;
  color: var(--resource-text);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

html.dark-mode .resources-resource-tab {
  background: rgba(255, 255, 255, 0.03);
}

.resources-resource-tab:hover,
.resources-resource-tab:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--resource-accent-rgb), 0.40);
  background: rgba(var(--resource-accent-rgb), 0.12);
  outline: none;
}

.resources-resource-tab.is-active {
  color: #fff;
  border-color: var(--resource-accent);
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  box-shadow: 0 12px 22px rgba(var(--resource-accent-rgb), 0.25);
}

html.dark-mode .resources-resource-tab.is-active {
  color: #fff;
}

.resources-resource-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.resources-resource-tab-text {
  min-width: 0;
}

.resources-resource-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: inherit;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
}

.resources-resource-tab.is-active .resources-resource-tab-count {
  background: rgba(255, 255, 255, 0.18);
}

html.dark-mode .resources-resource-tab-count {
  background: rgba(255, 255, 255, 0.10);
}

.resources-resource-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px dashed rgba(var(--resource-accent-rgb), 0.26);
  border-radius: 16px;
  background: rgba(var(--resource-accent-rgb), 0.07);
}

html.dark-mode .resources-resource-panel {
  background: rgba(255, 255, 255, 0.03);
}

.resources-resource-panel-title {
  margin: 0;
  color: var(--resource-text);
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.5;
  text-align: center;
}

.resources-resource-entry-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.resources-resource-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.16);
  border-radius: 14px;
  color: var(--resource-text);
  background: rgba(255, 255, 255, 0.82);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

html.dark-mode .resources-resource-entry {
  background: rgba(15, 23, 42, 0.74);
}

.resources-resource-entry:hover,
.resources-resource-entry:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--resource-accent-rgb), 0.38);
  background: rgba(255, 255, 255, 0.96);
  color: var(--resource-accent-dark);
  box-shadow: 0 10px 22px rgba(var(--resource-accent-rgb), 0.12);
  outline: none;
}

html.dark-mode .resources-resource-entry:hover,
html.dark-mode .resources-resource-entry:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.resources-resource-entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  color: var(--resource-accent);
  font-size: 1rem;
}

.resources-resource-entry-text {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.55;
}

.resources-resource-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--resource-border);
  border-radius: 14px;
  color: var(--resource-text);
  background: rgba(255, 255, 255, 0.42);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

html.dark-mode .resources-resource-link {
  background: rgba(255, 255, 255, 0.03);
}

.resources-resource-link:hover,
.resources-resource-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--resource-accent-rgb), 0.42);
  background: var(--resource-soft-strong);
  color: var(--resource-accent-dark);
  box-shadow: 0 10px 22px rgba(var(--resource-accent-rgb), 0.10);
  outline: none;
}

html.dark-mode .resources-resource-link:hover,
html.dark-mode .resources-resource-link:focus-visible {
  color: #fff;
}

.resources-resource-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(var(--resource-accent-rgb), 0.22);
}

.resources-resource-text {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.93rem;
  font-weight: 800;
  line-height: 1.55;
}

.resources-resource-state {
  padding: 11px 12px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.6;
}

.resources-resource-state--loading {
  border: 1px dashed rgba(var(--resource-accent-rgb), 0.28);
  color: var(--resource-muted);
  background: var(--resource-soft);
}

.resources-resource-state--empty {
  border: 1px dashed rgba(var(--resource-accent-rgb), 0.32);
  color: var(--resource-muted);
  background: rgba(var(--resource-accent-rgb), 0.08);
}

.resources-level-empty {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px dashed rgba(var(--resource-accent-rgb), 0.35);
  border-radius: 16px;
  color: var(--resource-muted);
  background: var(--resource-soft);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.6;
  text-align: center;
}

.resources-level-note {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--resource-muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.65;
}

.resources-empty {
  padding: 22px;
  border: 1px dashed rgba(var(--resource-accent-rgb), 0.35);
  border-radius: var(--resource-radius);
  color: var(--resource-muted);
  background: var(--resource-soft);
  font-weight: 800;
  text-align: center;
}

/* Shared resource category hubs
   ------------------------------------------------------------ */
.resources-hub-stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.resources-hub-card {
  --hub-accent: #2563eb;
  --hub-accent-rgb: 37, 99, 235;
  --hub-accent-dark: #1d4ed8;
  position: relative;
  display: flex;
  min-height: 220px;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(var(--hub-accent-rgb), 0.22);
  border-radius: var(--resource-radius);
  color: var(--resource-text);
  background:
    radial-gradient(circle at top right, rgba(var(--hub-accent-rgb), 0.20), transparent 38%),
    linear-gradient(135deg, var(--resource-card-solid), var(--resource-card));
  box-shadow: var(--resource-shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  isolation: isolate;
}

html[dir="ltr"] .resources-hub-card {
  background:
    radial-gradient(circle at top left, rgba(var(--hub-accent-rgb), 0.20), transparent 38%),
    linear-gradient(135deg, var(--resource-card-solid), var(--resource-card));
}

.resources-hub-card:hover,
.resources-hub-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(var(--hub-accent-rgb), 0.45);
  box-shadow: 0 22px 48px rgba(var(--hub-accent-rgb), 0.16);
  outline: none;
}

.resources-hub-card--p {
  --hub-accent: #16a34a;
  --hub-accent-rgb: 22, 163, 74;
  --hub-accent-dark: #15803d;
}

.resources-hub-card--m {
  --hub-accent: #f59e0b;
  --hub-accent-rgb: 245, 158, 11;
  --hub-accent-dark: #d97706;
}

.resources-hub-card--s {
  --hub-accent: #9333ea;
  --hub-accent-rgb: 147, 51, 234;
  --hub-accent-dark: #7e22ce;
}

.resources-hub-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.resources-hub-card-icon {
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--hub-accent), var(--hub-accent-dark));
  box-shadow: 0 14px 28px rgba(var(--hub-accent-rgb), 0.26);
  font-size: 1.3rem;
}

.resources-hub-card-title {
  margin: 0;
  color: var(--resource-text);
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1.3;
}

.resources-hub-card-text {
  margin: 10px 0 0;
  color: var(--resource-muted);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.7;
}

.resources-hub-card-action {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--hub-accent), var(--hub-accent-dark));
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 1100px) {
  .resources-hub-stage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .resources-hub-card {
    min-height: 190px;
    padding: 18px 16px;
  }

  .resources-hub-card-head {
    align-items: flex-start;
  }
}

/* 06) Mobile and small screens
   ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .resources-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .resources-content {
    min-height: auto;
  }

  .resources-breadcrumb {
    gap: 6px;
    font-size: 12px;
  }

  .resources-hero {
    padding: 20px 16px;
    border-radius: 20px;
  }

  .resources-hero-top {
    align-items: flex-start;
    gap: 12px;
  }

  .resources-hero-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 1.18rem;
  }

  .resources-title {
    font-size: 1.32rem;
  }

  .resources-subtitle {
    font-size: 0.94rem;
    line-height: 1.75;
  }

  .resources-level-head {
    padding: 14px 14px 10px;
  }

  .resources-subject-stack {
    padding: 12px 14px 14px;
  }

  .resources-subject-head {
    align-items: stretch;
    flex-direction: column;
  }

  .resources-subject-list {
    grid-template-columns: 1fr;
    padding: 12px 14px 14px;
  }

  .resources-subject-link {
    min-height: 46px;
  }

  .resources-subject-count-badge {
    min-width: 0;
    min-height: 0;
    justify-content: flex-start;
  }

  .resources-resource-card {
    padding: 12px;
    gap: 10px;
  }

  .resources-resource-card-head {
    gap: 10px;
  }

  .resources-resource-tab {
    width: 100%;
    justify-content: flex-start;
  }

  .resources-resource-panel {
    padding: 12px;
  }

  .resources-resource-entry-list {
    grid-template-columns: 1fr;
  }

  .resources-level-note {
    padding: 0 14px 14px;
  }
}

@media (max-width: 420px) {
  .resources-hero-top {
    flex-direction: column;
  }

  .resources-summary-row {
    gap: 8px;
  }

  .resources-pill {
    width: 100%;
    justify-content: center;
  }

  .resources-level-head {
    align-items: flex-start;
  }
}




.resources-subject-link--static {
  cursor: default;
  pointer-events: none;
}

.resources-subject-link--static:hover,
.resources-subject-link--static:focus-visible {
  transform: none;
  border-color: var(--resource-border);
  background: rgba(255, 255, 255, 0.55);
  color: var(--resource-text);
  box-shadow: none;
}

html.dark-mode .resources-subject-link--static:hover,
html.dark-mode .resources-subject-link--static:focus-visible {
  color: var(--resource-text);
  background: rgba(255, 255, 255, 0.04);
}



/* ============================================================
   Resource lesson accordion cards
   Shows only lesson title first; opens resources on click.
   ============================================================ */

.resources-resource-card {
  overflow: hidden;
}

.resources-resource-card-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.resources-resource-card-toggle:focus-visible {
  outline: 3px solid rgba(var(--resource-accent-rgb), 0.28);
  outline-offset: 4px;
  border-radius: 14px;
}

.resources-resource-card-toggle .resources-resource-card-index,
.resources-resource-card-toggle .resources-resource-card-title-wrap {
  pointer-events: none;
}

.resources-resource-card-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--resource-accent);
  background: rgba(var(--resource-accent-rgb), 0.10);
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
  pointer-events: none;
}

.resources-resource-card.is-open .resources-resource-card-chevron {
  transform: rotate(180deg);
  color: #fff;
  background: var(--resource-accent);
}


.resources-resource-card.is-open {
  border-color: rgba(var(--resource-accent-rgb), 0.38);
  box-shadow: 0 14px 30px rgba(var(--resource-accent-rgb), 0.13);
}

.resources-resource-card.is-open .resources-resource-panel {
  margin-top: 12px;
}

html.dark-mode .resources-resource-card.is-open {
  border-color: rgba(var(--resource-accent-rgb), 0.46);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

html.dark-mode .resources-resource-card-chevron {
  background: rgba(var(--resource-accent-rgb), 0.16);
  border-color: rgba(var(--resource-accent-rgb), 0.28);
}

/* ============================================================
   07) Resource accordion smooth open + visited state
   Applies to direct resource buttons: الدرس : النموذج 01, الملخص 01...
   ------------------------------------------------------------ */
.resources-resource-panel--accordion {
  display: grid;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
  will-change: max-height, opacity;
  transition:
    max-height 0.22s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.16s ease,
    margin-top 0.16s ease,
    padding-top 0.16s ease,
    padding-bottom 0.16s ease;
}

.resources-resource-card.is-open .resources-resource-panel--accordion {
  opacity: 1;
  margin-top: 12px;
  padding-top: 14px;
  padding-bottom: 14px;
  pointer-events: auto;
}

.resources-resource-card:not(.is-open) .resources-resource-panel--accordion {
  display: grid;
}

.resources-resource-entry {
  position: relative;
}

.resources-resource-entry.is-visited {
  padding-inline-end: 42px;
  border-color: rgba(var(--resource-accent-rgb), 0.48);
  background:
    linear-gradient(135deg, rgba(var(--resource-accent-rgb), 0.13), rgba(var(--resource-accent-rgb), 0.045)),
    rgba(255, 255, 255, 0.88);
  color: var(--resource-accent-dark);
  box-shadow:
    0 0 0 1px rgba(var(--resource-accent-rgb), 0.08),
    0 8px 18px rgba(var(--resource-accent-rgb), 0.10);
}

.resources-resource-entry.is-visited .resources-resource-entry-icon,
.resources-resource-entry.is-visited .resources-resource-entry-text {
  color: var(--resource-accent-dark);
  font-weight: 900;
}

.resources-resource-entry.is-visited::after {
  content: "✓";
  position: absolute;
  top: 50%;
  inset-inline-end: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.34);
  border-radius: 999px;
  background: rgba(var(--resource-accent-rgb), 0.16);
  color: var(--resource-accent-dark);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-50%);
}

html.dark-mode .resources-resource-entry.is-visited {
  border-color: rgba(var(--resource-accent-rgb), 0.55);
  background:
    linear-gradient(135deg, rgba(var(--resource-accent-rgb), 0.18), rgba(var(--resource-accent-rgb), 0.06)),
    rgba(15, 23, 42, 0.82);
  color: #fff;
}

html.dark-mode .resources-resource-entry.is-visited .resources-resource-entry-icon,
html.dark-mode .resources-resource-entry.is-visited .resources-resource-entry-text,
html.dark-mode .resources-resource-entry.is-visited::after {
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .resources-resource-panel--accordion {
    transition: none !important;
  }
}


/* ============================================================
   08) Big subject cards + semester split
   Structure: Level card → Subject card → Semestre/Dawra → Lesson accordion → Viewer files.
   ------------------------------------------------------------ */
.resources-grid {
  grid-template-columns: 1fr;
}

.resources-level-card {
  overflow: visible;
}

.resources-subject-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.resources-subject-group {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.24);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(var(--resource-accent-rgb), 0.055), transparent 58%),
    rgba(255, 255, 255, 0.58);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.resources-subject-group::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--resource-accent), var(--resource-accent-dark));
  border-radius: 20px 20px 0 0;
}

html.dark-mode .resources-subject-group {
  background:
    linear-gradient(180deg, rgba(var(--resource-accent-rgb), 0.12), transparent 62%),
    rgba(15, 23, 42, 0.64);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
}

.resources-subject-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.resources-subject-link--header {
  min-height: 58px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(var(--resource-accent-rgb), 0.18);
  font-size: 1.03rem;
  font-weight: 900;
}

html.dark-mode .resources-subject-link--header {
  background: rgba(255, 255, 255, 0.055);
}

.resources-subject-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  box-shadow: 0 10px 20px rgba(var(--resource-accent-rgb), 0.22);
}

.resources-subject-count-badge {
  min-width: 92px;
  min-height: 44px;
  border-radius: 16px;
}

.resources-resource-list {
  display: grid;
  gap: 14px;
}

.resources-semester-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

html.dark-mode .resources-semester-section {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(var(--resource-accent-rgb), 0.26);
}

.resources-semester-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  border-radius: 15px;
  background: rgba(var(--resource-accent-rgb), 0.08);
}

.resources-semester-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  color: #fff;
  background: var(--resource-accent);
  box-shadow: 0 8px 16px rgba(var(--resource-accent-rgb), 0.18);
}

.resources-semester-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--resource-text);
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.45;
}

.resources-semester-count {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--resource-accent-dark);
  background: rgba(var(--resource-accent-rgb), 0.10);
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.2;
}

html.dark-mode .resources-semester-count {
  color: #fff;
  background: rgba(var(--resource-accent-rgb), 0.18);
}

.resources-semester-lessons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.resources-resource-card {
  min-width: 0;
}

.resources-resource-card.is-open {
  grid-column: 1 / -1;
}

.resources-resource-card-toggle {
  min-height: 44px;
}

.resources-resource-card-title {
  line-height: 1.45;
}

.resources-resource-panel--accordion {
  transform: translateZ(0);
}

@media (max-width: 920px) {
  .resources-semester-lessons {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .resources-subject-group {
    padding: 13px;
    border-radius: 18px;
  }

  .resources-subject-head {
    align-items: stretch;
    flex-direction: column;
  }

  .resources-subject-link--header {
    min-height: 54px;
  }

  .resources-subject-count-badge {
    width: 100%;
    min-height: 38px;
  }

  .resources-semester-section {
    padding: 11px;
    border-radius: 16px;
  }

  .resources-semester-head {
    padding: 8px 10px;
  }

  .resources-semester-icon {
    width: 29px;
    height: 29px;
  }

  .resources-resource-card {
    padding: 12px;
  }

  .resources-resource-entry-list {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   09) Lazy subject accordion — clean final behavior
   Shows only subject cards first. Semesters and lessons load only
   after choosing a subject such as Mathématiques.
   ------------------------------------------------------------ */
.resources-subject-group--accordion {
  gap: 0;
}

.resources-subject-group--accordion .resources-subject-head {
  margin-top: 2px;
}

.resources-subject-toggle {
  width: 100%;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: start;
}

.resources-subject-toggle:focus-visible {
  outline: 3px solid rgba(var(--resource-accent-rgb), 0.28);
  outline-offset: 3px;
}

.resources-subject-toggle .resources-subject-text {
  flex: 1 1 auto;
}

.resources-subject-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-inline-start: auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: var(--resource-accent);
  background: rgba(var(--resource-accent-rgb), 0.10);
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  font-size: 0.84rem;
  line-height: 1;
  transition:
    transform 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.resources-subject-group.is-open .resources-subject-arrow {
  transform: rotate(180deg);
  color: #fff;
  background: var(--resource-accent);
  border-color: var(--resource-accent);
}

.resources-subject-group.is-open .resources-subject-toggle {
  border-color: rgba(var(--resource-accent-rgb), 0.42);
  background: var(--resource-soft-strong);
}

.resources-subject-body {
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  padding: 0 14px;
  border-top: 0 dashed rgba(var(--resource-accent-rgb), 0.20);
  transition:
    max-height 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.10s ease,
    padding 0.10s ease,
    border-width 0.14s ease;
  will-change: max-height, opacity;
}

.resources-subject-group.is-open .resources-subject-body {
  opacity: 1;
  padding: 12px 14px 16px;
  border-top-width: 1px;
}

.resources-subject-group.is-open {
  border-color: rgba(var(--resource-accent-rgb), 0.45);
  box-shadow: 0 16px 36px rgba(var(--resource-accent-rgb), 0.12);
}

.resources-subject-group:not(.is-open) .resources-subject-body {
  pointer-events: none;
}

@media (max-width: 768px) {
  .resources-subject-group.is-open .resources-subject-body {
    padding: 10px 10px 14px;
  }

  .resources-subject-arrow {
    width: 30px;
    height: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resources-subject-body,
  .resources-subject-arrow,
  .resources-subject-group {
    transition: none !important;
  }
}

/* ============================================================
   10) Level-first accordion final update
   Flow: level buttons first -> subjects -> semesters -> lessons -> files.
   This block intentionally comes last to override older portal rules cleanly.
   ============================================================ */

.resources-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.resources-level-card--accordion {
  overflow: hidden;
  align-self: start;
}

.resources-level-card--accordion.is-open {
  grid-column: 1 / -1;
}

.resources-level-card--accordion:hover {
  transform: translateY(-2px);
}

.resources-level-card--accordion .resources-level-head {
  padding: 0;
  border-bottom: 0;
}

.resources-level-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 76px;
  padding: 16px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.resources-level-toggle:focus-visible {
  outline: 3px solid rgba(var(--resource-accent-rgb), 0.28);
  outline-offset: -4px;
  border-radius: var(--resource-radius);
}

.resources-level-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.resources-level-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--resource-accent);
  background: rgba(var(--resource-accent-rgb), 0.10);
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  font-size: 0.86rem;
  line-height: 1;
  transition:
    transform 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.resources-level-card--accordion.is-open .resources-level-arrow {
  transform: rotate(180deg);
  color: #fff;
  background: var(--resource-accent);
  border-color: var(--resource-accent);
}

.resources-level-card--accordion.is-open .resources-level-toggle {
  border-bottom: 1px solid var(--resource-border);
  background: var(--resource-soft);
}

.resources-level-body {
  display: grid;
  gap: 14px;
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  padding: 0 16px;
  transition:
    max-height 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.10s ease,
    padding 0.10s ease;
  will-change: max-height, opacity;
}

.resources-level-card--accordion.is-open .resources-level-body {
  opacity: 1;
  padding: 14px 16px 16px;
}

.resources-level-card--accordion:not(.is-open) .resources-level-body {
  pointer-events: none;
}

.resources-level-card--accordion.is-open {
  border-color: rgba(var(--resource-accent-rgb), 0.42);
  box-shadow: var(--resource-shadow);
}

.resources-subject-group--accordion {
  overflow: hidden;
}

.resources-subject-group--accordion .resources-subject-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.resources-subject-toggle {
  width: 100%;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: start;
}

.resources-subject-toggle .resources-subject-text {
  flex: 1 1 auto;
}

.resources-subject-arrow {
  margin-inline-start: auto;
}

.resources-subject-count-badge {
  white-space: nowrap;
}

.resources-subject-body {
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  padding: 0 14px;
  border-top: 0 dashed rgba(var(--resource-accent-rgb), 0.20);
  transition:
    max-height 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.10s ease,
    padding 0.10s ease,
    border-width 0.14s ease;
  will-change: max-height, opacity;
}

.resources-subject-group.is-open .resources-subject-body {
  opacity: 1;
  padding: 12px 14px 16px;
  border-top-width: 1px;
}

@media (max-width: 1100px) {
  .resources-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .resources-grid {
    grid-template-columns: 1fr;
  }

  .resources-level-toggle {
    min-height: 68px;
    padding: 14px;
  }

  .resources-level-card--accordion.is-open .resources-level-body {
    padding: 12px 14px 14px;
  }
}

@media (max-width: 768px) {
  .resources-level-toggle {
    align-items: flex-start;
  }

  .resources-level-right {
    gap: 8px;
  }

  .resources-level-arrow,
  .resources-subject-arrow {
    width: 30px;
    height: 30px;
  }

  .resources-subject-group--accordion .resources-subject-head {
    align-items: stretch;
    flex-direction: column;
  }

  .resources-subject-count-badge {
    width: 100%;
  }

  .resources-subject-group.is-open .resources-subject-body {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resources-level-body,
  .resources-subject-body,
  .resources-level-arrow,
  .resources-subject-arrow,
  .resources-level-card--accordion,
  .resources-subject-group {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================

/* ============================================================
   FINAL OVERRIDE — Simple level cards + open subjects underneath
   Removed the large side-wing/trapezoid style.
   Flow remains: Level -> Subjects -> Semesters -> Lessons -> Files.
   ============================================================ */

.resources-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.resources-level-card--accordion {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--resource-border);
  border-radius: 22px;
  background: var(--resource-card);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

.resources-level-card--accordion:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--resource-accent-rgb), 0.32);
  box-shadow: var(--resource-shadow);
}

.resources-level-card--accordion.is-open {
  grid-column: 1 / -1;
  border-color: rgba(var(--resource-accent-rgb), 0.42);
  box-shadow: var(--resource-shadow);
}

.resources-level-card--accordion .resources-level-head {
  padding: 0;
  border-bottom: 0;
}

.resources-level-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 80px;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.resources-level-toggle:focus-visible {
  outline: 3px solid rgba(var(--resource-accent-rgb), 0.28);
  outline-offset: -4px;
  border-radius: 20px;
}

.resources-level-card--accordion.is-open .resources-level-toggle {
  border-bottom: 1px solid var(--resource-border);
  background: var(--resource-soft);
}

.resources-level-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.resources-level-title {
  margin: 0;
  color: var(--resource-text);
  font-size: 1.08rem;
  line-height: 1.35;
  font-weight: 900;
}

.resources-level-caption {
  margin: 4px 0 0;
  color: var(--resource-muted);
  font-size: 0.84rem;
  line-height: 1.45;
  font-weight: 800;
}

.resources-level-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.resources-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(var(--resource-accent-rgb), 0.24);
}

.resources-level-arrow,
.resources-subject-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--resource-accent);
  background: rgba(var(--resource-accent-rgb), 0.10);
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  font-size: 0.86rem;
  line-height: 1;
  transition:
    transform 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.resources-level-card--accordion.is-open .resources-level-arrow,
.resources-subject-group.is-open .resources-subject-arrow {
  transform: rotate(180deg);
  color: #fff;
  background: var(--resource-accent);
  border-color: var(--resource-accent);
}

.resources-level-body {
  display: grid;
  gap: 14px;
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  padding: 0 16px;
  transition:
    max-height 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.10s ease,
    padding 0.10s ease;
  will-change: max-height, opacity;
}

.resources-level-card--accordion.is-open .resources-level-body {
  opacity: 1;
  padding: 14px 16px 16px;
}

.resources-level-card--accordion:not(.is-open) .resources-level-body {
  pointer-events: none;
}

.resources-subject-group--accordion {
  overflow: hidden;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.28)),
    var(--resource-card-solid);
}

html.dark-mode .resources-subject-group--accordion {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)),
    rgba(15, 23, 42, 0.72);
}

.resources-subject-group--accordion .resources-subject-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.resources-subject-toggle {
  width: 100%;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: start;
}

.resources-subject-toggle .resources-subject-text {
  flex: 1 1 auto;
}

.resources-subject-arrow {
  margin-inline-start: auto;
}

.resources-subject-count-badge {
  white-space: nowrap;
}

.resources-subject-body {
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  padding: 0 14px;
  border-top: 0 dashed rgba(var(--resource-accent-rgb), 0.20);
  transition:
    max-height 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.10s ease,
    padding 0.10s ease,
    border-width 0.14s ease;
  will-change: max-height, opacity;
}

.resources-subject-group.is-open .resources-subject-body {
  opacity: 1;
  padding: 12px 14px 16px;
  border-top-width: 1px;
}

.resources-subject-group.is-open {
  border-color: rgba(var(--resource-accent-rgb), 0.45);
  box-shadow: 0 16px 36px rgba(var(--resource-accent-rgb), 0.12);
}

@media (max-width: 1100px) {
  .resources-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .resources-grid {
    grid-template-columns: 1fr;
  }

  .resources-level-card--accordion.is-open {
    grid-column: auto;
  }

  .resources-level-toggle {
    min-height: 70px;
    padding: 14px;
  }

  .resources-level-card--accordion.is-open .resources-level-body {
    padding: 12px 14px 14px;
  }
}

@media (max-width: 768px) {
  .resources-level-toggle {
    align-items: flex-start;
  }

  .resources-level-right {
    gap: 8px;
  }

  .resources-level-arrow,
  .resources-subject-arrow {
    width: 30px;
    height: 30px;
  }

  .resources-subject-group--accordion .resources-subject-head {
    align-items: stretch;
    flex-direction: column;
  }

  .resources-subject-count-badge {
    width: 100%;
  }

  .resources-subject-group.is-open .resources-subject-body {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resources-level-card--accordion,
  .resources-level-body,
  .resources-subject-body,
  .resources-level-arrow,
  .resources-subject-arrow,
  .resources-subject-group {
    transition: none !important;
    animation: none !important;
  }
}


/* ============================================================
   Responsive level behavior
   - Phones/small screens: levels stay collapsed until clicked.
   - Tablet/PC: every level shows its subject list immediately.
   ============================================================ */
@media (min-width: 769px) {
  .resources-level-card--accordion {
    overflow: visible;
  }

  .resources-level-card--accordion .resources-level-body {
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
    display: grid;
  }

  .resources-level-card--accordion .resources-level-arrow {
    display: none !important;
  }

  .resources-level-card--accordion .resources-level-toggle {
    cursor: default;
  }

  .resources-level-card--accordion .resources-level-caption {
    opacity: 0.92;
  }
}

@media (max-width: 768px) {
  .resources-level-card--accordion:not(.is-open) .resources-level-body {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}

/* ============================================================
   FINAL OVERRIDE — PC/tablet 3 level columns + visible subjects,
   phone/small screens accordion levels.
   ------------------------------------------------------------
   Desktop/tablet (>=769px):
   - Keep M1/M2/M3 as three cards in one row.
   - Show each level's subjects immediately under its title.
   - Clicking subjects still opens semesters/lessons.

   Phone/small screens (<=768px):
   - Show levels first only.
   - Click a level to reveal subjects.
   - Click a subject to reveal semesters/lessons.
   ============================================================ */

@media (min-width: 769px) {
  .resources-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    align-items: start !important;
    gap: 18px !important;
  }

  .resources-level-card--accordion,
  .resources-level-card--accordion.is-open {
    grid-column: auto !important;
  }

  .resources-level-card--accordion .resources-level-body {
    display: grid !important;
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
    padding: 14px 16px 16px !important;
    border-top: 1px dashed rgba(var(--resource-accent-rgb), 0.18) !important;
  }

  .resources-level-card--accordion:not(.is-open) .resources-level-body {
    display: grid !important;
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
    padding: 14px 16px 16px !important;
  }

  .resources-level-card--accordion .resources-level-arrow {
    display: none !important;
  }

  .resources-level-card--accordion .resources-level-toggle {
    cursor: default !important;
  }

  .resources-level-card--accordion .resources-level-head {
    border-bottom: 0 !important;
  }

  .resources-level-card--accordion .resources-level-caption {
    opacity: 0.9;
  }

  .resources-subject-stack.resources-level-body {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .resources-grid {
    grid-template-columns: 1fr !important;
  }

  .resources-level-card--accordion:not(.is-open) .resources-level-body {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-top-width: 0 !important;
  }

  .resources-level-card--accordion.is-open .resources-level-body {
    opacity: 1 !important;
    overflow: hidden;
    padding: 12px 14px 14px !important;
    border-top: 1px dashed rgba(var(--resource-accent-rgb), 0.18) !important;
  }

  .resources-level-card--accordion .resources-level-arrow {
    display: inline-flex !important;
  }

  .resources-level-card--accordion .resources-level-toggle {
    cursor: pointer !important;
  }
}

/* ============================================================
   FINAL FIX — Lesson cards full-width inside level columns
   ------------------------------------------------------------
   Fixes narrow two-column lesson cards on PC/tablet when levels
   are displayed in 3 columns. Long lesson titles stay readable.
   ============================================================ */

.resources-semester-list,
.resources-level-card--accordion .resources-semester-list,
.resources-subject-group .resources-semester-list {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 10px !important;
  width: 100% !important;
  min-width: 0 !important;
}

.resources-resource-card,
.resources-level-card--accordion .resources-resource-card,
.resources-subject-group .resources-resource-card {
  width: 100% !important;
  min-width: 0 !important;
  padding: 10px 11px !important;
  border-radius: 15px !important;
}

.resources-resource-card-toggle,
.resources-resource-card-head {
  width: 100% !important;
  min-width: 0 !important;
}

.resources-resource-card-toggle {
  align-items: flex-start !important;
  gap: 9px !important;
}

.resources-resource-card-index {
  min-width: 30px !important;
  width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 0.78rem !important;
}

.resources-resource-card-title-wrap {
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

.resources-resource-card-title {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  color: var(--resource-text) !important;
  font-size: clamp(0.78rem, 0.92vw, 0.92rem) !important;
  font-weight: 900 !important;
  line-height: 1.55 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
  hyphens: auto !important;
}

.resources-resource-card-chevron {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  margin-top: 0 !important;
}

.resources-resource-card.is-open .resources-resource-panel,
.resources-resource-card.is-open .resources-resource-panel--accordion {
  margin-top: 10px !important;
}

.resources-resource-panel,
.resources-resource-panel--accordion {
  padding: 10px !important;
  border-radius: 13px !important;
}

.resources-resource-panel-title {
  font-size: 0.82rem !important;
  line-height: 1.45 !important;
}

.resources-resource-entry-list {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
}

.resources-resource-entry {
  min-height: 40px !important;
  padding: 8px 10px !important;
  border-radius: 12px !important;
}

.resources-resource-entry-text {
  font-size: 0.8rem !important;
  line-height: 1.45 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
}

@media (min-width: 769px) {
  .resources-level-card--accordion .resources-semester-section {
    padding: 10px !important;
    border-radius: 16px !important;
  }

  .resources-level-card--accordion .resources-semester-head {
    gap: 8px !important;
    align-items: center !important;
  }

  .resources-level-card--accordion .resources-semester-title {
    font-size: 0.92rem !important;
    line-height: 1.35 !important;
  }

  .resources-level-card--accordion .resources-semester-count {
    min-height: 26px !important;
    padding: 5px 8px !important;
    font-size: 0.7rem !important;
  }
}

@media (max-width: 768px) {
  .resources-resource-card-title {
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
  }

  .resources-resource-card {
    padding: 11px !important;
  }
}

/* ============================================================
   FINAL FIX v2 — Readable lesson cards inside each subject
   ------------------------------------------------------------
   The previous fix targeted .resources-semester-list, but the
   current renderer uses .resources-semester-lessons. This forces
   one full-width lesson card per row and prevents narrow vertical
   title wrapping in the 3-column desktop layout.
   ============================================================ */

.resources-semester-lessons,
.resources-level-card--accordion .resources-semester-lessons,
.resources-subject-group .resources-semester-lessons {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 10px !important;
  width: 100% !important;
  min-width: 0 !important;
  align-items: stretch !important;
}

.resources-semester-lessons > .resources-resource-card,
.resources-level-card--accordion .resources-semester-lessons > .resources-resource-card,
.resources-subject-group .resources-semester-lessons > .resources-resource-card {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 11px 12px !important;
  border-radius: 15px !important;
}

.resources-semester-lessons .resources-resource-card-toggle {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  min-width: 0 !important;
}

.resources-semester-lessons .resources-resource-card-index {
  grid-column: 1 !important;
  flex: 0 0 auto !important;
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 0.78rem !important;
}

.resources-semester-lessons .resources-resource-card-title-wrap {
  grid-column: 2 !important;
  min-width: 0 !important;
  width: 100% !important;
}

.resources-semester-lessons .resources-resource-card-title {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  font-size: clamp(0.82rem, 0.9vw, 0.94rem) !important;
  font-weight: 900 !important;
  line-height: 1.45 !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  text-overflow: clip !important;
  overflow: visible !important;
  text-align: start !important;
}

.resources-semester-lessons .resources-resource-card-chevron {
  grid-column: 3 !important;
  flex: 0 0 auto !important;
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  margin: 0 !important;
}

.resources-semester-lessons .resources-resource-panel,
.resources-semester-lessons .resources-resource-panel--accordion {
  width: 100% !important;
  min-width: 0 !important;
  margin-top: 10px !important;
  padding: 10px !important;
  border-radius: 13px !important;
}

.resources-semester-lessons .resources-resource-entry-list {
  grid-template-columns: minmax(0, 1fr) !important;
}

.resources-semester-lessons .resources-resource-entry-text {
  font-size: 0.82rem !important;
  line-height: 1.45 !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

@media (max-width: 768px) {
  .resources-semester-lessons .resources-resource-card-toggle {
    gap: 9px !important;
  }

  .resources-semester-lessons .resources-resource-card-title {
    font-size: 0.88rem !important;
    line-height: 1.5 !important;
  }
}

/* ============================================================
   FINAL OVERRIDE — Vertical level cards
   Requested: show level cards one under each other, not horizontally.
   Applies to all screen sizes: PC, tablet, and phone.
   ============================================================ */
.resources-grid {
  grid-template-columns: 1fr !important;
  gap: 16px !important;
}

.resources-level-card--accordion,
.resources-level-card--accordion.is-open {
  grid-column: auto !important;
  width: 100% !important;
}

.resources-level-card--accordion .resources-level-body {
  width: 100% !important;
}

@media (min-width: 769px) {
  .resources-grid {
    grid-template-columns: 1fr !important;
  }

  .resources-level-card--accordion,
  .resources-level-card--accordion.is-open {
    grid-column: auto !important;
  }
}

/* ============================================================
   FINAL OVERRIDE — Arranged subject cards inside each level
   ------------------------------------------------------------
   Requested layout:
   - Level cards stay vertical, one under another.
   - Inside each opened/visible level, subject cards are arranged
     in a clean responsive grid instead of one long column.
   - When a subject is opened, it spans the full row so its
     semesters, lesson cards, and viewer resources stay readable.
   ============================================================ */

.resources-grid {
  grid-template-columns: 1fr !important;
  gap: 18px !important;
}

.resources-level-card--accordion,
.resources-level-card--accordion.is-open {
  grid-column: auto !important;
  width: 100% !important;
}

/* Arrange subjects under each level like clear cards in rows. */
.resources-level-card--accordion .resources-level-body,
.resources-level-card--accordion.is-open .resources-level-body,
.resources-level-card--accordion:not(.is-open) .resources-level-body {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
  align-items: start !important;
  gap: 14px !important;
  width: 100% !important;
  min-width: 0 !important;
}

/* Each subject is a clean card. Closed subjects occupy normal grid cells. */
.resources-level-card--accordion .resources-subject-group--accordion,
.resources-level-card--accordion .resources-subject-group {
  min-width: 0 !important;
  width: 100% !important;
}

/* Open subject must take the full row so long lessons never squeeze. */
.resources-level-card--accordion .resources-subject-group.is-open {
  grid-column: 1 / -1 !important;
  width: 100% !important;
}

/* Keep subject header readable and compact. */
.resources-subject-group--accordion .resources-subject-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 0 !important;
}

.resources-subject-toggle {
  min-width: 0 !important;
  width: 100% !important;
  min-height: 58px !important;
  padding: 11px 12px !important;
  border-radius: 16px !important;
}

.resources-subject-toggle .resources-subject-text {
  min-width: 0 !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
  word-break: normal !important;
  line-height: 1.35 !important;
}

.resources-subject-count-badge {
  width: auto !important;
  min-width: 78px !important;
  max-width: 112px !important;
  min-height: 38px !important;
  padding: 7px 10px !important;
  white-space: normal !important;
  text-align: center !important;
}

/* Open subject body: full-width area below the subject header. */
.resources-subject-group.is-open .resources-subject-body {
  width: 100% !important;
  min-width: 0 !important;
  padding: 14px !important;
}

/* Put semester blocks in two columns on wide screens; keep lesson cards readable. */
.resources-subject-group.is-open .resources-subject-body {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
}

.resources-subject-group.is-open .resources-resource-state {
  grid-column: 1 / -1 !important;
}

.resources-semester-section {
  min-width: 0 !important;
  width: 100% !important;
}

.resources-semester-lessons {
  grid-template-columns: 1fr !important;
}

.resources-semester-lessons > .resources-resource-card {
  width: 100% !important;
  min-width: 0 !important;
}

/* Medium screens: subject cards still arranged, semesters stack for readability. */
@media (max-width: 1180px) {
  .resources-subject-group.is-open .resources-subject-body {
    grid-template-columns: 1fr !important;
  }
}

/* Phones: keep simple one-column subjects and full readable text. */
@media (max-width: 768px) {
  .resources-level-card--accordion .resources-level-body,
  .resources-level-card--accordion.is-open .resources-level-body,
  .resources-level-card--accordion:not(.is-open) .resources-level-body {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .resources-subject-group--accordion .resources-subject-head {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .resources-subject-count-badge {
    width: 100% !important;
    max-width: none !important;
  }

  .resources-subject-group.is-open .resources-subject-body {
    grid-template-columns: 1fr !important;
    padding: 10px !important;
  }
}

/* ============================================================
   FINAL FIX — Clean readable subject cards
   ------------------------------------------------------------
   Fixes cramped subject cards where titles became vertical.
   Levels remain vertical. Subjects under each level are arranged
   in clean full-width rows/cards with readable text.
   ============================================================ */

/* Keep level cards one under another. */
.resources-grid {
  grid-template-columns: 1fr !important;
  gap: 18px !important;
}

.resources-level-card--accordion,
.resources-level-card--accordion.is-open {
  width: 100% !important;
  grid-column: auto !important;
}

/* The subject list under each level: clean rows, not squeezed mini-cards. */
.resources-level-card--accordion .resources-level-body,
.resources-level-card--accordion.is-open .resources-level-body,
.resources-level-card--accordion:not(.is-open) .resources-level-body {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(360px, 1fr)) !important;
  gap: 14px !important;
  align-items: start !important;
  width: 100% !important;
  min-width: 0 !important;
  padding: 16px !important;
}

/* Subject card: remove nested cramped-box feeling and give text room. */
.resources-level-card--accordion .resources-subject-group,
.resources-level-card--accordion .resources-subject-group--accordion {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  border-radius: 18px !important;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20) !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.78), rgba(255,255,255,0.55)),
    var(--resource-card-solid) !important;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.045) !important;
}

html.dark-mode .resources-level-card--accordion .resources-subject-group,
html.dark-mode .resources-level-card--accordion .resources-subject-group--accordion {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025)),
    rgba(15, 23, 42, 0.78) !important;
}

/* Open subject gets full width so semesters and lessons are never squeezed. */
.resources-level-card--accordion .resources-subject-group.is-open {
  grid-column: 1 / -1 !important;
}

.resources-subject-group--accordion .resources-subject-head,
.resources-subject-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px !important;
}

/* Subject button: icon + full title + arrow in one readable row. */
.resources-subject-toggle,
.resources-subject-link--header.resources-subject-toggle {
  display: grid !important;
  grid-template-columns: 44px minmax(0, 1fr) 34px !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 60px !important;
  padding: 10px 12px !important;
  border-radius: 16px !important;
  background: rgba(255,255,255,0.62) !important;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18) !important;
}

html.dark-mode .resources-subject-toggle,
html.dark-mode .resources-subject-link--header.resources-subject-toggle {
  background: rgba(255,255,255,0.045) !important;
}

.resources-subject-icon {
  width: 44px !important;
  height: 44px !important;
  border-radius: 14px !important;
}

.resources-subject-arrow {
  width: 34px !important;
  height: 34px !important;
  margin: 0 !important;
}

/* Critical readability fix: no vertical letter wrapping. */
.resources-subject-toggle .resources-subject-text,
.resources-subject-text {
  min-width: 0 !important;
  width: 100% !important;
  color: var(--resource-text) !important;
  font-size: 0.98rem !important;
  font-weight: 900 !important;
  line-height: 1.45 !important;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  text-align: start !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.resources-subject-count-badge {
  min-width: 92px !important;
  max-width: 120px !important;
  min-height: 38px !important;
  padding: 7px 10px !important;
  border-radius: 999px !important;
  white-space: nowrap !important;
  font-size: 0.78rem !important;
  line-height: 1.2 !important;
}

/* Open subject content: clean full area. */
.resources-subject-group.is-open .resources-subject-body {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
  width: 100% !important;
  min-width: 0 !important;
  padding: 14px !important;
  border-top: 1px dashed rgba(var(--resource-accent-rgb), 0.22) !important;
}

.resources-subject-group.is-open .resources-resource-state {
  grid-column: 1 / -1 !important;
}

.resources-semester-section {
  min-width: 0 !important;
  width: 100% !important;
}

.resources-semester-lessons {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 10px !important;
}

.resources-semester-lessons > .resources-resource-card {
  width: 100% !important;
  min-width: 0 !important;
}

/* Smaller desktop/tablet: one subject per row to preserve title width. */
@media (max-width: 1180px) {
  .resources-level-card--accordion .resources-level-body,
  .resources-level-card--accordion.is-open .resources-level-body,
  .resources-level-card--accordion:not(.is-open) .resources-level-body {
    grid-template-columns: 1fr !important;
  }

  .resources-subject-group.is-open .resources-subject-body {
    grid-template-columns: 1fr !important;
  }
}

/* Phones: badge under subject button, everything full-width. */
@media (max-width: 640px) {
  .resources-level-card--accordion .resources-level-body,
  .resources-level-card--accordion.is-open .resources-level-body,
  .resources-level-card--accordion:not(.is-open) .resources-level-body {
    padding: 10px !important;
    gap: 10px !important;
  }

  .resources-subject-group--accordion .resources-subject-head,
  .resources-subject-head {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
  }

  .resources-subject-toggle,
  .resources-subject-link--header.resources-subject-toggle {
    grid-template-columns: 40px minmax(0, 1fr) 30px !important;
    min-height: 56px !important;
    gap: 10px !important;
    padding: 9px 10px !important;
  }

  .resources-subject-icon {
    width: 40px !important;
    height: 40px !important;
  }

  .resources-subject-arrow {
    width: 30px !important;
    height: 30px !important;
  }

  .resources-subject-count-badge {
    width: 100% !important;
    max-width: none !important;
    justify-content: center !important;
  }

  .resources-subject-toggle .resources-subject-text,
  .resources-subject-text {
    font-size: 0.94rem !important;
  }
}

/* ============================================================
   FINAL OVERRIDE — horizontal semesters + slim lesson cards
   ------------------------------------------------------------
   Keep Semestre/Dawra 1 and 2 in two horizontal sections on PC,
   but stop the smaller semester box from stretching to the taller one.
   Lesson cards are slimmer and easier to scan.
   ============================================================ */

@media (min-width: 769px) {
  .resources-subject-group.is-open .resources-subject-body {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
    align-items: start !important;
    align-content: start !important;
  }
}

@media (max-width: 768px) {
  .resources-subject-group.is-open .resources-subject-body {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: start !important;
  }
}

.resources-semester-section {
  align-self: start !important;
  align-content: start !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 10px !important;
  gap: 9px !important;
  border-radius: 16px !important;
}

.resources-semester-head {
  min-height: 44px !important;
  padding: 7px 10px !important;
  gap: 9px !important;
  border-radius: 14px !important;
}

.resources-semester-icon {
  width: 28px !important;
  height: 28px !important;
  border-radius: 10px !important;
  font-size: 0.78rem !important;
  box-shadow: none !important;
}

.resources-semester-title {
  font-size: 0.94rem !important;
  line-height: 1.3 !important;
}

.resources-semester-count {
  padding: 4px 8px !important;
  font-size: 0.72rem !important;
  line-height: 1.1 !important;
}

.resources-semester-lessons {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
  align-items: start !important;
}

.resources-semester-lessons > .resources-resource-card,
.resources-semester-lessons .resources-resource-card {
  padding: 8px 9px !important;
  gap: 7px !important;
  border-radius: 14px !important;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.045) !important;
}

.resources-semester-lessons .resources-resource-card-toggle {
  min-height: 38px !important;
  gap: 8px !important;
  align-items: center !important;
}

.resources-semester-lessons .resources-resource-card-index {
  min-width: 28px !important;
  height: 28px !important;
  padding: 0 8px !important;
  border-radius: 10px !important;
  font-size: 0.76rem !important;
}

.resources-semester-lessons .resources-resource-card-title {
  font-size: 0.86rem !important;
  line-height: 1.35 !important;
  font-weight: 900 !important;
}

.resources-semester-lessons .resources-resource-card-chevron {
  width: 28px !important;
  height: 28px !important;
  font-size: 0.74rem !important;
}

.resources-semester-lessons .resources-resource-panel,
.resources-semester-lessons .resources-resource-panel--accordion {
  border-radius: 13px !important;
}

.resources-semester-lessons .resources-resource-card.is-open .resources-resource-panel--accordion {
  margin-top: 7px !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

.resources-semester-lessons .resources-resource-entry {
  min-height: 38px !important;
  padding: 7px 9px !important;
  border-radius: 12px !important;
}

.resources-semester-lessons .resources-resource-entry-text {
  font-size: 0.82rem !important;
  line-height: 1.35 !important;
}

/* ============================================================
   09) Secondary / Lycée stream layer
   Structure: Level → Stream/Filière → Subject → Semesters → Resources.
   This is scoped to resources pages only and does not affect global pages.
   ------------------------------------------------------------ */
.resources-level-card--secondary .resources-level-body {
  gap: 16px;
}

.resources-stream-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px 16px 16px;
}

.resources-stream-section {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.22);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(var(--resource-accent-rgb), 0.055), transparent 58%),
    rgba(255, 255, 255, 0.62);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
}

.resources-stream-section::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--resource-accent), var(--resource-accent-dark));
}

html.dark-mode .resources-stream-section {
  background:
    linear-gradient(180deg, rgba(var(--resource-accent-rgb), 0.12), transparent 62%),
    rgba(15, 23, 42, 0.64);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
}

.resources-stream-head {
  position: relative;
  z-index: 1;
  padding: 14px;
}

.resources-stream-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--resource-text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

html.dark-mode .resources-stream-toggle {
  background: rgba(255, 255, 255, 0.055);
}

.resources-stream-toggle:hover,
.resources-stream-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--resource-accent-rgb), 0.42);
  background: var(--resource-soft-strong);
  outline: none;
}

.resources-stream-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--resource-accent), var(--resource-accent-dark));
  box-shadow: 0 10px 20px rgba(var(--resource-accent-rgb), 0.22);
}

.resources-stream-title-wrap {
  display: grid;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.resources-stream-title {
  color: var(--resource-text);
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.resources-stream-subtitle {
  color: var(--resource-muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.resources-stream-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.resources-stream-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  border-radius: 999px;
  color: var(--resource-accent-dark);
  background: var(--resource-soft);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
}

html.dark-mode .resources-stream-count {
  color: #fff;
}

.resources-stream-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--resource-accent);
  background: rgba(var(--resource-accent-rgb), 0.10);
  border: 1px solid rgba(var(--resource-accent-rgb), 0.20);
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.resources-stream-section.is-open .resources-stream-arrow {
  transform: rotate(180deg);
  color: #fff;
  background: var(--resource-accent);
}

.resources-stream-body {
  display: grid;
  gap: 14px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding: 0 14px;
  pointer-events: none;
  will-change: max-height, opacity;
  transition:
    max-height 0.22s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.16s ease,
    padding-top 0.16s ease,
    padding-bottom 0.16s ease;
}

.resources-stream-section.is-open .resources-stream-body {
  padding-top: 0;
  padding-bottom: 14px;
  opacity: 1;
  pointer-events: auto;
}

.resources-stream-body .resources-subject-group {
  margin: 0;
}

@media (min-width: 1100px) {
  .resources-stream-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resources-stream-section.is-open {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .resources-stream-stack {
    padding: 12px 14px 14px;
    gap: 12px;
  }

  .resources-stream-head {
    padding: 12px;
  }

  .resources-stream-toggle {
    align-items: flex-start;
    gap: 10px;
    padding: 10px 11px;
    border-radius: 16px;
  }

  .resources-stream-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .resources-stream-right {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .resources-stream-count {
    min-width: 0;
    min-height: 28px;
    padding: 5px 8px;
    font-size: 0.72rem;
  }

  .resources-stream-arrow {
    width: 30px;
    height: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resources-stream-body,
  .resources-stream-arrow,
  .resources-stream-toggle {
    transition: none !important;
  }
}



/* ============================================================
   Breadcrumb stage link polish
   Stage segment (الإبتدائي / الإعدادي / التأهيلي) is now clickable.
   ============================================================ */
.resources-breadcrumb a.resources-crumb-stage {
  color: inherit;
  font-weight: 700;
}

.resources-breadcrumb a.resources-crumb-stage:hover,
.resources-breadcrumb a.resources-crumb-stage:focus-visible {
  color: var(--resource-accent);
}


/* ============================================================
   11) Secondary full-path upgrade: ordinary / international / professional
   Faster accordions + clearer stream cards.
   ------------------------------------------------------------ */
.resources-level-card--secondary {
  border-radius: 24px;
  overflow: hidden;
}

.resources-level-card--secondary .resources-level-head {
  background:
    linear-gradient(135deg, rgba(var(--resource-accent-rgb), 0.08), transparent 70%),
    var(--resource-card);
}

.resources-level-card--secondary .resources-level-toggle,
.resources-stream-toggle {
  -webkit-tap-highlight-color: transparent;
}

.resources-level-card--secondary .resources-level-body,
.resources-stream-body {
  transition:
    max-height 0.14s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.10s ease,
    padding-top 0.10s ease,
    padding-bottom 0.10s ease !important;
}

.resources-stream-section {
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(var(--resource-accent-rgb), 0.055), transparent 64%),
    var(--resource-card);
}

.resources-stream-section[data-stream-group="international"] {
  border-color: rgba(37, 99, 235, 0.20);
}

.resources-stream-section[data-stream-group="professional"] {
  border-color: rgba(22, 163, 74, 0.22);
}

.resources-stream-section[data-stream-group="international"]::before {
  background: linear-gradient(90deg, #2563eb, var(--resource-accent));
}

.resources-stream-section[data-stream-group="professional"]::before {
  background: linear-gradient(90deg, #16a34a, var(--resource-accent));
}

.resources-stream-toggle {
  min-height: 68px;
  padding-block: 12px;
}

.resources-stream-title {
  font-size: 0.98rem;
}

.resources-stream-subtitle {
  font-size: 0.80rem;
}

.resources-stream-right {
  gap: 6px;
}

.resources-stream-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(var(--resource-accent-rgb), 0.18);
  border-radius: 999px;
  color: var(--resource-accent-dark);
  background: rgba(var(--resource-accent-rgb), 0.09);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

html.dark-mode .resources-stream-group {
  color: #fff;
  background: rgba(var(--resource-accent-rgb), 0.16);
}

.resources-stream-section[data-stream-group="international"] .resources-stream-group {
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.20);
  background: rgba(37, 99, 235, 0.09);
}

.resources-stream-section[data-stream-group="professional"] .resources-stream-group {
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.22);
  background: rgba(22, 163, 74, 0.10);
}

html.dark-mode .resources-stream-section[data-stream-group="international"] .resources-stream-group,
html.dark-mode .resources-stream-section[data-stream-group="professional"] .resources-stream-group {
  color: #fff;
}

@media (min-width: 1180px) {
  .resources-level-card--secondary.is-open {
    grid-column: 1 / -1;
  }

  .resources-level-card--secondary .resources-stream-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .resources-stream-toggle {
    min-height: 62px;
    gap: 8px;
  }

  .resources-stream-icon {
    width: 38px;
    height: 38px;
    border-radius: 13px;
  }

  .resources-stream-right {
    flex-direction: column;
    align-items: flex-end;
  }

  html[dir="ltr"] .resources-stream-right {
    align-items: flex-start;
  }

  .resources-stream-group {
    font-size: 0.64rem;
    padding: 3px 7px;
  }
}
