@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;500;600&display=swap');

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

:root {
  --bg-deep: #110e0b;
  --bg-primary: #1a1410;
  --bg-surface: #231c15;
  --bg-elevated: #2c231a;
  --bg-code: #1e1812;
  --border: #3a2e22;
  --border-light: #4a3c2e;
  --text-primary: #e8dcc8;
  --text-secondary: #b8a68e;
  --text-muted: #8a7a66;
  --accent: #c9a96e;
  --accent-hover: #dbb97e;
  --accent-dim: #a08050;
  --link: #d4a85c;
  --link-hover: #e8c078;
  --scrollbar-thumb: #3a2e22;
  --scrollbar-track: #1a1410;
}

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body {
  font-family: 'Libre Baskerville', 'Georgia', serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.8;
  font-size: 17px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(26, 20, 16, 0.9);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.site-title:hover {
  color: var(--accent-hover);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-nav a {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 0.2s;
}

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

.coffee-icon {
  font-size: 1.1rem;
  opacity: 0.7;
}

/* Main content area */
.content-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

/* Audio player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 2rem;
  transition: border-color 0.3s;
}

.audio-player.playing {
  border-color: var(--accent-dim);
}

.audio-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg-deep);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.audio-play-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.audio-play-btn:active {
  transform: scale(0.97);
}

.audio-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.audio-progress-wrapper {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.audio-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.audio-progress-wrapper:hover {
  height: 6px;
}

.audio-progress-wrapper:hover .audio-progress-bar {
  background: var(--accent-hover);
}

.audio-time,
.audio-duration {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 2.5rem;
  text-align: right;
}

.audio-time::after {
  content: ' /';
  color: var(--border-light);
}

.audio-speed-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: center;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.audio-speed-btn:hover {
  color: var(--accent);
  border-color: var(--border-light);
}

.audio-player.scrubbing .audio-progress-wrapper {
  height: 6px;
}

.audio-player.scrubbing .audio-progress-bar {
  background: var(--accent-hover);
  transition: none;
}

/* Blog article */
.blog-article {
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typography */
.blog-article h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

.blog-article h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2.8rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.blog-article h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.blog-article p {
  margin-bottom: 1.4rem;
  color: var(--text-primary);
}

.blog-article strong {
  color: var(--accent);
  font-weight: 700;
}

.blog-article em {
  color: var(--text-secondary);
  font-style: italic;
}

.blog-article a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-dim);
  transition: all 0.2s;
}

.blog-article a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
}

/* Horizontal rule */
.blog-article hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2.5rem 0;
}

/* First hr is the metadata separator */
.blog-article hr:first-of-type {
  margin-top: 1.5rem;
}

/* Blockquote */
.blog-article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.8rem 0;
  background: var(--bg-surface);
  border-radius: 0 6px 6px 0;
}

.blog-article blockquote p {
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0;
}

/* Lists */
.blog-article ul,
.blog-article ol {
  margin-bottom: 1.4rem;
  padding-left: 1.5rem;
}

.blog-article li {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.blog-article li::marker {
  color: var(--accent-dim);
}

/* Code */
.blog-article code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.88em;
  background: var(--bg-elevated);
  color: var(--accent);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.blog-article pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.8rem 0;
  position: relative;
}

.blog-article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* Tables */
.blog-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.8rem 0;
  font-size: 0.92rem;
}

.blog-article th {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  color: var(--accent);
  border-bottom: 2px solid var(--border-light);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.blog-article td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.blog-article tr:hover td {
  background: var(--bg-surface);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 2rem;
}

.site-footer p {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.footer-separator {
  color: var(--accent-dim);
  margin: 0 0.5rem;
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--bg-surface);
  border-color: var(--border-light);
  color: var(--accent);
  transform: translateY(-2px);
}

/* Loading state */
.loading {
  text-align: center;
  padding: 4rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.75rem;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Selection */
::selection {
  background: rgba(201, 169, 110, 0.25);
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .content-wrapper {
    padding: 2rem 1.25rem 4rem;
  }

  .header-inner {
    padding: 0 1.25rem;
  }

  .blog-article h1 {
    font-size: 1.7rem;
  }

  .blog-article h2 {
    font-size: 1.25rem;
  }

  .blog-article pre {
    padding: 1rem;
    border-radius: 6px;
  }

  .blog-article table {
    font-size: 0.82rem;
  }

  .blog-article th,
  .blog-article td {
    padding: 0.5rem 0.6rem;
  }

  .audio-player {
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
  }

  .audio-label {
    display: none;
  }

  .audio-play-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 36px;
    height: 36px;
  }
}
