/* =====================================================================
   Tales From The Crypto Blog — theme
   Mobile-first, modern "crypto dashboard" aesthetic. Dark base with a
   single accent color; charts and tables reflow to full width on small
   screens so Chart.js canvases stay legible on phones.
   ===================================================================== */

:root {
  --bg: #0b0f19;
  --bg-elevated: #131a2b;
  --bg-card: #161f33;
  --border: #232d45;
  --text: #e7ebf3;
  --text-muted: #8b96b5;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --pos: #34d399;
  --neg: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --wrap: 1080px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--wrap); margin-left: auto; margin-right: auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: 10px 16px; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }

.main-nav { display: flex; align-items: center; gap: 20px; }
.main-nav a { color: var(--text-muted); font-weight: 600; font-size: 14px; }
.main-nav a:hover { color: var(--text); text-decoration: none; }

.lang-switch { display: flex; gap: 4px; background: var(--bg-card); border-radius: 8px; padding: 3px; border: 1px solid var(--border); }
.lang-switch__btn { padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--text-muted); border-radius: 6px; }
.lang-switch__btn:hover { text-decoration: none; color: var(--text); }
.lang-switch__btn.is-active { background: var(--accent); color: #fff; }

/* ---------- hero ---------- */
.hero { padding: 26px 0 18px; text-align: center; }
.hero h1 { font-size: clamp(24px, 4vw, 38px); margin: 0 0 6px; letter-spacing: -0.03em; }
.hero__pulse { color: var(--pos); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.hero__tagline { font-size: 16px; color: var(--text-muted); margin: 0 0 4px; }
.hero__meta { font-size: 13px; color: var(--text-muted); }

/* ---------- post feed / cards ---------- */
.post-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 20px 20px 40px; }
.post-feed__ad { grid-column: 1 / -1; }
.post-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: transform 0.15s ease, border-color 0.15s ease;
  padding-top: 20px;
}
.post-card:has(.post-card__banner) { padding-top: 0; }
.post-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.post-card__link { display: block; color: var(--text); }
.post-card__link:hover { text-decoration: none; }
.post-card__banner { margin: 0 0 14px; aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg); }
.post-card__banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card__link > *:not(.post-card__banner) { margin-left: 20px; margin-right: 20px; }
.post-card__link > .post-card__meta { margin-bottom: 20px; display: block; }
.post-card__coin img { border-radius: 50%; display: block; }
.post-card__topline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.post-card__topline .badge { margin-bottom: 0; }
.post-card__topline .badge--win { font-size: 15px; padding: 9px 16px; gap: 6px; }

/* Same "badge + coin icon" pairing as .post-card__topline above, sized up
   slightly for the full post page. */
.post__topline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.post__topline .badge { margin-bottom: 0; }
.post__topline-coin img { border-radius: 50%; display: block; }
.post-card h2 { font-size: 17px; margin: 6px 0 8px; line-height: 1.35; }
.post-card p { font-size: 14px; color: var(--text-muted); margin: 0 0 10px; }
.post-card__meta { font-size: 12px; color: var(--text-muted); }

/* featured/hero card: latest post, spans the full row width (two items
   wide in this grid's usual desktop layout), bigger banner + title */
.post-card--featured { grid-column: 1 / -1; }
.post-card--featured .post-card__banner { aspect-ratio: 21 / 9; }
.post-card--featured h2 { font-size: 24px; line-height: 1.25; margin: 8px 0 8px; }
.post-card--featured p { font-size: 15px; }
@media (max-width: 640px) {
  .post-card--featured .post-card__banner { aspect-ratio: 16 / 9; }
  .post-card--featured h2 { font-size: 20px; }
}

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; margin-bottom: 8px;
}
a.badge:hover { text-decoration: none; filter: brightness(1.15); }
.badge--win { background: rgba(52, 211, 153, 0.15); color: var(--pos); }
.badge--lg { font-size: 13px; padding: 6px 12px; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ---------- pagination ---------- */
.pagination { display: flex; justify-content: center; gap: 20px; align-items: center; padding: 20px 0 50px; color: var(--text-muted); font-size: 14px; }

/* ---------- article ---------- */
.post { padding: 30px 20px 20px; max-width: 760px; }
.post h1 { font-size: clamp(24px, 4vw, 36px); line-height: 1.3; margin: 8px 0 12px; letter-spacing: -0.02em; }
.post__meta { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.early-access-flag { display: inline-block; background: rgba(124, 92, 255, 0.15); color: var(--accent-2); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 12px; }

.post__body { font-size: 17px; }
.post__body h2 { font-size: 22px; margin: 36px 0 12px; }
.post__body h3 { font-size: 18px; margin: 28px 0 10px; color: var(--text); }
.post__body p { margin: 0 0 18px; color: #d3d9ea; }
.post__body ul, .post__body ol { margin: 0 0 18px; padding-left: 22px; color: #d3d9ea; }
.post__body a[target="_blank"]::after { content: " ↗"; font-size: 0.8em; }
.post__body a.inline-followup-link { color: var(--pos); font-weight: 600; text-decoration-color: rgba(52, 211, 153, 0.4); }
.post__body a.inline-followup-link:hover { text-decoration-color: var(--pos); }

/* chart embeds inside article body */
.post-chart {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 24px 0; position: relative;
}
.post-chart canvas { width: 100% !important; height: 220px !important; }
.post-chart::before {
  content: attr(data-symbol); display: block; font-weight: 800; font-size: 13px;
  color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.04em;
}

/* inline featured-image embed, dropped roughly halfway down the article --
   see includes/functions.php::injectMidArticleImage() */
.post-inline-image { margin: 28px 0; }
.post-inline-image img {
  width: 100%; height: auto; display: block;
  border-radius: var(--radius); border: 1px solid var(--border);
}

/* references */
.references { margin: 28px 0; padding: 16px 18px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.references h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.references ul { margin: 0; padding-left: 18px; }
.references li { margin-bottom: 6px; font-size: 14px; }

/* predictions */
.predictions { margin: 32px 0; }
.predictions__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.prediction-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.prediction-card__symbol { display: block; font-weight: 800; font-size: 15px; }
.prediction-card__horizon { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.prediction-card__dir { display: inline-block; font-weight: 700; font-size: 14px; padding: 2px 0; }
.prediction-card__dir--up { color: var(--pos); }
.prediction-card__dir--down { color: var(--neg); }
.prediction-card__dir--flat { color: var(--warn); }
.prediction-card__confidence { display: block; font-size: 11px; color: var(--text-muted); margin: 6px 0; text-transform: uppercase; letter-spacing: 0.04em; }
.prediction-card__rationale { font-size: 13px; color: #c3cbe0; margin: 6px 0 0; }

/* summary table */
.summary-table { margin: 32px 0; }
.table-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 560px; background: var(--bg-card); }
th, td { text-align: left; padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
td.cell-coin { display: flex; align-items: center; gap: 8px; font-weight: 700; }
td.cell-coin img { border-radius: 50%; }
td.pos { color: var(--pos); font-weight: 700; }
td.neg { color: var(--neg); font-weight: 700; }
tr.row--buy td:first-child { border-left: 3px solid var(--pos); }
tr.row--avoid td:first-child { border-left: 3px solid var(--neg); }
tr.row--watch td:first-child { border-left: 3px solid var(--warn); }

/* related posts */
.related-posts { margin: 40px 0; }
.related-posts ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.related-posts li { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }

/* ---------- ad units ---------- */
.ad-unit { margin: 28px 0; text-align: center; min-height: 90px; }
.ad-unit__label::before {
  content: "Advertisement"; display: block; font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}

/* ---------- newsletter CTA ---------- */
/* Temporary hide for the nav link + footer opt-in box -- CSS-only rather
   than removing/conditionally-rendering the PHP+HTML (which is what broke
   full-page rendering last time, for reasons not fully root-caused). This
   way the exact same markup that's confirmed working keeps rendering
   byte-for-byte; only visibility changes. Delete this rule (and the two
   class="is-hidden-temp" attributes in header.php/footer.php) to bring
   both back later. */
.is-hidden-temp { display: none !important; }
.newsletter-cta { background: linear-gradient(135deg, var(--bg-elevated), #0f1526); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 48px 0; margin-top: 40px; }
.newsletter-cta__inner { max-width: 640px; margin: 0 auto; text-align: center; padding: 0 20px; }
.newsletter-cta h2 { font-size: 24px; margin: 0 0 10px; }
.newsletter-cta p { color: var(--text-muted); margin: 0 0 20px; }
.newsletter-form { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.newsletter-form input[type="email"] {
  flex: 1 1 260px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px;
}
.newsletter-form button {
  background: var(--accent); color: #fff; border: none; padding: 12px 22px; border-radius: 10px;
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.newsletter-form button:hover { background: var(--accent-2); }
.newsletter-form__disclaimer { font-size: 12px; color: var(--text-muted); margin-top: 14px; }
.newsletter-toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 0 0 16px; }

/* ---------- footer ---------- */
.site-footer { padding: 40px 0 60px; }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.site-footer__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.site-footer__nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--text-muted); }
.site-footer__nav a { color: var(--text-muted); }
.bmc-button { margin-left: auto; }
.site-footer__disclaimer { flex-basis: 100%; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }
.site-footer__copy { flex-basis: 100%; font-size: 12px; color: var(--text-muted); }

/* ---------- archive ---------- */
.archive { padding: 40px 20px; }
.archive h1 { margin-bottom: 20px; }
.archive-search { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); margin-bottom: 20px; font-size: 15px; }
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.archive-list li a { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; color: var(--text); }
.archive-list li a:hover { border-color: var(--accent); text-decoration: none; }
.archive-list__title { flex: 1; font-size: 14px; }
.archive-list__date { font-size: 12px; color: var(--text-muted); }

/* ---------- filter by coin (archive.php + coin.php) ---------- */
.coin-filter { margin-bottom: 24px; }
.coin-filter label { display: block; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.coin-filter__input {
  width: 100%; max-width: 320px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 15px;
}
.coin-filter__input:focus { outline: none; border-color: var(--accent); }

/* ---------- coin page ---------- */
.coin-page { padding: 40px 20px; }
.coin-page__header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.coin-page__quote { color: var(--text-muted); }

.not-found { text-align: center; padding: 100px 20px; }

/* ---------- about page ---------- */
.about-page { max-width: 640px; margin: 0 auto; padding: 40px 20px 60px; text-align: center; }
.about-page__logo { max-width: 500px; width: 100%; height: auto; margin: 0 auto 24px; display: block; }
.about-page h1 { margin: 0 0 24px; }
.about-page p { text-align: left; color: #d3d9ea; font-size: 16px; line-height: 1.7; margin: 0 0 18px; }

/* ---------- mobile nav toggle ---------- */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 34px; height: 34px; background: none; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; width: 16px; background: var(--text); margin: 0 auto; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 12px 20px; gap: 14px;
  }
  .main-nav.is-open { display: flex; }
  .main-nav .lang-switch { flex-wrap: wrap; margin-top: 4px; }
  .nav-toggle { display: flex; }
  .site-header { position: sticky; }
  .site-header__inner { padding: 12px 16px; position: relative; }
  .hero { padding: 36px 0 24px; }
  .post { padding: 20px 16px 10px; }
  .newsletter-form { flex-direction: column; }
  .bmc-button { margin-left: 0; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  table { min-width: 480px; }
  .post-chart canvas { height: 180px !important; }
}

/* print-ish / reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hero__pulse { animation: none; }
  html { scroll-behavior: auto; }
}

/* =====================================================================
   Added: sidebar layout, share bar, language-fallback badges,
   newsletter preference checkboxes, RTL support
   ===================================================================== */

/* ---------- two-column layout (main content + "about" sidebar) ---------- */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
  padding-top: 8px;
  padding-bottom: 20px;
}
.layout-with-sidebar > .post,
.layout-with-sidebar > .post-feed,
.layout-with-sidebar > .archive,
.layout-with-sidebar > .coin-page {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
.layout-with-sidebar > .post-feed { padding-top: 0; padding-bottom: 0; }

/* Grid items default to min-width: auto, which means they refuse to
   shrink below their CONTENT's natural size -- for a grid track holding
   post-card images, that natural size can be driven by the <img>'s HTML
   width/height attributes (e.g. width="1200" set on the featured post's
   banner for layout-shift prevention) rather than the width:100% CSS that
   normally resizes it. In some engines that lets a single wide image
   inflate the ENTIRE grid (both the post-feed's own auto-fill columns and
   the outer layout-with-sidebar grid) far past the viewport, pushing all
   content off-screen to the right with nothing visible until the window
   is narrow enough for the overflow to be caught up with (confirmed in
   production: page was blank until the browser was resized/narrowed).
   min-width: 0 on every grid item in the chain overrides that default and
   forces each one to respect the track size grid layout actually computed
   for it, instead of its content's intrinsic size. */
.layout-with-sidebar > * { min-width: 0; }
.post-feed, .post-card, .post-card__banner { min-width: 0; }

.sidebar { position: sticky; top: 84px; }
.sidebar__card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; margin-bottom: 20px;
}
.sidebar__logo { height: 32px; width: auto; margin: 0 auto 14px; display: block; }
.sidebar__pic { border-radius: 50%; object-fit: cover; margin-bottom: 12px; }
.sidebar__name { font-size: 16px; margin: 0 0 4px; }
.sidebar__subtitle { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; }
.sidebar__bio { font-size: 13px; color: #c3cbe0; text-align: left; line-height: 1.6; margin: 0; }

@media (max-width: 900px) {
  .layout-with-sidebar { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
}

/* ---------- share bar (self-hosted, plain links + one JS copy button) --- */
.share-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 20px 0; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.share-bar__label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; }
.share-bar__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border-radius: 999px; background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  cursor: pointer;
}
.share-bar__btn svg { width: 16px; height: 16px; display: block; fill: currentColor; }
.share-bar__btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
/* Copy link has no platform icon -- keep it as a text pill, not a fixed-size icon circle. */
.share-bar__btn--copy { width: auto; padding: 6px 12px; font-family: inherit; font-size: 12px; font-weight: 700; }
.share-bar__btn.is-copied { background: var(--pos); border-color: var(--pos); color: #06281c; }

/* Visually hidden but still readable by screen readers / link-text SEO
   (used to keep the platform name in the DOM for the icon-only share
   buttons above). */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- language-fallback notices ---------- */
.fallback-notice {
  font-size: 13px; color: var(--warn); background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3); border-radiu