/* Base layout */
:root{
  --brand: #2596be;
  --brand-contrast: #fff;
  --accent: #f3bb20;
  --accent-contrast: #111;
  --danger: #dc2626;
}

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

img,
svg,
video,
canvas,
iframe,
object{
  max-width: 100%;
}

img{
  background: #fff;
}

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.6;
  color: #111;
  background: #fff;
  margin: 0;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}
.container{
  max-width: 950px;
  margin: 40px auto;
  padding: 0 16px;
}

.site-footer{
  max-width: 950px;
  margin: 24px auto 16px auto;
  padding: 0 16px;
  text-align: center;
  font-size: 14px;
}

.site-footer__link{
  color: var(--brand);
  text-decoration: underline;
  font-weight: 700;
}

.site-footer__link:hover{
  color: var(--accent);
}

/* Prevent common mobile overflows */
pre,
code{
  max-width: 100%;
  overflow-x: auto;
}

/* Fullscreen media viewer (mobile) */
.media-lightbox{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 999;
  display: none;
}
.media-lightbox.show{
  display: block;
}
.media-lightbox__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
}
.media-lightbox__viewport{
  position: relative;
  width: 100%;
  height: 100%;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: none;
}
.media-lightbox__content{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
}
.media-lightbox__viewport img,
.media-lightbox__viewport svg{
  max-width: 100%;
  max-height: 100%;
  background: #fff;
}
.media-lightbox__close{
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 28px;
  line-height: 44px;
  text-align: center;
  z-index: 1000;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,0.2);
}
.media-lightbox__close:hover{ background: var(--accent); color: var(--accent-contrast); }

body.media-lightbox-open{
  overflow: hidden;
  touch-action: none;
}

.lightbox-target{
  cursor: zoom-in;
}

table{
  max-width: 100%;
}

.module{
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Admin dashboard look (mirrors Django admin) */
#admin-container{
  max-width: 1100px;
  margin: 0 auto;
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
  width: 100%;
  overflow-x: hidden;
}
#admin-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--brand);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
}

/* Hamburger menu button (hidden by default, shown on mobile) */
.header-hamburger{
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}
.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after{
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.hamburger-icon{
  position: relative;
}
.hamburger-icon::before,
.hamburger-icon::after{
  content: '';
  position: absolute;
  left: 0;
}
.hamburger-icon::before{ top: -7px; }
.hamburger-icon::after{ top: 7px; }
.header-hamburger[aria-expanded="true"] .hamburger-icon{ background: transparent; }
.header-hamburger[aria-expanded="true"] .hamburger-icon::before{ transform: rotate(45deg); top: 0; }
.header-hamburger[aria-expanded="true"] .hamburger-icon::after{ transform: rotate(-45deg); top: 0; }
#branding #site-name a{
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}
#user-tools{
  color: #fff;
  font-size: 14px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  white-space: nowrap;
}
#user-tools a{ color: #fff; text-decoration: underline; font-weight: 600; }

.header-right{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 auto;
}
.header-links{
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-weight: 700;
}
.header-link{
  color: #fff;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.header-link:hover{
  background: rgba(255,255,255,0.12);
}
.header-links .divider{ color: #fff; }

.main{ padding: 18px 16px 24px 16px; }
#content h1{
  margin: 0 0 14px 0;
  font-size: 1.4rem;
  border: none;
  color: var(--brand);
}

.app-list{
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  align-items: start;
}
.app-list .module{
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
.app-list table{ width: 100%; border-collapse: collapse; }
.app-list caption{
  padding: 12px 14px;
  background: #f0f0f0;
  font-weight: 700;
  text-align: left;
}
.app-list th{
  text-align: left;
}
.app-list td{
  text-align: left;
}
.app-list caption a{ color: #000; text-decoration: none; }
.app-list tbody tr:nth-child(even){ background: #fff; }
.app-list tbody tr:nth-child(odd){ background: #f9f9f9; }
.app-list th,
.app-list td{
  padding: 10px 14px;
  border-top: 1px solid #e5e5e5;
}
.app-list th a{ color: #2c3e50; text-decoration: none; font-weight: 700; }
.app-list .changelink{ color: var(--brand); font-weight: 700; }
.app-list .changelink:hover{ text-decoration: underline; }

#content-related{
  margin-top: 18px;
}
#content-related .module{
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 12px 14px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
#content-related h2{
  margin: 0 0 8px 0;
  font-size: 1rem;
  color: var(--brand);
}
#content-related h3{
  margin: 0 0 6px 0;
  font-size: 0.9rem;
  color: #374151;
}
.actionlist{ margin: 0; padding-left: 16px; color: #374151; }
.actionlist li{ margin: 6px 0; }
.addlink{ color: var(--brand); font-weight: 700; }
.changelink{ color: var(--brand); font-weight: 700; }

.visually-hidden{
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.clear{ clear: both; }

/* Full-width override for landing page */
body.landing-full #admin-container{
  max-width: none;
  width: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  border: none;
  padding: 0;
  padding-top: 64px; /* space for fixed header */
}
#admin-header ul{
  list-style: none;
  margin: 0;
  padding: 0;
}
body.landing-full #admin-header{
  border-radius: 0;
  padding-left: 20px;
  padding-right: 20px;
}
body.landing-full main.container{
  margin: 0;
  padding: 0;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}
body.landing-full .auth-floating-left,
body.landing-full .auth-floating-right{
  display: none !important;
}
body.landing-full #admin-container .main{
  padding-left: 20px;
  padding-right: 20px;
}

/* Django-admin inspired shell */
.admin-shell{
  background: linear-gradient(135deg,#f7f9fb 0%,#eef3f6 100%);
  border: 1px solid #dfe6eb;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
  overflow: hidden;
}
.admin-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--brand);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand{
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.brand-text h1{
  margin: 2px 0 0 0;
  font-size: 1.2rem;
  line-height: 1.3;
  border: none;
  padding: 0;
  color: #fff;
}
.eyebrow{
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
}
.admin-actions{
  display: flex;
  align-items: center;
}
.admin-btn{
  background: #f0f0f0;
  color: var(--brand);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.admin-btn:hover{
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.22);
}

.admin-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  padding: 18px 20px 20px 20px;
}
.admin-card{
  background: #fff;
  border: 1px solid #e3e8ed;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.admin-card h2{
  margin: 6px 0 6px 0;
  font-size: 1.05rem;
  color: var(--brand);
}
.admin-card p{
  margin: 0 0 10px 0;
  color: #374151;
}
.card-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand);
  font-weight: 700;
}
.admin-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.08);
  border-color: #d0dae2;
}

/* Course pages shell */
.course-shell{
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 10px 20px 22px 20px;
  box-sizing: border-box;
  overflow-x: hidden;
}
.course-title-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.course-title-row h1{
  margin: 2px 0 0 0;
  border: none;
  color: var(--brand);
  font-size: 1.4rem;
}
.course-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}
.course-actions .admin-btn{
  box-shadow: 0 4px 14px rgba(0,0,0,0.16);
}
.course-module{
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
.course-shell .block{
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  background: #f8fafc;
  box-shadow: none;
}
.course-shell h2{
  color: var(--brand);
}
.course-shell .label{
  color: var(--brand);
}

/* Top-right button on homepage */
.hero-row{
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.hero-row h1{ margin: 0; }

.top-button{
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(0,0,0,0.12);
  transition: all 0.25s ease;
  margin-left: auto;
}
.top-button:hover{
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.16);
}

@media (max-width: 640px){
  .hero-row{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .top-button{
    margin-left: 0;
    align-self: flex-start;
  }
}

/* Headings and blocks */
h1{
  font-size: 1.6rem;
  border-bottom: 3px solid var(--brand);
  padding-bottom: 6px;
  margin-bottom: 18px;
}
h2{ margin-top: 26px; font-size: 1.2rem; }
.block{
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
  background: #fafafa;
}
.label{ font-weight: 700; margin-bottom: 8px; }
.green{ color: #1d8f2b; font-weight: 600; }

/* Course hint boxes */
.hint-green{
  padding: 12px 14px;
  margin: 10px 0 12px 0;
  border: 1px solid #ddd;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--brand);
}

/* Links and lists */
ul{ margin: 8px 0 0 18px; line-height: 2; }
a{ text-decoration: none; color: #111; transition: color 0.3s; }
a:hover{ color: var(--brand); }

/* Back link */
.back-link{
  display: inline-block;
  margin-bottom: 20px;
  color: #111;
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: all 0.3s ease;
}
.back-link:hover{ background:var(--accent); color:var(--accent-contrast); border-color:var(--accent); }

/* Plots */
.plot-container{ margin: 20px 0; text-align: center; }
.plot{ max-width: 100%; width: 100%; height: auto; display: block; margin: 0 auto; }
.plot{ max-width: min(100%, 900px); max-height: 70vh; object-fit: contain; border-radius: 10px; box-shadow: 0 8px 22px rgba(0,0,0,0.08); }

/* Clickable SVG decision diagrams */
.decision-diagram object.plot{
  width: 100%;
  max-width: min(100%, 900px);
  height: 360px;
  max-height: 70vh;
  aspect-ratio: 900 / 360;
}
.decision-diagram-inline svg{
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  max-width: min(100%, 900px);
  max-height: 70vh;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
}
.decision-diagram svg g.node{ cursor: pointer; }
.decision-diagram svg g.node:hover polygon,
.decision-diagram svg g.node:hover ellipse,
.decision-diagram svg g.node:hover path{
  fill: #f0f0f0;
}
.decision-diagram svg g.node:hover text{ fill: var(--brand); }

/* Short highlight for anchor jumps (e.g. clicking diagram nodes) */
.jump-highlight{
  animation: jump-highlight 3s ease-in-out 1;
  border-radius: 10px;
}
@keyframes jump-highlight{
  0%, 10%, 20%, 30%, 40%, 50%, 60%{
    background: #f0f0f0;
    box-shadow: 0 0 0 3px var(--accent);
  }
  5%, 15%, 25%, 35%, 45%, 55%, 65%{
    background: transparent;
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
  }
  100%{
    background: transparent;
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
  }
}

/* Course: right-side in-page navigation */
.with-side-nav{ /* base: no shift on mobile, handled in media query */
  display: block;
  padding-left: 0;
  margin-left: 0;
  box-sizing: border-box;
}

/* Hide mobile FAB by default (only show on narrow screens) */
.course-nav-fab{ display: none; }
.course-nav-backdrop{ display: none; }
.course-side-nav{
  position: fixed;
  left: 0;                 /* flush to the left edge */
  top: 0;                 /* start at very top to fill the column */
  bottom: 0;              /* extend to the bottom of the viewport */
  width: 220px;
  padding: 88px 12px 20px 20px; /* leave room for header + spacing */
  background: var(--brand);
  color: #fff;
  border: none;           /* no border */
  border-radius: 0; /* no rounded corners */
  box-shadow: none;       /* remove shadow */
  font-size: 14px;
  z-index: 90;
}
.course-side-nav .course-side-nav-toggle{ display: none; background: none; border: none; font-weight:700; cursor: pointer; padding: 6px 0; }
.course-side-nav ul{ list-style: none; margin: 8px 0 0 0; padding: 0; }
.course-side-nav li{ margin: 8px 0; }
.course-side-nav a{ color: #fff; text-decoration: none; padding: 8px 10px; display: inline-block; border-radius: 6px; font-weight:600; }
.course-side-nav a:hover{ background: rgba(255,255,255,0.08); color: #fff; }
.course-side-nav a.active{ background: var(--accent); color: var(--accent-contrast); box-shadow: none; }

@media (max-width: 640px){
  .container{ margin: 16px auto; padding: 0 12px; }

  h1{ font-size: 1.35rem; }
  h2{ margin-top: 18px; }

  .block{ padding: 14px; border-radius: 10px; }

  ul{ line-height: 1.7; }

  /* Allow header/user tools to wrap on small screens */
  #user-tools{ white-space: normal; }

  /* Admin dashboard grids -> stack */
  .app-list{ grid-template-columns: 1fr; }
  .app-list .module{ border-radius: 8px; }

  /* Reduce fixed diagram height on phones */
  .decision-diagram object.plot{ height: min(360px, 46vh); }

  /* Hide floating auth buttons on very small screens to avoid overlap */
  .auth-floating-left,
  .auth-floating-right{ display: none !important; }
}

/* Course: subsection links (indented) */
.course-side-nav li.nav-sub{ margin: 2px 0; }
.course-side-nav li.nav-sub a{
  padding: 6px 10px 6px 22px;
  font-size: 13px;
  font-weight: 600;
}

.course-side-nav .course-side-nav-toggle{ color: #fff; }

@media (max-width: 840px){
  .with-side-nav{ padding-left: 0; }

  /* Header hamburger menu on mobile */
  .header-hamburger{ display: flex; }
  .header-right{
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--brand);
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    z-index: 130;
  }
  #admin-header .header-right .header-links{
    flex-direction: column;
    gap: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  #admin-header .header-right .header-links.open{
    max-height: 300px;
    padding: 12px 16px;
  }
  .header-link{
    display: block;
    padding: 10px 8px;
    border-radius: 4px;
  }
  .header-links .divider{ display: none; }

  /* tighten course container spacing on mobile */
  .course-shell{ padding: 10px 14px 18px 14px; max-width: 100vw; overflow-x: hidden; }
  .course-title-row{ flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 10px; max-width: 100%; }
  .course-title-row h1{ font-size: 1.3rem; margin: 4px 0 0 0; word-wrap: break-word; }
  .course-module{ padding: 14px; border-radius: 10px; max-width: 100%; box-sizing: border-box; }
  .course-shell .block{ margin: 12px 0; padding: 14px; max-width: 100%; box-sizing: border-box; }
  .plot{ max-height: 50vh; }

  /* Mobile drawer style */
  .course-side-nav{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    padding: 18px 18px 24px 18px;
    background: var(--brand);
    box-shadow: 0 -6px 16px rgba(0,0,0,0.22);
    transform: translateY(100%);
    transition: transform 0.25s ease, opacity 0.25s ease;
    opacity: 0;
    max-height: 78vh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    z-index: 140;
  }
  .course-side-nav.open{ transform: translateY(0); opacity: 1; }
  .course-side-nav .course-side-nav-toggle{ display: none; }
  .course-side-nav ul{ display: block; }
  .course-side-nav ul{ margin: 0; }
  .course-side-nav a{ padding: 10px 0; display: block; color: #fff; }

  .course-side-nav li.nav-sub a{ padding-left: 16px; font-size: 13px; }

  /* Floating action button to open nav */
  .course-nav-fab{
    display: inline-flex;
    position: fixed;
    right: 16px;
    bottom: 16px;
    padding: 12px 16px;
    border: none;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(0,0,0,0.18);
    cursor: pointer;
    z-index: 130;
  }

  /* Backdrop */
  .course-nav-backdrop{
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 120;
  }
  .course-nav-backdrop.show{
    opacity: 1;
    pointer-events: auto;
  }
}

/* Lagebeziehungen: make sections easier to scan (scoped) */
.lagebeziehungen-page .block{
  border-left-width: 6px;
}
.lagebeziehungen-page .block--overview{ border-left-color: var(--brand); }
.lagebeziehungen-page .block--gg{ border-left-color: var(--brand); }
.lagebeziehungen-page .block--ge{ border-left-color: var(--brand); }
.lagebeziehungen-page .block--ee{ border-left-color: var(--brand); }

.lagebeziehungen-page h3{
  margin-top: 18px;
  padding: 8px 10px;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  background: #fff;
}

.lagebeziehungen-page hr{
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 16px 0;
}

/* Lagebeziehungen: back to decision diagram button */
.lagebeziehungen-page .back-to-diagram{
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
  font-weight: 800;
  line-height: 1;
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.lagebeziehungen-page .back-to-diagram.show{
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.lagebeziehungen-page .back-to-diagram:hover{
  background: var(--brand);
  color: #fff;
}
.lagebeziehungen-page .back-to-diagram:focus{
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (max-width: 840px){
  /* avoid overlap with the course nav FAB */
  .lagebeziehungen-page .back-to-diagram{ bottom: 72px; }
}

@media (min-width: 841px){
  /* Shift course content to the right of the fixed left nav */
  .with-side-nav{
    margin-left: 220px;
    padding-left: 24px;
    max-width: calc(100% - 220px);
  }
  /* Ensure left nav stays the intended width */
  .course-side-nav{ width: 220px; }
}
