/*
  Compact Grid layout for Hanout's #shipping-methods.

  The structured markup below (.shipping-method-option, .shipping-method-radio,
  .shipping-method-label, .shipping-method-price) is built at runtime by
  assets/js/shipping-layout.js, same as every other layout - see that file
  for why. The .shipping-method-icon element is built by
  assets/js/shipping-method-icons.js (only enqueued by includes/frontend.php
  when this layout is active, same script "icon" and "large" also use), so
  it never runs before the cards it needs to insert an icon into exist.

  Look: the same side-by-side, icon-on-top, no-radio-dot card as "Large"
  (equal-width grid cells, icon centered above the label/price), but sized
  compact from the start rather than needing a mobile breakpoint to shrink
  it after the fact - smaller icon tile, tighter padding, lower
  min-height, on desktop as well as mobile. Meant for stores that want the
  tap-target-card look without it taking up as much vertical space on the
  product page, especially when a 3rd shipping method is
  also turned on and would otherwise push the "confirm order" button
  further down.

  --hfe-shipping-accent and --hfe-shipping-radius are set from the
  "Shipping Form" admin tab (see includes/frontend.php); the values below
  are just the fallback so the layout still looks intentional if that
  inline override is ever missing.

  --- Grid blowout fix (1.8.3) ---
  Same fix as layout-large.css - see that file's header for the full
  explanation. Short version: grid-template-columns' bare minmax(Npx, 1fr)
  was a hard floor the browser could never shrink below, and
  #shipping-methods sits inside Hanout's own #codplugin_show_hide
  <table> (auto layout, no table-layout:fixed), sharing its row with the
  price/"FREE" <td>s - on a narrow phone the two tracks' combined minimum
  could force that whole table wider than the viewport, independent of
  shipping method location. minmax(min(Npx, 100%), 1fr) plus min-width:0
  on the grid and its items fixes that at the source.
*/

:root {
    --hfe-shipping-accent: #259bea;
    --hfe-shipping-radius: 10px;
}

#shipping-methods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(96px, 100%), 1fr));
    gap: 7px;
    margin-top: 8px;
    margin-left: 0;
    font-size: 14px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.shipping-method-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    min-height: 62px;
    min-width: 0;
    box-sizing: border-box;
    border: 1.5px solid #e3e8ee;
    border-radius: var(--hfe-shipping-radius);
    padding: 9px 6px;
    background: #fff;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.25;
    color: #404040;
    transition: border-color .2s cubic-bezier(.4,0,.2,1),
                background-color .2s cubic-bezier(.4,0,.2,1);
}

.shipping-method-option:hover {
    border-color: var(--hfe-shipping-accent);
}

.shipping-method-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
}

.shipping-method-option input[type="radio"]:focus-visible ~ .shipping-method-icon {
    box-shadow: 0 0 0 3px rgba(37, 155, 234, .25);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hfe-shipping-accent) 25%, transparent);
}

.shipping-method-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f3f5;
    color: #6b7785;
    transition: background-color .2s ease, color .2s ease;
}

.shipping-method-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.shipping-method-icon[data-hfe-icon-type="pickup"] {
    background: rgba(37, 155, 234, .12);
    background: color-mix(in srgb, var(--hfe-shipping-accent) 14%, white);
    color: var(--hfe-shipping-accent);
}

.shipping-method-icon[data-hfe-icon-type="home"] {
    background: rgba(26, 135, 84, .12);
    color: #1a8754;
}

.shipping-method-option.is-selected .shipping-method-icon {
    background: var(--hfe-shipping-accent);
    color: #fff;
}

.shipping-method-label {
    font-size: 11.5px;
}

.shipping-method-price {
    font-size: 11px;
    font-weight: 600;
    color: #6b7785;
    white-space: nowrap;
}

.shipping-method-option.is-selected {
    border-color: var(--hfe-shipping-accent);
    background: rgba(37, 155, 234, .05);
    background: color-mix(in srgb, var(--hfe-shipping-accent) 5%, white);
}

.shipping-method-option.is-selected .shipping-method-label {
    color: #185fa5;
    color: color-mix(in srgb, var(--hfe-shipping-accent) 65%, black);
    font-weight: 600;
}

.shipping-method-option.is-selected .shipping-method-price {
    color: #185fa5;
    color: color-mix(in srgb, var(--hfe-shipping-accent) 65%, black);
}

/* small corner checkmark badge, same idea as "Large" but scaled down to
   match this layout's tighter card - no radio dot here either */
.shipping-method-option.is-selected::after {
    content: '';
    position: absolute;
    top: 5px;
    inset-inline-end: 5px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--hfe-shipping-accent);
}

.shipping-method-option.is-selected::before {
    content: '';
    position: absolute;
    top: 8px;
    inset-inline-end: 9.5px;
    width: 3px;
    height: 5.5px;
    border: solid #fff;
    border-width: 0 1.3px 1.3px 0;
    transform: rotate(45deg);
    z-index: 1;
}

.shipping-method-currency {
    font-weight: 400;
}

.shipping-method-free {
    color: #1a8754;
    font-weight: 600;
}

.shipping-method-radio {
    display: none;
}

/* Even the "compact" size still has a little more room to give up on a
   narrow phone - trims further rather than leaving it as the floor. */
@media (max-width: 480px) {
    #shipping-methods {
        grid-template-columns: repeat(auto-fit, minmax(min(88px, 100%), 1fr));
        gap: 6px;
    }

    .shipping-method-option {
        min-height: 54px;
        padding: 7px 5px;
        gap: 3px;
    }

    .shipping-method-icon {
        width: 22px;
        height: 22px;
    }

    .shipping-method-icon svg {
        width: 12px;
        height: 12px;
    }

    .shipping-method-label {
        font-size: 11px;
        line-height: 1.2;
    }

    .shipping-method-price {
        font-size: 10.5px;
    }
}
