/* dekai.me — sun-bleached paper, rounded type, doodles in the margins. */

:root {
    --ground: #F0EADD;
    --ink: #26231E;
    --muted: #7C7568;
    --faint: #A9A093;
    --hairline: #DFD7C7;
    --rule: #CDC4B1;
    --underline: #B4AA9A;
    /* moss — survives a tinted ground where a bright green wouldn't */
    --accent: #4F6B3D;
    --grid-dot: #E2DACA;
    /* the noise is printed in the page's own ink, not on a black slab */
    --noise: rgba(38, 35, 30, 0.2);

    --round: "M PLUS Rounded 1c", ui-rounded, "Hiragino Maru Gothic ProN", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
    box-sizing: border-box;
}

html {
    background-color: var(--ground);
}

body {
    margin: 0;
    font-family: var(--round);
    font-size: 15px;
    font-weight: 400;
    line-height: 25px;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.paper {
    position: relative;
    background-color: var(--ground);
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Light source above the masthead. */
.paper::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 620px;
    background: radial-gradient(ellipse 60% 100% at 34% 0%, rgba(255, 253, 246, 0.85), transparent 72%);
    pointer-events: none;
}

.ink-defs {
    position: absolute;
}

main {
    position: relative;
    z-index: 1;
    width: 680px;
    max-width: calc(100% - 48px);
    margin: 0 auto;
    padding: 104px 0 48px;
}

/* ---------------------------------------------------------------- *
 * Index rail                                                        *
 * ---------------------------------------------------------------- */

.rail {
    position: fixed;
    top: 104px;
    left: 76px;
    z-index: 2;
    font-size: 15px;
    line-height: 28px;
    color: var(--muted);
}

.rail a {
    color: inherit;
    border-bottom: 0;
    transition: color 160ms ease;
}

.rail a:hover {
    color: var(--ink);
}

.rail-home {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 92px;
    font-size: 17px;
}

.rail-home svg {
    width: 20px;
    height: 15px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rail ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (max-width: 1180px) {
    .rail {
        display: none;
    }
}

/* ---------------------------------------------------------------- *
 * Document                                                          *
 * ---------------------------------------------------------------- */

.masthead {
    margin-bottom: 40px;
}

.masthead h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 25px;
}

.updated {
    margin: 0;
    color: var(--muted);
}

.prose p {
    max-width: 600px;
    margin: 0 0 18px;
}

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

a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--underline);
    transition: border-color 120ms ease, color 120ms ease;
}

a:hover {
    border-bottom-color: var(--ink);
}

a.accent {
    border-bottom-color: var(--accent);
}

/* ---------------------------------------------------------------- *
 * Writing                                                           *
 * ---------------------------------------------------------------- */

.writing {
    margin-top: 72px;
}

.writing h2 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 400;
    line-height: 25px;
    color: var(--muted);
}

.writing ul {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--hairline);
}

.writing li {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 6px 0;
    border-bottom: 1px solid var(--hairline);
}

.year,
.date {
    flex-shrink: 0;
    color: var(--muted);
}

.year {
    width: 130px;
}

.date {
    width: 52px;
    text-align: right;
}

.entry {
    flex: 1;
    border-bottom: 1px solid transparent;
}

.entry:hover {
    border-bottom-color: var(--underline);
}

/* Circled by hand, the way you'd ring something in a margin. */
.tag {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 28px;
    margin-right: 12px;
    font-size: 12px;
    color: var(--accent);
}

.ring {
    position: absolute;
    inset: 0;
    width: 64px;
    height: 28px;
    overflow: visible;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.9;
    stroke-linecap: round;
    transform: rotate(-5deg);
}

/* ---------------------------------------------------------------- *
 * Software lede                                                     *
 * ---------------------------------------------------------------- */

.lede {
    max-width: 600px;
    margin: -2px 0 14px;
    color: var(--muted);
}

/* Software rows carry a destination, not a date, so the lane runs wider. */
.software .date {
    width: 92px;
}

.year .tag {
    margin-right: 0;
}

/* ---------------------------------------------------------------- *
 * Articles                                                          *
 * ---------------------------------------------------------------- */

.articles {
    margin-top: 72px;
}

.articles h2 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 400;
    line-height: 25px;
    color: var(--muted);
}

.articles .lede {
    margin: 0;
}

/* ---------------------------------------------------------------- *
 * Career                                                            *
 * ---------------------------------------------------------------- */

.career {
    margin-top: 72px;
}

.career h2 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 400;
    line-height: 25px;
    color: var(--muted);
}

.career ol {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--hairline);
}

.career li {
    display: flex;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--hairline);
}

/* Fixed slot so the text lane holds even when a mark is missing. */
.mark {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
    background-color: #FFFFFF;
    box-shadow: 0 0 0 1px var(--hairline);
}

.role {
    flex: 1;
    min-width: 0;
}

.role p {
    margin: 0;
}

.title {
    font-weight: 500;
}

.when {
    color: var(--muted);
}

.what {
    max-width: 520px;
    margin-top: 6px !important;
}

/* ---------------------------------------------------------------- *
 * Elsewhere                                                         *
 * ---------------------------------------------------------------- */

.elsewhere {
    margin-top: 72px;
}

.elsewhere h2 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 400;
    line-height: 25px;
    color: var(--muted);
}

.elsewhere p {
    max-width: 600px;
    margin: 0;
}

/* ---------------------------------------------------------------- *
 * Footer                                                            *
 * ---------------------------------------------------------------- */

footer {
    margin-top: 80px;
}

footer hr {
    width: 96px;
    height: 1px;
    margin: 0 0 28px;
    border: 0;
    background-color: var(--rule);
}

.meta {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 18px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.pip {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 999px;
    background-color: var(--accent);
}

.critter {
    letter-spacing: 0.04em;
    color: var(--faint);
}

.meta a {
    margin-left: auto;
    border-bottom-color: var(--underline);
}

/* ---------------------------------------------------------------- *
 * Marginalia — doodles in the gutters. Faint until you approach.    *
 * ---------------------------------------------------------------- */

.stickers {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

/* Three nested layers so parallax, drift and hover don't fight over
   the same transform: .sticker = cursor parallax (JS),
   i = idle drift (CSS), svg = hover pop. */
.sticker {
    position: absolute;
    top: var(--y);
    left: calc(50% + var(--x));
    pointer-events: auto;
    will-change: transform;
    cursor: grab;
    touch-action: none;
}

.sticker.held {
    cursor: grabbing;
    z-index: 3;
}

.sticker.held img {
    opacity: 1;
    transform: rotate(calc(var(--tilt) * -1.4)) scale(1.14);
    transition-duration: 120ms;
}

/* A held sticker shouldn't also be bobbing. */
.sticker.held i {
    animation-play-state: paused;
}

.sticker i {
    display: block;
    animation: drift 17s ease-in-out infinite;
}

.sticker:nth-child(even) i {
    animation-duration: 21s;
    animation-direction: reverse;
}

.sticker img {
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    opacity: 0.42;
    transform: rotate(var(--tilt));
    transition: opacity 400ms ease, transform 500ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.sticker:hover img {
    opacity: 1;
    transform: rotate(calc(var(--tilt) * -1.4)) scale(1.1);
    transition-duration: 180ms;
}

.sticker.poke img {
    animation: poke 540ms cubic-bezier(0.3, 1.4, 0.4, 1);
}

@keyframes drift {

    0%,
    100% {
        transform: translate3d(0, 0, 0);
    }

    50% {
        transform: translate3d(3px, -7px, 0);
    }
}

@keyframes poke {
    0% {
        transform: rotate(var(--tilt)) scale(1.1);
    }

    30% {
        transform: rotate(calc(var(--tilt) + 16deg)) scale(1.17);
    }

    62% {
        transform: rotate(calc(var(--tilt) - 11deg)) scale(1.11);
    }

    100% {
        transform: rotate(calc(var(--tilt) * -1.4)) scale(1.1);
    }
}

/* Not enough gutter to hold them — drop the whole layer. */
@media (max-width: 1200px) {
    .stickers {
        display: none;
    }
}

/* ---------------------------------------------------------------- *
 * Terminal noise                                                    *
 * ---------------------------------------------------------------- */

.ascii-band {
    position: relative;
    height: 300px;
    overflow: hidden;
    cursor: crosshair;
    /* Densest in the middle, dissolving on every edge — so it emerges from
       the page rather than sitting on it as a block. */
    -webkit-mask-image: radial-gradient(ellipse 68% 76% at 50% 46%, #000 34%, transparent 100%);
    mask-image: radial-gradient(ellipse 68% 76% at 50% 46%, #000 34%, transparent 100%);
}

#ascii {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------------------------------------------------------------- *
 * Small screens                                                     *
 * ---------------------------------------------------------------- */

@media (max-width: 640px) {
    main {
        padding: 68px 0 56px;
    }

    .writing {
        margin-top: 56px;
    }

    .writing li {
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 16px;
        row-gap: 2px;
        align-items: baseline;
        min-height: 0;
        padding: 11px 0;
    }

    .year {
        width: auto;
        grid-column: 1;
        grid-row: 1;
    }

    .tag {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        margin-right: 0;
    }

    .entry {
        grid-column: 1;
        grid-row: 2;
    }

    .date {
        width: auto;
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
    }

    footer {
        margin-top: 56px;
    }

    .meta {
        flex-wrap: wrap;
        gap: 10px;
    }

    .meta a {
        margin-left: 0;
        flex-basis: 100%;
    }

    .ascii-band {
        height: 190px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sticker i {
        animation: none;
    }

    .sticker svg {
        transition-duration: 1ms;
    }
}
