/* ═══════════════════════════════════════════════════════════
   A/L ICT Hub — shared site chrome
   Top navigation, theme persistence, EN/සිං language switching
   ═══════════════════════════════════════════════════════════ */

/* ── Language switching ──
   Pages mark parallel content with .en / .si blocks.
   html[data-lang] decides which side is visible.
   Pages with Sinhala-only supplements (.si without an .en twin)
   simply hide them in English mode. */
html[data-lang="en"] .si { display: none !important; }
html[data-lang="si"] .en { display: none !important; }

/* ── Background scene (glassmorphism base) ──
   A fixed, softly-blurred gradient "photo" behind every page.
   Pages make their own body background transparent so surfaces
   float over this scene as frosted glass. */
html {
  background:
    radial-gradient(900px 600px at 12% -8%, rgba(0, 212, 170, 0.16), transparent 60%),
    radial-gradient(1100px 700px at 88% 12%, rgba(129, 140, 248, 0.15), transparent 60%),
    radial-gradient(800px 600px at 70% 90%, rgba(249, 115, 22, 0.10), transparent 55%),
    radial-gradient(700px 500px at 25% 70%, rgba(0, 140, 255, 0.08), transparent 55%),
    linear-gradient(180deg, #0b0f16, #0d1117 45%, #0a0e14);
  background-attachment: fixed;
  min-height: 100%;
}

html[data-theme="light"] {
  background:
    radial-gradient(900px 600px at 12% -8%, rgba(0, 158, 130, 0.14), transparent 60%),
    radial-gradient(1100px 700px at 88% 12%, rgba(91, 91, 214, 0.12), transparent 60%),
    radial-gradient(800px 600px at 70% 90%, rgba(217, 96, 11, 0.08), transparent 55%),
    linear-gradient(180deg, #eef2f7, #f6f8fa 45%, #eaeef4);
  background-attachment: fixed;
}

body { background: transparent !important; }

/* ── Top navigation: floating glass pill ── */
#topnav {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  height: 46px;
  /* leave room for the fixed corner controls on both sides */
  max-width: min(1200px, calc(100vw - 300px));
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  background: rgba(13, 17, 23, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.55);
  font-family: 'Sora', 'Noto Sans Sinhala', sans-serif;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

#topnav::-webkit-scrollbar { height: 0; }

html[data-theme="light"] #topnav {
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(13, 27, 42, 0.10);
  box-shadow: 0 12px 30px -16px rgba(40, 50, 70, 0.35);
}

#topnav .tn-brand {
  font-size: 13px;
  font-weight: 800;
  color: #00d4aa;
  letter-spacing: 0.5px;
  margin-right: 14px;
  text-transform: uppercase;
}

html[data-theme="light"] #topnav .tn-brand { color: #009e82; }

#topnav a {
  font-size: 12.5px;
  color: #9aa4b1;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

#topnav a:hover { color: #e6edf3; background: rgba(255, 255, 255, 0.08); }

html[data-theme="light"] #topnav a { color: #5a6473; }
html[data-theme="light"] #topnav a:hover { color: #1f2328; background: rgba(13, 27, 42, 0.07); }

#topnav a.tn-active {
  color: #06211b;
  background: #00d4aa;
  font-weight: 600;
  box-shadow: 0 6px 18px -8px rgba(0, 212, 170, 0.7);
}

html[data-theme="light"] #topnav a.tn-active {
  background: #009e82;
  color: #ffffff;
  box-shadow: 0 6px 18px -8px rgba(0, 158, 130, 0.6);
}

/* ── Language + theme: fixed cluster in the top-right corner ──
   Mirrors the sidebar toggle in the top-left, so the nav pill keeps
   page links only. */
#tnCtrls {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 2100;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Sora', 'Noto Sans Sinhala', sans-serif;
}

.tn-ctrl {
  height: 40px;
  min-width: 40px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  color: #9aa4b1;
  background: rgba(13, 17, 23, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 4px 16px -6px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.tn-ctrl.tn-icon { padding: 0; font-size: 17px; }

/* account chip (top-right): logged-in name + a green status dot */
a#tnLogin { text-decoration: none; }
#tnAccount { display: flex; gap: 8px; }
#tnUser { gap: 7px; cursor: default; max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#tnUser:hover { color: #9aa4b1; border-color: rgba(255,255,255,0.12); background: rgba(13,17,23,0.6); box-shadow: 0 4px 16px -6px rgba(0,0,0,0.5); }
html[data-theme="light"] #tnUser:hover { color: #5a6473; }
.tn-udot { width: 8px; height: 8px; border-radius: 50%; background: #3fb950; box-shadow: 0 0 8px rgba(63,185,80,0.7); flex: none; }

.tn-ctrl:hover {
  color: #00d4aa;
  border-color: rgba(0, 212, 170, 0.4);
  background: rgba(0, 212, 170, 0.12);
  box-shadow: 0 4px 20px -6px rgba(0, 212, 170, 0.3);
}

html[data-theme="light"] .tn-ctrl {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(13, 27, 42, 0.12);
  color: #5a6473;
  box-shadow: 0 4px 16px -6px rgba(40, 50, 70, 0.25);
}

html[data-theme="light"] .tn-ctrl:hover {
  color: #009e82;
  border-color: rgba(0, 158, 130, 0.4);
  background: rgba(0, 158, 130, 0.1);
}

/* A page's own in-sidebar theme button is superseded by the corner control. */
#themeBtn { display: none !important; }

/* ── Sidebar toggle: fixed top-left corner button ── */
#tnSide {
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 2100;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(13, 17, 23, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #9aa4b1;
  box-shadow: 0 4px 16px -6px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
  font-family: inherit;
  padding: 0;
}
#tnSide:hover {
  color: #00d4aa;
  border-color: rgba(0, 212, 170, 0.4);
  background: rgba(0, 212, 170, 0.12);
  box-shadow: 0 4px 20px -6px rgba(0, 212, 170, 0.3);
}
#tnSide.is-on {
  color: #06211b;
  background: #00d4aa;
  border-color: #00d4aa;
  box-shadow: 0 4px 20px -6px rgba(0, 212, 170, 0.5);
}

html[data-theme="light"] #tnSide {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(13, 27, 42, 0.12);
  color: #5a6473;
  box-shadow: 0 4px 16px -6px rgba(40, 50, 70, 0.25);
}
html[data-theme="light"] #tnSide:hover {
  color: #009e82;
  border-color: rgba(0, 158, 130, 0.4);
  background: rgba(0, 158, 130, 0.1);
}
html[data-theme="light"] #tnSide.is-on {
  color: #fff;
  background: #009e82;
  border-color: #009e82;
}

/* ── WhatsApp call-to-action ──
   Floats bottom-right on every page. The pages' own "back to top" button is
   pushed above it so the two never overlap. */
#socialFab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2200;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: gap 0.25s ease;
}

#socialFab a {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease,
              opacity 0.25s ease, max-width 0.3s ease, padding 0.25s ease, margin 0.25s ease;
  overflow: hidden;
}

#waFab {
  gap: 9px;
  padding: 13px 18px;
  border-radius: 999px;
  background: #25D366;
  color: #06211b;
  font-family: 'Sora', 'Noto Sans Sinhala', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 10px 28px -8px rgba(37, 211, 102, 0.55);
  max-width: 300px;
}

#waFab:hover {
  background: #1ebe5b;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -8px rgba(37, 211, 102, 0.7);
}

#fbFab {
  width: 48px;
  height: 48px;
  justify-content: center;
  border-radius: 999px;
  background: #1877F2;
  color: #fff;
  box-shadow: 0 10px 28px -8px rgba(24, 119, 242, 0.55);
  max-width: 48px;
}

#fbFab:hover {
  background: #0f63d2;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -8px rgba(24, 119, 242, 0.7);
}

#socialFab svg { flex: none; }

/* ── Social FAB: toggle button ── */
#socialToggle {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  order: 10; /* always last (right-most) in the row */
}

/* ── Social FAB: hidden state ── */
#socialFab.social-hidden {
  gap: 0;
}
#socialFab.social-hidden a {
  max-width: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

/* on narrow screens the WhatsApp pill collapses to a round icon button */
@media (max-width: 700px) {
  #socialFab { gap: 8px; right: 16px; bottom: 16px; }
  #waFab { padding: 14px; gap: 0; }
  #waFab .wa-label { display: none; }
  #fbFab { width: 42px; height: 42px; max-width: 42px; }
  #socialToggle { width: 36px; height: 36px; min-width: 36px; font-size: 14px; }
}

/* keep the pages' back-to-top button clear of the WhatsApp button */
.back-to-top { bottom: 92px !important; }

/* ── Collapsible side menu ──
   Toggled by the ☰ button in the nav; class lives on <html> so it applies
   before paint. Covers both sidebar layouts: #sidebar (flex pages) and
   .wrap > aside (the lab's grid). */

/* Sidebar base transition */
#sidebar {
  transition: width 0.3s ease, min-width 0.3s ease, opacity 0.25s ease,
              padding 0.3s ease, transform 0.3s ease;
}
body > .wrap > aside {
  transition: width 0.3s ease, min-width 0.3s ease, opacity 0.25s ease,
              padding 0.3s ease, transform 0.3s ease;
}

/* Desktop collapsed: shrink to zero */
html.side-collapsed #sidebar {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  padding: 0 !important;
  margin: 0 !important;
  border-width: 0 !important;
  overflow: hidden;
  pointer-events: none;
}
html.side-collapsed .wrap { grid-template-columns: 1fr !important; }
html.side-collapsed .wrap > aside {
  display: none;
}

/* ── Mobile: sidebar becomes a slide-over overlay ── */
@media (max-width: 900px) {
  /* Override pages' own `display:none` at 768px so the toggle works */
  #sidebar,
  body > .wrap > aside {
    display: flex !important;
    flex-direction: column;
    position: fixed !important;
    top: 0 !important;
    left: 0;
    z-index: 3000;
    width: 300px !important;
    min-width: 0 !important;
    max-width: 85vw;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 18px 18px 0 !important;
    transform: translateX(0);
    opacity: 1;
    overflow-y: auto;
    padding-top: 60px !important;
  }

  /* When collapsed on mobile: slide off-screen */
  html.side-collapsed #sidebar,
  html.side-collapsed .wrap > aside {
    display: flex !important;
    transform: translateX(-110%) !important;
    opacity: 0 !important;
    pointer-events: none;
    width: 300px !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Unified page shell
   Every page adopts the Programming Lab's structure: a 288px
   sidebar with a brand block and pill nav, and a centred content
   column headed by a rounded hero card.
   ═══════════════════════════════════════════════════════════ */

/* ── Sidebar (Comp pages use #sidebar; the lab uses .wrap > aside) ── */
#sidebar {
  width: 288px !important;
  min-width: 288px !important;
  padding: 6px 16px 40px;
}

#sidebar .sidebar-header {
  padding: 20px 4px 0 !important;
  border-bottom: 0 !important;
  background: transparent !important;
  position: static !important;
}
#sidebar .sidebar-header h2 { font-size: 15px; letter-spacing: 0.5px; }
#sidebar .sidebar-header p { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; }

#sidebar .sidebar-search { padding: 16px 4px 4px !important; border-bottom: 0 !important; }
#sidebar .sidebar-search input { border-radius: 10px; padding: 9px 12px; }

#sidebar .nav-section { padding: 4px 4px 20px; }

#sidebar .nav-group-title {
  padding: 0 4px 8px;
  margin-top: 24px;
  font-size: 10px;
  letter-spacing: 2.2px;
  color: #00d4aa;
}
html[data-theme="light"] #sidebar .nav-group-title { color: #009e82; }

#sidebar .nav-item {
  padding: 8px 12px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12.8px;
}
#sidebar .nav-item.sub  { padding-left: 12px; }
#sidebar .nav-item.sub2 { padding-left: 26px; font-size: 12.2px; }
#sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.07); }
#sidebar .nav-item.active {
  color: #0d1117;
  background: #00d4aa;
  border-color: #00d4aa;
  font-weight: 700;
}
html[data-theme="light"] #sidebar .nav-item.active { background: #009e82; color: #fff; }

/* ── Main column: hero card, pill stats, centred content ── */
@media (min-width: 900px) {
  /* the column breathes away from the sidebar, exactly as the lab's main does
     (!important because the pages declare #main padding after this file) */
  #main { padding-left: 48px !important; padding-right: 48px !important; }

  #main .page-header,
  #main .stats-bar,
  #main .content-area {
    max-width: 944px;
    margin-left: auto;
    margin-right: auto;
  }

  #main .page-header {
    position: relative;
    overflow: hidden;
    margin-top: 46px;
    padding: 40px 42px !important;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 22px;
  }

  /* faint grid wash, matching the lab's hero */
  #main .page-header::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(400px 300px at 90% 10%, #000, transparent);
    -webkit-mask-image: radial-gradient(400px 300px at 90% 10%, #000, transparent);
  }
  #main .page-header > * { position: relative; z-index: 1; }

  #main .stats-bar {
    margin-top: 22px;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    gap: 10px;
  }
  #main .stats-bar .stat {
    padding: 8px 15px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 30px;
    background: rgba(20, 26, 34, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  html[data-theme="light"] #main .stats-bar .stat {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(13, 27, 42, 0.10);
  }

  #main .content-area {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 44px;
    padding-bottom: 120px;
  }
}

/* Grid/flex items default to min-width:auto, which lets wide flowcharts and
   code panes stretch the whole page instead of scrolling inside themselves. */
.wrap > main,
#main { min-width: 0; }

/* Grid transition for programming lab page */
.wrap {
  transition: grid-template-columns 0.3s ease;
}
#main, .wrap > main {
  transition: margin 0.3s ease;
}
.content-area {
  transition: margin 0.3s ease;
}

/* ── Page offsets for the floating bar ── */
body { padding-top: 66px !important; }

/* Sticky sidebars start below the bar */
#sidebar,
body > .wrap > aside {
  top: 66px !important;
  height: calc(100vh - 66px) !important;
}

@media (max-width: 900px) {
  body > .wrap > aside { height: auto !important; }
}

/* Below this width the pill cannot sit beside both corner control clusters
   without clipping, so it drops onto its own row underneath them. */
@media (max-width: 980px) {
  #topnav { top: 60px; max-width: calc(100vw - 20px); }
  body { padding-top: 112px !important; }
  #sidebar { top: 112px !important; height: calc(100vh - 112px) !important; }
  body > .wrap > aside { top: 112px !important; }
  [id] { scroll-margin-top: 128px !important; }
}

/* Anchored sections scroll to below the bar */
[id] { scroll-margin-top: 82px !important; }

/* Reading-progress strips stick to the very top (the bar floats) */
/* (the reading-progress strip was removed from the pages; rule kept out) */

/* ── Frosted-glass surfaces ──
   The major panels of every page become translucent glass over the
   background scene. Code editors, consoles and tables keep their own
   solid backgrounds for readability. */
#sidebar,
.page-header,
body > .wrap > aside,
.hero,
.card,
.note,
.nav button:not(.active),
.anno-btn:not(.sel) {
  background: rgba(20, 26, 34, 0.55) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* borders soften on the big containers (notes keep their accent stripe) */
#sidebar, .page-header, body > .wrap > aside, .hero, .card {
  border-color: rgba(255, 255, 255, 0.09) !important;
}

.card, .hero, .note { box-shadow: 0 16px 40px -24px rgba(0, 0, 0, 0.55); }

/* ── Side menu: floating glass panel ──
   The left menu detaches from the page edge and reads as real frosted glass:
   a deeper blur, a rim highlight along the top edge and a soft drop shadow. */
#sidebar,
body > .wrap > aside {
  margin: 0 0 14px 14px;
  height: calc(100vh - 80px) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(18, 24, 32, 0.52) 42%) !important;
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    0 24px 60px -28px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

html[data-theme="light"] #sidebar,
html[data-theme="light"] body > .wrap > aside {
  border-color: rgba(13, 27, 42, 0.10) !important;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.55) 42%) !important;
  box-shadow:
    0 24px 55px -30px rgba(40, 50, 70, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

/* slim, unobtrusive scrollbar inside the glass */
#sidebar::-webkit-scrollbar,
body > .wrap > aside::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb,
body > .wrap > aside::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

@media (max-width: 900px) {
  #sidebar,
  body > .wrap > aside {
    margin: 0;
    border-radius: 0;
    height: auto !important;
  }
}

/* tables get a light tint (no blur — cheap and readable over the scene) */
table { background: rgba(15, 20, 27, 0.5); }
html[data-theme="light"] table { background: rgba(255, 255, 255, 0.55); }

/* the side menu is excluded here — it has its own glass panel treatment above */
html[data-theme="light"] .page-header,
html[data-theme="light"] .hero,
html[data-theme="light"] .card,
html[data-theme="light"] .note,
html[data-theme="light"] .nav button:not(.active),
html[data-theme="light"] .anno-btn:not(.sel) {
  background: rgba(255, 255, 255, 0.62) !important;
}

html[data-theme="light"] #sidebar,
html[data-theme="light"] .page-header,
html[data-theme="light"] body > .wrap > aside,
html[data-theme="light"] .hero,
html[data-theme="light"] .card {
  border-color: rgba(13, 27, 42, 0.10) !important;
}

html[data-theme="light"] .card,
html[data-theme="light"] .hero,
html[data-theme="light"] .note { box-shadow: 0 16px 36px -26px rgba(40, 50, 70, 0.4); }

/* ── Sidebar backdrop overlay (mobile) ──
   A dark scrim behind the open sidebar on small screens.
   Injected by site.js, shown only when the sidebar is visible. */
#sideBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2999;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#sideBackdrop.show {
  display: block;
  opacity: 1;
}

/* ── Mobile-specific refinements ── */
@media (max-width: 600px) {
  /* Top controls: tighter spacing */
  #tnCtrls { right: 10px; top: 10px; gap: 6px; }
  #tnSide  { left: 10px;  top: 10px; }
  .tn-ctrl { height: 36px; min-width: 36px; padding: 0 10px; font-size: 11.5px; }
  .tn-ctrl.tn-icon { font-size: 15px; }

  /* Nav pill: full-width below controls */
  #topnav {
    max-width: calc(100vw - 16px) !important;
    height: 40px;
    font-size: 11px;
    padding: 0 6px;
  }
  #topnav .tn-brand { font-size: 11px; margin-right: 8px; }
  #topnav a { padding: 5px 10px; font-size: 11px; }

  /* Content pages: tighter padding */
  .content-area { padding: 20px 16px !important; }
  .page-header { padding: 24px 16px !important; }
  .stats-bar { padding: 12px 16px !important; gap: 16px !important; }
  .page-header h1 { font-size: 22px !important; }

  /* Index page */
  .container { padding: 20px 12px 80px !important; }
  .hero { padding: 22px 16px !important; border-radius: 14px !important; }
  .grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .cta-row { grid-template-columns: 1fr !important; }

  /* Tables scroll horizontally */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Normalization page grids */
  .grid2, .grid3 { grid-template-columns: 1fr !important; }
}

/* Tablets (600-900px) */
@media (min-width: 601px) and (max-width: 900px) {
  .content-area { padding: 32px 24px !important; }
  .page-header { padding: 32px 24px !important; }
  .stats-bar { padding: 14px 24px !important; }
}
