/* ==========================================================================
   Theme
   ========================================================================== */

:root {
  --bg: #fcfcfb;
  --text: #222222;
  --muted: #6b6b68;
  --border: #e4e4e0;

  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar: 260px;
  --column: 640px;
  --gutter: 24px;
}

:root[data-theme="dark"] {
  --bg: #1b1b1a;
  --text: #e8e8e5;
  --muted: #9a9a95;
  --border: #333331;
}


/* ==========================================================================
   Base
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-color: currentColor;
}

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

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

button {
  font: inherit;
}

code {
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--border);
  font-family: var(--font-mono);
  font-size: 0.875em;
}


/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;

  display: flex;
  flex-direction: column;
  gap: 36px;
  width: var(--sidebar);
  padding: 40px 28px 28px;
  overflow-y: auto;

  border-right: 1px solid var(--border);
  background: var(--bg);
}

.site-name {
  font-weight: 600;
  text-decoration: none;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-nav a,
.social-links a {
  color: var(--muted);
  font-size: 1rem;
  text-decoration: none;
}

.side-nav a:hover,
.social-links a:hover,
.side-nav a.is-active {
  color: var(--text);
}

.side-nav a.is-active {
  font-weight: 600;
}

.side-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.social-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.9375rem;
}

.side-footer p {
  margin: 12px 0 0;
}

#theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

#theme-toggle:hover {
  color: var(--text);
}

.topbar,
.backdrop {
  display: none;
}


/* ==========================================================================
   Main area
   ========================================================================== */

main {
  margin-left: var(--sidebar);
  padding: 64px var(--gutter) 96px;
}

.view {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  overflow-wrap: anywhere;
}

main.wide .view {
  max-width: 1080px;
}

main.home {
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding-top: 40px;
  padding-bottom: 40px;
}


/* ==========================================================================
   Home
   ========================================================================== */

.home-view {
  text-align: center;
}

.home-image {
  display: block;
  width: 1920px;
  height: 420px;
  margin: 0 auto 32px;
  border-radius: 0%;
  object-fit: cover;
}

.home-lines p {
  margin: 0 0 6px;
  font-size: 1.375rem;
  line-height: 1.5;
}

.home-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 28px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  font-size: 1.0625rem;
}


/* ==========================================================================
   Writing list
   ========================================================================== */

.view-title,
.article h1,
.page h1,
.editor h1 {
  margin: 0 0 8px;
  font-size: 2.125rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.view-title {
  margin-bottom: 32px;
}

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

.post-item {
  padding: 28px 0;
  border-top: 1px solid var(--border);
}

.post-item:last-child {
  border-bottom: 1px solid var(--border);
}

.post-item h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
}

.post-item h2 a {
  text-decoration: none;
}

.post-item h2 a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.post-item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.post-cover {
  display: block;
  margin-bottom: 16px;
}

.post-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
}

.meta {
  display: block;
  color: var(--muted);
  font-size: 0.9375rem;
}


/* ==========================================================================
   Posts and About page
   ========================================================================== */

.article .meta {
  margin-bottom: 32px;
}

.article p,
.page p,
.article ul,
.page ul,
.article ol,
.page ol {
  margin: 0 0 1.4em;
}

.article h2,
.page h2 {
  margin: 2em 0 0.6em;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.3;
}

.article h3,
.page h3 {
  margin: 1.6em 0 0.5em;
  font-size: 1.1875rem;
  font-weight: 600;
}

.article li,
.page li {
  margin-bottom: 0.3em;
}

.article blockquote {
  margin: 1.6em 0;
  padding-left: 20px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-style: italic;
}

.article blockquote p {
  margin: 0;
}

.article hr,
.page hr {
  margin: 2.4em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.back-link {
  display: inline-block;
  margin-top: 40px;
  color: var(--muted);
  font-size: 1rem;
}

.not-found {
  color: var(--muted);
}


/* ==========================================================================
   Images
   ========================================================================== */

figure {
  margin: 0;
}

figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.cover,
.images {
  margin: 0 0 1.6em;
}

.cover img,
.images img {
  display: block;
  width: 100%;
  border-radius: 4px;
}

.images a {
  display: block;
}

.images.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.images.gallery img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}


/* ==========================================================================
   Editor
   ========================================================================== */

.editor .hint {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 1rem;
}

.editor-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.editor-top .inline {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  margin: 0;
}

.editor-top select {
  flex: 1;
  min-width: 0;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
}

.editor label {
  display: block;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 1rem;
}

.editor .field-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 1rem;
}

.editor input,
.editor textarea,
.editor select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.6;
}

.editor select {
  margin-top: 0;
}

.editor textarea {
  margin-top: 0;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.editor button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 0.9375rem;
  cursor: pointer;
}

.editor button:hover {
  border-color: var(--text);
}

.editor .primary {
  border-color: var(--text);
}

.preview {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.preview .article h1 {
  font-size: 1.75rem;
}

.editor-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.status {
  color: var(--muted);
  font-size: 0.9375rem;
}


/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 900px) {
  .editor-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  :root {
    --gutter: 20px;
  }

  body {
    font-size: 1.0625rem;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;

    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 16px var(--gutter);

    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }

  .topbar button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
  }

  .sidebar {
    z-index: 40;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  body.menu-open .sidebar {
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }

  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.35);
  }

  body.menu-open .backdrop {
    display: block;
  }

  main {
    margin-left: 0;
    padding-top: 40px;
  }

  .home-image {
    width: 150px;
    height: 150px;
  }

  .home-lines p {
    font-size: 1.1875rem;
  }

  .view-title,
  .article h1,
  .page h1,
  .editor h1 {
    font-size: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}


/* ==========================================================================
   Home page has no sidebar
   ========================================================================== */

body.is-home .sidebar,
body.is-home .topbar,
body.is-home .backdrop {
  display: none;
}

body.is-home main {
  margin-left: 0;
}


/* ==========================================================================
   Editor extras
   ========================================================================== */

.slug-hint {
  margin: -12px 0 20px;
  color: var(--muted);
  font-size: 0.875rem;
}

.settings {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.settings summary {
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

.settings .note {
  margin: 16px 0 24px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
}

.editor button:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 560px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* ==========================================================================
   Extra pages
   ========================================================================== */

.page h1 {
  margin-bottom: 24px;
}

.page .meta {
  margin: -12px 0 28px;
}