/*
 * DATA SCIENCE KÖNYV – frissített vizuális stílus
 * ----------------------------------------------------------
 * Kizárólag CSS: nem igényel HTML-módosítást, JavaScriptet,
 * külső betűkészletet vagy más függőséget.
 * A pandoc.css UTÁN töltődik be; annak alapszabályait finomítja.
 */

:root {
  color-scheme: light;
  --ink: #1a2c47;
  --body-ink: #304866;
  --muted: #64748b;
  --accent: #008b94;
  --accent-deep: #087885;
  --accent-2: #7152dd;
  --accent-3: #fb7663;
  --line: #dbe7f1;
  --paper: #ffffff;
  --surface: #f6f9fd;
  --code-bg: #14243b;
  --radius: 16px;
  --font-sans: Inter, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  background: #e8f4f8;
  background-image: radial-gradient(ellipse at 2% 10%, #cbedf0 0, transparent 46%),
                    radial-gradient(ellipse at 96% 6%, #e7e4ff 0, transparent 51%),
                    linear-gradient(160deg, #effaff, #f6f6ff 80%);
}
body {
  width: min(100% - 3rem, 1060px);
  max-width: none;
  min-height: 100vh;
  margin: 2.2rem auto 3.5rem;
  padding: 3.2rem clamp(1.6rem, 5.2vw, 4.5rem) 4rem;
  background: var(--paper);
  border: 1px solid #d5e2ec;
  border-radius: 24px;
  box-shadow: 0 22px 65px rgba(28, 57, 104, .10);
  color: var(--body-ink);
  font: 16.5px/1.8 var(--font-sans);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #c9f5ee; color: #133958; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 4px; border-radius: 4px; }

/* Hosszú olvasásra hangolt szöveg és alcímek */
p { margin: .95rem 0 1.22rem; }
strong { color: var(--ink); font-weight: 750; }
em { color: #4b5b83; }
a {
  color: #087895;
  text-decoration-color: rgba(0, 139, 148, .35);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  transition: color .18s ease, text-decoration-color .18s ease, background .18s ease;
}
a:hover { color: #6948c4; text-decoration-color: currentColor; }
a:focus-visible { outline-offset: 3px; }
h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  line-height: 1.28;
  letter-spacing: -.025em;
  overflow-wrap: break-word;
  text-wrap: pretty;
}
h1 { margin: 2.3rem 0 1.15rem; font-size: clamp(2.05rem, 4.3vw, 3.05rem); }
h2 { margin: 3.15rem 0 1.3rem; font-size: clamp(1.65rem, 3vw, 2.32rem); }
h3 { margin: 2.4rem 0 1.0rem; font-size: clamp(1.26rem, 2vw, 1.53rem); }
h4 { margin: 1.8rem 0 .7rem; font-size: 1.12rem; }
h5, h6 { margin: 1.5rem 0 .6rem; }
hr { border: 0; height: 1px; background: var(--line); margin: 2rem 0; }
small { color: var(--muted); }

/* Kezdőoldal – könyvborító (csak az eredeti #title-block-header) */
#title-block-header {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: -.2rem -1.3rem 2.8rem;
  padding: clamp(2rem, 5.6vw, 4.3rem) clamp(1.7rem, 5vw, 4.5rem);
  color: #fff;
  background: linear-gradient(125deg, #192d4c 2%, #244b7c 51%, #583fa3 100%);
  border: 0;
  border-radius: 23px;
  box-shadow: 0 20px 34px rgba(36, 51, 100, .17);
}
#title-block-header::before,
#title-block-header::after {
  position: absolute;
  z-index: -1;
  content: "";
  width: 350px;
  height: 350px;
  border: 1px solid rgba(255, 255, 255, .19);
  border-radius: 50%;
  pointer-events: none;
}
#title-block-header::before { right: -165px; top: -175px; }
#title-block-header::after { right: 6%; bottom: -305px; }
#title-block-header .title {
  max-width: 850px;
  margin: 0;
  color: #fff;
  font-size: clamp(2.1rem, 4.55vw, 3.36rem);
  font-weight: 800;
  letter-spacing: -.047em;
  line-height: 1.14;
}
#title-block-header .subtitle {
  max-width: 650px;
  margin: 1.55rem 0 0;
  padding: .12rem 0 .12rem 1.2rem;
  border-left: 4px solid #57e7db;
  color: #e5edff;
  font-size: clamp(1rem, 2vw, 1.16rem);
  font-weight: 500;
  line-height: 1.65;
}

/* Kezdőoldal – Pandoc tartalomjegyzék, kártyás fejezetlista */
#tartalom {
  position: relative;
  padding-bottom: 1rem;
  margin: 1.5rem 0 2rem;
  font-size: clamp(1.9rem, 3.5vw, 2.35rem);
  border-bottom: 2px solid var(--line);
}
#tartalom::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 70px;
  height: 4px;
  border-radius: 10px;
  background: linear-gradient(90deg, #fb7266, #ffbc5c);
}
/* A h2#sch... (és a run.py-k által .toc-chapter osztállyal jelölt) fejezetcímeket
   mindegyik következő ul kapcsolja össze. */
:is(h2[id^="sch"], .toc-chapter) {
  --section-color: #008c93;
  --section-soft: #e5f7f7;
  margin: 2rem 0 0;
  padding: 1.15rem 1.3rem 1.05rem;
  background: linear-gradient(115deg, var(--section-soft), #f6f9fe 85%);
  border: 1px solid #dce7f2;
  border-left: 6px solid var(--section-color);
  border-radius: 16px 16px 0 0;
  font-size: clamp(1.13rem, 2vw, 1.36rem);
  font-weight: 760;
  line-height: 1.43;
  letter-spacing: -.025em;
}
:is(h2[id^="sch"], .toc-chapter) + ul {
  margin: 0 0 2.05rem;
  padding: 1rem 1.1rem 1.1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.2rem;
  row-gap: .24rem;
  list-style: none;
  background: #fbfdff;
  border: 1px solid #dce7f2;
  border-top: 0;
  border-radius: 0 0 16px 16px;
}
:is(h2[id^="sch"], .toc-chapter) + ul li { min-width: 0; margin: 0; padding: 0; }
:is(h2[id^="sch"], .toc-chapter) + ul a {
  display: block;
  position: relative;
  padding: .55rem .45rem .55rem 1.5rem;
  border-radius: 8px;
  color: #305474;
  font-size: .91rem;
  font-weight: 600;
  line-height: 1.55;
  text-decoration: none;
}
:is(h2[id^="sch"], .toc-chapter) + ul a::before {
  content: "↗";
  position: absolute;
  left: .18rem;
  top: .52rem;
  color: #00939a;
  font-weight: 800;
}
:is(h2[id^="sch"], .toc-chapter) + ul a:hover { background: #e9f8fa; color: #086b82; }
/* Színes, de egységes fejezetcsoportok */
:is(h2[id^="sch"], .toc-chapter):nth-of-type(6n+2) { --section-color: #7651df; --section-soft: #efebff; }
:is(h2[id^="sch"], .toc-chapter):nth-of-type(6n+3) { --section-color: #ec7967; --section-soft: #fff0ec; }
:is(h2[id^="sch"], .toc-chapter):nth-of-type(6n+4) { --section-color: #178ac6; --section-soft: #eaf5ff; }
:is(h2[id^="sch"], .toc-chapter):nth-of-type(6n+5) { --section-color: #23a78e; --section-soft: #e8faf3; }
:is(h2[id^="sch"], .toc-chapter):nth-of-type(6n+6) { --section-color: #ad65b8; --section-soft: #f8edfc; }

/* Alfejezetek – címszámok és címsorok */
body > h2[data-number] {
  position: relative;
  margin: 2rem 0 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(2rem, 4.2vw, 2.66rem);
  font-weight: 810;
  letter-spacing: -.045em;
}
body > h2[data-number]::after {
  position: absolute;
  content: "";
  bottom: -2px;
  left: 0;
  width: 85px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #008b94, #7b50e0);
}
body > h2[data-number] > .header-section-number {
  color: #008b94;
  margin-right: .12em;
  white-space: nowrap;
}
body > h3[data-number] {
  padding-bottom: .5rem;
  border-bottom: 1px solid #e1eaf3;
  font-weight: 750;
}
body > h3[data-number] > .header-section-number,
body > h4[data-number] > .header-section-number {
  display: inline-block;
  margin-right: .45rem;
  padding: .05rem .45rem;
  border-radius: 7px;
  background: #e7f7f7;
  color: #087f86;
  font-size: .78em;
  font-weight: 750;
  white-space: nowrap;
  letter-spacing: -.01em;
}
body > h4[data-number] { color: #304262; }
body > h4[data-number] > .header-section-number { background: #efeaff; color: #6647be; }

/* Listák / szövegdobozok */
ul, ol { padding-left: 1.6rem; margin: 1rem 0 1.5rem; }
li { padding-left: .18rem; margin: .35rem 0; }
li::marker { color: #7651df; font-weight: 750; }
li > ul, li > ol { margin: .35rem 0 .7rem; }
blockquote {
  margin: 1.7rem 0;
  padding: .9rem 1.3rem;
  border-left: 4px solid #7152dd;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(90deg, #f2efff, #f8fbff);
  color: #37496e;
}
blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }
p:has(> strong:only-child) {
  width: fit-content;
  max-width: 100%;
  margin: 1.7rem 0 .7rem;
  padding: .38rem .82rem;
  border-left: 4px solid #fb7663;
  border-radius: 8px;
  background: #fff1ec;
}
p:has(> strong:only-child) strong { color: #8a4550; }

/* Kód – olvasható, színes szintaxis, valódi vízszintes görgetéssel */
code, pre, kbd, samp { font-family: var(--font-mono); }
:not(pre) > code {
  padding: .13em .38em;
  border: 1px solid #cfebeb;
  border-radius: 6px;
  background: #eaf8f8;
  color: #006b78;
  font-size: .87em;
  font-weight: 620;
  white-space: break-spaces;
  overflow-wrap: anywhere;
}
pre {
  display: block;
  width: 100%;
  margin: 1.3rem 0 1.8rem;
  padding: 1rem 1.2rem;
  border: 1px solid #c8e9e2;
  border-radius: 12px;
  background: #edf9f5;
  color: #1d5557;
  font-size: .84rem;
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
  overflow-wrap: normal;
  tab-size: 4;
}
pre > code { font-size: inherit; color: inherit; white-space: pre; overflow-wrap: normal; }
div.sourceCode {
  position: relative;
  margin: 1.55rem 0 1.85rem;
  padding: 0;
  border: 1px solid #31425f;
  border-radius: 13px;
  background: var(--code-bg);
  box-shadow: 0 12px 25px rgba(21, 38, 70, .13);
  overflow: hidden;
}
div.sourceCode::before {
  content: "KÓD";
  display: block;
  padding: .42rem 1.2rem;
  border-bottom: 1px solid #2e425e;
  color: #96b5d1;
  background: #1a304d;
  font: 700 .68rem/1.4 var(--font-sans);
  letter-spacing: .11em;
}
div.sourceCode:has(> pre.python)::before { content: "PYTHON"; }
div.sourceCode:has(> pre.sql)::before { content: "SQL"; }
div.sourceCode:has(> pre.bash)::before { content: "TERMINÁL · BASH"; }
div.sourceCode:has(> pre.powershell)::before { content: "POWERSHELL"; }
div.sourceCode:has(> pre.json)::before { content: "JSON"; }
div.sourceCode:has(> pre.yaml)::before { content: "YAML"; }
div.sourceCode:has(> pre.r)::before { content: "R"; }
div.sourceCode > pre.sourceCode {
  margin: 0;
  padding: 1.08rem 1.25rem 1.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e0ecff;
  font-size: .84rem;
  line-height: 1.65;
  overflow-x: auto;
}
div.sourceCode > pre > code.sourceCode,
div.sourceCode > pre > code.sourceCode > span {
  color: inherit;
  white-space: pre;
  overflow-wrap: normal;
}
div.sourceCode code span.kw,
div.sourceCode code span.cf,
div.sourceCode code span.im { color: #c9a9ff; font-weight: 700; }
div.sourceCode code span.st,
div.sourceCode code span.vs,
div.sourceCode code span.ss,
div.sourceCode code span.ch { color: #a7e6bb; }
div.sourceCode code span.dv,
div.sourceCode code span.fl,
div.sourceCode code span.bn { color: #ffbc83; }
div.sourceCode code span.co,
div.sourceCode code span.cv,
div.sourceCode code span.an,
div.sourceCode code span.do { color: #9badc4; font-style: italic; }
div.sourceCode code span.fu,
div.sourceCode code span.bu { color: #7cd7ff; }
div.sourceCode code span.va,
div.sourceCode code span.at { color: #e7dfff; }
div.sourceCode code span.op,
div.sourceCode code span.sc { color: #ffc6a0; }
div.sourceCode code span.er,
div.sourceCode code span.al { color: #ff7d8b; }
div.sourceCode code span.dt,
div.sourceCode code span.cn { color: #f2d998; }
div.sourceCode code span.ot,
div.sourceCode code span.pp { color: #b0e5e0; }
pre.numberSource { margin-left: 0; border-left: 0; padding-left: 1.25rem; }
pre.numberSource code > span { left: 0; }
pre.numberSource code > span > a:first-child::before { color: #8195b0; }

/* Adattáblák – kerekített fejléc, zebra-sorok, mobilon oldalra gördülnek */
table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.6rem 0 1.9rem;
  border: 1px solid #dae7f1;
  border-radius: 13px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  box-shadow: 0 6px 15px rgba(26, 54, 94, .04);
  font-size: .87rem;
  line-height: 1.6;
}
thead { background: #e8f5fb; }
th, td {
  padding: .7rem .85rem;
  text-align: left;
  vertical-align: top;
  border: 0;
  border-bottom: 1px solid #e4edf4;
  min-width: 9.5rem;
  overflow-wrap: normal;
}
th { color: #215270; font-weight: 760; white-space: normal; }
th:not(:last-child), td:not(:last-child) { border-right: 1px solid #ecf1f7; }
tbody tr:nth-child(even) { background: #f6f9fd; }
tbody tr:hover { background: #eef9f8; }
tbody tr:last-child td { border-bottom: 0; }
table code { font-size: .82em; }
td:first-child, th:first-child { min-width: 10.5rem; }

/* Matematikai képletek, képek, egyéb Pandoc-elemek */
math { font-size: 1.05em; }
math[display="block"] {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 1.25rem 0;
  padding: .85rem .7rem;
  border: 1px solid #e5e9fa;
  border-left: 3px solid #8072df;
  border-radius: 10px;
  background: linear-gradient(105deg, #f5f6ff, #fafcff);
  color: #273e71;
  text-align: center;
}
.display { display: block; text-align: center; max-width: 100%; overflow-x: auto; }
figure { margin: 1.8rem 0; }
img, svg { max-width: 100%; height: auto; }
img { display: block; margin: 1.25rem auto .5rem; border-radius: 9px; }
figcaption { margin-top: .65rem; text-align: center; color: var(--muted); font-size: .9rem; }
#TOC { margin: 1.6rem 0; padding: 1.3rem 1.5rem; border: 1px solid #cde9ee; border-radius: var(--radius); background: #edfafb; }
#TOC ul { padding-left: 1.4rem; }

/* Lapozósáv – működik a meglévő .pagenav markup változtatása nélkül */
.pagenav { font-size: .88rem; }
.pagenav.top { margin: 0 0 2.2rem; padding: .75rem 0 1.25rem; border-bottom: 1px solid var(--line); }
.pagenav.bottom { margin: 3.25rem 0 0; padding: 1.45rem 0 .4rem; border-top: 1px solid var(--line); }
.pagenav .crumbs {
  margin: 0 0 .85rem;
  padding: .52rem .85rem;
  border-radius: 9px;
  background: #ecf7fa;
  color: #345e7b;
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.55;
}
.pagenav .crumbs a { color: #345e7b; text-decoration: none; }
.pagenav .crumbs a:hover { color: #6948c4; }
.pagenav .links { display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center; gap: .7rem; }
.pagenav .links > a {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-block;
  padding: .68rem .9rem;
  border: 1px solid #d9e5f0;
  border-radius: 10px;
  background: #f5f9fe;
  color: #35536e;
  font-size: .83rem;
  font-weight: 730;
  line-height: 1.5;
  text-decoration: none;
}
.pagenav .links > a:hover { background: #e9f7fc; border-color: #abdce3; color: #087885; }
.pagenav .links > a.home { flex: 0 0 auto; background: #f0ebff; border-color: #e1d8fc; color: #6545bb; text-align: center; }
.pagenav .links > a.home:hover { background: #e9dfff; }
.pagenav .links > a.prev { text-align: left; }
.pagenav .links > a.next {
  margin-left: auto;
  max-width: 48%;
  text-align: right;
  border-color: #07859d;
  background: linear-gradient(120deg, #008e96, #126ca7);
  color: white;
  box-shadow: 0 5px 13px rgba(9, 117, 154, .14);
}
.pagenav .links > a.next:hover { background: linear-gradient(120deg, #00757e, #125a8b); color: white; }

/* Tabletek, keskeny képernyők */
@media (max-width: 760px) {
  body { width: min(100% - 1.5rem, 1060px); margin: .8rem auto 1.5rem; padding: 2rem 1.55rem 3rem; border-radius: 18px; }
  #title-block-header { margin: 0 0 2rem; border-radius: 17px; }
  :is(h2[id^="sch"], .toc-chapter) + ul { grid-template-columns: 1fr; }
  .pagenav .links { flex-wrap: wrap; align-items: stretch; }
  .pagenav .links > a.next { max-width: 100%; }
  .pagenav .links > a.home { order: -1; flex-basis: 100%; }
  table { font-size: .83rem; }
}
@media (max-width: 480px) {
  html { background: #fff; }
  body { width: 100%; min-height: 100vh; margin: 0; padding: 1.15rem 1rem 2.7rem; border: 0; border-radius: 0; box-shadow: none; font-size: 15.5px; line-height: 1.76; }
  #title-block-header { padding: 2rem 1.35rem 2.2rem; }
  #title-block-header .title { font-size: 2.18rem; }
  #title-block-header .subtitle { font-size: 1rem; }
  :is(h2[id^="sch"], .toc-chapter) { padding: 1rem .9rem; font-size: 1.12rem; }
  :is(h2[id^="sch"], .toc-chapter) + ul { padding: .6rem .75rem .8rem; }
  :is(h2[id^="sch"], .toc-chapter) + ul a { padding-top: .6rem; padding-bottom: .6rem; }
  body > h2[data-number] { font-size: clamp(1.7rem, 7.7vw, 2.15rem); }
  body > h3[data-number] { font-size: 1.25rem; }
  .pagenav .links > a { padding: .65rem .7rem; }
  .pagenav .links > a.prev, .pagenav .links > a.next { flex: 1 1 100%; max-width: 100%; text-align: center; }
  .pagenav .links > a.home { order: -1; }
  .pagenav .links > a.next { margin-left: 0; }
  div.sourceCode > pre.sourceCode, pre { font-size: .77rem; }
  table { font-size: .79rem; }
  th, td { padding: .58rem .66rem; }
  math[display="block"] { padding: .7rem .35rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
/* Nyomtatás: tinta- és papírkímélő változat */
@media print {
  @page { margin: 1.7cm; }
  html { background: white; }
  body { width: auto; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; font-size: 11pt; color: #1b2b40; }
  .pagenav { display: none !important; }
  #title-block-header { padding: 1.5cm; margin: 0 0 1cm; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  h1, h2, h3, h4 { break-after: avoid; }
  img, table, pre, blockquote, div.sourceCode, math[display="block"] { break-inside: avoid; }
  :is(h2[id^="sch"], .toc-chapter) + ul { display: block; }
  a { color: #19576d; }
  a::after { display: none; }
  pre { white-space: pre-wrap; }
  div.sourceCode > pre.sourceCode { white-space: pre-wrap; }
  div.sourceCode > pre > code.sourceCode { white-space: pre-wrap; }
}
