/* === CSS Custom Properties === */
:root {
  --bg: #f7f7f8;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --hover-bg: #ededee;
  --border-color: #e5e5e5;
  --code-bg: #f1f1f1;
  --selection-bg: #b4d5fe;
  --max-width: 692px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
}

/* === Base Reset & Typography === */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
}

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

/* === Container === */
.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  padding-bottom: 64px;
}

/* === Links === */
a {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
}

a:hover {
  color: inherit;
}

/* === Headings === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}

h1::before, h2::before, h3::before,
h4::before, h5::before, h6::before {
  content: none;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4, h5, h6 { font-size: 1rem; }

/* === Header === */
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 24px;
}

header .main {
  font-size: 1rem;
  font-weight: 500;
}

header .main a {
  color: var(--text-primary);
}

header .main a:hover {
  background: none;
}

header nav {
  display: flex;
  gap: 4px;
}

header nav a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

header nav a:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

/* === Homepage Sections === */
.section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: 0;
}

.home-section {
  margin-top: 56px;
}

.home-section:first-child {
  margin-top: 24px;
}

/* === Bio / Intro === */
.bio p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  margin: 0 0 12px 0;
}

.bio a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-color);
  text-underline-offset: 3px;
}

.bio a:hover {
  text-decoration-color: var(--text-primary);
}

/* === Item Links (projects, writing cards) === */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.items-list:not(.items-grid) .item-link {
  margin: 0 -12px;
}

.item-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background-color 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.item-link:hover {
  background-color: var(--hover-bg);
}

.item-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.item-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.item-date {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.item-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.5;
}

/* === Project Items (with logo) === */
.project-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.project-details {
  min-width: 0;
  flex: 1;
}

/* === Read More Link === */
.read-more {
  display: inline-block;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 10px;
  margin-top: 8px;
  margin-left: -10px;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.read-more:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

/* === Social Links === */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: -10px;
}

.social-links a {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.social-links a:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

/* === Footer === */
footer {
  border-top: 1px solid var(--border-color);
  padding: 24px 0;
  margin-top: 64px;
}

.footer-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* === Paragraphs === */
p {
  font-family: var(--font-sans);
  line-height: 1.7;
}

/* === Lists === */
ul {
  list-style: disc;
  padding-left: 1.5em;
}

ul li {
  text-indent: 0;
}

ul > li::before {
  content: none;
}

ol {
  padding-left: 1.5em;
}

/* === Post List Page === */
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
}

.page-title::before {
  content: none;
}

/* === Single Post === */
article .title h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
  margin-top: 0;
}

article .title h1::before {
  content: none;
}

article .meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

article .body {
  font-size: 16px;
  line-height: 1.75;
}

article .body a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-color);
  text-underline-offset: 3px;
}

article .body a:hover {
  text-decoration-color: var(--text-primary);
  background: none;
}

article .body p {
  margin-bottom: 1.25em;
}

article .body ul,
article .body ol {
  margin-bottom: 1.25em;
}

/* === Code === */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

pre {
  background-color: #1a1a2e;
  color: #e5e5e5;
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.5em 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  color: inherit;
  border-radius: 0;
}

/* === Blockquotes === */
blockquote {
  border-left: 3px solid var(--border-color);
  margin: 1.5em 0;
  padding-left: 1em;
  color: var(--text-secondary);
}

blockquote p {
  margin: 0;
}

/* === Images === */
img {
  max-width: 100%;
  height: auto;
  border: none;
  border-radius: 8px;
}

figure {
  margin: 1.5em 0;
}

figcaption {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* === Tables === */
table {
  border-spacing: 0;
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
}

table th,
table td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  font-size: 14px;
  text-align: left;
}

table th {
  font-weight: 600;
  background-color: var(--hover-bg);
}

/* === Tags === */
.tags {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 32px;
}

.tags li {
  text-indent: 0;
}

.tags li::before {
  content: none;
}

.tags a {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  background-color: var(--hover-bg);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tags a:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

/* === Horizontal Rule === */
hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

/* === Time === */
time {
  color: var(--text-muted);
  font-size: 13px;
}

/* === Draft Label === */
.draft-label {
  color: #e67e22;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: #fef3e2;
  font-weight: 500;
}

/* === Description === */
.description {
  color: var(--text-secondary);
  font-size: 14px;
}

/* === TL;DR === */
.tldr {
  background-color: var(--hover-bg);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  font-size: 15px;
  color: var(--text-secondary);
}

/* === Syntax Highlighting === */
.highlight {
  position: relative;
  margin: 1.5em 0;
}

/* === Welcome section (legacy compat) === */
.welcome-section {
  margin-top: 24px;
}

.welcome-section p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
}

/* === Callout === */
.callout {
  background-color: var(--hover-bg);
  border-radius: 8px;
  padding: 16px;
  margin: 1.5em 0;
}

.callout-inner {
  font-size: 15px;
  color: var(--text-secondary);
}

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 0;
  margin-top: 32px;
}

.pagination .page-link {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}

.pagination .page-link:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

/* === SVG icons === */
svg {
  max-height: 15px;
}

/* === Listening Page — Track Items === */
.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin: 0 -12px;
  border-radius: 8px;
  transition: background-color 0.15s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.track-item:hover {
  background-color: var(--hover-bg);
}

.now-playing-active {
  padding-left: 28px;
}

.track-art {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.track-art-empty {
  background-color: var(--hover-bg);
}

.track-info {
  min-width: 0;
  flex: 1;
}

.track-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-time {
  color: var(--text-muted);
  font-size: 13px;
}

/* === Listening Page — Artist Items === */
.artist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin: 0 -12px;
  border-radius: 8px;
  transition: background-color 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.artist-item:hover {
  background-color: var(--hover-bg);
}

.artist-art {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.artist-art-empty {
  background-color: var(--hover-bg);
}

.artist-info {
  min-width: 0;
  flex: 1;
}

.artist-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Listening Page — Now Playing Dot === */
.now-playing-dot {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #1DB954;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
  50% { opacity: 0.5; transform: translateY(-50%) scale(0.8); }
}

/* === Listening Page — Time Range Tabs === */
.time-range-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  margin-left: -10px;
}

.tab-btn {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  font-weight: 500;
  background-color: var(--hover-bg);
}

/* === Listening Page — Skeleton Loading === */
.skeleton-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin: 0 -12px;
}

.skeleton-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--hover-bg) 25%, #e8e8e9 50%, var(--hover-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

.skeleton-text-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-text {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--hover-bg) 25%, #e8e8e9 50%, var(--hover-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Listening Page — Scrollable List === */
.scrollable-list {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollable-list::-webkit-scrollbar {
  display: none;
}

/* === Listening Page — States === */
.not-playing {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.section-error {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* === Responsive === */
@media screen and (max-width: 600px) {
  .content {
    padding: 0 16px;
    padding-bottom: 48px;
  }

  .home-section {
    margin-top: 40px;
  }

  header {
    padding: 16px;
  }

  article .title h1 {
    font-size: 1.3rem;
  }

  .items-grid {
    grid-template-columns: 1fr;
  }
}
