/* The corkboard: a cork panel in a wooden frame, with polaroids of the birds pinned on it.
   assets/board.js places each polaroid by its stored position and sets --card, the
   polaroid width that suits the board's size. */

:root {
    --wall: #2a1f16;
    --wall-text: #efe4d2;
    --wall-muted: #bfae96;
    --link: #f2c57c;
    --cork: #c39058;
    --frame-light: #8a5a33;
    --frame-dark: #4e3019;
    --paper: #fbf8f1;
    --ink: #2d2a26;
    --card: 120px;
    --handwriting: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Neue", "Marker Felt", cursive;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--wall);
    color: var(--wall-text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--link); }

/* --- Masthead --------------------------------------------------------------------------- */

.masthead {
    padding: 18px 24px 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 24px;
}

.masthead h1 {
    margin: 0;
    font: 700 clamp(1.4rem, 3.2vw, 2.2rem)/1.15 Georgia, "Times New Roman", serif;
    letter-spacing: 0.01em;
}

.masthead .tagline {
    font-weight: 400;
    font-style: italic;
    color: var(--wall-muted);
}

/* The status line and the link to the archive, side by side */
.masthead-side {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 20px;
}

.nav a { font-size: 0.95rem; }

.status {
    margin: 0;
    color: var(--wall-muted);
    font-size: 0.95rem;
}

.status .live-dot {
    display: inline-block;
    width: 0.55em;
    height: 0.55em;
    margin-right: 0.45em;
    border-radius: 50%;
    background: #e0473c;
    vertical-align: 0.08em;
    animation: blink 2.4s ease-in-out infinite;
}

body.asleep .status .live-dot { display: none; }

@keyframes blink { 50% { opacity: 0.25; } }

/* --- The board ---------------------------------------------------------------------------- */

main {
    flex: 1;
    display: flex;
    padding: 6px 16px 0;
}

/* Wooden frame around the cork */
.frame {
    flex: 1;
    display: flex;
    padding: clamp(8px, 1.4vw, 16px);
    border-radius: 6px;
    background:
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0 2px, transparent 2px 9px),
        linear-gradient(135deg, var(--frame-light), var(--frame-dark));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.board {
    position: relative;
    flex: 1;
    /* Tall enough for a collage on a phone, and the whole window on a desktop */
    min-height: max(560px, calc(100vh - 190px));
    border-radius: 2px;
    overflow: hidden;
    /* Cork: fine noise for the grain, coarser blotchy noise for the uneven colour, and a soft vignette */
    background-color: var(--cork);
    background-image:
        radial-gradient(ellipse at center, transparent 55%, rgba(60, 30, 5, 0.35) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.14 0 0 0 0 0.04 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.06' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.16 0 0 0 0 0.05 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23b)'/%3E%3C/svg%3E");
    background-size: 100% 100%, 220px 220px, 400px 400px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45);
    transition: filter 1.5s ease;
}

/* Night at the feeder: the board dims, the birds stay */
body.asleep .board { filter: brightness(0.62) saturate(0.8); }

.board-note {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-2deg);
    margin: 0;
    max-width: min(80%, 26rem);
    padding: 18px 22px;
    background: #fff7a8;
    color: var(--ink);
    font: 1.15rem/1.4 var(--handwriting);
    text-align: center;
    box-shadow: 2px 6px 14px rgba(0, 0, 0, 0.35);
    z-index: 100000;
}

/* --- Polaroids ----------------------------------------------------------------------------- */

.polaroid {
    /* Set per bird by board.js: --x/--y position (0–1), --r tilt, --s scale, --pin colour */
    position: absolute;
    left: calc(var(--x) * 100%);
    top: calc(var(--y) * 100%);
    width: calc(var(--card) * var(--s, 1));
    margin: 0;
    padding: calc(var(--card) * 0.06) calc(var(--card) * 0.06) 0;
    background: var(--paper);
    border: 0;
    border-radius: 2px;
    color: var(--ink);
    text-align: center;
    cursor: pointer;
    transform: translate(-50%, -50%) rotate(var(--r));
    /* Grows away from the nearer edges when lifted, so a picture near the frame stays in view */
    transform-origin: calc(var(--x) * 100%) calc(var(--y) * 100%);
    box-shadow: 1px 3px 6px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 1.2s ease;
}

.polaroid img {
    display: block;
    width: 100%;
    /* height: auto, or the img's height attribute (kept for layout hints) would win over the ratio */
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    background: #ddd6c8;
}

/* .caption: the same handwriting under a picture that is a link (archive.js), where a figcaption can't go */
.polaroid figcaption,
.polaroid .caption {
    display: block;
    padding: calc(var(--card) * 0.04) 2px calc(var(--card) * 0.07);
    font: calc(var(--card) * 0.085) / 1.2 var(--handwriting);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The push pin */
.polaroid::before {
    content: "";
    position: absolute;
    left: 50%;
    top: calc(var(--card) * -0.035);
    width: calc(var(--card) * 0.11);
    height: calc(var(--card) * 0.11);
    margin-left: calc(var(--card) * -0.055);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.75) 0 12%, transparent 30%), var(--pin);
    box-shadow: 1px 3px 3px rgba(0, 0, 0, 0.45);
    z-index: 1;
}

/* Hover, keyboard focus or a tap lifts the picture out so it can be seen properly */
.polaroid:hover,
.polaroid:focus-visible,
.polaroid.lifted {
    z-index: 99999 !important;
    transform: translate(-50%, -50%) rotate(0deg) scale(1.9);
    box-shadow: 4px 14px 28px rgba(0, 0, 0, 0.5);
    outline: none;
}

.polaroid.leaving { opacity: 0; }

/* A new bird drops onto the board from above and settles at its tilt */
.polaroid.dropping { animation: drop 1.1s cubic-bezier(0.25, 0.7, 0.35, 1) both; }

@keyframes drop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(-45vh) rotate(calc(var(--r) - 24deg)) scale(1.6);
        box-shadow: 20px 50px 50px rgba(0, 0, 0, 0.15);
    }
    15% { opacity: 1; }
    70% {
        transform: translate(-50%, -50%) rotate(calc(var(--r) + 3deg)) scale(1.04);
        box-shadow: 6px 14px 16px rgba(0, 0, 0, 0.3);
    }
    85% { transform: translate(-50%, -50%) rotate(calc(var(--r) - 1deg)) scale(0.99); }
    100% { transform: translate(-50%, -50%) rotate(var(--r)); }
}

/* The birds already on the board when the page opens just fade in */
.polaroid.appearing { animation: appear 0.5s ease both; }

@keyframes appear { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .polaroid.dropping { animation: appear 0.8s ease both; }
    .status .live-dot { animation: none; }
    .polaroid { transition: opacity 1.2s ease; }
}

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

.footer {
    padding: 14px 24px 22px;
    color: var(--wall-muted);
    font-size: 0.9rem;
    max-width: 60rem;
}

.footer p { margin: 0; }

@media (max-width: 600px) {
    .masthead { padding: 14px 16px 8px; }
    main { padding: 4px 8px 0; }
    .footer { padding: 12px 16px 18px; }
    .board { min-height: max(520px, calc(100vh - 170px)); }
}
