/* NepLang website. Palette from the flag of Nepal: crimson field, blue border.
   One bold element per page (the keyword wall on the home page, the editor on the
   playground); everything else stays quiet. */

:root {
  --crimson: #dc143c;
  --crimson-ink: #b0102f;      /* crimson that passes contrast as text on snow */
  --blue: #003893;
  --ink: #0e1b3d;
  --muted: #4a5a7d;
  --mist: #d9e1ef;
  --snow: #f5f7fb;
  --paper: #ffffff;
  --code-bg: #0e1b3d;
  --code-fg: #e8edf8;
  --code-dim: #8b9bc0;
  --code-kw: #ff6b86;
  --code-str: #9fd6a8;
  --code-num: #ffc46b;
  --code-fn: #8cb8ff;
  --code-type: #c9a6ff;
  --focus: #ffb000;

  --font: "Mukta", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --measure: 68ch;
  --radius-s: 4px;
  --radius-m: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --crimson-ink: #ff5c7a;
    --blue: #8cb0ff;
    --ink: #e8edf8;
    --muted: #a3b1d1;
    --mist: #26375f;
    --snow: #08132e;
    --paper: #0d1a3b;
    --code-bg: #050d22;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --crimson-ink: #ff5c7a;
  --blue: #8cb0ff;
  --ink: #e8edf8;
  --muted: #a3b1d1;
  --mist: #26375f;
  --snow: #08132e;
  --paper: #0d1a3b;
  --code-bg: #050d22;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--snow);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.55;
}

a { color: var(--blue); text-underline-offset: 0.18em; }
a:hover { color: var(--crimson-ink); }

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

code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code {
  background: var(--mist);
  padding: 0.08em 0.35em;
  border-radius: var(--radius-s);
}

h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; color: var(--ink); }
h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0 0 1em; max-width: var(--measure); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--paper); padding: 0.5rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--mist);
  background: var(--paper);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 64px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 800; font-size: 1.3rem; color: var(--ink); text-decoration: none;
}
.brand svg { width: 22px; height: 28px; flex: none; }
.nav { display: flex; gap: 1.25rem; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--crimson); }
.theme-toggle {
  background: none; border: 1px solid var(--mist); color: var(--muted);
  border-radius: 999px; width: 36px; height: 36px; cursor: pointer;
  display: inline-grid; place-items: center;
}
.theme-toggle:hover { color: var(--ink); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font: inherit; font-weight: 700; font-size: 1rem;
  padding: 0.6rem 1.15rem; border-radius: var(--radius-s);
  border: 2px solid var(--blue); background: var(--blue); color: #fff;
  text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--ink); border-color: var(--ink); color: var(--snow); }
.btn.secondary { background: transparent; color: var(--blue); }
.btn.secondary:hover { background: var(--blue); color: #fff; }
.btn.small { font-size: 0.9rem; padding: 0.35rem 0.8rem; }

/* The run button is a little pennant: the one place the flag shape appears besides the logo. */
.btn.run {
  background: var(--crimson); border-color: var(--crimson); color: #fff;
  padding-right: 1.6rem;
  clip-path: polygon(0 0, 100% 50%, 82% 50%, 100% 100%, 0 100%);
}
.btn.run:hover { background: var(--crimson-ink); border-color: var(--crimson-ink); }
.btn.run:focus-visible { clip-path: none; }
.btn[disabled] { opacity: 0.55; cursor: progress; }

/* ---------- home ---------- */

.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 3rem; }
.hero-grid {
  display: grid; gap: clamp(2rem, 4vw, 3.5rem);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: start;
}
.hero .lead { font-size: 1.3rem; color: var(--muted); max-width: 34ch; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* The keyword wall: the memorable element of the home page. */
.keywords {
  list-style: none; margin: 2.25rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.1rem 1.1rem;
  font-weight: 800; font-size: clamp(1.7rem, 3.6vw, 2.6rem); line-height: 1.2;
}
.keywords li { display: inline-flex; flex-direction: column; }
.keywords .np { color: var(--crimson-ink); }
.keywords .en { font-weight: 500; font-size: 0.95rem; color: var(--muted); line-height: 1; }

.section { padding: 3.5rem 0; border-top: 1px solid var(--mist); }
.section > .wrap > p { color: var(--muted); }

.compare { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.compare th, .compare td {
  text-align: left; padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--mist); vertical-align: top;
}
.compare th { font-weight: 700; color: var(--muted); font-size: 0.95rem; }
.compare td:first-child { color: var(--muted); white-space: nowrap; }
.compare code { white-space: nowrap; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem 3rem; margin-top: 1.5rem; }
.facts h3 { margin-bottom: 0.3rem; }
.facts p { color: var(--muted); margin: 0; }

/* ---------- code editor ---------- */

.editor {
  position: relative; display: grid; grid-template-columns: auto 1fr;
  background: var(--code-bg); color: var(--code-fg);
  border-radius: var(--radius-m);
  border-left: 6px solid var(--crimson);
  /* whole-pixel line height: gutter numbers and code lines stay aligned */
  font-family: var(--mono); font-size: 15px; line-height: 24px;
  overflow: hidden; height: var(--editor-h, 22rem);
}
.editor .gutter {
  padding: 1rem 0.6rem 1rem 0.9rem; color: var(--code-dim); text-align: right;
  user-select: none; white-space: pre; overflow: hidden;
}
.editor .area { position: relative; min-width: 0; }
.editor textarea, .editor pre.hl {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 1rem 1rem 1rem 0.4rem; border: 0;
  font: inherit; line-height: inherit; tab-size: 4; letter-spacing: 0;
  white-space: pre; overflow-wrap: normal;
}
.editor textarea {
  resize: none; background: transparent; overflow: auto;
  color: transparent; caret-color: #fff; outline: none;
}
.editor textarea::selection { background: rgba(140, 184, 255, 0.35); color: transparent; }
.editor pre.hl { pointer-events: none; color: var(--code-fg); overflow: hidden; }
.editor:focus-within { box-shadow: 0 0 0 3px var(--focus); }

.tok-kw { color: var(--code-kw); font-weight: 600; }
.tok-str { color: var(--code-str); }
.tok-num { color: var(--code-num); }
.tok-com { color: var(--code-dim); font-style: italic; }
.tok-fn { color: var(--code-fn); }
.tok-type { color: var(--code-type); }
.tok-interp { color: var(--code-num); }

.output {
  margin: 0; padding: 0.9rem 1rem; min-height: 4.5rem;
  background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius-m);
  font-family: var(--mono); font-size: 0.92rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; overflow: auto;
}
.output .err { color: var(--crimson-ink); }
.output .note { color: var(--muted); font-style: italic; font-family: var(--font); }
.output:empty::before { content: "Output appears here."; color: var(--muted); font-family: var(--font); }

.try { display: grid; gap: 0.75rem; }
.try .bar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.try .hint { color: var(--muted); font-size: 0.95rem; }

/* ---------- playground ---------- */

.pg {
  display: grid; gap: 1rem; padding: 1rem 0 2rem;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 65px);
}
.pg .toolbar {
  grid-column: 1 / -1; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
}
.pg .toolbar .spacer { flex: 1; }
.pg select, .pg .seg {
  font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--mist); border-radius: var(--radius-s); padding: 0.4rem 0.6rem;
}
.seg { display: inline-flex; padding: 0 !important; overflow: hidden; }
.seg label { padding: 0.4rem 0.75rem; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--ink); box-shadow: inset 0 -3px 0 var(--crimson); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.pg .editor { --editor-h: auto; min-height: 60vh; }
.pg .side { display: grid; gap: 1rem; grid-template-rows: auto 1fr auto; min-height: 0; }
.pg .side h2 { font-size: 1rem; margin: 0 0 0.35rem; color: var(--muted); }
.pg .output { min-height: 14rem; height: 100%; max-height: 70vh; }
.pg textarea.stdin {
  width: 100%; min-height: 4.5rem; resize: vertical;
  font-family: var(--mono); font-size: 0.92rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius-m);
  padding: 0.6rem 0.8rem;
}
.status { color: var(--muted); font-size: 0.95rem; }
.kbd-hint { color: var(--muted); font-size: 0.9rem; }
kbd { border: 1px solid var(--mist); border-bottom-width: 2px; border-radius: var(--radius-s); padding: 0 0.3em; }

/* ---------- download ---------- */

.page-head { padding: 3rem 0 1rem; }
.page-head p { color: var(--muted); font-size: 1.2rem; }
.primary-install {
  border: 2px solid var(--blue); border-radius: var(--radius-m); background: var(--paper);
  padding: 1.5rem; margin: 1.5rem 0 2rem;
}
.primary-install h2 { margin-bottom: 0.25rem; }
.cmd {
  position: relative; display: flex; align-items: stretch;
  background: var(--code-bg); color: var(--code-fg); border-radius: var(--radius-s);
  margin: 0.6rem 0 1rem;
}
.cmd pre { margin: 0; padding: 0.75rem 1rem; overflow-x: auto; flex: 1; font-size: 0.92rem; }
.cmd button {
  flex: none; font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer;
  background: transparent; color: var(--code-fg); border: 0; border-left: 1px solid #26375f;
  padding: 0 0.9rem;
}
.cmd button:hover { color: #fff; background: #1b2c55; }
.platforms { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2.5rem; }
.platforms section { min-width: 0; }
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: 0.4rem; }
.assets { width: 100%; border-collapse: collapse; font-size: 1rem; }
.assets td, .assets th { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--mist); text-align: left; }
.assets th { color: var(--muted); font-weight: 700; }
.assets td.size { color: var(--muted); white-space: nowrap; }
.release-meta { color: var(--muted); }

/* ---------- docs ---------- */

.docs { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 3rem; padding: 2rem 0 4rem; }
.docs nav { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow: auto; font-size: 0.98rem; }
.docs nav ul { list-style: none; margin: 0; padding: 0; }
.docs nav li { margin: 0.15rem 0; }
.docs nav li.sub { padding-left: 0.9rem; font-size: 0.93rem; }
.docs nav a { color: var(--muted); text-decoration: none; }
.docs nav a:hover { color: var(--ink); }
.docs article { min-width: 0; }
.docs article h2 { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--mist); }
.docs article h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.docs article h3 { margin-top: 2rem; }
.docs article table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 1rem; display: block; overflow-x: auto; }
.docs article th, .docs article td { border-bottom: 1px solid var(--mist); padding: 0.45rem 0.9rem 0.45rem 0; text-align: left; vertical-align: top; }
.docs article pre {
  background: var(--code-bg); color: var(--code-fg); padding: 1rem; border-radius: var(--radius-s);
  overflow-x: auto; line-height: 1.55; border-left: 4px solid var(--crimson); position: relative;
}
.docs article pre .try-btn {
  position: absolute; top: 0.5rem; right: 0.5rem; font: inherit; font-family: var(--font);
  font-size: 0.85rem; font-weight: 700; color: var(--code-fg); background: #1b2c55;
  border: 0; border-radius: var(--radius-s); padding: 0.2rem 0.6rem; cursor: pointer; text-decoration: none;
}
.docs article pre .try-btn:hover { background: var(--crimson); color: #fff; }

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--mist); padding: 2rem 0 3rem; color: var(--muted); font-size: 1rem; }
.site-footer .wrap { display: flex; gap: 1rem 2rem; flex-wrap: wrap; justify-content: space-between; }
.site-footer a { color: var(--muted); }

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .hero-grid, .pg { grid-template-columns: 1fr; }
  .pg { min-height: 0; }
  .pg .editor { min-height: 50vh; }
  .docs { grid-template-columns: 1fr; gap: 1rem; }
  .docs nav { position: static; max-height: none; border-bottom: 1px solid var(--mist); padding-bottom: 1rem; }
  .compare td:first-child { white-space: normal; }
  .nav { margin-left: 0; gap: 1rem; }
}

@media (max-width: 640px) {
  /* the comparison table becomes one block per row, so the NepLang column stays visible */
  .compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .compare tr { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.15rem 0.75rem; padding: 0.7rem 0; border-bottom: 1px solid var(--mist); }
  .compare td { border: 0; padding: 0; }
  .compare td:first-child { grid-row: span 2; font-weight: 600; }
  .compare td:nth-child(2)::before { content: "Python  "; color: var(--muted); font-size: 0.85rem; }
  .compare td:nth-child(3)::before { content: "NepLang  "; color: var(--crimson-ink); font-size: 0.85rem; font-weight: 600; }
  .compare code { white-space: normal; }
}

@media (prefers-reduced-motion: no-preference) {
  .keywords li { animation: rise 0.5s ease-out both; animation-delay: calc(var(--i, 0) * 45ms); }
  @keyframes rise { from { opacity: 0; transform: translateY(0.4em); } }
}
