@import './reset.css';

/* The card gallery (/card/templates). Looks like the template picker it
   replaced — same paper, same menu buttons, same thumbnails — but it is a page
   of its own, so it scrolls as a document and has the site header on top. */

* {
    box-sizing: border-box;
}

body {
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23e0e0e0' fill-opacity='0.35'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z'/%3E%3Cpath d='M6 5V0H5v5H0v1h5v94h1V6h94V5H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    font-family: "Afacad", sans-serif;
    /* Afacad's regular (400) is a thin cut; the editor's own labels are 500
       and up, and at 400 this page read as lighter than the rest of the app. */
    font-weight: 500;
    color: #222;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    text-decoration: none;
    color: inherit;
}

hr {
    border: none;
    border-top: 1px solid #ddd;
    width: 100%;
    margin: 10px 0;
}

/* ── header (as on the editor) ─────────────────────────────── */

header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    width: 100%;
    border-bottom: solid 1px #aaa;
    font-weight: 700;
    background: #fff;
}

header div.header_logo {
    white-space: nowrap;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    margin-right: 25px;
}

header div.header_logo a {
    color: #000;
}

@media (hover: hover) {
    header div.header_logo a:hover {
        color: #f58a00;
    }
}

header div.header_logo a:focus-visible,
.tg-resume:focus-visible,
.tg-menu__item:focus-visible,
.tg-card:focus-visible {
    outline: 2px solid #46433f;
    outline-offset: 2px;
}

/* Back to the card the customer was making. Sits at the right, beside the
   account icon: it takes over the account menu's push-to-the-right, or the two
   would share the free space and leave the button in the middle of the header. */
.tg-resume + .account-menu {
    margin-left: 0;
}

.tg-resume {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 11px;
    background: #1b1a18;
    border: 1.5px solid #000;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
}

.tg-resume:active {
    background: #000;
}

/* ── layout ────────────────────────────────────────────────── */

.tg {
    flex: 1;
    display: flex;
    align-items: flex-start;
}

.tg-menu {
    display: flex;
    gap: 5px;
    padding: 15px 10px;
    background-color: #eee;
    position: sticky;
    top: 0;
    z-index: 2;
}

.tg-menu__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #65615c;
    letter-spacing: 0.08em;
    padding-left: 2px;
}

/* The two groups behave differently and look it: a category is a link in a
   quiet list with one black row (you are here); a size is a box that takes a
   tick and a dark border when it is on (a filter, several can be on). */
.tg-menu__item {
    display: block;
    padding: 8px 10px;
    border-radius: 5px;
    border: solid 1px transparent;
    background: transparent;
    color: #1b1a18;
    font-family: "Afacad", sans-serif;
    font-weight: 500;
    font-size: 1.05rem;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.tg-menu__item--category.is-selected {
    background: #1b1a18;
    border-color: #1b1a18;
    color: #fff;
    font-weight: 600;
}

/* A size button is two lines: the size, and how many cards it has in this
   category ("76 mallar") — a bare number beside the size said nothing. One
   frame per choice: the box itself is the control (a tick box inside it was a
   second frame, and read as a form field). The tick is drawn here and follows
   aria-pressed, the state the script sets. */
.tg-menu__item--size {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    min-height: 44px;
    padding: 7px 4px 6px 28px;
    border-color: #aaa59c;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
}

.tg-menu__item--size[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    left: 12px;
    top: 12px;
    width: 5px;
    height: 8px;
    border: solid #1b1a18;
    border-width: 0 1px 1px 0;
    transform: rotate(45deg);
}

.tg-menu__item--size.is-selected {
    border-color: #1b1a18;
    background: #eeece8;
}

.tg-menu__count {
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: #65615c;
}

.tg-menu__item--size.is-selected .tg-menu__count {
    color: #494640;
}

@media (hover: hover) {
    .tg-menu__item:not(.is-selected):hover {
        background: #dedbd5;
        border-color: #aaa59c;
    }

    .tg-menu__item--category.is-selected:hover {
        background: #37342f;
    }

    .tg-menu__item--size.is-selected:hover {
        background: #dedbd5;
    }
}

/* a finger gets a full-size target, whichever way the screen is turned */
@media (pointer: coarse) {
    .tg-menu__item {
        min-height: 44px;
        min-width: 44px;
    }
}

/* A real grid: equal columns, so the cards line up down the page as well as
   across. A row is as tall as its tallest thumbnail (a row of wide 10 x 21
   cards stays low), each thumbnail sits in the middle of its cell and the
   names share one line along the bottom of the row. */
.tg-main {
    flex: 1;
    min-width: 0;
}

/* above the grid: the order */
.tg-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 14px 20px 0;
}

.tg-sort {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tg-sort__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #777;
}

.tg-sort__select {
    appearance: none;
    -webkit-appearance: none;
    min-height: 34px;
    padding: 0 32px 0 12px;
    border: solid 1px #ccc;
    border-radius: 5px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23222' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 13px;
    color: #000;
    font-family: "Afacad", sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.tg-sort__select:focus-visible {
    outline: 2px solid #46433f;
    outline-offset: 2px;
}

.tg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 28px 20px;
    padding: 20px;
}

.tg-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: #222;
    border-radius: 3px;
}

.tg-card[hidden] {
    display: none;
}

.tg-card__img {
    display: block;
    /* auto on every side: centred in whatever height the row gives the cell */
    margin: auto;
    /* the card a "Byt mall" link came from (#mall-…) lands clear of the top */
    scroll-margin-top: 20px;
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.75);
    transition: box-shadow 0.12s, transform 0.12s;
}

/* under the thumbnail: the size, then the card's number */
.tg-card__size {
    display: block;
    padding-top: 7px;
    font-size: 0.92rem;
    font-weight: 600;
    color: #222;
}

.tg-card__name {
    display: block;
    padding-top: 3px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #6b6b6b;
}

@media (hover: hover) {
    .tg-card:hover .tg-card__img {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
        transform: translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tg-card__img {
        transition: none;
    }
}

/* ── wide: the menu is a column down the left edge ─────────── */
@media screen and (orientation: landscape) {
    .tg-menu {
        flex-direction: column;
        align-items: stretch;
        min-width: 120px;
        height: 100dvh;
        overflow-y: auto;
        border-right: solid 1px #ccc;
    }

    .tg-menu__label {
        padding-top: 4px;
    }

    /* a list reads down its left edge */
    .tg-menu__item--category {
        text-align: left;
    }
}

/* ── tall: the menu is a bar across the top ────────────────── */
@media screen and (orientation: portrait) {
    .tg {
        flex-direction: column;
        align-items: stretch;
    }

    .tg-menu {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 10px;
        border-bottom: solid 1px #ccc;
    }

    .tg-menu__label {
        display: none;
    }

    /* the bar is used with a thumb: every item is a 44 px target */
    .tg-menu__item {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        min-width: 44px;
        padding: 6px 9px;
        font-size: 0.95rem;
    }

    .tg-menu hr {
        flex-basis: 100%;
        height: 0;
        border: none;
        margin: 2px 0;
    }

    /* on one line here: the bar has no room for two-line buttons */
    .tg-menu__item--size {
        flex-direction: row;
        align-items: center;
        gap: 7px;
        padding: 5px 10px 5px 30px;
        font-size: 0.82rem;
        border-color: #bbb;
    }

    .tg-menu__item--size[aria-pressed="true"]::after {
        top: 16px;
    }

    .tg-toolbar {
        padding: 10px 10px 0;
    }

    .tg-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 18px 14px;
        padding: 12px 10px;
    }

    .tg-card__img {
        /* the sticky bar is taller here */
        scroll-margin-top: 130px;
    }
}
