/* =====================================================================
   styles.css – shared design rules for the index page and ALL lessons.
   Link it with a RELATIVE path: index.html -> href="styles.css"; a lesson page -> href="../../../styles.css"
   ===================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@500;700;800&display=swap");

/* ---------- Design tokens ---------- */
:root {
  --bg: #f4f8ff;
  --surface: #ffffff;
  --text: #1f2a44;
  --muted: #5b6785;
  --accent: #3d68e8;
  --accent-dark: #2b4bb5;
  --highlight: #ffd166;
  --shadow: 0 6px 18px rgba(31, 42, 68, 0.12);
  --radius: 18px;
}

/* ---------- Grade themes: the class "theme-N" is added automatically (N = grade number) ---------- */
.theme-5  { --accent: #087f63; --accent-dark: #065c48; }  /* green  */
.theme-6  { --accent: #3d68e8; --accent-dark: #2b4bb5; }  /* blue   */
.theme-7  { --accent: #c24a22; --accent-dark: #963816; }  /* orange */
.theme-8  { --accent: #8147d0; --accent-dark: #5f2fa8; }  /* purple */
/* extra colors, used automatically for further grades (9-12) or as a fallback */
.theme-9  { --accent: #b3264f; --accent-dark: #861c3b; }  /* raspberry */
.theme-10 { --accent: #0f7c9a; --accent-dark: #0a5a71; }  /* teal      */
.theme-11 { --accent: #8a6a00; --accent-dark: #664f00; }  /* gold      */
.theme-12 { --accent: #4a5d23; --accent-dark: #364519; }  /* olive     */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 10%, rgba(255, 209, 102, 0.25) 0, transparent 35%),
    radial-gradient(circle at 90% 20%, rgba(6, 214, 160, 0.18) 0, transparent 35%);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a:focus-visible, .btn:focus-visible { outline: 4px solid #ffb703; outline-offset: 3px; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  padding: 18px 20px 14px;
  box-shadow: var(--shadow);
}
.header-inner { max-width: 1000px; margin: 0 auto; }
.header-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.header-logo { font-size: 2.4rem; line-height: 1; }
.header-titles { flex: 1; min-width: 220px; }
.header-class { margin: 0; font-size: 1.7rem; font-weight: 800; line-height: 1.2; }
.header-meta { margin: 2px 0 0; font-size: 1rem; font-weight: 700; }
.header-meta span + span::before { content: "•"; margin: 0 8px; opacity: 0.7; }

.class-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.class-nav a {
  color: #fff; text-decoration: none; font-weight: 800;
  padding: 8px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}
.class-nav a:hover { background: rgba(255, 255, 255, 0.35); }
.class-nav a[aria-current="page"] { background: #fff; color: var(--accent-dark); }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 24px 20px 40px; }
main:focus { outline: none; }
h1.page-title { font-size: 1.7rem; margin: 6px 0 4px; outline: none; }
.page-sub { margin: 0 0 20px; color: var(--muted); font-weight: 600; }

.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 700; font-size: 0.95rem; margin-bottom: 8px; }
.breadcrumb a { color: var(--accent-dark); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--muted); }

/* ---------- Cards and buttons ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card-btn {
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  min-height: 120px; padding: 18px 20px;
  background: var(--surface); color: var(--text); text-decoration: none;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border-bottom: 8px solid var(--accent);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card-btn:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(31, 42, 68, 0.18); }
.card-emoji { font-size: 2.2rem; line-height: 1; }
.card-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1.8rem; font-weight: 800;
}
.card-title { font-size: 1.25rem; font-weight: 800; }
.card-note { font-size: 0.95rem; color: var(--muted); font-weight: 600; }

.intro-box {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 22px; border-left: 8px solid var(--highlight);
}
.intro-box p { margin: 0; font-weight: 600; }

.btn {
  display: inline-block; text-decoration: none; font-weight: 800;
  background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 999px;
  border: 0; font-family: inherit; font-size: 1rem;
}
.btn:hover { background: var(--accent-dark); }
.btn.disabled { background: #d9dfee; color: #55607d; cursor: not-allowed; }
.empty {
  background: var(--surface); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); font-weight: 700; color: var(--muted);
}

/* ---------- Resource list (lesson page in index.html) ---------- */
.resource-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.resource {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 18px; border-left: 8px solid var(--res-color);
}
.resource-icon { font-size: 2rem; }
.resource-name { flex: 1; font-size: 1.1rem; font-weight: 800; }
.resource-name small, .resource-format { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 600; }

/* ---------- Lesson pages (HTML lessons) ---------- */
.lesson-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 30px; border-top: 8px solid var(--accent);
}
.lesson-chapter {
  display: inline-block; margin: 0 0 8px; padding: 4px 14px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 0.95rem; font-weight: 800;
}
.lesson-card h1 { margin: 6px 0 4px; font-size: 2rem; line-height: 1.25; }
.lesson-subtitle { margin: 0 0 22px; font-size: 1.2rem; color: var(--muted); font-weight: 700; }
.lesson-card h2 { margin: 28px 0 8px; font-size: 1.4rem; color: var(--accent-dark); }
.lesson-card p, .lesson-card li { font-size: 1.08rem; }
.lesson-card a { color: var(--accent-dark); font-weight: 700; text-decoration: underline; }
.lesson-card a:hover { text-decoration-thickness: 3px; }
.lesson-card a.btn { color: #fff; text-decoration: none; }
.lesson-card figure { margin: 22px 0; text-align: center; }
.lesson-card figure img {
  max-width: 100%; height: auto; border-radius: 12px;
  border: 3px solid var(--bg); background: #fff;
}
.lesson-card figcaption { margin-top: 8px; font-size: 0.95rem; color: var(--muted); font-style: italic; }
.note {
  margin: 20px 0; padding: 14px 18px; border-radius: 12px;
  background: #fff7e0; border-left: 8px solid var(--highlight);
}
.note p { margin: 0; }

/* ---------- Terminal box for Linux commands ----------
   Usage in a lesson:   <p class="code">cowsay 'Salut'</p>
   More commands:       <p class="code">figlet 'pinguin'<br>cmatrix</p>          */
.code, .lesson-card .code {
  position: relative;
  margin: 10px 0 20px;
  padding: 42px 18px 14px;
  background: #1e1f2e;
  color: #b8f5b0;
  font-family: "Ubuntu Mono", Consolas, "Courier New", monospace;
  font-size: 1.1rem;
  line-height: 1.7;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.code::before {                              /* the bar with three dots and the "Terminal" label */
  content: "Terminal";
  position: absolute; top: 0; left: 0; right: 0;
  height: 30px; line-height: 30px; padding-left: 66px;
  font-family: "Nunito", "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 0.8rem; font-weight: 800; color: #9aa1bd;
  border-radius: 12px 12px 0 0;
  background:
    radial-gradient(circle at 18px 50%, #ff5f57 5px, transparent 6px),
    radial-gradient(circle at 34px 50%, #febc2e 5px, transparent 6px),
    radial-gradient(circle at 50px 50%, #28c840 5px, transparent 6px),
    #2c2e42;
}
.code::selection, .code *::selection { background: #3d68e8; color: #fff; }
pre.code { white-space: pre-wrap; }          /* <pre class="code"> keeps the line breaks as written */

/* ---------- Educational software catalog (software-educational/index.html) ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 0 0 22px; }
.stat {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 18px; border-left: 8px solid var(--accent);
}
.stat-value { display: block; font-size: 2.1rem; font-weight: 800; line-height: 1.1; color: var(--accent-dark); }
.stat-label { font-weight: 700; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 10px; }
.search {
  flex: 1 1 240px; min-width: 0; padding: 10px 18px; border-radius: 999px;
  border: 2px solid #d9dfee; background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 1rem; font-weight: 600;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-btn {
  font-family: inherit; font-size: 0.95rem; font-weight: 800; cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  border: 2px solid var(--accent); background: var(--surface); color: var(--accent-dark);
}
.filter-btn:hover { background: #eef2fd; }
.filter-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.filter-count { opacity: 0.75; }
.search:focus-visible, .filter-btn:focus-visible { outline: 4px solid #ffb703; outline-offset: 2px; }
.result-count { margin: 0 0 4px; color: var(--muted); font-weight: 700; }
.category-title { font-size: 1.35rem; margin: 26px 0 12px; }
.category-count { color: var(--muted); font-size: 1rem; }
.grid-apps { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.app-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; border-bottom: 8px solid var(--accent);
}
.app-head { display: flex; align-items: center; gap: 10px; }
.app-emoji { font-size: 1.9rem; line-height: 1; }
.app-title { margin: 0; font-size: 1.2rem; font-weight: 800; line-height: 1.25; }
.app-desc { margin: 0; color: var(--muted); font-weight: 600; flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.chip { padding: 2px 10px; border-radius: 999px; background: #e8eefc; color: #2b4bb5; font-size: 0.85rem; font-weight: 800; }
.app-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: auto; }
.link-muted { color: var(--accent-dark); font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--muted); font-weight: 600; font-size: 0.9rem; padding: 16px; }

/* ---------- Responsive, motion, print ---------- */
@media (max-width: 560px) {
  .header-class { font-size: 1.35rem; }
  .resource { flex-wrap: wrap; }
  .resource .btn { width: 100%; text-align: center; }
  .lesson-card { padding: 20px 16px; }
  .lesson-card h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .class-nav, .breadcrumb, .toolbar { display: none; }
  body { background: #fff; }
  .site-header, .lesson-card { box-shadow: none; }
  .code, .lesson-card .code { background: #fff; color: #000; border: 2px solid #000; box-shadow: none; }
  .code::before { background: #eee; color: #000; }
}

/* ---------- Grade cards (index page): max 5 per row, the rest wrap onto the next row ---------- */
.grid-grades {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px;
}
.grid-grades .card-btn { align-items: center; text-align: center; min-height: 150px; padding: 18px 10px; }
.grid-grades .card-title { font-size: clamp(1rem, 1.6vw, 1.25rem); overflow-wrap: anywhere; }
.card-missing { opacity: 0.6; cursor: default; }
.card-missing:hover { transform: none; box-shadow: var(--shadow); }
@media (max-width: 900px) {            /* tablets: 3 per row, so the cards never get cramped */
  .grid-grades { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {            /* phones: 2 per row */
  .grid-grades { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-grades .card-btn { min-height: 120px; }
}