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

:root {
    --paper: #f6cfc6;   /* page colour: pale rose blush, like the pinks in the paintings */
    --black: #111;
    --muted: rgba(0, 0, 0, 0.4);
    --border: 2px solid #111;
}

body {
    background-color: var(--paper);
    color: var(--black);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    line-height: 1.7;
}

/* Header */

header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 1.5rem 2rem;
    border-bottom: var(--border);
    position: sticky;
    top: 0;
    background-color: var(--paper);
    z-index: 10;
}

.site-title {
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--black);
    letter-spacing: 0.02em;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    background: transparent;
    border: none;
    border-bottom: var(--border);
    padding: 0.1rem 0;
    cursor: pointer;
    color: var(--black);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-toggle:focus {
    outline: none;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background-color: var(--paper);
    border: var(--border);
    list-style: none;
    min-width: 100%;
    z-index: 100;
}

.dropdown-menu li {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.dropdown-menu li:hover {
    background-color: var(--black);
    color: var(--paper);
}

.dropdown.open .dropdown-menu {
    display: block;
}

/* Feed */

#feed {
    width: 100%;
}

.post {
    padding: 2.5rem 2rem;
    border-bottom: var(--border);
}

/* Writing sits in a centred column. The text itself stays left-aligned
   so long pieces are easy to read. */
.post-writing {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.post-writing .post-meta,
.post-writing .post-title {
    text-align: center;
}

.post-writing .post-body {
    width: 100%;
}

.post-painting {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Size of the photos in paintings and cha. */
.post-painting .post-image {
    width: 800px;
}

.post-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 0.6rem;
    letter-spacing: 0.03em;
}

.post-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1.2rem;
}

.post-body {
    max-width: 60ch;
    color: var(--black);
    white-space: pre-wrap;
}

.post-body p + p {
    margin-top: 1em;
}

.post-body img {
    display: block;
    max-width: 100%;
    width: 480px;
    margin-top: 1.2rem;
    margin-bottom: 1.2rem;
}

.post-image {
    display: block;
    max-width: 100%;
    width: 480px;
    margin-top: 0.5rem;
    border: var(--border);
    cursor: pointer;
}

.post-caption {
    margin-top: 0.6rem;
    font-size: 12px;
    color: var(--muted);
}

a {
    color: var(--black);
    text-decoration: none;
    border-bottom: var(--border);
}

a:hover {
    opacity: 0.6;
}

.button {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.4rem 1rem;
    border: var(--border);
}

.button:hover {
    background-color: var(--black);
    color: var(--paper);
    opacity: 1;
}

/* Full-width photos (cha): the whole photo, as wide as the screen,
   with its title on top in the corner. */

.post-full {
    position: relative;
    border-bottom: var(--border);
}

.post-full-image {
    display: block;
    width: 100%;
    height: auto;
}

.post-full-text {
    position: absolute;
    top: 1.5rem;
    left: 2rem;
    right: 2rem;
}

.post-full-text .post-title {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

/* Lightbox */

#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

#lightbox.open {
    display: flex;
}

#lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border: 2px solid #fff;
}

/* Empty state */

.empty {
    padding: 4rem 2rem;
    color: var(--muted);
    font-size: 13px;
}

.post-body h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
}

.post-body p + h3 {
    margin-top: 2em;
}

/* Home page: the paintings run the full width of the screen and stack
   top to bottom, so you scroll down over them. */

:root {
    --panel-h: max(420px, calc(100svh - var(--header-h, 77px)));
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
}

#feed {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.home {
    flex: 1;
    position: relative;
    background-color: #8a6f2c;
}

/* No top bar on the home page: the title and menu sit on top of the
   paintings, which start at the very top of the screen. */
body.is-home header {
    position: fixed;
    left: 0;
    right: 0;
    background-color: transparent;
    border-bottom: none;
    pointer-events: none;
}

body.is-home .site-title,
body.is-home .dropdown {
    pointer-events: auto;
}

/* Home page text sits straight on the paintings, with no box. A soft glow
   in the page colour keeps it readable over dark paint. */
body.is-home .site-title,
body.is-home .dropdown-toggle,
.home-card,
.post-full-text {
    font-weight: 500;
    text-shadow:
        0 0 2px var(--paper), 0 0 2px var(--paper),
        0 0 6px var(--paper), 0 0 6px var(--paper),
        0 0 14px var(--paper), 0 0 14px var(--paper);
}

/* Each painting is as wide as the screen and as tall as it needs to be,
   so nothing is cropped: you see all of it by scrolling down. */
.home-painting {
    display: block;
    width: 100%;
    height: auto;
}

.home-painting + .home-painting {
    border-top: var(--border);
}

/* Holds the card in place on screen while the paintings scroll behind it. */
.home-overlay {
    position: sticky;
    top: var(--header-h, 77px);
    height: var(--panel-h);
    margin-bottom: calc(-1 * var(--panel-h));
    z-index: 1;
    pointer-events: none;
}

.home-card {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 340px;
    max-width: calc(100% - 4rem);
    padding: 1.5rem 1.75rem 1.75rem;
    pointer-events: auto;
}

.home-title {
    font-size: 1.6rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    margin-bottom: 1rem;
}

.home-text {
    margin-bottom: 1.5rem;
}

.home-links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.home-links a {
    display: inline-block;
    padding: 0.55rem 1.2rem;
    font-size: 16px;
    background-color: var(--paper);
    border: var(--border);
    box-shadow: 3px 3px 0 var(--black);
    text-shadow: none;
}

.home-links a:hover {
    background-color: var(--black);
    color: var(--paper);
    opacity: 1;
}

.home-links a:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

/* ---------- Phones ----------
   Everything in here only applies on narrow screens; the desktop site is untouched. */
@media (max-width: 700px) {
    /* A little more room for content */
    header { padding: 1rem 1.25rem; }
    .post { padding: 2rem 1.25rem; }

    /* Menu that is easy to hit with a thumb */
    .dropdown-toggle { font-size: 15px; padding: 0.4rem 0; }
    .dropdown-menu li { font-size: 16px; padding: 0.7rem 1.1rem; }

    /* Home: text and buttons sit near the top, clear of the walker at the bottom */
    .home-card {
        top: 4.5rem;
        left: 1.25rem;
        right: 1.25rem;
        transform: none;
        width: auto;
        max-width: none;
        padding: 0;
    }
    .home-title { font-size: 1.3rem; margin-bottom: 0.5rem; }
    .home-text { margin-bottom: 1rem; }

    /* Cha: smaller titles so they don't cover the photo */
    .post-full-text { top: 0.9rem; left: 1.25rem; right: 1.25rem; }
    .post-full-text .post-title { font-size: 1rem; }
}

/* Bouncing walker along the bottom of the screen */

#walker {
    position: fixed;
    bottom: 0;
    left: 0;
    --walker-w: 100px;
    width: var(--walker-w);
    z-index: 500;
    pointer-events: none;
    animation: walker-across 18s linear infinite alternate;
}

#walker img {
    display: block;
    width: 100%;
    height: auto;
    animation: walker-bounce 0.45s cubic-bezier(0.1, 0.9, 0.3, 1) infinite alternate;
    transform-origin: bottom center;
}

@keyframes walker-across {
    from { transform: translateX(0); }
    to   { transform: translateX(calc(100vw - var(--walker-w))); }
}

@keyframes walker-bounce {
    from { transform: translateY(0) scaleY(1); }
    to   { transform: translateY(-36px) scaleY(1.03); }
}

/* Attack mode: walking pauses, it pounces at the cursor */

#walker.attacking {
    animation-play-state: paused;
}

#walker.attacking img {
    animation: walker-pounce 0.4s cubic-bezier(0.2, 1.2, 0.3, 1) infinite;
}

@keyframes walker-pounce {
    0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
    35%  { transform: translate(var(--dx, 0px), var(--dy, 0px)) rotate(var(--rot, 0deg)) scale(1.12); }
    55%  { transform: translate(var(--dx, 0px), var(--dy, 0px)) rotate(var(--rot, 0deg)) scale(1.08); }
    100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

/* Distress marks that fly off the cursor during an attack */

.distress {
    position: fixed;
    z-index: 600;
    pointer-events: none;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-shadow: 1px 1px 0 var(--paper), -1px -1px 0 var(--paper), 1px -1px 0 var(--paper), -1px 1px 0 var(--paper);
    opacity: 0;
}

/* Phones: a smaller walker with a lower bounce, so it covers less of the page */
@media (max-width: 700px) {
    #walker { --walker-w: 64px; }
    @keyframes walker-bounce {
        from { transform: translateY(0) scaleY(1); }
        to   { transform: translateY(-22px) scaleY(1.03); }
    }
}

@media (prefers-reduced-motion: reduce) {
    #walker, #walker img { animation: none; }
}
