/* "Hose Size Details" on hose adapter product pages
   (functions/woocommerce/hose-size-panel.php). One tab per Hose Size; the
   size on show gets its render ("Looks like"), a shaded side drawing with the
   two outside measurements ("Measures"), and a status box with the "Select"
   button. Loaded only on qualifying products (functions/core/assets.php),
   after the product bundle.

   State is on the markup, set by PHP and kept by hose-size-panel.js:
   .is-imperial on the root shows inches, aria-pressed="true" marks the tab on
   show, data-tc-hsp-state="selected" | "viewing" on a size says whether it is
   the buy box's Hose Size ("browse" where Hose Size is not an option on the
   product), and --tc-hsp-count is how many sizes there are.

   The drawing is an inline SVG 460 x 460 units; its type is sized in those
   units, so it shrinks with the drawing and steps up on phones, where the
   drawing is narrower than it was drawn. */

.tc-hsp {
    padding: var(--space-1) 0 var(--space-5);
    /* The buy box's "Which hose do I have?" link scrolls here and focuses the
       root; leave room for the accordion heading above it. */
    scroll-margin-top: 72px;
}

.tc-hsp:focus {
    outline: none;
}

/* That link, at the right end of the buy box's "Hose Size" label row. */
.woocommerce div.product form.cart .variations th.label .tc-hsp-jump {
    float: right;
    margin-left: var(--space-3);
    cursor: pointer;
}

/* The global stylesheet's "#wrapper p" margin has ID weight; spacing here comes from gaps. */
#wrapper .tc-hsp p {
    margin: 0;
}

.tc-hsp__fig,
.tc-hsp__rows,
.tc-hsp__row dd {
    margin: 0;
}

/* The theme reset pins every span to normal weight; these follow their parent instead. */
.tc-hsp__mm,
.tc-hsp__in,
.tc-hsp__dia,
.tc-hsp__tab-word,
.tc-hsp__when-selected,
.tc-hsp__when-viewing {
    font-weight: inherit;
}

/* Units: every length is printed twice; the root decides which shows. */
.tc-hsp__in,
.tc-hsp.is-imperial .tc-hsp__mm {
    display: none;
}

.tc-hsp.is-imperial .tc-hsp__in {
    display: inline;
}

/* Selected / viewing: both wordings are printed; the size's state decides. */
.tc-hsp__item[data-tc-hsp-state="selected"] .tc-hsp__when-viewing,
.tc-hsp__item[data-tc-hsp-state="viewing"] .tc-hsp__when-selected {
    display: none;
}

/* Intro: what to do, the units switch, and the buy box's current size. */
.tc-hsp__intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "lede units"
        "label label";
    align-items: start;
    gap: 14px 24px;
}

#wrapper .tc-hsp__lede {
    grid-area: lede;
    max-width: 660px;
    font-size: 15px;
    line-height: 1.45;
    color: var(--text-body);
}

.tc-hsp__units {
    display: flex;
    grid-area: units;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: #fff;
}

.tc-hsp__unit {
    min-width: 48px;
    height: 36px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: var(--text-body);
    font-family: inherit;
    font-size: var(--fs-14);
    font-weight: var(--fw-semibold);
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background 150ms ease, color 150ms ease;
}

.tc-hsp__unit + .tc-hsp__unit {
    border-left: 1px solid var(--line-strong);
}

.tc-hsp__unit:hover {
    background: var(--surface-1);
}

.tc-hsp__unit[aria-pressed="true"] {
    background: var(--navy-800);
    color: #fff;
}

.tc-hsp__unit:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--navy-700), var(--ring-focus);
}

#wrapper .tc-hsp__label {
    grid-area: label;
    font-size: var(--fs-14);
    line-height: 20px;
    color: var(--text-heading);
}

.tc-hsp__label strong {
    font-weight: var(--fw-semibold);
}

/* Tabs: one real button per Hose Size. aria-pressed = the size on show. */
.tc-hsp__tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
    gap: 10px;
    margin-top: 10px;
}

.tc-hsp__tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 64px;
    margin: 0;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 2px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--text-heading);
    font: inherit;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 150ms ease, background 150ms ease;
}

.tc-hsp__tab:hover {
    border-color: var(--ink-200);
}

.tc-hsp__tab[aria-pressed="true"] {
    border-color: var(--navy-700);
    background: var(--surface-1);
}

.tc-hsp__tab:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.tc-hsp__thumb {
    flex: none;
    width: 36px;
    height: 44px;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    background: #fff;
}

.tc-hsp__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tc-hsp__tab-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tc-hsp__tab-name {
    font-size: var(--fs-16);
    font-weight: var(--fw-bold);
    line-height: 20px;
}

.tc-hsp__tab-dim {
    font-family: var(--font-mono);
    font-size: var(--fs-13);
    font-weight: var(--fw-medium);
    line-height: 18px;
    color: var(--ink-500);
    white-space: nowrap;
}

.tc-hsp__check,
.tc-hsp__tip-check {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: #fff;
}

.tc-hsp__check {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--navy-700);
}

.tc-hsp__check[hidden] {
    display: none;
}

/* One size: pictures on the left, words on the right. */
.tc-hsp__item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px 36px;
    margin-top: 22px;
}

.tc-hsp__item[hidden] {
    display: none;
}

.tc-hsp__figs {
    display: grid;
    flex: 0 1 686px;
    grid-template-columns: minmax(0, 210fr) minmax(0, 460fr);
    gap: 16px;
    min-width: 0;
    max-width: 100%;
}

.tc-hsp__fig {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.tc-hsp__eyebrow {
    font-size: var(--fs-11);
    font-weight: var(--fw-bold);
    letter-spacing: 0.11em;
    line-height: 16px;
    text-transform: uppercase;
    color: var(--ink-500);
}

/* The render is cut to the tile's shape with the top of the hose where the
   drawing's hose starts, so the two line up; it runs off the bottom edge. */
.tc-hsp__picture {
    display: flex;
    flex: 1 1 auto;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 9px;
    background: #fff;
}

.tc-hsp__picture img {
    display: block;
    width: 100%;
    height: auto;
    /* Exactly as tall as the drawing beside it; any hair of difference is trimmed from the bottom. */
    min-height: 100%;
    object-fit: cover;
    object-position: 50% 0;
}

.tc-hsp__drawing {
    overflow: hidden;
    border-radius: 9px;
    background-color: #f6f8fc;
    /* A 20-unit grid that scales with the drawing (460 x 460 units). */
    background-image:
        linear-gradient(#e3e8ef 1px, transparent 1px),
        linear-gradient(90deg, #e3e8ef 1px, transparent 1px);
    background-size: 4.3478% 4.3478%;
    box-shadow: inset 0 0 0 1px var(--line);
}

.tc-hsp__svg {
    display: block;
    width: 100%;
    height: auto;
}

.tc-hsp__bar,
.tc-hsp__leader {
    fill: none;
    stroke: var(--orange-500);
    stroke-width: 3px;
}

.tc-hsp__leader {
    stroke-width: 1.5px;
}

.tc-hsp__num {
    fill: var(--orange-700);
    font-family: var(--font-mono);
    font-size: 19px;
    font-weight: var(--fw-semibold);
}

.tc-hsp__cap {
    fill: var(--ink-700);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: var(--fw-semibold);
}

.tc-hsp__scale-note {
    fill: var(--ink-500);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: var(--fw-medium);
}

/* The same note as text under the drawing, for widths where the one inside it is too small. */
.tc-hsp__foot {
    display: none;
}

/* A size with no drawing yet: the render alone, at its own shape. */
.tc-hsp__item--plain .tc-hsp__figs {
    flex-basis: 210px;
    grid-template-columns: minmax(0, 1fr);
}

.tc-hsp__side {
    display: flex;
    flex: 1 1 300px;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    max-width: 520px;
}

.tc-hsp__head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.tc-hsp__type {
    font-size: var(--fs-11);
    font-weight: var(--fw-bold);
    letter-spacing: 0.11em;
    line-height: 16px;
    text-transform: uppercase;
    color: var(--steel-600);
}

.tc-hsp__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

#wrapper .tc-hsp__name {
    margin: 0;
    padding: 0;
    color: var(--text-heading);
    font-family: var(--font-ui);
    font-size: 24px;
    font-weight: var(--fw-bold);
    letter-spacing: -0.01em;
    line-height: 30px;
    text-transform: none;
}

.tc-hsp__tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--navy-700);
    color: #fff;
    font-size: var(--fs-11);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.06em;
    line-height: 16px;
    text-transform: uppercase;
}

#wrapper .tc-hsp__cue {
    font-size: var(--fs-14);
    line-height: 21px;
    color: var(--ink-500);
}

.tc-hsp__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--line-faint);
    font-size: var(--fs-14);
    line-height: 20px;
}

.tc-hsp__row:last-child {
    border-bottom: 1px solid var(--line-faint);
}

.tc-hsp__row dt {
    font-weight: var(--fw-regular);
    color: var(--text-body);
}

.tc-hsp__row dd {
    font-family: var(--font-mono);
    font-weight: var(--fw-semibold);
    color: var(--text-heading);
    text-align: right;
    white-space: nowrap;
}

/* Status: is this the size chosen above, the note about its name, and "Select". */
.tc-hsp__status {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
}

#wrapper .tc-hsp__status-text {
    font-size: 15px;
    line-height: 22px;
    color: var(--text-body);
}

.tc-hsp__state {
    margin-right: 6px;
    font-size: var(--fs-11);
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-500);
}

.tc-hsp__select {
    margin: 0;
    padding: 11px 18px;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--navy-700);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: var(--fw-bold);
    line-height: 22px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background 150ms ease;
}

.tc-hsp__select:hover {
    background: var(--navy-800);
}

.tc-hsp__select:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.tc-hsp__select[hidden] {
    display: none;
}

.tc-hsp__tip {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 12px 13px;
    border-radius: 9px;
    background: var(--success-050);
}

.tc-hsp__tip-check {
    margin-top: 1px;
    background: var(--success-700);
}

#wrapper .tc-hsp__tip p {
    font-size: var(--fs-13);
    line-height: 20px;
    color: var(--success-700);
}

/* Not enough room for the words beside the pictures: they go underneath, as wide as the pictures. */
@media (max-width: 1055px) {
    .tc-hsp__side {
        flex-basis: 100%;
        max-width: 686px;
    }
}

/* Not enough room for five tabs with the picture beside the name: one compact
   row instead, picture above name, as many columns as there are sizes. */
@media (max-width: 939px) {
    .tc-hsp__tabs {
        grid-template-columns: repeat(var(--tc-hsp-count, 5), minmax(0, 1fr));
        gap: 6px;
        margin-top: 12px;
    }

    .tc-hsp__tab {
        flex-direction: column;
        justify-content: flex-start;
        gap: 6px;
        min-height: 0;
        padding: 8px 2px 7px;
        text-align: center;
    }

    .tc-hsp__thumb {
        width: 40px;
        height: 49px;
    }

    .tc-hsp__tab-text {
        align-items: center;
        gap: 1px;
    }

    .tc-hsp__tab-name {
        font-size: var(--fs-14);
        line-height: 18px;
    }

    .tc-hsp__tab-dim {
        font-size: var(--fs-11);
        line-height: 15px;
    }

    .tc-hsp__check {
        top: 3px;
        right: 3px;
        width: 16px;
        height: 16px;
    }
}

/* Phone. Each size reads top to bottom: the render beside its name and
   status, then the drawing at full width with its two numbers, then the
   numbers as rows, then the tip. */
@media (max-width: 767px) {
    .tc-hsp__intro {
        grid-template-areas:
            "lede lede"
            "label units";
        align-items: center;
        gap: 12px 16px;
    }

    .tc-hsp__unit {
        height: 44px;
    }

    /* "Hose" is the same on every tab; keep it for screen readers only. */
    .tc-hsp__tab-word {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .tc-hsp__dia {
        display: none;
    }

    .tc-hsp__item {
        display: grid;
        grid-template-columns: 132px minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "looks head"
            "looks status"
            "measures measures"
            "rows rows"
            "tip tip";
        gap: 0 14px;
        margin-top: 18px;
    }

    .tc-hsp__item--plain {
        grid-template-areas:
            "looks head"
            "looks status"
            "rows rows"
            "tip tip";
    }

    .tc-hsp__figs,
    .tc-hsp__side {
        display: contents;
    }

    .tc-hsp__fig--looks {
        grid-area: looks;
        align-self: start;
    }

    /* Never wider than it was drawn, so its type never gets oversized on a big phone. */
    .tc-hsp__fig--measures {
        grid-area: measures;
        max-width: 460px;
        margin-top: 18px;
    }

    .tc-hsp__head {
        grid-area: head;
        gap: 6px;
        /* Level with the picture, under the "Looks like" line. */
        padding-top: 24px;
    }

    #wrapper .tc-hsp__name {
        font-size: 22px;
        line-height: 26px;
    }

    .tc-hsp__status {
        grid-area: status;
        align-self: start;
        margin-top: 12px;
        padding: 12px;
    }

    #wrapper .tc-hsp__status-text {
        font-size: var(--fs-14);
        line-height: 20px;
    }

    .tc-hsp__select {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
    }

    .tc-hsp__rows {
        grid-area: rows;
        margin-top: 14px;
    }

    .tc-hsp__tip {
        grid-area: tip;
        margin-top: 14px;
    }

    .tc-hsp__scale-note {
        display: none;
    }

    #wrapper .tc-hsp__foot {
        display: block;
        font-size: var(--fs-12);
        line-height: 1.4;
        color: var(--text-soft);
    }
}

/* The drawing is narrower than it was drawn from here down; its type (sized
   in drawing units) steps up so the numbers stay about 17 px on screen. */
@media (max-width: 460px) {
    .tc-hsp__num {
        font-size: 22px;
    }

    .tc-hsp__cap {
        font-size: 15px;
    }
}

@media (max-width: 410px) {
    .tc-hsp__num {
        font-size: 24px;
    }

    .tc-hsp__cap {
        font-size: 16px;
    }
}

@media (max-width: 340px) {
    .tc-hsp__num {
        font-size: 25px;
    }

    .tc-hsp__cap {
        font-size: 17px;
    }

    .tc-hsp__tab-dim {
        font-size: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tc-hsp__unit,
    .tc-hsp__tab,
    .tc-hsp__select {
        transition: none;
    }
}
