/* onworks blog — shared stylesheet.
 * Tokens mirror the landing page (/index.html) and app/globals.css,
 * so the three read as one product. This is a static site that
 * follows the OS preference, exactly like the landing page does. */

:root {
  color-scheme: light;

  --canvas: #fafafa;
  --surface: #ffffff;
  --elevated: #ffffff;

  --ink: #111827;
  --ink-muted: #565e6b;
  --ink-faint: #667085;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --on-accent: #ffffff;

  --border: rgb(16 24 40 / 0.08);
  --border-strong: rgb(16 24 40 / 0.16);
  --wash: rgb(16 24 40 / 0.03);

  --grid-line: 16 24 40;
  --grid-alpha: 0.5;

  --shadow-soft: 0 1px 2px 0 rgb(16 24 40 / 0.04),
    0 1px 3px 0 rgb(16 24 40 / 0.06);
  --shadow-lift: 0 8px 24px -12px rgb(16 24 40 / 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --canvas: #0b0d12;
    --surface: #14161c;
    --elevated: #21242c;

    --ink: #e8eaed;
    --ink-muted: #9aa1ac;
    --ink-faint: #868e9e;

    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --on-accent: #11141c;

    --border: rgb(255 255 255 / 0.12);
    --border-strong: rgb(255 255 255 / 0.24);
    --wash: rgb(255 255 255 / 0.04);

    --grid-line: 255 255 255;
    --grid-alpha: 0.32;

    --shadow-soft: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --shadow-lift: 0 8px 24px -12px rgb(0 0 0 / 0.55);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    Helvetica,
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

:where(a, button):focus-visible {
  outline: 2px solid rgb(79 70 229 / 0.6);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :where(a, button):focus-visible {
    outline-color: rgb(129 140 248 / 0.6);
  }
}

/* ── Backdrop: same two blurred fields as the landing page ── */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.backdrop::before,
.backdrop::after {
  content: "";
  position: absolute;
  border-radius: 9999px;
  filter: blur(110px);
}

.backdrop::before {
  top: -180px;
  left: -140px;
  width: 520px;
  height: 520px;
  background: rgb(79 70 229 / 0.09);
}

.backdrop::after {
  right: -160px;
  bottom: -200px;
  width: 480px;
  height: 480px;
  background: rgb(79 70 229 / 0.06);
}

@media (prefers-color-scheme: dark) {
  .backdrop::before {
    background: rgb(129 140 248 / 0.08);
  }

  .backdrop::after {
    background: rgb(129 140 248 / 0.05);
  }
}

.backdrop-grid {
  position: absolute;
  inset: 0;
  display: none;
  background-image:
    linear-gradient(
      to right,
      rgb(var(--grid-line) / var(--grid-alpha)) 1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      rgb(var(--grid-line) / var(--grid-alpha)) 1px,
      transparent 1px
    );
  background-size: 44px 44px;
  opacity: 0.4;
  -webkit-mask-image: radial-gradient(
    ellipse at 30% 40%,
    #000 0%,
    transparent 70%
  );
  mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 70%);
}

/* ── Page shell ── */

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.nav {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-soft);
  flex-shrink: 0;
}

.logo-mark svg {
  width: 20px;
  height: 20px;
}

.logo-word {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-link {
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-link:hover {
  color: var(--ink);
}

/* ── Article column ── */

.wrap {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  flex: 1;
  padding: 24px 0 90px;
}

.index-hero {
  padding: 56px 0 44px;
  max-width: 720px;
}

.index-hero h1 {
  margin: 14px 0 16px;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 600;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}

.leading {
  margin: 0;
  color: var(--ink-muted);
  font-size: 17px;
  line-height: 1.8;
}

/* Post list */

.posts {
  max-width: 800px;
}

.post-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px 72px;
  align-items: start;
}

.group-title {
  margin: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

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

.post-row {
  position: relative;
  display: block;
  padding: 26px 56px 26px 0;
  border-bottom: 1px solid var(--border);
}

.post-row::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: 0;
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transform: translate(-8px, 4px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

@media (hover: hover) {
  .post-row:hover h2 {
    color: var(--accent);
  }

  .post-row:hover::after {
    opacity: 1;
    transform: translate(0, 4px);
  }
}

.post-date {
  display: block;
  margin-top: 13px;
  white-space: nowrap;
  color: var(--ink-faint);
  font-size: 13px;
}

.post-row h2 {
  margin: 0 0 9px;
  font-size: 20px;
  line-height: 1.28;
  letter-spacing: -0.025em;
  transition: color 0.18s ease;
}

.post-row p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.72;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ── Article page ── */

.article {
  max-width: 820px;
  margin: 0 auto;
  padding-top: 40px;
}

.article-header .eyebrow {
  margin-bottom: 4px;
}

.article h1 {
  margin: 12px 0 14px;
  font-size: clamp(30px, 5vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 600;
}

.byline {
  color: var(--ink-faint);
  font-size: 13.5px;
}

.byline a {
  color: var(--accent);
  font-weight: 600;
}

.byline a:hover {
  text-decoration: underline;
}

.content {
  margin-top: 34px;
  font-size: 17px;
  line-height: 1.9;
  color: var(--ink);
}

.content p {
  margin: 1em 0;
}

.content h2 {
  margin: 2.2em 0 0.7em;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.content h3 {
  margin: 1.8em 0 0.5em;
  font-size: 18.5px;
  color: var(--accent);
}

.content ul,
.content ol {
  padding-left: 1.4em;
  margin: 1em 0;
}

.content li {
  margin: 0.45em 0;
}

.content strong {
  font-weight: 650;
}

.content code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--wash);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.4em;
}

.content pre {
  overflow: auto;
  background: var(--wash);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.6;
}

.content pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* First element of the piece should not sit under the article header's rhythm */
.content > :first-child {
  margin-top: 0;
}

.content blockquote {
  margin: 1.6em 0;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--wash);
  color: var(--ink-muted);
}

.content blockquote p {
  margin: 0.6em 0;
}

.content hr {
  margin: 2.4em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* ── Skip link ── */

.skip {
  position: fixed;
  top: 12px;
  left: 50%;
  translate: -50% 0;
  z-index: 20;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  /* Hidden until keyboard focus */
  opacity: 0;
  pointer-events: none;
}

.skip:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

/* The "In one sentence" callout and example dialogues */

.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 1.6em 0;
}

.callout .k {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.callout p {
  margin: 0.35em 0;
}

/* Dialogue bubbles: the speaker becomes a small chip, so a
   beginner can see at a glance who is holding the floor. */

.example {
  background: var(--wash);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 1.6em 0;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.75;
}

.example p {
  margin: 0.55em 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.example .who {
  color: var(--on-accent);
  background: var(--accent);
  font-weight: 650;
  font-size: 12.5px;
  line-height: 1;
  border-radius: 7px;
  padding: 5px 9px;
  flex-shrink: 0;
  margin-top: 3px;
  min-width: 2.6em;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 15px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: top;
}

th {
  color: var(--ink-faint);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── In-article mini TOC (chips row under the byline) ── */

.toc {
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toc a {
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s ease, border-color 0.2s ease;
}

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

/* In-article anchors land a little clear of the page top */
.content [id] {
  scroll-margin-top: 18px;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ── Article nav: prev / next ── */

.post-nav {
  margin-top: 60px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.post-nav a {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.post-nav a:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
}

.post-nav .dir {
  display: block;
  color: var(--ink-faint);
  font-size: 12.5px;
  margin-bottom: 6px;
}

.post-nav .t {
  color: var(--ink);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.5;
}

/* ── Footer ── */

.bottom {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--ink-faint);
  font-size: 13px;
}

.icp {
  transition: color 0.2s ease;
}

.icp:hover {
  color: var(--ink-muted);
}

/* ── Mobile ── */

@media (max-width: 640px) {
  .nav,
  .wrap,
  .bottom {
    width: calc(100% - 40px);
  }

  .nav {
    height: 68px;
    gap: 14px;
  }

  .nav-links {
    gap: 14px;
  }

  .index-hero {
    padding: 36px 0 30px;
  }

  .post-columns {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .post-row {
    padding: 22px 44px 22px 0;
  }

  .bottom {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
