/* ------------------------------------------------------------------
   mikhaiel.net
   One stylesheet for the whole site. No build step.

   Structure
     1. Tokens (color, type, spacing)
     2. Reset and base
     3. Typography
     4. Layout: header, page, rows, footer
     5. Components: entry lists, meta tables, figures, code, buttons
     6. Page-specific bits
     7. Print
   ------------------------------------------------------------------ */


/* 1. Tokens ------------------------------------------------------- */

:root {
  /* Palette: bone paper, near-black ink, oxidized-copper accent, ochre for
     small marks. Light and dark are the same idea with the roles swapped. */
  --bg:        #f3efe6;
  --bg-alt:    #eae5d8;
  --ink:       #1c1b18;
  --ink-2:     #5b574d;
  --ink-3:     #6e695c;
  --rule:      #cfc8b8;
  --rule-soft: #e0dacc;
  --accent:    #1f5c4f;
  --accent-2:  #8c5a14;

  --font-display: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body:    "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono:    "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --measure: 62ch;           /* body copy line length */
  --label-col: 11rem;        /* left margin column for row labels */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --wrap: 76rem;

  --step--1: 0.875rem;
  --step-0:  1.0625rem;
  --step-1:  1.25rem;
  --step-2:  1.625rem;
  --step-3:  clamp(2rem, 1.4rem + 2vw, 2.75rem);
  --step-4:  clamp(2.5rem, 1.8rem + 3vw, 3.75rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #1a1b19;
    --bg-alt:    #22241f;
    --ink:       #e7e2d6;
    --ink-2:     #a8a293;
    --ink-3:     #8e8875;
    --rule:      #3b3d37;
    --rule-soft: #2c2e2a;
    --accent:    #8fc4b0;
    --accent-2:  #d5a651;
  }
}


/* 2. Reset and base ------------------------------------------------ */

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

html {
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; display: block; }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

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

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

.skip {
  position: absolute;
  left: 0;
  top: -100%;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}
.skip:focus { top: 0; z-index: 10; }


/* 3. Typography ---------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0 0 0.6em;
  text-wrap: balance;
}

h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); font-family: var(--font-body); font-weight: 500; }

p, ul, ol, dl, blockquote, pre, table, figure {
  margin: 0 0 1.25em;
  max-width: var(--measure);
}

p:last-child, ul:last-child, ol:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color 120ms ease, color 120ms ease;
}
a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

strong { font-weight: 500; }
em { font-style: italic; }

small, .small { font-size: var(--step--1); }

.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

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

.lede {
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.4;
  color: var(--ink);
  max-width: 34em;
}

ul.plain, ol.plain { list-style: none; padding: 0; }

ul { list-style: square; padding-left: 1.2em; }
ul li::marker { color: var(--ink-3); }
li { margin-bottom: 0.35em; }

blockquote {
  padding-left: 1.25rem;
  border-left: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.4;
}


/* 4. Layout ------------------------------------------------------- */

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* Header: name on the left, nav on the right, hairline beneath. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-top: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.site-name {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -0.005em;
}
.site-name:hover { color: var(--ink); text-decoration: none; }
.site-name .domain {
  color: var(--ink-3);
  font-style: italic;
  font-weight: 400;
  margin-left: 0.35em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.site-nav a {
  text-decoration: none;
  color: var(--ink-2);
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--rule);
}
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* Page title block */
.page-head {
  padding-top: 3rem;
  padding-bottom: 2.5rem;
}
.page-head .kicker {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1rem;
}
.page-head h1 { margin-bottom: 0.5em; }
.page-head .lede { margin-bottom: 0; }

/* Rows: the main structural device. A label in the left margin, content
   on the right, a hairline above. Stacks on narrow screens. */
.row {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: 1rem 3rem;
  padding: 2.5rem 0;
  border-top: 1px solid var(--rule);
}
.row:last-of-type { border-bottom: 1px solid var(--rule); }

.row-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0.35rem 0 0;
  line-height: 1.4;
}
.row-label .num {
  display: block;
  color: var(--accent-2);
  margin-bottom: 0.15rem;
}

.row-body { min-width: 0; }
.row-body > h2:first-child,
.row-body > h3:first-child { margin-top: 0; }

@media (max-width: 44rem) {
  .row { grid-template-columns: 1fr; gap: 0.75rem; padding: 2rem 0; }
  .row-label { margin-top: 0; }
  .row-label .num { display: inline; margin-right: 0.6em; }
}

/* Footer */
.site-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}
.site-footer a { color: inherit; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 0 1.25rem; margin: 0; }


/* 5. Components ---------------------------------------------------- */

/* Definition-style "now" block */
.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  margin: 0;
  max-width: var(--measure);
}
.facts dt {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  padding-top: 0.2rem;
}
.facts dd { margin: 0; }

/* Entry list: rule-separated items for work, education, projects. */
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
}
.entries > li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, var(--measure));
  gap: 0.5rem 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule-soft);
  margin: 0;
}
.entries > li:first-child { border-top: 0; padding-top: 0; }
.entries > li:last-child { padding-bottom: 0; }

.entry-when {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-2);
  padding-top: 0.3rem;
  white-space: nowrap;
}
.entry-body { min-width: 0; }
.entry-body h3 { margin-bottom: 0.15em; }
.entry-body h3 a { text-decoration: none; }
.entry-body h3 a:hover { text-decoration: underline; }
.entry-org {
  color: var(--ink-2);
  margin-bottom: 0.75em;
}
.entry-org .loc::before { content: " · "; color: var(--ink-3); }
.org-logo {
  height: 1em;
  width: auto;
  vertical-align: -0.1em;
  margin-right: 0.4em;
  color: inherit;
}
.org-logo-mask {
  display: inline-block;
  width: auto;
  height: 1em;
  vertical-align: -0.1em;
  margin-right: 0.4em;
  background-color: currentColor;
  -webkit-mask: var(--mask-src) no-repeat center / contain;
  mask: var(--mask-src) no-repeat center / contain;
}
.entry-body p { margin-bottom: 0.9em; }
.entry-body ul { margin-bottom: 0; }

.entry-tags {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  margin-top: 0.75em;
}
.entry-tags span + span::before { content: " / "; }

@media (max-width: 44rem) {
  .entries > li { grid-template-columns: 1fr; gap: 0.25rem; }
  .entry-when { padding-top: 0; }
}

/* Compact list for the home page's selected work */
.entries.compact > li { padding: 1rem 0; }
.entries.compact h3 { font-size: var(--step-0); font-family: var(--font-body); font-weight: 500; }

/* Meta table for project pages */
.meta {
  border-collapse: collapse;
  width: 100%;
  max-width: var(--measure);
  font-size: var(--step--1);
}
.meta th, .meta td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0;
  border-top: 1px solid var(--rule-soft);
}
.meta tr:first-child th, .meta tr:first-child td { border-top: 0; }
.meta th {
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  width: 8.5rem;
  padding-right: 1rem;
}

/* Figures: bordered, no shadow, sharp corners. The hatched box is a
   stand-in for images that do not exist yet. */
figure {
  margin: 2rem 0;
  max-width: none;
}
figure img {
  border: 1px solid var(--rule);
}
figcaption {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-2);
  margin-top: 0.75rem;
  max-width: var(--measure);
}
.placeholder-img {
  border: 1px solid var(--rule);
  background: repeating-linear-gradient(
    135deg,
    var(--bg-alt) 0 6px,
    var(--bg) 6px 12px
  );
  aspect-ratio: 16 / 8;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-2);
}

/* Code */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
}
:not(pre) > code {
  padding: 0.05em 0.35em;
  background: var(--bg-alt);
}
pre {
  max-width: none;
  padding: 1rem 1.25rem;
  background: var(--bg-alt);
  border: 1px solid var(--rule-soft);
  overflow-x: auto;
  line-height: 1.5;
}
pre code { font-size: 0.8125rem; }

/* Buttons and button-like links. One style, sharp corners, hairline. */
.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 0.55rem 1rem;
  cursor: pointer;
  line-height: 1.2;
  transition: background 120ms ease, color 120ms ease;
}
.btn:hover {
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}

/* Small utilities used instead of inline styles (the CSP forbids those) */
.more { margin-top: 1.5rem; }
.note { color: var(--ink-3); margin-left: 0.75rem; }
.meta.wide th { width: 14rem; }
.meta code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Status marks used in the project list */
.status {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent-2);
}

/* Contact list */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: var(--measure);
}
.contact-list li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 0.25rem 2rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule-soft);
  margin: 0;
}
.contact-list li:first-child { border-top: 0; padding-top: 0; }
.contact-list .k {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  padding-top: 0.2rem;
}
.contact-list .v { min-width: 0; overflow-wrap: anywhere; }
.contact-list .btn { margin-left: 0.75rem; padding: 0.2rem 0.55rem; vertical-align: 0.1em; }
.copy-note { color: var(--ink-3); margin-left: 0.5rem; }

@media (max-width: 44rem) {
  .contact-list li { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* Long-form article body (project write-ups, about) */
.prose h2 {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-soft);
}
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { margin-top: 1.75rem; }

/* Sequential page navigation at the bottom of write-ups */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
.pager a { text-decoration: none; }
.pager a:hover { text-decoration: underline; }


/* 6. Page-specific ------------------------------------------------- */

/* Home: the intro sentence is the h1, set larger and in the serif. */
.home-intro h1 {
  font-size: var(--step-4);
  font-weight: 400;
  line-height: 1.12;
  max-width: 20em;
  margin-bottom: 0.7em;
}
.home-intro h1 em {
  font-style: italic;
  color: var(--accent);
}


/* 7. Print --------------------------------------------------------- */

@media print {
  :root {
    --bg: #fff;
    --ink: #000;
    --ink-2: #333;
    --ink-3: #555;
    --rule: #999;
    --rule-soft: #ccc;
  }
  .site-nav, .skip, .btn, .pager, .site-footer ul { display: none; }
  .row { break-inside: avoid; }
  a { text-decoration: none; }
  .entries > li { break-inside: avoid; }
}
