:root {
    --primary: #2d3436;
    --primary-light: #636e72;
    --accent: #0984e3;
    --pale-blue: #dceefc;
    --background: #f5f6fa;
    --sidebar-bg: #ffffff;
    --text: #2d3436;
    --white: #ffffff;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 280px;
    --sidebar-padding: 2rem;
    --total-sidebar-width: calc(var(--sidebar-width) + (var(--sidebar-padding) * 2));
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.8;
}

h1, h2, h3,
.sidebar h1,
.header h1,
.header h2,
.composition-card h3,
.detail-hero h1,
.detail-eyebrow ~ h1 {
    font-family: 'Cormorant', Georgia, serif;
    letter-spacing: 0;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--text);
    padding: var(--sidebar-padding);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--shadow);
    box-sizing: border-box;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-avatar {
    display: block;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1rem;
    box-shadow: var(--shadow);
    border: 3px solid var(--white);
}

.sidebar h1 {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.site-title-sub {
    display: block;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--primary-light);
    margin-top: 0.35rem;
}

.sidebar-menu {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    margin-bottom: 1rem;
}

.sidebar-menu button,
.sidebar-menu a {
    display: block;
    width: 100%;
    box-sizing: border-box;
    /* padding: 1rem 1.25rem; */
    padding-top: 4px;   
    padding-bottom: 4px;
    padding-left: 1.25rem;
    background-color: transparent;
    color: var(--primary);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 0.5rem;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: var(--transition);
    font-size: .9em;
    line-height: 1.1;
    font-weight: 500;
}

.sidebar-menu i {
    margin-right: 0.45rem;
    vertical-align: -2px;
}

.sidebar-menu button:hover,
.sidebar-menu a:hover {
    background-color: var(--accent);
    color: var(--white);
    transform: translateY(-2px);
    border-color: transparent;
}

.sidebar-menu button.active,
.sidebar-menu a.active {
    background-color: var(--accent);
    color: var(--white);
    border-color: transparent;
}

.sidebar-category-item {
    margin-bottom: 0.7rem;
}

.category-toggle {
    font-weight: 700;
}

.sidebar-submenu {
    list-style: none;
    padding: 0.55rem 0.6rem;
    margin: 0.35rem 0 0 0.55rem;
    display: none;
    background: linear-gradient(135deg, rgba(9, 132, 227, 0.08), rgba(9, 132, 227, 0.02));
    border: 1px solid rgba(9, 132, 227, 0.16);
    border-radius: 0.6rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.sidebar-category-item.open > .sidebar-submenu {
    display: block;
}

.sidebar-submenu li {
    margin-bottom: 0.45rem;
}

.sidebar-submenu button {
    font-size: 0.82rem;
    padding-left: 0.9rem;
    background-color: rgba(255, 255, 255, 0.55);
}

.mobile-filter-selects {
    display: none;
}

.main-content {
    margin-left: calc(var(--sidebar-width) + 1rem);
    padding: 2rem;
    width: calc(100% - var(--total-sidebar-width));
    min-height: 100vh;
    background-color: var(--white);
    position: relative;
    z-index: 20;
}

.header {
    background-color: transparent;
    padding: 2rem;
    margin-bottom: .5rem;
    text-align: center;
    box-shadow: none;
}

.header h1 {
    margin: 0;
    color: var(--primary);
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hero-with-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    text-align: left;
}

.hero-photo {
    flex: 0 0 auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow);
    border: 4px solid var(--white);
}

.hero-text {
    flex: 1 1 auto;
    max-width: 640px;
}

.hero-text h1,
.hero-text h2 {
    text-align: left;
}

.hero-text h2 {
    margin-top: 0.75rem;
}

@media (max-width: 700px) {
    .hero-with-photo {
        flex-direction: column;
        text-align: center;
    }
    .hero-text h1,
    .hero-text h2 {
        text-align: center;
    }
    .hero-photo {
        width: 110px;
        height: 110px;
    }
}

.composition-grid {
    /*display: grid;*/
    display: flex;
    flex-wrap: wrap;
   /* grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));*/
    gap: 1.2rem;
    padding: 0;
    width: 100%
}


/* Ensure at least 3 fixed-width cards fit across a laptop screen and don't stretch if fewer */
.composition-cards-container {
  display: flex;
  flex-wrap: wrap;
  /*justify-content: center;   /* Center cards if fewer than 3 */
  gap: 1rem;                 /* Space between cards */
  padding: 1rem 0;
  justify-content: flex-start; /* Align cards to the left */
}


.composition-card {
    position: relative;
    height: 230px;

    flex: 0 0 calc((100% - 1.2rem) / 2);
    max-width: calc((100% - 1.2rem) / 2);
    box-sizing: border-box;
    border-radius: 0.8rem;
    box-shadow: var(--shadow);
    overflow: visible;
    background-size: cover;
    background-position: center;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.composition-card:hover {
    transform: translateY(-0.5rem) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.card-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.8)
    );
    color: var(--white);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.45rem;
    box-sizing: border-box;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.composition-card:hover .card-content {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.2),
        rgba(0, 0, 0, 0.9)
    );
}

.composition-card h3 {
    margin-top: 0;
    margin-bottom: 0rem;
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.composition-card .card-title-link {
    color: #cfe8ff;
    text-decoration: none;
}

.composition-card .card-title-link:hover {
    color: var(--white);
    text-decoration: underline;
}

.composition-card p {
    margin: 0.2rem 0 0;
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.composition-card .links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
    align-items: center;
}

.composition-card .links a,
.composition-card .links button,
.composition-card .links .audio-toggle-btn {
    text-decoration: none;
    color: var(--primary);
    padding: 0.5rem 0.9rem;
    background-color: var(--pale-blue);
    border-radius: 0.375rem;
    transition: var(--transition);
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
    min-height: 2.1rem;
    box-sizing: border-box;
    line-height: 1;
    border: none;
    cursor: pointer;
}

.composition-card .links a:hover,
.composition-card .links button:hover,
.composition-card .links .audio-toggle-btn:hover {
    background-color: var(--accent);
    color: var(--white);
    transform: translateY(-2px);
}

.composition-card .links i,
.detail-link i,
.detail-nav-btn i {
    font-size: 1.05em;
    line-height: 1;
}

/* Details is the primary action on each card — give it a filled,
   higher-contrast treatment so it reads as the main click target,
   with Score/Audio/Video as clearly secondary icon buttons. */
.composition-card .links .details-link {
    background-color: var(--accent);
    color: var(--white);
    font-weight: 600;
}

.composition-card .links .details-link:hover {
    background-color: var(--primary);
    color: var(--white);
}

.composition-card .audio-player {
  width: 110px;      /* Similar to button width */
  height: 32px;      /* Typical button height */
  min-width: 80px;
  margin: 0 4px 0 0;
  vertical-align: middle;
  display: inline-block;
}

.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

.page-content {
    background-color: var(--white);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 2rem;
    /*max-width: 800px; */
    margin: 0 auto;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 560px;
    margin-top: 1.25rem;
}

.contact-form label {
    font-weight: 600;
    color: var(--primary);
}

.contact-form input,
.contact-form textarea {
    padding: 0.8rem 0.95rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 0.6rem;
    font: inherit;
    background-color: var(--background);
}

.contact-form textarea {
    resize: vertical;
    min-height: 120px;
}

.contact-form button {
    align-self: flex-start;
    border: none;
    border-radius: 0.6rem;
    padding: 0.8rem 1.1rem;
    background-color: var(--accent);
    color: var(--white);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.contact-form button:hover {
    background-color: var(--primary);
    transform: translateY(-2px);
}

.form-status {
    margin: 0;
    font-size: 0.95rem;
    color: var(--primary-light);
}

.bio-image, .contact-image {
    width: 100%;
    height: auto;
    margin-top: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

#contact-section .page-content a[href*="imslp.org"],
#contact-section .page-content a[href*="bergmann-edition"],
#contact-section .page-content a[href*="sheetmusicplus"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 220px;
    max-width: 100%;
    min-height: 56px;
    margin: 0 0 1rem 0;
}

#contact-section .page-content a[href*="imslp.org"] img,
#contact-section .page-content a[href*="bergmann-edition"] img,
#contact-section .page-content a[href*="sheetmusicplus"] img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 56px;
    object-fit: contain;
}

/* Audio modal styles */
#audio-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  overflow: auto;
  background: rgba(0,0,0,0.4);
}
#audio-modal .audio-modal-content {
  background: var(--white);
  margin: 10% auto;
  padding: 1.5rem 2rem;
  border-radius: 1rem;
  width: 320px;
  box-shadow: var(--shadow);
  position: relative;
  text-align: center;
}
#audio-modal .audio-modal-close {
  color: var(--primary-light);
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}
#audio-modal .audio-modal-close:hover {
  color: var(--accent);
}

.audio-toggle-btn {
  background-color: var(--pale-blue);
  color: var(--primary);
  border: none;
  border-radius: 0.375rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin: 0;
  outline: none;
  display: inline-block;
}
.audio-toggle-btn + a,
.audio-toggle-btn + button {
  margin-left: 0.5rem;
}
.audio-toggle-btn:hover,
.audio-toggle-btn:focus {
  background-color: var(--accent);
  color: var(--white);
}
.audio-toggle-btn.audio-toggle-btn-active {
  background-color: var(--accent);
  color: var(--white);
}

/* Playing popup styles */
#audio-playing-popup {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: var(--white);
  padding: 0.7rem 1.5rem;
  border-radius: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  z-index: 2000;
  display: none;
  pointer-events: none;
  opacity: 0.95;
  overflow: hidden;
  min-width: 220px;
}
#audio-playing-popup .ticker {
  display: inline-block;
  white-space: nowrap;
  animation: ticker-move 8s linear infinite;
}
@keyframes ticker-move {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --total-sidebar-width: 100%;
    }
    
    body {
        flex-direction: column;
    }
    
    .sidebar {
        height: auto;
        position: relative;
        padding: 1rem;
        z-index: 10;  /* Keep consistent z-index */
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
        z-index: 20;  /* Keep consistent z-index */
    }
    
    .composition-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar-menu button:hover {
        transform: none;
    }

    /* Mobile improvements: make cards full-width, stack controls, and reduce spacing */
    .composition-card {
        flex: 1 1 100%;
        max-width: 100%;
        height: auto;
        min-height: 160px;
        margin-bottom: 0.75rem;
        border-radius: 0.75rem;
    }

    .card-content {
        padding: 0.9rem;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .header h2 {
        font-size: 1rem;
    }

    .composition-card h3 {
        font-size: 1.05rem;
    }

    .composition-card p {
        font-size: 0.85rem;
    }

    /* Tile link buttons across the card: auto width, wrap when needed */
    .composition-card .links {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-top: 0.5rem;
        align-items: center;
        justify-content: flex-start;
    }

    .composition-card .links a,
    .composition-card .links button,
    .composition-card .links .audio-toggle-btn {
        display: inline-flex;
        flex: 0 0 auto; /* size to content */
        white-space: nowrap;
        box-sizing: border-box;
        text-align: center;
        padding: 0.35rem 0.5rem;
        font-size: 0.82rem;
    }

    /* Make audio popup shorter on phones */
    #audio-playing-popup {
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        min-width: 180px;
        font-size: 0.95rem;
        padding: 0.5rem 1rem;
    }

    /* Sidebar: compact stacked bar for mobile. Row layout doesn't hold up
       once dropdown filters are involved, so use a column instead. */
    .sidebar {
        position: relative;
        height: auto;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        padding: 0.75rem 1rem;
        border-right: none;
        box-shadow: none;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .sidebar h1 {
        font-size: 1.1rem;
        padding-bottom: 0.5rem;
        margin-bottom: 0;
        border-bottom: none;
    }

    /* Nested expand/collapse category menu doesn't work well on small
       screens (the open submenu overlaps surrounding content) — hide it
       and use the native <select> dropdowns instead. */
    #category-menu {
        display: none;
    }

    .mobile-filter-selects {
        display: flex;
        gap: 0.5rem;
    }

    .mobile-filter-selects select {
        flex: 1 1 50%;
        min-width: 0;
        padding: 0.5rem 0.6rem;
        border-radius: 0.5rem;
        border: 1px solid rgba(0, 0, 0, 0.12);
        background-color: var(--white);
        color: var(--primary);
        font-size: 0.85rem;
    }

    .sidebar hr {
        margin: 0;
        border: none;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .sidebar-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        align-items: center;
    }

    .sidebar-menu button {
        padding-top: 4px;
        padding-bottom: 4px;
        padding-left: 0.6rem;
        padding-right: 0.6rem;
        font-size: 0.78rem;
    }
}