@import url('./colors.css');
@import url('./highlight.css');

:root {
  --spacer: 2rem;
}

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

img {
  width: 100%;
  height: auto;
  display: block;
}

/* Post images (flexible aspect ratio) */
.post img {
  width: 100%;
  height: auto;
  display: block;
}

/* Pinned card images (fixed aspect ratio) */
.post-item img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16/9;
  object-fit: contain;
}

[data-theme="dark"] .post img, [data-theme="dark"] .post-item img {
  filter: invert(1) hue-rotate(180deg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .post img,
  :root:not([data-theme="light"]) .post-item img {
    filter: invert(1) hue-rotate(180deg);
  }
}

/* Other images just dim in dark mode */
[data-theme="dark"] img:not(.post img):not(.post-item img) {
  filter: contrast(1.1) brightness(0.75);
}

[data-theme="dark"] p {
  color: var(--text-secondary);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) img:not(.post img):not(.post-item img) {
    filter: contrast(1.1) brightness(0.75);
  }

  :root:not([data-theme="light"]) p {
    color: var(--text-secondary);
  }
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 18px;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-secondary);
}

/* Links */
a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary);
}

.main-content a:not(.btn) {
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 2px;
}

.main-content a:not(.btn):hover {
  text-decoration-color: var(--primary);
}

.tag-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 2px;
}

.tag-link:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
}

.tag-icon {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  vertical-align: -0.125em;
}

.tag-page-icon {
  width: 2.5rem;
  height: 2.5rem;
  vertical-align: -0.125em;
}

/* Header & Navigation */
.header {
  background: var(--bg-primary);
  width: 100%;
}

.nav-container {
  padding: 0 var(--spacer);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: var(--spacer);
}

.logo-img {
  height: clamp(3rem, 10vw, 8rem);
  width: auto;
}

.logo-link {
  white-space: nowrap;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s ease;
}

.logo-link:hover {
  color: var(--primary);
  transform: scale(1.25);
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  padding: 0;
  font-size: 0.95rem;
}

.nav-links a {
  color: var(--text-secondary);
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s ease;
  text-decoration: underline;
}

.nav-links a:hover {
  color: var(--primary);
  transform: scale(1.25);
}

.nav-search {
  display: none;
  border: 1.5px solid var(--text-primary);
  background: transparent;
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: text;
  transition: all 0.2s ease;
}

.nav-search::placeholder {
  color: var(--text-secondary);
}

.nav-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lighter);
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--spacer) var(--spacer) var(--spacer);
  font-size: 18px;
}

/* Logo Hero */
.hero-bubble {
  max-width: 20rem;
  margin: 0 auto;
}

.hero-bubble-text {
  margin: 0;
  padding: 1rem;
  text-align: center;
  border: 2px solid currentColor;
  border-bottom: none;
  box-sizing: border-box;
}

.hero-bubble-text > * {
  margin: 0;
}

.hero-bubble-text h1,
.hero-bubble-text h2 {
  text-align: center;
}

.hero-bubble-tail {
  display: block;
  width: 100%;
  height: 1.5rem;
}

.intro-bubble {
  margin: 2rem auto 0;
}

.intro-bubble-text {
  margin-top: 1rem;
  padding: 0;
  text-align: left;
  box-sizing: border-box;
}

.intro-bubble-text > * {
  margin: 0;
  color: var(--text-muted);
}

.intro-bubble-text h1,
.intro-bubble-text h2 {
  text-align: center;
}

.logo-hero {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: var(--spacer);
}

.logo-home {
  height: clamp(10rem, 22vw, 30rem);
  width: auto;
  aspect-ratio: auto;
}

/* Intro Section */
.intro {
  margin-top: var(--spacer);
  margin-bottom: 0;
  padding-bottom: 0;
}

.intro p {
  color: var(--text-muted);
}

.cta-buttons {
  display: flex;
  gap: calc(var(--spacer) * 0.5);
  margin-top: var(--spacer);
  align-items: center;
}

.btn {
  display: inline-block;
  padding: 0.875rem 1.75rem;
  border: 1.5px solid var(--text-primary);
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.25px;
  border-radius: 2rem;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--bg-primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* Blog Sections */
.blog-header {
  margin-bottom: 2rem;
}

.blog-header p {
  color: var(--text-secondary);
}

/* Post Items */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-item {
  padding: 0;
}

.post-item h3 {
  margin: 0;
  color: var(--text-primary);
}

.post-item h3 a {
  color: var(--text-primary);
}

.post-item h3 a:hover {
  color: var(--primary);
}

.post-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

.post-excerpt {
  color: var(--text-secondary);
  margin: 0;
}

.post-excerpt .read-more {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 2px;
}

.post-excerpt .read-more:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
}

/* Featured Posts Section */
.featured-posts {
  margin-top: calc(var(--spacer) * 2);
  padding-top: var(--spacer);
  border-top: 1px solid var(--border);
}

.featured-posts h2 {
  font-size: 1.5rem;
  margin-bottom: var(--spacer);
  font-weight: 600;
  color: var(--text-primary);
}

.featured-posts p {
  color: var(--text-secondary);
  font-style: italic;
}

/* Pinned posts on home page */
.pinned-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacer);
}

.pinned-card img {
  border: 2px solid currentColor;
  padding: 0.5rem;
  margin-bottom: 1rem;
}

.icon-inline {
  width: 1.5rem;
  height: 1.5rem;
  vertical-align: -0.3rem;
  transition: transform 0.2s ease;
  display: block;
  margin: 0;
  padding: 0;
}

.theme-toggle:hover .icon-inline,
.footer-links a:hover .icon-inline {
  transform: scale(1.25);
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

@media (hover: hover) {
  .theme-toggle:hover {
    color: var(--primary);
  }
}

[data-theme="light"] .theme-icon-dark,
[data-theme="light"] .theme-icon-auto { display: none; }
[data-theme="dark"] .theme-icon-light,
[data-theme="dark"] .theme-icon-auto { display: none; }
[data-theme="auto"] .theme-icon-light,
[data-theme="auto"] .theme-icon-dark { display: none; }

/* Footer */
.footer {
  background: var(--bg-primary);
  margin-top: auto;
  padding-top: 2rem;
  width: 100%;
}

.footer-content {
  padding: var(--spacer);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--spacer);
  align-items: center;
}

.footer-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.footer-left {
  text-align: left;
}

.footer-left p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0;
}

.footer-left p a {
  color: var(--text-secondary);
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s ease;
  text-decoration: underline;
  margin-left: 1rem;
}

.footer-left p a:hover {
  color: var(--primary);
  transform: scale(1.25);
}

.footer-right {
  text-align: right;
}

.footer-links {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacer);
  flex-wrap: nowrap;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  padding: 0;
  text-decoration: underline;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-legal {
  text-align: left;
  padding: 0 var(--spacer) var(--spacer) var(--spacer);
  font-size: 0.9rem;
}

.footer-legal a {
  color: var(--text-secondary);
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s ease;
  text-decoration: underline;
}

.footer-legal a:hover {
  color: var(--primary);
  transform: scale(1.25);
}

/* Code blocks */
code {
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Cascadia Code", "Source Code Pro", "JetBrains Mono", ui-monospace, monospace;
  font-size: 95%;
  color: inherit;
  background: inherit;
}

pre {
  position: relative;
  background-color: var(--bg-tertiary);
  padding: 0.25rem 0;
  overflow-x: auto;
  min-height: 3rem;
  margin: var(--spacer) 0;
  border: none;
  border-radius: 4px;
  font-size: 95%;
  line-height: 1.5;
  color: var(--text-primary);
}

pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
  line-height: inherit;
  margin-right: 6rem;
}

/* Code wrapper */
.code-wrapper {
  position: relative;
}

/* Code header with language label and copy button */
.code-header {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  z-index: 2;
  transition: all 0.2s ease;
}

.code-header:hover {
  transform: scale(1.1);
  cursor: pointer;
}

.code-language-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: lowercase;
  font-weight: 500;
  transition: color 0.2s ease;
}

.code-header:hover .code-language-label {
  color: var(--primary);
}

.code-copy-button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.code-copy-button svg {
  width: 1.25rem;
  height: 1.25rem;
  color: inherit;
}

.code-header:hover .code-copy-button {
  color: var(--primary);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

h1 {
  font-size: 2.5rem;
  text-align: left;
  line-height: 1;
  margin-bottom: 1rem;
}
h2 { font-size: 1.75rem; margin: 1rem 0 1rem 0; }
h3 { font-size: 1.25rem; margin: 1rem 0 1rem 0; }
h4 { font-size: 1.25rem; }

/* Post content */
p {
  margin: 1rem 0;
}

ul, ol {
  margin: calc(var(--spacer) * 0.5) 0;
  padding-left: var(--spacer);
}

li {
  margin: 0.5rem 0;
}

blockquote {
  padding-left: var(--spacer);
  margin: 1rem 0;
}

mark {
  background-color: var(--highlight);
  color: inherit;
  padding: 0.125rem 0.375rem;
  border-radius: 2px;
}

nowrap {
  white-space: nowrap;
}

article > *:last-child {
  margin-bottom: 0;
}

/* Contact page */
.contact-section {
  width: 100%;
  padding: 2rem calc(50% - 50vw);
}

.contact-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacer);
  max-width: 800px;
  margin: 0 auto;
}

.contact-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 2rem 1.5rem;
  border: 2px solid var(--border);
  border-radius: 2px;
  text-align: center;
}

.contact-link {
  color: var(--text-secondary);
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s ease;
  text-decoration: underline;
}

.contact-link:hover {
  color: var(--primary);
  transform: scale(1.25);
}

.contact-service {
  color: var(--text-secondary);
}

.contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  font-size: 1.5rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.contact-icon svg {
  width: 100%;
  height: auto;
  stroke-width: 1;
}


@media (max-width: 480px) {
  .contact-links {
    grid-template-columns: 1fr;
  }
}

/* Responsive */
@media (max-width: 768px) {
  img {
    aspect-ratio: 4/3;
  }
}

@media (max-width: 480px) {
  img {
    aspect-ratio: auto;
  }
}

@media (max-width: 360px) {
  .footer-links {
    flex-wrap: wrap;
  }
}

@media (max-width: 1024px) {
  .main-content {
    padding: var(--spacer) var(--spacer);
  }

  .hero-content h1 {
    font-size: 2.5rem;
  }

  .blog-header h1 {
    font-size: 2rem;
  }
}

@media (max-width: 768px) {
  :root {
    --spacer: 1rem;
  }

  .nav-container {
    padding: var(--spacer);
  }

  .main-content {
    padding: var(--spacer);
  }

  .hero {
    margin-bottom: 3rem;
  }

  .hero-content h1 {
    font-size: 2rem;
  }

  .tagline {
    font-size: 1rem;
  }

  .blog-header h1 {
    font-size: 1.75rem;
  }

  .nav-links {
    gap: 1rem;
    font-size: 0.9rem;
  }

  .cta-buttons {
    flex-direction: column;
    align-items: flex-start;
  }

  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: calc(var(--spacer) * 0.5);
    border: none;
    padding-top: 0;
  }

  .footer-links {
    gap: var(--spacer);
    justify-content: flex-start;
  }

  .footer-links a {
    align-items: flex-start;
  }

  .footer-content {
    grid-template-columns: 1fr;
  }

  .footer-right {
    text-align: left;
  }

  .footer {
    padding-bottom: 1rem;
  }
}
