/*
 * Rig Builder cards (§17.576): a build or product card inside an /embed/ iframe,
 * or printed into a GTPlanet WordPress post by the Rig Builder Cards plugin.
 *
 * Self-contained: neither place loads rigbuilder.css. Every rule starts with
 * .rb-card so it outweighs a host theme's own a, p, img and button styles,
 * and each has a .dark version, which the host page or the embed's head
 * script sets on <html>.
 */

.rb-card {
    --rb-card-bg: #fff;
    --rb-card-subtle: #f5f5f5;
    --rb-card-border: #d8d8d8;
    --rb-card-text: #141414;
    --rb-card-muted: #8c8c8c;
    --rb-card-link: #004d90;
    --rb-card-positive: #426b42;
    --rb-card-warning-bg: #fff5d1;
    --rb-card-warning-border: #dcbd62;
    --rb-card-warning-text: #61542d;

    display: flex;
    gap: 14px;
    box-sizing: border-box;
    max-width: 640px;
    margin: 20px 0;
    padding: 12px 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--rb-card-text);
    text-align: left;
    background: var(--rb-card-bg);
    border: 1px solid var(--rb-card-border);
    border-radius: 4px;
    position: relative;
}

.dark .rb-card {
    --rb-card-bg: #141517;
    --rb-card-subtle: #232323;
    --rb-card-border: #323232;
    --rb-card-text: #d9d9d9;
    --rb-card-muted: #ababab;
    --rb-card-link: rgba(255, 255, 255, 0.85);
    --rb-card-positive: #6ca56c;
    --rb-card-warning-bg: rgba(255, 246, 201, 0.12);
    --rb-card-warning-border: #6b5a22;
    --rb-card-warning-text: #e8d58a;
}

.rb-card * { box-sizing: border-box; }
.rb-card p { margin: 0; }
.rb-card a { color: var(--rb-card-link); text-decoration: none; }
.rb-card a:hover { text-decoration: underline; }
/* The host page's own link underlines (the Rig Builder admin, some themes)
   do not reach into the card. */
.rb-card .rb-card-title a,
.rb-card .rb-card-partText a,
.rb-card .rb-card-more a { text-decoration: none; }
.rb-card .rb-card-title a:hover,
.rb-card .rb-card-partText a:hover,
.rb-card .rb-card-more a:hover { text-decoration: underline; }
.rb-card img { display: block; max-width: 100%; height: auto; margin: 0; border: 0; box-shadow: none; }
.rb-card form { margin: 0; }

/* The photo sits on white in both modes: product photos are cut out on white (§17.9). */
.rb-card .rb-card-media {
    flex: 0 0 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    padding: 6px;
    background: #fff;
    border-radius: 4px;
}

.rb-card .rb-card-media img { max-height: 140px; width: auto; }

/* A product card with little to say sits level with its photo, rather than
   hugging the top and leaving a gap under its buttons. */
.rb-card--product { align-items: center; }
.rb-card--product .rb-card-media { align-self: center; }
.rb-card--product .rb-card-body { gap: 8px; }

.rb-card .rb-card-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rb-card .rb-card-title { font-size: 19px; font-weight: 700; line-height: 1.3; }
.rb-card .rb-card-title a { color: var(--rb-card-text); }
.rb-card .rb-card-text { font-size: 13px; }
.rb-card .rb-card-meta { font-size: 12px; color: var(--rb-card-muted); }

.rb-card .rb-card-warning {
    padding: 6px 8px;
    font-size: 13px;
    color: var(--rb-card-warning-text);
    background: var(--rb-card-warning-bg);
    border: 1px solid var(--rb-card-warning-border);
    border-radius: 4px;
}

/* Prices, labeled the same way as on the Rig Builder's own pages (§10.2). */
.rb-card .rb-card-price { font-size: 18px; line-height: 1.35; }
.rb-card .rb-card-total { font-size: 14px; }
.rb-card .rb-card-total { font-weight: 600; }
/* Beats every display rule here: only the reader's region shows. */
.rb-card [hidden] { display: none !important; }
.rb-card .rb-price { font-weight: 700; }
.rb-card .rb-price--was { font-weight: 400; color: var(--rb-card-muted); text-decoration: line-through; }
.rb-card .rb-price--coded { color: var(--rb-card-positive); }
.rb-card .rb-price-qualifier { font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--rb-card-positive); }
.rb-card .rb-price--sale .rb-price-qualifier { font-weight: 400; color: var(--rb-card-muted); }

.rb-card .rb-card-offer { display: flex; flex-direction: column; gap: 4px; }
/* The saving, as on the product page (§11). */
.rb-card .rb-card-savings { font-size: 14px; font-weight: 600; color: var(--rb-card-muted); }
.rb-card .rb-card-savings--code { color: var(--rb-card-positive); }
.rb-card .rb-card-savings strong {
    display: inline-block;
    padding: 1px 6px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px dashed currentColor;
    border-radius: 4px;
}

/* The code: monospaced, in the product page's dashed box, and a button that
   copies it. */
.rb-card .rb-card-copy {
    display: inline-block;
    margin: 0;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.02em;
    color: inherit;
    text-transform: none;
    background: transparent;
    border: 1px dashed currentColor;
    border-radius: 4px;
    box-shadow: none;
    cursor: copy;
}

.rb-card .rb-card-copy:hover { background: rgba(66, 107, 66, 0.1); }
.dark .rb-card .rb-card-copy:hover { background: rgba(160, 251, 160, 0.08); }
.rb-card .rb-card-copy:focus-visible { outline: 2px solid #1172b7; outline-offset: 2px; }
.rb-card .rb-card-copy.is-copied { border-style: solid; }
.rb-card .rb-card-copied { margin-left: 6px; font-size: 12px; font-weight: 600; }
.rb-card .rb-card-copied:empty { margin: 0; }
.rb-card .rb-saving {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 7px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    color: #fff;
    background: var(--rb-card-positive);
    border-radius: 3px;
}
.dark .rb-card .rb-saving { color: #141517; }

.rb-card .rb-card-parts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    margin: 2px 0;
    padding: 0;
    list-style: none;
}

.rb-card .rb-card-part {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.rb-card .rb-card-part::before { content: none; }

.rb-card .rb-card-thumb {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    background: #fff;
    border: 1px solid var(--rb-card-border);
    border-radius: 4px;
}

.rb-card .rb-card-thumb img { max-height: 36px; width: auto; }

.rb-card .rb-card-partText {
    min-width: 0;
    display: flex;
    flex-direction: column;
    font-size: 13px;
    line-height: 1.3;
}

.rb-card .rb-card-partText a,
.rb-card .rb-card-partText > span:not(.rb-card-partCategory):not(.rb-card-qty) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-card .rb-card-partCategory { font-size: 11px; color: var(--rb-card-muted); }
.rb-card .rb-card-qty { color: var(--rb-card-muted); }
.rb-card .rb-card-more { font-size: 13px; }

.rb-card .rb-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.rb-card .rb-card-button {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 32px;
    margin: 0;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: #141414;
    text-decoration: none;
    background: linear-gradient(180deg, #fff, #e7e7e7);
    border: 1px solid #cccaca;
    border-bottom-color: #b9b9b9;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

.rb-card .rb-card-button:hover { text-decoration: none; background: linear-gradient(180deg, #fff, #dcdcdc); }
.rb-card .rb-card-button:active { box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25); }
.rb-card .rb-card-button:focus-visible { outline: 2px solid #1172b7; outline-offset: 3px; }

/* The buy button: the site's green, in both modes. A direct, tagged link to
   the store (§4.5). */
.rb-card .rb-buyButton,
.rb-card .rb-buyButton:visited {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 32px;
    margin: 0;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(180deg, #2a8c2a, #166f16);
    border: 1px solid #126810;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* The external-window icon, as on the product page. */
.rb-card .rb-buyButton::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 7px;
    background: currentColor;
    -webkit-mask: url('external-link.svg?v=1') center / contain no-repeat;
    mask: url('external-link.svg?v=1') center / contain no-repeat;
}

.rb-card .rb-buyButton:hover { color: #fff; text-decoration: none; background: linear-gradient(180deg, #35a035, #208220); }
.rb-card .rb-buyButton:active { box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25); }
.rb-card .rb-buyButton:focus-visible { outline: 2px solid #1172b7; outline-offset: 3px; }

.rb-card .rb-card-button--primary {
    color: #fff;
    background: linear-gradient(180deg, #1172b7, #00528c);
    border-color: #00528c;
}

.rb-card .rb-card-button--primary:hover { background: linear-gradient(180deg, #1681cb, #08629f); }

.dark .rb-card .rb-card-button {
    color: #fff;
    background: linear-gradient(180deg, #626262, #494949);
    border-color: #575757;
}

.dark .rb-card .rb-card-button:hover { background: linear-gradient(180deg, #707070, #555); }

.dark .rb-card .rb-card-button--primary {
    background: linear-gradient(180deg, #1172b7, #00528c);
    border-color: #00528c;
}

.dark .rb-card .rb-card-button--primary:hover { background: linear-gradient(180deg, #1681cb, #08629f); }


/* The GTPlanet Rig Builder logo, bottom right, level with the buttons. The
   button rows keep clear of it. The logo file is a mask filled with the
   card's text color, so it is dark on light and light on dark. */
.rb-card .rb-card-logo {
    position: absolute;
    right: 14px;
    bottom: 12px;
    display: block;
    width: 51px;
    height: 40px;
    color: var(--rb-card-text);
    opacity: 0.85;
}

.rb-card .rb-card-logo:hover { opacity: 1; }
.rb-card .rb-card-logo:focus-visible { outline: 2px solid #1172b7; outline-offset: 3px; border-radius: 2px; }

.rb-card .rb-card-logo span {
    display: block;
    width: 100%;
    height: 100%;
    background: currentColor;
    -webkit-mask: url('rig-builder-card-logo.svg?v=1') center / contain no-repeat;
    mask: url('rig-builder-card-logo.svg?v=1') center / contain no-repeat;
}

.rb-card--framed .rb-card-actions { padding-right: 62px; }

/* Inside an /embed/ iframe the card is the whole page. */
.rb-embed {
    margin: 0;
    padding: 0;
    background: transparent;
}

.rb-embed .rb-card { max-width: none; margin: 0; }

@media (max-width: 650px) {
    .rb-card .rb-card-media { flex-basis: 110px; }
    .rb-card .rb-card-media img { max-height: 110px; }
}

@media (max-width: 480px) {
    .rb-card { flex-direction: column; padding: 10px; }
    .rb-card .rb-card-logo { right: 10px; bottom: 10px; }
    .rb-card--product { align-items: stretch; }
    .rb-card--product .rb-card-media { align-self: stretch; }
    .rb-card .rb-card-media { align-self: stretch; }
    .rb-card .rb-card-media img { max-height: 180px; }
    .rb-card .rb-card-parts { grid-template-columns: minmax(0, 1fr); }
}
