/* tdhs.uk: full-screen adverts for The Dog House Solution. Bricolage Grotesque headings, Inter text, the TDHS lime. */

:root {
    --lime: #D7DF23;
    --ink: #0E0F10;
    --sage: #CBD3C8;
    --white: #fff;
    --text: rgba(255, 255, 255, .86);
    --heading: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
    --body: "Inter", system-ui, sans-serif;
    --ease: cubic-bezier(.16, 1, .3, 1);
    --edge: clamp(24px, 5vw, 80px);
    /* (svh: the screen without the phone's address bar, so the slide isn't hidden behind it) */
    --screen: 100vh;
}

@supports (height: 100svh) {
    :root {
        --screen: 100svh;
    }
}

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

html,
body {
    height: 100%;
}

body {
    font-family: var(--body);
    background: var(--ink);
    color: var(--white);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

img {
    display: block;
    max-width: 100%;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------- the logo */

.logo {
    position: fixed;
    top: clamp(20px, 4vh, 40px);
    left: var(--edge);
    z-index: 10;
    width: clamp(200px, 26vw, 380px);
}

.logo img {
    width: 100%;
    height: auto;
}

/* ---------------------------------------------------------------- the slides
   They sit side by side and snap, so a phone swipes between them (and a trackpad scrolls them). */

.slider {
    display: flex;
    width: 100vw;
    height: var(--screen);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.slider::-webkit-scrollbar {
    display: none;
}

.slider:focus-visible {
    outline: none;
}

.slide {
    position: relative;
    flex: 0 0 100vw;
    height: var(--screen);
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    background: var(--ink);
}

.slide picture {
    position: absolute;
    inset: 0;
}

.slide__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* shading, so the words read on any photo: darker at the bottom left where they sit, and along the top for the logo */
.slide::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to top, rgba(8, 9, 10, .82) 0%, rgba(8, 9, 10, .35) 38%, rgba(8, 9, 10, 0) 65%),
        linear-gradient(to right, rgba(8, 9, 10, .55) 0%, rgba(8, 9, 10, 0) 60%),
        linear-gradient(to bottom, rgba(8, 9, 10, .45) 0%, rgba(8, 9, 10, 0) 22%);
}

.slide__content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1100px;
    padding: 0 var(--edge) calc(clamp(24px, 6vh, 64px) + 64px);
}

/* "01 —— 08" */
.slide__count {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: clamp(16px, 3vh, 28px);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .2em;
    color: rgba(255, 255, 255, .6);
}

.slide__count span {
    color: var(--lime);
}

.slide__count i {
    display: block;
    width: 48px;
    height: 1px;
    background: currentColor;
}

.slide__text h1,
.slide__text h2 {
    font-family: var(--heading);
    font-weight: 700;
    font-size: clamp(2.6rem, 6.4vw, 6.4rem);
    font-variation-settings: "opsz" 96;
    line-height: .96;
    letter-spacing: -.035em;
    text-wrap: balance;
    max-width: 13em;
    margin-bottom: clamp(16px, 3vh, 28px);
}

/* a word or two picked out (italic in the CMS editor) */
.slide__text em {
    font-style: normal;
    color: var(--lime);
}

.slide__text p {
    font-size: clamp(1.05rem, 1.35vw, 1.35rem);
    font-weight: 300;
    line-height: 1.55;
    max-width: 32em;
    color: var(--text);
}

.slide__text p + p {
    margin-top: .75em;
}

.slide__text a,
.slide__link {
    color: var(--white);
    text-decoration: none;
    background: linear-gradient(var(--lime), var(--lime)) 0 100% / 100% 2px no-repeat;
    transition: background-size .35s var(--ease), color .35s var(--ease);
    padding-bottom: 2px;
}

.slide__text a:hover,
.slide__link:hover {
    color: var(--ink);
    background-size: 100% 100%;
}

.slide__link {
    display: inline-block;
    margin-top: clamp(20px, 3vh, 32px);
    font-weight: 500;
}

/* ---------------------------------------------------------------- the progress bar and arrows */

.controls {
    position: fixed;
    left: var(--edge);
    right: var(--edge);
    bottom: clamp(20px, 5vh, 48px);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 40px);
}

.progress {
    flex: 1;
    display: flex;
    gap: 6px;
}

/* (a tall button around a thin line, so it's easy to tap) */
.progress__bar {
    flex: 1;
    height: 24px;
    display: flex;
    align-items: center;
}

.progress__bar span {
    position: relative;
    display: block;
    width: 100%;
    height: 2px;
    overflow: hidden;
    background: rgba(255, 255, 255, .25);
    transition: background-color .3s;
}

.progress__bar:hover span {
    background: rgba(255, 255, 255, .45);
}

.progress__bar span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--lime);
    transform: scaleX(0);
    transform-origin: left;
}

.progress__bar.is-done span::after,
.progress__bar.is-current span::after {
    transform: none;
}

/* while it plays by itself, the current bar fills up until the next slide (site.js sets the time) */
.is-playing .progress__bar.is-current span::after {
    animation: fill var(--slide-time, 6s) linear forwards;
}

@keyframes fill {
    from { transform: scaleX(0); }
    to { transform: none; }
}

.arrows {
    display: flex;
    gap: 10px;
}

.arrow {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(14, 15, 16, .25);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background-color .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease), opacity .3s;
}

.arrow svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.arrow:hover {
    background: var(--lime);
    border-color: var(--lime);
    color: var(--ink);
}

.arrow:disabled {
    opacity: .25;
    pointer-events: none;
}

/* phones swipe, so the arrows make way for the progress bar; the logo spans the screen, between the margins
   (on a phone turned sideways it would be far too big, so there it's the size it is on a desktop) */
@media (max-width: 767px) {
    .logo {
        right: var(--edge);
        width: auto;
    }

    @media (orientation: landscape) {
        .logo {
            right: auto;
            width: clamp(200px, 40vw, 300px);
        }
    }

    .arrows {
        display: none;
    }

    .slide__content {
        padding-bottom: calc(clamp(20px, 5vh, 48px) + 48px);
    }
}

/* ---------------------------------------------------------------- movement
   Each time a slide comes into view (by arrow, swipe, keyboard or by itself) its photo settles slowly, the number
   and line come in, the heading's words rise one after another out of a mask, and the text follows. Leaving a
   slide resets it, so it plays again next time. site.js wraps the heading's words in <span class="word">. */

.js .slide__image {
    transform: scale(1.12);
}

.js .slide.is-current .slide__image {
    transform: none;
    transition: transform 9s cubic-bezier(.2, .6, .3, 1);
}

.word {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    /* (room for descenders, given back so the lines sit as before) */
    padding-bottom: .12em;
    margin-bottom: -.12em;
}

.word > span {
    display: inline-block;
}

.js .slide .word > span {
    transform: translateY(110%) rotate(4deg);
    transform-origin: left bottom;
}

.js .slide.is-current .word > span {
    transform: none;
    transition: transform 1s var(--ease);
    transition-delay: calc(.25s + var(--i, 0) * 70ms);
}

.js .slide .slide__count,
.js .slide .slide__text p,
.js .slide .slide__link {
    opacity: 0;
    transform: translateY(18px);
}

.js .slide.is-current .slide__count,
.js .slide.is-current .slide__text p,
.js .slide.is-current .slide__link {
    opacity: 1;
    transform: none;
    transition: opacity .9s var(--ease), transform .9s var(--ease);
}

.js .slide.is-current .slide__count {
    transition-delay: .1s;
}

.js .slide.is-current .slide__text p {
    transition-delay: calc(.45s + var(--words, 4) * 70ms);
}

.js .slide.is-current .slide__link {
    transition-delay: calc(.6s + var(--words, 4) * 70ms);
}

.js .slide .slide__count i {
    transform: scaleX(0);
    transform-origin: left;
}

.js .slide.is-current .slide__count i {
    transform: none;
    transition: transform 1.2s var(--ease) .3s;
}

@media (prefers-reduced-motion: reduce) {
    .slider {
        scroll-behavior: auto;
    }

    .js .slide .slide__image,
    .js .slide .word > span,
    .js .slide .slide__count,
    .js .slide .slide__count i,
    .js .slide .slide__text p,
    .js .slide .slide__link {
        opacity: 1;
        transform: none !important;
        transition: none !important;
    }
}

/* ---------------------------------------------------------------- the loader (only if the first photo is slow) */

.loader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background: var(--ink);
    transition: opacity .6s ease;
}

.loader.is-done {
    opacity: 0;
    pointer-events: none;
}

.loader__icon {
    width: 80px;
    height: 80px;
    opacity: 0;
    transition: opacity .3s ease;
}

.loader.is-slow .loader__icon {
    opacity: 1;
}

.ring {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transform-origin: 50% 50%;
}

.ring1 {
    stroke: var(--lime);
    stroke-dasharray: 80 140;
    animation: spin 1.6s linear infinite;
}

.ring2 {
    stroke: rgba(255, 255, 255, .4);
    stroke-dasharray: 40 160;
    animation: spin 2.2s linear infinite reverse;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* without JavaScript there's nothing to take it away */
html:not(.js) .loader {
    display: none;
}

/* ---------------------------------------------------------------- other pages (not found, and any section that isn't the slides) */

.panel {
    min-height: var(--screen);
    display: flex;
    align-items: flex-end;
    padding: 140px var(--edge) clamp(40px, 10vh, 120px);
    background: radial-gradient(ellipse at 80% 0%, #24262a 0%, var(--ink) 60%);
}

body:has(.panel) {
    overflow: auto;
}

.panel__inner {
    max-width: 1100px;
}

.panel h1 {
    font-family: var(--heading);
    font-weight: 700;
    font-size: clamp(2.6rem, 6.4vw, 6.4rem);
    line-height: .96;
    letter-spacing: -.035em;
    margin-bottom: 24px;
}

.panel h1 em {
    font-style: normal;
    color: var(--lime);
}

.panel p {
    font-size: clamp(1.05rem, 1.35vw, 1.35rem);
    font-weight: 300;
    line-height: 1.55;
    color: var(--text);
    max-width: 32em;
}

.panel a {
    color: var(--white);
    text-decoration: none;
    background: linear-gradient(var(--lime), var(--lime)) 0 100% / 100% 2px no-repeat;
}

.content > * + * {
    margin-top: 1em;
}
