/* ============================================================
   KALKULATOR KALORII I MAKRO — style specyficzne dla strony
   Korzysta z tokenów i komponentów z styles.css (--accent, .btn, .field, .wrap...)
   ============================================================ */

.calc-page { background: var(--surface-2); }

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 4vw, 56px);
  margin-top: 52px;
  align-items: start;
}

/* ---------- formularz ---------- */
.calc-form .field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px 16px;
  margin: 0 0 18px;
}
.calc-form .field-group legend {
  font-size: 13.5px;
  font-weight: 700;
  padding: 0 6px;
}
.radio-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.radio-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 999px;
  font-size: 14.5px; font-weight: 600; color: var(--text-soft);
  cursor: pointer; transition: border-color .2s, background .2s, color .2s;
}
.radio-pill input { accent-color: var(--accent); }
.radio-pill.is-checked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.radio-pill:focus-within { box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }

.field-hint { margin-top: 8px; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }

/* ---------- tryb trenera (opcja dyskretna, nie ma konkurować wizualnie z resztą formularza) ---------- */
.trainer-toggle { margin: 0 0 18px; }
.checkbox-subtle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 500; color: var(--text-faint);
  cursor: pointer; user-select: none;
}
.checkbox-subtle input { width: 14px; height: 14px; accent-color: var(--text-faint); cursor: pointer; }
.checkbox-subtle:hover { color: var(--text-soft); }
.trainer-fields { margin-top: 10px; padding-left: 2px; }
.trainer-fields[hidden] { display: none; }

.calc-form .btn { width: 100%; margin-top: 4px; }

/* ---------- panel wyników ---------- */
.calc-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(26px, 3vw, 40px);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.calc-placeholder { color: var(--text-faint); text-align: center; font-size: 15px; margin: 0 auto; max-width: 320px; }

:root {
  /* Kolory dopasowane do emoji makroskładników: białko 🍗 — jasny, kremowy,
     tłuszcz 🥑 (awokado) — zielony, węglowodany 🍞 (chleb) — złocisto-brązowy.
     Osobno od kolorów wykresu prognozy (--chart-illustration), żeby zmiana
     jednych nie ruszała drugich. */
  --macro-protein: #EFE6D2;
  --macro-fat: #6E9B5E;
  --macro-carbs: #E3B23C;
  --chart-illustration: #B5713C;
}

.result-label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 700; }
.result-value { display: block; font-family: var(--heading-font); font-size: 21px; font-weight: 800; margin-top: 6px; }
.result-value-kcal { font-family: var(--body-font); font-size: 11.5px; font-weight: 600; color: var(--text-faint); }
.result-hint { margin-top: 8px; font-size: 12.5px; color: var(--text-soft); line-height: 1.5; }

/* ---------- hero: cel kaloryczny ---------- */
.result-hero {
  text-align: center; padding: 22px 16px; border-radius: var(--radius-lg);
  border: 1.5px solid var(--accent); background: var(--accent-soft);
}
.result-hero .result-label { color: var(--accent-strong); }
.result-hero-value {
  display: block; font-family: var(--heading-font); font-weight: 800;
  font-size: clamp(38px, 5vw, 52px); line-height: 1.1; margin-top: 8px; color: var(--text);
}
.result-hero .result-hint { max-width: 480px; margin-inline: auto; font-size: 13.5px; }

/* ---------- BMR / TDEE: statystyki drugorzędne ---------- */
.result-substats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
.result-substat { padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: center; }
.result-substat-value { display: block; font-family: var(--heading-font); font-size: 16px; font-weight: 700; margin-top: 2px; }
.result-substat-caption { display: block; font-size: 11px; color: var(--text-faint); margin-top: 1px; }

/* ---------- makroskładniki: kafelki w kolumnie + wykres kołowy ---------- */
.result-macros-wrap { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: center; margin-top: 24px; }
.result-macros-list { display: grid; gap: 10px; }
.result-macro {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto;
  align-items: center; column-gap: 10px;
  padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm);
}
.result-macro .macro-emoji { grid-column: 1; grid-row: 1; }
.result-macro .result-label { grid-column: 2; grid-row: 1; text-align: left; }
.result-macro .result-value { grid-column: 3; grid-row: 1; margin-top: 0; text-align: right; white-space: nowrap; font-size: 19px; }
.result-macro .result-basis { grid-column: 2 / span 2; grid-row: 2; margin-top: 14px; text-align: left; }
.result-basis { display: block; font-size: 11.5px; color: var(--text-faint); }

.macro-emoji { font-size: 18px; line-height: 1; grid-row: 1; }

.result-macro-pie { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.macro-pie-svg { width: 130px; height: 130px; }
.macro-pie-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; color: var(--text-soft); }
.macro-pie-legend li { display: flex; align-items: center; gap: 8px; }
.macro-pie-legend b { color: var(--text); margin-left: auto; }

.result-chart { margin-top: 30px; }
.chart-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.result-chart h3 { font-size: 16px; }

.horizon-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.horizon-btn {
  border: none; background: transparent; color: var(--text-soft); font-family: var(--body-font);
  font-weight: 700; font-size: 12.5px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: background .2s, color .2s;
}
.horizon-btn.is-active { background: var(--accent); color: var(--accent-ink); }
.horizon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#chartSvgContainer { position: relative; }
.calc-chart-svg { width: 100%; height: auto; display: block; touch-action: none; }
.calc-chart-area { fill: var(--accent-soft); stroke: none; }
.calc-chart-line { fill: none; stroke: var(--accent); stroke-width: 2.75; stroke-linecap: round; stroke-linejoin: round; }
.calc-chart-real { fill: none; stroke: var(--chart-illustration); stroke-width: 1.8; stroke-dasharray: 4 4; stroke-linecap: round; opacity: .85; }
.calc-chart-dot { fill: var(--accent); }

.chart-gridline { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 9.5px; font-family: var(--body-font); fill: var(--text-faint); }
.chart-axis-label-y { text-anchor: end; }
.chart-axis-label-x { text-anchor: middle; }
.chart-axis-title { font-size: 9.5px; font-family: var(--body-font); fill: var(--text-faint); text-anchor: end; }


.chart-overlay { fill: transparent; cursor: crosshair; }
.chart-overlay:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chart-guide-line { stroke: var(--border-strong); stroke-width: 1; opacity: 0; pointer-events: none; }
.chart-guide-line.is-active { opacity: 1; }
.chart-guide-dot { pointer-events: none; opacity: 0; stroke: var(--surface); stroke-width: 1.5; }
.chart-guide-dot.is-active { opacity: 1; }
.chart-guide-dot-trend { fill: var(--accent); }
.chart-guide-dot-real { fill: var(--chart-illustration); }

.chart-tooltip {
  position: absolute; top: -8px; transform: translateY(-100%);
  background: var(--band); color: var(--band-text); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 11.5px; line-height: 1.5; white-space: nowrap;
  pointer-events: none; box-shadow: var(--shadow); z-index: 2;
}
.chart-tooltip b { display: block; font-size: 12px; margin-bottom: 2px; }
.chart-tooltip span { display: block; }
.chart-tooltip .tooltip-trend { color: color-mix(in srgb, var(--accent) 65%, white); }
.chart-tooltip .tooltip-real { color: color-mix(in srgb, var(--chart-illustration) 55%, white); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 12px; color: var(--text-soft); }
.chart-legend span { position: relative; padding-left: 20px; }
.chart-legend span::before { content: ""; position: absolute; left: 0; top: 50%; width: 14px; height: 2.5px; transform: translateY(-50%); border-radius: 2px; }
.legend-trend::before { background: var(--accent); }
.legend-real::before {
  background: none;
  background-image: repeating-linear-gradient(90deg, var(--chart-illustration) 0 4px, transparent 4px 8px);
  opacity: .9;
}

.chart-endpoint { margin-top: 14px; font-size: 14.5px; color: var(--text-soft); }
.chart-endpoint b { font-size: 17px; color: var(--text); }
.chart-note { margin-top: 12px; font-size: 12px; color: var(--text-faint); line-height: 1.6; }

.calc-note-inline { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.6; }
.calc-note-inline p { color: inherit; }
.calc-note-floor { background: var(--accent-soft); color: var(--accent-strong); }
.calc-note-info { background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }

.calc-note-warning { display: flex; align-items: flex-start; gap: 10px; }
.calc-note-icon { flex-shrink: 0; margin-top: 1px; }
.calc-note-text p + p { margin-top: 6px; }

.result-hero-value--muted { color: var(--text-soft); }
.result-hint-warning { display: inline-flex; align-items: flex-start; gap: 6px; text-align: left; color: var(--accent-strong); }
.result-hint-warning .calc-note-icon { margin-top: 2px; }

.export-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; align-items: center; }
.export-actions .btn { width: auto; flex: 1 1 auto; min-width: 180px; }
.export-status { width: 100%; font-size: 12.5px; color: var(--text-faint); margin: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- wysuwana zakładka "prezent" (przykładowy dzień treningowy za e-mail) ---------- */
.side-gift {
  position: fixed; top: 50%; right: 0; transform: translateY(-50%);
  z-index: 60;
  /* .side-gift-inner jest szersze niż to, co faktycznie widać (patrz niżej), a CSS
     transform na dziecku nie zmniejsza pudełka rodzica — bez tego #sideGift miałby
     niewidoczny, zawsze obecny hitbox na pełną (otwartą) szerokość, blokujący klikanie
     w cokolwiek, co akurat jest pod nim na stronie. Realną klikalność oddajemy więc
     .side-gift-inner, które faktycznie podąża (wizualnie i w hit-testingu) za swoim
     transformem. */
  pointer-events: none;
}
.side-gift[hidden] { display: none; }

.side-gift-inner {
  display: flex; align-items: stretch;
  transform: translateX(calc(100% - 76px));
  transition: transform .3s ease;
  box-shadow: 0 0 0 3px var(--bg), 0 18px 40px rgba(0, 0, 0, .18);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  pointer-events: auto;
}
/* .is-near-gift to poszerzona, niewidoczna (i nieblokująca kliknięć w resztę
   strony — patrz initSideGift w JS) strefa wokół zakładki: najechanie na nią
   dodaje tę klasę dopiero po odczekaniu chwili (opóźnienie liczone w JS, nie
   przez CSS transition-delay — dzięki temu klik (.is-open) zawsze otwiera
   natychmiast i nie ma wyścigu między regułami o różnym opóźnieniu tej samej
   właściwości). JS liczy tę strefę względem aktualnego, realnego położenia
   całej wysuwanej zakładki (patrz initSideGift), więc gdy jest już otwarta,
   strefa obejmuje też panel — ruch myszy w stronę pola e-mail jej nie zamyka. */
.side-gift.is-open .side-gift-inner,
.side-gift.is-near-gift .side-gift-inner,
.side-gift:focus-within .side-gift-inner {
  transform: translateX(0);
}

.side-gift-tab {
  width: 76px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 20px 10px; font-family: inherit; font-weight: 800; font-size: 17px; letter-spacing: .08em;
  box-shadow: 0 10px 26px rgba(224, 81, 76, .5), 0 2px 8px rgba(21, 41, 46, .1);
  transition: box-shadow .25s ease, background .2s ease;
  animation: sideGiftGlow 2.4s ease-in-out infinite;
}
.side-gift-tab svg { flex-shrink: 0; width: 30px; height: 30px; }
.side-gift-tab span { writing-mode: vertical-rl; text-orientation: mixed; text-transform: uppercase; }

.side-gift-tab:hover,
.side-gift.is-open .side-gift-tab,
.side-gift.is-near-gift .side-gift-tab,
.side-gift:focus-within .side-gift-tab {
  background: var(--accent-strong); animation-play-state: paused;
  box-shadow: 0 0 0 6px rgba(224, 81, 76, .22), 0 16px 42px rgba(224, 81, 76, .95), 0 2px 10px rgba(21, 41, 46, .15);
}

@keyframes sideGiftGlow {
  0%, 100% { box-shadow: 0 10px 26px rgba(224, 81, 76, .5), 0 2px 8px rgba(21, 41, 46, .1); }
  50% { box-shadow: 0 10px 34px rgba(224, 81, 76, .85), 0 2px 10px rgba(21, 41, 46, .14); }
}
@media (prefers-reduced-motion: reduce) {
  .side-gift-tab { animation: none; }
}

.side-gift-panel {
  width: 300px; max-width: calc(100vw - 56px); flex: 0 0 auto;
  background: var(--surface-2); border: 1px solid var(--border); border-left: none;
  box-shadow: var(--shadow-lg);
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.side-gift.is-open .side-gift-panel,
.side-gift.is-near-gift .side-gift-panel,
.side-gift:focus-within .side-gift-panel {
  opacity: 1; pointer-events: auto;
}

/* Na wąskich ekranach pionowa zakładka na środku wysokości ekranu nachodziła na
   treść (nie ma już bocznego marginesu, jaki jest na desktopie). Zamieniamy ją
   w małą "pigułkę" przypiętą do rogu — panel wysuwa się znad niej (do góry),
   nie w bok, bo przy samym rogu nie ma miejsca z boku. */
@media (max-width: 640px) {
  .side-gift { top: auto; bottom: 16px; right: 16px; left: auto; transform: none; }

  .side-gift-inner {
    display: block; transform: none; box-shadow: none; border-radius: 0;
  }

  .side-gift-tab {
    width: auto; flex-direction: row; gap: 8px;
    border-radius: 999px; padding: 13px 18px 13px 14px; font-size: 14px; letter-spacing: .02em;
  }
  .side-gift-tab svg { width: 22px; height: 22px; }
  .side-gift-tab span { writing-mode: horizontal-tb; text-orientation: initial; text-transform: none; }

  .side-gift-panel {
    position: absolute; right: 0; bottom: calc(100% + 12px);
    width: min(300px, calc(100vw - 32px));
    border-radius: var(--radius); border: 1px solid var(--border);
    transform: translateY(12px);
    transition: opacity .25s ease, transform .25s ease;
  }
  .side-gift.is-open .side-gift-panel,
  .side-gift.is-near-gift .side-gift-panel,
  .side-gift:focus-within .side-gift-panel {
    transform: translateY(0);
  }
}

.lead-magnet-head { display: flex; align-items: center; gap: 10px; }
.lead-magnet-head svg { color: var(--accent); flex-shrink: 0; }
.lead-magnet-head h3 { font-size: 16px; }
.side-gift-panel > p { margin-top: 6px; font-size: 13.5px; color: var(--text-soft); line-height: 1.5; }
.lead-magnet-form { margin-top: 14px; }
.lead-magnet-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.lead-gender-group { border: none; padding: 0; margin: 0 0 12px; }
.lead-gender-row { flex-wrap: nowrap; gap: 6px; }
.lead-gender-pill { flex: 1 1 0; justify-content: center; gap: 5px; padding: 7px 4px; font-size: 11.5px; white-space: nowrap; }
.lead-gender-pill svg { flex-shrink: 0; width: 14px; height: 14px; }
.lead-magnet-row { display: flex; flex-direction: column; gap: 10px; }
.lead-magnet-row input[type="email"] {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px;
}
.lead-magnet-row input[type="email"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.lead-magnet-row .btn { align-self: center; }
.lead-magnet-status { margin-top: 10px; font-size: 12.5px; color: var(--text-faint); }
.lead-magnet-status.is-success { color: var(--accent-strong); font-weight: 700; }

/* ---------- sekcje informacyjne ---------- */
.calc-method, .calc-note, .calc-disclaimer { max-width: 760px; margin: 36px auto 0; }
.calc-note p { color: var(--text-soft); line-height: 1.7; }
.calc-note {
  padding: 18px 22px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14.5px;
}
.calc-disclaimer { font-size: 13px; color: var(--text-faint); border-top: 1px solid var(--border); padding-top: 20px; }
.calc-disclaimer p { color: inherit; line-height: 1.6; }

.calc-method-details {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px;
}
.calc-method-details summary {
  cursor: pointer; font-weight: 700; font-size: 14.5px; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.calc-method-details summary::-webkit-details-marker { display: none; }
.calc-method-details summary::after { content: "+"; color: var(--accent); font-size: 20px; font-weight: 700; }
.calc-method-details[open] summary::after { content: "–"; }
.calc-method-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.calc-method-list li { font-size: 13px; color: var(--text-soft); line-height: 1.6; }
.calc-method-list b { color: var(--text); }

.calc-lead-placeholder[hidden] { display: none; }

/* .calc-cta łączy się z globalną klasą .cta-band (tło --accent, dekoracja, .tag, .btn-onband) —
   tutaj tylko layout i rzeczy specyficzne dla wersji wyśrodkowanej na stronie kalkulatora. */
.calc-cta { margin-top: 40px; text-align: center; border-radius: var(--radius-lg); }
.calc-cta-inner { position: relative; z-index: 2; padding: clamp(32px, 5vw, 52px); }
.calc-cta h2 { font-size: clamp(26px, 3vw, 36px); margin-top: 14px; margin-inline: auto; }
.calc-cta p { margin-inline: auto; }
.calc-cta .cta-actions { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 26px; flex-wrap: wrap; }

/* Dekoracyjne ikony w rogach pasma CTA — subtelne (16% krycia), częściowo wychodzące
   poza krawędź; czysto ozdobne, więc aria-hidden i bez wpływu na czytelność tekstu. */
.calc-cta-icon { position: absolute; z-index: 1; width: 230px; height: 230px; opacity: .16; pointer-events: none; }
.calc-cta-icon-right { right: -10px; bottom: -18px; transform: rotate(-6deg); }
.calc-cta-icon-left { left: -10px; top: -18px; transform: rotate(8deg); }
@media (max-width: 640px) {
  .calc-cta-icon { width: 150px; height: 150px; }
}

/* ---------- responsywność ---------- */
@media (max-width: 860px) {
  .calc-grid { grid-template-columns: 1fr; }
  .calc-results { order: 2; }
}
@media (max-width: 560px) {
  .result-substats { grid-template-columns: 1fr 1fr; }
  .result-macros-wrap { grid-template-columns: 1fr; }
  .result-macro-pie { flex-direction: row; justify-content: center; }
  .radio-row { gap: 8px; }
  .radio-pill { padding: 9px 14px; font-size: 13.5px; }
  .chart-header { flex-direction: column; align-items: flex-start; }
  .export-actions .btn { width: 100%; }
}
