/* Public pages, login, and the shell around the Svelte editor. */

:root {
  --bg: #fbfaf7;
  --surface: #f2f0ea;
  --field: #ffffff;
  --text: #1d1c1a;
  --muted: #6a665e;
  --rule: #e2ded5;
  --border: #c4bfb3;
  --accent: #0b5f4f;
  --danger: #a3291d;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #1f1e1c;
    --field: #1b1a19;
    --text: #e7e4dd;
    --muted: #a39e93;
    --rule: #32302c;
    --border: #55514a;
    --accent: #7cc9b5;
    --danger: #f08a7e;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Keeps focused fields clear of the editor's sticky Save bar. */
  scroll-padding-top: 4.5rem;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
}

main {
  flex: 1;
  width: 100%;
  padding-block: 2.5rem 4rem;
}

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

/* A Markdown link whose URL was removed by the sanitizer reads as plain text. */
a:not([href]) {
  color: inherit;
  text-decoration: none;
}

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

h1 {
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 600;
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

/* Layout */

.page {
  width: 100%;
  max-width: 42rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.page--wide {
  max-width: 60rem;
}

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

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.1rem;
}

.site-name {
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
}

.site-name:hover {
  text-decoration: underline;
}

.site-nav {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}

.site-nav a,
.site-nav .link-button {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav .link-button:hover {
  color: var(--text);
  text-decoration: underline;
}

.site-nav form {
  margin: 0;
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 1.5rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8125rem;
}

/* Small sans label used for section names */

.label {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--muted);
}

.label__tag {
  color: var(--text);
}

.empty {
  color: var(--muted);
}

/* Home */

.lede {
  margin: 0 0 2.5rem;
  font-size: 1.3rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.list-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-bottom: 0.6rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}

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

.note-item {
  display: grid;
  grid-template-columns: 6.25rem 1fr;
  gap: 0 1.5rem;
  padding-block: 1.4rem;
  border-top: 1px solid var(--rule);
}

.note-item time {
  padding-top: 0.3rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.note-item h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
}

.note-item h2 a {
  color: var(--text);
  text-decoration: none;
}

.note-item h2 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.note-item p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

@media (max-width: 34rem) {
  .note-item {
    grid-template-columns: 1fr;
  }

  .note-item time {
    padding: 0 0 0.2rem;
  }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.85rem;
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 0.8125rem;
}

.tags a {
  color: var(--muted);
  text-decoration: none;
}

.tags a::before {
  content: "#";
}

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

/* Note page */

.note__header {
  margin-bottom: 2.25rem;
}

.note__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1rem;
  margin: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.875rem;
}

.abstract {
  margin-bottom: 2.25rem;
  padding: 1.1rem 0 1.2rem;
  border-block: 1px solid var(--rule);
}

.abstract p {
  margin: 0.5rem 0 0;
}

/* Rendered Markdown: the note body and the editor preview */

.prose {
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose table,
.prose .highlight {
  margin-block: 1.15em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 2em 0 0.6em;
  font-weight: 600;
  line-height: 1.3;
}

.prose h1 {
  font-size: 1.6rem;
}

.prose h2 {
  font-size: 1.4rem;
}

.prose h3 {
  font-size: 1.2rem;
}

.prose h4,
.prose h5,
.prose h6 {
  font-size: 1.0625rem;
}

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

.prose li + li {
  margin-top: 0.3em;
}

.prose blockquote {
  margin-inline: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

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

.prose code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.85em;
}

.prose pre {
  margin: 0;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  tab-size: 4;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.prose th,
.prose td {
  padding: 0.45rem 0.9rem 0.45rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.prose th {
  border-bottom-color: var(--border);
  font-weight: 600;
}

/* Forms and buttons (login and the editor) */

label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.4;
}

textarea {
  resize: vertical;
}

.field {
  margin-bottom: 1.1rem;
}

.button {
  display: inline-block;
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  opacity: 0.88;
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.button--danger {
  border-color: currentColor;
  background: transparent;
  color: var(--danger);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.form-error {
  margin: 0 0 1.1rem;
  color: var(--danger);
  font-family: var(--sans);
  font-size: 0.9rem;
}

.login {
  max-width: 22rem;
  margin-inline: auto;
  padding-top: 1.5rem;
}

.login h1 {
  margin-bottom: 1.5rem;
  font-size: 1.6rem;
}
