/* =====================
   CSS CUSTOM PROPERTIES
   ===================== */
:root {
    --primary-bg: #FAF9F5;
    --header-bg: #C66241;   /* lighter orange */
    --header-text: #FAF9F5;
    --main-text: #343433;
    --accent: #A44A3F;      /* darker red-orange */
    --border: #D8D8D8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Gentium Plus', serif;
    background-color: var(--primary-bg);
    color: var(--main-text);
    line-height: 1.6;
}

.container {
    width: 80%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    text-decoration: underline;
}

/* =====================
   GLOBAL PHOTO GREYSCALE + HOVER LIFT
   All photos greyscale at rest, colour + scale on hover.
   ===================== */
img {
    display: block;
    filter: grayscale(100%);
    transition: filter 0.45s ease, transform 0.35s ease;
}

img:hover {
    filter: grayscale(0%);
    transform: scale(1.03);
}

/* =====================
   HEADER
   ===================== */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 20px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
}

header nav ul {
    display: flex;
    list-style: none;
}

header nav ul li {
    margin-left: 30px;
}

header nav ul li a {
    color: var(--header-text);
    font-weight: 500;
    position: relative;
}

header nav ul li a:hover {
    text-decoration: none;
}

header nav ul li a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: var(--header-text);
    transition: width 0.3s ease;
}

header nav ul li a:hover::after,
header nav ul li a.current::after {
    width: 100%;
}

/* =====================
   HERO SECTION (index.html)
   ===================== */
.hero {
    padding: 80px 0;
}

.hero .content {
    display: flex;
    align-items: flex-start;
    gap: 50px;
}

.hero .text-content {
    flex: 2;
    text-align: justify;
}

.hero .text-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Image column on homepage */
.hero .image-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Profile photo: contain so never cropped; hover scale via global rule */
.hero .image-content img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Social icons below profile photo */
.social-icons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    width: 100%;
}

.social-icons a {
    display: inline-block;
}

.social-icons svg {
    width: 24px;
    height: 24px;
    transition: opacity 0.3s ease;
    /* SVG icons are not <img> so the global img rule won't affect them */
}

.social-icons svg:hover {
    opacity: 0.7;
}

/* =====================
   PAGE HEADER (shared listing pages)
   ===================== */
.page-header {
    padding: 40px 0 0;
}

.page-header h1 {
    font-size: 2.5rem;
    color: var(--accent);
}

/* =====================
   FILTER BAR — subtle, no icon
   ===================== */
.filter-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 22px 0;
}

.filter-dropdown {
    position: relative;
    display: inline-block;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #999;
    border: 1px solid #d0cec9;
    border-radius: 4px;
    padding: 6px 14px;
    font-family: 'Gentium Plus', serif;
    font-size: 0.88rem;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.25s ease, border-color 0.25s ease;
    letter-spacing: 0.02em;
}

.filter-btn:hover,
.filter-dropdown.open .filter-btn {
    color: var(--accent);
    border-color: var(--accent);
}

.filter-chevron {
    font-size: 0.62rem;
    display: inline-block;
    transition: transform 0.25s ease;
    color: inherit;
}

.filter-dropdown.open .filter-chevron {
    transform: rotate(180deg);
}

.filter-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background-color: white;
    border: 1px solid #e0ddd8;
    border-radius: 4px;
    min-width: 160px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
    z-index: 100;
    overflow: hidden;
}

.filter-dropdown.open .filter-menu {
    display: block;
}

.filter-menu-section-label {
    display: block;
    padding: 8px 14px 4px;
    font-family: 'Gentium Plus', serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #bbb;
    border-top: 1px solid #f0ede8;
}

.filter-menu-section-label:first-child {
    border-top: none;
}

.filter-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 14px 7px 18px;
    background: none;
    border: none;
    font-family: 'Gentium Plus', serif;
    font-size: 0.88rem;
    color: #777;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.filter-menu button:hover {
    background-color: var(--primary-bg);
    color: var(--accent);
}

.filter-menu button.active {
    color: var(--accent);
    font-weight: 600;
}

/* =====================
   EVENTS TABS (Talks / Conferences and Workshops Organised)
   Text tabs in the site's accent colour with an underline on the
   active tab; the matching year filter sits on the right.
   ===================== */
.events-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 22px 0;
}

.tab-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 30px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 4px 0;
    font-family: 'Gentium Plus', serif;
    font-size: 1.15rem;
    color: #999;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: color 0.25s ease, border-color 0.25s ease;
}

.tab-btn:hover {
    color: var(--accent);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.toolbar-filters {
    display: flex;
    align-items: center;
}

.filter-dropdown.hidden,
.event-section.hidden {
    display: none;
}

/* =====================
   CARD GRID — blog, events, publications (3 columns, masonry)
   CSS columns layout: cards pack to their natural height with no
   whitespace. Cards flow top-to-bottom within each column, then
   left-to-right across columns.
   ===================== */
.card-grid {
    columns: 3;
    column-gap: 26px;
    padding-bottom: 60px;
}

.card {
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    break-inside: avoid;          /* never split a card across columns */
    margin-bottom: 26px;          /* vertical gap between cards */
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.card.hidden {
    display: none;
}

/* =====================
   ROW-ORDERED GRID (events page)
   Cards read left-to-right across each row, then continue on the
   next row (max 3 per row). Cards keep their natural heights.
   Collapses to 2 columns, then 1 column on mobile (same order as before).
   ===================== */
.card-grid.card-grid--rows {
    columns: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 26px;
    row-gap: 26px;
    align-items: start;
}

.card-grid.card-grid--rows .card {
    margin-bottom: 0;
}

/* Once filter.js has measured the cards, rows become 1px units and each
   card spans its own height (+ gap), so there are no vertical gaps. */
.card-grid.card-grid--rows.masonry-ready {
    grid-auto-rows: 1px;
    row-gap: 0;
}

/* =====================
   CARD IMAGE WRAPPER
   No fixed height or aspect-ratio — the image sets its own height
   at its natural proportions (width: 100%, height: auto).
   Portrait photos produce a tall image area; landscape photos
   produce a shorter one. Both fill the full card width with zero
   whitespace and zero cropping.
   ===================== */
.card-image {
    width: 100%;
    display: block;
    overflow: hidden;
    flex-shrink: 0;
    text-decoration: none;
}

.card-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: filter 0.45s ease, transform 0.4s ease;
}

/* Suppress global img:hover scale inside cards —
   scale is handled by the card:hover rule below */
.card-image img:hover {
    transform: none;
}

.card:hover .card-image img {
    transform: scale(1.04);
    filter: grayscale(0%);
}

/* =====================
   CARD BODY — shared by blog, events, publications
   ===================== */
.card-body {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Title — darker orange/red */
.card-body h3 {
    font-size: 1.05rem;
    margin-bottom: 5px;
    line-height: 1.35;
    color: var(--accent);
}

.card-body h3 a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

.card-body h3 a:hover {
    text-decoration: underline;
}

/* Event conference name — bold italic, slightly muted */
.card-body h4 {
    font-size: 0.9rem;
    font-weight: 700;
    font-style: italic;
    color: var(--main-text);
    margin-top: 4px;
    margin-bottom: 2px;
    line-height: 1.3;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 5px;
    margin-top: 3px;
}

/* Publication venue — italic, muted */
.card-venue {
    font-style: italic;
    color: #777;
    font-size: 0.85rem;
}

/* Year — lighter orange, not italic */
.card-year {
    font-weight: 600;
    color: var(--header-bg);
    font-size: 0.85rem;
    font-style: normal;
}

/* Event location — plain */
.card-location {
    color: #666;
    font-size: 0.85rem;
    font-style: normal;
    font-weight: 400;
}

/* Date — lighter orange, not italic */
.card-date {
    color: var(--header-bg);
    font-size: 0.85rem;
    font-style: normal;
    font-weight: 600;
}

.card-sep {
    color: #ccc;
    font-size: 0.75rem;
}

/* =====================
   BLOG POST (individual post page)
   ===================== */
.blog-post {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 0 60px;
}

.blog-post h1 {
    color: var(--accent);
    font-size: 2.5rem;
    margin-bottom: 10px;
    line-height: 1.2;
}

.blog-post .meta {
    color: var(--header-bg);
    font-style: normal;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 28px;
    display: block;
}

/* featured image: contain, never cropped */
.blog-post .featured-image {
    width: 100%;
    height: auto;
    object-fit: contain;
    margin: 0 0 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.blog-post .content {
    text-align: justify;
    line-height: 1.8;
}

.blog-post .content p {
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.blog-post .content h2 {
    color: var(--accent);
    font-size: 1.8rem;
    margin: 40px 0 20px;
}

.blog-post .content h3 {
    color: var(--main-text);
    font-size: 1.5rem;
    margin: 30px 0 15px;
}

.blog-post .content img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    margin: 20px auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.blog-post .content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 20px;
    margin: 30px 0;
    font-style: italic;
    color: #555;
}

.blog-post .content blockquote p {
    margin-bottom: 10px;
}

.blog-post .content blockquote cite {
    display: block;
    text-align: right;
    font-style: normal;
    font-weight: bold;
    margin-top: 10px;
}

.blog-post .content ul,
.blog-post .content ol {
    margin: 0 0 25px 20px;
}

.blog-post .content li {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.blog-post .blog-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

.blog-post .prev-post,
.blog-post .next-post {
    max-width: 45%;
}

.blog-post .nav-label {
    display: block;
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 5px;
}

/* =====================
   ENDNOTES
   In-text: <cite class="en">Note text here.</cite>
   JS replaces each with a superscript number and builds the
   Notes section automatically at the end of .content.
   ===================== */

/* Hide the raw cite tags before JS processes them */
cite.en {
    display: none;
}

/* Superscript reference link in body text */
.en-ref {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
    color: var(--accent);
    text-decoration: none;
    font-style: normal;
    margin-left: 1px;
}

.en-ref:hover {
    text-decoration: underline;
}

/* Notes section heading — same style as content h2 */
.endnotes-section h2 {
    color: var(--accent);
    font-size: 1.8rem;
    margin: 40px 0 20px;
}

/* Endnote list */
.endnotes-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.endnotes-list li {
    display: flex;
    gap: 10px;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.endnotes-list li .en-num {
    flex-shrink: 0;
    color: var(--accent);
    font-weight: 600;
    min-width: 20px;
}

/* Back-link arrow */
.en-back {
    color: #aaa;
    text-decoration: none;
    font-size: 0.85rem;
    margin-left: 4px;
    flex-shrink: 0;
}

.en-back:hover {
    color: var(--accent);
    text-decoration: none;
}

/* =====================
   FOOTER
   ===================== */
footer {
    background-color: #f5f5f5;
    padding: 30px 0;
    text-align: center;
    color: #777;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 960px) {
    .card-grid {
        columns: 2;
    }

    .card-grid.card-grid--rows {
        columns: auto;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .toolbar-filters {
        margin-left: auto;
    }

    header .container {
        flex-direction: column;
        text-align: center;
    }

    header nav ul {
        margin-top: 15px;
    }

    header nav ul li {
        margin: 0 10px;
    }

    .hero .content {
        flex-direction: column-reverse;
    }

    .hero .image-content {
        margin-bottom: 30px;
        width: 100%;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .blog-post .blog-navigation {
        flex-direction: column;
        gap: 20px;
    }

    .blog-post .prev-post,
    .blog-post .next-post {
        max-width: 100%;
    }

    .blog-post h1 {
        font-size: 2rem;
    }
}

@media (max-width: 560px) {
    .card-grid {
        columns: 1;
    }

    .card-grid.card-grid--rows {
        columns: auto;
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 0 10px;
    }

    header nav ul li {
        margin: 0 5px;
    }

    .filter-bar {
        padding: 16px 0;
    }
}
