/********* basics ***********/
@import url('https://fonts.cdnfonts.com/css/amazon-ember');

:root {
    --ok: 120, 80%, 50%;
    --danger: 0, 80%, 50%;
    --warning: 40, 80%, 50%;
    --fg: 0, 0%, 0%;
    --bg: 0, 0%, 100%;
    --shade: 0, 0%, 90%;
    --shade-strong: 0, 0%, 70%;

    --small-size: 0.8em;

    interpolate-size: allow-keywords;
}

* {
    font-family: "Amazon Ember", sans-serif;
}

@media (prefers-reduced-motion: no-preference) {
    .animatable, tbody > tr, div, span, img, ul {
        transition-duration: 0.2s;
        transition-timing-function: ease-out;
    }
}

html, body {
    min-height: 100vh;
}

body {
    background-color: hsl(var(--bg));
    color: hsl(var(--fg));
    font-size: 12px;
    margin: 0;
    --gap: 1em !important;
}

#main-wrapper {
    flex: 1 0 auto;
}

main {
    padding: 0.5em 2em;

    & > #content {
        margin-block: 1em;
    }
}

h2 {
    color: var(--acc1);
}

a {
    color: hsl(var(--fg));

    &.no-underline {
        text-decoration: none;
    }
}

.accent {
    color: var(--acc1);
}

img {
    &.thumbnail {
        max-width: calc(100% - 6px);
        object-fit: contain;
    }
    &.inline {
        height: 1em;
    }
}
.thumbnail, .thumbnail-wrapper, .tippy-popper img {
    height: 15em;
}

h2, h4 {
    margin-top: 1em;
    margin-bottom: 0.5em;
}
h3 {
    margin-top: 1.5em;
    margin-bottom: 0.15em;
}
h1, p, ul {
    margin-block: 0.5em;

    &:first-child {
        margin-top: 0;
    }
}
p:first-of-type {
    margin-top: 0;
}

.hidden {
    display: none !important;
}


header h1,
footer h2 {
    margin: 0;
}

.padded,
input, textarea, select,
aside ul > :not(ul),
button, .button-like,
.alert,
.actions,
#category-dropdown ul li {
    padding: 0.5em 1em;
}

/* round corners */
.rounded,
main,
search,
button, .button-like:not(#top-nav .button-like, .tabs .button-like),
.tiling > *, .listing > *,
ul > *,
aside,
input, textarea, select {
    border-radius: 0.5rem;
}

/* borders */
.framed,
aside {
    border: 1px solid hsl(var(--shade));
}

/*********** colors ***********/
div.ghost, li.ghost, a.ghost, td.ghost {
    opacity: 0.5;
}
small.ghost, span.ghost, p.ghost, h4.ghost, h3.ghost, h2.ghost {
    color: hsla(var(--fg), 0.4);
}
.ok {
    color: hsl(var(--ok));
}
.warning {
    color: hsl(var(--warning));
}
.danger {
    color: hsl(var(--danger));
}

/*********** flexing ***********/
.flex-down, .flex-right, .grid {
    --gap: 0.5em;
    gap: var(--gap);

    &.grid {
        display: grid;
    }

    .no-gap {
        --gap: 0;
    }

    &.flex-down, &.flex-right {
        display: flex;

        &.wrap {
            flex-wrap: wrap;
        }

        &.flex-down {
            flex-direction: column;
            &.center {
                align-items: center;
            }
            &.middle {
                justify-content: center;
            }
        }

        &.flex-right {
            &.center {
                justify-content: center;
            }
            &.middle {
                align-items: center;
            }
            &.spread {
                justify-content: space-between;
            }
        }
        &.center-both {
            justify-content: center;
            align-items: center;
        }
    }
}

/* spacing */
#main-wrapper, #header-wrapper,
#category-dropdown > #columns, nav.flex-right:not([role="pagination"]) {
    --gap: 0;
}

.max-width-wrapper {
    width: calc(100vw - 3rem);
    max-width: calc(1920px * 2 / 3 - 3rem);
    margin-inline: auto;
}

/*********** big things ***********/
#header-wrapper {
    position: static;
    z-index: 5;
    top: -10em;
    background-color: hsl(var(--bg));
    width: 100%;

    &.visible {
        position: sticky;
        top: 0;
    }
}

header {
    background-color: hsl(var(--shade));
    padding-block: 1em;

    & .max-width-wrapper {
        align-items: center;
        --gap: 5vw !important;

        & > div:first-child {
            --gap: 2em;
        }

        & > :first-child, & > :last-child {
            width: 250px;
            overflow: visible;
        }

        & > :last-child {
            justify-content: right;
        }
    }

}

search {
    width: 40vw;
    background-color: hsl(var(--bg));

    & input {
        border: none;
        width: 100%;
    }
}

footer {
    background-color: black;
    align-self: stretch;
    color: white;
    align-items: center;
    flex-shrink: 0;

    & a {
        color: white;
    }

    & > div > div:last-child > *::after {
        content: " | ";
        color: hsl(var(--shade-strong)) !important;
    }
    & > div > div:last-child > *:last-child::after {
        content: "";
    }
}

.clickable, .button-like, button, [onclick] {
    cursor: pointer;
    user-select: none;
}
.button-like, nav a, button {
    border: none;
    font-size: 1em;
    text-decoration: none;
    background-color: var(--acc2);
    color: hsl(var(--fg));

    &.small {
        font-size: 80%;
    }

    &[disabled] {
        opacity: 0.5;
        background-color: hsl(var(--shade));
        cursor: not-allowed;
    }
    &:hover, &.active {
        background-color: var(--acc3);
        opacity: 1;
    }
    &.danger {
        background-color: hsla(var(--danger), 0.4);
        color: hsl(var(--danger));
    }
}

.button-like {
    position: relative;

    & img, & svg {
        height: 1.5em;
        pointer-events: none;
    }

    &.sleek {
        padding: 0;
        background: none;
    }

    &.info {
        cursor: help;
    }

    & .badge {
        font-size: var(--small-size);
        --size: 1.75em;
        position: absolute; top: calc(var(--size) / -3); right: calc(var(--size) / -3);
        width: var(--size); height: var(--size);
        border-radius: 100%;
        background-color: hsl(var(--danger));
        color: white;
    }
}

.refresh-page-btn {
    position: fixed;
    bottom: 3em; left: 1em;
    font-size: 1.25em;
}

nav {
    background-color: var(--acc2);
    overflow: hidden;

    &#top-nav {
        position: relative;
        --upscale: 1.1;
        font-size: calc(var(--upscale) * 100%);
        overflow: visible;
    }

    & svg {
        height: 1em;
    }

    & .max-width-wrapper, & {
        & > * {
            font-weight: bold;
        }

        & > li {
            list-style: none;
        }

        & > .button-like {
            border-radius: 0;
        }
    }

    &[role="pagination"] > form {
        width: 100%;

        &, & > [role$="filtrables"] {
            --gap: 0 2em;
        }

        /* & svg {
            height: var(--small-size);
        } */
        & button, & .button-like {
            font-size: var(--small-size);
        }

        & .input-container {
            grid-template-columns: auto auto;
            align-items: center;
            --gap: 0.5em;
        }

        &#bottom-pagination {
            justify-content: end;
            --gap: 0.5em;
        }

        & input[name=page] {
            width: 1.5em;
            text-align: center;
        }
    }

    &[role="pagination"] {
        background-color: transparent !important;
        margin-bottom: 0.5em;
        overflow: visible;
    }
}

#sidebar-wrapper {
    grid-template-columns: 17em 1fr;
    align-items: start;
    --gap: 1em !important;
}

aside {
    & > h2 {
        background-color: hsl(var(--shade));
        margin: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        padding: 0.25em 0.5em;

        color: hsl(var(--fg));
        font-size: 1.2em;
    }

    & ul {
        list-style: none;
        padding-left: 0.5em;
        margin: 0;

        & > li, & > a {
            display: list-item;
            text-decoration: none;
            position: relative;
            margin-block: 0.25em;
            padding-block: 0;

            & > svg {
                position: absolute;
                height: 1.25em;

                &.left {
                    left: -0.5em;
                }

                &.right {
                    right: 0.25em;

                    .active > & {
                        rotate: -90deg;
                    }
                }
            }

            &.active, &.bold {
                font-weight: bold;
            }

            &.active {
                color: var(--acc1);
            }

            &:hover {
                color: var(--acc3);
            }
        }
    }
    & > ul {
        padding-left: 0;
        & > ul {
            padding-left: 1em;
        }
    }
}
#category-dropdown {
    position: absolute;
    top: 100%; left: 0; right: 0;
    z-index: 5;

    font-size: calc(1em / var(--upscale));
    font-weight: normal;
    text-align: initial;

    display: none;

    &.visible {
        display: flex;
    }

    & ul {
        list-style: none;
        margin: 0;
        padding: 0;
        border-right: 1px solid hsl(var(--shade));

        position: absolute;
        top: 0;
        left: 100%;
        width: max-content;

        & > * {
            display: list-item;
            text-decoration: none;
            border-radius: 0;
            padding-right: 2em !important;
            position: relative;

            background-color: var(--acc2);

            &:hover, &.active {
                background-color: var(--acc3);
            }

            & > svg {
                position: absolute;
                right: 0.5em;
            }
        }
    }
    & > ul {
        position: static;
    }
}

.breadcrumbs {
    margin-bottom: 2em;

    & > ul {
        list-style: none;
        padding: 0;
        margin: 0;

        & > * {
            padding: 0;
        }
    }
}

.alert {
    position: absolute; right: 3em; top: 3em;
    z-index: 99;
    border: 2px solid gray;
    box-shadow: 0.5em 0.5em 1.5em #00000044;
    opacity: 0; translate: 0 -100px;
    font-weight: bold;

    &.in {
        opacity: 1;
        translate: 0 0;
    }

    &.success, &.error, &.warning {
        border-color: currentColor;
        background-color: hsl(var(--bg));

        &.success {
            --clr-wh: hsla(var(--ok), 0.4);
            color: hsl(var(--ok));
        }
        &.error{
            --clr-wh: hsla(var(--danger), 0.4);
            color: hsl(var(--danger));
        }
        &.warning{
            --clr-wh: hsla(var(--warning), 0.4);
            color: hsl(var(--warning));
        }
    }
}

.fullscreen-popup {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999;
    background-color: #000000aa;

    & > .contents {
        background-color: hsl(var(--bg));
        max-height: 80vh;
        overflow: auto;
    }
}

.input-container {
    display: grid;
    grid-template-columns: 8em 1fr;
    align-items: start;
    margin: 0.5em 0;
    gap: var(--gap);

    & pre {
        margin: 0;
        white-space: wrap;
    }

    & .clicker {
        color: var(--acc3);
    }
}
input, textarea, select,
[role="filter"] > .button-like {
    background: none;
    color: hsl(var(--fg));
    font-size: 1em;
    border: 1px solid hsl(var(--shade));
    width: calc(100% - 2 * 1em);

    &:focus {
        outline: none;
        border-color: var(--acc1);
    }
    &[type=checkbox] {
        accent-color: var(--acc1);
        height: 1.5em;
        width: 1.5em;
    }
    &:disabled {
        background-color: hsl(var(--shade));
        opacity: 0.5;
    }

    &.button-like {
        font-size: 1em;
        font-weight: normal;

        & > span {
            width: 5em;
        }

        &::after {
            content: "⌟";
            rotate: 45deg;
            translate: 0.75em -0.25em;
            scale: 1.2;
        }
    }
}
textarea {
    height: 5em;
    font-family: monospace;
    resize: vertical;

    &[rows] {
        height: unset;
    }
}
select {
    width: 100%;
}
label {
    color: hsla(var(--fg), 1);
}

.logo {
    max-height: 2em;
    width: 100%;
    object-fit: contain;
    object-position: left;

    &.small {
        max-height: 1.5em;
    }
}

.listing, .tiling {
    --tile-width: 240px;

    &.small-tiles {
        --tile-width: 188px;
    }
    &.stretch-tiles {
        --tile-width: auto;
    }

    &.large-gap {
        gap: calc(var(--gap) * 3)
    }

    & > *{
        border: 3px double hsl(var(--shade));
        background-color: hsl(var(--bg));
        list-style: none;
        padding: 0;
        overflow: hidden;

        display: flex;
        justify-content: space-between;

        & .thumbnail-wrapper {
            overflow: hidden;
            position: relative;

            & > .tag > .ribbon {
                position: absolute;
                z-index: 10;
                top: 0;
            }

            & > * {
                width: 100%;
                height: inherit;
                max-width: none;
                object-fit: contain;
            }
            &.covering > * {
                object-fit: cover;
            }
        }

        & .content-wrapper {
            & > * {
                overflow-x: hidden;
            }

            & > .flex-right:first-child {
                & h3, & h4 {
                    margin-block: 0.6em;
                }

                & > img, & > svg {
                    height: 1.5em;
                }
            }
        }

        & .lower-split {
            padding-bottom: 0.5em;
        }

        &:hover {
            border: 3px solid var(--acc3);

            & .thumbnail-wrapper > img {
                scale: 1.15;
            }
        }
    }

    &.tiling {
        justify-content: center;

        &.flex-right > * {
            width: var(--tile-width);
        }

        & .thumbnail-wrapper {
            height: var(--tile-width);
        }

        &.to-the-left {
            justify-content: left !important;
        }
    }

    &.listing {
        & .thumbnail-wrapper {
            width: calc(var(--tile-width) * 0.65);
            height: calc(var(--tile-width) * 0.65);
        }

        & .cart-item {
            display: grid;
            gap: calc(var(--gap) * 3);
            grid-template-columns: auto 1fr auto;
            align-items: center;
            padding: 0.5em 1em;

            & .thumbnail-wrapper {
                width: calc(var(--tile-width) * 0.3);
                height: calc(var(--tile-width) * 0.3);
            }
            & h3, & h4 {
                margin: 0;
            }
            & .input-container {
                grid-template-columns: auto 1fr;

                & label {
                    font-weight: bold;
                }
            }
        }
    }
}
.files {
    align-items: start;
}

.stock-display {
    margin-block: 0.25em;
    --gap: 1em;
}
.size-stock-table {
    --gap: 0 1em;
    grid-template-columns: auto 1fr;
    grid-auto-flow: column;
    justify-content: flex-start;

    & > [role="labels"] {
        text-align: right;
        padding: 2px 0;
    }

    & > [role="amounts"] {
        text-align: center;
    }
}

.photo-gallery {
    position: relative;

    &.fullscreen {
        position: fixed;
        z-index: 10;
        top: 0; left: 0; right: 0; bottom: 0;
        background-color: hsla(0, 0%, 0%, 0.75);

        & > #main-photo-wrapper {
            height: 75vh;

            & > .gallery-btn.control {
                color: var(--acc1);
                --size: 7.5em;
            }
        }
    }

    & > #main-photo-wrapper {
        height: 50vh;
        width: 100%;
        overflow: hidden;
        position: relative;

        & > img {
            height: 100%; width: 100%;
            object-fit: contain;
        }

        & > .gallery-btn {
            position: absolute;
            opacity: 0.5;

            --size: 5em;
            height: var(--size);

            &.control {
                top: calc(50% - (var(--size) / 2));

                &:nth-of-type(1) { left: 0; }
                &:nth-of-type(2) { right: 0; }
            }
        }
    }
    & > .list {
        & > img {
            height: 3em;
            max-width: 3em;
            object-fit: contain;
            box-sizing: border-box;
            border: 0 solid hsl(var(--shade-strong));

            &.active {
                border-width: 1px;
            }
        }
    }
}

.variant-tile, .size-tile {
    --dim: 18px;

    width: var(--dim);
    height: var(--dim);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    vertical-align: top;
    text-align: center;

    overflow: hidden;

    outline: 1px solid hsla(var(--fg), 0.25);
    box-sizing: border-box;
    border-radius: 0.25em;
    background-color: var(--tile-color);

    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: contain !important;

    position: relative;

    &.active, a > &:hover {
        outline: 3px solid var(--acc3);

        &.active:not(.custom)::after {
            content: "✓";
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            display: flex;
            justify-content: center;
            align-items: center;

            font-weight: bold;
            color: var(--acc3);
        }
    }
    &.small {
        --dim: 9px;
    }
    &.no-color {
        --space: 15%;
        --w-col-1: gold;
        --w-col-2: #222;
        background: repeating-linear-gradient(to bottom right, var(--w-col-1), var(--w-col-1) var(--space), var(--w-col-2) var(--space), var(--w-col-2) calc(var(--space) * 2));
    }

    &.size-tile {
        width: auto;
        white-space: nowrap;
        text-align: center;
        font-weight: bold;
        font-size: calc(0.8 * var(--dim));
        padding: 0 5px;
        user-select: none;

        &.active {
            background-color: var(--acc3);
        }
    }
}

table {
    width: 100%;
    border-spacing: 0;
    margin: 1em 0;

    & thead, & tfoot {
        background-color: var(--acc2);
        text-align: left;
    }

    & tbody {
        & > tr:nth-child(even) {
            background-color: hsla(var(--shade), 0.5);
        }
    }

    & th, & td {
        padding: 0.25em 0.5em;
    }
}

ul[role="specification"] {
    &, & ul {
        padding-left: 2em;
    }
}

.tabs {
    margin-block: 2em 1em;

    & h3 {
        margin: 0;
        text-align: center;
    }

    & table {
        margin: 0;
    }

    & table th {
        text-align: right;
        width: 50%;
        vertical-align: baseline;
    }

    & .content-box {
        & .button-like {
            background-color: hsl(var(--shade));
            &:hover {
                background-color: var(--acc3);
            }
        }
    }
}

.product-tag {
    & .ribbon {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        width: 100%;
        height: 2em;
        overflow: hidden;

        font-weight: bold;
        font-size: var(--text-size);
        color: var(--text-color);
        background-color: var(--ribbon-color);
    }

    &.top-bar > .ribbon {
    }
    &.right-corner > .ribbon {
        right: 0;
        rotate: 45deg;
        transform-origin: 100% 0%;
        --position-factor: 3;
        translate: 30px 104px;
    }
}

#showcase {
    font-size: 200%;
    overflow: hidden;

    & > * {
        padding: 0.5em 1em;
        box-sizing: border-box;
        width: 100%;
        text-align: center;
    }

    & h2 {
        margin: 0;
        color: hsl(var(--fg));
        background-color: hsl(var(--shade));
    }

    & video {
        width: 100%;
    }

    & .flex-right {
        justify-content: space-around;

        & > * {
            width: calc(50% - 2em);
        }
    }

    & h2, & span {
        &:hover {
            scale: 1.1;
        }
    }
}

.choices__inner {
    width: 15em !important;
    min-height: unset !important;
}
*:has(.choices.is-open) {
    overflow: visible;
}

[role="product-description"], .tabs {
    & figure {
        margin: 0 !important;
        width: 100% !important;

        & > img {
            width: 100%;
            height: auto;
        }
    }
}

.carousel {
    max-width: 1016px;

    & img {
        width: 100%;
        height: 200px;
        object-fit: contain;
    }
}
