:root {
    /* Light mode colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-container: #fefefe;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --accent-color: #2d50b2;
    --accent-hover: #3bf3f6;
}

/* Dark mode colors */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #111827;
        --bg-secondary: #1f2937;
        --bg-container: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --border-color: #374151;
        --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
        --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
        --accent-color: #3bf3f6;
        --accent-hover: #2d50b2;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1 {
    font-size: clamp(1.75rem, 2.5vw, 2.25rem);
    line-height: 1.2;
    margin-bottom: 1.75rem;
}

h2 {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    line-height: 1.3;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Increase spacing above h2 when it follows containers or course grids */
.container + h2,
.courses-grid + h2 {
    margin-top: 2.5rem;
}

/* Adjust h2 spacing when it's first in a container */
.container > h2:first-child {
    margin-top: 0;
}

h3 {
    font-size: clamp(1.125rem, 1.8vw, 1.25rem);
    line-height: 1.35;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

p {
    margin-top: 0.75rem;
}

/* Let heading margins control spacing to avoid margin-collapsing surprises */
h1 + p,
h2 + p,
h3 + p {
    margin-top: 0;
}

ul, ol {
    margin-top: 0.75rem;
    padding-left: 1.25rem;
}

li + li {
    margin-top: 0.25rem;
}

/* Global link styles */
a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 700;
}

/* Header Styles */
header {
    background-color: var(--bg-container);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
    min-width: 0;
}

.header-container > * {
    min-width: 0;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: block;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: 400;
    flex-shrink: 0;
    white-space: nowrap;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.5rem;
    transition: color 0.3s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.breadcrumb-item:hover {
    color: var(--accent-hover);
}

/* Navigation */
nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
    padding-bottom: 0.7rem;
    align-items: baseline; /* vertically center items in the nav bar */
    
}

    nav li {
        display: flex;
        align-items: baseline;
    }

    nav li:not(.nav-dropdown) {
        justify-content: flex-end;
    }

nav a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
    padding: 0;                         /* avoid vertical padding skew */
    display: inline-flex;            /* ensure consistent baseline handling */
    align-items: center;             /* vertically center link text */
    line-height: 1;                  /* normalize text metrics */
}

nav a:hover {
    color: var(--accent-color);
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-dropdown-toggle::after {
    content: " ▼";
    font-size: 0.7em;
    opacity: 0.7;
    transition: transform 0.2s ease;
    margin-left: 0.25rem;
}

@media (min-width: 769px) {
    .nav-dropdown:hover .nav-dropdown-toggle::after {
        transform: rotate(180deg);
    }
}

.nav-dropdown.active .nav-dropdown-toggle::after {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-medium);
    min-width: 200px;
    max-width: 300px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 70vh;
    overflow-y: auto;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-menu li {
    display: block;
    margin: 0;
    width: 100%;
}

.nav-dropdown-menu a {
    display: block;
    width: 100%;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    line-height: 1.5;
    box-sizing: border-box;
}

.nav-dropdown-menu a:hover {
    background-color: rgba(45, 80, 178, 0.12);
    color: var(--accent-color);
}

/* Dark mode hover - use lighter, more visible background */
@media (prefers-color-scheme: dark) {
    .nav-dropdown-menu a:hover {
        background-color: rgba(59, 243, 246, 0.2);
        color: var(--accent-color);
    }
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr;
    
}

.container {
    background-color: var(--bg-container);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-medium);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

/* Increase spacing between sections inside containers */
.container section + section {
    margin-top: 2rem;
}

/* Improve spacing between text and following button */
.container p + p {
    margin-top: 1rem;
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7));
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    box-shadow: var(--shadow-light);
    will-change: transform;
}

@media (prefers-color-scheme: dark) {
    .button {
        background: linear-gradient(180deg, rgba(31,41,55,0.9), rgba(17,24,39,0.9));
    }

    /* Dark mode: adjust icon strokes to dark accent color */
    a[href^="mailto:"]::before {
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233bf3f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 4h16v16H4z'/><path d='M22 6l-10 7L2 6'/></svg>");
    }

    a[href^="tel:"]::before {
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233bf3f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M22 16.92v3a2 2 0 0 1-2.18 2 19.8 19.8 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.12.89.3 1.76.54 2.6a2 2 0 0 1-.45 1.95L8.09 9.91a16 16 0 0 0 6 6l1.64-1.14a2 2 0 0 1 1.95-.24c.84 .24 1.71 .42 2.6 .54A2 2 0 0 1 22 16.92z'/></svg>");
    }
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-light);
}

.button-accent {
    border-color: transparent;
    background: linear-gradient(180deg, var(--accent-color), var(--accent-hover));
    color: #ffffff;
}

.button-accent:hover {
    filter: brightness(1.05);
}

.button .icon {
    width: 1.1rem;
    height: 1.1rem;
    display: inline-block;
    transition: transform 0.2s ease;
}

.button:hover .icon {
    transform: translateX(2px);
}

/* Iconified contact links without external assets */
a[href^="mailto:"]::before,
a[href^="tel:"]::before {
    content: "";
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    margin-right: 0.5rem;
    vertical-align: -0.125em;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
    background-color: var(--bg-container);
    border-radius: 0.25rem;
}

/* Email icon */
a[href^="mailto:"]::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232d50b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 4h16v16H4z'/><path d='M22 6l-10 7L2 6'/></svg>");
}

/* Phone icon */
a[href^="tel:"]::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232d50b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M22 16.92v3a2 2 0 0 1-2.18 2 19.8 19.8 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.12.89.3 1.76.54 2.6a2 2 0 0 1-.45 1.95L8.09 9.91a16 16 0 0 0 6 6l1.64-1.14a2 2 0 0 1 1.95-.24c.84 .24 1.71 .42 2.6 .54A2 2 0 0 1 22 16.92z'/></svg>");
}

/* Dark-mode overrides placed AFTER base icons to win the cascade */
@media (prefers-color-scheme: dark) {
    a[href^="mailto:"]::before {
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233bf3f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 4h16v16H4z'/><path d='M22 6l-10 7L2 6'/></svg>");
    }
    a[href^="tel:"]::before {
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233bf3f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M22 16.92v3a2 2 0 0 1-2.18 2 19.8 19.8 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.12.89.3 1.76.54 2.6a2 2 0 0 1-.45 1.95L8.09 9.91a16 16 0 0 0 6 6l1.64-1.14a2 2 0 0 1 1.95-.24c.84 .24 1.71 .42 2.6 .54A2 2 0 0 1 22 16.92z'/></svg>");
    }
}

/* Footer */
footer {
    background-color: var(--bg-container);
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Mobile header - smaller and collapsible */
    .header-container {
        height: 3rem;
        padding: 0 1rem;
    }

    .breadcrumbs {
        gap: 0.5rem;
        overflow: hidden;
        flex: 0 1 auto;
        min-width: 0;
        max-width: calc(100% - 3rem);
    }

    .logo {
        font-size: 1.25rem;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    .breadcrumb-item {
        font-size: 1.125rem;
        gap: 0.375rem;
    }

    .breadcrumb-item .logo-icon {
        width: 20px;
        height: 20px;
    }

    .breadcrumb-separator {
        font-size: 1rem;
    }

    .menu-toggle {
        display: block;
    }

    nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bg-container);
        border-top: 1px solid var(--border-color);
        box-shadow: var(--shadow-medium);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    nav.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    nav ul {
        flex-direction: column;
        gap: 0;
        padding: 1rem;
        align-items: flex-end; /* Align all items to the right */
    }

    nav li {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }

    nav a {
        display: block;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
        text-align: right; /* Align text to the right */
        min-width: 120px; /* Ensure consistent width for easier tapping */
    }

    nav a:last-child {
        border-bottom: none;
    }

    /* Mobile dropdown styles */
    .nav-dropdown {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .nav-dropdown-toggle {
        text-align: right;
        width: 100%;
    }

    .nav-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--border-color);
        margin-top: 0;
        padding: 0;
        max-width: 100%;
    }

    .nav-dropdown.active .nav-dropdown-menu {
        display: flex;
    }

    .nav-dropdown-menu a {
        padding: 0.75rem 1rem;
        padding-right: 2rem;
        text-align: right;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-dropdown-toggle::after {
        float: right;
    }

    /* Auto-hide header on scroll down (mobile only) */
    header.hidden {
        transform: translateY(-100%);
    }

    /* Mobile main content */
    main {
        padding: 1rem;
    }

    .container {
        padding: 1.5rem;
        border-radius: 0.5rem;
    }

    /* Mobile course cards - compact design */
    .courses-grid {
        grid-template-columns: 1fr;
    }

     /* Mobile footer - smaller and collapsible */
    footer {
        transition: all 0.3s ease;
    }

    footer.hidden {
        transform: translateY(100%);
    }

    .footer-container {
        padding: 0.75rem;
        font-size: 0.75rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet styles */
    .header-container {
        padding: 0 1.5rem;
    }

    main {
        padding: 1.5rem;
    }
}

@media (min-width: 1025px) {
    .grid-two {
        grid-template-columns: 1fr 1fr;
        gap: 0rem 2rem; /* row-gap column-gap: smaller vertical, larger horizontal */
    }
}

/* Desktop-only tweaks */
@media (min-width: 769px) {
    nav a {
        height: 4rem; /* match header container height for vertical centering */
    }
}

/* Utility classes */
.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;
}

/* Course cards grid for teaching portal */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0 0 0;
    padding: 0;
}

.course-card {
    position: relative;
    background-color: var(--bg-container);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-medium);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.course-card h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--accent-color);
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.course-card h3::after {
    content: "";
    width: 1.9rem;
    height: 0.60rem;
    flex-shrink: 0;
    display: inline-block;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    border-radius: 0.875rem;
    padding: 0.25rem 0.75rem;
    background-color: transparent;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 8' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M8 4h16'/><path d='M20 1l4 3-4 3'/></svg>"), linear-gradient(180deg, var(--accent-color), var(--accent-hover));
    background-size: 60% auto, 100% 100%;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    box-shadow: var(--shadow-light);
}

.course-card:hover h3::after {
    transform: translateX(2px);
    box-shadow: var(--shadow-medium);
    filter: brightness(1.05);
}

.course-card p {
    color: var(--text-secondary);
    margin: 0;
    flex-grow: 1;
    line-height: 1.4;
    font-size: 0.9rem;
}

/* Make the entire card clickable - hide button content but keep link functional */
/* Only apply this to course cards inside courses-grid */
.courses-grid .course-card .button {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    width: 100%;
    height: 100%;
}

.courses-grid .course-card .button span,
.courses-grid .course-card .button .icon {
    display: none;
}

/* For standalone course cards (not in grid), show the button normally */
.course-card .button {
    margin-top: auto;
    justify-self: flex-end;
}

/* Mobile: More compact design */
@media (max-width: 768px) {
    .courses-grid {
        gap: 0.75rem;
        margin: 1rem 0;
        padding: 0;
    }

    .course-card {
        padding: 1rem;
        gap: 0.375rem;
        background-color: var(--bg-container);
        border-radius: 0.75rem;
        box-shadow: var(--shadow-medium);
        border: 1px solid var(--border-color);
    }

    .course-card h3 {
        font-size: 1rem;
    }

    .course-card h3::after {
        width: 1.6rem;
        height: 0.5rem;
        padding: 0.2rem 0.5rem;
        background-size: 35% auto, 100% 100%;
    }

    .course-card p {
        font-size: 0.85rem;
        line-height: 1.3;
        display: block;
    }

    /* Ensure buttons cover the whole card on mobile and remain clickable */
    .courses-grid .course-card .button {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
        background: transparent;
        border: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
        width: 100%;
        height: 100%;
        display: block;
    }

    .courses-grid .course-card .button span,
    .courses-grid .course-card .button .icon {
        display: none;
    }
}

/* Impressum-specific heading numbering - simplified approach */
.impressum {
    counter-reset: h2-counter;
}

.impressum h2 {
    counter-increment: h2-counter;
    counter-reset: h3-counter;
}

.impressum h2::before {
    content: counter(h2-counter) ". ";
    color: var(--text-primary);
    font-weight: 700;
}

.impressum h3 {
    counter-increment: h3-counter;
}

.impressum h3::before {
    content: counter(h2-counter) "." counter(h3-counter) " ";
    color: var(--text-primary);
    font-weight: 700;
}

/* Grouped links container - card-based layout */
.links-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.link-card {
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.link-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--accent-color);
}

.link-card h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--accent-color);
    margin: 0;
    line-height: 1.2;
}

.link-card p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    flex-grow: 1;
}

.link-card .button {
    margin-top: auto;
    width: 100%;
    justify-content: center;
}

/* Responsive adjustments for grouped links */
@media (max-width: 768px) {
    .links-group {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .link-card {
        padding: 1rem;
    }
}

@media (min-width: 1025px) {
    .links-group {
        grid-template-columns: repeat(3, 1fr);
    }
}

