/* SYSTEMS / BRUTALIST MINIMALISM
   Focus: Readability, Accessibility, and Semantic Structure
   By Michael Harley
*/

/* === VARIABLES & RESET === */
:root {
  color-scheme: light dark;
  --bg-color: #f7f5f0;
  --text-color: #2b2b2b;
  --heading-color: #1a1a1a;
  --border-color: #1a1a1a;
  --border-subtle: #e9e7e1;
  --code-bg: #edebe5;
  --pre-bg: #f2f0ea;
  --link-color: #1a0dab;
  --focus-ring: #1a0dab;
  --muted-color: #5a5a5a;

  --font-sans: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #262626;
    --text-color: #d1d1d1;
    --heading-color: #ffffff;
    --border-color: #ffffff;
    --border-subtle: #383838;
    --code-bg: #1c1c1c;
    --pre-bg: #1c1c1c;
    --link-color: #8ab4f8;
    --muted-color: #9a9a9a;
  }
}

/* Manual theme overrides (set via toggle) */
[data-theme="light"] {
  --bg-color: #f7f5f0;
  --text-color: #2b2b2b;
  --heading-color: #1a1a1a;
  --border-color: #1a1a1a;
  --border-subtle: #e9e7e1;
  --code-bg: #edebe5;
  --pre-bg: #f2f0ea;
  --link-color: #1a0dab;
  --focus-ring: #1a0dab;
  --muted-color: #5a5a5a;
}

[data-theme="dark"] {
  --bg-color: #262626;
  --text-color: #d1d1d1;
  --heading-color: #ffffff;
  --border-color: #ffffff;
  --border-subtle: #383838;
  --code-bg: #1c1c1c;
  --pre-bg: #1c1c1c;
  --link-color: #8ab4f8;
  --muted-color: #9a9a9a;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  line-height: 1.6;
  margin: 0;
  color: var(--text-color);
  background-color: var(--bg-color);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* === ACCESSIBILITY & UTILITY === */
.wrapper {
  max-width: 65ch;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--heading-color);
  color: var(--bg-color);
  padding: 1rem;
  z-index: 100;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.skip-link:focus { top: 0; outline: none; }

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

::selection {
  background: var(--link-color);
  color: #fff;
}

/* === TYPOGRAPHY & GLOBAL ELEMENTS === */
h1, h2, h3 {
  color: var(--heading-color);
  line-height: 1.1;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 1.25rem;
  letter-spacing: normal;
}

h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

.page-hero-title {
  font-size: 2rem;
  margin-top: 0;
}

a {
  color: var(--link-color);
  text-underline-offset: 2px;
  transition: opacity 0.2s;
}

a:hover { opacity: 0.7; }

/* External link indicator */
a[target="_blank"]::after {
  content: "";
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-left: 0.25em;
  margin-bottom: -0.05em;
  background-color: var(--border-color);
  mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M9 2L9 3L12.3 3L6 9.3L6.7 10L13 3.7L13 7L14 7L14 2L9 2z M4 4C2.9 4 2 4.9 2 6L2 12C2 13.1 2.9 14 4 14L10 14C11.1 14 12 13.1 12 12L12 7L11 8L11 12C11 12.6 10.6 13 10 13L4 13C3.4 13 3 12.6 3 12L3 6C3 5.4 3.4 5 4 5L8 5L9 4L4 4z"/></svg>');
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M9 2L9 3L12.3 3L6 9.3L6.7 10L13 3.7L13 7L14 7L14 2L9 2z M4 4C2.9 4 2 4.9 2 6L2 12C2 13.1 2.9 14 4 14L10 14C11.1 14 12 13.1 12 12L12 7L11 8L11 12C11 12.6 10.6 13 10 13L4 13C3.4 13 3 12.6 3 12L3 6C3 5.4 3.4 5 4 5L8 5L9 4L4 4z"/></svg>');
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  opacity: 0.6;
}

p, ul, ol { margin-bottom: 1.75rem; }
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.5rem; }

.post-subhead + .post-subhead {
  margin-top: -1.25rem;
}

.site-description,
.post-subhead,
.post-meta time,
.c-tags {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-color);
}

hr {
  border: 0;
  border-top: 2px solid var(--border-color);
  margin: 4rem 0;
}

/* === SITE HEADER === */
.site-header {
  margin-top: 2rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

.site-title { margin: 0; font-size: 1.25rem; font-weight: .600; line-height: 1.1; }
.site-title a { text-decoration: none; color: var(--heading-color); }

.site-description {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-decoration: none;
}

/* === THEME TOGGLE === */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-color);
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.theme-toggle:hover {
  opacity: 1;
}

.site-nav .theme-toggle {
  margin-left: auto;
}

/* Standalone toggle (post pages without site header) */
.wrapper > .theme-toggle {
  float: right;
  margin-top: 1rem;
}

/* Show sun in dark mode, moon in light mode */
.icon-sun { display: none; }
.icon-moon { display: inline; }

@media (prefers-color-scheme: dark) {
  .icon-sun { display: inline; }
  .icon-moon { display: none; }
}

[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

/* === POST LISTINGS === */
.latest-posts ul,
.post-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 2rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border-subtle);
  align-items: baseline;
}

.post-link {
  color: var(--link-color);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  display: block;
  margin-bottom: 0.5rem;
}


.post-link:hover {
  opacity: 0.7;
  text-decoration-thickness: 2px;
}

.post-summary {
  font-size: 1.05rem;
  margin: 0;
  max-width: 50ch;
  opacity: 0.85;
}

/* === POST CONTENT === */
.post-content {
  margin-top: 2rem;
}

/* === HEADING ANCHORS === */
.heading-anchor {
  text-decoration: none;
  color: var(--link-color);
  font-weight: 400;
  margin-left: 0.25em;
  opacity: 0;
  transition: opacity 0.2s;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 0.5;
}

.heading-anchor:hover {
  opacity: 1;
}

.update-banner {
  margin: 1.75rem 0;
  padding: 0.5rem 1rem;
  border-left: 2px solid var(--text-color);
  font-size: 0.85rem;
}

.update-banner p {
  margin-bottom: 0;
}

blockquote {
  margin: 3rem 0;
  padding: 1rem 2rem;
  border-left: 4px solid #888;
  background-color: var(--code-bg);
  font-style: italic;
  font-size: 1.2rem;
}

pre {
  background: var(--pre-bg);
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  margin: 2.5rem 0;
  border-radius: 6px;
}

code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 0.2rem 0.4rem;
  font-size: 0.9em;
  border-radius: 3px;
}

pre code {
  padding: 0;
  background: none;
  border-radius: 0;
}

/* === CODE BLOCK COPY BUTTON === */
pre {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--text-color);
  line-height: 1;
}

pre:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 0.5;
}

.copy-btn:hover {
  opacity: 1 !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

thead th {
  border-bottom: 2px solid var(--border-color);
  font-weight: bold;
}

.author-bio {
  margin-top: 2.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background-color: var(--code-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-info h2 { margin: 0 0 0.5rem 0; font-size: 1.1rem; font-weight: 700; }
.author-info p { margin: 0; font-size: 0.95rem; line-height: 1.5; }
.author-info p + p { margin-top: 0.5rem; }

.end-of-article {
  margin-top: 3rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

.end-of-article::before {
  content: "⁂";
  display: inline-block;
  font-size: 1.5rem;
  opacity: 0.8;
}

/* === BOOK LISTINGS === */
.rating-scale {
  list-style: none;
  padding: 0;
}

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

.book-entry-summary {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-subtle);
  align-items: baseline;
}

.book-link {
  color: var(--link-color);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.book-link:hover {
  opacity: 0.7;
  text-decoration-thickness: 2px;
}

.book-author {
  opacity: 0.85;
}

.book-rating {
  letter-spacing: 0.1em;
  color: #00a843;
}

@media (prefers-color-scheme: dark) {
  .book-rating { color: #00e054; }
}

[data-theme="dark"] .book-rating { color: #00e054; }
[data-theme="light"] .book-rating { color: #00a843; }

.book-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}


@media (max-width: 700px) {
  .book-entry-summary { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* === WATCH LISTINGS === */
.watch-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.watch-entry-summary {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-subtle);
  align-items: baseline;
}

.watch-link {
  color: var(--link-color);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.watch-link:hover {
  opacity: 0.7;
  text-decoration-thickness: 2px;
}

.watch-year {
  opacity: 0.7;
}

.watch-type {
  opacity: 0.85;
}


@media (max-width: 700px) {
  .watch-entry-summary { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* === ENTRY META (shared by book + watch detail pages) === */
.entry-meta {
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
}

.entry-meta dt {
  font-weight: 700;
}

.entry-meta dd {
  margin: 0;
}

.entry-meta dd[aria-label*="stars"] {
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  color: #00a843;
}

@media (prefers-color-scheme: dark) {
  .entry-meta dd[aria-label*="stars"] { color: #00e054; }
}

[data-theme="dark"] .entry-meta dd[aria-label*="stars"] { color: #00e054; }
[data-theme="light"] .entry-meta dd[aria-label*="stars"] { color: #00a843; }

/* === FAVORITE BADGE === */
.favorite-badge {
  color: #d4a017;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .favorite-badge { color: #f5c518; }
}

[data-theme="dark"] .favorite-badge { color: #f5c518; }
[data-theme="light"] .favorite-badge { color: #d4a017; }

/* === SITE FOOTER === */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 0 4rem 0;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.site-footer p { margin: 0; white-space: nowrap; }
.site-footer nav { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.site-footer nav a { white-space: nowrap; }

.rss-link { text-decoration: none; }
.rss-link span { text-decoration: underline; }
.rss-link:hover span { text-decoration: none; }
.rss-icon { vertical-align: -1px; margin-right: 0.2em; }

/* === RESPONSIVE / MOBILE === */
@media (max-width: 700px) {
  body { font-size: 1.125rem; }
  .wrapper { padding: 0 1rem; }
  .site-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
  .site-nav { gap: 1rem; }
  .post-entry { grid-template-columns: 1fr; gap: 0.5rem; }
  .author-bio { flex-direction: column; text-align: center; }
  .site-footer {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }
}

/* === IMAGES === */
img,
picture {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

.constrained-img {
  max-width: 500px;
  margin: 1.5rem auto;
}

figure {
  margin: 2em 0;
}

figcaption {
  font-size: 0.9em;
  font-style: italic;
  text-align: center;
  margin-top: 0.5em;
  opacity: 0.8;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 2rem 0;
}

.photo-grid img,
.photo-grid picture {
  margin: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1;
  border-radius: 2px;
}

@media (max-width: 30em) {
  .photo-grid {
    grid-template-columns: 1fr;
  }
}
