/* ============================================
   Tickar Financiero — Ghost Theme
   Dark financial theme (Bloomberg/FT style)
   ============================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- Variables --- */
:root {
  --bg-primary: #0d1117;
  --bg-card: #161b22;
  --bg-ticker: #010409;
  --bg-input: #21262d;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent-gold: #d4a853;
  --accent-green: #2ea043;
  --accent-red: #f85149;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: Georgia, 'Times New Roman', serif;
  --max-width: 1280px;
  --ticker-height: 40px;
  --nav-height: 60px;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #e8c06a;
}

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

/* --- Ticker Tape --- */
.ticker-tape {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--ticker-height);
  background: var(--bg-ticker);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.ticker-track {
  display: flex;
  align-items: center;
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
  will-change: transform;
}

.ticker-track:hover {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 20px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ticker-item .ticker-name {
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.7rem;
}

.ticker-item .ticker-value {
  color: var(--text-primary);
}

.ticker-item .ticker-change {
  font-size: 0.72rem;
}

.ticker-item .ticker-change.up {
  color: var(--accent-green);
}

.ticker-item .ticker-change.down {
  color: var(--accent-red);
}

.ticker-item .ticker-separator {
  color: var(--text-muted);
  margin: 0 4px;
}

/* --- Navigation --- */
.site-nav {
  position: fixed;
  top: var(--ticker-height);
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  z-index: 999;
  display: flex;
  align-items: center;
}

.nav-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo img {
  height: 32px;
  width: auto;
}

.nav-logo .site-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.nav-logo .site-title span {
  color: var(--accent-gold);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

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

/* --- Layout --- */
.site-content {
  margin-top: calc(var(--ticker-height) + var(--nav-height));
  padding-top: 24px;
  min-height: calc(100vh - var(--ticker-height) - var(--nav-height));
}

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

/* --- Hero Section --- */
.hero {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
  align-items: center;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.hero-image {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
}

.hero-content {
  padding: 32px 32px 32px 0;
}

.hero-tag {
  display: inline-block;
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 3px;
  margin-bottom: 16px;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero-title a {
  color: var(--text-primary);
}

.hero-title a:hover {
  color: var(--accent-gold);
}

.hero-excerpt {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hero-meta .author-name {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Main Grid (Articles + Market Panel) --- */
.home-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 40px;
  padding-bottom: 60px;
}

/* --- Post Cards --- */
.post-feed {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.post-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.post-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.post-card-content {
  padding: 20px;
}

.post-card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.post-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}

.post-card-title a {
  color: var(--text-primary);
}

.post-card-title a:hover {
  color: var(--accent-gold);
}

.post-card-excerpt {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-card-meta .reading-time {
  color: var(--text-muted);
}

/* --- Market Panel --- */
.market-panel {
  position: sticky;
  top: calc(var(--ticker-height) + var(--nav-height) + 20px);
}

.market-panel-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.market-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.market-panel-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.market-panel-header .market-timestamp {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.market-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.market-section:last-child {
  border-bottom: none;
}

.market-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 20px 8px;
}

.market-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  transition: background 0.15s;
}

.market-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.market-row .market-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}

.market-row .market-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  min-width: 80px;
}

.market-row .market-change {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
  min-width: 60px;
}

.market-row .market-change.up {
  color: var(--accent-green);
}

.market-row .market-change.down {
  color: var(--accent-red);
}

.market-row .market-change.neutral {
  color: var(--text-muted);
}

.market-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Single Post --- */
.post-header {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 0 32px;
  text-align: center;
}

.post-header .post-tag {
  display: inline-block;
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: 3px;
  margin-bottom: 20px;
}

.post-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.post-header .post-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.post-header .post-meta .author-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.post-feature-image {
  max-width: 1000px;
  margin: 0 auto 40px;
  border-radius: 8px;
  overflow: hidden;
}

.post-feature-image img {
  width: 100%;
}

.post-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 48px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-bottom: 60px;
}

.post-body {
  max-width: 720px;
}

.post-body-content {
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.post-body-content h2 {
  font-family: var(--font-ui);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2em 0 0.5em;
  letter-spacing: -0.01em;
}

.post-body-content h3 {
  font-family: var(--font-ui);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.5em 0 0.5em;
}

.post-body-content p {
  margin-bottom: 1.4em;
}

.post-body-content blockquote {
  border-left: 3px solid var(--accent-gold);
  padding-left: 20px;
  margin: 1.5em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-body-content a {
  color: var(--accent-gold);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-body-content img {
  border-radius: 6px;
  margin: 1.5em 0;
}

.post-body-content ul, .post-body-content ol {
  margin-bottom: 1.4em;
  padding-left: 1.5em;
}

.post-body-content li {
  margin-bottom: 0.4em;
}

.post-body-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

.post-body-content code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

.post-body-content pre code {
  background: none;
  padding: 0;
}

.post-body-content figure {
  margin: 1.5em 0;
}

.post-body-content figcaption {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 8px;
  font-family: var(--font-ui);
}

.post-body-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.post-body-content th, .post-body-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.post-body-content th {
  background: var(--bg-card);
  font-weight: 600;
}

/* --- Ghost Koenig Editor Width Classes --- */
.kg-width-wide {
  margin-left: -80px;
  margin-right: -80px;
  max-width: calc(100% + 160px);
}

.kg-width-full {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  max-width: 100vw;
  width: 100vw;
}

.kg-width-wide img,
.kg-width-full img {
  width: 100%;
}

@media (max-width: 1024px) {
  .kg-width-wide {
    margin-left: -24px;
    margin-right: -24px;
    max-width: calc(100% + 48px);
  }
}

/* --- Related Posts --- */
.related-posts {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 60px;
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
  color: var(--text-secondary);
}

.related-posts .post-feed {
  grid-template-columns: repeat(3, 1fr);
}

/* --- Tag / Author Archive --- */
.archive-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.archive-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.archive-header p {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 1rem;
}

.archive-feed {
  padding-bottom: 60px;
}

.archive-feed .post-feed {
  grid-template-columns: repeat(3, 1fr);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 0;
  font-size: 0.875rem;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s;
}

.pagination a:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.pagination .page-number {
  color: var(--text-muted);
}

/* --- Error Page --- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--accent-gold);
  line-height: 1;
  margin-bottom: 16px;
}

.error-message {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.error-link {
  padding: 12px 24px;
  background: var(--accent-gold);
  color: var(--bg-primary);
  font-weight: 600;
  border-radius: 6px;
  transition: opacity 0.2s;
}

.error-link:hover {
  opacity: 0.9;
  color: var(--bg-primary);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  background: var(--bg-ticker);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
  list-style: none;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: color 0.2s;
}

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

/* --- Responsive --- */
@media (max-width: 1024px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
  .post-layout {
    grid-template-columns: 1fr;
  }
  .market-panel {
    position: static;
  }
  .related-posts .post-feed,
  .archive-feed .post-feed {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  :root {
    --ticker-height: 36px;
    --nav-height: 54px;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-image {
    min-height: 220px;
  }

  .hero-content {
    padding: 24px;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .post-feed {
    grid-template-columns: 1fr;
  }

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

  .related-posts .post-feed,
  .archive-feed .post-feed {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 16px;
  }

  .nav-links a {
    font-size: 0.75rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .ticker-item {
    padding: 0 12px;
    font-size: 0.72rem;
  }

  .post-header {
    padding: 32px 0 24px;
  }

  .post-body-content {
    font-size: 1rem;
  }
}
