/*
 * python-kurs.eu — visual modernization layer (prototype, 2026-08-12)
 *
 * Deliberately additive: this file is loaded AFTER the historical/Jupyter CSS.
 * It keeps the established python-kurs.eu palette and does not alter tutorial
 * content or generated notebook HTML.
 */

:root {
  --pk-green-dark: #476042;
  --pk-green: #6A9662;
  --pk-green-light: #A6C0A1;
  --pk-green-pale: #ddffdd;
  --pk-orange: #F17C0B;
  --pk-orange-text: #A94E00;
  --pk-cream: #FAF8E9;
  --pk-page: #f5f7f4;
  --pk-surface: #ffffff;
  --pk-code: #f3f8f1;
  --pk-text: #29342d;
  --pk-muted: #647068;
  --pk-border: #dce4da;
  --pk-shadow: 0 8px 28px rgba(31, 49, 35, .08);
  --pk-radius: 10px;
}

html {
  scroll-behavior: smooth;
  background: var(--pk-page);
}

body {
  margin: 0;
  padding: 0;
  color: var(--pk-text);
  background: var(--pk-page);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* ---------- Page shell ---------- */

#container {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 0;
  background: var(--pk-surface);
  box-shadow: var(--pk-shadow);
}

#banner {
  min-height: 78px;
  height: auto;
  margin: 0;
  padding: 18px 24px;
  color: var(--pk-green-dark);
  background-color: #fff;
  /* Restore the historical image if it exists; the old combined CSS contains
     a malformed absolute URL. The color remains a safe fallback. */
  background-image: url("images/image03.jpg");
  background-repeat: no-repeat;
  background-position: left center;
  background-size: auto 100%;
  border-bottom: 1px solid var(--pk-border);
}

#banner h1 {
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  font-size: clamp(1.45rem, 2.1vw, 2rem);
  line-height: 1.2;
  letter-spacing: -.02em;
  font-weight: 680;
  color: var(--pk-green-dark);
  background: transparent;
}

/* ---------- Top navigation ---------- */

#navlist {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  width: 100%;
  margin: 0 0 28px;
  padding: 7px 14px;
  line-height: 1.3;
  color: #fff;
  background: var(--pk-green-dark);
  box-shadow: 0 3px 12px rgba(31, 49, 35, .16);
}

#navlist li {
  display: block;
  margin: 0;
  list-style: none;
}

#navlist li a,
#navlist li a:link,
#navlist li a:visited {
  display: block;
  margin: 0;
  padding: .58rem .78rem;
  color: #fff;
  background: transparent;
  border-radius: 7px;
  text-decoration: none;
  font-size: .94rem;
  font-weight: 600;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}

#navlist li a:hover,
#navlist li a:focus-visible {
  color: var(--pk-text);
  background: var(--pk-green-light);
  text-decoration: none;
  outline: none;
}

#navlist li a#current {
  color: var(--pk-text);
  background: var(--pk-green-light);
  box-shadow: inset 0 -3px 0 var(--pk-orange);
}

/* ---------- Three-column learning layout ---------- */

#sidebar-a,
#sidebar-b {
  float: none;
  min-width: 0;
  font-size: .91rem;
  line-height: 1.48;
}

#sidebar-a {
  width: auto;
  margin: 0;
  padding: 0 14px 32px 18px;
  color: var(--pk-muted);
  background: #fff;
}

#sidebar-b {
  width: auto;
  margin: 0 18px 32px 0;
  padding: 14px 16px 22px;
  color: var(--pk-text);
  background: var(--pk-cream);
  border: 1px solid #ece6cc;
  border-radius: var(--pk-radius);
  align-self: start;
}

#content {
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0 34px 52px;
  color: var(--pk-text);
  background: #fff;
  border: 0;
  font-size: 1rem;
  line-height: 1.72;
}

/* Progressive enhancement: modern grid on sufficiently wide screens. */
@media (min-width: 1080px) {
  #container {
    display: grid;
    grid-template-columns: minmax(185px, 215px) minmax(0, 1fr) minmax(190px, 225px);
    grid-template-areas:
      "banner banner banner"
      "nav nav nav"
      "left content right"
      "footer footer footer";
  }

  #banner { grid-area: banner; }
  #navlist { grid-area: nav; }
  #sidebar-a { grid-area: left; }
  #content { grid-area: content; }
  #sidebar-b { grid-area: right; }
  #footer { grid-area: footer; }

  #sidebar-a,
  #sidebar-b {
    position: sticky;
    top: 78px;
    max-height: calc(100vh - 94px);
    overflow: auto;
  }
}

/* Give prose a comfortable reading measure without constraining wide tables,
   notebook figures, or code blocks. */
#content > p,
#content > ul,
#content > ol,
#content > blockquote,
#content > .tutorial-summary,
#content > .modern-note {
  max-width: 78ch;
}

/* ---------- Typography ---------- */

p {
  margin: 0 0 1.05em;
}

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  text-rendering: optimizeLegibility;
}

#content h1,
#content h2,
#content h3,
#content h4 {
  width: auto;
  letter-spacing: normal;
}

#content h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  line-height: 1.15;
  color: var(--pk-green-dark);
  background: transparent;
}

#content h2 {
  margin: .15rem 0 1.35rem;
  padding: 0 0 .65rem;
  font-size: clamp(1.6rem, 2.2vw, 2.05rem);
  line-height: 1.22;
  font-weight: 700;
  color: var(--pk-green-dark);
  background: transparent;
  border-bottom: 2px solid var(--pk-green-light);
}

#content h3 {
  margin: 2.15rem 0 .85rem;
  padding: .18rem 0 .18rem .8rem;
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--pk-green-dark);
  background: transparent;
  border-left: 4px solid var(--pk-green);
}

#content h4 {
  margin: 1.8rem 0 .7rem;
  padding: .12rem 0 .12rem .8rem;
  font-size: 1.08rem;
  line-height: 1.4;
  font-weight: 700;
  color: var(--pk-text);
  background: transparent;
  border-left: 4px solid var(--pk-orange);
}

/* Sidebar headings keep the familiar green/orange language but lose the
   heavy full-width legacy bars. */
#sidebar-a h3,
#sidebar-b h3 {
  margin: 1.2rem 0 .55rem;
  padding: 0 0 .38rem;
  color: var(--pk-green-dark);
  background: transparent;
  border-bottom: 2px solid var(--pk-green-light);
  font-size: .96rem;
  font-weight: 750;
  letter-spacing: .01em;
}

/* ---------- Links ---------- */

a,
a:link,
a:visited {
  color: var(--pk-orange-text);
  background: transparent;
  text-decoration: underline;
  text-decoration-color: rgba(241, 124, 11, .55);
  text-underline-offset: .16em;
  text-decoration-thickness: .08em;
}

a:hover,
a:focus-visible {
  color: var(--pk-green-dark);
  background: transparent;
  text-decoration-color: var(--pk-orange);
}

.menu ul,
.textmenu ul {
  padding-left: 1.1rem;
}

.menu ul li,
.textmenu ul li {
  margin: 0 0 .34rem;
  padding: 0;
  line-height: 1.38;
  color: var(--pk-green);
  list-style-type: square;
}

.menu ul li a,
.textmenu ul li a {
  color: var(--pk-green-dark);
  background: transparent;
  text-decoration: none;
}

.menu ul li a:hover,
.textmenu ul li a:hover {
  color: var(--pk-orange-text);
  background: transparent;
  text-decoration: underline;
  text-decoration-color: var(--pk-orange);
}

#contextlinks {
  margin: 0 0 1.4rem;
  padding: .55rem .75rem;
  color: var(--pk-text);
  background: #edf4eb;
  border-radius: 8px;
}

#contextlinks a:link,
#contextlinks a:visited,
#contextlinks a:hover {
  color: var(--pk-green-dark);
  background: transparent;
}

/* ---------- Notebook and code rendering ---------- */

code,
kbd,
pre,
samp,
.input_area,
.output_area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
}

code {
  font-size: .92em;
  color: #33452f;
  background: #eef4ec;
  border: 1px solid #dce8d8;
  border-radius: 4px;
  padding: .08em .32em;
}

pre,
.highlight pre,
div.output_subarea pre {
  margin: 0;
  padding: 1rem 1.05rem;
  overflow-x: auto;
  overflow-y: visible;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  color: #26352a;
  background: var(--pk-code);
  border: 1px solid #d7e4d3;
  border-left: 4px solid var(--pk-green);
  border-radius: 8px;
  font-size: .91rem;
  line-height: 1.55;
  tab-size: 4;
}

pre code,
.highlight pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font-size: inherit;
}

/* Jupyter's historical HTML stays untouched; only the shell is restyled. */
div.cell {
  margin: 1.15rem 0 1.55rem;
}

div.text_cell {
  margin-top: .4rem;
  margin-bottom: .8rem;
}

div.input,
div.output_wrapper {
  margin: .55rem 0;
}

div.input_area {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  overflow: visible;
}

div.output_wrapper {
  margin-top: .45rem;
  padding: .2rem 0 0 1rem;
  border-left: 3px solid var(--pk-orange);
}

div.output_area pre {
  background: #fbfbf7;
  border-color: #e5e4d7;
  border-left-width: 1px;
}

div.prompt,
div.input_prompt,
div.output_prompt {
  color: var(--pk-muted);
  font-size: .78rem;
}

.highlight {
  background: transparent;
}

/* ---------- Tables, figures, forms ---------- */

table {
  max-width: 100%;
  margin: 1.25rem 0 1.6rem;
  border-collapse: collapse;
  font-size: .94rem;
}

th,
td {
  padding: .58rem .7rem;
  border: 1px solid var(--pk-border);
  vertical-align: top;
}

th {
  color: var(--pk-text);
  background: #eaf2e7;
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: #fafbf9;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.border {
  max-width: 100%;
  margin: .4rem auto 1rem;
  padding: 5px;
  border: 1px solid var(--pk-border);
  border-radius: 8px;
}

input[type="search"],
input[type="text"],
select,
textarea {
  max-width: 100%;
  min-height: 2.15rem;
  padding: .38rem .55rem;
  color: var(--pk-text);
  background: #fff;
  border: 1px solid #bfcbbd;
  border-radius: 6px;
}

input[type="button"],
input[type="submit"],
button {
  min-height: 2.15rem;
  padding: .38rem .7rem;
  color: #fff;
  background: var(--pk-green-dark);
  border: 1px solid var(--pk-green-dark);
  border-radius: 6px;
  cursor: pointer;
}

input[type="button"]:hover,
input[type="submit"]:hover,
button:hover {
  color: var(--pk-text);
  background: var(--pk-green-light);
}

.tutorial-summary,
.modern-note {
  margin: 1.1rem 0 1.6rem;
  padding: .9rem 1.05rem;
  line-height: 1.6;
  border: 1px solid var(--pk-border);
  border-left: 4px solid var(--pk-green);
  border-radius: 8px;
  background: #f7faf6;
}

.modern-note {
  border-left-color: var(--pk-orange);
  background: #fff9f1;
}

/* ---------- Footer ---------- */

#footer {
  clear: both;
  margin: 22px 0 0;
  padding: 18px 24px;
  color: #fff;
  background: var(--pk-green-dark);
  font-size: .9rem;
}

#footer a,
#footer a:link,
#footer a:visited {
  color: #fff;
  background: transparent;
  text-decoration-color: rgba(255,255,255,.5);
}

#footer a:hover,
#footer a:focus-visible {
  color: #fff;
  background: transparent;
  text-decoration-color: var(--pk-orange);
}

/* ---------- Responsive behaviour ---------- */

@media (max-width: 1079px) {
  #container {
    width: 100%;
    box-shadow: none;
  }

  #sidebar-b {
    display: none;
  }

  #sidebar-a {
    float: left;
    width: 190px;
    margin: 0;
    padding-left: 14px;
  }

  #content {
    margin-left: 205px;
    margin-right: 0;
    padding-right: 24px;
  }
}

@media (max-width: 820px) {
  #banner {
    min-height: 64px;
    padding: 14px 16px;
    background-size: auto 64px;
  }

  #banner h1 {
    font-size: 1.4rem;
  }

  #navlist {
    position: sticky;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    margin-bottom: 20px;
    padding: 6px 8px;
    scrollbar-width: thin;
  }

  #navlist li {
    flex: 0 0 auto;
  }

  #navlist li a,
  #navlist li a:link,
  #navlist li a:visited {
    padding: .55rem .68rem;
    font-size: .9rem;
  }

  #sidebar-a,
  #sidebar-b {
    display: none;
  }

  #content {
    margin: 0;
    padding: 0 18px 40px;
    font-size: 1rem;
  }

  #content > p,
  #content > ul,
  #content > ol,
  #content > blockquote,
  #content > .tutorial-summary,
  #content > .modern-note {
    max-width: none;
  }

  pre,
  .highlight pre,
  div.output_subarea pre {
    margin-left: 0;
    margin-right: 0;
    padding: .8rem .85rem;
    font-size: .84rem;
  }

  div.output_wrapper {
    padding-left: .65rem;
  }

  .intro,
  .intro2,
  .intro3,
  .intro_double {
    float: none;
    width: auto;
    margin: 0 0 1rem;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  #navlist,
  #sidebar-a,
  #sidebar-b {
    display: none !important;
  }

  #container {
    display: block;
    box-shadow: none;
  }

  #content {
    margin: 0;
    padding: 0;
  }
}

/* ---------- Mobile navigation improvements (v2) ---------- */

/* JavaScript wraps the top navigation in this shell on small screens. */
.pk-mobile-nav-shell {
  display: contents;
}

.pk-nav-scroll-button,
.pk-mobile-section-nav {
  display: none;
}

@media (max-width: 820px) {
  /* The shell, rather than the list itself, becomes sticky once the helper
     buttons are present. The old behaviour remains the fallback without JS. */
  .pk-mobile-nav-shell {
    position: sticky;
    top: 0;
    z-index: 120;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: stretch;
    width: 100%;
    margin: 0 0 16px;
    background: var(--pk-green-dark);
    box-shadow: 0 3px 12px rgba(31, 49, 35, .18);
  }

  .pk-mobile-nav-shell #navlist {
    position: static;
    min-width: 0;
    margin: 0;
    padding: 6px 3px 7px;
    box-shadow: none;
    scrollbar-width: auto;
    scrollbar-color: var(--pk-orange) rgba(255, 255, 255, .18);
  }

  .pk-mobile-nav-shell #navlist::-webkit-scrollbar {
    height: 8px;
  }

  .pk-mobile-nav-shell #navlist::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, .14);
  }

  .pk-mobile-nav-shell #navlist::-webkit-scrollbar-thumb {
    background: var(--pk-orange);
    border: 2px solid var(--pk-green-dark);
    border-radius: 999px;
  }

  .pk-nav-scroll-button {
    display: grid;
    place-items: center;
    min-width: 38px;
    min-height: 100%;
    padding: 0;
    color: #fff;
    background: var(--pk-green-dark);
    border: 0;
    border-radius: 0;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background-color .16s ease, opacity .16s ease;
  }

  .pk-nav-scroll-button:hover,
  .pk-nav-scroll-button:focus-visible {
    color: #fff;
    background: #385035;
    outline: 2px solid var(--pk-orange);
    outline-offset: -3px;
  }

  .pk-nav-scroll-button:not(:disabled) {
    box-shadow: inset 0 -3px 0 var(--pk-orange);
  }

  .pk-nav-scroll-button:disabled {
    opacity: .26;
    cursor: default;
  }

  /* Compact replacement for the hidden left chapter sidebar. */
  .pk-mobile-section-nav {
    display: block;
    margin: 0 18px 20px;
  }

  .pk-mobile-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: .62rem .82rem;
    color: #fff;
    background: var(--pk-green-dark);
    border: 1px solid var(--pk-green-dark);
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(31, 49, 35, .12);
    font: inherit;
    font-weight: 700;
    text-align: left;
  }

  .pk-mobile-section-toggle:hover,
  .pk-mobile-section-toggle:focus-visible {
    color: var(--pk-text);
    background: var(--pk-green-light);
    outline: 2px solid var(--pk-orange);
    outline-offset: 2px;
  }

  .pk-mobile-section-toggle .pk-chevron {
    flex: 0 0 auto;
    margin-left: .8rem;
    font-size: 1.15rem;
    transition: transform .18s ease;
  }

  .pk-mobile-section-toggle[aria-expanded="true"] .pk-chevron {
    transform: rotate(180deg);
  }

  .pk-mobile-section-panel {
    margin-top: 6px;
    padding: .45rem .5rem .55rem;
    max-height: min(62vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #f7faf6;
    border: 1px solid var(--pk-border);
    border-top: 3px solid var(--pk-orange);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(31, 49, 35, .11);
  }

  .pk-mobile-section-panel[hidden] {
    display: none;
  }

  .pk-mobile-section-panel ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .pk-mobile-section-panel li {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .pk-mobile-section-panel a,
  .pk-mobile-section-panel a:link,
  .pk-mobile-section-panel a:visited {
    display: block;
    padding: .62rem .7rem;
    color: var(--pk-green-dark);
    background: transparent;
    border-radius: 6px;
    text-decoration: none;
    line-height: 1.35;
  }

  .pk-mobile-section-panel a:hover,
  .pk-mobile-section-panel a:focus-visible {
    color: var(--pk-text);
    background: #e7f0e4;
    outline: none;
  }

  .pk-mobile-section-panel a.pk-current,
  .pk-mobile-section-panel a[aria-current="page"] {
    color: var(--pk-text);
    background: #e3ede0;
    box-shadow: inset 4px 0 0 var(--pk-orange);
    font-weight: 750;
  }
}

@media print {
  .pk-mobile-nav-shell {
    display: contents;
  }

  .pk-nav-scroll-button,
  .pk-mobile-section-nav {
    display: none !important;
  }
}
