/*
  Shared layout for the built-in themes.
  Palettes live in assets/themes/*.css and define the color variables.
*/

:root {
  --max: 80ch;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 17px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  font-synthesis: none;
}

body {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 5vw, 2.5rem) 4rem;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

/* Skip link: off-screen until focused, then the first thing in the page. */

.skip {
  position: absolute;
  top: 0;
  left: -9999px;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  color: var(--fg);
}

.skip:focus,
.skip:focus-visible {
  top: 1rem;
  left: 1rem;
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.site {
  margin: 0 0 3rem;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site a {
  color: var(--accent);
  text-decoration: underline;
}

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

h1,
h2,
h3 {
  font-weight: 400;
  line-height: 1.25;
}

h1 {
  margin: 0 0 1.5rem;
  color: var(--heading);
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

p {
  margin: 0 0 1.1rem;
}

.words {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.page-date,
.page-tags {
  margin: -0.75rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.page-date:empty,
.page-tags:empty {
  display: none;
}

.page-tags a + a::before {
  content: "·";
  margin: 0 0.45rem;
  color: var(--muted);
}

ul,
ol {
  padding-left: 1.4rem;
}

li {
  margin: 0.25rem 0;
}

ul > li::marker {
  content: "†  ";
}

strong {
  font-weight: inherit;
  text-decoration: underline;
  text-decoration-style: double;
}

em {
  font-style: normal;
  text-decoration: underline;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid var(--muted);
  color: var(--muted);
}

blockquote p {
  margin: 0;
}

code,
pre {
  font-family: inherit;
}

code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.1em 0.3em;
}

pre {
  margin: 1.5rem 0;
  padding: 0.8rem 1rem;
  background: var(--code-bg);
  color: var(--code-fg);
  border-left: 2px solid var(--accent-dim);
  overflow-x: auto;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--muted);
  font-weight: 400;
  text-align: left;
}

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

/* Generated listings: title plus optional date. */

.listing,
.tag-list,
.plain-list {
  list-style: none;
  padding: 0;
}

.listing {
  margin: 1.5rem 0 0;
}

.listing li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.4rem 0;
}

.listing .date {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.listing .date:empty {
  display: none;
}

.tag-list,
.plain-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1.5rem 0 0;
}

.tag-list li,
.plain-list li {
  margin: 0;
}

.tag-list .count {
  color: var(--muted);
  font-size: 0.8em;
}

/* Backlinks: just the page titles. */

.backlinks {
  margin-top: 3rem;
}

.backlinks h2 {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.backlinks li {
  display: inline;
  margin: 0;
}

.backlinks li + li::before {
  content: " · ";
  color: var(--muted);
}

.backlinks .meta,
.backlinks .count {
  display: none;
}

.footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--muted);
  font-size: 0.8rem;
}

.footer a {
  color: var(--accent);
}

@media (max-width: 40rem) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Respect a reduced-motion preference for anything added later. */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Paper: no chrome, no color, no decoration. */

@media print {
  :root {
    --bg: #fff;
    --fg: #000;
    --muted: #444;
    --accent: #000;
    --accent-dim: #000;
    --heading: #000;
  }

  body {
    max-width: none;
    padding: 0;
  }

  .site,
  .footer,
  .skip,
  .page-date,
  .page-tags,
  .backlinks {
    display: none;
  }

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

  code,
  pre {
    background: #f4f4f4;
    color: #000;
  }

  pre {
    border: 1px solid #999;
  }
}

/* uteri-night — pink dark (neokafe layout, Helix uteri-night palette) */
:root {
  color-scheme: dark;
  --bg: #120a0e;
  --fg: #e6d5dc;
  --muted: #a0838e;
  --heading: #fdf0f4;
  --accent: #df7fa0;
  --accent-dim: #c46788;
  --code-bg: #2b1520;
  --code-fg: #ffc9dd;
}
