/* ─── CHARLY.CASH · SHARED STYLES ─────────────────────────── */
/* Google Fonts loaded via <link> in each HTML for better performance */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #030507;
  --bg-2:     #06090d;
  --bg-card:  #090d12;
  --bg-hover: #0d1520;
  --border:   rgba(74,222,128,.1);
  --border-2: rgba(74,222,128,.22);
  --green:    #4ade80;
  --green-d:  #30b060;
  --green-gl: rgba(74,222,128,.07);
  --red:      #ff2244;
  --blue:     #00b4ff;
  --text:     #e8f5e0;
  --text-2:   #a8ccb4;
  --text-3:   #6a9478;
  --mono:     'JetBrains Mono', 'Courier New', monospace;
  --sans:     'Inter', system-ui, sans-serif;
  --max-w:    1060px;
  --radius:   6px;
  --header-h: 56px;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

::selection { background: rgba(74,222,128,.2); color: #d8f0d0; }

body {
  font-family: var(--sans);
  font-size: 17px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Global dot-grid background — overridden per-page */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(74,222,128,.028) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* Scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,.07) 0px,
    rgba(0,0,0,.07) 1px,
    transparent 1px,
    transparent 3px
  );
}

a { color: inherit; text-decoration: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 28px; }
.mono { font-family: var(--mono); }

/* ── READING PROGRESS BAR ── */
.progress-bar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: 2px;
  z-index: 200;
  pointer-events: none;
  background: rgba(74,222,128,.06);
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--green);
  box-shadow: 0 0 10px rgba(74,222,128,.5);
  transform-origin: 0 0;
  transform: scaleX(0);
}
@supports (animation-timeline: scroll()) {
  .progress-bar::after {
    animation: read-progress linear both;
    animation-timeline: scroll(root);
  }
  @keyframes read-progress { to { transform: scaleX(1); } }
}

/* ── BACK TO TOP BUTTON ── */
.back-top {
  position: fixed;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  cursor: pointer;
}
.back-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── CURSOR ── */
.cursor {
  display: inline-block;
  width: 9px; height: 1em;
  background: var(--green);
  vertical-align: text-bottom;
  margin-left: 3px;
  animation: blink .9s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── TAG / LABEL ── */
.tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.tag::before { content: '//'; opacity: .45; }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 12px 22px;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-primary {
  border: 1px solid var(--green);
  background: rgba(74,222,128,.08);
  color: var(--green);
}
.btn-ghost {
  border: 1px solid var(--border-2);
  color: var(--text-2);
}

/* ── HEADER ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(3,5,7,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.logo {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.logo-b { color: var(--text-3); font-size: 14px; }

.nav { display: flex; align-items: center; gap: 0; }
.nav a {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text-2);
  padding: 5px 11px;
  border-radius: 4px;
  white-space: nowrap;
  position: relative;
}
.nav a.active { color: var(--green); }
.nav a[href="kurs"] { color: var(--green); border: 1px solid rgba(57,211,83,.25); border-radius: 4px; }
.nav a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 8px;
  right: 8px;
  height: 1px;
  background: var(--green);
  box-shadow: 0 0 6px rgba(74,222,128,.5);
  border-radius: 1px;
}

/* hamburger */
.nav-toggle { display: none; }
.hamburger {
  display: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  cursor: pointer;
  padding: 6px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.hamburger span { display: block; height: 1.5px; background: var(--text-2); border-radius: 2px; transition: transform .25s, opacity .25s; }
.nav-toggle:checked ~ .hamburger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); background: var(--green); }
.nav-toggle:checked ~ .hamburger span:nth-child(2) { opacity: 0; }
.nav-toggle:checked ~ .hamburger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); background: var(--green); }
.nav-toggle:checked ~ .nav { display: flex; }


/* ── NOTE CARD ── */
.note-card {
  border: 1px solid rgba(74,222,128,.18);
  border-left: 2px solid var(--green);
  border-radius: 4px;
  background: rgba(74,222,128,.025);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-family: var(--mono);
}
.note-card-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.note-title { font-size: 12px; font-weight: 700; color: var(--green); margin-bottom: 5px; letter-spacing:.06em; }
.note-text  { font-size: 12px; color: var(--text-2); line-height: 1.75; }

/* ── TERMINAL WINDOW ── */
.terminal {
  border: 1px solid var(--border-2);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
}
.terminal-bar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.win-dot { width: 10px; height: 10px; border-radius: 50%; }
.win-dot.r { background: #ff3b30; }
.win-dot.y { background: #ffcc00; }
.win-dot.g { background: #28cd41; }
.terminal-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  margin-left: 6px;
}
.terminal-body { padding: 28px 32px; }

/* ── PAGE HERO (inner pages) ── */
.page-hero {
  padding: 64px 0 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: relative;
  overflow: hidden;
  animation: hero-in .45s ease both;
}
@keyframes hero-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(74,222,128,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,222,128,.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.page-hero-inner { position: relative; z-index: 1; }
.page-hero-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 18px;
}
.page-hero-path .sep { margin: 0 6px; opacity: .4; }
.page-hero-path a { color: var(--text-3); }
.page-hero-path .cur { color: var(--text-2); }
.page-hero h1 {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  letter-spacing: -.035em;
  color: #d8f0d0;
  line-height: 1.08;
  margin-bottom: 14px;
}
.page-hero-sub {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
  max-width: 540px;
  line-height: 1.85;
}

/* ── ARTICLE LAYOUT ── */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 48px;
  padding: 56px 0 80px;
  align-items: start;
  animation: hero-in .5s .1s ease both;
}
.article-content { min-width: 0; }

/* prose */
.prose h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #d8f0d0;
  margin: 44px 0 14px;
  padding-top: 44px;
  border-top: 1px solid var(--border);
  line-height: 1.2;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.prose p {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.9;
  margin-bottom: 16px;
}
.prose p strong { color: var(--text); font-weight: 700; }
.prose a { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.prose ul, .prose ol {
  margin: 16px 0 20px 0;
  padding-left: 0;
  list-style: none;
}
.prose li {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.8;
  padding: 6px 0 6px 22px;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.prose li:last-child { border-bottom: none; }
.prose ul li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--green);
  font-family: var(--mono);
  font-size: 12px;
  top: 8px;
}
.prose ol { counter-reset: step; }
.prose ol li::before {
  content: counter(step, decimal-leading-zero);
  counter-increment: step;
  position: absolute;
  left: 0;
  color: var(--green);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  top: 9px;
}
.prose .highlight {
  background: rgba(74,222,128,.04);
  border: 1px solid var(--border-2);
  border-left: 2px solid var(--green);
  border-radius: 4px;
  padding: 18px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.8;
  font-family: var(--mono);
}
.prose .highlight strong { color: var(--green); font-weight: 700; }
.prose img {
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 24px 0;
  max-width: 100%;
}

/* article sidebar */
.article-sidebar {}
.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
}
.sidebar-card-head {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 700;
  letter-spacing: .08em;
}
.sidebar-card-body { padding: 16px 14px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.sidebar-link::before {
  content: '›';
  color: var(--text-3);
  flex-shrink: 0;
  line-height: 1;
}
.sidebar-link:last-child { border-bottom: none; }
.sidebar-link.active { color: var(--green); }
.sidebar-link.active::before { color: var(--green); }

/* ── SCROLL-REVEAL ── */
@supports (animation-timeline: view()) {
  .sr {
    animation: sr-fade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 22%;
  }
  @keyframes sr-fade {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ── TERMINAL BUTTONS ── */
.btn-terminal {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 13px 24px;
  border-radius: 4px;
  border: 1px solid var(--green);
  background: rgba(74,222,128,.07);
  color: var(--green);
  cursor: pointer;
}
.btn-terminal-ghost {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 12px 22px;
  border-radius: 4px;
  border: 1px solid var(--border-2);
  color: var(--text-2);
  cursor: pointer;
}

/* ── STATUS STRIP ── */
.status-strip { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.status-item { font-family: var(--mono); font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); flex-shrink: 0; animation: pulse-dot 2.5s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100%{box-shadow:0 0 6px var(--green)} 50%{box-shadow:0 0 14px var(--green), 0 0 28px rgba(74,222,128,.3)} }

/* ── MOBILE TOC (article pages) ── */
.mobile-toc {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  overflow: hidden;
}
.mobile-toc-toggle {
  width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: none;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
  letter-spacing: .1em;
}
.mobile-toc-toggle svg { transition: transform .25s; flex-shrink: 0; }
.mobile-toc.open .mobile-toc-toggle svg { transform: rotate(180deg); }
.mobile-toc-body {
  display: none;
  padding: 8px 16px 14px;
  border-top: 1px solid var(--border);
}
.mobile-toc.open .mobile-toc-body { display: block; }
.mobile-toc-link {
  display: block;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.mobile-toc-link:last-child { border-bottom: none; }


/* ── HOVER (pointer devices only) ── */
@media (hover: hover) {
  /* Transitions — only for devices that support hover */
  .btn { transition: background .15s, box-shadow .15s, border-color .15s, color .15s; }
  .logo { transition: filter .2s; }
  .nav a { transition: color .15s, background .15s; }
  .hamburger { transition: background .15s, border-color .15s; }
  .hamburger span { transition: background .15s; }
  .back-top { transition: border-color .2s, box-shadow .2s; }
  .note-card { transition: background .2s, border-color .2s; }
  .terminal { transition: border-color .2s, box-shadow .2s; }
  .page-hero-path a { transition: color .15s; }
  .prose li { transition: color .15s, padding-left .15s; }
  .prose ul li::before { transition: left .15s; }
  .prose .highlight { transition: background .2s; }
  .prose img { transition: border-color .2s, box-shadow .2s; }
  .sidebar-link { transition: color .15s, padding-left .15s; }
  .sidebar-link::before { transition: color .15s, transform .15s; }
  .btn-terminal { transition: background .15s, box-shadow .15s; }
  .btn-terminal-ghost { transition: border-color .15s, color .15s, background .15s; }
  .mobile-toc-link { transition: color .15s, padding-left .15s; }
  /* Hover effects */
  .back-top:hover { border-color: var(--green); box-shadow: 0 0 20px rgba(74,222,128,.2); }
  .btn-primary:hover { background: rgba(74,222,128,.16); box-shadow: 0 0 24px rgba(74,222,128,.18); }
  .btn-ghost:hover { border-color: rgba(74,222,128,.35); color: var(--green); background: var(--green-gl); }
  .logo:hover { filter: drop-shadow(0 0 8px rgba(74,222,128,.5)); }
  .nav a:hover { color: var(--green); background: var(--green-gl); }
  .nav a[href="kurs"]:hover { border-color: rgba(57,211,83,.6); }
  .hamburger:hover { background: var(--green-gl); border-color: var(--border); }
  .hamburger:hover span { background: var(--green); }
  .note-card:hover { background: rgba(74,222,128,.04); }
  .terminal:hover { border-color: rgba(74,222,128,.3); box-shadow: 0 4px 32px rgba(74,222,128,.05); }
  .page-hero-path a:hover { color: var(--green); }
  .prose a:hover { text-decoration: none; }
  .prose li:hover { color: var(--text); padding-left: 26px; }
  .prose li:hover ul li::before, .prose ul li:hover::before { left: 2px; }
  .prose .highlight:hover { background: rgba(74,222,128,.06); }
  .prose img:hover { border-color: var(--border-2); box-shadow: 0 4px 24px rgba(0,0,0,.4); }
  .sidebar-link:hover { color: var(--green); padding-left: 4px; }
  .sidebar-link:hover::before { color: var(--green); transform: translateX(2px); }
  .btn-terminal:hover { background: rgba(74,222,128,.14); box-shadow: 0 0 24px rgba(74,222,128,.15), inset 0 0 24px rgba(74,222,128,.04); }
  .btn-terminal-ghost:hover { border-color: rgba(74,222,128,.4); color: var(--green); background: var(--green-gl); }
  .mobile-toc-toggle:hover { color: var(--green); }
  .mobile-toc-link:hover { color: var(--green); padding-left: 6px; }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .article-layout { grid-template-columns: 1fr; }
  .article-sidebar { display: none; }
  .mobile-toc { display: block; }
}
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: rgba(3,5,7,.97);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px 16px 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    z-index: 99;
  }
  .nav a { padding: 11px 12px; width: 100%; border-radius: 4px; }
  .nav a.active::after { display: none; }
  .nav-toggle:checked ~ .nav { display: flex; }
}
@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .container { padding: 0 16px; }
  .terminal-body { padding: 20px; }
  .page-hero { padding: 44px 0 36px; }
  .page-hero h1 { font-size: clamp(24px, 7vw, 36px); }
  .article-layout { padding: 36px 0 60px; gap: 32px; }
  .prose h2 { font-size: 18px; }
  .prose p, .prose li { font-size: 14px; }
  .back-top { bottom: 16px; right: 16px; }
}
