@font-face {
    font-family: "Erode";
    src: url("fonts/Erode-Semibold.otf") format("opentype");
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Recia";
    src: url("fonts/Recia-Regular.otf") format("opentype");
    font-weight: 400;
    font-display: swap;
}

:root {
    --cream-1: #FEFFE1;
    --cream-2: #F1F4D6;
    --sage-1: #BEC9A9;
    --sage-2: #8EA280;
    --green-1: #204721;
    --green-2: #0F3931;
}

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

html {
    scroll-behavior: smooth;
    /* The navbar is sticky (~67px), so an anchor jump would otherwise land the
       target underneath it. This offsets every in-page anchor on the site. */
    scroll-padding-top: 88px;
}

body {
    font-family: "Recia", Georgia, serif;
    background: var(--cream-1);
    color: var(--green-2);
    line-height: 1.7;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 48px;
    background: var(--green-2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    font-family: "Erode", Georgia, serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--cream-1);
    letter-spacing: 0.5px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.logo:hover {
    color: var(--sage-1);
}

.nav-links {
    display: flex;
    gap: 28px;
}

.nav-links a {
    font-size: 14px;
    color: var(--sage-1);
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 100%;
    height: 2px;
    background: var(--cream-1);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.nav-links a:hover {
    color: var(--cream-1);
}

.nav-links a:hover::after {
    transform: scaleX(1);
}

/* Hero */
.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 48px;
    padding: 96px 48px 72px;
    background: var(--cream-2);
}

/* display:block matters: until the CDN module defines <model-viewer> it is an
   unknown element and therefore inline, so width/height would not apply and
   the panel would collapse while the script loads. */
.hero-model model-viewer {
    display: block;
    width: 100%;
    height: 380px;
    background: var(--green-2);
    border-radius: 12px;
}

.hero-model-caption {
    margin-top: 10px;
    font-size: 12px;
    color: var(--sage-2);
    text-align: center;
}

/* Fallback for browsers that can't run the viewer. Hidden by default; shown
   when the custom element never defines (blocked CDN, no ES modules, JS off)
   or when it defines but fails to render (no WebGL — .model-failed). */
.model-fallback {
    display: none;
}

.hero-model model-viewer:not(:defined) {
    display: none;
}

model-viewer:not(:defined) ~ .model-fallback,
.hero-model.model-failed .model-fallback {
    display: block;
}

.hero-model.model-failed model-viewer {
    display: none;
}

/* The caption says "drag to rotate", which is wrong once we're showing a photo */
model-viewer:not(:defined) ~ .hero-model-caption,
.hero-model.model-failed .hero-model-caption {
    display: none;
}

.model-fallback img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 12px;
}

.model-fallback p {
    margin-top: 10px;
    font-size: 12px;
    color: var(--sage-2);
    text-align: center;
}

.hero-eyebrow {
    font-size: 14px;
    font-weight: 500;
    color: var(--sage-2);
    margin-bottom: 10px;
}

.hero h1 {
    font-family: "Erode", Georgia, serif;
    font-size: 42px;
    font-weight: 600;
    line-height: 1.25;
    max-width: 640px;
    margin-bottom: 16px;
}

.hero-sub {
    font-size: 16px;
    color: var(--green-1);
    max-width: 520px;
    margin-bottom: 28px;
}

.hero-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 11px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--green-2);
    color: var(--cream-1);
}

.btn-primary:hover {
    background: var(--green-1);
    box-shadow: 0 4px 12px rgba(15, 57, 49, 0.25);
}

.btn-outline {
    color: var(--green-2);
    border: 1px solid var(--sage-2);
}

.btn-outline:hover {
    background: var(--sage-1);
    box-shadow: 0 4px 12px rgba(142, 162, 128, 0.3);
}

/* Sections */
.section {
    padding: 56px 48px;
}

.section-label {
    font-family: "Erode", Georgia, serif;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

/* Skill tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.skill-tag {
    display: inline-block;
    background: var(--sage-1);
    color: var(--green-2);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    padding: 5px 10px;
    border-radius: 8px;
    text-align: center;
    cursor: default;
}

/* Projects */
/* 260px floor gives 3 cards per row at ~1030px instead of a cramped 4.
   auto-FILL, not auto-fit: auto-fit collapses the empty tracks and lets a
   handful of cards stretch to fill an ultrawide screen, so cards would balloon.
   auto-fill keeps those tracks, which caps card width at one track (~290px)
   at any viewport. The max must stay 1fr: with a definite max like 380px the
   repeat count is computed from the MAX, not the min, which silently drops
   ~1030px to two columns. */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.project-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--cream-2);
    border: 1px solid var(--sage-1);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(32, 71, 33, 0.15);
    border-color: var(--sage-2);
}

.project-thumb {
    background: var(--green-1);
}

/* The ratio lives on the img, not the container: sizing the img with
   height:100% against a container whose own height comes from aspect-ratio
   is a cyclic dependency, and the image falls back to its natural ratio. */
.project-thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* Fallback tile for a project with no photo yet */
.project-thumb-empty {
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease;
}

.project-thumb-empty i {
    color: var(--cream-1);
    font-size: 30px;
}

.project-card:hover .project-thumb-empty {
    background: var(--green-2);
}

.project-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 20px;
}

/* The ::after stretches this button over the whole card, so clicking
   anywhere on the card opens the dialog while the button stays the real,
   keyboard-reachable control. */
.project-open {
    align-self: flex-start;
    margin-top: 14px;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--green-2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none; /* it can be a <button> or an <a> — no underline either way */
    white-space: nowrap;   /* never break "View details" across two lines */
    transition: color 0.2s ease;
}

/* Slide the icon with transform, not gap. Animating gap changes the element's
   width mid-hover, which can push a tight card's label onto a second line. */
.project-open i {
    transition: transform 0.2s ease;
}

.project-open::after {
    content: "";
    position: absolute;
    inset: 0;
}

.project-card:hover .project-open {
    color: var(--green-1);
}

.project-card:hover .project-open i {
    transform: translateX(4px);
}

.project-open:focus-visible {
    outline: 2px solid var(--sage-2);
    outline-offset: 3px;
}

/* Row for a card with more than one action */
/* Wraps as whole actions if the card is too narrow for both side by side,
   rather than breaking either label mid-phrase. */
.project-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 14px;
}

.project-actions .project-open {
    margin-top: 0;
    align-self: auto;
}

/* Raised above .project-open::after, which is stretched over the whole card —
   without the z-index this link sits under the overlay and can't be clicked. */
.project-live {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sage-2);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.project-live i {
    transition: transform 0.2s ease;
}

.project-live:hover {
    color: var(--green-1);
}

.project-live:hover i {
    transform: translateX(3px);
}

.project-live:focus-visible {
    outline: 2px solid var(--sage-2);
    outline-offset: 3px;
}

/* Project dialog */
.project-dialog {
    /* The `*` reset above zeroes margin, which kills the UA's `margin: auto`
       on a modal dialog — that auto margin is what centres it. Put it back. */
    margin: auto;
    width: min(720px, calc(100vw - 48px));
    max-height: calc(100vh - 80px);
    padding: 0;
    border: 1px solid var(--sage-1);
    border-radius: 12px;
    background: var(--cream-1);
    color: var(--green-2);
    overflow: hidden;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.25s ease, transform 0.25s ease,
                overlay 0.25s ease allow-discrete, display 0.25s ease allow-discrete;
}

.project-dialog:not([open]) {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
}

@starting-style {
    .project-dialog[open] {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

.project-dialog::backdrop {
    background: rgba(15, 57, 49, 0.55);
}

/* Keep the page behind from scrolling while a dialog is open */
body:has(.project-dialog[open]) {
    overflow: hidden;
}

.dialog-scroll {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.dialog-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: var(--green-2);
    color: var(--cream-1);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.dialog-close:hover {
    transform: translateY(-2px);
    background: var(--green-1);
}

.dialog-hero {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.dialog-body {
    padding: 24px;
}

.dialog-body h2 {
    font-family: "Erode", Georgia, serif;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 12px;
}

.dialog-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.dialog-gallery img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
}

.project-card h3 {
    font-family: "Erode", Georgia, serif;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.project-card p {
    font-size: 13px;
    color: var(--sage-2);
}

.card-date {
    font-size: 12px;
    color: var(--sage-2);
    margin-bottom: 6px;
}

/* Bullets inside a project card. Matches the card's 13px body text, unlike
   .exp-bullets which is sized for the wider experience rows. */
.card-bullets {
    margin-top: 10px;
    padding-left: 18px;
}

.card-bullets li {
    font-size: 13px;
    color: var(--sage-2);
    margin-bottom: 4px;
}

.card-bullets li::marker {
    color: var(--sage-1);
}

.project-card .tags {
    margin-top: auto;
    padding-top: 14px;
}

/* Experience */
.exp-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.exp-item {
    background: var(--cream-2);
    border: 1px solid var(--sage-1);
    border-radius: 12px;
    padding: 20px;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.exp-item:hover {
    box-shadow: 0 8px 20px rgba(32, 71, 33, 0.15);
    border-color: var(--sage-2);
}

.exp-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.exp-head h3 {
    font-family: "Erode", Georgia, serif;
    font-size: 17px;
    font-weight: 600;
}

.exp-date {
    font-size: 12px;
    color: var(--sage-2);
}

.exp-org {
    font-size: 13px;
    color: var(--green-1);
    margin-bottom: 8px;
}

.exp-bullets {
    padding-left: 18px;
}

.exp-bullets li {
    font-size: 14px;
    color: var(--green-1);
    margin-bottom: 2px;
}

.exp-bullets li::marker {
    color: var(--sage-2);
}

/* Blog */

/* Center the content column on the blog pages only. #posts is the blog index
   section; article.section is a post page. work.html uses section.section and
   index.html uses .hero, so neither is affected. 776px = the 680px reading
   column + the 48px section padding on each side. */
#posts,
article.section {
    max-width: 776px;
    margin-left: auto;
    margin-right: auto;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-card {
    display: block;
    background: var(--cream-2);
    border: 1px solid var(--sage-1);
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(32, 71, 33, 0.15);
    border-color: var(--sage-2);
}

.post-card h3 {
    font-family: "Erode", Georgia, serif;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.post-date {
    font-size: 12px;
    color: var(--sage-2);
    margin-bottom: 4px;
}

.post-excerpt {
    font-size: 14px;
    color: var(--green-1);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--sage-2);
    text-decoration: none;
    margin-bottom: 20px;
    transition: color 0.2s ease, transform 0.2s ease;
}

.back-link:hover {
    color: var(--green-2);
    transform: translateX(-3px);
}

.post-title {
    font-family: "Erode", Georgia, serif;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.25;
    max-width: 680px;
    margin-bottom: 12px;
}

/* "Last updated" line in a post header. Sits outside .post-body, so a plain
   class is enough here — no specificity clash with `.post-body p`. */
.post-updated {
    margin-top: 14px;
    font-size: 12px;
    color: var(--sage-2);
}

.post-updated a {
    color: var(--sage-2);
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

.post-updated a:hover {
    color: var(--green-2);
}

.post-body {
    max-width: 680px;
    margin-top: 28px;
}

.post-body p {
    font-size: 16px;
    color: var(--green-1);
    margin-bottom: 18px;
}

.post-body h3 {
    font-family: "Erode", Georgia, serif;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Updates / corrections log at the foot of a post. Newest entry first. */
.update-log {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 20px;
}

.update-entry {
    border-left: 3px solid var(--sage-1);
    padding-left: 20px;
}

.update-entry > p:last-child {
    margin-bottom: 0;
}

/* Scoped to .post-body: a bare .update-date would lose to `.post-body p`,
   which is more specific and would force it back to 16px green-1. */
.post-body .update-date {
    font-size: 12px;
    color: var(--sage-2);
    margin-bottom: 4px;
}

.post-body h2 {
    font-family: "Erode", Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    margin: 32px 0 10px;
}

.post-body ul {
    padding-left: 20px;
    margin-bottom: 18px;
}

.post-body li {
    font-size: 16px;
    color: var(--green-1);
    margin-bottom: 4px;
}

.post-body li::marker {
    color: var(--sage-2);
}

.post-body a {
    color: var(--green-2);
    text-decoration-color: var(--sage-2);
    text-underline-offset: 3px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.post-body a:hover {
    color: var(--green-1);
    text-decoration-color: var(--green-1);
}

/* Figures inside a post */
.post-body figure {
    margin: 24px 0;
}

.post-body figure img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}

.post-body figcaption {
    margin-top: 8px;
    font-size: 12px;
    color: var(--sage-2);
    text-align: center;
}

/* Two charts side by side; stacks on narrow screens. */
.chart-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 24px 0;
    align-items: start;
}

.chart-pair figure {
    margin: 0;
}

@media (max-width: 600px) {
    .chart-pair {
        grid-template-columns: 1fr;
    }
}

/* Text with a figure floated to its right; stacks on narrow screens. */
.prediction-split {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin: 18px 0;
}

.prediction-text {
    flex: 1 1 0;
    min-width: 0;
}

.prediction-text p:last-child {
    margin-bottom: 0;
}

.prediction-chart {
    flex: 0 0 300px;
    margin: 0;
}

@media (max-width: 600px) {
    .prediction-split {
        flex-direction: column;
    }

    .prediction-chart {
        flex-basis: auto;
        width: 100%;
    }
}

/* Template placeholder for an image the author hasn't added yet */
.image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    aspect-ratio: 16 / 9;
    margin: 24px 0;
    padding: 16px;
    border: 2px dashed var(--sage-1);
    border-radius: 12px;
    background: var(--cream-2);
    color: var(--sage-2);
    font-size: 13px;
    text-align: center;
}

.image-placeholder i {
    font-size: 28px;
}

/* MathJax equations. SVG glyphs use fill: currentColor, so setting the colour
   here makes both inline and display math match the body text (green-1) —
   without it, display math would inherit the darker green-2 body default. */
.post-body mjx-container {
    color: var(--green-1);
}

/* Keep a wide display equation inside its own scroll box, not the whole page */
.post-body mjx-container[display="true"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 0;
}

/* Collapsible table. Native <details>; closed unless the author adds `open`. */
.post-body details.table-details {
    margin: 24px 0;
    border: 1px solid var(--sage-1);
    border-radius: 12px;
    background: var(--cream-2);
    overflow: hidden;
}

.post-body details.table-details summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--green-2);
    cursor: pointer;
    list-style: none;
    transition: background 0.2s ease;
}

/* Hide the browser's own disclosure triangle in both engines */
.post-body details.table-details summary::-webkit-details-marker {
    display: none;
}

.post-body details.table-details summary::marker {
    content: "";
}

.post-body details.table-details summary:hover {
    background: var(--sage-1);
}

.post-body details.table-details summary i {
    font-size: 15px;
    transition: transform 0.2s ease;
}

.post-body details.table-details[open] summary i {
    transform: rotate(90deg);
}

.post-body details.table-details .table-scroll {
    margin: 0;
    padding: 0 16px 16px;
}

/* Footnote markers in a table, and the note list under it */
sup.fn-ref {
    font-size: 10px;
    margin-left: 1px;
}

sup.fn-ref a {
    color: var(--green-2);
    text-decoration: none;
}

.post-body .footnotes {
    margin-top: 12px;
    padding-left: 20px;
}

.post-body .footnotes li {
    font-size: 12px;
    color: var(--sage-2);
    margin-bottom: 4px;
}

.post-body .footnotes li::marker {
    color: var(--sage-2);
}

/* Data tables in a post. Wrap the <table> in .table-scroll so a wide table
   scrolls inside its own box instead of the page. */
.table-scroll {
    overflow-x: auto;
    margin: 24px 0;
}

.post-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums; /* keeps decimal columns aligned */
}

.post-body caption {
    caption-side: top;
    text-align: left;
    font-size: 12px;
    color: var(--sage-2);
    margin-bottom: 10px;
}

.post-body th,
.post-body td {
    padding: 8px 14px;
    text-align: right;                  /* number columns */
    border-bottom: 1px solid var(--sage-1);
}

.post-body th:not(:first-child),
.post-body td:not(:first-child) {
    white-space: nowrap;
}

.post-body th:first-child,
.post-body td:first-child {
    text-align: left;                   /* deck-name column */
}

.post-body thead th {
    font-family: "Erode", Georgia, serif;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--green-2);
    border-bottom: 2px solid var(--sage-2);
}

.post-body tbody td {
    color: var(--green-1);
}

.post-body tbody tr:nth-child(even) {
    background: var(--cream-2);
}

.post-body tfoot td {
    font-size: 12px;
    color: var(--sage-2);
    border-top: 2px solid var(--sage-2);
    border-bottom: none;
}

/* Footer */
.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 36px 48px;
    background: var(--green-2);
}

.footer p {
    font-size: 15px;
    font-weight: 500;
    color: var(--cream-1);
}

.contact-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 22px;
}

.contact-links a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--sage-1);
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
}

.contact-links a i {
    font-size: 20px;
}

.contact-links a:hover {
    color: var(--cream-1);
    transform: translateY(-3px);
}

/* Responsive */
@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .hero-model model-viewer {
        height: 300px;
    }
}

@media (max-width: 600px) {
    .navbar, .hero, .section, .footer {
        padding-left: 24px;
        padding-right: 24px;
    }

    .hero h1 {
        font-size: 30px;
    }

    .post-title {
        font-size: 26px;
    }

    .nav-links {
        gap: 16px;
    }
}
