/*
 * iframe4.css -- IFRAME 4 (Templates/_shared/iframe4.aspx)
 *
 * Form-only card capture, Google-style underlined fields with floating labels, on a
 * TRANSPARENT background so the frame blends into the host page. No header, no
 * buttons. Host-side styling hooks are out of scope for v1.
 *
 * Layout:
 *   row 1  card number (flex) | MM / YY | CVC (fixed width, hint icon inside)
 *   row 2  cardholder name 60% | postal code 40%  (cardholder 100% without postal)
 *   narrow frames (< 400px): card number takes row 1 alone; MM / YY | CVC wrap below.
 *
 * Fonts: the CCE CSP allows font-src 'self' only, so Google Fonts cannot load here;
 * Roboto is used when the device has it, else the platform UI font.
 */

:root {
    --cv4-text: #202124;
    --cv4-label: #80868b;
    --cv4-label-float: #5f6368;
    --cv4-line: #dadce0;
    --cv4-accent: #1a73e8;
    --cv4-error: #d93025;
    --cv4-tip-bg: #3c4043;
}

html, body {
    margin: 0;
    padding: 0;
    background: transparent;
}

body {
    font-family: Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--cv4-text);
    -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }

form { margin: 0; }

.cv4-form { padding: 0 2px 2px; }

/* -- Rows ----------------------------------------------------------------------- */

.cv4-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.cv4-row-card > * { flex-shrink: 0; }

/* The number field takes whatever the fixed-width expiry / CVC leave. It is a size
   container so the idle accepted-brands row can drop out when there is no room. */
.cv4-num {
    flex: 1 1 auto;
    flex-shrink: 1;
    min-width: 0;
    container-type: inline-size;
}

.cv4-holder { flex: 3 1 0; min-width: 0; }
.cv4-postal { flex: 2 1 0; min-width: 0; }

/* -- Field: underline + floating label ------------------------------------------ */

.cv4-field {
    position: relative;
    padding-top: 16px;
    margin-bottom: 8px;
}

.cv4-box { position: relative; }

.cv4-field input {
    display: block;
    width: 100%;
    height: 32px;
    margin: 0;
    padding: 6px 0;
    border: 0;
    border-bottom: 1px solid var(--cv4-line);
    border-radius: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: 20px;
    color: var(--cv4-text);
    -webkit-appearance: none;
    appearance: none;
}

/* The label sits on the input line while the field is empty and idle, and floats
   above it when the field has focus or a value (.cv4-float, set by cv-iframe4.js). */
.cv4-field label {
    position: absolute;
    left: 0;
    top: 6px;
    font-size: 16px;
    line-height: 20px;
    color: var(--cv4-label);
    white-space: nowrap;
    pointer-events: none;
    transition: top .15s ease, font-size .15s ease, color .15s ease;
}

.cv4-field.cv4-float label {
    top: -16px;
    font-size: 12px;
    line-height: 16px;
    color: var(--cv4-label-float);
}

.cv4-accent {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--cv4-accent);
    transform: scaleX(0);
    transition: transform .2s ease;
    pointer-events: none;
}

.cv4-field.cv4-focus .cv4-accent { transform: scaleX(1); }
.cv4-field.cv4-focus label { color: var(--cv4-accent); }

/* Error: red underline; the label stays grey (Google's behaviour). */
.cv4-field.cv4-invalid .cv4-accent { transform: scaleX(1); background: var(--cv4-error); }
.cv4-field.cv4-focus.cv4-invalid label { color: var(--cv4-label-float); }

.cv4-err {
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--cv4-error);
}

.cv4-err:empty { display: none; }

/* -- Card number: brand icons at the right end of the field --------------------- */

.cv4-brands {
    position: absolute;
    right: 0;
    top: 6px;
    display: flex;
    gap: 4px;
    pointer-events: none;
}

.cv4-brands img {
    display: block;
    width: 32px;
    height: 20px;
    border-radius: 2px;
}

.cv4-num.cv4-has-brand input { padding-right: 40px; }

@container (max-width: 279px) {
    .cv4-num .cv4-brands.cv4-all { display: none; }
}

/* -- Expiry --------------------------------------------------------------------- */

.cv4-exp {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.cv4-mm, .cv4-yy { width: 44px; }

.cv4-slash {
    padding-top: 22px;
    font-size: 16px;
    line-height: 20px;
    color: var(--cv4-label);
}

.cv4-exp-col .cv4-err { margin-top: -4px; max-width: 104px; }

/* -- CVC: fixed width; the hint icon shows only while focus is in the CVC field -- */

.cv4-cvc { width: 84px; }

.cv4-cvc input { padding-right: 34px; }

.cv4-cvc-hint {
    position: absolute;
    right: 0;
    top: 5px;
    display: none;
    cursor: help;
    outline: 0;
}

.cv4-cvc:focus-within .cv4-cvc-hint { display: block; }

.cv4-cvc-hint img {
    display: block;
    width: 30px;
    height: 19px;
}

.cv4-cvc-hint:focus img { outline: 2px solid var(--cv4-accent); outline-offset: 1px; }

.cv4-tip {
    display: none;
    position: absolute;
    right: 0;
    top: 26px;
    z-index: 5;
    width: 220px;
    padding: 8px 10px;
    border-radius: 4px;
    background: var(--cv4-tip-bg);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
}

.cv4-cvc-hint:hover .cv4-tip,
.cv4-cvc-hint:focus .cv4-tip { display: block; }

/* -- Status line (server decline / error) --------------------------------------- */

.cv4-status {
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--cv4-error);
}

/* -- Hard error (form not configured) ------------------------------------------- */

.cv4-hard-error {
    padding: 12px 0;
    font-size: 14px;
    color: var(--cv4-error);
}

/* -- Narrow frames ---------------------------------------------------------------- */

@media (max-width: 399px) {
    .cv4-row-card { flex-wrap: wrap; row-gap: 4px; }
    .cv4-num { flex-basis: 100%; }
    .cv4-opt { display: none; }
}

/* A label never spills out of its field, however narrow the frame. */
.cv4-field label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
