/*
Theme Name: Tektikle
Description: Apple-inspired technical learning platform with MDN-style sidebar, dark/light auto theme, LearnPress integration, and tutorial frame viewer.
Version: 4.0.0
Text Domain: tektikle
*/

/* ============================================================
   APPLE-INSPIRED DESIGN SYSTEM
   Dark theme 8pm–7am, Light theme 7am–8pm (set by JS)
   Follows SF Pro spacing, radius and motion principles
   ============================================================ */

/* ── Light theme (day) ── */
:root,
[data-theme="light"] {
  --bg:           #f5f5f7;
  --bg-card:      #ffffff;
  --bg-elevated:  #f0f0f2;
  --bg-glass:     rgba(255,255,255,0.72);
  --border:       rgba(0,0,0,0.08);
  --border-mid:   rgba(0,0,0,0.12);

  --primary:      #0071e3;
  --primary-dim:  #0077ed;
  --primary-glow: rgba(0,113,227,0.15);
  --accent:       #ff6b35;
  --success:      #34c759;
  --warning:      #ff9f0a;
  --danger:       #ff3b30;
  --purple:       #af52de;
  --teal:         #32ade6;

  --text:         #1d1d1f;
  --text-2:       #424245;
  --muted:        #6e6e73;
  --faint:        #aeaeb2;
  --heading:      #1d1d1f;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-card:  0 2px 8px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.06);

  --nav-bg:       rgba(245,245,247,0.85);
  --topbar-bg:    rgba(255,255,255,0.9);
  --sidebar-bg:   #ffffff;

  --font-mono:    'JetBrains Mono','SF Mono','Fira Code',monospace;
  --font-body:    -apple-system,'SF Pro Display','Helvetica Neue',sans-serif;
  --font-display: -apple-system,'SF Pro Display','Helvetica Neue',sans-serif;

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --radius-xl:    24px;
  --radius-pill:  999px;

  --nav-h:        52px;
  --topbar-h:     40px;
  --sidebar-w:    260px;

  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:     cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --dur:          220ms;
}

/* ── Dark theme (night) ── */
[data-theme="dark"] {
  --bg:           #000000;
  --bg-card:      #1c1c1e;
  --bg-elevated:  #2c2c2e;
  --bg-glass:     rgba(28,28,30,0.72);
  --border:       rgba(255,255,255,0.08);
  --border-mid:   rgba(255,255,255,0.12);

  --primary:      #0a84ff;
  --primary-dim:  #409cff;
  --primary-glow: rgba(10,132,255,0.2);
  --accent:       #ff6b35;
  --success:      #30d158;
  --warning:      #ffd60a;
  --danger:       #ff453a;
  --purple:       #bf5af2;
  --teal:         #5ac8fa;

  --text:         #f5f5f7;
  --text-2:       #d1d1d6;
  --muted:        #8e8e93;
  --faint:        #48484a;
  --heading:      #ffffff;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.6);
  --shadow-card:  0 2px 8px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.06);

  --nav-bg:       rgba(0,0,0,0.85);
  --topbar-bg:    rgba(28,28,30,0.9);
  --sidebar-bg:   #1c1c1e;
}

/* ── Base reset ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background 0.4s var(--ease-out), color 0.4s var(--ease-out);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dim); }

h1,h2,h3,h4,h5,h6 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 600;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 700; }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h3 { font-size: 1.2rem; }
p  { margin-bottom: 1rem; color: var(--text-2); }

code {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  color: var(--primary);
}

pre {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.7;
}

pre code { background: none; border: none; padding: 0; color: var(--text); }
blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.875rem 1.25rem;
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-style: italic;
}

ul,ol { padding-left: 1.5rem; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; margin-bottom: 1.25rem; }
th {
  background: var(--bg-elevated);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.5rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td { padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-2); }

/* ── Site wrapper ── */
.site-wrapper { display: flex; flex-direction: column; min-height: 100vh; }

/* ============================================================
   TOP NAVIGATION — Apple SF-style frosted glass
   ============================================================ */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 600;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  transition: background var(--dur) var(--ease-out),
              box-shadow var(--dur);
}

.site-header.scrolled {
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 1.5rem;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(145deg, var(--primary), var(--purple));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.03em;
}

.logo-text span { color: var(--primary); }

/* Nav links */
.primary-nav { flex: 1; }

.nav-menu {
  display: flex;
  list-style: none;
  gap: 1px;
  padding: 0; margin: 0;
}

.nav-menu li a {
  display: block;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: all var(--dur) var(--ease-out);
  white-space: nowrap;
}

.nav-menu li a:hover,
.nav-menu li.current-menu-item a {
  color: var(--primary);
  background: var(--primary-glow);
}

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Theme toggle button */
.btn-theme {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--dur);
}
.btn-theme:hover { border-color: var(--primary); color: var(--primary); }

.btn-search {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur);
}
.btn-search:hover { border-color: var(--primary); color: var(--primary); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
  text-decoration: none;
}
.btn-primary:hover {
  background: var(--primary-dim);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: transparent;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid var(--primary);
  cursor: pointer;
  transition: all var(--dur);
  text-decoration: none;
}
.btn-outline:hover {
  background: var(--primary-glow);
  color: var(--primary);
}

/* Mobile hamburger */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--muted);
  border-radius: 2px;
  transition: all var(--dur) var(--ease-out);
}
.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px,4px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px,-4px); }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 0.75rem;
  width: 100%;
  font-family: var(--font-body);
  transition: all var(--dur);
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle:hover { border-color: var(--primary); color: var(--primary); }
.sidebar-toggle svg { transition: transform var(--dur) var(--ease-out); }
.sidebar-toggle.active svg { transform: rotate(180deg); }

/* ============================================================
   TOPBAR — Horizontally scrollable topic tabs
   ============================================================ */
.tps-topbar {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 599;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 0.5px solid var(--border);
}

.tps-topbar-inner {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  height: 100%;
  padding: 0 1rem;
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
}
.tps-topbar-inner::-webkit-scrollbar { display: none; }

.tps-tab {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
  letter-spacing: -0.01em;
}
.tps-tab:hover { color: var(--text); background: var(--primary-glow); }
.tps-tab--active { color: var(--primary) !important; border-bottom-color: var(--primary) !important; }

/* ============================================================
   LAYOUT
   ============================================================ */
.site-main {
  margin-top: calc(var(--nav-h) + var(--topbar-h));
  flex: 1;
  display: flex;
}

.site-content-wrap {
  display: flex;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  align-items: flex-start;
}

.main-content-column {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem 4rem;
}

/* Reading progress */
.reading-progress-bar {
  position: fixed;
  top: calc(var(--nav-h) + var(--topbar-h));
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  width: 0%;
  z-index: 598;
  transition: width 80ms linear;
}

/* ============================================================
   SIDEBAR — Apple-style
   ============================================================ */
.tps-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  flex-shrink: 0;
  font-size: 13px;
  background: var(--sidebar-bg);
  border-right: 0.5px solid var(--border);
  position: sticky;
  top: calc(var(--nav-h) + var(--topbar-h));
  max-height: calc(100vh - var(--nav-h) - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 12px 0 24px;
  align-self: flex-start;
  transition: background var(--dur);
}
.tps-sidebar::-webkit-scrollbar { width: 3px; }
.tps-sidebar::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* Sidebar loading */
.tps-loading { display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; }
.tps-skel {
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: tps-shimmer 1.5s ease-in-out infinite;
}
.tps-skel--title { height: 16px; width: 50%; margin-bottom: 4px; }
.tps-skel--short { width: 35%; }

@keyframes tps-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.tps-error { padding: 16px 12px; font-size: 0.78rem; color: var(--muted); }
.tps-retry-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px; padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--dur);
  font-family: var(--font-body);
}
.tps-retry-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Tree */
.tps-tree { padding: 4px 0; }

.tps-header { padding: 0 0 8px 0; margin-bottom: 4px; border-bottom: 0.5px solid var(--border); }
.tps-header__link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--dur);
}
.tps-header__link:hover { background: var(--primary-glow); color: var(--primary); }

.tps-group { margin-bottom: 1px; }

.tps-group__summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur);
}
.tps-group__summary::-webkit-details-marker { display: none; }
.tps-group__summary:hover { background: var(--bg-elevated); }
.tps-group__summary.tps-active { background: var(--primary-glow); }

.tps-caret {
  font-size: 0.48rem;
  color: var(--faint);
  transition: transform var(--dur) var(--ease-out);
  flex-shrink: 0;
}
.tps-group[open] > .tps-group__summary .tps-caret,
.tps-subgroup[open] > .tps-subgroup__summary .tps-caret { transform: rotate(90deg); }

.tps-group__name {
  flex: 1; font-size: 0.8rem; font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: color var(--dur);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tps-group__name:hover { color: var(--primary); }

.tps-count {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--faint);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  margin-left: auto;
}

.tps-items { list-style: none; margin: 0; padding: 2px 0 4px 20px; }
.tps-items--flat { padding-left: 8px; }
.tps-items--nested { padding-left: 14px; }

.tps-item__link {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  transition: all var(--dur);
  cursor: pointer;
}
.tps-item__link:hover { color: var(--text); background: var(--bg-elevated); }

/* Active item — Apple blue highlight */
.tps-item--active .tps-item__link,
.tps-item__link.tps-active {
  color: var(--primary) !important;
  background: var(--primary-glow) !important;
  font-weight: 600;
  border-left: 2px solid var(--primary);
  padding-left: 10px;
}

.tps-item__title { flex: 1; min-width: 0; }
.tps-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.tps-dot--article  { background: var(--primary); }
.tps-dot--tutorial { background: var(--accent); }
.tps-dot--short    { background: var(--success); }
.tps-dot--quiz     { background: var(--warning); }
.tps-dot--course   { background: var(--purple); }

.tps-subgroup { border: none; }
.tps-subgroup__summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
  color: var(--muted);
  transition: all var(--dur);
}
.tps-subgroup__summary::-webkit-details-marker { display: none; }
.tps-subgroup__summary:hover { background: var(--bg-elevated); color: var(--text); }
.tps-subgroup__summary.tps-active { color: var(--primary); }

.tps-empty { font-size: 0.78rem; color: var(--faint); padding: 12px; line-height: 1.6; }

/* ============================================================
   CARDS — Apple-style with frosted glass + vibrant accents
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--dur) var(--ease-spring),
              box-shadow var(--dur),
              border-color var(--dur);
  box-shadow: var(--shadow-card);
}
.card:hover {
  transform: translateY(-3px) scale(1.005);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-mid);
}

.card-thumb { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--bg-elevated); }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease-out); }
.card:hover .card-thumb img { transform: scale(1.06); }

.card-type-badge {
  position: absolute;
  top: 0.625rem; left: 0.625rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
}

.badge-article  { background: rgba(0,113,227,0.85); color: #fff; }
.badge-tutorial { background: rgba(255,107,53,0.85); color: #fff; }
.badge-short    { background: rgba(52,199,89,0.85);  color: #fff; }
.badge-quiz     { background: rgba(255,159,10,0.85); color: #fff; }
.badge-course   { background: rgba(175,82,222,0.85); color: #fff; }

.card-body { padding: 1.125rem; }
.card-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.375rem; }
.card-category { font-size: 0.7rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.06em; }
.card-date { font-size: 0.7rem; color: var(--faint); }
.card-title { font-size: 0.95rem; line-height: 1.4; margin-bottom: 0.5rem; }
.card-title a { color: var(--heading); transition: color var(--dur); }
.card-title a:hover { color: var(--primary); }
.card-excerpt { font-size: 0.82rem; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 0.875rem; }
.card-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 0.625rem; border-top: 0.5px solid var(--border); }
.card-author { display: flex; align-items: center; gap: 6px; font-size: 0.73rem; color: var(--muted); }
.card-author img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.125rem; }

/* ============================================================
   PAGE HERO
   ============================================================ */
.page-hero {
  padding: 1.75rem 0 1.5rem;
  margin-bottom: 1.75rem;
  border-bottom: 0.5px solid var(--border);
}
.page-hero-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 0.625rem;
}
.page-hero h1 { margin-bottom: 0.375rem; }
.page-hero p { color: var(--muted); margin-bottom: 0; }

/* Breadcrumbs */
.breadcrumbs { margin-top: 0.75rem; font-size: 0.75rem; color: var(--faint); }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0; margin: 0; align-items: center; }
.breadcrumbs li+li::before { content: '/'; margin-right: 4px; color: var(--faint); }
.breadcrumbs a { color: var(--muted); transition: color var(--dur); }
.breadcrumbs a:hover { color: var(--primary); }

/* ============================================================
   ENTRY CONTENT
   ============================================================ */
.entry-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-2);
  max-width: 720px;
}
.entry-content h2 {
  color: var(--heading);
  font-size: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 0.5px solid var(--border);
}
.entry-content h3 { color: var(--heading); font-size: 1.1rem; margin-top: 2rem; margin-bottom: 0.5rem; }
.entry-content img { border-radius: var(--radius-md); margin: 1rem auto; box-shadow: var(--shadow-md); }

/* ============================================================
   TUTORIAL FRAME — MDN-style inline reader
   ============================================================ */
.tutorial-layout {
  display: flex;
  height: calc(100vh - var(--nav-h) - var(--topbar-h) - 1px);
  overflow: hidden;
}

.tutorial-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 0.5px solid var(--border);
  background: var(--sidebar-bg);
  /* sidebar is controlled by tps-sidebar styles */
}

.tutorial-frame-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tutorial-frame-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 0.5px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.tutorial-frame-title {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.85rem;
}

.tutorial-frame-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tutorial-frame-nav button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all var(--dur);
  font-family: var(--font-body);
}
.tutorial-frame-nav button:hover { border-color: var(--primary); color: var(--primary); }
.tutorial-frame-nav button:disabled { opacity: 0.3; cursor: not-allowed; }

.tutorial-frame-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted);
  font-size: 0.85rem;
  gap: 10px;
}

.tutorial-frame-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.tutorial-content-frame {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  background: var(--bg);
}

/* ============================================================
   SEARCH OVERLAY
   ============================================================ */
.search-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur), visibility var(--dur);
}
.search-overlay.active { opacity: 1; visibility: visible; }
.search-overlay-inner {
  width: 100%; max-width: 600px;
  padding: 0 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-overlay input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border);
  color: var(--heading);
  font-family: var(--font-body);
  font-size: 1.2rem;
  padding: 1.25rem 1.25rem;
  outline: none;
}
.search-close {
  position: fixed;
  top: 1.5rem; right: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px; height: 36px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur);
}
.search-close:hover { border-color: var(--danger); color: var(--danger); }

/* ============================================================
   LEARNPRESS — theme integration
   ============================================================ */
.learnpress .lp-content,
.single-lp_course .site-main {
  background: var(--bg);
  color: var(--text);
}

.lp-course-curriculum .curriculum-section > .curriculum-section-header,
.lp-course-curriculum .curriculum-section-header {
  background: var(--bg-elevated) !important;
  border: 0.5px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  color: var(--heading) !important;
  font-family: var(--font-display) !important;
}

.lp-button,
.learn-press-checkout-button,
button.lp-button {
  background: var(--primary) !important;
  color: #fff !important;
  border-radius: var(--radius-pill) !important;
  font-family: var(--font-body) !important;
  font-weight: 600 !important;
  border: none !important;
  padding: 10px 22px !important;
  transition: all var(--dur) !important;
  box-shadow: 0 2px 8px var(--primary-glow) !important;
}
.lp-button:hover, .learn-press-checkout-button:hover {
  background: var(--primary-dim) !important;
  transform: translateY(-1px) !important;
}

.lp-course-item-meta { color: var(--muted) !important; }
.learn-press-message { border-radius: var(--radius-md) !important; }
.lp-course-progress-bar { background: var(--primary) !important; border-radius: var(--radius-pill) !important; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 3rem; }
.pagination a, .pagination span {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 0.5px solid var(--border);
  color: var(--muted);
  background: var(--bg-card);
  transition: all var(--dur);
  box-shadow: var(--shadow-sm);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--bg-card);
  border-top: 0.5px solid var(--border);
  padding: 3rem 2rem 1.5rem;
  transition: background var(--dur);
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 3rem; margin-bottom: 2rem; }
.footer-brand p { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; max-width: 260px; }
.footer-col h5 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.875rem; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col ul li { margin-bottom: 0.375rem; }
.footer-col ul li a { font-size: 0.85rem; color: var(--faint); transition: color var(--dur); }
.footer-col ul li a:hover { color: var(--primary); }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 1.25rem;
  border-top: 0.5px solid var(--border);
  font-size: 0.78rem;
  color: var(--faint);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-up { animation: fadeUp 400ms var(--ease-out) both; }
.animate-fade-up:nth-child(2) { animation-delay: 60ms; }
.animate-fade-up:nth-child(3) { animation-delay: 120ms; }
.animate-fade-up:nth-child(4) { animation-delay: 180ms; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .site-content-wrap { flex-direction: column; }
  .tps-sidebar {
    width: 100%;
    min-width: 0;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 0.5px solid var(--border);
    display: none; /* hidden by default, toggled by JS */
  }
  .tps-sidebar.mobile-open { display: block; }
  .sidebar-toggle { display: flex; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .main-content-column { padding: 1.25rem 1.25rem 3rem; }
}

@media (max-width: 768px) {
  :root { --nav-h: 50px; --topbar-h: 36px; }
  .menu-toggle { display: flex; }
  .primary-nav {
    position: fixed;
    top: var(--nav-h); left: 0; right: 0; bottom: 0;
    background: var(--bg);
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease-out);
    z-index: 598;
  }
  .primary-nav.open { transform: translateX(0); }
  .nav-menu { flex-direction: column; gap: 2px; }
  .nav-menu li a { padding: 0.875rem 1rem; font-size: 0.95rem; border-radius: var(--radius-md); }
  .header-actions .btn-outline { display: none; }
  .posts-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .footer-bottom { flex-direction: column; gap: 0.5rem; text-align: center; }
  .tutorial-layout { flex-direction: column; height: auto; }
  .tutorial-frame-wrap { height: 70vh; }
}

@media (max-width: 480px) {
  .main-content-column { padding: 1rem 0.875rem 2.5rem; }
  .tps-tab { padding: 0 10px; font-size: 0.65rem; }
}

/* ── Vibrant gradient accents ── */
.hero-gradient {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 15%, var(--bg)),
    color-mix(in srgb, var(--purple) 10%, var(--bg)));
}
