/* ==========================================================
   HOEKSEMA.GITHUB.IO — STYLE
   Dark theme. Geist Mono. Orange where humans touch.
   ========================================================== */

/* ─── Reset / Base ─────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: #141414;
    color: #F0F0F0;
    font-family: 'Geist Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
}

body {
    display: block;
    min-height: 100vh;
    background: #141414;
}

/* ─── Sidebar Nav ──────────────────────────────────────── */
.nav-toggle {
    display: none;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 72px;
    background: #0D0D0D;
    border-right: 1px solid #2A2A2A;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 150ms ease;
    z-index: 100;
    padding-top: 12px;
}

.nav-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 66px;
    cursor: pointer;
    color: #666;
    font-size: 30px;
    flex-shrink: 0;
    transition: color 80ms;
}

.nav-hamburger:hover {
    color: #F0F0F0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 21px;
    text-decoration: none;
    color: #666;
    min-height: 66px;
    white-space: nowrap;
    transition: color 80ms;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.05em;
    border-left: 3px solid transparent;
    flex-shrink: 0;
}

.nav-item i {
    font-size: 27px;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}

.nav-item:hover {
    color: #F0F0F0;
    text-decoration: none;
}

.nav-item.active {
    color: #FF6200;
    border-left-color: #FF6200;
}

.nav-label {
    font-size: 17px;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Desktop: expand on hover */
@media (min-width: 641px) {
    .sidebar:hover {
        width: 200px;
    }
}

/* ─── Content Area ─────────────────────────────────────── */
.content {
    max-width: 50vw;
    width: 100%;
    margin: 0 auto;
    padding: 32px;
}

/* On screens too narrow to center without overlapping sidebar */
@media (max-width: 736px) {
    .content {
        margin-left: 72px;
        margin-right: 0;
        max-width: calc(100vw - 72px);
    }
}

/* ─── Typography ───────────────────────────────────────── */
h1 {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    color: #FF6200;
    margin-top: 72px;   /* ~two blank lines above section-level headings */
    margin-bottom: 24px;
}

/* The page-title h1 keeps sitting at the top */
h1:first-of-type {
    margin-top: 0;
}

h2 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    color: #F0F0F0;
    margin-top: 48px;   /* ~one blank line */
    margin-bottom: 16px;
}

h3 {
    font-size: 20px;
    font-weight: 500;
    line-height: 1.2;
    color: #F0F0F0;
    margin-top: 16px;
    margin-bottom: 12px;
}

h4, h5, h6 {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.2;
    color: #F0F0F0;
    margin-top: 12px;
    margin-bottom: 8px;
}

p {
    margin-bottom: 16px;
    color: #F0F0F0;
}

ul, ol {
    padding-left: 20px;
    margin-bottom: 16px;
}

li {
    margin-bottom: 8px;
}

strong {
    font-weight: 700;
}

/* ─── Links ────────────────────────────────────────────── */
a {
    color: #FF6200;
    text-decoration: none;
    transition: text-decoration 80ms;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid #FF6200;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Nav items override link colors */
.nav-item,
.nav-item:hover {
    color: inherit;
}

/* ─── Post / Project Card Lists ────────────────────────── */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.post-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #1A1A1A;
    border: 1px solid #2A2A2A;
    border-radius: 2px;
    min-height: 44px;
    text-decoration: none;
    color: #F0F0F0;
    transition: border-color 80ms, background 80ms;
}

.post-item:hover {
    border-color: #FF6200;
    background: #1E1E1E;
    text-decoration: none;
    color: #F0F0F0;
}

.post-title {
    color: #F0F0F0;
    font-size: 14px;
}

.post-item:hover .post-title {
    color: #FF6200;
}

.post-date {
    color: #666;
    font-size: 11px;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ─── Profile Photo ────────────────────────────────────── */
.profile-photo {
    width: 450px;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto 24px;
    border: 1px solid #2A2A2A;
}

/* ─── Home Centered Layout ────────────────────────────── */
.home-centered {
    text-align: center;
    font-size: 21px;
}

.home-centered h1 {
    font-size: 48px;
}

/* ─── Code ─────────────────────────────────────────────── */
code {
    background: #1A1A1A;
    border: 1px solid #2A2A2A;
    border-radius: 2px;
    padding: 1px 4px;
    font-family: 'Geist Mono', 'Courier New', monospace;
    font-size: 13px;
    color: #00D4FF;
}

pre {
    background: #1A1A1A;
    border: 1px solid #2A2A2A;
    border-radius: 2px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    color: #F0F0F0;
}

/* ─── Images ───────────────────────────────────────────── */
.content img {
    max-width: 100%;
    height: auto;
}

/* ─── Video ────────────────────────────────────────────── */
/* Height-capped like the explainer-box images, so portrait phone
   footage doesn't run the length of the page. */
.content video {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    margin: 24px auto;
    background: #000;
}

/* ─── Post Page ─────────────────────────────────────────── */
.post-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2A2A2A;
}

.post-header time {
    display: block;
    color: #666;
    font-size: 11px;
    letter-spacing: 0.05em;
    margin-top: 8px;
}

/* ─── Horizontal Rule ───────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid #2A2A2A;
    margin: 24px 0;
}

/* ─── Blockquote ────────────────────────────────────────── */
blockquote {
    border-left: 2px solid #FF6200;
    padding: 8px 16px;
    margin: 16px 0;
    background: #1A1A1A;
    color: #F0F0F0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ─── Blue Box Explainer ──────────────────────────────────── */
.blue-box {
    background: #0D3047;
    border: 1px solid #00D4FF;
    border-radius: 2px;
    padding: 16px 20px;
    width: 90%;
    margin: 24px auto;
}

.blue-box > *:last-child {
    margin-bottom: 0;
}

.blue-box-title {
    display: block;
    color: #00D4FF;
    font-weight: 700;
    margin-bottom: 8px;
}

/* ─── Green Box Explainer ─────────────────────────────────── */
.green-box {
    background: #0D3D2A;
    border: 1px solid #00FF88;
    border-radius: 2px;
    padding: 16px 20px;
    width: 90%;
    margin: 24px auto;
}

.green-box > *:last-child {
    margin-bottom: 0;
}

.green-box-title {
    display: block;
    color: #00FF88;
    font-weight: 700;
    margin-bottom: 8px;
}

/* Images inside explainer boxes: centered, height-capped so tall
   portrait photos don't take over the page */
.blue-box img,
.green-box img {
    display: block;
    max-width: 100%;
    max-height: 420px;
    width: auto;
    margin: 0 auto;
}

/* ─── Essay: header / subtitle / link buttons / TOC / captioned figures ── */
/* Scoped to the essay header so the site's other h1s keep their left edge. */
.essay-header {
    text-align: center;
}

.essay-subtitle {
    color: #999;
    font-style: italic;
    margin-top: -16px;
    margin-bottom: 24px;
}

.essay-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 32px;
}

/* Three buttons share one row on a full-width column, so the padding and
   type are trimmed and the label is allowed to wrap onto a second line
   instead of forcing a row break. The icon and label live together in one
   span: as separate flex items the label box would keep the full leftover
   width and centre its lines inside it, stranding the icon out at the edge. */
.essay-button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 150px;
    min-height: 56px;
    padding: 12px 8px;
    background: #1A1A1A;
    border: 1px solid #FF6200;
    border-radius: 2px;
    color: #FF6200;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.3;
    text-align: center;
    text-wrap: balance;
    transition: background 80ms, color 80ms;
}

.essay-button i {
    margin-right: 6px;
    font-size: 18px;
    line-height: 1;
    vertical-align: -3px;
}

.essay-button:hover {
    background: #FF6200;
    color: #141414;
    text-decoration: none;
}

.essay-toc {
    background: #1A1A1A;
    border: 1px solid #2A2A2A;
    border-radius: 2px;
    padding: 16px 20px;
    margin: 24px 0 32px;
}

.essay-toc-title {
    display: block;
    color: #666;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.essay-toc ul {
    margin-bottom: 0;
}

.essay-toc li {
    margin-bottom: 4px;
}

/* Captioned figures: image and caption centered, caption in gray */
.essay-figure {
    margin: 24px auto;
    text-align: center;
}

.essay-figure img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
}

/* Captions read as an aside, not a paragraph, so they wrap at half the
   column instead of running the full measure under the image. */
.essay-figure figcaption {
    color: #999;
    font-size: 13px;
    max-width: 50%;
    margin: 8px auto 0;
    text-align: center;
}

/* A captioned video keeps the figure's own spacing, not the standalone
   video margin, so the caption sits as close as an image caption does. */
.essay-figure video {
    margin: 0 auto;
}

/* ─── Sourced images: hover reveals a link to where they came from ──
   Borrowed figures carry their source instead of spending a caption line
   on it. The wrapper shrink-wraps the image so the badge pins to the
   picture's own corner, not the column's. */
.img-link {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    line-height: 0;
}

.img-link-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 2px;
    background: rgba(20, 20, 20, 0.85);
    border: 1px solid #FF6200;
    color: #FF6200;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    transition: opacity 120ms, background 80ms, color 80ms;
}

.img-link:hover .img-link-badge,
.img-link-badge:focus-visible {
    opacity: 1;
}

.img-link-badge:hover {
    background: #FF6200;
    color: #141414;
    text-decoration: none;
}

/* No hover to reveal it on a touch screen, so it just stays put. */
@media (hover: none) {
    .img-link-badge { opacity: 1; }
}

/* Centered display equation */
.essay-equation {
    text-align: center;
    font-size: 18px;
    margin: 24px 0;
}

/* ─── Contact Methods ─────────────────────────────────────── */
.contact-method {
    margin-bottom: 24px;
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    /* The sidebar no longer reserves 72px of a small screen: it collapses
       to nothing and slides in as an overlay when the hamburger opens it. */
    .sidebar {
        width: 0;
        border-right: none;
        padding-top: 56px;
    }

    /* On mobile, hover does nothing; use toggle */
    .sidebar:hover {
        width: 0;
    }

    .nav-toggle:checked ~ .sidebar {
        width: 200px;
        border-right: 1px solid #2A2A2A;
        box-shadow: 0 0 32px rgba(0, 0, 0, 0.7);
    }

    /* The hamburger escapes the zero-width sidebar as a fixed button. */
    .nav-hamburger {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 48px;
        height: 48px;
        font-size: 26px;
        z-index: 102;
        color: #F0F0F0;
    }

    .content {
        margin-left: 0;
        max-width: 100vw;
        padding: 52px 12px 16px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    .profile-photo {
        width: clamp(288px, 60vw, 360px);
    }

    .home-centered {
        font-size: clamp(12px, 3.5vw, 15px);
    }

    .home-centered h1 {
        font-size: clamp(29px, 7vw, 36px);
    }

    /* Half a phone-width column would break a caption into a ragged
       stack, so it takes the full measure here. */
    .essay-figure figcaption {
        max-width: 100%;
    }

    /* One button per row on a phone, so each label gets the full
       measure back at the desktop type size. */
    .essay-buttons {
        flex-direction: column;
        gap: 10px;
    }

    /* The column axis is now vertical, so the row-layout flex-basis would
       set a 150px height. Each button goes back to hugging its label. */
    .essay-button {
        flex: 0 0 auto;
        padding: 12px 20px;
        font-size: 16px;
    }

    .essay-button i {
        margin-right: 10px;
        font-size: 22px;
        vertical-align: -4px;
    }
}

/* ─── Minesweeper ─────────────────────────────────────── */
#minesweeper-wrap {
    position: fixed;
    bottom: 0;
    left: 72px;
    right: 0;
    height: 25vh;
    min-height: 120px;
    background: #FF6200;
    z-index: 10;
    overflow: hidden;
}

#minesweeper {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 2px;
    background: #FF6200;
}

.ms-slot {
    position: relative;
    background: #FF6200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-content {
    font-family: 'Geist Mono', monospace;
    font-weight: 700;
    font-size: 18px;
    color: #141414;
    user-select: none;
    pointer-events: none;
}

.ms-bomb {
    font-size: 22px;
}

.ms-num { color: #FFFFFF; }

.ms-cell {
    position: absolute;
    inset: 0;
    background: #E8E8E8;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0;
    box-shadow:
        inset  2px  2px 0 0 #FFFFFF,
        inset -2px -2px 0 0 #999999,
        inset  1px  1px 0 0 #D4D4D4,
        inset -1px -1px 0 0 #AAAAAA;
    transition: transform 0.35s ease-in, opacity 0.35s ease-in;
    transform-origin: bottom center;
    backface-visibility: hidden;
}

.ms-cell:hover:not(.revealed) {
    background: #F0F0F0;
}

.ms-cell:active:not(.revealed) {
    box-shadow:
        inset -1px -1px 0 0 #FFFFFF,
        inset  1px  1px 0 0 #999999;
}

.ms-cell.flagged::after {
    content: '\2691';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 54px;
    color: #141414;
    pointer-events: none;
}

.ms-cell.victory-reveal {
    background: #00FF66;
}

.ms-cell.revealed {
    animation: tile-fall 0.35s ease-in forwards;
    pointer-events: none;
}

@keyframes tile-fall {
    0%   { transform: perspective(400px) rotateX(0deg); opacity: 1; }
    100% { transform: perspective(400px) rotateX(90deg) translateY(20px); opacity: 0; }
}

.page-home .content {
    padding-bottom: 28vh;
}

/* Modal */
#ms-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

#ms-modal.active {
    display: flex;
}

#ms-modal-inner {
    background: #1A1A1A;
    border: 1px solid #FF6200;
    border-radius: 2px;
    padding: 24px 36px;
    text-align: center;
    font-family: 'Geist Mono', monospace;
}

#ms-modal-inner h2 {
    color: #FF6200;
    margin: 0 0 16px;
    font-size: 20px;
}

#ms-modal-inner button {
    background: #FF6200;
    color: #141414;
    border: none;
    padding: 8px 24px;
    font-family: 'Geist Mono', monospace;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    border-radius: 2px;
}

#ms-modal-inner button:hover {
    background: #E55A00;
}

@media (max-width: 640px) {
    #minesweeper-wrap {
        left: 0;
        height: 22vh;
    }

    .page-home .content {
        padding-bottom: 25vh;
    }
}
