/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap');

:root {
    /* HSLU Corporate Identity */
    --color-primary: #0064a3;
    --color-primary-light: #0078c2;
    --color-primary-dark: #004f80;
    --color-primary-subtle: #EBF5FB;

    /* Neutrals */
    --color-text: #1A1A1A;
    --color-text-secondary: #4A4A4A;
    --color-text-light: #5A5A5A;
    --color-background: #FFFFFF;
    --color-background-warm: #FAFAFA;
    --color-background-alt: #F5F5F5;
    --color-border: #E0E0E0;
    --color-border-light: #EEEEEE;

    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 5rem;
    --space-3xl: 7rem;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Shadows (layered, soft) */
    --shadow-sm: 0 1px 2px rgba(16, 42, 67, 0.05), 0 1px 3px rgba(16, 42, 67, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 42, 67, 0.06), 0 12px 28px rgba(16, 42, 67, 0.08);
    --shadow-lg: 0 8px 24px rgba(16, 42, 67, 0.08), 0 24px 56px rgba(16, 42, 67, 0.12);

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms var(--ease-out);

    /* Layout */
    --max-width: 1200px;
    --max-width-narrow: 800px;
    --header-height: 72px;
}

body {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--color-text);
    background-color: var(--color-background);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-light);
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

img {
    max-width: 100%;
    display: block;
}

.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;
}

/* ===== Scroll reveal (progressive enhancement) ===== */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
    will-change: opacity, transform;
}

.reveal.is-visible {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .reveal {
        opacity: 1;
        transform: none;
    }
}

/* ===== Typography ===== */
h1, h2, h3 {
    line-height: 1.25;
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 3.25rem);
    letter-spacing: -0.02em;
    font-weight: 600;
}

h2 {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3vw, 2rem);
    letter-spacing: -0.01em;
    font-weight: 600;
}

h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
}

.eyebrow {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: var(--space-sm);
}

.lead {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
    line-height: 1.8;
}

/* ===== Layout ===== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-lg);
    width: 100%;
}

.section {
    padding: var(--space-xl) 0;
}

.section-header {
    margin-bottom: var(--space-xl);
}

.section-header.centered {
    text-align: center;
    max-width: var(--max-width-narrow);
    margin-left: auto;
    margin-right: auto;
    margin-bottom: var(--space-xl);
}

.section-header p {
    margin-top: var(--space-sm);
}

/* ===== Header ===== */
.site-header {
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border-light);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.92);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header .brand {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-header .brand-logo {
    height: 28px;
    width: auto;
}

.site-header .brand span {
    font-weight: 400;
    color: var(--color-text-light);
    border-left: 1px solid var(--color-border);
    padding-left: 0.75rem;
}

.site-header nav {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.site-header nav a {
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    padding: 0.5rem 0;
    transition: color var(--transition-fast);
    border-bottom: 2px solid transparent;
}

.site-header nav a:hover,
.site-header nav a.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background var(--transition-base), color var(--transition-base),
        border-color var(--transition-base), transform var(--transition-base),
        box-shadow var(--transition-base);
}

.btn .btn-arrow {
    transition: transform var(--transition-base);
}

.btn:hover .btn-arrow {
    transform: translateX(3px);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== Hero ===== */
.hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-background) 0%, var(--color-primary-subtle) 100%);
    padding: var(--space-3xl) var(--space-lg);
    text-align: center;
    border-bottom: 1px solid var(--color-border-light);
}

/* Subtle dotted grid + radial glow backdrop — CSS only */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(0, 100, 163, 0.10) 1px, transparent 1px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    top: -30%;
    left: 50%;
    width: 60rem;
    height: 60rem;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(0, 120, 194, 0.12) 0%, transparent 60%);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    z-index: 1;
    max-width: var(--max-width-narrow);
    margin: 0 auto;
}

.hero .eyebrow {
    margin-bottom: var(--space-md);
}

.hero h1 {
    color: var(--color-text);
    margin-bottom: var(--space-md);
}

.hero .lead {
    max-width: 600px;
    margin: 0 auto;
}

.hero-cta {
    margin-top: var(--space-lg);
}

.hero-stats {
    margin-top: var(--space-md);
    font-family: var(--font-heading);
    font-size: 0.875rem;
    color: var(--color-text-light);
    letter-spacing: 0.02em;
}

.hero-stats strong {
    color: var(--color-text);
    font-weight: 600;
}

/* Hero entrance — staggered fade-up */
@media (prefers-reduced-motion: no-preference) {
    .hero-inner > * {
        opacity: 0;
        animation: hero-rise 0.7s var(--ease-out) forwards;
    }
    .hero-inner > *:nth-child(1) { animation-delay: 0.05s; }
    .hero-inner > *:nth-child(2) { animation-delay: 0.15s; }
    .hero-inner > *:nth-child(3) { animation-delay: 0.25s; }
    .hero-inner > *:nth-child(4) { animation-delay: 0.35s; }
    .hero-inner > *:nth-child(5) { animation-delay: 0.45s; }
    .hero-inner > *:nth-child(6) { animation-delay: 0.55s; }
}

@keyframes hero-rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}

.staff {
    margin-top: var(--space-md);
    font-size: 0.9375rem;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.hero .staff {
    justify-content: center;
}

.staff a {
    color: var(--color-text-secondary);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.staff a:hover {
    color: var(--color-primary);
}

.staff-sep {
    color: var(--color-border);
}

/* ===== Footer ===== */
#footer {
    margin-top: auto;
}

.site-footer {
    background: var(--color-background-warm);
    border-top: 1px solid var(--color-border-light);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.875rem;
    line-height: 1.8;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.footer-links a {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.footer-links a:hover {
    color: var(--color-primary);
}

/* ===== Semester Cards (Landing Page) ===== */
.semester-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
}

.semester-card {
    background: var(--color-background);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: transform var(--transition-base), box-shadow var(--transition-base),
        border-color var(--transition-base);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    position: relative;
    overflow: hidden;
}

.semester-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-primary);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.semester-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-border);
    transform: translateY(-3px);
}

.semester-card .card-chip {
    align-self: flex-start;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--color-primary);
    background: var(--color-primary-subtle);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.semester-card:hover::before {
    opacity: 1;
}

.semester-card h3 {
    color: var(--color-text);
}

.semester-card p {
    color: var(--color-text-light);
    font-size: 0.9375rem;
}

.semester-card .arrow {
    margin-top: auto;
    padding-top: var(--space-sm);
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    transition: gap var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.semester-card:hover .arrow {
    gap: 0.5rem;
}

/* ===== Semester Page ===== */
.page-header {
    padding: var(--space-2xl) 0 var(--space-xl);
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: var(--space-xl);
}

.page-title {
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}

.page-subtitle {
    color: var(--color-text-light);
    font-size: 1.1rem;
}

/* ===== Projects toolbar (search + count) ===== */
.projects-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.search-box {
    position: relative;
    flex: 1 1 280px;
    max-width: 420px;
}

.search-box svg {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-light);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--color-text);
    padding: 0.7rem 1rem 0.7rem 2.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-background);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box input::placeholder {
    color: var(--color-text-light);
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 100, 163, 0.12);
}

.project-count {
    font-family: var(--font-heading);
    font-size: 0.875rem;
    color: var(--color-text-light);
    white-space: nowrap;
}

.project-count strong {
    color: var(--color-text);
    font-weight: 600;
}

.empty-state {
    display: none;
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
    color: var(--color-text-light);
}

.empty-state.is-visible {
    display: block;
}

.empty-state h3 {
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}

/* ===== Project Cards ===== */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-lg);
    padding-bottom: var(--space-3xl);
}

.project-card {
    background: var(--color-background);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base),
        border-color var(--transition-base);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.project-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--color-border);
}

.project-card .card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--color-background-alt);
    border-bottom: 1px solid var(--color-border-light);
    transition: transform var(--transition-slow);
}

.project-card:hover .card-image {
    transform: scale(1.05);
}

/* Architecture-diagram cards: show the whole diagram (no crop) and let it zoom. */
.project-card .card-media {
    position: relative;
    display: block;
}

.project-card .card-media .card-image {
    object-fit: contain;
    background: #fff;
    cursor: zoom-in;
    padding: 6px;
}

/* A contain-fitted diagram shouldn't scale on hover (it just shifts within the box). */
.project-card:hover .card-media.is-zoomable .card-image {
    transform: none;
}

/* Hover affordance that the diagram opens full-screen. */
.project-card .card-zoom-badge {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(20, 20, 20, 0.72);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.project-card .card-media.is-zoomable:hover .card-zoom-badge {
    opacity: 1;
}

/* When a diagram fails to load, the runtime drops is-zoomable: revert to crop.
   Exclude the logo fallback (is-fallback) so it keeps its centered styling. */
.project-card .card-media:not(.is-zoomable) .card-image:not(.is-fallback) {
    object-fit: cover;
    cursor: auto;
    padding: 0;
}

.project-card .card-media:not(.is-zoomable) .card-zoom-badge {
    display: none;
}

/* Full-screen diagram lightbox. */
.diagram-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(10, 12, 16, 0.86);
    cursor: zoom-out;
}

.diagram-lightbox.is-open {
    display: flex;
}

.diagram-lightbox img {
    max-width: 96vw;
    max-height: 92vh;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

.diagram-lightbox .lightbox-close {
    position: absolute;
    top: 18px;
    right: 24px;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
}

/* Branded fallback when the GitHub OpenGraph image fails to load */
.project-card .card-image.is-fallback {
    object-fit: contain;
    padding: 16% 22%;
    background: linear-gradient(135deg, var(--color-primary-subtle) 0%, #fff 100%);
}

.project-card:hover .card-image.is-fallback {
    transform: none;
}

.project-card .card-body {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.project-card .card-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.25rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card .card-author {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-bottom: var(--space-sm);
}

.project-card .card-summary {
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
    flex-grow: 1;
    margin-bottom: var(--space-md);
}

.project-card .card-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--color-primary);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.625rem 1.25rem;
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-base), color var(--transition-base),
        box-shadow var(--transition-base);
    align-self: flex-start;
    background: transparent;
}

.project-card .card-link:hover {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.project-card.is-hidden {
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-header {
        height: auto;
        padding: var(--space-sm) var(--space-md);
    }

    .header-inner {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .site-header .brand span {
        display: none;
    }

    .hero {
        padding: var(--space-2xl) var(--space-md);
    }

    .container {
        padding: 0 var(--space-md);
    }

    .project-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .semester-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .projects-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        flex: none;
        width: 100%;
        max-width: none;
    }
}
