/* Theme variables – rely on global ones, but define fallbacks */
:root {
    --bg: #000000;
    --text: #00ff41;
    --text-alt: #008f11;
    --glow: rgba(0, 255, 65, 0.5);
    --scanline: rgba(18, 16, 16, 0.1);
}

[data-theme="light"] {
    --bg: #f5f5dc;
    --text: #1a4d2e;
    --text-alt: #2d5a27;
    --glow: rgba(26, 77, 46, 0.3);
    --scanline: rgba(0, 0, 0, 0.05);
}

/* ------------------------------------------------------------------
   Timeline container
   ------------------------------------------------------------------ */
.timeline-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 0;
    background: transparent; /* no border/glow */
}

/* ------------------------------------------------------------------
   Timeline SVG paths
   ------------------------------------------------------------------ */
.path-base {
    fill: none;
    stroke: var(--text-alt);
    stroke-width: 2;
    opacity: 0.4;
}

.path-glow {
    fill: none;
    stroke: var(--text);
    stroke-width: 4;
    filter: drop-shadow(0 0 8px var(--text));
    stroke-dasharray: 60 2000; /* will be overridden by JS */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
    opacity: 0.8;
}

.connector-line {
    stroke: var(--text-alt);
    stroke-width: 2;
    opacity: 0.5;
}

circle {
    fill: var(--bg);
    stroke: var(--text);
    stroke-width: 2;
}

/* ------------------------------------------------------------------
   Label styles
   ------------------------------------------------------------------ */
.edu-label {
    fill: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: fill 0.2s, filter 0.2s;
}

.edu-label:hover {
    fill: #ff3333 !important;
    filter: drop-shadow(0 0 8px #ff3333);
}

/* ------------------------------------------------------------------
   Modal (identical to Projects page)
   ------------------------------------------------------------------ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(10px) brightness(0.6);
    background: rgba(0, 0, 0, 0.3);
    z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal-overlay.flex   { display: flex; align-items: center; justify-content: center; }

.modal-box {
    position: relative;
    max-width: 650px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--text);
    box-shadow: var(--text), 0 0 15px var(--text);
    padding: 2rem;
    box-sizing: border-box;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    background: #ff3333;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 1rem;
    z-index: 10;
    line-height: 1;
    padding: 0;
}
.modal-close-btn:hover {
    filter: brightness(1.2);
}

/* Glowing text inside modal */
.glow-text {
    color: #ff6b6b;
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.4);
}
html[data-theme="light"] .glow-text {
    color: #b30000;
    text-shadow: 0 0 5px rgba(179, 0, 0, 0.3);
}

/* Modal links (red on hover) */
.modal-link:hover {
    color: #ff3333 !important;
}

/* ------------------------------------------------------------------
   Scrollbar styling – matches global theme
   ------------------------------------------------------------------ */
/* Global scrollbar (body) */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
    border-left: 1px solid var(--text-alt);
}
::-webkit-scrollbar-thumb {
    background: var(--text);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-alt);
}

/* Modal scrollbar (same style) */
.modal-box::-webkit-scrollbar {
    width: 8px;
}
.modal-box::-webkit-scrollbar-track {
    background: var(--bg);
    border-left: 1px solid var(--text-alt);
}
.modal-box::-webkit-scrollbar-thumb {
    background: var(--text);
}
.modal-box::-webkit-scrollbar-thumb:hover {
    background: var(--text-alt);
}

/* ------------------------------------------------------------------
   Refined education archive
   ------------------------------------------------------------------ */
.top-nav-bar {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    min-height: 56px;
    gap: 0.5rem;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--text) 35%, transparent);
    backdrop-filter: blur(12px);
}

.top-nav-bar > .theme-toggle:first-child {
    grid-column: 1;
}

.top-nav-bar .header-title-slot {
    grid-column: 2;
    min-width: 0;
}

.top-nav-bar > .theme-toggle:last-child {
    grid-column: 3;
}

.top-nav-bar .header-title {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.education-main {
    min-height: 100vh;
    padding: 2.5rem 1.25rem 5rem;
}

.education-shell {
    width: min(1120px, 100%);
    margin: 0 auto;
}

.education-hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
    align-items: center;
    min-height: 290px;
    padding: clamp(1.4rem, 4vw, 3rem);
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--text) 50%, transparent);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--text) 8%, transparent), transparent 58%),
        radial-gradient(circle at 90% 20%, color-mix(in srgb, var(--text) 14%, transparent), transparent 42%),
        var(--bg);
    box-shadow: 0 0 30px var(--glow), inset 0 0 25px color-mix(in srgb, var(--text) 5%, transparent);
}

.education-hero::before,
.education-hero::after {
    position: absolute;
    width: 28px;
    height: 28px;
    content: "";
    pointer-events: none;
}

.education-hero::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid var(--text);
    border-left: 2px solid var(--text);
}

.education-hero::after {
    right: -1px;
    bottom: -1px;
    border-right: 2px solid var(--text);
    border-bottom: 2px solid var(--text);
}

.education-hero-copy {
    position: relative;
    z-index: 1;
}

.education-kicker,
.education-commandbar,
.education-card-type,
.education-card-date,
.education-card-status,
.education-card-action,
.education-stats {
    color: var(--text-alt);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.education-kicker {
    margin: 0 0 0.8rem;
    color: var(--text);
}

.education-hero h2 {
    margin: 0;
    color: var(--text);
    font-family: "Courier Prime", "Courier New", monospace;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.07em;
    line-height: 0.95;
    text-shadow: 0 0 18px var(--glow);
}

.education-lede {
    max-width: 58ch;
    margin: 1.25rem 0 0;
    color: color-mix(in srgb, var(--text) 72%, var(--bg));
    font-size: 0.84rem;
    line-height: 1.8;
}

.education-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-top: 1.5rem;
}

.education-stats strong {
    display: block;
    color: var(--text);
    font-size: 1.15rem;
    letter-spacing: 0;
}

.education-ascii-art {
    justify-self: end;
    width: 100%;
    max-width: 480px;
    margin: 0;
    overflow: hidden;
    color: var(--text);
    font-family: "JetBrains Mono", "Courier New", monospace;
    font-size: clamp(10px, 0.52vw, 6px);
    line-height: 0.95;
    opacity: 0.72;
    text-align: center;
    text-shadow: 0 0 7px var(--glow);
    white-space: pre;
    user-select: none;
}

.education-commandbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0 0.75rem;
    border-bottom: 1px dashed color-mix(in srgb, var(--text) 35%, transparent);
}

.education-commandbar .terminal-status-dot {
    width: 7px;
    height: 7px;
    margin-right: 0.35rem;
}

.education-records {
    margin-top: 1.5rem;
}

.education-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.education-section-heading .education-kicker {
    margin: 0;
}

.education-section-heading h3 {
    margin: 0;
    color: var(--text);
    font-family: "Courier Prime", "Courier New", monospace;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    letter-spacing: -0.04em;
    text-transform: uppercase;
}

.education-list {
    position: relative;
    display: grid;
    gap: 1rem;
}

.education-list::before {
    position: absolute;
    top: 2.2rem;
    bottom: 2.2rem;
    left: 1.65rem;
    width: 1px;
    background: linear-gradient(var(--text), color-mix(in srgb, var(--text) 15%, transparent));
    content: "";
    opacity: 0.55;
}

.education-card {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 3.3rem minmax(0, 1fr);
    min-height: 170px;
    border: 1px solid color-mix(in srgb, var(--text) 38%, transparent);
    background: linear-gradient(135deg, color-mix(in srgb, var(--text) 7%, transparent), var(--bg));
    cursor: pointer;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s, background 0.25s;
}

.education-card:hover,
.education-card:focus-visible {
    border-color: var(--text);
    background: linear-gradient(135deg, color-mix(in srgb, var(--text) 14%, transparent), var(--bg));
    box-shadow: 0 0 22px color-mix(in srgb, var(--text) 25%, transparent);
    transform: translateX(4px);
}

.education-card:focus-visible {
    outline: 1px solid var(--text);
    outline-offset: 3px;
}

.education-card-marker {
    display: grid;
    width: 2.1rem;
    height: 2.1rem;
    margin: 1.25rem 0 0 0.6rem;
    place-items: center;
    border: 1px solid var(--text);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    font-size: 0.65rem;
    box-shadow: 0 0 12px var(--glow);
}

.education-card-main {
    min-width: 0;
    padding: 1.15rem 1.25rem 1.15rem 0;
}

.education-card-top,
.education-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.education-card-type,
.education-card-date,
.education-card-status,
.education-card-action {
    font-size: 0.58rem;
}

.education-card h4 {
    margin: 0.85rem 0 0;
    color: var(--text);
    font-family: "Courier Prime", "Courier New", monospace;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    line-height: 1.08;
    text-transform: uppercase;
}

.education-preview {
    display: -webkit-box;
    margin: 0.8rem 0 1.1rem;
    overflow: hidden;
    color: color-mix(in srgb, var(--text) 70%, var(--bg));
    font-size: 0.76rem;
    line-height: 1.7;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.education-card-bottom {
    border-top: 1px dashed color-mix(in srgb, var(--text) 25%, transparent);
    padding-top: 0.7rem;
}

.education-card-action {
    color: var(--text);
    white-space: nowrap;
}

.modal-overlay {
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.7rem, 4vw, 3rem);
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.72);
}

.modal-overlay.hidden {
    display: none;
}

html[data-theme="light"] .modal-overlay {
    background: rgba(245, 245, 220, 0.72);
}

.modal-box {
    width: min(820px, 100%);
    max-width: none;
    max-height: min(88vh, 900px);
    margin: auto;
    overflow-y: auto;
    background: var(--bg);
    border-color: color-mix(in srgb, var(--text) 55%, transparent);
    box-shadow: 0 0 40px color-mix(in srgb, var(--text) 22%, transparent);
}

.modal-heading {
    position: sticky;
    top: 0;
    z-index: 2;
    min-height: 52px;
    padding-left: 3.5rem !important;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(10px);
}

.modal-box > .p-6 {
    color: var(--text);
}

.modal-close-btn {
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.modal-close-btn:hover,
.modal-close-btn:focus-visible {
    background: #ff5555;
    box-shadow: 0 0 12px rgba(255, 51, 51, 0.65);
    outline: none;
    transform: scale(1.05);
}

.modal-edu-img {
    max-width: min(100%, 440px);
    max-height: 220px;
    margin: 0 auto;
    border-color: color-mix(in srgb, var(--text) 45%, transparent);
    box-shadow: 0 0 18px var(--glow);
}

body.education-modal-open .top-nav-bar {
    visibility: visible;
}

@media (max-width: 768px) {
    html,
    body {
        min-height: 100%;
        overflow-y: auto !important;
        height: auto !important;
    }

    html {
        overflow-x: clip !important;
    }

    body {
        overflow: visible !important;
    }

    .top-nav-bar {
        position: sticky !important;
        top: 0;
        grid-template-columns: 40px minmax(0, 1fr) 40px;
        padding: 0.75rem 1rem;
    }

    .top-nav-bar .header-title {
        font-size: 0.75rem !important;
        letter-spacing: 0.05em;
    }

    .education-main {
        padding: 2rem 0.8rem 3rem;
    }

    .education-hero {
        display: block;
        min-height: 0;
        padding: 1.25rem;
    }

    .education-hero h2 {
        font-size: clamp(1.8rem, 10vw, 2.7rem);
    }

    .education-lede {
        font-size: 0.76rem;
    }

    .education-ascii-art {
        max-width: 100%;
        margin-top: 1.5rem;
        font-size: 3px;
        opacity: 0.5;
    }

    .education-commandbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
        font-size: 0.58rem;
    }

    .education-section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.4rem;
    }

    .education-list::before {
        left: 1.15rem;
    }

    .education-card {
        grid-template-columns: 2.4rem minmax(0, 1fr);
    }

    .education-card-marker {
        width: 1.8rem;
        height: 1.8rem;
        margin-left: 0.25rem;
        font-size: 0.58rem;
    }

    .education-card-main {
        padding: 1rem 0.8rem 1rem 0;
    }

    .education-card-top,
    .education-card-bottom {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }

    .education-card h4 {
        margin-top: 0.65rem;
        font-size: 1.05rem;
    }

    .education-preview {
        margin: 0.6rem 0 0.8rem;
        font-size: 0.68rem;
    }

    .modal-overlay {
        padding: 0.6rem;
    }

    .modal-box {
        max-height: 94vh;
        padding: 1rem;
    }

    .modal-heading {
        margin: -1rem -1rem 0;
        padding-left: 3rem !important;
    }

    .modal-box > .p-6 {
        padding: 1rem;
    }

    body.education-modal-open .top-nav-bar {
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .education-card,
    .modal-close-btn {
        transition: none;
    }
}

/* ------------------------------------------------------------------
   Override Tailwind color utilities with CSS variables for theme sync
   ------------------------------------------------------------------ */
.bg-background,
.bg-surface-container,
.bg-surface-variant {
    background-color: var(--bg) !important;
}
.text-on-background,
.text-primary,
.text-primary-container,
.text-on-primary-container,
.text-outline-variant,
.text-on-surface,
.text-on-surface-variant {
    color: var(--text) !important;
}
.border-outline-variant,
.border-primary,
.border-primary-container,
.border {
    border-color: var(--text) !important;
}

.edu-logo {
    filter: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    will-change: opacity;
}

.edu-logo.visible {
    opacity: 1;
    transition: opacity 0.75s ease;
}

/* Institution logo inside education modal */
.modal-edu-img {
    max-width: 100%;
    max-height: 160px;
    width: auto;
    height: auto;
    margin: 0 auto;
    display: block;
    object-fit: contain;
    border: 1px solid var(--text);
    padding: 0.25rem;
    background: var(--bg);
    box-shadow: 0 0 12px var(--glow);
}
