/* ============ Design tokens ============ */
/* Warm "notebook" identity: warm ivory / graphite surfaces, coral accent,
   rounded cards with soft warm shadows. Mono is reserved for code. */

:root,
:root[data-theme="light"] {
  --bg: #fbf6ec;
  --bg-raised: #fffdf8;
  --text: #2a2622;
  --text-muted: #8b8173;
  --accent: #ef6f5b;
  --accent-strong: #e2543d;
  --accent-soft: rgba(239, 111, 91, 0.12);
  --on-accent: #fffaf5;
  --border: #ece2ce;
  --code-bg: #f4eede;
  --shadow-card: 0 6px 18px -10px rgba(198, 120, 88, 0.4), 0 2px 6px -4px rgba(120, 92, 60, 0.14);
  --shadow-card-hover: 0 16px 32px -14px rgba(224, 118, 88, 0.5), 0 4px 12px -6px rgba(120, 92, 60, 0.18);
  --shadow-pop: 0 12px 34px -12px rgba(180, 110, 80, 0.35);

  --code-comment: #a79b85;
  --code-keyword: #c15b7a;
  --code-string: #6f8a37;
  --code-number: #c67b2e;
  --code-title: #3e8a9e;
  --code-attr: #b07a2e;
}

:root[data-theme="dark"] {
  --bg: #141210;
  --bg-raised: #1c1a17;
  --text: #efe7da;
  --text-muted: #a79c8b;
  --accent: #f4876f;
  --accent-strong: #f7a08b;
  --accent-soft: rgba(244, 135, 111, 0.16);
  --on-accent: #241a15;
  --border: #2c2823;
  --code-bg: #0f0e0b;
  --shadow-card: 0 8px 22px -12px rgba(0, 0, 0, 0.55);
  --shadow-card-hover: 0 18px 36px -14px rgba(0, 0, 0, 0.65);
  --shadow-pop: 0 14px 34px -12px rgba(0, 0, 0, 0.6);

  --code-comment: #7c7362;
  --code-keyword: #e38ba5;
  --code-string: #aec17a;
  --code-number: #e0a860;
  --code-title: #7fc3d6;
  --code-attr: #d9b678;
}

/* ============ Fonts ============ */

@font-face {
  font-family: "Nunito";
  src: url("/fonts/Nunito-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito";
  src: url("/fonts/Nunito-cyrillic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============ Base ============ */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}

img {
  max-width: 100%;
  height: auto;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-strong);
}

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

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.container {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ============ Header ============ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2.25rem;
  padding-bottom: 2.75rem;
  flex-wrap: wrap;
}

.logo {
  font-weight: 800;
  font-size: 1.3rem;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.site-nav > a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.1rem 0.15rem;
}

.site-nav > a:hover {
  color: var(--accent);
}

.site-nav > a.active {
  color: var(--accent);
}

/* --- "more" dropdown --- */

.nav-more {
  position: relative;
}

.nav-more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0.1rem 0.15rem;
  background: none;
  border: none;
  font: inherit;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.nav-more.active .nav-more-toggle {
  color: var(--accent);
}

.nav-more.open .nav-more-toggle {
  color: var(--text);
}

.nav-more-toggle:hover {
  color: var(--accent);
}

.nav-more-caret {
  transition: transform 0.2s ease;
}

.nav-more.open .nav-more-caret {
  transform: rotate(180deg);
}

.nav-more-menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  min-width: 9rem;
  padding: 0.4rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 20;
}

.nav-more.open .nav-more-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-more-menu a {
  display: block;
  padding: 0.45rem 0.7rem;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-more-menu a:hover,
.nav-more-menu a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* --- language switch (segmented pill) --- */

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

.lang-opt {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.15s ease, background 0.15s ease;
}

.lang-opt.active {
  color: var(--on-accent);
  background: var(--accent);
}

a.lang-opt:hover {
  color: var(--accent);
}

.lang-opt.disabled {
  opacity: 0.35;
  cursor: default;
}

/* --- theme toggle (round) --- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}

.theme-toggle:active {
  transform: scale(0.92);
}

.theme-toggle .theme-icon {
  display: block;
  width: 16px;
  height: 16px;
}

:root[data-theme="dark"] .theme-icon-sun,
:root:not([data-theme="dark"]) .theme-icon-moon {
  display: none;
}

/* ============ Main / footer ============ */

main {
  flex: 1;
}

.site-footer {
  padding-top: 4rem;
  padding-bottom: 2.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
}

/* ============ Meta line ============ */

.meta {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.meta .accent {
  color: var(--accent);
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.copy-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.copy-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.copy-link.copied {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.copy-link-icon {
  flex-shrink: 0;
}

/* ============ Home: post cards ============ */

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
}

.post-card h2 {
  margin: 0.5rem 0 0.4rem;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.post-card h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-card h2 a:hover {
  color: var(--accent);
}

.post-card .summary {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
}

.empty-state {
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2.5rem 1.6rem;
  text-align: center;
  background: var(--bg-raised);
  border: 1px dashed var(--border);
  border-radius: 16px;
}

/* ============ Article ============ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.back-arrow {
  transition: transform 0.15s ease;
}

.back-link:hover .back-arrow {
  transform: translateX(-3px);
}

.article-header h1 {
  margin: 0.4rem 0 0.75rem;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.article-cover {
  width: 100%;
  border-radius: 16px;
  margin: 1.5rem 0 0;
  display: block;
  box-shadow: var(--shadow-card);
}

.article-content {
  margin-top: 2rem;
  overflow-wrap: break-word;
}

.article-content h2,
.article-content h3,
.article-content h4 {
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 2.2rem 0 0.75rem;
}

.article-content h2 {
  font-size: 1.55rem;
}

.article-content h3 {
  font-size: 1.25rem;
}

.article-content p {
  margin: 0 0 1.15rem;
}

.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.article-content a:hover {
  color: var(--accent-strong);
  text-decoration-color: var(--accent-strong);
}

.article-content img {
  max-width: 100%;
  border-radius: 12px;
}

.article-content blockquote {
  margin: 1.5rem 0;
  padding: 0.8rem 1.2rem;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  color: var(--text);
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-content hr {
  border: none;
  border-top: 2px dotted var(--border);
  margin: 2.5rem 0;
}

.article-content ul,
.article-content ol {
  padding-left: 1.3rem;
}

.article-content li {
  margin: 0.3rem 0;
}

.article-content li::marker {
  color: var(--accent);
}

.article-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.article-content th,
.article-content td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
  text-align: left;
}

.article-content tr:last-child td {
  border-bottom: none;
}

.article-content th {
  background: var(--code-bg);
  font-weight: 800;
  font-size: 0.9rem;
}

/* ============ Code ============ */

code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

p code,
li code,
td code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  line-height: 1.6;
  margin: 1.4rem 0;
  box-shadow: var(--shadow-card);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.hljs-comment,
.hljs-quote {
  color: var(--code-comment);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-built_in,
.hljs-type {
  color: var(--code-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-addition {
  color: var(--code-string);
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-meta {
  color: var(--code-number);
}

.hljs-title,
.hljs-section,
.hljs-name,
.hljs-function {
  color: var(--code-title);
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-selector-class,
.hljs-selector-id {
  color: var(--code-attr);
}

.hljs-deletion {
  color: #e06c75;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 700;
}

/* ============ Login ============ */

.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-card {
  width: 100%;
  max-width: 20rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: var(--shadow-card-hover);
}

.login-card .logo {
  font-size: 1.4rem;
}

.login-card form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login-card label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

.login-card input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  padding: 0.6rem 0.85rem;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button {
  margin-top: 0.4rem;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: var(--on-accent);
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.7rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.login-card button:hover {
  background: var(--accent-strong);
}

.login-card button:active {
  transform: scale(0.98);
}

.notice {
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  margin-top: 1rem;
}

.notice.error {
  color: #d1483a;
  background: rgba(224, 108, 117, 0.1);
  border-color: rgba(224, 108, 117, 0.4);
}

.notice.ok {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ============ Error pages ============ */

.error-wrap {
  text-align: center;
  padding-top: 14vh;
}

.error-code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.03em;
}

.error-wrap p {
  color: var(--text-muted);
}

/* ============ Accessibility / responsive ============ */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 17px;
  }

  .container {
    padding: 0 1rem;
  }

  .site-header {
    padding-top: 1.5rem;
    padding-bottom: 1.75rem;
    gap: 0.75rem;
  }

  .site-nav {
    gap: 0.5rem 0.85rem;
  }

  .nav-more-menu {
    right: auto;
    left: 0;
    max-width: calc(100vw - 1.5rem);
  }

  .post-card {
    padding: 1.3rem 1.35rem;
  }

  .post-card h2 {
    font-size: 1.25rem;
  }

  .article-content {
    margin-top: 1.5rem;
  }

  .article-content h2 {
    font-size: 1.35rem;
  }

  .article-content h3 {
    font-size: 1.15rem;
  }

  pre {
    padding: 0.9rem 1rem;
    border-radius: 12px;
  }

  .site-footer {
    padding-top: 3rem;
  }

  .login-card {
    padding: 1.5rem;
  }

  .error-wrap {
    padding-top: 10vh;
  }

  .error-code {
    font-size: 3.5rem;
  }
}
