/* ============================================================
   LEDGER — muhyo.uz design tokens & styles
   Direction: editorial paper-and-ink. See DESIGN.md.
   No gradients. No shadows. No glass. Hairlines and type only.
   ============================================================ */

/* ---------- Fonts: self-hosted, latin + latin-ext only ----------
   (inlined from former assets/fonts/fonts.css — removes the
    stylesheet @import waterfall: zero extra round-trips) ---------- */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('assets/fonts/Newsreader-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('assets/fonts/Newsreader-normal-latin.woff2') format('woff2');
  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: 'Newsreader';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url('assets/fonts/Newsreader-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url('assets/fonts/Newsreader-italic-latin.woff2') format('woff2');
  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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/JetBrainsMono-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/JetBrainsMono-normal-latin.woff2') format('woff2');
  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;
}

:root {
  color-scheme: light;

  /* --- Paper theme (light, default) --- */
  --bg: #f4f0e6;
  --surface: #fffdf6;          /* barely lifted paper, used sparingly */
  --ink: #17233c;              /* 13.75:1 on --bg */
  --ink-soft: #3f4a63;         /*  7.78:1 on --bg */
  --muted: #59637a;            /*  5.29:1 on --bg */
  --hairline: #d8d3c6;         /* decorative rules only, never text */
  --accent: #1e4fa3;           /*  6.83:1 on --bg */
  --accent-hover: #173d7e;     /*  9.20:1 on --bg */
  --accent-wash: rgb(30 79 163 / 10%);
  --focus: #1e4fa3;
  --selection: rgb(30 79 163 / 18%);

  /* --- Type --- */
  --font-serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --text-2xs: 0.6875rem;       /* 11px micro labels (mono) */
  --text-xs: 0.78125rem;       /* 12.5px meta (mono caps) */
  --text-sm: 0.875rem;         /* 14px nav / secondary */
  --text-base: 1.0625rem;      /* 17px body */
  --text-lede: 1.25rem;        /* 20px lede */
  --text-md: 1.375rem;         /* 22px essay titles */
  --text-lg: clamp(1.5rem, 1.15rem + 1.6vw, 2.125rem);   /* h2 */
  --text-xl: clamp(2.6rem, 1.35rem + 6vw, 4.5rem);       /* h1 */

  /* --- Space (4px base) --- */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-6: 1.5rem;
  --s-8: 2.25rem;
  --s-12: 3.5rem;
  --s-16: 5.5rem;
  --s-24: 8.5rem;

  --r: 2px;                     /* the only radius on the site */
  --measure: 68ch;
  --gutter: clamp(1.25rem, 5vw, 4.5rem);
  --max: 72rem;

  /* --- Motion --- */
  --t-fast: 160ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
}

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

    --bg: #111b30;              /* deep navy — "blue, darker" */
    --surface: #182338;
    --ink: #ece9de;             /* 14.12:1 on --bg */
    --ink-soft: #b7bdcb;        /*  9.12:1 on --bg */
    --muted: #9aa3b8;           /*  6.79:1 on --bg */
    --hairline: #25334e;        /* decorative only */
    --accent: #93b4e8;          /*  8.12:1 on --bg */
    --accent-hover: #b7cdf5;    /* 10.68:1 on --bg */
    --accent-wash: rgb(147 180 232 / 14%);
    --focus: #93b4e8;
    --selection: rgb(147 180 232 / 22%);
  }
}

/* ---------- View transitions ----------
   Cross-document crossfade between pages (Chromium 126+, Safari 18.2+).
   Progressive: unsupported browsers navigate normally. Disabled under reduce. */
@view-transition { navigation: auto; }

/* ---------- Reset ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  touch-action: manipulation;
}

[id] { scroll-margin-top: var(--s-6); }

a, .btn { -webkit-tap-highlight-color: var(--selection); }

@media (pointer: fine) {
  html { overscroll-behavior: none; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); }

img, picture, svg { max-width: 100%; }

p {
  max-width: var(--measure);
  margin: 0 0 var(--s-4);
  text-wrap: pretty;
  overflow-wrap: break-word;
}

/* ---------- Focus ---------- */

:focus:not(:focus-visible) { outline: none; }

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

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -3rem;
  z-index: 100;
  padding: var(--s-3) var(--s-4);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: top var(--t-fast) var(--ease-out);
}

.skip-link:focus-visible { top: var(--s-3); }

/* ---------- Layout primitives ---------- */

.wrap {
  width: 100%;
  max-width: calc(var(--max) + (var(--gutter) * 2));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.kicker {
  margin: 0 0 var(--s-6);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.7;
  text-transform: uppercase;
  color: var(--accent);
  text-wrap: balance;
}

.section-kicker {
  display: block;
  margin-bottom: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-rule {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 0 0 var(--s-8);
}

/* ---------- Links ---------- */

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 0.075em;
  text-underline-offset: 0.2em;
  text-decoration-color: rgb(30 79 163 / 40%);
  transition: color var(--t-fast) var(--ease-out),
              text-decoration-color var(--t-fast) var(--ease-out);
}

@media (prefers-color-scheme: dark) {
  a { text-decoration-color: rgb(147 180 232 / 40%); }
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--hairline);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-4);
}

.wordmark {
  font-family: var(--font-serif);
  font-weight: 640;
  font-size: 1.375rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}

.wordmark::after {
  content: ".";
  color: var(--accent);
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(var(--s-4), 3vw, var(--s-8));
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;                 /* touch target */
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

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

.site-nav .nav-icon {
  display: inline-flex;
  width: 1.15em;
  height: 1.15em;
}

.site-nav .nav-icon svg { width: 100%; height: 100%; }

/* ---------- Hero ---------- */

.hero {
  padding-block: var(--s-12) var(--s-16);
}

.hero .wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-8);
  align-items: center;
}

.hero h1 {
  margin: 0 0 var(--s-6);
  font-weight: 560;
  font-size: var(--text-xl);
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.lede {
  font-size: var(--text-lede);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 34ch;
  margin-bottom: var(--s-8);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-6);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 48px;
  padding: 0 var(--s-6);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  transition: background-color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out);
}

.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #f4f0e6;
}

@media (prefers-color-scheme: dark) {
  .btn:hover { color: #111b30; }
}

.btn .btn-arrow {
  width: 1em;
  height: 1em;
  transition: transform var(--t-fast) var(--ease-out);
}

.btn:hover .btn-arrow { transform: translateX(4px); }

.cta-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Portrait: arch-topped cameo of dots */
.portrait {
  margin: 0;
  justify-self: center;
  text-align: center;
}

.portrait picture {
  display: block;
  width: min(17rem, 72vw);
  margin-inline: auto;
  border-radius: 9rem 9rem var(--r) var(--r);
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--surface);
}

.portrait img {
  display: block;
  width: 100%;
  height: auto;
}

.portrait figcaption {
  margin-top: var(--s-4);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Essays ---------- */

.essays { padding-block: var(--s-16); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-6);
  margin-bottom: var(--s-8);
}

.section-head h2 {
  margin: 0;
  font-weight: 560;
  font-size: var(--text-lg);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.section-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

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


.essay-list li {
  border-top: 1px solid var(--hairline);
}

.essay-list a {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-6);
  align-items: baseline;
  padding: var(--s-6) var(--s-2);
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease-out);
}

.essay-list a:hover { background: var(--accent-wash); }

.essay-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Arrow appears on hover/focus — a quiet affordance, not a gimmick */
.essay-arrow {
  align-self: center;
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--muted);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out);
}

.essay-arrow svg { width: 100%; height: 100%; }

.essay-list a:hover .essay-arrow,
.essay-list a:focus-visible .essay-arrow {
  opacity: 1;
  transform: none;
  color: var(--accent);
}

/* No hover on touch — the affordance is always visible there */
@media (hover: none) {
  .essay-arrow { opacity: 1; transform: none; }
}

.essay-title {
  font-size: var(--text-md);
  font-weight: 560;
  line-height: 1.25;
  text-wrap: pretty;
}

/* Honest in-progress state — designed, not an apology */
.essays-empty {
  border-left: 2px solid var(--accent);
  padding: var(--s-2) var(--s-6);
  max-width: 46rem;
}

.essays-empty strong {
  font-size: var(--text-md);
  font-weight: 560;
  letter-spacing: -0.01em;
}

.essays-empty p { color: var(--ink-soft); }

.empty-kicker {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--s-3);
}

.empty-meta {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--s-6);
}

/* ---------- About ---------- */

.about { padding-block: var(--s-16); border-top: 1px solid var(--hairline); }

.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-8);
  margin-bottom: var(--s-12);
}

.about-grid p {
  font-size: var(--text-lede);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 44ch;
}

.facts {
  margin: 0;
  border-top: 1px solid var(--hairline);
}

.facts > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-1) var(--s-8);
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--hairline);
}

.facts dt {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: center;
}

.facts dd { margin: 0; max-width: none; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--hairline);
  padding-block: var(--s-8);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
}

.footer-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.socials {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--s-6);
}

.socials a {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

.socials a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

.socials svg { width: 1.05em; height: 1.05em; }

.colophon {
  flex: none;
  width: 100%;
  max-width: none;          /* p caps at 68ch — a flex row needs the full wrap */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-6);
  margin: var(--s-6) 0 0;
  padding-top: var(--s-6);
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.to-top {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

.to-top:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

/* ---------- Essays page & posts ---------- */

.page-head { padding-block: var(--s-12) var(--s-8); }

.page-head h1 {
  margin: 0;
  font-weight: 560;
  font-size: var(--text-xl);
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.article {
  padding-block: var(--s-12) var(--s-16);
  max-width: var(--measure);
}

.article h1 {
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-wrap: balance;
}

.article-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--s-8);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-8);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- Breakpoints ---------- */

@media (min-width: 48rem) {           /* 768px */
  .facts > div {
    grid-template-columns: 13rem 1fr;
  }

  .about-grid {
    grid-template-columns: 1.2fr 1fr;
    align-items: start;
  }
}

@media (min-width: 64rem) {           /* 1024px */
  .hero {
    padding-block: var(--s-16) var(--s-16);
  }

  .hero .wrap {
    grid-template-columns: 7fr 4fr;
    gap: var(--s-12);
  }

  .lede { max-width: 36ch; }

  .portrait picture { width: min(21rem, 30vw); }
}

@media (min-width: 90rem) {           /* 1440px */
  .portrait picture { width: 24rem; }
}

/* ---------- Reduced motion ---------- */

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

  @view-transition { navigation: none; }

  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Hide the honest empty state once at least one essay exists */
.essay-list:has(li) + .essays-empty { display: none; }

/* ---------- Forced colors (Windows High Contrast) ----------
   The browser drops custom colors; we keep structure visible with system keywords. */
@media (forced-colors: active) {
  .skip-link {
    background: Canvas;
    color: LinkText;
    outline: 1px solid LinkText;
  }

  .btn {
    background: ButtonFace;
    color: ButtonText;
    border: 1px solid ButtonText;
  }

  .wordmark { color: LinkText; }
  .wordmark::after { color: currentColor; }

  .kicker, .section-kicker, .empty-kicker, .article-meta,
  .essay-date, .colophon, .footer-note, .cta-note { color: CanvasText; }

  .essays-empty { border-left-color: CanvasText; }

  .portrait picture, .section-rule, .about, .site-header, .site-footer,
  .facts, .facts > div, .essay-list li { border-color: CanvasText; }

  .essay-list a:hover { background: Canvas; outline: 1px solid Highlight; }

  :focus-visible { outline: 2px solid Highlight; }

  .essay-arrow { opacity: 1; transform: none; color: LinkText; }
}

/* ---------- More contrast (prefers-contrast: more) ---------- */

@media (prefers-contrast: more) {
  :root {
    --muted: var(--ink-soft);      /* promote meta text to full secondary ink */
    --accent: #173d7e;             /* 9.20:1 — was 6.83:1 */
    --hairline: #a49e8d;           /* decorative rules gain real visibility */
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root {
    --muted: var(--ink-soft);
    --accent: #b7cdf5;             /* 10.68:1 */
    --hairline: #4a5a80;
  }
}

/* ---------- Print: paper, not pixels ---------- */

@page { margin: 2cm; }

@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
    line-height: 1.5;
    -webkit-print-color-adjust: economy;
  }

  p { max-width: none; }

  h1, h2 { font-size: 17pt; }

  /* Chrome that's navigation, media, or affordances — ink is for content */
  .site-header, .skip-link, .cta-row, .portrait,
  .to-top, .socials, .essay-arrow { display: none; }

  a { color: #000; text-decoration: underline; }

  .essays, .about, .hero { padding-block: 0.75cm; }

  .about { border-top-color: #666; }

  .facts, .facts > div { border-color: #666; }

  .essay-list li { border-top-color: #666; }

  .colophon {
    border-top-color: #666;
    color: #333;
  }

  /* Honest pagination: never split a row or a quote across pages */
  .essay-list li, .essays-empty, .facts > div { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}
