/* tobybush.co.uk: full-screen photos with a name card over them, and a 404 to match.
   Outfit for the words; Fraunces only for the 404's big titles. Black and white, no accent colour. Written by hand,
   no build step. */

:root {
    --ink: #111;
    --paper: #fbfaf7;
    --muted: #5f5c57;
    --card: rgba(251, 250, 247, .86);

    --sans: "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
    --serif: "Fraunces", Georgia, "Times New Roman", serif;

    --edge: clamp(16px, 3.5vw, 44px);
    --ease: cubic-bezier(.22, .61, .36, 1);
}

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

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--ink);
    color: var(--ink);
    font: 300 1rem/1.6 var(--sans);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a { color: inherit; }

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- the photos */

.photos { position: fixed; inset: 0; background: var(--ink); }

.photo { position: absolute; inset: 0; margin: 0; opacity: 0; transition: opacity 2.6s ease; }
.photo.is-on { opacity: 1; z-index: 1; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* the photo settles slowly while it's on, and carries on while it fades out (is-leaving), so it doesn't jump */
.photo.is-on img, .photo.is-leaving img { animation: settle 26s linear both; }
@keyframes settle { from { transform: scale(1.09); } to { transform: scale(1); } }

/* ---------------------------------------------------------------- the name card */

.card {
    position: fixed; z-index: 10; top: var(--edge); left: var(--edge);
    width: min(340px, calc(100vw - 2 * var(--edge)));
    background: var(--card);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
            backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .16);
    animation: arrive 1.2s var(--ease) .3s both;
}
@keyframes arrive { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.card__head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 22px; }

.card h1, .card h2, .card h3 {
    margin: 0; font: 500 1.1rem/1 var(--sans); letter-spacing: -.05em; color: #606060;
}

/* the toggle covers the head, so the whole name opens the card; a thin + on the right, turning to a - */
.card__toggle { position: absolute; inset: 0; width: 100%; border: 0; background: none; cursor: pointer; }
.card__toggle::before, .card__toggle::after {
    content: ""; position: absolute; right: 24px; top: 50%; width: 13px; height: 1px;
    background: var(--ink); transition: transform .4s var(--ease);
}
.card__toggle::after { transform: rotate(90deg); }
.card.is-open .card__toggle::after { transform: rotate(0); }

/* the rest of the words open below the name */
.card__more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .55s var(--ease); }
.card.is-open .card__more { grid-template-rows: 1fr; }
.card__inner { overflow: hidden; padding: 0 22px; }
.card__inner > :last-child { margin-bottom: 20px; }
.card__inner > * { opacity: 0; transform: translateY(-4px); transition: opacity .3s ease, transform .4s var(--ease); }
.card.is-open .card__inner > * { opacity: 1; transform: none; transition-delay: .15s; }

.prose { color: var(--muted); font-size: .95rem; }
.prose p, .prose ul { margin: 0 0 .6em; }
.prose ul { list-style: none; padding: 0 0 .9em; }
.prose li { font-size: .85rem; margin-bottom: .15em; }
.prose a { color: var(--ink); text-decoration: none; border-bottom: 1px solid rgba(17, 17, 17, .35); transition: border-color .2s; }
.prose a:hover { border-bottom-color: var(--ink); }

/* without JavaScript: the card's words are always shown */
html:not(.js) .card__more { grid-template-rows: 1fr; }
html:not(.js) .card__inner > * { opacity: 1; transform: none; }
html:not(.js) .card__toggle { display: none; }
html:not(.js) noscript .photo { opacity: 1; }

/* ---------------------------------------------------------------- page not found (and the error page) */

body.is-lost { overflow: auto; background: #0c0c0c; color: var(--paper); }

/* a little film grain over everything */
body.is-lost::before {
    content: ""; position: fixed; inset: -50%; z-index: 0; pointer-events: none; opacity: .09;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
    0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); }
    60% { transform: translate(-4%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

.lost {
    position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh;
    display: grid; align-content: center; justify-items: center; gap: 8px;
    padding: var(--edge); text-align: center;
}

/* the 404, with the photo drifting through its letters */
.lost__code {
    margin: 0;
    font: 900 clamp(6rem, 44vw, 34rem)/.8 var(--serif); font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 1;
    letter-spacing: -.06em;
    /* (the tightened spacing leaves room on the right; this evens it up so it's truly centred) */
    margin-right: -.06em;
    color: #2a2a2a;
    background: var(--photo, linear-gradient(120deg, #3a3a3a, #8a8a8a, #3a3a3a)) center / cover;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: drift 30s ease-in-out infinite alternate, appear 1.6s var(--ease) both;
}
@keyframes drift { from { background-position: 20% 30%; background-size: 140%; } to { background-position: 80% 70%; background-size: 115%; } }
@keyframes appear { from { opacity: 0; transform: scale(.96); filter: blur(12px); } to { opacity: 1; transform: none; filter: none; } }

.lost__text { max-width: 30rem; margin-top: clamp(8px, 2vw, 24px); animation: appear 1.2s var(--ease) .5s both; }
.lost h1 { margin: 0 0 .35em; font: italic 400 clamp(2rem, 4vw, 3rem)/1 var(--serif); }
.lost__text p { color: rgba(251, 250, 247, .65); text-wrap: balance; }

.lost__back { display: inline-flex; align-items: center; gap: .6em; color: var(--paper); text-decoration: none; border-bottom: 1px solid rgba(251, 250, 247, .4); padding-bottom: 3px; transition: border-color .2s; }
.lost__back::before { content: "←"; transition: transform .3s var(--ease); }
.lost__back:hover { border-bottom-color: var(--paper); }
.lost__back:hover::before { transform: translateX(-4px); }

/* ---------------------------------------------------------------- anything else (a page without a slide show) */

.panel { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: var(--edge); background: var(--paper); }
.panel__inner { max-width: 40rem; }

/* ---------------------------------------------------------------- less motion */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition-duration: .01s !important; transition-delay: 0s !important; }
}
