/*
Theme Name: Trainero Blog Child
Theme URI: https://blog.trainero.com
Template: hello-elementor
Description: Nopea, lukuoptimoitu artikkelipohja Traineron blogille. Ohittaa Elementor-renderöinnin single-postauksissa ja käyttää brändivärejä natiivisti. Etusivu ja muut Elementor-sivut jäävät ennalleen.
Author: Trainero / Seopal
Author URI: https://seopal.fi
Version: 1.1.0
Text Domain: trainero-blog-child
Tags: blog, fast, custom-colors
*/

/* ----------------------------------------------------------------
   1. Brändivärit ja design tokenit
---------------------------------------------------------------- */
:root {
  --t-red:        #d90000;
  --t-red-bright: #FA1515;
  --t-red-dark:   #ba120c;
  --t-red-50:     #fff0f0;
  --t-red-100:    #ffd6d6;

  --t-text:       #1a1a1a;
  --t-text-2:     #393939;
  --t-muted:      #7d7d7d;
  --t-muted-2:    #939393;

  --t-border:     #e4e4e4;
  --t-border-2:   #d3d1c7;

  --t-bg:         #ffffff;
  --t-bg-subtle:  #f7f7f7;
  --t-bg-2:       #fafafa;

  --t-link:       #027be3;

  --t-radius:     8px;
  --t-radius-lg:  12px;

  --t-content-max: 720px;
  --t-page-max:    1180px;

  --t-font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --t-font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --t-font-serif:   Georgia, 'Times New Roman', serif;
}

/* ----------------------------------------------------------------
   2. Pohja (vain single-postille, ei riko muita sivuja)
---------------------------------------------------------------- */
body.tr-blog {
  font-family: var(--t-font-body);
  color: var(--t-text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--t-bg);
}

body.tr-blog a { color: var(--t-link); }
body.tr-blog a:hover { color: var(--t-red); }

/* ----------------------------------------------------------------
   3. Reading progress -palkki
---------------------------------------------------------------- */
.tr-progress {
  position: sticky;
  top: 0;
  height: 3px;
  background: var(--t-border);
  z-index: 100;
  width: 100%;
}
.tr-progress__bar {
  height: 100%;
  background: var(--t-red);
  width: 0;
  transition: width 0.08s linear;
  will-change: width;
}

/* ----------------------------------------------------------------
   4. Hero (otsikko + meta + featured image)
---------------------------------------------------------------- */
.tr-hero {
  max-width: var(--t-content-max);
  margin: 60px auto 28px;
  padding: 0 24px;
}

.tr-crumb {
  font-size: 13px;
  color: var(--t-muted);
  margin-bottom: 14px;
}
.tr-crumb a {
  color: var(--t-muted);
  text-decoration: none;
}
.tr-crumb a:hover { color: var(--t-text); }

.tr-cat {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--t-red);
  margin-bottom: 10px;
}

.tr-title {
  font-family: var(--t-font-display);
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--t-text);
  margin: 0 0 22px;
}

@media (max-width: 680px) {
  .tr-title { font-size: 30px; }
  .tr-hero { margin-top: 32px; }
}

.tr-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--t-muted);
  flex-wrap: wrap;
  margin-bottom: 0;
}
.tr-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--t-red-50);
  color: var(--t-red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.tr-meta__name { color: var(--t-text); font-weight: 500; }
.tr-meta__sep  { color: var(--t-border-2); }

/* Featured image */
.tr-featured-image {
  max-width: var(--t-page-max);
  margin: 0 auto 36px;
  padding: 0 24px;
}
.tr-featured-image img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--t-radius-lg);
  display: block;
}

/* ----------------------------------------------------------------
   5. Artikkelilayout: TOC + content
---------------------------------------------------------------- */
.tr-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 60px;
  max-width: var(--t-page-max);
  margin: 0 auto 40px;
  padding: 0 24px;
}

@media (max-width: 960px) {
  .tr-layout {
    grid-template-columns: 1fr;
    gap: 0;
    max-width: var(--t-content-max);
  }
  .tr-toc { display: none; }
}

/* TOC */
.tr-toc {
  position: sticky;
  top: 24px;
  align-self: start;
  font-size: 13px;
}
.tr-toc__label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--t-muted);
  margin-bottom: 14px;
}
.tr-toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tr-toc__list a {
  color: var(--t-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 10px;
  line-height: 1.35;
  display: block;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tr-toc__list a:hover {
  color: var(--t-text);
}
.tr-toc__list a.is-active {
  color: var(--t-text);
  font-weight: 500;
  border-color: var(--t-red);
}

/* ----------------------------------------------------------------
   6. Sisältö (artikkelin runko)
---------------------------------------------------------------- */
.tr-content {
  max-width: var(--t-content-max);
  font-size: 17px;
  line-height: 1.7;
  color: var(--t-text);
}
.tr-content > * {
  margin-top: 0;
  margin-bottom: 1.2em;
}
.tr-content p { margin: 0 0 1.2em; }

.tr-content h2, .tr-content h3, .tr-content h4 {
  color: var(--t-text);
  letter-spacing: -0.01em;
  line-height: 1.25;
  font-weight: 600;
  scroll-margin-top: 32px;
}
.tr-content h2 {
  font-size: 26px;
  margin-top: 2.2em;
  margin-bottom: 0.6em;
}
.tr-content h3 {
  font-size: 20px;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}
.tr-content h4 {
  font-size: 17px;
  margin-top: 1.5em;
  margin-bottom: 0.4em;
}

.tr-content a {
  color: var(--t-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tr-content a:hover {
  color: var(--t-red);
}

.tr-content blockquote {
  border-left: 3px solid var(--t-red);
  padding: 4px 0 4px 20px;
  margin: 32px 0;
  font-family: var(--t-font-serif);
  font-size: 19px;
  line-height: 1.5;
  color: var(--t-text-2);
  font-style: normal;
  background: none;
}
.tr-content blockquote p { margin-bottom: 0.6em; }
.tr-content blockquote p:last-child { margin-bottom: 0; }

.tr-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--t-radius);
  display: block;
  margin: 24px auto;
}

.tr-content ul, .tr-content ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}
.tr-content li { margin-bottom: 0.4em; }

.tr-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--t-bg-subtle);
  padding: 2px 6px;
  border-radius: 4px;
}
.tr-content pre {
  background: var(--t-bg-subtle);
  border-radius: var(--t-radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
}
.tr-content pre code {
  background: none;
  padding: 0;
}

.tr-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
}
.tr-content th, .tr-content td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--t-border);
}
.tr-content th {
  font-weight: 600;
  background: var(--t-bg-subtle);
}

/* ----------------------------------------------------------------
   7. Inline CTA (artikkelin sisällä)
---------------------------------------------------------------- */
.tr-cta-inline {
  background: var(--t-red-50);
  border-radius: var(--t-radius-lg);
  padding: 22px 24px;
  margin: 36px 0;
  display: flex;
  gap: 20px;
  align-items: center;
}
.tr-cta-inline__text { flex: 1; min-width: 0; }
.tr-cta-inline__title {
  font-weight: 600;
  color: var(--t-red-dark);
  font-size: 16px;
  margin-bottom: 4px;
}
.tr-cta-inline__sub {
  font-size: 14px;
  color: var(--t-red-dark);
  opacity: 0.85;
  margin: 0;
}

@media (max-width: 520px) {
  .tr-cta-inline { flex-direction: column; align-items: stretch; text-align: left; }
}

.tr-btn {
  display: inline-block;
  padding: 11px 20px;
  background: var(--t-red);
  color: #ffffff !important;
  border-radius: var(--t-radius);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none !important;
  transition: background 0.15s ease;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}
.tr-btn:hover  { background: var(--t-red-bright); color: #fff !important; }
.tr-btn:active { background: var(--t-red-dark); }
.tr-btn:focus-visible { outline: 3px solid var(--t-red-100); outline-offset: 2px; }

/* ----------------------------------------------------------------
   8. Tagit ja chipit
---------------------------------------------------------------- */
.tr-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0;
}
.tr-tag {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--t-border);
  border-radius: 16px;
  font-size: 13px;
  color: var(--t-text-2);
  text-decoration: none;
  background: #fff;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.tr-tag:hover {
  border-color: var(--t-red);
  color: var(--t-red);
}

/* ----------------------------------------------------------------
   9. Related posts
---------------------------------------------------------------- */
.tr-related {
  border-top: 1px solid var(--t-border);
  padding-top: 32px;
  max-width: var(--t-content-max);
  margin: 48px auto 60px;
  padding-left: 24px;
  padding-right: 24px;
}
.tr-related__label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--t-muted);
  margin-bottom: 20px;
}
.tr-related__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 600px) {
  .tr-related__grid { grid-template-columns: 1fr; gap: 16px; }
}

.tr-related__item {
  display: flex;
  gap: 14px;
  text-decoration: none !important;
  color: inherit !important;
  align-items: flex-start;
}
.tr-related__thumb {
  width: 92px;
  height: 62px;
  border-radius: var(--t-radius);
  background: var(--t-bg-subtle) center/cover no-repeat;
  flex-shrink: 0;
}
.tr-related__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--t-text);
  margin: 0 0 4px;
}
.tr-related__meta {
  font-size: 12px;
  color: var(--t-muted);
}
.tr-related__item:hover .tr-related__title {
  color: var(--t-red);
}

/* ----------------------------------------------------------------
   10. Tulostus
---------------------------------------------------------------- */
@media print {
  .tr-progress, .tr-toc, .tr-cta-inline, .tr-related { display: none !important; }
  .tr-content { font-size: 12pt; }
  body.tr-blog { color: #000; }
}

/* ----------------------------------------------------------------
   11. Pieni performance: piilota oletustyylit single-postille
---------------------------------------------------------------- */
body.tr-blog .elementor-section-wrap > section:not(.elementor-edit-mode),
body.tr-blog .entry-content > .elementor { /* placeholder, ei pakollinen */ }

/* ================================================================
   ETUSIVU (front-page.php) - kaikki .tr-home -alueella
================================================================ */

body.tr-home {
  font-family: var(--t-font-body);
  color: var(--t-text);
  background: var(--t-bg);
  -webkit-font-smoothing: antialiased;
}

.tr-home-wrap {
  max-width: var(--t-page-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* Etusivun intro / esittely */
.tr-home-intro {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--t-border);
  margin-bottom: 36px;
}
.tr-home-intro__label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--t-red);
  font-weight: 600;
  margin-bottom: 12px;
}
.tr-home-intro__title {
  font-size: 36px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--t-text);
}
.tr-home-intro__sub {
  font-size: 17px;
  color: var(--t-muted);
  max-width: 640px;
  margin: 0;
  line-height: 1.55;
}
@media (max-width: 680px) {
  .tr-home-intro { padding: 32px 0 24px; margin-bottom: 24px; }
  .tr-home-intro__title { font-size: 28px; }
  .tr-home-intro__sub { font-size: 15px; }
}

/* Hero: 1 iso vasemmalla + 3 nostoa oikealla */
.tr-hero-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 20px;
  margin-bottom: 40px;
}
@media (max-width: 880px) {
  .tr-hero-grid { grid-template-columns: 1fr; gap: 16px; }
}

.tr-feature {
  display: block;
  text-decoration: none !important;
  color: inherit !important;
  background: var(--t-red-50);
  border-radius: var(--t-radius-lg);
  overflow: hidden;
  min-height: 380px;
  position: relative;
  transition: transform 0.2s ease;
}
.tr-feature:hover { transform: translateY(-2px); }

.tr-feature__media {
  width: 100%;
  height: 240px;
  background: var(--t-bg-subtle) center/cover no-repeat;
  display: block;
}
.tr-feature__body {
  padding: 22px 24px 26px;
}
.tr-feature__meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  align-items: center;
}
.tr-feature__cat {
  color: var(--t-red);
  font-weight: 600;
  text-transform: uppercase;
}
.tr-feature__read {
  color: var(--t-red-dark);
  opacity: 0.7;
}
.tr-feature__title {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 600;
  color: var(--t-text);
  margin: 0 0 10px;
}
.tr-feature__date {
  font-size: 13px;
  color: var(--t-muted);
}
@media (max-width: 680px) {
  .tr-feature__media { height: 200px; }
  .tr-feature__title { font-size: 20px; }
}

/* Side rail nostot */
.tr-side-rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tr-side-item {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius);
  text-decoration: none !important;
  color: inherit !important;
  transition: border-color 0.15s ease;
  flex: 1;
}
.tr-side-item:hover {
  border-color: var(--t-red);
}
.tr-side-item__tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--t-red);
  font-weight: 600;
  margin-bottom: 6px;
}
.tr-side-item__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--t-text);
  margin: 0;
}

/* Chip-rivi */
.tr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 36px;
  align-items: center;
}
.tr-chips__label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--t-muted);
  margin-right: 6px;
}
.tr-chip {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--t-border);
  border-radius: 18px;
  font-size: 13px;
  color: var(--t-text-2);
  text-decoration: none !important;
  background: #fff;
  transition: all 0.15s ease;
}
.tr-chip:hover {
  border-color: var(--t-red);
  color: var(--t-red);
}
.tr-chip--all {
  background: var(--t-text);
  color: #fff;
  border-color: var(--t-text);
}
.tr-chip--all:hover {
  background: var(--t-red);
  border-color: var(--t-red);
  color: #fff;
}

/* Posts-grid 3x3 */
.tr-grid-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--t-muted);
  margin: 8px 0 18px;
}
.tr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-bottom: 48px;
}
@media (max-width: 880px) {
  .tr-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
}
@media (max-width: 540px) {
  .tr-grid { grid-template-columns: 1fr; }
}

.tr-card {
  display: block;
  text-decoration: none !important;
  color: inherit !important;
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius);
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s ease, transform 0.2s ease;
}
.tr-card:hover {
  border-color: var(--t-red);
  transform: translateY(-2px);
}
.tr-card__media {
  aspect-ratio: 16 / 10;
  background: var(--t-bg-subtle) center/cover no-repeat;
  display: block;
}
.tr-card__body {
  padding: 14px 16px 18px;
}
.tr-card__tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--t-red);
  font-weight: 600;
  margin-bottom: 6px;
}
.tr-card__title {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 500;
  color: var(--t-text);
  margin: 0 0 10px;
}
.tr-card__meta {
  font-size: 12px;
  color: var(--t-muted);
}

/* Newsletter / CTA -osio */
.tr-cta-band {
  background: var(--t-red-50);
  border-radius: var(--t-radius-lg);
  padding: 36px 40px;
  margin: 0 0 60px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
}
@media (max-width: 720px) {
  .tr-cta-band {
    grid-template-columns: 1fr;
    padding: 28px 24px;
    text-align: left;
  }
}
.tr-cta-band__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--t-red-dark);
  margin: 0 0 6px;
  line-height: 1.25;
}
.tr-cta-band__sub {
  font-size: 15px;
  color: var(--t-red-dark);
  opacity: 0.85;
  margin: 0;
  line-height: 1.5;
}

/* "Browse all" linkki gridin alle */
.tr-browse-all {
  text-align: center;
  margin: 0 0 48px;
}
.tr-browse-all a {
  display: inline-block;
  padding: 12px 22px;
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--t-text);
  text-decoration: none !important;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.tr-browse-all a:hover {
  border-color: var(--t-red);
  color: var(--t-red);
}
