/* Deliberately close to the original site: centred pink title, Tahoma, a grid of thumbnails
   with captions underneath, three clicks from the front page to a picture. The differences are
   that it reflows on a phone instead of being a fixed five-column table, and the tidy rows come
   from CSS rather than from black bars baked into 40,000 thumbnail files. */

:root {
    --pink: #ff4fa3;
    --ink: #1a1a1a;
    --muted: #6b6b6b;
    --line: #e3e3e3;
    --page: #ffffff;
    --tile: #fafafa;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #ececec;
        --muted: #a0a0a0;
        --line: #333333;
        --page: #141414;
        --tile: #1d1d1d;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 1rem 3rem;
    background: var(--page);
    color: var(--ink);
    font-family: Tahoma, Verdana, Geneva, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; }

/* ---------------------------------------------------------------- header */

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 0 1rem;
    border-bottom: 2px solid var(--line);
}

.site-title {
    font-family: "Arial Black", Arial, sans-serif;
    font-size: 1.6rem;
    letter-spacing: 0.02em;
    color: var(--pink);
    text-decoration: none;
}

.search { display: flex; gap: 0.4rem; }

.search input {
    font: inherit;
    padding: 0.4rem 0.6rem;
    min-width: 15rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--page);
    color: var(--ink);
}

.search button {
    font: inherit;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--pink);
    border-radius: 4px;
    background: var(--pink);
    color: #fff;
    cursor: pointer;
}

/* ---------------------------------------------------------------- crumbs */

.crumbs {
    max-width: 1200px;
    margin: 0.85rem auto 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 0.4rem; }

/* ---------------------------------------------------------------- content */

main { max-width: 1200px; margin: 0 auto; }

h1 {
    font-size: 1.35rem;
    font-weight: normal;
    margin: 1.25rem 0 0.25rem;
}

/* The search page's two halves - events first, then individual captions. The rule above each
   heading is what keeps them from reading as one long undifferentiated wall of thumbnails. */
.results + .results {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.results h2 {
    font-size: 1.05rem;
    font-weight: normal;
    color: var(--pink);
    margin: 1.5rem 0 0.25rem;
}

.subtitle { margin: 0 0 1rem; }
.muted { color: var(--muted); font-size: 0.8rem; }
.empty { color: var(--muted); padding: 1.5rem 0; }

/* ---------------------------------------------------------------- the grid */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1.25rem;
    margin: 1.25rem 0;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
}

.tile-image {
    /* A fixed aspect box with object-fit is what replaces the old black letterbox padding.
       Same tidy rows, nothing burned into the files, and the layout can change later. */
    aspect-ratio: 4 / 3;
    background: var(--tile);
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tile-image img.video-icon {
    width: auto;
    height: auto;
    max-width: 60%;
    max-height: 60%;
    object-fit: contain;
}

/* A video's real frame fills the tile like a photo, so a play button is what marks it as a
   video. Hidden while the movie.png fallback is showing, which already says "video". */
.tile-image { position: relative; }

.play-badge {
    position: absolute;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
    pointer-events: none;
}

.play-badge::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 0.6rem 0 0.6rem 1rem;
    border-color: transparent transparent transparent #fff;
}

.video-icon + .play-badge { display: none; }

.tile:hover .tile-image { border-color: var(--pink); }

.tile-caption {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- editing */

.editing-banner {
    background: var(--pink);
    color: #fff;
    text-align: center;
    padding: 0.4rem 1rem;
    margin: 0 -1rem;
    font-size: 0.85rem;
}

/* The edit boxes deliberately look almost exactly like the text they replace - same font, same
   size, no chrome until touched. Captioning 40,000 pictures should feel like typing on the page,
   not like filling in a form. */
[data-edit] {
    font: inherit;
    color: inherit;
    width: 100%;
    padding: 0.15rem 0.25rem;
    border: 1px dashed var(--line);
    border-radius: 3px;
    background: transparent;
    resize: vertical;
    overflow: hidden;
}

h1 [data-edit] { font: inherit; }

.tile-caption [data-edit] { font-size: 0.82rem; }

[data-edit]:hover { border-color: var(--muted); }

[data-edit]:focus {
    outline: none;
    border-style: solid;
    border-color: var(--pink);
    background: var(--page);
    overflow: auto;
}

[data-edit].saving { border-color: var(--muted); opacity: 0.6; }
[data-edit].saved { border-color: #2e9e4f; border-style: solid; }
[data-edit].failed { border-color: #c62828; border-style: solid; background: rgba(198, 40, 40, 0.08); }

/* In edit mode the tile is a plain div and only the image is a link, so these two carry the
   layout the <a class="tile"> rule provides the rest of the time. */
.tile-shot { display: block; text-decoration: none; color: inherit; }
.tile:hover .tile-image { border-color: var(--pink); }

/* The tile currently representing its event or year.
   Deliberately NOT pink: hover is pink, and the site's whole palette is pink, so a pink "chosen"
   marker was near-invisible among it. Ink is the one colour nothing else here uses for state,
   and it inverts correctly in dark mode. */
.tile.is-chosen .tile-image { border-color: var(--ink); border-width: 2px; }

/* Currently representing its event or year, but only because it is the first one - nobody has
   chosen it. Dashed says "this is what is showing, and it could move on its own". */
.tile.is-default .tile-image { border-color: var(--muted); border-width: 2px; border-style: dashed; }

.promote {
    font: inherit;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    align-self: flex-start;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.promote:hover { border-color: var(--pink); color: var(--ink); }
.promote .star { font-size: 0.9rem; line-height: 1; }

/* Chosen reads as ink and bold, so "this is the one" is legible at a glance against a grid of
   grey offers. Pink is reserved for hover, which is a transient state, not a stored one. */
.promote.chosen {
    border-color: var(--ink);
    color: var(--ink);
    font-weight: bold;
}
/* The defaulted one: filled star so you can see what is being used, but grey and dashed rather
   than ink and bold, because nobody actually picked it. */
.promote.defaulted {
    border-color: var(--muted);
    border-style: dashed;
    color: var(--muted);
}

.promote.failed { border-color: #c62828; color: #c62828; }
.promote:disabled { opacity: 0.5; cursor: default; }

/* Videos and empty events cannot be promoted - they have no thumbnail to promote. Shown rather
   than hidden, so the absence of a button never looks like something failed to render. */
.promote-na {
    font-size: 0.75rem;
    color: var(--muted);
    align-self: flex-start;
    padding: 0.15rem 0;
}

.signin {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 20rem;
    margin: 1.5rem 0;
}

.signin label { display: flex; flex-direction: column; gap: 0.25rem; }

.signin input {
    font: inherit;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--page);
    color: var(--ink);
}

.signin button {
    font: inherit;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--pink);
    border-radius: 4px;
    background: var(--pink);
    color: #fff;
    cursor: pointer;
    align-self: flex-start;
}

.form-error {
    color: #c62828;
    border-left: 3px solid #c62828;
    padding-left: 0.6rem;
}

.inline-form { display: inline; }

.linkish {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------------------------------------------------------------- footer */

footer {
    max-width: 1200px;
    margin: 2.5rem auto 0;
    padding-top: 1rem;
    border-top: 2px solid var(--line);
    text-align: center;
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .site-header { justify-content: center; text-align: center; }
    .search input { min-width: 0; flex: 1; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.9rem; }

    /* iOS Safari zooms the whole page when a text field smaller than 16px takes focus, and it
       does not zoom back out afterwards. Captioning on a phone is the main way this feature will
       ever be used, so the boxes are full size there even though the caption text around them
       is not. */
    [data-edit], .signin input { font-size: 16px; }
}
