/* ==========================================
   TRADINGVIEW LIBRARY - BRUTALIST REDESIGN
   ========================================== */

:root {
  /* Colors (from landing page) */
  --color-bg: #0a0e14 !important;
  --color-bg-light: #171b21;
  --color-fg: #fafafa;
  --color-primary: #00d1b2;
  --color-primary-dark: #00a896;
  --color-accent: #c77dff;
  --color-muted: #7d8590;
  --color-border: rgba(255, 255, 255, 0.1);
  
  /* Typography */
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;
  
  /* Spacing */
  --container-max: 1200px;
  --section-padding: 8rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-display);
  background: var(--color-bg);
  color: var(--color-fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.noise {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 1;
}

/* ==========================================
   BUTTONS (from landing)
   ========================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 0;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

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

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

.btn-outline {
  background: transparent;
  color: var(--color-fg);
  border: 2px solid var(--color-fg);
}

.btn-outline:hover {
  background: var(--color-fg);
  color: var(--color-bg);
}

.btn-lg {
  padding: 1.25rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  font-size: 1rem;
}

/* ==========================================
   SECTION TAGS & TITLES (from landing)
   ========================================== */

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.section-tag-line {
  width: 3rem;
  height: 1px;
  background: var(--color-primary);
}

.section-tag-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.tv-library .section-title {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  display: block;
  color: var(--text-light);
}

.tv-library .section-title-line {
  display: block;
}

.tv-library .section-title-stroke {
  -webkit-text-stroke: 1px var(--color-primary);
  color: transparent;
}

/* ==========================================
   HERO SECTION
   ========================================== */

.tv-hero {
  position: relative;
  min-height: 85vh;
  display: flex;
  align-items: center;
  padding: 8rem 0 6rem;
  margin-top: 4.5rem;
  overflow: hidden;
  background: var(--color-bg);
}

.tv-hero-bg-text {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  transform: translateY(-50%);
  pointer-events: none;
  overflow: hidden;
}

.tv-hero-bg-text-inner {
  font-size: 18vw;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
  color: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

/* Geometric elements */
.tv-hero-geo {
  position: absolute;
  display: none;
}

.tv-hero-geo-1 {
  top: 8rem;
  right: 4rem;
  width: 12rem;
  height: 12rem;
  border: 1px solid rgba(0, 209, 178, 0.2);
  transform: rotate(45deg);
}

.tv-hero-geo-2 {
  bottom: 8rem;
  left: 4rem;
  width: 6rem;
  height: 6rem;
  background: rgba(0, 209, 178, 0.1);
}

@media (min-width: 1024px) {
  .tv-hero-geo {
    display: block;
  }
}

.tv-hero-container {
  position: relative;
  z-index: 10;
}

.tv-hero-content {
  max-width: 48rem;
  margin: 0 auto;
  text-align: center;
}

.tv-hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  animation: fade-in 0.6s ease-out;
}

.tv-hero-tag-line {
  width: 3rem;
  height: 1px;
  background: var(--color-primary);
}

.tv-hero-tag-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.tv-hero-title {
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: -0.03em;
  margin-bottom: 0rem;
  padding-bottom: 0;
}

.tv-hero-title-line {
  display: block;
  animation: slide-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

.tv-hero-title-line:nth-child(1) {
  animation-delay: 0s;
}

.tv-hero-title-line:nth-child(2) {
  animation-delay: 0.1s;
}

.tv-hero-title-line:nth-child(3) {
  animation-delay: 0.2s;
}

.tv-hero-title-stroke {
  -webkit-text-stroke: 1px var(--color-primary);
  color: transparent;
}

.gradient-text {
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 50%, var(--color-primary) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient 3s ease infinite;
}

.tv-hero-description {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--color-muted);
  max-width: 32rem;
  margin-top: 0 !important;
  margin-bottom: 3rem;
  margin-left: auto;
  margin-right: auto;
  padding-top: 0;
  animation: slide-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
  opacity: 0;
}

.tv-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 4rem;
  animation: slide-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
  opacity: 0;
}

.tv-hero-stats {
  display: flex;
  justify-content: center;
  gap: 4rem;
  flex-wrap: wrap;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  animation: fade-in 0.6s ease-out 0.3s forwards;
  opacity: 0;
}

.tv-hero-stat {
  text-align: center;
}

.tv-hero-stat-value {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.tv-hero-stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
}

/* ==========================================
   LIBRARY SECTION
   ========================================== */

.tv-library {
  position: relative;
  padding: var(--section-padding) 0;
  background: #0d1117;
  overflow: hidden;
}

.tv-library .container {
  position: relative;
  z-index: 2;
}

.tv-library-header {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-bottom: 4rem;
  text-align: center;
}

@media (min-width: 1024px) {
  .tv-library-header {
    text-align: left;
  }
}

.tv-library-description {
  font-size: 1.125rem;
  color: var(--color-muted);
  max-width: 28rem;
}

/* ==========================================
   TOOLBAR
   ========================================== */

.tv-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 3rem;
}

@media (min-width: 768px) {
  .tv-toolbar {
    grid-template-columns: 1fr auto;
  }
}

.tv-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.tv-search-icon {
  position: absolute;
  left: 1rem;
  color: var(--color-muted);
  font-size: 1rem;
  pointer-events: none;
}

.tv-search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  background: var(--color-bg-light);
  border: 2px solid var(--color-border);
  border-radius: 0;
  color: var(--color-fg);
  font-family: var(--font-display);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tv-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 209, 178, 0.1);
}

.tv-search-input::placeholder {
  color: var(--color-muted);
}

.tv-sort-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.tv-sort-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 1rem 3rem 1rem 1rem;
  background: var(--color-bg-light);
  border: 2px solid var(--color-border);
  border-radius: 0;
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tv-sort-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.tv-sort-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 209, 178, 0.1);
}

.tv-sort-select option {
  background: var(--color-bg);
  color: var(--color-fg);
}

.tv-sort-icon {
  position: absolute;
  right: 1rem;
  color: var(--color-primary);
  font-size: 0.875rem;
  pointer-events: none;
}

/* ==========================================
   SCRIPTS GRID
   ========================================== */

.tv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .tv-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================
   SCRIPT CARD
   ========================================== */

.tv-script-card {
  position: relative;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px);
  animation: slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
}

.tv-script-card:nth-child(1) { animation-delay: 0.05s; }
.tv-script-card:nth-child(2) { animation-delay: 0.1s; }
.tv-script-card:nth-child(3) { animation-delay: 0.15s; }
.tv-script-card:nth-child(4) { animation-delay: 0.2s; }
.tv-script-card:nth-child(5) { animation-delay: 0.25s; }
.tv-script-card:nth-child(6) { animation-delay: 0.3s; }

.tv-script-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* Image */
.tv-script-image {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  border-bottom: 2px solid var(--color-border);
}

.tv-script-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.tv-script-card:hover .tv-script-image img {
  transform: scale(1.05);
  opacity: 0.9;
}

.tv-script-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10, 14, 20, 0.8), transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.tv-script-card:hover .tv-script-overlay {
  opacity: 1;
}

/* Content */
.tv-script-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

/* Meta */
.tv-script-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.tv-script-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tv-script-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
}

.tv-script-author-name {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-fg);
}

.tv-script-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
  white-space: nowrap;
}

/* Title */
.tv-script-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-fg);
  margin: 0;
}

/* Description */
.tv-script-description {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-muted);
  margin: 0;
  flex: 1;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Link */
.tv-script-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  margin-top: 0.5rem;
  background: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: all 0.2s ease;
}

.tv-script-link:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}

.tv-script-link i {
  transition: transform 0.2s ease;
}

.tv-script-link:hover i {
  transform: translateX(4px);
}

/* Accent corner */
.tv-script-accent {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 3rem 3rem 0;
  border-color: transparent var(--color-primary) transparent transparent;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tv-script-card:hover .tv-script-accent {
  opacity: 1;
}

/* ==========================================
   EMPTY STATE
   ========================================== */

.tv-empty {
  margin-top: 4rem;
}

.tv-empty-content {
  max-width: 32rem;
  margin: 0 auto;
  padding: 4rem 2rem;
  text-align: center;
  background: var(--color-bg-light);
  border: 2px solid var(--color-border);
}

.tv-empty-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  color: var(--color-muted);
  font-size: 1.5rem;
}

.tv-empty-title {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-fg);
  margin-bottom: 0.75rem;
}

.tv-empty-description {
  font-size: 1rem;
  color: var(--color-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(60px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes gradient {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes pulse-slow {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

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

@media (max-width: 767px) {
  :root {
    --section-padding: 4rem;
  }
  
  .tv-hero {
    padding: 6rem 0 4rem;
    min-height: 75vh;
  }
  
  .tv-hero-cta {
    flex-direction: column;
    width: 100%;
  }
  
  .tv-hero-cta .btn {
    width: 100%;
  }
  
  .tv-hero-stats {
    gap: 2rem;
  }
  
  .tv-hero-stat-value {
    font-size: 2rem;
  }
}
