/* ==========================================================================
   Font Loading
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Inter'), local('Inter-Regular');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local('Inter'), local('Inter-SemiBold');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Inter'), local('Inter-Bold');
}

@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Fira Code'), local('FiraCode-Regular');
}

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
  /* Color Scheme */
  color-scheme: dark;

  /* Colors - Background */
  --bg: #0d1219;
  --surface: #16192a;
  --surface-alt: #1e2236;

  /* Colors - Text */
  --text: #ffffff;
  --text-high-contrast: #ffffff;
  --text-heading: #f0c899;
  --muted: #9aa5bc;
  --muted-dark: #6b7a99;

  /* Colors - Accent */
  --accent: #5fb3f5;
  --accent-secondary: #6ec4ff;
  --accent-tertiary: #4a9bd8;
  --accent-soft: rgba(95, 179, 245, 0.12);

  /* Colors - UI Elements */
  --border: rgba(100, 125, 165, 0.2);
  --code-bg: #0f1420;
  --code-text: #ffffff;
  --shadow: 0 18px 55px rgba(5, 8, 12, 0.6);

  /* Layout */
  --layout-max-width: 960px;
  --layout-gutter: clamp(0.75rem, 3vw, 1.5rem);
  --layout-gutter-tight: clamp(0.65rem, 2.5vw, 1.25rem);
  --content-max-width: 680px;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

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

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, rgba(95, 179, 245, 0.04), transparent 60%),
    radial-gradient(circle at 80% 10%, rgba(110, 196, 255, 0.06), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ==========================================================================
   Focus States
   ========================================================================== */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.post-card__row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
}

.section-heading__rss:focus-visible,
.post__back:focus-visible,
.site-footer__social a:focus-visible {
  outline: 2px solid var(--accent-secondary);
  outline-offset: 3px;
}

/* ==========================================================================
   Layout - Site Structure
   ========================================================================== */

.site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1;
  max-width: var(--layout-max-width);
  width: min(100%, var(--layout-max-width));
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2rem) var(--layout-gutter) clamp(2rem, 5vw, 2.5rem);
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
}

.site-header__inner {
  max-width: var(--layout-max-width);
  width: min(100%, var(--layout-max-width));
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1rem) var(--layout-gutter-tight);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header__brand {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-high-contrast);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  margin-top: 2.5rem;
  padding: clamp(1.25rem, 3vw, 1.5rem) var(--layout-gutter) clamp(1.5rem, 4vw, 2rem);
  background: rgba(13, 18, 25, 0.3);
  backdrop-filter: blur(12px);
}

.site-footer__inner {
  max-width: var(--layout-max-width);
  width: min(100%, var(--layout-max-width));
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.site-footer__social {
  list-style: none;
  display: flex;
  gap: 1rem;
  padding: 0;
  margin: 0;
}

.site-footer__social a {
  color: var(--accent);
  transition: color 0.2s ease;
}

.site-footer__social a:hover,
.site-footer__social a:focus {
  color: var(--accent-secondary);
}

.site-footer__credits p {
  margin: 0;
  color: var(--text);
}

/* ==========================================================================
   Section Heading
   ========================================================================== */

.section-heading-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.section-heading {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text-high-contrast);
}

.section-heading__rss {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s ease;
}

.section-heading__rss:hover,
.section-heading__rss:focus {
  color: var(--accent-secondary);
}

.section-subtitle {
  margin: 0 0 1.5rem;
  max-width: 640px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ==========================================================================
   Post Listing
   ========================================================================== */

.post-listing {
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
}

.post-card__row {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 1.5rem);
  padding: clamp(0.625rem, 2vw, 0.75rem) 0;
  position: relative;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: all 0.3s ease;
}

.post-card__row::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--text-heading), var(--accent));
  transition: width 0.3s ease;
}

.post-card__row:hover,
.post-card__row:focus {
  color: var(--accent);
  padding-left: 0.5rem;
}

.post-card__row:hover::after,
.post-card__row:focus::after {
  width: 100%;
}

.post-card__date {
  min-width: 110px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  transition: color 0.3s ease;
}

.post-card__row:hover .post-card__date,
.post-card__row:focus .post-card__date {
  color: var(--text-heading);
}

.post-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.post-card__title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text-high-contrast);
}

.post-card__meta {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted-dark);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ==========================================================================
   Feature Grid
   ========================================================================== */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem;
  margin: 3rem 0 4rem;
}

.feature {
  padding: 1.75rem 2rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(5, 8, 12, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.feature:hover {
  transform: translateY(-4px);
  border-color: rgba(95, 179, 245, 0.4);
  box-shadow: 0 20px 40px rgba(5, 8, 12, 0.3);
}

.feature h3 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.feature p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ==========================================================================
   Archive
   ========================================================================== */

.archive__header {
  margin-bottom: 2.5rem;
}

.archive__title {
  margin-bottom: 0.5rem;
  font-size: clamp(2.25rem, 5vw, 3rem);
}

.archive__description {
  max-width: 640px;
  color: var(--muted);
}

.archive__list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.archive-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.5rem;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(5, 8, 12, 0.12);
}

.archive-item__date {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.archive-item__title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.archive-item__excerpt {
  margin: 0 0 1rem;
  color: var(--muted);
}

.archive-item__tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.archive-item__tags li {
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   Page & Post - Title and Meta
   ========================================================================== */

.page__title,
.post__title {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--text-high-contrast);
}

.page__description,
.post__description {
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--muted);
}

.post__meta {
  margin-bottom: 1rem;
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}

.post__footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post__back {
  display: inline-block;
  font-size: 0.9375rem;
  color: var(--muted);
  transition: color 0.2s ease;
}

.post__back:hover,
.post__back:focus {
  color: var(--accent);
}

/* ==========================================================================
   Post Content - Typography
   ========================================================================== */

.page__content,
.post__content {
  max-width: var(--content-max-width);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text);
}

.post__content h2 {
  margin-top: 2rem;
  margin-bottom: 0.875rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--text-heading);
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--text-heading), transparent) 1;
  padding-bottom: 0.375rem;
}

.post__content h3 {
  margin-top: 1.75rem;
  margin-bottom: 0.625rem;
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text);
}

.post__content h4 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--text);
}

.post__content > p,
.post__content > ul,
.post__content > ol {
  margin-bottom: 1.25rem;
}

.post__content > p + p {
  margin-top: 0;
}

.post__content > blockquote,
.post__content > .highlight,
.post__content > pre {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.post__content strong {
  font-weight: 600;
  color: var(--text-high-contrast);
}

.post__content em {
  font-style: italic;
  color: var(--text);
}

.post__content a {
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.post__content a:hover {
  color: var(--accent-secondary);
}

/* ==========================================================================
   Post Content - Lists
   ========================================================================== */

.post__content ul,
.post__content ol {
  padding-left: 1.5em;
}

.post__content li {
  margin-bottom: 0.5rem;
  line-height: 1.75;
}

.post__content li::marker {
  font-weight: 600;
  color: var(--text);
}

/* ==========================================================================
   Post Content - Images
   ========================================================================== */

.post__content img {
  max-width: 100%;
  margin: 2rem 0;
  border-radius: 16px;
  box-shadow: 0 14px 30px rgba(5, 8, 12, 0.15);
}

/* ==========================================================================
   Typography - Blockquotes
   ========================================================================== */

blockquote {
  position: relative;
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-style: italic;
  line-height: 1.6;
  border-left: 3px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

blockquote p:first-child {
  margin-top: 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Code - Inline
   ========================================================================== */

code {
  padding: 0.2rem 0.45rem;
  font-family: 'Fira Code', 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
  font-weight: 500;
  border-radius: 4px;
  background: linear-gradient(135deg, rgba(95, 179, 245, 0.15), rgba(110, 196, 255, 0.12));
}

pre code {
  padding: 0;
  font-size: 1em;
  font-weight: 400;
  background: transparent;
}

/* ==========================================================================
   Code - Blocks
   ========================================================================== */

.post__content pre {
  padding: 1rem 1.25rem;
  border-radius: 14px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow: auto;
}

.highlight {
  margin: 2.5rem 0;
  border: 1px solid rgba(95, 179, 245, 0.25);
  border-radius: 12px;
  background: var(--code-bg);
  box-shadow: 0 20px 35px rgba(5, 8, 12, 0.4);
  overflow: auto;
}

.highlight pre {
  margin: 0;
  padding: 1.5rem 1.75rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  background: transparent;
  color: var(--code-text);
}

.highlight code {
  padding: 0;
  background: transparent;
  color: inherit;
}

/* ==========================================================================
   Code - Syntax Highlighting
   ========================================================================== */

.highlight .c,
.highlight .cm,
.highlight .c1,
.highlight .cs {
  font-style: italic;
  color: #7c8f8f;
}

.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt,
.highlight .o,
.highlight .ow {
  font-weight: 600;
  color: #ff79c6;
}

.highlight .s,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .s1,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr,
.highlight .ss,
.highlight .dl {
  color: #f1fa8c;
}

.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il {
  color: #bd93f9;
}

.highlight .nb,
.highlight .bp,
.highlight .nx {
  color: #8be9fd;
}

.highlight .na,
.highlight .nc,
.highlight .nd,
.highlight .nf,
.highlight .nn,
.highlight .nt,
.highlight .nv {
  color: #50fa7b;
}

.highlight .gi {
  display: inline-block;
  width: 100%;
  background: rgba(80, 250, 123, 0.15);
  color: #50fa7b;
}

.highlight .gd {
  display: inline-block;
  width: 100%;
  background: rgba(255, 85, 85, 0.15);
  color: #ff5555;
}

.highlight .p,
.highlight .w {
  color: var(--code-text);
}

/* ==========================================================================
   Callouts
   ========================================================================== */

.note,
.important,
.warning {
  display: block;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(22, 25, 42, 0.9), rgba(15, 20, 32, 0.92));
  box-shadow: 0 18px 28px rgba(5, 8, 12, 0.3);
}

.note {
  border-color: rgba(95, 179, 245, 0.35);
  background: linear-gradient(135deg, rgba(95, 179, 245, 0.18), rgba(110, 196, 255, 0.12));
}

.important {
  border-color: rgba(139, 92, 246, 0.35);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(167, 139, 250, 0.12));
}

.warning {
  border-color: rgba(248, 113, 113, 0.35);
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.18), rgba(252, 165, 165, 0.12));
}

.callout {
  margin: 1.5rem 0;
}

.callout__title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.callout__body > :first-child {
  margin-top: 0;
}

.callout__body > :last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  width: 100%;
  margin: 2.5rem 0;
  font-size: 1rem;
  line-height: 1.6;
  border-collapse: collapse;
}

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

th {
  font-weight: 600;
  color: var(--text-high-contrast);
  background: rgba(95, 179, 245, 0.08);
}

/* ==========================================================================
   Horizontal Rule
   ========================================================================== */

hr {
  margin: 3rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Media Queries
   ========================================================================== */

@media (max-width: 720px) {
  .site-header__inner {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .section-heading-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .site-main {
    padding: clamp(2rem, 7vw, 2.5rem) var(--layout-gutter) clamp(3rem, 9vw, 3.5rem);
  }

  .site-footer {
    padding: clamp(1.5rem, 6vw, 2rem) var(--layout-gutter) clamp(2rem, 8vw, 2.75rem);
  }

  .post,
  .page {
    padding: clamp(1rem, 3.5vw, 1.35rem);
  }

  .post-card__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .post-card__date {
    min-width: auto;
  }

  .archive-item {
    grid-template-columns: 1fr;
    padding: 1.25rem;
  }
}
