/* BerkeleyMono Font Faces */
@font-face {
  font-family: 'BerkeleyMono';
  src: url('/fonts/BerkeleyMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BerkeleyMono';
  src: url('/fonts/BerkeleyMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BerkeleyMono';
  src: url('/fonts/BerkeleyMono-Oblique.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'BerkeleyMono';
  src: url('/fonts/BerkeleyMono-Bold-Oblique.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* Color Palette - Triadic Bold */
:root {
  --sunflower-gold: #ffba49;
  --light-sea-green: #20a39e;
  --vibrant-coral: #ef5b5b;
  --midnight-violet: #23001e;
  --cool-steel: #a4a9ad;
  --white: #ffffff;
  --code-text: #5ee8df;

  /* Dark mode first */
  --bg: var(--midnight-violet);
  --bg-secondary: #2d0a28;
  --text: #f0f0f5;
  --text-muted: var(--cool-steel);
  --accent: var(--vibrant-coral);
  --link: var(--light-sea-green);
  --link-hover: #2bc4be;
  --highlight: var(--sunflower-gold);
  --code-bg: #2d0a28;
  --border: #4a2040;
  --radius: 2px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'BerkeleyMono', 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  font-size: 1rem;
  line-height: 1.7;
  background-color: var(--bg);
  color: var(--text);
}

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 2rem 0 1rem 0;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  position: relative;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.2rem; }
h4, h5, h6 { font-size: 1rem; }

/* Header decorations */
.post-content h1 {
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--vibrant-coral);
}

.post-content h2::before {
  content: '//';
  color: var(--vibrant-coral);
  margin-right: 0.5rem;
  opacity: 0.7;
}

.post-content h3::before {
  content: '>';
  color: var(--light-sea-green);
  margin-right: 0.5rem;
  opacity: 0.7;
}

p {
  margin: 1rem 0;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--accent);
  color: var(--white);
  padding: 0.5rem 1rem;
  z-index: 100;
  border-bottom: none;
}

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

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.site-title a {
  color: var(--text);
  border-bottom: none;
}

.site-title a::before {
  content: '>';
  color: var(--vibrant-coral);
  margin-right: 0.5rem;
}

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

.site-nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-nav a:hover {
  color: var(--light-sea-green);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.social-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* Post List */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-item {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--bg-secondary);
}

.post-item:last-child {
  border-bottom: none;
}

.post-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.post-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.post-title a {
  color: var(--text);
}

.post-title a:hover {
  color: var(--light-sea-green);
}

.post-summary {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Single Post */
.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-tags {
  margin-top: 0.5rem;
}

.post-tags a {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--light-sea-green);
  background: rgba(32, 163, 158, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  margin-right: 0.5rem;
  margin-bottom: 0.25rem;
}

.post-tags a::before {
  content: '#';
  color: var(--sunflower-gold);
}

.post-tags a:hover {
  background: rgba(239, 91, 91, 0.2);
  color: var(--vibrant-coral);
}

.post-content {
  margin-top: 2rem;
}

/* Inline Code */
code {
  font-family: 'BerkeleyMono', 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9em;
  background-color: rgba(32, 163, 158, 0.2);
  color: var(--code-text);
  padding: 0.15em 0.4em;
  border-radius: var(--radius);
  border: 1px solid rgba(32, 163, 158, 0.4);
}

/* Code Blocks */
.code-block {
  position: relative;
  margin: 1.5rem 0;
}

pre {
  background-color: var(--code-bg);
  color: var(--text);
  padding: 1rem;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--light-sea-green);
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* Copy Button */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--cool-steel);
  color: var(--midnight-violet);
  border: none;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--vibrant-coral);
  color: #fff;
}

.copy-btn.copied {
  background: var(--light-sea-green);
  color: #fff;
}

.copy-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  opacity: 1;
}

.copy-btn:focus:not(:focus-visible) {
  outline: none;
}

.copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  opacity: 1;
}

/* Blockquote */
blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
}

blockquote p {
  margin: 0;
}

/* Lists */
ul, ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

li {
  margin-bottom: 0.5rem;
}

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

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

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

th {
  font-weight: 700;
  color: var(--sunflower-gold);
}

/* Profile Section (Homepage) */
.profile {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(32, 163, 158, 0.1) 0%, rgba(239, 91, 91, 0.1) 100%);
  border-radius: var(--radius);
  border-left: 3px solid var(--sunflower-gold);
}

.profile-title {
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
  color: var(--sunflower-gold);
}

.profile-subtitle {
  color: var(--text-muted);
  margin: 0;
}

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

  .container {
    padding: 1.5rem 1rem;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}

/* Selection */
::selection {
  background-color: var(--vibrant-coral);
  color: #fff;
}

/* Scrollbar (webkit) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Light Mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa;
    --bg-secondary: #f0f0f0;
    --text: #23001e;
    --text-muted: #5a5a5a;
    --accent: var(--vibrant-coral);
    --link: #1a857f;
    --link-hover: var(--vibrant-coral);
    --code-bg: #f5f5f0;
    --code-text: #1a857f;
    --border: #ddd;
  }

  h1, h2, h3, h4, h5, h6,
  .site-title a,
  .post-title a {
    color: var(--midnight-violet);
  }

  th {
    color: var(--vibrant-coral);
  }

  .site-nav a:hover,
  .post-title a:hover {
    color: var(--vibrant-coral);
  }

  ::selection {
    background-color: var(--light-sea-green);
    color: #fff;
  }

  ::-webkit-scrollbar-track {
    background: var(--bg);
  }

  ::-webkit-scrollbar-thumb {
    background: #ccc;
  }

  .post-tags a {
    color: #1a857f;
    background: rgba(32, 163, 158, 0.1);
  }

  .post-tags a:hover {
    background: rgba(239, 91, 91, 0.15);
    color: var(--vibrant-coral);
  }

  .profile {
    background: linear-gradient(135deg, rgba(32, 163, 158, 0.08) 0%, rgba(255, 186, 73, 0.08) 100%);
  }

  .profile-title {
    color: var(--vibrant-coral);
  }

  .copy-btn {
    background: #666;
    color: #fff;
  }

  code {
    background-color: rgba(32, 163, 158, 0.12);
    color: #1a857f;
    border-color: rgba(32, 163, 158, 0.25);
  }
}

/* ============================================
   8-BIT STYLE ANIMATIONS
   ============================================ */

/* Blinking cursor after site title */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.site-title a::after {
  content: '_';
  color: var(--sunflower-gold);
  animation: blink 1s steps(1) infinite;
  margin-left: 0.1rem;
}

/* Stepped transitions for that retro feel */
a {
  transition: color 0.15s steps(3), border-color 0.15s steps(3);
}

.post-tags a {
  transition: background 0.2s steps(4), color 0.15s steps(3);
}

.copy-btn {
  transition: opacity 0.15s steps(3), background 0.15s steps(3);
}

/* Pixel-style hover underline on post titles */
.post-title a {
  position: relative;
}

.post-title a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--light-sea-green);
  transition: width 0.2s steps(6);
}

.post-title a:hover::after {
  width: 100%;
}

/* Subtle glow pulse on profile - 8-bit stepped */
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 186, 73, 0); }
  25% { box-shadow: 0 0 10px rgba(255, 186, 73, 0.1); }
  50% { box-shadow: 0 0 20px rgba(255, 186, 73, 0.15); }
  75% { box-shadow: 0 0 10px rgba(255, 186, 73, 0.1); }
}

.profile {
  animation: glow-pulse 4s steps(4) infinite;
}

/* Nav link pixel underline */
.site-nav a {
  position: relative;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--vibrant-coral), var(--sunflower-gold));
  transition: width 0.15s steps(4);
}

.site-nav a:hover::after {
  width: 100%;
}

/* Social links staggered hover */
.social-links a {
  transition: color 0.1s steps(2), transform 0.1s steps(2);
}

.social-links a:hover {
  color: var(--sunflower-gold);
  transform: translateY(-2px);
}
