html {
    padding: 80px;
    padding-top: 40px;
}

body {
    display: block;
    margin: 0px auto;

    /* shared.css pins body to 100dvh for the home page's fixed-hero layout.
       This is a long scrolling page, so it has to grow with its content -
       otherwise the scroll extent stops a screen short and the bottom clips. */
    height: auto;
}

header,
printwrap,
purchasepanel {
    transition: filter 0.6s ease;
}

html.menu-open header,
html.menu-open printwrap,
html.menu-open purchasepanel,
html.purchase-open header,
html.purchase-open printwrap {
    filter: blur(5px) brightness(65%);
}

html.purchase-open::before {
    filter: blur(5px) brightness(65%);
}

html.purchase-open printwrap {
    pointer-events: none;
}

/* Set on the root, so it applies to the viewport itself: kills pull-to-refresh
   and scroll chaining while the screen is open. purchasescreen has its own
   overscroll-behavior, but a drag starting on #purchase-close never touches
   it - that button sits in purchasepanel, outside the scroller. */
html.purchase-open {
    overscroll-behavior: none;
}

header {
    max-width: 1250px;
    margin: 0 auto;
}

h1 {
    color: var(--secondary);
    border-bottom: solid 2px var(--primary);
    padding: 24px;
    padding-top: 0px;
}

h2 {
    color: var(--secondary);
    font-size: 32px;
}

price {
    color: var(--secondary);
    font-size: 20px;
}

.price-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

purchasetitle {
    display: block;
    color: var(--secondary);
    font-size: 32px;
    font-weight: 700;
    padding-bottom: 16px;
}

printwrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 96px;
    width: 100%;
    max-width: 1250px;
    margin: 0 auto;
    padding-bottom: 48px;
}

.image-frame {
    display: grid;
    padding: 24px;
}

card > .image-frame {
    flex-grow: 1;
    padding: 12px;
}

.image-frame > img {
    grid-area: 1 / 1;
    width: 100%;
    height: auto;
    border: solid var(--frame-border, 12px) #FFFFFF;
    border-radius: 0px;
}

.image-frame.stacked {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-frame.stacked > img {
    width: 46%;
    flex-shrink: 0;
}

.image-frame.stacked > img:nth-child(1) {
    order: 1;
    margin-right: -20%;
    transform: translateY(16px);
}

.image-frame.stacked > img:nth-child(2) {
    order: 3;
    margin-left: -20%;
    transform: translateY(16px);
}

.image-frame.stacked > img:last-child {
    order: 2;
    z-index: 1;
}

card {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    padding: 24px 0px;
    min-width: 0;
    transition: opacity 0.4s ease;
}

card.lifted {
    opacity: 0;
}

img {
    width: 100%;
    height: min-content;
    border-radius: 12px;
}

button {
    position: relative;
    background-color: var(--primary);
    color: var(--background);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    padding: 12px;
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

/* prints only: the purchase screen dims its backdrop too, so the icon goes
   white for that state as well. */
html.purchase-open menu > img {
    filter: none;
}

purchasepanel {
    position: fixed;
    inset: 0px;
    height: 100dvh;
    z-index: 7;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

purchasescreen {
    position: relative;
    border: solid 2px var(--primary);
    border-radius: 12px;
    width: 70%;
    height: 80%;
    max-height: 450px;
    max-width: 800px;
    overflow: hidden;

    display: flex;
    flex-direction: row;
    justify-content: start;
    background-color: var(--background);

    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;

    visibility: hidden;
    transition: opacity 0.4s ease,
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                translate 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                scale 0.25s ease,
                border-radius 0.25s ease,
                visibility 0s linear 0.5s;
}

/* While a drag is in progress, translate has to track the finger exactly, so
   it gets no transition - but scale still does, so the shrink past the dismiss
   threshold eases in and out instead of snapping. That's the whole reason the
   drag uses the individual translate/scale properties rather than the
   transform shorthand: one shorthand can't be part-transitioned.
   Specificity has to beat the rule below, which also sets transition. */
html.purchase-open purchasescreen.dragging {
    transition: scale 0.25s ease,
                border-radius 0.25s ease;
}

/* Armed to dismiss: mobile strips the radius for the full-bleed layout, so
   putting it back is what sells the screen lifting away from the edges. Rides
   the same threshold as the shrink. */
html.purchase-open purchasescreen.dismissing {
    border-radius: 12px;
}

html.purchase-open purchasescreen {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;

    visibility: visible;
    transition: opacity 0.4s ease,
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                translate 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                scale 0.25s ease,
                border-radius 0.25s ease,
                visibility 0s linear 0s;
}

#purchase-frame {
    width: 45%;
    height: 100%;
    flex-shrink: 0;
    align-content: center;
}

#purchase-frame > .bundle-extra {
    display: none;
}

#purchase-frame.stacked > .bundle-extra {
    display: block;
}

#purchase-close {
    position: absolute;
    z-index: 2;

    box-sizing: content-box;
    width: 24px;
    height: 24px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;

    /* x.svg is white artwork; with the postcard frame this now sits on cream
       rather than on the photo. Mobile flips it back - see the media query. */
    filter: invert(1);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

html.purchase-open #purchase-close {
    opacity: 1;
    pointer-events: auto;
}

purchasedetails {
    background-color: var(--background);
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 24px;
    overflow: scroll;
}

#link-authentication-element {
    margin-bottom: 12px;
}

#payment-element {
    margin-top: 12px;
}

#border-options {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

/* Unknown element, so block - vertical padding does nothing while inline. */
disclaimer {
    display: block;
    color: var(--secondary);
    font-size: 12px;
    padding: 6px 0px 16px 0px;
}

/* shared.css sizes a for the menu overlay - clamp(1rem, 10dvw, 5rem) - so the
   size has to be pulled back to the disclaimer's own. */
disclaimer > a {
    color: var(--primary);
    font-size: inherit;
}

/* The blanket `display: block` above beats the user agent's [hidden] rule, so
   it has to be restated. Without this the test-mode notice shows in live. */
disclaimer[hidden] {
    display: none;
}

/* Loud on purpose - this is the only thing distinguishing a real checkout from
   one that takes no money. */
#test-mode {
    margin: 0px 0px 12px 0px;
    padding: 8px 12px;
    border: 1px solid var(--secondary);
    color: var(--secondary);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
}

disclaimer.footer {
    max-width: 1250px;
    margin: 0 auto;
    padding: 0px 24px 48px 24px;
    text-align: center;
}

#border-options > button {
    flex: 1;
    padding: 8px;
    color: var(--secondary);
    border: solid 1px var(--secondary);
    background-color: transparent;
}

#border-options > button.selected {
    border-width: 3px;
}

#payment-message {
    font-size: 16px;
    padding-top: 12px;
    color: var(--secondary);
}

#payment-message.error {
    color: #B3261E;
}

#submit {
    background-color: var(--primary);
    color: var(--background);
    border: solid 1px var(--primary);
    width: 100%;
    margin-top: 16px;
}

/* Processing / done states.
   Ring and tick are SVG strokes rather than a CSS border, because arc length
   can only be animated through stroke-dashoffset. Both carry pathLength="1",
   which normalises their length so the dash values are plain fractions instead
   of computed circumferences. */
#submit.processing {
    background-color: color-mix(in srgb, var(--primary) 55%, var(--background));
    border-color: color-mix(in srgb, var(--primary) 55%, var(--background));
}

#submit > .label {
    transition: opacity 0.12s ease;
}

#submit.processing > .label,
#submit.done > .label,
#submit.failed > .label {
    opacity: 0;
}

.submit-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0px 0px -11px;

    fill: none;
    stroke: var(--background);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;

    opacity: 0;
}

#submit.processing .submit-icon,
#submit.done .submit-icon,
#submit.failed .submit-icon {
    opacity: 1;
}

/* All three start with zero visible length.
   visibility matters as much as the dash here: stroke-linecap: round still
   paints its caps on a zero-length dash, so an "invisible" stroke shows up as
   a dot. Each shape stays hidden until its own animation runs, and the
   keyframes below carry the visibility with them. */
.submit-icon .ring,
.submit-icon .tick,
.submit-icon .cross {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    visibility: hidden;
}

/* Only the ring spins - the tick sits outside this group, so it draws upright
   while the ring is still turning underneath it. */
#submit.processing .ring-spin,
#submit.done .ring-spin,
#submit.failed .ring-spin {
    transform-origin: 50% 50%;
    animation: submit-spin 0.8s linear infinite;
}

#submit.processing .ring {
    animation: ring-grow 0.6s ease forwards;
}

#submit.done .ring,
#submit.failed .ring {
    animation: ring-shrink 0.3s ease forwards;
}

/* Starts just before the ring finishes collapsing, so it reads as one shape
   becoming the other rather than two separate steps. The cross is a single
   path with two subpaths, so the dash sweeps through one stroke and then the
   other rather than drawing both at once. */
#submit.done .tick,
#submit.failed .cross {
    animation: draw-stroke 0.3s ease 0.16s forwards;
}

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

/* visibility is special-cased when animated: if either end is visible, it
   stays visible across the whole interval and only flips at the very end. So
   ring-shrink keeps the ring on screen while it collapses and hides it exactly
   when it hits zero, instead of leaving a spinning cap behind. */
@keyframes ring-grow {
    from {
        stroke-dashoffset: 1;
        visibility: visible;
    }
    to {
        stroke-dashoffset: 0.25;
        visibility: visible;
    }
}

@keyframes ring-shrink {
    from {
        stroke-dashoffset: 0.25;
        visibility: visible;
    }
    to {
        stroke-dashoffset: 1;
        visibility: hidden;
    }
}

@keyframes draw-stroke {
    from {
        stroke-dashoffset: 1;
        visibility: visible;
    }
    to {
        stroke-dashoffset: 0;
        visibility: visible;
    }
}

@media screen and (max-width: 1200px) {
    printwrap {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 600px) {
    html {
        padding: 28px;
    }

    h1 {
        padding: 12px;
        padding-bottom: 24px;
        margin-bottom: 24px;
    }

    h2 {
        font-size: 24px;
    }

    printwrap {
        grid-template-columns: 1fr;
        gap: 80px;
    }

    card {
        padding: 0px 0px;
    }

    purchasescreen {
        overscroll-behavior: none;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        flex-direction: column;
        overflow: scroll;
        border-radius: 0px;
        border: none;
    }

    #purchase-frame {
        width: 100%;
        height: auto;
        flex-shrink: 0;
    }

    html.purchase-open menu > img {
        filter: invert(1);
    }

    html.menu-open menu > img {
        filter: none;
    }

    purchasedetails {
        height: auto;
        overflow: visible;
    }

    .image-frame {
        padding-top: 56px;
    }
}

/* Debug controls, injected by prints.js only in test mode. Dashed so they
   don't read as real UI. */
#test-failures {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 16px;
}

#test-failures > button {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 400;
    border: dashed 1px var(--background);
    border-radius: 6px;

    background-color: var(--secondary);
    color: var(--background);
}
