/* CRT Effect Styles - Based on Tympanus Variation #2 */

/* CRT Screen Effect */
.crt-container {
  position: relative;
  background: #1a1f2e;
  min-height: 100vh;
  overflow: hidden;
}

/* Scanlines */
.crt-container::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 2px;
  z-index: 2;
  pointer-events: none;
  animation: scanlines 12s linear infinite;
  will-change: background-position;
}

/* Flicker effect */
.crt-container::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 16, 16, 0.1);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  animation: flicker 0.2s infinite;
  will-change: opacity;
}

@keyframes scanlines {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 10px;
  }
}
/* Reduce motion for performance */
@media (prefers-reduced-motion: reduce) {
  .crt-container::before, .crt-container::after {
    animation: none;
  }
}

@keyframes flicker {
  0% {
    opacity: 0.27861;
  }
  5% {
    opacity: 0.34769;
  }
  10% {
    opacity: 0.23604;
  }
  15% {
    opacity: 0.90626;
  }
  20% {
    opacity: 0.18128;
  }
  25% {
    opacity: 0.83891;
  }
  30% {
    opacity: 0.65583;
  }
  35% {
    opacity: 0.67807;
  }
  40% {
    opacity: 0.26559;
  }
  45% {
    opacity: 0.84693;
  }
  50% {
    opacity: 0.96019;
  }
  55% {
    opacity: 0.08594;
  }
  60% {
    opacity: 0.20313;
  }
  65% {
    opacity: 0.71988;
  }
  70% {
    opacity: 0.53455;
  }
  75% {
    opacity: 0.37288;
  }
  80% {
    opacity: 0.71428;
  }
  85% {
    opacity: 0.70419;
  }
  90% {
    opacity: 0.7003;
  }
  95% {
    opacity: 0.36108;
  }
  100% {
    opacity: 0.24387;
  }
}

/* Text glow effect */
.crt-glow {
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5),
               0 0 20px rgba(255, 255, 255, 0.3),
               0 0 30px rgba(255, 255, 255, 0.2);
}

/* Green phosphor color */
.crt-text {
  color: #b0b0b0;
  text-shadow: none;
}

/* Apply CRT text effect by default to all text */
.crt-container {
  color: #b0b0b0;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.crt-container h1, .crt-container h2, .crt-container h3 {
  color: #b0b0b0;
  text-shadow: none;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.crt-container a {
  color: #b0b0b0;
  text-decoration: none;
}

.crt-container a:hover {
  color: #ffffff;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

/* Blue variation */
.crt-text-blue {
  color: #00d4ff;
  text-shadow: 0 0 5px #00d4ff;
}

/* White variation */
.crt-text-white {
  color: #ffffff;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

/* Scramble text hover effect - Tympanus Variation #2 style */
.hover-text {
  position: relative;
  display: inline-block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Sliding white background effect */
.hover-text::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -4px;
  right: -4px;
  bottom: -2px;
  background-color: #e0e0e0;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 300ms ease-out;
  z-index: -1;
}

.hover-text:hover::before,
.hover-text.active::before {
  transform: scaleX(1);
}

.hover-text.active {
  color: #2d2d30 !important;
  z-index: 1;
}

/* Individual character spans */
.hover-text span {
  position: relative;
  display: inline-block;
  transition: none;
}

.hover-text:hover {
  background-color: #ffffff !important;
  color: #1a1f2e !important;
  padding: 2px 4px;
  margin: -2px -4px;
  box-shadow: 0 0 0 1px #ffffff;
}

/* Prevent button shape changes while keeping scramble text */
.btn.hover-text:hover,
.nav-link.hover-text:hover {
  background: transparent !important;
  color: inherit !important;
  padding: inherit !important;
  margin: inherit !important;
  box-shadow: none !important;
}

.btn.hover-text::before,
.nav-link.hover-text::before {
  display: none !important;
}

.btn.hover-text.active,
.nav-link.hover-text.active {
  background: transparent !important;
  color: inherit !important;
}

/* Stagger the animation for each letter */
.hover-text span:nth-child(1) { transition-delay: 0s; }
.hover-text span:nth-child(2) { transition-delay: 0.015s; }
.hover-text span:nth-child(3) { transition-delay: 0.03s; }
.hover-text span:nth-child(4) { transition-delay: 0.045s; }
.hover-text span:nth-child(5) { transition-delay: 0.06s; }
.hover-text span:nth-child(6) { transition-delay: 0.075s; }
.hover-text span:nth-child(7) { transition-delay: 0.09s; }
.hover-text span:nth-child(8) { transition-delay: 0.105s; }
.hover-text span:nth-child(9) { transition-delay: 0.12s; }
.hover-text span:nth-child(10) { transition-delay: 0.135s; }
.hover-text span:nth-child(11) { transition-delay: 0.15s; }
.hover-text span:nth-child(12) { transition-delay: 0.165s; }
.hover-text span:nth-child(13) { transition-delay: 0.18s; }
.hover-text span:nth-child(14) { transition-delay: 0.195s; }
.hover-text span:nth-child(15) { transition-delay: 0.21s; }

/* Column layout from demo */
.crt-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3rem;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.crt-column {
  padding: 1rem;
}

.crt-column-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 2rem;
  opacity: 0.7;
}

.crt-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.crt-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  gap: 0.6rem;
}

.crt-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
  margin: 0 -0.2rem;
  padding: 0.2rem;
}

.crt-item-title {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.3;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  word-break: keep-all !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  hyphens: none !important;
}

/* More specific selector for anchor titles */
a.crt-item-title {
  word-break: keep-all !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  hyphens: none !important;
}

/* Ensure hover-text class doesn't interfere */
.crt-item-title.hover-text {
  word-break: keep-all !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  hyphens: none !important;
}

.crt-item-meta {
  font-size: 0.7rem;
  opacity: 0.6;
  white-space: nowrap;
  margin-left: 0;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  align-self: flex-start;
}

.crt-item-number {
  font-size: 0.75rem;
  opacity: 0.4;
  margin-right: 0;
  font-family: 'Space Mono', monospace;
  flex-shrink: 0;
  align-self: flex-start;
}

/* Blog-specific styling */
.blog-item .crt-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  white-space: normal;
  gap: 0.25rem;
  max-width: 120px;
}

.blog-read-time {
  color: #e0e0e0;
  font-weight: 500;
}

.blog-date {
  color: #b0b0b0;
  font-size: 0.7rem;
}

.blog-author {
  color: #7a8a9a;
  font-size: 0.65rem;
}

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  justify-content: flex-end;
  margin-top: 0.1rem;
}

.blog-tag {
  font-size: 0.55rem;
  color: #00d4ff;
  opacity: 0.8;
  line-height: 1.2;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .crt-columns {
    grid-template-columns: 1fr;
  }
  
  .blog-item .crt-item-meta {
    max-width: none;
    align-items: flex-start;
    text-align: left;
  }
  
  .blog-tags {
    justify-content: flex-start;
    gap: 0.1rem;
    margin-top: 0.1rem;
  }
}

@media (max-width: 768px) {
  /* Mobile CRT styling improvements */
  .crt-columns {
    padding: 1rem;
    gap: 2rem;
  }
  
  .crt-item {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .crt-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.35rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
  }
  
  .crt-list-item:hover {
    margin: 0;
    background: rgba(255, 255, 255, 0.05);
  }
  
  .crt-item-title {
    font-size: 1rem !important;
    line-height: 1.3 !important;
    margin-bottom: 0.3rem;
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    hyphens: none !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }
  
  /* Mobile-specific anchor and hover-text fixes */
  a.crt-item-title,
  .crt-item-title.hover-text {
    font-size: 1rem !important;
    line-height: 1.3 !important;
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    hyphens: none !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }
  
  .crt-item-content {
    font-size: 0.85rem;
    line-height: 1.5;
  }
  
  .crt-item-meta {
    font-size: 0.75rem;
    align-self: flex-start;
    width: 100%;
    max-width: none;
  }
  
  .blog-item .crt-item-meta {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    max-width: none;
    text-align: left;
  }
  
  .blog-date {
    font-size: 0.75rem;
  }
  
  .blog-author {
    font-size: 0.7rem;
  }
  
  .blog-tag {
    font-size: 0.55rem;
    padding: 0.1rem 0.3rem;
    line-height: 1.2;
  }
  
  .blog-tags {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .crt-columns {
    padding: 0.5rem;
    gap: 1.5rem;
  }
  
  .crt-item {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }
  
  .crt-list-item {
    padding: 0.75rem;
  }
  
  .crt-item-title {
    font-size: 1rem !important;
    line-height: 1.3 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    hyphens: auto !important;
  }
  
  a.crt-item-title,
  .crt-item-title.hover-text {
    font-size: 1rem !important;
    line-height: 1.3 !important;
  }
  
  .crt-item-content {
    font-size: 0.8rem;
  }
  
  .crt-item-meta {
    font-size: 0.7rem;
  }
  
  .blog-date {
    font-size: 0.7rem;
  }
  
  .blog-author {
    font-size: 0.65rem;
  }
  
  .blog-tag {
    font-size: 0.6rem;
    padding: 0.15rem 0.3rem;
  }
}