/* ─────────────────────────────────────────────────────────────────────────
   site.css — Copsy's public-site design system (home, blog, articles).
   Loaded LAST on article pages, so it also re-points the legacy tokens that
   style.css / pages.css read (--bg, --surface, --accent …). The web
   dashboard inside index.html does not load this file.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --c-bg:        #05060a;
  --c-bg-2:      #080a10;
  --c-surface:   #0c0e15;
  --c-surface-2: #12151e;
  --c-line:      rgba(255, 255, 255, 0.07);
  --c-line-2:    rgba(255, 255, 255, 0.13);
  --c-text:      #eef1f8;
  --c-text-2:    #a9b1c4;
  --c-muted:     #6f778c;
  --c-blue:      #62a8ff;
  --c-indigo:    #7479ff;
  --c-violet:    #a56dff;
  --c-green:     #43dd9b;
  --c-amber:     #f4b54c;
  --grad-brand:  linear-gradient(100deg, #7cbcff 0%, #7479ff 45%, #b27bff 100%);

  --font-sans:  "Geist", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:  "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-accent: "Space Grotesk", "Geist", -apple-system, sans-serif;

  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1180px;
  --nav-h: 64px;

  /* legacy tokens used by style.css / pages.css on article pages */
  --bg:        var(--c-bg);
  --surface:   var(--c-surface);
  --surface2:  var(--c-surface-2);
  --surface3:  #181c27;
  --border:    var(--c-line);
  --border2:   var(--c-line-2);
  --text:      var(--c-text);
  --text2:     var(--c-text-2);
  --muted:     var(--c-muted);
  --accent:    var(--c-blue);
  --accent-h:  #4b93f5;
  --success:   var(--c-green);
  --warn:      var(--c-amber);

  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, video, svg { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: rgba(116, 121, 255, 0.35); color: #fff; }

:focus-visible {
  outline: 2px solid var(--c-blue);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.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;
}

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ── Type ─────────────────────────────────────────────────────────────── */
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--c-muted);
  margin: 0;
}
.accent {
  font-family: var(--font-accent); font-weight: 600;
  letter-spacing: -0.055em;
}
.grad {
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  /* background-clip text can shave the last glyph's overhang */
  padding-inline-end: 0.04em; margin-inline-end: -0.04em;
}
.display {
  font-size: clamp(46px, 7.4vw, 96px); font-weight: 600;
  line-height: 0.97; letter-spacing: -0.045em; margin: 0;
  text-wrap: balance;
}
.display .accent { letter-spacing: -0.06em; }
.h2 {
  font-size: clamp(32px, 4.6vw, 58px); font-weight: 600;
  line-height: 1.02; letter-spacing: -0.038em; margin: 0;
  text-wrap: balance;
}
.h3 { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; margin: 0; }
.lead {
  font-size: clamp(17px, 1.5vw, 20px); line-height: 1.55;
  color: var(--c-text-2); margin: 0; max-width: 56ch; text-wrap: pretty;
}
.muted { color: var(--c-muted); }
.gradient-text { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.mono { font-family: var(--font-mono); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.button {
  --b-bg: rgba(255, 255, 255, 0.06);
  --b-fg: var(--c-text);
  --b-line: var(--c-line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 42px; padding: 0 18px; border-radius: 11px;
  background: var(--b-bg); color: var(--b-fg);
  border: 1px solid var(--b-line);
  font: 600 14.5px/1 var(--font-sans); letter-spacing: -0.01em;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 200ms ease,
              border-color 200ms ease, box-shadow 200ms ease;
}
.button:active { transform: scale(0.97); }
.button-sm { height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; }
.button-lg { height: 52px; padding: 0 24px; border-radius: 13px; font-size: 16px; }
.button-primary {
  --b-bg: #f4f6fb; --b-fg: #07080d; --b-line: transparent;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 8px 30px -8px rgba(116, 121, 255, 0.55);
}
.button-ghost { --b-bg: rgba(255, 255, 255, 0.04); }
@media (hover: hover) and (pointer: fine) {
  .button:hover { --b-bg: rgba(255, 255, 255, 0.1); --b-line: rgba(255, 255, 255, 0.2); }
  .button-primary:hover {
    --b-bg: #ffffff; --b-line: transparent;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 10px 40px -8px rgba(116, 121, 255, 0.8);
  }
}

.link-arrow {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--c-text); text-decoration: none; font-weight: 550; font-size: 15px;
}
.link-arrow .icon { width: 16px; height: 16px; transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .link-arrow:hover .icon { transform: translateX(3px); }
}

/* ── Nav ──────────────────────────────────────────────────────────────── */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(5, 6, 10, 0.62);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color 250ms ease, background-color 250ms ease;
}
.site-nav[data-scrolled="true"] { border-bottom-color: var(--c-line); background: rgba(5, 6, 10, 0.82); }
.site-nav .wrap { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--c-text); text-decoration: none;
  font-weight: 650; font-size: 17px; letter-spacing: -0.03em;
  margin-inline-end: auto;
}
.brand img { width: 26px; height: 26px; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  position: relative;
  display: inline-flex; align-items: center; height: 36px; padding: 0 12px;
  border-radius: 9px; color: var(--c-text-2); text-decoration: none;
  font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em;
  transition: color 200ms ease, background-color 200ms ease;
}
.nav-link[aria-current="page"] { color: var(--c-text); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 1.5px;
  border-radius: 2px; background: var(--grad-brand);
}
@media (hover: hover) and (pointer: fine) {
  .nav-link:hover { color: var(--c-text); background: rgba(255, 255, 255, 0.05); }
}
.nav-cta { margin-inline-start: 8px; }
@media (max-width: 440px) {
  .site-nav .wrap { gap: 6px; }
  .site-nav .brand span { display: none; }
  .nav-link { padding: 0 9px; font-size: 14px; }
  .nav-cta { margin-inline-start: 2px; padding: 0 12px; }
  .nav-cta .nav-cta-long { display: none; }
}
@media (min-width: 441px) { .nav-cta .nav-cta-short { display: none; } }

/* ── Language menu (homepage) ─────────────────────────────────────────── */
.lang { position: relative; }
.lang-btn { gap: 6px; background: transparent; border: 0; font: inherit; cursor: pointer; font-size: 14px; }
.lang-btn .icon { width: 16px; height: 16px; }
.lang-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 60;
  min-width: 196px; padding: 6px; border-radius: 14px;
  background: rgba(16, 19, 27, 0.96); border: 1px solid var(--c-line-2);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  display: grid; gap: 2px;
  opacity: 0; transform: translateY(-4px) scale(0.97); transform-origin: top right;
  visibility: hidden; pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out), visibility 0s linear 150ms;
}
[dir="rtl"] .lang-menu { transform-origin: top left; }
.lang[data-open] .lang-menu {
  opacity: 1; transform: none; visibility: visible; pointer-events: auto;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.lang-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 9px 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--c-text-2); text-align: start;
  font: 500 14px/1.2 var(--font-sans); cursor: pointer;
}
.lang-item[aria-checked="true"] { color: var(--c-text); background: rgba(255, 255, 255, 0.06); }
.lang-item[aria-checked="true"]::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c-green); }
@media (hover: hover) and (pointer: fine) {
  .lang-item:hover { color: var(--c-text); background: rgba(255, 255, 255, 0.08); }
}
@media (max-width: 440px) { .lang-btn [data-lang-label] { display: none; } }
@media (prefers-reduced-motion: reduce) { .lang-menu { transition: none; } }

/* Non-Latin scripts: tight negative tracking hurts CJK and breaks Arabic joining. */
html:is(:lang(ar), :lang(hi), :lang(zh), :lang(ja)) body * { letter-spacing: 0 !important; }
html:is(:lang(ar), :lang(hi)) .display { line-height: 1.15; }
html:is(:lang(ar), :lang(hi)) .h2 { line-height: 1.25; }
/* CJK: break headings between phrases, not inside words, and give them room. */
html:is(:lang(ja), :lang(zh)) :is(.display, .h2, .h3, .post-title) { word-break: auto-phrase; }
html:is(:lang(ja), :lang(zh)) .hero .display { max-width: 9em; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-foot {
  margin-top: clamp(64px, 10vw, 120px);
  border-top: 1px solid var(--c-line);
  background: linear-gradient(180deg, var(--c-bg) 0%, var(--c-bg-2) 100%);
  padding: 56px 0 36px;
  font-size: 14px; color: var(--c-text-2);
}
.foot-grid {
  display: grid; gap: 40px 28px;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(120px, 1fr));
}
@media (max-width: 820px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-about { grid-column: 1 / -1; } }
.foot-about p { margin: 14px 0 20px; max-width: 34ch; line-height: 1.6; }
.foot-col h2 {
  margin: 0 0 14px; font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--c-muted);
}
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.foot-col a { color: var(--c-text-2); text-decoration: none; transition: color 200ms ease; }
@media (hover: hover) and (pointer: fine) { .foot-col a:hover { color: var(--c-text); } }
.foot-base {
  margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--c-line);
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
  font-size: 13px; color: var(--c-muted);
}
.foot-base .mono { font-size: 12px; }
.foot-base [hidden] { display: none; }

.socials { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 18px 0 0; padding: 0; }
.social {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; border: 1px solid var(--c-line-2);
  background: rgba(255, 255, 255, 0.03); color: var(--c-text-2);
  transition: transform 160ms var(--ease-out), color 200ms ease,
              border-color 200ms ease, background-color 200ms ease;
}
.social:active { transform: scale(0.94); }
.brand-icon { width: 17px; height: 17px; fill: currentColor; stroke: none; }
@media (hover: hover) and (pointer: fine) {
  .social:hover {
    color: var(--c-text); border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
  }
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--c-line-2); background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-text-2);
  white-space: nowrap;
}
.badge-amber { color: var(--c-amber); border-color: rgba(244, 181, 76, 0.3); background: rgba(244, 181, 76, 0.08); }
.badge-green { color: var(--c-green); border-color: rgba(67, 221, 155, 0.3); background: rgba(67, 221, 155, 0.08); }

.live-dot {
  position: relative; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c-green); flex: none;
}
.live-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid var(--c-green); opacity: 0;
  animation: live-ring 2.4s var(--ease-out) infinite;
}
@keyframes live-ring {
  0%   { transform: scale(0.5); opacity: 0.7; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── Blog cards (home teaser, blog index, related) ────────────────────── */
.post-card {
  position: relative; display: flex; flex-direction: column;
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--c-surface); border: 1px solid var(--c-line);
  color: inherit; text-decoration: none;
  transition: border-color 250ms ease, transform 300ms var(--ease-out);
}
.post-card:active { transform: scale(0.99); }
.post-cover { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--c-surface-2); }
.post-cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 700ms var(--ease-out), opacity 400ms ease;
}
.post-body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 20px; flex: 1; }
.post-kicker {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--c-blue);
}
.post-title {
  margin: 0; font-size: 18px; font-weight: 600; line-height: 1.28; letter-spacing: -0.02em;
  text-wrap: balance;
}
.post-excerpt { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--c-text-2); }
.post-meta {
  margin-top: auto; padding-top: 6px;
  display: flex; gap: 8px; align-items: center;
  font-size: 12.5px; color: var(--c-muted);
}
@media (hover: hover) and (pointer: fine) {
  .post-card:hover { border-color: var(--c-line-2); }
  .post-card:hover .post-cover img { transform: scale(1.04); }
}

/* ── Reveal on scroll (only when JS runs) ─────────────────────────────── */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 800ms var(--ease-out), transform 800ms var(--ease-out), filter 800ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.js .reveal-blur { filter: blur(6px); }
.js .reveal.is-in { opacity: 1; transform: none; filter: none; }

@media (prefers-reduced-motion: reduce) {
  .js .reveal { transform: none; filter: none; transition: opacity 300ms ease; }
  .live-dot::after { animation: none; }
  .button, .post-card, .post-cover img { transition: none; }
}
