/*
 * brianli.com — Ghost theme stylesheet
 * Faithfully ported from the Astro + StyleX design system.
 */

:root {
  --bg: #18181b;
  --fg: #e4e4e7;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --faint: #52525b;
  --twitter: #00acee;
  --github: #6e5494;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Reset */
*,
::before,
::after,
::backdrop {
  box-sizing: border-box;
  border: 0 solid;
  margin: 0;
  padding: 0;
}

html {
  background-color: var(--bg);
  color-scheme: dark;
  min-width: 20rem;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.5;
  margin: 0;
  min-height: 100vh;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

a {
  color: inherit;
  text-decoration: inherit;
}

b, strong {
  font-weight: bolder;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 1em;
}

sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub { bottom: -0.25em; }
sup { top: -0.5em; }

table {
  border-collapse: collapse;
  border-color: inherit;
  text-indent: 0;
}

summary { display: list-item; }
ol, ul, menu { list-style: none; }

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

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

button, input, select, optgroup, textarea {
  background-color: transparent;
  border-radius: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
}

button, input:where([type="button"], [type="reset"], [type="submit"]) {
  appearance: button;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible {
  border-radius: 0.25rem;
  outline: 2px solid var(--muted);
  outline-offset: 0.2rem;
}

/* Lock page scroll while the navigation popover is open */
html:has(#site-navigation:popover-open) {
  overflow: hidden;
}

/* Site Shell */
.site-shell {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: 100vh;
}

@media (min-width: 40rem) {
  .site-shell {
    gap: 3rem;
  }
}

.site-main {
  flex: auto;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  width: 100%;
}

.centered {
  margin-inline: auto;
  max-width: 36rem;
  padding-inline: 1rem;
  width: 100%;
}

.full-width {
  width: 100%;
}

.wrap-anywhere {
  overflow-wrap: anywhere;
}

.no-margin {
  margin: 0;
}

/* Header & Popover Navigation */
.header-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 3rem;
  padding-inline: 1rem;
  width: 100%;
}

.brand {
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  text-transform: lowercase;
}

.color-link {
  color: var(--subtle);
  text-decoration-line: none;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, fill 150ms ease, stroke 150ms ease;
}

.color-link:hover {
  color: var(--fg);
  text-decoration-line: underline;
}

.icon-button {
  align-items: center;
  background-color: transparent;
  border: 0 solid;
  color: var(--subtle);
  cursor: pointer;
  display: inline-grid;
  justify-items: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem;
  transition: color 150ms ease;
}

.icon-button:hover {
  color: var(--fg);
}

.icon-24 {
  height: 1.5rem;
  width: 1.5rem;
}

.nav-dialog {
  background-color: var(--bg);
  border: 0 solid;
  color: var(--fg);
  height: 100%;
  inset: 0;
  margin: 0;
  max-height: none;
  max-width: none;
  padding: 0;
  width: 100%;
}

.nav-dialog:popover-open {
  display: grid;
  grid-template-rows: 3rem 1fr 3rem;
}

.nav-dialog::backdrop {
  background-color: var(--bg);
}

.nav-center {
  align-items: center;
  display: flex;
  justify-content: center;
}

.nav-list {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  list-style-type: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.5;
  text-decoration-line: none;
  text-transform: lowercase;
  transition: color 150ms ease;
}

.nav-link:hover {
  color: var(--fg);
  text-decoration-line: underline;
}

/* Footer & Socials */
.site-footer {
  align-items: center;
  color: var(--subtle);
  display: flex;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  justify-content: space-between;
  letter-spacing: -0.025em;
  line-height: 1.5;
  min-height: 3rem;
  padding-inline: 1rem;
  width: 100%;
}

.social-links {
  align-items: center;
  display: flex;
  gap: 1rem;
}

.twitter-link {
  color: var(--subtle);
  transition: color 150ms ease;
}

.twitter-link:hover {
  color: var(--twitter);
}

.github-link {
  color: var(--subtle);
  transition: color 150ms ease;
}

.github-link:hover {
  color: var(--github);
}

.social-icon {
  fill: currentColor;
  height: 1rem;
  width: 1rem;
}

/* Articles & Typography */
.article {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.entry-meta {
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.heading {
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
}

.page-heading {
  font-size: 1.5rem;
}

.entry-heading {
  font-size: 1.25rem;
}

.title-link {
  text-decoration-line: none;
}

.title-link:hover {
  text-decoration-line: underline;
}

.muted-link {
  color: var(--muted);
  font-family: var(--font-sans);
  text-decoration-line: none !important;
}

.muted-link:hover {
  text-decoration-line: underline !important;
}

.inline-link {
  text-decoration-line: underline;
}

.inline-link:hover {
  text-decoration-line: none;
}

.paragraph {
  margin-block: 0 1rem;
}

/* Post Content */
.post-content {
  overflow-wrap: anywhere;
  width: 100%;
}

.post-content > :where(p, h1, h2, h3, h4, h5, h6, ol, ul, hr) {
  margin-inline: auto;
  max-width: 36rem;
  padding-inline: 1rem;
  width: 100%;
}

.post-content hr {
  border-top: 1px solid #27272a;
  margin-block: 2rem;
}

.post-content p {
  margin-block: 0 1rem;
}

.post-content a {
  text-decoration-line: underline;
}

.post-content a:hover {
  text-decoration-line: none;
}

.post-content :where(h1, h2, h3, h4, h5, h6) {
  font-weight: 700;
  line-height: 1.25;
  margin-block: 2rem 0.5rem;
}

.post-content :where(h1, h2) { font-size: 1.5rem; }
.post-content h3 { font-size: 1.325rem; }
.post-content h4 { font-size: 1.2rem; }
.post-content :where(h5, h6) { font-size: 1.15rem; }

.post-content blockquote {
  border-color: #333;
  border-left-width: 0.5rem;
  font-size: 0.9rem;
  margin-block: 0 1.5rem;
  margin-inline: auto;
  max-width: 36rem;
  padding-left: 1rem;
  width: 100%;
}

.post-content blockquote > :first-child { margin-top: 0; }
.post-content blockquote > :last-child { margin-bottom: 0; }

.post-content :where(ol, ul) {
  margin-block: 0 1.5rem;
  padding-left: 2.5rem;
}

.post-content ol li { list-style-type: decimal; }
.post-content ul li { list-style-type: square; }
.post-content li:not(:last-child) { margin-bottom: 0.25rem; }

.post-content pre {
  background: #27272a !important;
  color: #f8f8f2;
  line-height: 1.2;
  margin-block: 1.5rem;
  margin-inline: auto;
  max-width: 34rem;
  overflow-x: auto;
  padding: 1.5rem;
  width: calc(100% - 2rem);
}

.post-content code {
  background-color: #27272a;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1rem;
  padding: 0.15rem 0.25rem;
}

.post-content pre code {
  background-color: transparent;
  border-width: 0;
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 0;
}

.post-content .table {
  display: block;
  margin-block: 2rem;
  margin-inline: auto;
  max-width: 48rem;
  overflow-x: auto;
  padding-inline: 1rem;
  width: 100%;
}

.post-content table {
  border-collapse: collapse;
  table-layout: auto;
  text-align: left;
  width: 100%;
}

.post-content :where(td, th) {
  border-color: #424242;
  border-width: 1px;
  padding: 0.5rem 1rem;
  white-space: nowrap;
}

.post-content th {
  background-color: #212121;
}

/* Images, Figures, and Ghost Koenig Cards */
.post-content > :where(figure, img, iframe, video),
.post-content > p:has(> img:only-child),
.post-content > .kg-card {
  margin-block: 2rem;
  margin-inline: auto;
  max-width: 48rem;
  width: 100%;
}

.post-content figure img,
.post-content > img,
.post-content > p > img:only-child {
  display: block;
  height: auto;
  margin-inline: auto;
  width: 100%;
}

.post-content figcaption {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.25rem;
  margin-inline: auto;
  margin-top: 0.5rem;
  max-width: 36rem;
  padding-inline: 1rem;
  text-align: center;
}

.post-content .content-image {
  max-width: 40rem;
}

.post-content .content-image--wide,
.post-content .kg-width-wide {
  max-width: 48rem;
}

.post-content .content-image--full,
.post-content .kg-width-full {
  max-width: 100%;
}

.post-content .content-gallery,
.post-content .kg-gallery-card {
  max-width: 64rem;
  width: 100%;
}

.post-content .content-gallery-grid {
  display: grid;
  gap: 0.25rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-content .content-gallery-grid img {
  display: block;
  height: auto;
  width: 100%;
}

.post-content .kg-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-content .kg-gallery-row {
  display: flex;
  gap: 0.5rem;
}

.post-content .kg-gallery-image img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.post-content .footnotes {
  margin-inline: auto;
  max-width: 36rem;
  padding-inline: 1rem;
  width: 100%;
}

.post-content .sr-only {
  border-width: 0;
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Photo Figures & EXIF Details */
.photo-figure {
  margin-inline: auto;
  margin-top: 1.5rem;
  max-width: 48rem;
  width: 100%;
}

.responsive-image {
  display: block;
  height: auto;
  margin-inline: auto;
  width: 100%;
}

.photo-caption {
  align-items: baseline;
  color: var(--muted);
  display: flex;
  font-size: 0.875rem;
  gap: 1rem;
  justify-content: flex-end;
  line-height: 1.5;
  margin-top: 0.35rem;
  padding-inline: 1rem;
  text-align: right;
}

.exif-details {
  margin-left: auto;
}

.exif-summary {
  cursor: pointer;
  list-style-type: none;
}

.exif-summary::-webkit-details-marker {
  display: none;
}

[data-exif-details]:not([open]) [data-exif-open],
[data-exif-details][open] [data-exif-closed] {
  display: none;
}

.exif-list {
  font-size: 0.75rem;
  line-height: 1.45;
  list-style-type: none;
  margin-block: 0.25rem 1.5rem;
  padding: 0;
}

.exif-list li {
  list-style-type: none;
  margin: 0;
}

/* Photo Grid (/photos/) */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-block: 2rem;
  width: 100%;
}

.photo-grid-link {
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  opacity: 1;
  transition: opacity 150ms ease;
}

.photo-grid-link:hover {
  opacity: 0.8;
}

.photo-grid-link img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

@media (min-width: 40rem) {
  .post-content :where(ol, ul) { padding-left: 3rem; }
  .post-content .content-gallery-grid { gap: 0.5rem; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 48rem) {
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 64rem) {
  .photo-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 80rem) {
  .photo-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Tags */
.tag-nav {
  font-family: var(--font-mono);
}

.tag-nav:not(:has(li)) {
  display: none;
}

.tag-heading {
  text-transform: lowercase;
}

.tag-list {
  column-gap: 0.625rem;
  display: flex;
  flex-wrap: wrap;
  list-style-type: none;
  margin: 0;
  padding: 0;
  row-gap: 0.3rem;
}

.tag-link {
  color: var(--faint);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.5;
  text-decoration-line: none;
  text-transform: lowercase;
}

.tag-link:hover {
  text-decoration-line: underline;
}

/* Archive & Tag Entry List */
.entry-list {
  list-style-type: none;
  margin-block: 0;
}

.entry-list-item {
  align-items: baseline;
  display: flex;
  flex-direction: column;
  list-style-type: none;
  margin: 0 0 0.5rem;
}

.entry-list-item:last-child {
  margin-bottom: 0;
}

.entry-list-time {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.entry-list-link {
  line-height: 1.25;
  text-decoration-line: none;
}

.entry-list-link:hover {
  text-decoration-line: underline;
}

/* Pagination */
.pagination {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
}

.newer-link {
  color: var(--muted);
  order: 1;
  text-decoration-line: none;
}

.newer-link:hover {
  text-decoration-line: underline;
}

.older-link {
  color: var(--muted);
  margin-left: auto;
  order: -1;
  text-decoration-line: none;
}

.older-link:hover {
  text-decoration-line: underline;
}
