/* The archive: days as polaroids on a cork strip, and a day's birds in a tidy grid.
   Builds on board.css (colours, masthead, polaroid look). */

.masthead .home { color: inherit; text-decoration: none; }
.masthead .home:hover { text-decoration: underline; }

.archive {
    flex: 1;
    display: block;
    padding: 8px 24px 0;
}

.archive-message { color: var(--wall-muted); }

.archive h2 {
    margin: 6px 0 4px;
    font: 700 clamp(1.2rem, 2.4vw, 1.6rem)/1.2 Georgia, "Times New Roman", serif;
}

.archive .summary {
    margin: 0 0 14px;
    color: var(--wall-muted);
}

/* The cork panel the polaroids lie on, like the board's but growing with its content */
.cork {
    position: relative;
    padding: 28px 18px 22px;
    border: clamp(8px, 1.4vw, 16px) solid var(--frame-dark);
    border-image: linear-gradient(135deg, var(--frame-light), var(--frame-dark)) 1;
    background-color: var(--cork);
    background-image:
        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: 220px 220px, 400px 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), inset 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* Polaroids in rows instead of pinned at stored spots */
.grid {
    --card: 150px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card), 1fr));
    gap: 26px 18px;
    justify-items: center;
}

.grid .polaroid {
    --x: 0.5;
    --y: 0.5;
    position: relative;
    left: auto;
    top: auto;
    /* A gentler tilt than on the board, so the rows stay readable */
    transform: rotate(calc(var(--r) * 0.4));
    display: block;
    text-decoration: none;
}

/* The species filter hides cards with the hidden attribute, which display: block would override */
.grid .polaroid[hidden] { display: none; }

.grid .polaroid:hover,
.grid .polaroid:focus-visible {
    z-index: 2 !important;
    transform: rotate(0deg) scale(1.08);
}

/* The list of days: a bigger polaroid per day, with the count and the commonest species */
.days { --card: 190px; gap: 34px 22px; }

.days .polaroid .caption { font-size: calc(var(--card) * 0.09); }

.day-info {
    display: block;
    padding: 0 4px calc(var(--card) * 0.06);
    margin-top: calc(var(--card) * -0.03);
    color: #6b6359;
    font: 0.78rem/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    white-space: normal;
}

/* One day: back and next links, and species filters */
.day-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.day-nav .spacer { flex: 1; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.filters button {
    padding: 4px 12px;
    border: 1px solid rgba(239, 228, 210, 0.35);
    border-radius: 999px;
    background: transparent;
    color: var(--wall-text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.filters button[aria-pressed="true"] {
    background: var(--wall-text);
    color: var(--wall);
    border-color: var(--wall-text);
}

.filters button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* The bigger view of one bird */
.viewer {
    max-width: min(92vw, 640px);
    padding: 14px 14px 0;
    border: 0;
    border-radius: 3px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.viewer::backdrop { background: rgba(20, 14, 9, 0.75); }

.viewer figure { margin: 0; }

.viewer img {
    display: block;
    width: min(600px, 86vw);
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
}

.viewer figcaption {
    padding: 10px 4px 16px;
    font: 1.25rem/1.3 var(--handwriting);
    text-align: center;
}

.viewer-close {
    position: absolute;
    top: 4px;
    right: 8px;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 600px) {
    .archive { padding: 6px 10px 0; }
    .cork { padding: 22px 10px 16px; }
    .grid { --card: 120px; gap: 20px 12px; }
    .days { --card: 140px; }
}
