/*
  Minimal personal-site stylesheet matching Karri Saarinen's size and style.
  Uses fixed pixel sizes, OKLCH colors, logical properties, and native dialogs.
*/

/* ---------- reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  min-inline-size: 0;
}

:root {
  color-scheme: light dark;
  interpolate-size: allow-keywords;
  text-wrap: pretty;
  overflow-wrap: break-word;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;

  /* colors: one token for light and dark via light-dark() */
  --text: light-dark(oklch(0.2 0.01 100), oklch(0.9 0.01 100));
  --text-muted: light-dark(oklch(0.55 0.015 100), oklch(0.68 0.015 100));
  --bg: light-dark(oklch(0.99 0.005 100), oklch(0.145 0.005 100));
  --link: light-dark(oklch(0.1 0 none), oklch(1 0 none));
  --rule: light-dark(oklch(0.9 0.015 100), oklch(0.32 0 none));
  --quote-rule: light-dark(oklch(0.85 0.015 100), oklch(0.4 0.02 100));
  --quote-ink: light-dark(oklch(0.42 0.02 100), oklch(0.72 0.02 100));
  --code-bg: light-dark(oklch(0.95 0.01 100), oklch(0.18 0 none));
  --frame: light-dark(oklch(0.95 0 none), oklch(0.23 0 none));

  /* type: fixed sizes matching karrisaarinen.com */
  --text-tiny: 11px;
  --text-small: 12px;
  --text-body: 14px;
  --text-h1: 18px;

  /* space */
  --space-3xs: 0.1875rem;
  --space-2xs: 0.375rem;
  --space-xs: 0.5rem;
  --space-s: 0.75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2.125rem;
  --space-2xl: 2.875rem;
  --space-3xl: 3.75rem;
  --space-4xl: 4.5rem;

  /* leading */
  --leading-tight: 1.4;
  --leading-snug: 1.45;
  --leading-heading: 1.5;
  --leading-body: 1.7;

  /* layout */
  --measure: 480px;

  /* motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

body {
  margin-inline: auto;
  max-inline-size: var(--measure);
  min-block-size: 100svh;
  padding-inline: 24px;
  padding-block: 72px 60px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: var(--text-body);
  font-weight: 400;
  line-height: 1.7;
}

h1, h2, h3, h4 {
  text-wrap: balance;
  margin: 0;
}

h1 {
  font-size: var(--text-h1);
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: -0.2px;
  margin-block-end: 28px;
}

h2 {
  font-size: var(--text-body);
  font-weight: 600;
  margin-block: 34px 10px;
  line-height: 1.5;
}

h3 {
  font-size: var(--text-body);
  font-weight: 600;
  margin-block: 28px 8px;
  line-height: 1.5;
}

h4 {
  font-size: var(--text-small);
  font-weight: 600;
  margin-block: 24px 8px;
}

img, svg, video {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

a {
  color: var(--link);
  font-weight: 450;
  text-decoration: none;
}

button, a, [role="button"] { touch-action: manipulation; }

button, [role="button"] {
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, select { font-size: max(16px, 1rem); }

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

/* ---------- header ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-block-end: 46px;
}

.site-header h1 {
  margin: 0;
  font-size: inherit;
}

.site-header .name {
  color: var(--text);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.2px;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: var(--text-small);
}

.site-header .social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  min-block-size: 24px;
  padding-inline: 7px;
  padding-block: 3px;
  border-radius: 3px;
  background: var(--frame);
  line-height: 1.4;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
}

/* ---------- home ---------- */
.home [data-content-body] > ul {
  list-style: none;
  padding-inline-start: 20px;
  margin-block: 12px 24px;
}

.home [data-content-body] > ul > li {
  position: relative;
  margin-block: 7px;
}

.home [data-content-body] > ul > li::before {
  content: '·';
  position: absolute;
  inset-inline-start: -18px;
  inset-block-start: -0.05em;
  color: var(--text-muted);
}

.home h2 { margin-block-start: 32px; }

.home-writing { margin-block-start: 48px; }

.writing-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-block-end: 24px;
}

.writing-heading h2 { margin: 0; }

.writing-heading > span {
  color: var(--text-muted);
  font-size: var(--text-body);
}

.writing-heading > a {
  font-size: var(--text-body);
  font-weight: 400;
}

.archive-year {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 22px;
  margin-block-end: 25px;
}

.archive-year h2,
.archive-year h3 {
  color: var(--text-muted);
  font-size: var(--text-small);
  font-weight: 400;
  margin: 3px 0 0;
}

.archive-year ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.archive-year li {
  margin-block-end: 13px;
  line-height: 1.45;
}

.archive-year time {
  display: block;
  margin-block-start: 3px;
  color: var(--text-muted);
  font-size: var(--text-tiny);
}

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

.posts li {
  margin-block-end: 13px;
  line-height: 1.45;
}

.posts a { font-weight: 450; }

.posts time {
  display: block;
  margin-block-start: 3px;
  color: var(--text-muted);
  font-size: var(--text-tiny);
  font-variant-numeric: tabular-nums;
}

/* ---------- post ---------- */
.article h1 {
  font-size: var(--text-h1);
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: -0.2px;
  margin-block-end: 28px;
}

.date, .meta {
  color: var(--text-muted);
  font-size: var(--text-tiny);
}

.date {
  margin-block-start: -12px;
  margin-block-end: 28px;
}

.meta {
  margin-block-start: -12px;
  margin-block-end: 32px;
}

/* flow spacing for article blocks */
.article [data-content-body] > * { margin-block: 0; }

.article [data-content-body] > * + * {
  margin-block-start: var(--flow-space, 20px);
}

.article [data-content-body] > :is(h2, h3) { --flow-space: 34px; }
.article [data-content-body] > :is(h2, h3) + * { --flow-space: 10px; }
.article [data-content-body] > figure { --flow-space: 28px; }
.article [data-content-body] > blockquote { --flow-space: 28px; }

.article [data-content-body] > ul,
.article [data-content-body] > ol {
  padding-inline-start: 24px;
  margin-block: 12px 24px;
}

.article [data-content-body] > ul > li,
.article [data-content-body] > ol > li {
  margin-block: 7px;
}

.article [data-content-body] > p {
  margin-block-end: 20px;
}

.article img,
.article video,
.article iframe {
  max-inline-size: 100%;
  block-size: auto;
}

.article img {
  display: block;
  inline-size: 100%;
  width: 100%;
  margin-block: 24px;
  -webkit-user-drag: none;
  user-select: none;
}

.article figure img {
  inline-size: 100%;
  width: 100%;
  margin-block: 0;
}

.article figure {
  inline-size: 100%;
  width: 100%;
  margin-inline: 0;
  margin-block: 28px;
}

.article figcaption {
  font-size: var(--text-tiny);
  color: var(--text-muted);
}

.article blockquote {
  margin-inline: 0;
  margin-block: 28px;
  padding-inline-start: 22px;
  border-inline-start: 2px solid var(--quote-rule);
  color: var(--quote-ink);
}

.article [style*="width"], .article .column, .article .photocol {
  max-inline-size: 100%;
}

.post-navigation {
  display: flex;
  justify-content: space-between;
  margin-block-start: 40px;
  padding-block-start: 20px;
  border-block-start: 1px solid var(--rule);
}

.post-navigation a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 32px;
  min-block-size: 40px;
  font-size: var(--text-body);
  line-height: 1;
  color: var(--text-muted);
  text-decoration: none;
}

.post-navigation .post-prev { margin-inline-start: -8px; }
.post-navigation .post-next { margin-inline-start: auto; margin-inline-end: -8px; }

/* ---------- shared ---------- */
pre {
  overflow-x: auto;
  padding: 16px;
  background: var(--code-bg);
  font-size: var(--text-body);
  line-height: 1.6;
}

code { font-size: 0.85em; }

hr {
  border: 0;
  border-block-start: 1px solid var(--rule);
  margin-block: 32px;
  margin-inline: 0;
}

/* ---------- interaction ---------- */
a, .post-navigation a, .lightbox-close, .site-header .social-link {
  transition: color 150ms var(--ease-out);
}

@media (prefers-reduced-motion: no-preference) {
  .post-navigation a, .lightbox-close, .site-header .social-link {
    transition: color 150ms var(--ease-out), transform 100ms var(--ease-out);
  }
}

@media (hover: hover) and (pointer: fine) {
  a:hover { color: var(--link); }
  .post-navigation a:hover { color: var(--text); }
  .lightbox-close:hover { color: var(--text); }
  .site-header .social-link:hover { color: var(--text); }
}

.post-navigation a:active,
.lightbox-close:active,
.site-header .social-link:active {
  transform: scale(0.97);
}

/* ---------- lightbox ---------- */
.lightbox-image { cursor: zoom-in; }
.lightbox-image:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

html:has(.image-lightbox:modal) { overflow: hidden; }

.image-lightbox {
  position: fixed;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  max-inline-size: none;
  max-block-size: none;
  margin: 0;
  padding-block: 64px 24px;
  padding-inline: 24px;
  border: 0;
  background: transparent;
  color: var(--text);
  opacity: 0;
  transition:
    opacity 0.2s var(--ease-out),
    display 0.2s allow-discrete,
    overlay 0.2s allow-discrete;
}

.image-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

@starting-style {
  .image-lightbox[open] { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .image-lightbox {
    translate: 0 0.5rem;
    transition:
      opacity 0.2s var(--ease-out),
      translate 0.2s var(--ease-out),
      display 0.2s allow-discrete,
      overlay 0.2s allow-discrete;
  }
  .image-lightbox[open] { translate: 0 0; }
  @starting-style {
    .image-lightbox[open] { translate: 0 0.5rem; }
  }
}

.image-lightbox::backdrop {
  background: var(--bg);
  opacity: 0;
  transition:
    opacity 0.2s var(--ease-out),
    display 0.2s allow-discrete,
    overlay 0.2s allow-discrete;
}

.image-lightbox[open]::backdrop { opacity: 0.96; }

@starting-style {
  .image-lightbox[open]::backdrop { opacity: 0; }
}

.image-lightbox img {
  display: block;
  inline-size: auto;
  block-size: auto;
  max-inline-size: 100%;
  max-block-size: 100%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  inset-block-start: 16px;
  inset-inline-end: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 28px;
  cursor: pointer;
}

/* ---------- mobile ---------- */
@media (max-width: 560px) {
  body {
    padding-inline: 22px;
    padding-block: 36px 40px;
  }
  .site-header { margin-block-end: 34px; }
  .archive-year {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
  }
}
