/* ============================================
   CSS Variables
   ============================================ */

:root {

  /* Colors */
  --bg: #E8E9EB;
  --bg-raised: #E4E4E0;
  --header-bg: #E4E4E0;

  --border: lch(from var(--bg-raised) calc(l - 5) c h);
  --border-hi: lch(from var(--border) calc(l + 10) c h);

  --text: #000;
  --text-muted: lch(from var(--text) calc(l + 35) c h);
  --text-dim: #6b7280;
  --text-heading: #424242ff;

  --link: #EE5A58;
  --accent: lch(from var(--link) calc(l + 10) c h);
  --bg-code: var(--bg-raised);


  /* Fonts */
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-prose: 'Lora', Georgia, serif;

  /* Sizes */
  --max-prose: 68ch;
  --max-wide: 900px;
  --radius: 4px;
  --transition: 120ms ease;
}



/*  background-color: lch(from var(--base-color) calc(l - 20) c h); */

/* ============================================
   Reset & Base
   ============================================ */

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-prose);
  line-height: 1.7;
  font-size: clamp(1rem, 2vw, 1.125rem);
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition);
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-code);
  color: var(--accent);
  padding: 0.2em 0.4em;
  border-radius: var(--radius);
}

pre {
  background: var(--bg-code);
  border-left: 3px solid var(--accent);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

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

ul, ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

ul li::marker {
  color: var(--accent);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

thead {
  border-bottom: 2px solid var(--accent);
}

th {
  text-align: left;
  padding: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ============================================
   Layout
   ============================================ */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(1rem, 5vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  font-weight: 700;

}

.site-logo {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 3vw, 1.25rem);
  color: var(--link);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .site-nav {
    display: none;
  }
}

.site-footer {
  text-align: center;
  padding: clamp(1rem, 5vw, 2.5rem);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.container {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: clamp(1rem, 5vw, 2.5rem);
}

/* ============================================
   Blog-Specific Styles
   ============================================ */

/* Post Grid (Index Page) */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.post-tile {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
  display: flex;
  flex-direction: column;
}

.post-tile:hover {
  border-color: var(--border-hi);
}

.post-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-tile-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.post-excerpt {
  font-family: var(--font-prose);
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.read-more {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--link);
  padding: 0.5rem 1rem;
  border: 1px solid var(--link);
  border-radius: var(--radius);
  transition: all var(--transition);
  align-self: flex-start;
}

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

@media (max-width: 480px) {
  .read-more {
    display: block;
    text-align: center;
  }
}

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

.post-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  color: var(--text-muted);
}

.post-excerpt-quote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.post-body {
  width: 100%;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
  margin: 1.5rem 0;
}

.gallery-button {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  transition: all var(--transition);
  line-height: 1;
}

.gallery-button:hover {
  background: var(--accent);
  color: var(--bg);
}


.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.gallery-thumb {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
  position: relative;
}

.gallery-thumb:hover {
  border-color: var(--accent);
}

.gallery-thumb img,
.gallery-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.gallery-counter {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* Carousel */
.carousel {
  position: relative;
  overflow: hidden;
  background: var(--bg-raised);
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
  margin-bottom: 1rem;
}

.carousel-track {
  display: flex;
  transition: transform 300ms ease;
  height: 100%;
}

.carousel-slide {
  min-width: 100%;
  height: 100%;
}

.carousel-slide img,
.carousel-slide video,
.carousel-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.carousel-prev,
.carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: var(--accent);
  border: none;
  font-size: 2rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  z-index: 10;
}

.carousel-prev:hover,
.carousel-next:hover {
  background: rgba(0, 0, 0, 0.8);
}

.carousel-prev {
  left: 0.5rem;
}

.carousel-next {
  right: 0.5rem;
}

@media (max-width: 480px) {
  .carousel-prev,
  .carousel-next {
    display: none;
  }
}

.carousel-counter {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  z-index: 10;
}

.carousel-placeholder {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--bg-raised),
    var(--bg-raised) 10px,
    var(--bg-code) 10px,
    var(--bg-code) 20px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 2rem;
  cursor: pointer;
  z-index: 1001;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: var(--accent);
  border: none;
  font-size: 3rem;
  padding: 1rem;
  cursor: pointer;
  transition: background var(--transition);
  z-index: 1001;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-media {
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img,
.lightbox-video {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.lightbox-counter {
  position: absolute;
  top: 2rem;
  left: 4rem;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.9rem;
  z-index: 1001;
}

/* Post 3D Models Section */
.post-3d-models {
  margin-top: 3rem;
  padding-top: 2rem;
}

.post-3d-models h2 {
  margin-bottom: 1.5rem;
}

/* Post Files Section */
.post-files {
  margin-top: 3rem;
  padding-top: 2rem;
}

.files-table {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.files-table-header {
  text-align: left;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.files-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.files-table tbody tr:last-child {
  border-bottom: none;
}

.files-table tbody tr:hover {
  background: var(--bg-code);
}

.file-icon-cell {
  width: 3rem;
  padding: 0.5rem 0 0.5rem 1rem;
  font-size: 1.25rem;
  text-align: center;
}

.file-name-cell {
  padding: 0.5rem 1rem;
}

.file-link {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  display: block;
  word-break: break-all;
}

.file-link:hover {
  color: var(--accent);
}

.model-viewer-container {
  width: 100%;
  height: 500px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

model-viewer {
  width: 100%;
  height: 100%;
}

/* Code Blocks Mobile Full Bleed */
@media (max-width: 480px) {
  .post-body pre {
    margin-left: calc(-1 * clamp(1rem, 5vw, 2.5rem));
    margin-right: calc(-1 * clamp(1rem, 5vw, 2.5rem));
    border-radius: 0;
  }

  .model-viewer-container {
    height: 300px;
  }
}

.md-inline-grid {
  display: grid;
  /*align-items: center; */
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin: 1.6em 0;
}

.md-inline-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
}