/* ========================================
   Praxis San Diego - Main Stylesheet
   ======================================== */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Mono', monospace;
    background-color: #f8fafb;
    color: #333;
    line-height: 1.6;
    padding: 2rem 0;
    position: relative;
    overflow-x: hidden;
    transition: padding-right 0.3s ease;
}

/* Canvas Background */
#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Animation Toggle Button */
#animationToggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #000;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    z-index: 1002; /* Above menu panel */
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#animationToggle:hover {
    background-color: #333;
}

#animationToggle.paused {
    background-color: #666;
}

/* Container */
.container {
    max-width: 950px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    background-color: #f8fafb;
    z-index: 1;
    /* Smooth transition when menu opens/closes */
    transition: max-width 0.3s ease, margin 0.3s ease;
}

/* Header */
header {
    margin-bottom: 3rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    font-size: 2.5rem;
    letter-spacing: 0.1rem;
    font-weight: 700;
}

h2 {
    font-size: 1.8rem;
    margin: 2rem 0 1rem 0;
    font-weight: 700;
}

h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.8rem 0;
    font-weight: 700;
}

/* Links */
a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.back-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 700;
}

.back-link:hover {
    text-decoration: underline;
}

/* Description Section */
.description {
    margin-bottom: 2rem;
}

/* Paragraph Spacing (replaces <br><br>) */
.description p,
.custom-content p,
.section p {
    margin-bottom: 1rem;
}

.description p:last-child,
.custom-content p:last-child,
.section p:last-child {
    margin-bottom: 0;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 300px;
}

.search-box input {
    width: 100%;
    font-family: 'Space Mono', monospace;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Table Styles */
.table-wrapper {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

th {
    background-color: #f5f5f5;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    vertical-align: top;
}

th:hover {
    background-color: #ebebeb;
}

th::after {
    content: ' ↕';
    opacity: 0.3;
    font-size: 0.8em;
}

th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

/* Sub-sort headers (for Days, Times, Dates columns) */
th.has-sub-sort {
    cursor: default;
}

th.has-sub-sort::after {
    content: none;
}

th.has-sub-sort:hover {
    background-color: #f5f5f5;
}

.sub-sort-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sub-sort {
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    display: inline-block;
    transition: background-color 0.2s ease;
}

.sub-sort:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.sub-sort::after {
    content: ' ↕';
    opacity: 0.3;
    font-size: 0.8em;
}

.sub-sort.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

.sub-sort.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

tr:hover {
    background-color: #f9f9f9;
}

td a {
    color: #2563eb;
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

.class-name {
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.class-description {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* Stats */
.stats {
    margin-top: 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* Table Column Widths - Default (4 column tables like university.html) */
.table-4col th:nth-child(1), .table-4col td:nth-child(1) { width: 33%; }
.table-4col th:nth-child(2), .table-4col td:nth-child(2) { width: 20%; }
.table-4col th:nth-child(3), .table-4col td:nth-child(3) { width: 28%; }
.table-4col th:nth-child(4), .table-4col td:nth-child(4) { width: 19%; }

/* Table Column Widths - Index page (4 column simplified) */
.table-index th:nth-child(1), .table-index td:nth-child(1) { width: 44%; }
.table-index th:nth-child(2), .table-index td:nth-child(2) { width: 20%; }
.table-index th:nth-child(3), .table-index td:nth-child(3) { width: 16%; }
.table-index th:nth-child(4), .table-index td:nth-child(4) { width: 20%; }

/* Class Info Box (for individual class pages) */
.class-info-box {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem 1.5rem 0.5rem 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.info-grid {
    display: grid;
    gap: 1rem;
}

.info-item-vertical {
    display: flex;
    flex-direction: column;
}

.info-label-vertical {
    font-weight: 700;
    color: #666;
    margin-bottom: 0.3rem;
}

.info-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
}

.info-label {
    font-weight: 700;
    color: #666;
    flex-shrink: 0;
    min-width: 100px;
    text-align: right;
}

.info-value {
    color: #333;
}

/* Description Section */
.description-section {
    margin: 2rem 0;
}

/* Custom Content (class pages) */
.custom-content {
    margin: 3rem 0;
}

.custom-content p {
    margin-bottom: 1rem;
}

.custom-content ul, .custom-content ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.custom-content li {
    margin-bottom: 0.5rem;
}

/* Application Section */
.application-section {
    margin-top: 2rem;
    padding-top: 0.5rem;
    border-top: 2px solid #ddd;
}

/* Form Embed */
.form-embed {
    margin-top: 1.5rem;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    min-height: 500px;
}

.loading-message {
    text-align: center;
    color: #666;
    padding: 2rem;
}

/* Email obfuscation */
div.email > span:nth-child(2) {
    display: none;
}

/* Diamond Bulletpoint List */
ul li::marker {
  content: "❖ ";
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.announcement-big {
    color: red;
    font-size: 125%;
}

.announcement {
    color: red;
}

/* Image Floats (for class pages with instructor photos) */
.image-left {
    float: left;
    margin: 0 20px 0px 0;
}

.image-right {
    float: right;
    margin: 0px 0 0px 20px;
}

/* Container image sizing */
.container img {
    width: 250px;
    height: 250px;
    object-fit: cover;
}

/* Clear float after container */
.container::after {
    content: "";
    display: table;
    clear: both;
}

/* Section spacing */
.section {
    margin-bottom: 2rem;
}

/* Responsive Styles */
@media (max-width: 1000px) {
    .container {
        padding: 0 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .table-wrapper {
        overflow-x: auto;
    }
}

/* Table min-width only for tablet screens (between 769px and 1000px) */
@media (min-width: 769px) and (max-width: 1000px) {
    table {
        min-width: 600px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.4rem;
    }
}

/* Class page specific - smaller header margin */
.class-page header {
    margin-bottom: 1rem;
}

.class-page h1 {
    margin-bottom: 0.5rem;
}

/* ========================================
   Navigation Menu Styles (Push-style)
   ======================================== */

/* CSS Custom Property for menu width */
:root {
    --menu-width: 320px;
}

/* Menu Toggle Button (Hamburger) */
.menu-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 10px;
    transition: background-color 0.3s ease, border-color 0.3s ease, right 0.3s ease;
}

.menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.4);
}

.menu-toggle.active {
    background-color: rgba(255, 255, 255, 0.95);
    /* Button stays in place - no position change */
}

.menu-line {
    width: 20px;
    height: 2px;
    background-color: #333;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.menu-toggle.active .menu-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .menu-line:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .menu-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Menu Overlay - invisible for push-style menu, but still captures clicks */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Menu Panel - slides in from off-screen right */
.menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--menu-width);
    max-width: 85vw;
    height: 100%;
    background-color: rgba(248, 250, 251, 0.35);
    backdrop-filter: blur(5px);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.menu-panel.active {
    transform: translateX(0);
}

.menu-content {
    padding: 80px 20px 40px 20px;
}

/* Menu List - no bullets */
.menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Override diamond bullet for menu items */
.menu-list li::marker {
    content: none;
}

.menu-item {
    margin-bottom: 0.5rem;
}

.menu-item > a,
.menu-item-header > a {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.menu-item > a:hover,
.menu-item-header > a:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #2563eb;
    text-decoration: none;
}

/* Menu Item with Submenu */
.menu-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-item-header > a {
    flex: 1;
}

.submenu-toggle {
    background: none;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submenu-arrow {
    font-size: 1.2rem;
    color: #666;
    transition: transform 0.3s ease;
    display: inline-block;
}

.submenu-arrow.rotated {
    transform: rotate(90deg);
}

/* Submenu - no bullets */
.submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

/* Override diamond bullet for submenu items */
.submenu li::marker {
    content: none;
}

.submenu.expanded {
    max-height: 1000px;
    opacity: 1;
}

.submenu-item {
    margin: 0;
}

.submenu-item a {
    display: block;
    padding: 10px 16px 10px 32px;
    color: #555;
    text-decoration: none;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    line-height: 1.4;
}

.submenu-item a:hover {
    background-color: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    text-decoration: none;
}

.submenu-item.empty,
.submenu-item.error,
.submenu-loading {
    padding: 10px 16px 10px 32px;
    color: #999;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    font-style: italic;
}

.submenu-item.error {
    color: #c53030;
}

.term-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 6px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    margin-left: 6px;
    color: #666;
}

/* Body and container state when menu is open */
body.menu-open {
    overflow-x: hidden;
    /* Push all content left by adding padding on right - menu occupies this space */
    padding-right: var(--menu-width);
}

/* Container constraints when menu is open */
/* Ensures container doesn't visually extend under the menu */
body.menu-open .container {
    /* Container stays within the available space (viewport - menu) */
    max-width: min(950px, calc(100vw - var(--menu-width) - 4rem));
    /* Re-center in the available space - margin auto handles this naturally */
    /* but we ensure the right edge doesn't extend past where menu begins */
    /* margin-right: 0; */
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */

/* Hide mobile-only elements on desktop */
.mobile-class-nav {
    display: none;
}

@media (max-width: 768px) {
    /* ----- make the menu less transparent on mobile ----- */
    .menu-panel {
        background-color: rgba(248, 250, 251, 0.9);
    }

    /* ----- Issue 1: Hide animation toggle on mobile ----- */
    #animationToggle {
        display: none;
    }

    /* ----- Mobile class filter (multi-select) ----- */
    .mobile-class-nav {
        display: block;
        margin-bottom: 1rem;
        background-color: #fff;
        border: 1px solid #ddd;
        border-radius: 4px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        overflow: hidden;
    }

    .mobile-filter-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        cursor: pointer;
    }

    .mobile-filter-label {
        font-weight: 700;
        font-size: 0.9rem;
        color: #333;
    }

    .mobile-filter-toggle {
        font-family: 'Space Mono', monospace;
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        background-color: #f5f5f5;
        color: #333;
        cursor: pointer;
        transition: background-color 0.2s ease;
    }

    .mobile-filter-toggle:hover {
        background-color: #e8e8e8;
    }

    .mobile-filter-list {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        border-top: 1px solid #ddd;
    }

    .mobile-filter-list.expanded {
        max-height: 400px;
        overflow-y: auto;
    }

    .mobile-filter-actions {
        display: flex;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #eee;
        background-color: #fafafa;
    }

    .mobile-filter-action-btn {
        font-family: 'Space Mono', monospace;
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        background-color: #fff;
        color: #2563eb;
        cursor: pointer;
        transition: background-color 0.2s ease;
    }

    .mobile-filter-action-btn:hover {
        background-color: rgba(37, 99, 235, 0.1);
    }

    .mobile-filter-checkboxes {
        padding: 0.5rem 0;
    }

    .mobile-filter-item {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.6rem 1rem;
        cursor: pointer;
        transition: background-color 0.2s ease;
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .mobile-filter-item:hover {
        background-color: #f5f5f5;
    }

    .mobile-filter-item input[type="checkbox"] {
        width: 18px;
        height: 18px;
        margin-top: 2px;
        flex-shrink: 0;
        cursor: pointer;
        accent-color: #2563eb;
    }

    .mobile-filter-item span {
        flex: 1;
    }

    /* ----- Issue 5: Menu overlay instead of push on mobile ----- */
    :root {
        --menu-width: 280px;
    }

    .menu-content {
        padding: 70px 15px 30px 15px;
    }

    .menu-item > a,
    .menu-item-header > a {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .submenu-item a {
        padding: 8px 12px 8px 24px;
        font-size: 0.8rem;
    }

    /* Override push behavior - use overlay instead */
    body.menu-open {
        padding-right: 0;
        overflow: hidden; /* Prevent scrolling when menu is open */
    }

    body.menu-open .container {
        max-width: none;
    }

    /* Add semi-transparent backdrop on mobile */
    .menu-overlay.active {
        background-color: rgba(0, 0, 0, 0.3);
    }

    /* ----- Issue 4: Fix text overflow in class-info-box ----- */
    .info-value {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .info-label {
        text-align: left;
        min-width: unset;
    }

    /* ----- Issue 2 & 3: Card layout for tables ----- */
    /* Remove the min-width that forces horizontal scroll */
    table {
        min-width: unset;
    }

    .table-wrapper {
        overflow-x: visible;
        background-color: transparent;
        border: none;
        box-shadow: none;
    }

    /* Hide table headers on mobile */
    .table-4col thead,
    .table-index thead {
        display: none;
    }

    /* Transform table rows into cards */
    .table-4col tbody,
    .table-index tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .table-4col tbody tr,
    .table-index tbody tr {
        display: flex;
        flex-direction: column;
        background-color: #fff;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .table-4col tbody tr:hover,
    .table-index tbody tr:hover {
        background-color: #fff;
    }

    .table-4col tbody td,
    .table-index tbody td {
        display: block;
        padding: 0.5rem 0;
        border-bottom: none;
        width: 100% !important;
    }

    /* Add labels before each cell */
    .table-4col tbody td::before,
    .table-index tbody td::before {
        display: block;
        font-weight: 700;
        color: #666;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    /* Labels for university.html and archive.html (table-4col) */
    .table-4col tbody td:nth-child(1)::before {
        content: ""; /* Class name already has styling */
    }

    .table-4col tbody td:nth-child(2)::before {
        content: "Instructor";
    }

    .table-4col tbody td:nth-child(3)::before {
        content: "When";
    }

    .table-4col tbody td:nth-child(4)::before {
        content: "Location";
    }

    /* For archive page, 4th column is "Term" */
    #archiveTable tbody td:nth-child(4)::before {
        content: "Term";
    }

    /* Labels for index.html (table-index) */
    .table-index tbody td:nth-child(1)::before {
        content: ""; /* Class name */
    }

    .table-index tbody td:nth-child(2)::before {
        content: "Start Date";
    }

    .table-index tbody td:nth-child(3)::before {
        content: "Duration";
    }

    .table-index tbody td:nth-child(4)::before {
        content: ""; /* "Learn more" link doesn't need label */
    }

    /* Style the class name prominently */
    .table-4col tbody td:first-child,
    .table-index tbody td:first-child {
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #eee;
        margin-bottom: 0.5rem;
    }

    /* ----- Schedule table styles for Erudite pages ----- */
    .schedule-table {
        display: block;
    }

    .schedule-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .schedule-table tr {
        display: flex;
        flex-direction: column;
        background-color: #f9f9f9;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 1rem;
    }

    .schedule-table td {
        display: block;
        padding: 0.25rem 0;
        white-space: normal !important;
    }

    /* First cell (Week or Meeting info) as header */
    .schedule-table td:first-child {
        font-size: 0.9rem;
        font-weight: bold;
        color: #333;
    }

    /* For 3-column tables: Week + Meeting displayed together */
    /* Second cell when there are 3 columns - show inline with first */
    .schedule-table tr td:nth-child(2):not(:last-child) {
        font-weight: bold;
        color: #666;
        font-size: 0.9rem;
        border-bottom: 1px solid #ddd;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
    }

    /* For 2-column tables: first cell gets the border */
    .schedule-table tr td:first-child:nth-last-child(2) {
        border-bottom: 1px solid #ddd;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
    }

    /* Content cell (always last) */
    .schedule-table td:last-child {
        padding-top: 0.5rem;
    }

    .schedule-table td:last-child ul {
        margin-left: 1.5rem;
        margin-top: 0.5rem;
    }

    /* ----- Mobile Class Picker Dropdown ----- */
    .mobile-class-picker {
        display: block;
        margin-bottom: 1rem;
    }

    .mobile-class-picker label {
        display: block;
        font-weight: 700;
        margin-bottom: 0.5rem;
        color: #333;
    }

    .mobile-class-picker select {
        width: 100%;
        padding: 0.75rem;
        font-family: 'Space Mono', monospace;
        font-size: 0.9rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        background-color: #fff;
        cursor: pointer;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.75rem center;
        padding-right: 2.5rem;
    }

    .mobile-class-picker select:focus {
        outline: none;
        border-color: #2563eb;
        box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
    }
}

/* Hide mobile class picker on desktop */
.mobile-class-picker {
    display: none;
}
