/* Exact styles adapted from https://parsiad.ca/assets/main.css */

:root {
    --bg: #fff;
    --code-bg: #eff1f5;
    --fg: #1a1a1a;
    --hover: #1a4a7a;
    --link: #2b6cb0;
    --maxw: 42rem;
    --muted: #666;
    --rule: #ddd;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 18px;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: "EB Garamond", serif;
    line-height: 1.6;
    margin: 0;
    padding: 1.5rem 1rem 1rem;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100%;
}

h1,
h2,
h3 {
    font-weight: normal;
    line-height: 1.25;
    margin: 2rem 0 0.75rem;
}

h1 {
    font-size: 2.2rem;
}

h2 {
    border-bottom: 1px solid var(--rule);
    font-size: 1.4rem;
    padding-bottom: 0.25rem;
}

h3 {
    font-size: 1.15rem;
}

p,
ul,
ol,
table,
form {
    margin: 1rem 0;
}

time:not(table time) {
    color: var(--muted);
}

/* Links with parsiad.ca smooth underline gradient transition */
#content a,
footer a {
    color: var(--link);
    background-image: linear-gradient(var(--link), var(--link));
    background-size: 0 2px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    text-decoration: none;
    transition:
        background-size 0.25s ease,
        color 0.25s ease;
}

#content a:hover,
footer a:hover {
    color: var(--hover);
    background-size: 100% 2px;
}

/* Layout */

body > h1 {
    margin-top: 0;
}

body > h1,
nav,
#content,
footer {
    margin-left: auto;
    margin-right: auto;
    max-width: var(--maxw);
}

nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    list-style: none;
    margin: 1rem 0 2rem;
    padding: 0;
}

/* Content */

#content img {
    height: auto;
    max-width: 100%;
}

#avatar {
    border-radius: 50%;
    box-shadow: 0px 0px 0.25em rgba(0, 0, 0, 0.25);
    float: left;
    margin: 0 1.5rem 1rem 0;
    width: 200px;
    height: 200px;
    object-fit: cover;
}

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

th,
td {
    padding: 0.4rem 0.2rem;
    text-align: left;
    vertical-align: top;
}

thead,
tr:not(:last-child) {
    border-bottom: 1px solid var(--rule);
}

td.date {
    white-space: nowrap;
    width: 6.5rem;
    color: var(--muted);
    padding-right: 0.75rem;
}

/* Lists: standard lists */

#content ul {
    margin: 1rem 0;
    padding-left: 1.25rem;
}

#content ul li {
    line-height: 1.6;
    margin: 0.35em 0;
}

#content ul ul {
    margin: 0.25rem 0 0.5rem 0.5rem;
}

/* Arrow symbol - only in paper area */

ul.papers,
#under-review + ul,
#published + ul {
    list-style: none;
    margin: 1rem 0;
    padding: 0;
}

ul.papers li,
#under-review + ul li,
#published + ul li {
    line-height: 1.6;
    margin: 0.5em 0;
    padding-left: 1.5em;
    position: relative;
    transition: color 0.2s;
}

ul.papers li::before,
#under-review + ul li::before,
#published + ul li::before {
    color: var(--muted);
    content: "▹";
    font-size: 1.2em;
    left: 0;
    line-height: 1.2;
    position: absolute;
}

/* Footer */

footer {
    color: var(--muted);
    font-size: 0.75rem;
    padding-top: 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--rule);
    text-align: right;
}

/* Nav */

nav a {
    color: var(--muted);
    text-decoration: none;
}

nav a:hover {
    color: var(--fg);
}

nav a.active {
    text-decoration: underline;
}

/* Code */

#content code {
    font-family: "Source Code Pro", monospace;
    font-size: 0.82rem;
    background: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
    word-break: break-word;
    overflow-wrap: break-word;
}

pre {
    background: #faf3cc;
    border-radius: 4px;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    margin: 1.25rem 0;
}

pre code {
    display: block;
    overflow-x: auto;
    padding: 0.85rem 1rem;
    font-size: 0.82rem;
    line-height: 1.45;
    white-space: pre;
    max-width: 100%;
    box-sizing: border-box;
}

blockquote {
    margin: 1.25rem 0;
    padding: 0;
    color: var(--muted);
    font-style: italic;
}

details {
    margin: 1.25rem 0;
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 0.6rem 0.85rem;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

details summary {
    cursor: pointer;
    color: var(--fg);
    user-select: none;
    font-size: 0.95rem;
}

details summary:hover {
    color: var(--link);
}

details[open] summary {
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 0.4rem;
}

/* Responsive Utilities & Mobile Optimization */

.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0.75rem 0 1rem;
    box-sizing: border-box;
}

.activity-chart {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.25rem 0 1.5rem;
    box-sizing: border-box;
}

@media (max-width: 650px) {
    html {
        font-size: 16.5px;
    }

    body {
        padding: 1.15rem 0.85rem;
        max-width: 100vw;
        overflow-x: hidden;
    }

    body > h1 {
        font-size: 1.85rem;
    }

    #content h1 {
        font-size: 1.65rem;
    }

    h2 {
        font-size: 1.25rem;
        margin-top: 1.75rem;
    }

    /* Navigation */
    nav ul {
        gap: 0.5rem 1rem;
        margin: 0.75rem 0 1.5rem;
    }

    nav a {
        padding: 0.2rem 0;
        font-size: 1.05rem;
    }

    /* Centered Avatar on Mobile */
    #avatar {
        display: block;
        float: none;
        margin: 0.5rem auto 1.5rem;
        width: 150px;
        height: 150px;
    }

    /* Text & container containment */
    #content,
    #content p,
    #content li,
    #content td,
    #content strong {
        overflow-wrap: break-word;
        word-wrap: break-word;
        max-width: 100%;
    }

    /* Stack two-column project and subsystem tables into clean readable blocks on mobile */
    table.responsive-stack {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
    }

    table.responsive-stack thead {
        display: none;
    }

    table.responsive-stack tbody {
        display: block;
        width: 100% !important;
    }

    table.responsive-stack tr {
        display: block;
        width: 100% !important;
        padding: 0.85rem 0;
        border-bottom: 1px solid var(--rule);
        box-sizing: border-box;
    }

    table.responsive-stack td {
        display: block;
        width: 100% !important;
        padding: 0.15rem 0;
        box-sizing: border-box;
    }

    table.responsive-stack td:first-child {
        margin-bottom: 0.35rem;
    }

    /* Compact date columns in updates and education */
    td.date {
        width: 5.25rem !important;
        min-width: 4.8rem;
        font-size: 0.9rem;
        padding-right: 0.5rem;
    }

    /* Blog date column */
    table th[style*="width: 8rem"],
    table td:has(time) {
        width: auto !important;
        white-space: nowrap;
    }

    /* Skills table compact label column */
    td[style*="width: 7rem"] {
        width: 5.25rem !important;
    }

    /* Code blocks strictly contained */
    pre {
        max-width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
    }

    pre code {
        font-size: 0.78rem;
        padding: 0.75rem 0.85rem;
        -webkit-overflow-scrolling: touch;
        white-space: pre;
    }

    /* GitHub activity graph horizontal swipe within isolated container */
    .activity-chart {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }

    .activity-chart img {
        display: block;
        max-width: none;
        width: 580px;
        height: auto;
    }

    /* Multi-column tables inside details */
    .table-scroll {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }

    .table-scroll table {
        min-width: 440px;
        width: 100%;
    }
}
