/* ============================================================
   CSS-muuttujat — kaikki värit ja mitat yhdessä paikassa
   ============================================================ */
:root {
  --color-muku:    #d9822b;   /* muuttuvat kulut: oranssi */
  --color-kate:    #4f7f52;   /* kate: vihreä */
  --color-fixed:   #7a4a3a;   /* kiinteät kulut: tummanruskea */
  --color-profit:  #b8944a;   /* liikevoitto: kulta */

  --color-bg:      #f5f2ea;
  --color-text:    #2e2b27;
  --color-border:  #333;
  --color-muted:   #666;

  --bar-width-sm:  60px;
  --bar-width:     80px;
  --bar-height-sm: 150px;
  --bar-height:    180px;
}

/* ============================================================
   Pohja — mobile first
   ============================================================ */
body {
  background:  var(--color-bg);
  color:       var(--color-text);
  font-family: Georgia, serif;
  max-width:   600px;
  margin:      0 auto;
  padding:     15px;
  line-height: 1.6;
}

@media (min-width: 700px) {
  body { padding: 30px; }
}

h3 { color: #4f6b50; }

.step { margin-bottom: 48px; }

.slider { width: 100%; }

/* ============================================================
   Palkki — yhteinen rakenne kaikille palkeille
   ============================================================ */
.bar {
  border:        none;
  border-radius: 8px;
  overflow:      hidden;
  display:       flex;
  flex-direction: column-reverse;
  box-shadow:    0 2px 8px rgba(0,0,0,0.13);
}

/* Pieni palkki (step 1) */
.bar--sm {
  width:  var(--bar-width-sm);
  height: var(--bar-height-sm);
}

/* Iso palkki (step 2, 3) */
.bar--lg {
  width:         var(--bar-width);
  height:        var(--bar-height);
  border-radius: 10px;
}

/* Palkin segmentit */
.bar__muku   { width: 100%; background: var(--color-muku);   position: relative; }
.bar__kate   { width: 100%; background: var(--color-kate);   position: relative; }
.bar__fixed  { width: 100%; background: var(--color-fixed);  position: relative; }
.bar__profit { width: 100%; background: var(--color-profit); position: relative; }

/* Teksti segmentin sisällä */
.bar__label {
  position:   absolute;
  top:        50%;
  left:       50%;
  transform:  translate(-50%, -50%);
  color:      white;
  font-weight: bold;
  font-size:  13px;
  line-height: 1.2;
  text-align: center;
  width:      100%;
}

/* ============================================================
   Asteikko — palkin vieressä olevat euromäärät
   ============================================================ */
.scale {
  position:  relative;
  color:     var(--color-muted);
  font-size: 14px;
}

.scale--sm { height: var(--bar-height-sm); width: 90px; }
.scale--lg { height: var(--bar-height);    width: 90px; }

/* Yksittäinen asteikkoteksti — JS asettaa top-arvon dynaamisesti */
.scale__label {
  position:   absolute;
  left:       4px;
  white-space: nowrap;
}

.scale__label--bold { font-weight: bold; }

/* ============================================================
   Vizualisointirivi — palkki + asteikko vierekkäin
   ============================================================ */
.viz-wrap {
  display:         flex;
  gap:             8px;
  align-items:     flex-end;
  justify-content: center;
}

/* ============================================================
   Minipalkkirivi (step 2)
   ============================================================ */
.mini-bars {
  display:         flex;
  flex-wrap:       wrap;
  gap:             8px;
  align-items:     flex-end;
  justify-content: center;
}

.mini-bar {
  width:          12px;
  height:         36px;
  border:         none;
  border-radius:  3px;
  overflow:       hidden;
  display:        flex;
  flex-direction: column-reverse;
  box-shadow:     0 1px 4px rgba(0,0,0,0.13);
}

/* Korkeudet asetetaan JS:ssä, väri tulee tästä */
.mini-bar__muku { background: var(--color-muku); }
.mini-bar__kate { background: var(--color-kate); }

/* Teksti palkin vasemmalla puolella */
.bar-side-label {
  font-size:   13px;
  color:       var(--color-muted);
  max-width:   75px;
  text-align:  right;
  line-height: 1.4;
  align-self:  center;
}

/* ============================================================
   Nuoli steppien välissä
   ============================================================ */
.arrow {
  text-align:  center;
  font-size:   40px;
  color:       var(--color-muted);
  margin:      8px 0;
}

/* ============================================================
   Step 3 — vierekkäinen asettelu
   ============================================================ */
.step3-layout {
  display:         flex;
  gap:             16px;
  justify-content: center;
  align-items:     flex-end;
}

/* Sarake = palkki-otsikko-ryhmä + asteikko vierekkäin */
.step3-col {
  display:     flex;
  gap:         8px;
  align-items: flex-end;
}

/* Otsikko + palkki pystysuuntaan, otsikko keskitettyä vain palkin yläpuolelle */
.bar-with-label {
  display:        flex;
  flex-direction: column;
  align-items:    center;
}

/* Otsikkoteksti palkin yläpuolella */
.viz-label {
  font-weight:   bold;
  text-align:    center;
  margin-bottom: 10px;
}

/* Nuoli kolumnien välissä */
.step3-arrow {
  font-size:   40px;
  color:       var(--color-muted);
  align-self:  flex-start;
  padding-top: 4px;
}

.step3-shared-title {
  text-align:    center;
  font-weight:   bold;
  font-size:     15px;
  color:         var(--color-muted);
  margin-bottom: 16px;
  line-height:   1.4;
}

/* Mobiili: pienennetään palkit ja asteikot vierekkäisyyden säilyttämiseksi */
@media (max-width: 600px) {
  .bar--lg {
    width:  58px;
    height: 140px;
  }

  .scale--lg {
    height:    140px;
    width:     65px;
    font-size: 11px;
  }

  .step3-layout { gap: 8px; }
  .step3-col    { gap: 5px; }

  .step3-arrow {
    font-size:   28px;
    align-self:  flex-start;
    padding-top: 8px;
  }
}

/* ============================================================
   Latausosio
   ============================================================ */
.download-card {
  background:    white;
  border-radius: 12px;
  padding:       28px;
  box-shadow:    0 2px 12px rgba(0,0,0,0.08);
}

.download-card h3 {
  margin-top: 0;
}

.download-desc {
  color:     var(--color-muted);
  font-size: 15px;
}

.download-row {
  display:   flex;
  gap:       10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.email-input {
  flex:          1;
  min-width:     180px;
  padding:       10px 14px;
  border:        2px solid #ddd;
  border-radius: 8px;
  font-family:   Georgia, serif;
  font-size:     15px;
  color:         var(--color-text);
  background:    var(--color-bg);
}

.email-input:focus {
  outline:      none;
  border-color: var(--color-kate);
}

.btn {
  padding:       10px 20px;
  border:        none;
  border-radius: 8px;
  font-family:   Georgia, serif;
  font-size:     15px;
  cursor:        pointer;
  font-weight:   bold;
}

.btn--primary {
  background: var(--color-kate);
  color:      white;
  width:      100%;
}

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

.btn:hover { opacity: 0.85; }

/* ============================================================
   Step 4 — palikkavisualisointi
   ============================================================ */

/* Yksi kuukausipalikka — koko ei muutu, vain määrä kasvaa */
:root {
  --box-size: 20px;
  --box-gap:  3px;
}

.step4-layout {
  display:         flex;
  flex-direction:  row;
  gap:             16px;
  align-items:     flex-end;  /* sarakkeet kohdistuvat alaosasta */
  justify-content: center;
  flex-wrap:       wrap;      /* mobiililla palstut rivittyvät */
}

.step4-col {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            6px;
}

/* Palikkaruudukko — wrap-reverse täyttää alhaalta ylös, vasemmalta oikealle */
.box-grid {
  display:   flex;
  flex-wrap: wrap-reverse;
  gap:       var(--box-gap);
}

/* Leveys rajoittaa rivien pituuden (= sarakkeiden määrän) */
.box-grid--1 { width: var(--box-size); }
.box-grid--4 { width: calc(4 * var(--box-size) + 3 * var(--box-gap)); }
/* col3 saa leveyden dynaamisesti JS:stä */

/* Yksittäinen palikka */
.box {
  width:         var(--box-size);
  height:        var(--box-size);
  background:    var(--color-profit);
  border-radius: 3px;
}

/* Nuoli sarakkeiden välissä */
.step4-arrow {
  font-size:    28px;
  color:        var(--color-muted);
  padding-bottom: 80px;  /* kohdistuu suunnilleen palikkapinon puoliväliin */
}

/* Euromäärät */
.step4-amount {
  font-size:   22px;
  font-weight: bold;
  color:       var(--color-text);
  margin-top:  4px;
}

.step4-amount--big {
  font-size: 28px;
  color:     var(--color-profit);
}

.step4-desc {
  font-size: 13px;
  color:     var(--color-muted);
}

.step4-sub {
  font-size: 12px;
  color:     #aaa;
}

/* Mobiili: pienemmät palat, pystysuuntainen nuoli */
@media (max-width: 500px) {
  :root {
    --box-size: 15px;
    --box-gap:  2px;
  }

  .step4-arrow {
    font-size:      22px;
    padding-bottom: 0;
    padding-right:  0;
    align-self:     center;
  }
}

/* ============================================================
   Erottaja
   ============================================================ */
.section-divider {
  display:         flex;
  align-items:     center;
  gap:             16px;
  margin:          48px 0 32px;
}

.divider-line {
  flex:             1;
  height:           2px;
  background:       var(--color-kate);
  opacity:          0.3;
}

.divider-title {
  font-size:        13px;
  font-weight:      bold;
  letter-spacing:   2px;
  color:            var(--color-kate);
  text-transform:   uppercase;
  white-space:      nowrap;
}

/* ============================================================
   Tiivistelmä (step 5)
   ============================================================ */
.summary-text {
  line-height: 1.8;
  color:       var(--color-text);
  margin-bottom: 24px;
}

.summary-cards {
  display:   flex;
  flex-wrap: wrap;
  gap:       12px;
}

.summary-card {
  background:    white;
  border-radius: 10px;
  padding:       14px 18px;
  box-shadow:    0 1px 6px rgba(0,0,0,0.07);
  min-width:     120px;
}

.summary-card--big {
  border:     2px solid var(--color-kate);
  flex-basis: 100%;
}

.summary-card__label {
  font-size: 11px;
  color:     var(--color-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.summary-card__value {
  font-size:   20px;
  font-weight: bold;
  color:       var(--color-text);
}

.summary-card--big .summary-card__value {
  font-size: 26px;
  color:     var(--color-kate);
}

.summary-card__sub {
  font-size: 12px;
  color:     var(--color-muted);
  margin-top: 2px;
}

/* ============================================================
   Herkkyysanalyysi (step 6)
   ============================================================ */
.step-intro {
  color:       var(--color-muted);
  font-size:   15px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.scenario-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.scenario-table {
  border-collapse: collapse;
  min-width:       560px;
  width:           100%;
}

.scenario-table th,
.scenario-table td {
  padding:      8px 10px;
  text-align:   right;
  font-size:    14px;
  border-bottom: 1px solid var(--color-border);
}

.row-label-cell {
  text-align:  left !important;
  color:       var(--color-muted);
  font-size:   13px !important;
  white-space: nowrap;
  min-width:   130px;
}

.col-now {
  background: rgba(79, 127, 82, 0.07);
  font-weight: bold;
  min-width:   90px;
}

.col-scenario {
  min-width: 110px;
}

/* Sarakkeen otsikkosolu */
.scenario-col-head {
  display:     flex;
  align-items: center;
  justify-content: flex-end;
  gap:         4px;
  margin-bottom: 4px;
}

.col-num  { font-size: 16px; }
.col-name { font-weight: bold; font-size: 13px; }

.col-delta {
  font-size:   18px;
  font-weight: bold;
  color:       var(--color-text);
  margin-bottom: 4px;
}

.col-slider {
  width:     100%;
  display:   block;
  margin:    4px 0 0;
}

/* Parantunut / huonontunut solu */
.cell-better { background: rgba(79, 127, 82, 0.10); }
.cell-worse  { background: rgba(220, 53, 69, 0.08); }

.cell-delta       { font-size: 12px; }
.delta-pos        { color: var(--color-kate); font-weight: bold; }
.delta-neg        { color: #c0392b; font-weight: bold; }

/* Lihavoidut rivit */
.row-bold td     { font-weight: bold; border-top: 1px solid var(--color-border); }
.row-big  td     { font-weight: bold; font-size: 15px; background: rgba(184,148,74,0.08); }

/* Info-nappi */
.info-btn {
  background:    none;
  border:        1px solid var(--color-muted);
  border-radius: 50%;
  width:         18px;
  height:        18px;
  font-size:     11px;
  color:         var(--color-muted);
  cursor:        pointer;
  line-height:   1;
  padding:       0;
  flex-shrink:   0;
}

.info-btn:hover { background: var(--color-muted); color: white; }

/* Kelluva tooltip */
.info-tooltip {
  display:       none;
  position:      absolute;
  z-index:       1000;
  background:    white;
  border:        1px solid #ddd;
  border-radius: 10px;
  padding:       16px 18px;
  max-width:     260px;
  font-size:     13px;
  line-height:   1.6;
  box-shadow:    0 4px 20px rgba(0,0,0,0.12);
  color:         var(--color-text);
}

/* Palkki-vertailu */
.scenario-chart-section {
  margin-top: 32px;
}

.scenario-chart-label {
  font-weight:   bold;
  font-size:     13px;
  color:         var(--color-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.scenario-chart {
  display:     flex;
  gap:         12px;
  align-items: flex-end;
  overflow-x:  auto;
}

.chart-col {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  min-width:      70px;
  flex:           1;
}

.chart-bar-wrap {
  width:           100%;
  height:          180px;
  display:         flex;
  align-items:     flex-end;
  justify-content: center;
}

.chart-bar {
  width:         80%;
  border-radius: 4px 4px 0 0;
  min-height:    4px;
}

.chart-bar--base   { background: #888; }
.chart-bar--better { background: var(--color-kate); }
.chart-bar--worse  { background: #c0392b; }
.chart-bar--same   { background: #aaa; }

.chart-bar-val {
  position:   absolute;
  top:        -20px;
  left:       50%;
  transform:  translateX(-50%);
  font-size:  10px;
  white-space: nowrap;
  font-weight: bold;
  color:       var(--color-text);
}

.chart-col-name {
  font-size:  11px;
  color:      var(--color-muted);
  margin-top: 4px;
  text-align: center;
}

.chart-col-pct {
  font-size:   12px;
  font-weight: bold;
  color:       var(--color-text);
}

/* ============================================================
   Palautelomake
   ============================================================ */
.feedback-textarea {
  width:         100%;
  min-height:    100px;
  padding:       12px 14px;
  border:        2px solid #ddd;
  border-radius: 8px;
  font-family:   Georgia, serif;
  font-size:     15px;
  color:         var(--color-text);
  background:    var(--color-bg);
  resize:        vertical;
  box-sizing:    border-box;
}

.feedback-textarea:focus {
  outline:      none;
  border-color: var(--color-kate);
}

.feedback-msg {
  margin-top: 10px;
  font-size:  14px;
  color:      var(--color-kate);
  min-height: 20px;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  margin-top:    48px;
  padding:       28px 0 32px;
  border-top:    2px solid rgba(79,127,82,0.2);
  text-align:    center;
  color:         var(--color-muted);
  font-size:     13px;
  line-height:   1.8;
}

.footer-logo {
  font-size:     18px;
  font-weight:   bold;
  color:         var(--color-kate);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.footer-copy { font-weight: bold; color: var(--color-text); }

.footer-contact a {
  color:           var(--color-kate);
  text-decoration: none;
  font-weight:     bold;
}

.footer-contact a:hover { text-decoration: underline; }

.footer-legal {
  margin-top: 10px;
  font-size:  11px;
  color:      #999;
  max-width:  400px;
  margin-left:  auto;
  margin-right: auto;
}

.step-intro--tip {
  font-size:   13px;
  color:       var(--color-muted);
  font-style:  italic;
  margin-top: -12px;
}

.chart-bar-valbelow {
  font-size:   11px;
  font-weight: bold;
  color:       var(--color-text);
  text-align:  center;
  margin-top:  4px;
  white-space: nowrap;
}

.chart-bar-delta {
  font-size:  11px;
  text-align: center;
  white-space: nowrap;
}

.chart-col-change {
  font-size:   11px;
  color:       var(--color-muted);
  text-align:  center;
  white-space: nowrap;
}

/* ============================================================
   Sivun intro-osio
   ============================================================ */
.site-intro {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 2px solid rgba(79,127,82,0.15);
}

.site-intro__title {
  font-size:   24px;
  color:       var(--color-kate);
  margin:      0 0 10px;
}

.site-intro__text {
  color:       var(--color-muted);
  font-size:   15px;
  line-height: 1.7;
  margin:      0;
}

/* ============================================================
   Step 2 — bar-side-label leveämmäksi, teksti ei enää pinoidu
   ============================================================ */
.bar-side-label {
  max-width:  90px;
  text-align: right;
}

/* ============================================================
   Step 3 — tilaa otsikon ja asteikon välille
   ============================================================ */
.step3-layout {
  margin-top: 32px;
}
