/* sheepi.sh — one stylesheet for every page.
 *
 * Tokens, type and page chrome come from the landing page; the film-strip
 * and lightbox rules are only used by photography.html but live here so
 * there is a single place to change anything.
 *
 * Images are never colour-dimmed. Photographs show their own colour.
 */

@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Caveat:wght@400;700&family=Cinzel+Decorative:wght@400;700&family=Cormorant+Garamond:wght@400;500;600;700&family=Old+Standard+TT:wght@400;700&family=Orbitron:wght@400;500;700&family=Patrick+Hand&family=Rock+Salt&family=Special+Elite&family=Uncial+Antiqua&display=swap');


/* ---------- tokens ---------- */

:root {
    --page-bg: #111;
    --panel-bg: rgba(255, 255, 255, 0.04);
    --ink: #f9f0d1;
    --gold: #d4af37;

    /* 35mm, to scale. The film is 35mm wide and a frame is 24mm tall, so the
       two perforation bands are (35-24)/2 = 5.5mm each. The frame is 36mm
       wide on a 38mm pitch, and Kodak KS-1870 perfs run at 4.75mm -- which
       is why there are exactly EIGHT perforations per frame. Everything
       derives from --mm, so changing that one number rescales the whole
       contact sheet correctly. */
    --mm: 4.9px;
    --frame-h: calc(24 * var(--mm));
    --frame-w: calc(36 * var(--mm));
    --gap: calc(2 * var(--mm));
    --pitch: calc(4.75 * var(--mm));
    --band: calc(5.5 * var(--mm));

    --base: #14120f;   /* film base */
    --perf: #e8dcc0;   /* light through the sprocket holes */
}


/* ---------- page chrome ---------- */

body {
    font-family: 'Georgia', serif;
    font-size: 17px;
    line-height: 1.5;
    background: var(--page-bg);
    color: var(--ink);
    margin: 20px;
}

.topbar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.brand {
    font-family: 'Caveat', cursive;
    font-size: clamp(2.6rem, 5vw, 5rem);
    line-height: 1;
    letter-spacing: 0.06em;
    margin: 0;
    font-weight: 700;
    color: var(--ink);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.topbar .nav {
    margin-left: 22px;
    font-size: 13px;
    letter-spacing: 0.1em;
    color: var(--gold);
    text-decoration: none;
    opacity: 0.8;
}

.topbar .nav:hover {
    opacity: 1;
}

.intro {
    margin: 0 0 34px;
    max-width: 60ch;
    opacity: 0.75;
}


/* ---------- the art gallery (index.html) ---------- */

.artbox {
    position: relative;
    display: inline-block;
    width: var(--w, 600px);
    float: left;
    margin: 0 14px 14px 0;
    padding: 14px;
    background: linear-gradient(135deg, rgba(212,175,55,0.22), rgba(255,240,180,0.08));
    border: 2px solid #d8b04e;
    box-shadow:
        0 0 0 2px rgba(130, 96, 20, 0.75),
        0 0 0 6px rgba(212, 175, 55, 0.18),
        inset 0 0 0 2px rgba(255, 228, 128, 0.38),
        inset 0 0 18px rgba(0, 0, 0, 0.45);
    line-height: 0;
}

.artbox::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(255, 219, 114, 0.8);
    pointer-events: none;
}

.artbox img {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;

    /* inline placeholder sits exactly behind the image, never the frame */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

div.artbox {
    margin-right: 50px !important;
    margin-bottom: 50px !important;
}

.artbox .caption {
    display: block;
    margin-top: 8px;
    line-height: 1.2;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: #f3d992;
    text-align: left;
}

.artbox .caption a {
    color: inherit;
    text-decoration: none;
    font-style: italic;
    font-weight: inherit;
}

/* once the real image has decoded, stop nearest-neighbour scaling. This is
   the only thing is-ready does now -- the artwork is never desaturated. */
.artbox.is-ready img {
    image-rendering: auto;
}


/* ---------- a roll (photography.html) ---------- */

.roll {
    margin-bottom: 54px;
}

.roll-head {
    border-bottom: 1px solid rgba(212, 175, 55, 0.28);
    padding-bottom: 8px;
    margin-bottom: 22px;
}

.roll-head h2 {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 2rem;
    margin: 0;
    letter-spacing: 0.03em;
}

.roll-meta {
    font-family: 'Special Elite', monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0.8;
    margin-top: 2px;
}

.roll-blurb {
    margin: 8px 0 0;
    font-size: 14px;
    opacity: 0.7;
}

/* a subsection within a roll */
.group-head {
    font-family: 'Special Elite', monospace;
    font-size: 12px;
    font-weight: normal;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 26px 0 10px;
    opacity: 0.9;
}

.group-head::before {
    content: "— ";
    opacity: 0.5;
}


/* ---------- the film strip ---------- */

.strip {
    position: relative;
    display: inline-block;
    background-color: var(--base);
    /* Sprocket holes, drawn in millimetres so they scale with --mm: one
       4.75mm tile, perf 2.79 x 1.98mm, tiled at exactly the frame pitch so 8
       land per frame. Each row is pushed to the OUTER edge of its band, which
       leaves the inner ~2.9mm clear for the edge printing and frame numbers
       -- exactly where real film puts them. */
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4.75' height='5.5' viewBox='0 0 4.75 5.5'%3E%3Crect x='0.98' y='0.6' width='2.79' height='1.98' rx='0.55' fill='%23e8dcc0'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4.75' height='5.5' viewBox='0 0 4.75 5.5'%3E%3Crect x='0.98' y='2.92' width='2.79' height='1.98' rx='0.55' fill='%23e8dcc0'/%3E%3C/svg%3E");
    background-repeat: repeat-x, repeat-x;
    background-position: left top, left bottom;
    background-size: var(--pitch) var(--band), var(--pitch) var(--band);
    padding: var(--band) calc(var(--gap) / 2);
    margin: 0 0 16px 0;
    max-width: 100%;
    /* never let a strip push the page sideways on a narrow screen */
    overflow-x: auto;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.6);
}

/* film stock / roll name, printed along the top edge like real film */
.strip::before {
    content: attr(data-edge);
    position: absolute;
    /* in the clear inner part of the top band, left edge lined up with the
       first frame rather than floating at an arbitrary offset */
    top: calc(var(--band) - 13px);
    left: calc(var(--gap) / 2);
    font-family: 'Special Elite', monospace;
    font-size: 9px;
    letter-spacing: 0.3em;
    color: #c8892f;
    opacity: 0.85;
    pointer-events: none;
}

.frames {
    display: flex;
    gap: var(--gap);
    align-items: center;
}

.frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* every frame is the same 36x24mm gate, whichever way the camera was
       held -- a vertical shot just leaves film base either side */
    width: var(--frame-w);
    height: var(--frame-h);
    padding: 0;
    border: 0;
    background: #000;
    cursor: pointer;
    flex: 0 0 auto;
    line-height: 0;
    /* deliberately NOT overflow:hidden -- the frame number sits outside the
       gate, down in the sprocket band. The img is bounded by max-width and
       max-height, so nothing can spill anyway. */
}

.frame img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;

    /* the inline placeholder sits behind, so the slot has colour before the
       thumbnail lands. No filter here: the scan shows its own colour. */
    background-size: cover;
    background-position: center;
    transition: filter 180ms ease;
}

.frame:hover img,
.frame:focus-visible img {
    filter: brightness(1.08);
}

.frame:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* frame number, printed down in the sprocket band like real film */
.frame::after {
    content: attr(data-no);
    position: absolute;
    /* clear inner part of the bottom band, above the sprocket row */
    bottom: calc(-1 * var(--band) + 15px);
    left: 1px;
    font-family: 'Special Elite', monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
    color: #c8892f;
    line-height: 1;
}


/* ---------- lightbox ---------- */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 8, 0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 130px);
    object-fit: contain;
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
}

.lb-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 14px;
    font-family: 'Special Elite', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--ink);
    opacity: 0.85;
}

.lb-bar a {
    color: var(--gold);
    text-decoration: none;
}

.lb-bar a:hover {
    text-decoration: underline;
}

.lb-caption {
    font-family: 'Georgia', serif;
    font-style: italic;
    letter-spacing: 0;
}

.lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    color: var(--ink);
    font-size: 40px;
    opacity: 0.4;
    cursor: pointer;
    padding: 20px;
    line-height: 1;
}

.lb-nav:hover {
    opacity: 1;
}

.lb-prev { left: 4px; }
.lb-next { right: 4px; }

.lb-close {
    position: absolute;
    top: 10px;
    right: 16px;
    background: none;
    border: 0;
    color: var(--ink);
    font-size: 30px;
    opacity: 0.5;
    cursor: pointer;
    line-height: 1;
}

.lb-close:hover {
    opacity: 1;
}


/* ---------- narrow screens ---------- */

@media (max-width: 700px) {
    :root { --mm: 3.6px; }

    body { margin: 12px; }
}
