/* =======================
   MICROBLOG STYLES
   Card-based design inspired by Claude blog
   ======================= */

/* ================================
   PAGE OVERRIDE
   ================================ */

/* Override body max-width when microblog is present */
body:has(.microblog) {
  max-width: 1440px;
  padding: 0 2rem;
}

@media (max-width: 640px) {
  body:has(.microblog) {
    padding: 0 1rem;
  }
}

/* ================================
   MAIN CONTAINER
   ================================ */

.microblog {
  padding: 1.5rem 0;
}

.microblog > p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 3rem;
}

/* ================================
   YEAR SECTIONS
   ================================ */

.posts-year {
  margin-bottom: 3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.posts-year__heading {
  grid-column: 1 / -1; /* Span all columns */
  font-family: var(--font-body);
  font-size: 12rem;
  font-weight: 700;
  letter-spacing: -0.08em;
  line-height: 0.7;
  color: var(--heading-color);
  margin: 0;
  margin-left: -0.5rem;
  margin-bottom: 1rem;
  padding: 0;
  border: none;
  text-transform: none;
  -webkit-text-stroke: 1px var(--heading-color);
  paint-order: stroke fill;
  opacity: 0.08;
}

/* 2 columns on medium screens */
@media (max-width: 1024px) {
  .posts-year {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 1 column on small screens */
@media (max-width: 640px) {
  .posts-year {
    grid-template-columns: 1fr;
  }

  .microblog {
    padding: 1rem 0.75rem;
  }
}

/* ================================
   POST CARDS (Base)
   ================================ */

.post {
  background: var(--card-bg);
  border-radius: 4px;
  overflow: hidden;
  transition: opacity 0.2s ease;
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
}

.post:hover {
  opacity: 0.85;
}

.post__content {
  padding: 1.25rem;
  flex-grow: 1;
}

.post__content p {
  margin: 0;
  line-height: 1.6;
}

.post__content p + p {
  margin-top: 0.75rem;
}

.post__meta {
  padding: 0.75rem 1.25rem;
  background: var(--card-meta-bg);
  border-top: 1px solid var(--card-meta-border);
}

.post__meta time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant: normal;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

/* ================================
   TEXT POST
   ================================ */

.post--text .post__content {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ================================
   PHOTO POST
   ================================ */

.post--photo .post__content {
  padding: 0;
}

.post--photo img {
  display: block;
  width: 100%;
  height: auto;
}

.post--photo figcaption {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: var(--heading-color);
}

.post--photo figure {
  margin: 0;
}

/* ================================
   QUOTE POST
   ================================ */

.post--quote {
  background: transparent;
  border: none;
}

/* Organic tilt for quotes - varied rotations */
.post--quote:nth-child(4n+1) {
  transform: rotate(-1.5deg);
}

.post--quote:nth-child(4n+2) {
  transform: rotate(1deg);
}

.post--quote:nth-child(4n+3) {
  transform: rotate(2deg);
}

.post--quote:nth-child(4n+4) {
  transform: rotate(-0.5deg);
}

.post--quote .post__content {
  padding: 2rem 1.5rem;
  padding-top: 3rem;
  margin: 0;
  background: transparent;
  position: relative;
}

.post--quote .post__content::before {
  content: '\201C';
  position: absolute;
  top: -0.25rem;
  left: 0.75rem;
  font-family: var(--font-serif);
  font-size: 8rem;
  line-height: 1;
  color: var(--border-deco);
  opacity: 0.3;
  pointer-events: none;
}

.post--quote blockquote {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.25;
  font-style: italic;
  color: var(--heading-color);
  letter-spacing: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post--quote blockquote::before {
  display: none;
}

.post--quote blockquote p {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
}

.post--quote figure {
  margin: 0;
}

.post--quote figcaption {
  margin-top: 1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: normal;
}

.post--quote figcaption::before {
  display: none;
}

.post__quote-author {
  font-weight: 600;
}

.post--quote .post__meta {
  background: transparent;
  border: none;
}

/* ================================
   LINK POST
   ================================ */

.post--link .post__link-card {
  display: block;
  text-decoration: none;
}

.post--link .post__link-card:hover,
.post--link .post__link-card:focus {
  background: transparent;
  outline: none;
}

.post__link-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  line-height: 1.25;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.post--link:hover .post__link-title {
  color: var(--heading-color);
}

.post__link-commentary {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.post__link-domain {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-family: var(--font-body);
}

.post__link-domain::before {
  content: '↗ ';
}

/* ================================
   EMBED POST (iframe)
   ================================ */

.post--embed .post__content {
  padding: 0;
}

.post__embed-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background: var(--pattern-bg);
}

.post__embed-container--square {
  padding-bottom: 100%;
}

.post__embed-container--portrait {
  padding-bottom: 125%;
}

.post__embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Monochromatic overlay for video embeds - reduces visual noise */
.post--embed .post__embed-container {
  filter: grayscale(1);
  transition: filter 0.3s ease;
}

/* Blue-tinted monochrome for dark theme */
[data-theme="blue"] .post--embed .post__embed-container {
  filter: grayscale(1) sepia(1) hue-rotate(180deg) saturate(0.7);
}

/* Reveal full colors on hover */
.post--embed:hover .post__embed-container {
  filter: none;
}

/* Overlay approach for social embeds (tweet/instagram) - filters break their scripts */
.post__embed-container--tweet,
.post__embed-container--instagram {
  filter: none !important;
  position: relative;
}

.post__embed-container--tweet::before,
.post__embed-container--instagram::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--page-background);
  opacity: 0.7;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.post--embed:hover .post__embed-container--tweet::before,
.post--embed:hover .post__embed-container--instagram::before {
  opacity: 0;
}

/* Video thumbnail preview card */
.post__embed-preview {
  display: block;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.post__embed-preview img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1);
  transition: filter 0.3s ease;
}

[data-theme="blue"] .post__embed-preview img {
  filter: grayscale(1) sepia(1) hue-rotate(180deg) saturate(0.7);
}

.post--embed:hover .post__embed-preview img {
  filter: none;
}

.post__embed-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.5);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  transition: background 0.3s ease;
  pointer-events: none;
}

/* CSS triangle for play icon */
.post__embed-play::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 54%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent white;
}

.post--embed:hover .post__embed-play {
  background: rgba(0, 0, 0, 0.75);
}

/* Twitter/X embed styling */
.post__embed-container--tweet {
  padding-bottom: 0; /* Let tweet determine height */
}

.post__embed-container--tweet .twitter-tweet {
  margin: 0 !important;
}

/* Instagram embed styling */
.post__embed-container--instagram {
  padding-bottom: 0; /* Let instagram determine height */
}

.post__embed-container--instagram .instagram-media {
  margin: 0 !important;
  min-width: 100% !important;
}

.post__embed-caption {
  padding: 1rem 1.25rem;
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post__embed-source {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.5rem 1.25rem 0;
  font-family: var(--font-body);
}

.post__embed-source::before {
  content: '↗ ';
}

/* ================================
   GEOMETRIC PATTERNS (minimal set)
   8 clean patterns that cycle
   Full card background for text/link posts
   ================================ */

/* Hide the pattern div - patterns now applied to card background */
.post__pattern {
  display: none;
}

/* Pattern color with built-in transparency for subtle effect */
:root {
  --pattern-line: rgba(0, 0, 0, 0.06);
}

[data-theme="blue"] {
  --pattern-line: rgba(255, 255, 255, 0.08);
}

/* Pattern 1: Fine grid */
.post--text:nth-child(8n+1),
.post--link:nth-child(8n+1) {
  background-image:
    linear-gradient(var(--pattern-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--pattern-line) 1px, transparent 1px);
  background-size: 12px 12px;
  background-position: 0 0;
}

/* Pattern 2: Grid */
.post--text:nth-child(8n+2),
.post--link:nth-child(8n+2) {
  background-image:
    linear-gradient(var(--pattern-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--pattern-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}

/* Pattern 3: Dots */
.post--text:nth-child(8n+3),
.post--link:nth-child(8n+3) {
  background-image: radial-gradient(circle, var(--pattern-line) 1.5px, transparent 1.5px);
  background-size: 16px 16px;
}

/* Pattern 4: Horizontal lines */
.post--text:nth-child(8n+4),
.post--link:nth-child(8n+4) {
  background-image: repeating-linear-gradient(
    0deg,
    var(--pattern-line) 0,
    var(--pattern-line) 1px,
    transparent 1px,
    transparent 10px
  );
}

/* Pattern 5: Vertical lines */
.post--text:nth-child(8n+5),
.post--link:nth-child(8n+5) {
  background-image: repeating-linear-gradient(
    90deg,
    var(--pattern-line) 0,
    var(--pattern-line) 1px,
    transparent 1px,
    transparent 10px
  );
}

/* Pattern 6: Cross */
.post--text:nth-child(8n+6),
.post--link:nth-child(8n+6) {
  background-image:
    linear-gradient(var(--pattern-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--pattern-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: center center;
}

/* Pattern 7: Dense dots */
.post--text:nth-child(8n+7),
.post--link:nth-child(8n+7) {
  background-image: radial-gradient(circle, var(--pattern-line) 1px, transparent 1px);
  background-size: 8px 8px;
}

/* Pattern 8: Sparse dots */
.post--text:nth-child(8n+8),
.post--link:nth-child(8n+8) {
  background-image: radial-gradient(circle, var(--pattern-line) 2px, transparent 2px);
  background-size: 32px 32px;
}

/* ================================
   TAGS (optional enhancement)
   ================================ */

.post__tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0 1.25rem 1rem;
}

.post__tag {
  font-size: 0.7rem;
  color: var(--heading-color);
  background: hsl(210, 20%, 95%);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
}

.post__tag::before {
  content: "#";
  opacity: 0.5;
}

/* ================================
   MOBILE RESPONSIVE
   ================================ */

@media (max-width: 700px) {
  .post {
    border-radius: 2px;
  }

  .post__content {
    padding: 1rem;
  }

  .post__meta {
    padding: 0.6rem 1rem;
  }

  .posts-year__heading {
    font-size: 5rem;
    margin-bottom: 0.5rem;
    margin-left: -0.25rem;
  }

  .post__link-title {
    font-size: 1rem;
  }

}
