/*
 * Rollpix Spin & Win — base styles, shared by the storefront and the admin
 * preview (hence view/base).
 *
 * Everything is namespaced under .rollpix-saw so it cannot leak into the theme.
 *
 * Colours are NOT baked in here: every one of them reads a custom property that
 * the widget sets from the admin configuration. A template therefore decides
 * *layout* only — which is why there is no "dark" or "neon" template. Dark is
 * just a different set of colours.
 *
 * Neither are type sizes. Every font-size is a calc() against --rpx-font-scale,
 * so "el texto se ve chico" is one number in the admin and not a stylesheet
 * edit. Layouts override the *base* px inside those calcs, never the calc
 * itself, so the admin's scale keeps applying whichever layout is on.
 *
 * The fallbacks in each var() are the shipped defaults, so the stylesheet is
 * still correct on its own if the config ever fails to load.
 */

.rollpix-saw {
    --rpx-overlay: rgba(0, 0, 0, .55);
    --rpx-modal-bg: #ffffff;
    --rpx-text: #1f1f1f;
    --rpx-muted: rgba(31, 31, 31, .75);
    --rpx-border: #cccccc;
    --rpx-button-bg: #1f1f1f;
    --rpx-button-text: #ffffff;
    --rpx-pointer: #1f1f1f;
    --rpx-icon-bg: #1f1f1f;
    --rpx-icon-text: #ffffff;
    --rpx-radius: 14px;

    /* Type scale (Apariencia → Escala tipográfica). 1 = the sizes below. */
    --rpx-font-scale: 1;
    --rpx-fs-title: calc(26px * var(--rpx-font-scale));
    --rpx-fs-description: calc(16px * var(--rpx-font-scale));
    --rpx-fs-input: calc(16px * var(--rpx-font-scale));
    --rpx-fs-button: calc(18px * var(--rpx-font-scale));
    --rpx-fs-consent: calc(14px * var(--rpx-font-scale));
    --rpx-fs-status: calc(16px * var(--rpx-font-scale));
    --rpx-fs-coupon: calc(24px * var(--rpx-font-scale));
    --rpx-fs-tab: calc(15px * var(--rpx-font-scale));

    /* Size is configuration too (Apariencia → Tamaño). Layouts that are sized
       by the viewport — side, sheet, bottom — deliberately ignore these. */
    --rpx-modal-w: 440px;
    --rpx-wheel-w: 320px;

    /* How far the floating launcher sits from the edges, and how big the round
       one is. Configurable because a fixed inset is what lands it on top of the
       site's own chat button, and because an uploaded logo rarely wants 52px. */
    --rpx-icon-x: 18px;
    --rpx-icon-y: 18px;
    --rpx-icon-size: 52px;
}

.rollpix-saw__overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--rpx-overlay);
    padding: 16px;
}

.rollpix-saw__overlay.is-open {
    display: flex;
}

.rollpix-saw__modal {
    position: relative;
    width: 100%;
    max-width: var(--rpx-modal-w);
    max-height: 92vh;
    overflow-y: auto;
    padding: 28px 24px 24px;
    border-radius: var(--rpx-radius);
    background: var(--rpx-modal-bg);
    color: var(--rpx-text);
    text-align: center;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
}

.rollpix-saw__close {
    position: absolute;
    top: 8px;
    right: 12px;
    border: 0;
    background: none;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    color: inherit;
}

.rollpix-saw__title {
    margin: 0 0 6px;
    font-size: var(--rpx-fs-title);
    color: inherit;
}

.rollpix-saw__description {
    margin: 0 0 14px;
    font-size: var(--rpx-fs-description);
    color: var(--rpx-muted);
}

.rollpix-saw__wheel {
    position: relative;
    display: inline-block;
    margin-bottom: 16px;
}

/* The display size lives here, not in the canvas attributes: the JS sizes the
   backing store to whatever CSS grants, so the wheel stays sharp at any scale. */
.rollpix-saw__canvas {
    display: block;
    width: var(--rpx-wheel-w);
    max-width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    transform: rotate(0deg);
}

/* Pointer sits at 12 o'clock — the template declares that angle as
   `pointer_angle: -90` and spinTo() lands the winning slice right here. */
.rollpix-saw__pointer {
    position: absolute;
    top: -6px;
    left: 50%;
    z-index: 2;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 20px solid var(--rpx-pointer);
}

.rollpix-saw__form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rollpix-saw__input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--rpx-border);
    border-radius: 8px;
    background: transparent;
    color: var(--rpx-text);
    /* Never below 16px: iOS Safari zooms the whole page when a focused input is
       smaller, and the popup ends up half off-screen. The admin can scale the
       type down without that side effect. */
    font-size: max(16px, var(--rpx-fs-input));
}

.rollpix-saw__consent {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: var(--rpx-fs-consent);
    line-height: 1.35;
    text-align: left;
    color: var(--rpx-muted);
}

.rollpix-saw__button {
    padding: 13px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--rpx-button-bg);
    color: var(--rpx-button-text);
    font-size: var(--rpx-fs-button);
    font-weight: 700;
    cursor: pointer;
}

.rollpix-saw__button[disabled] {
    opacity: .55;
    cursor: default;
}

.rollpix-saw__status {
    margin: 14px 0 0;
    font-size: var(--rpx-fs-status);
}

/* ── The prize ─────────────────────────────────────────────── */

/*
 * The code and a one-tap copy button.
 *
 * Selectable text alone is not enough on a phone: pressing the code raises the
 * platform's own selection toolbar over the popup, and the visitor has to drag
 * handles around to get twelve characters out. The code stays `user-select: all`
 * so that route still works — the button just makes it one tap.
 */

.rollpix-saw__coupon {
    display: none;
    margin-top: 10px;
}

.rollpix-saw__coupon.is-visible {
    display: block;
}

.rollpix-saw__coupon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 14px;
    border: 2px dashed var(--rpx-border);
    border-radius: 8px;
}

.rollpix-saw__coupon-code {
    font-size: var(--rpx-fs-coupon);
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1.2;
    word-break: break-all;
    user-select: all;
}

/*
 * Same hardening as the floating launcher: Luma styles `button` heavily and the
 * inherited padding, line-height and font would knock this out of square.
 */
.rollpix-saw__coupon-copy {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 36px;
    height: 36px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 1px solid var(--rpx-border);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s ease, color .15s ease;
}

.rollpix-saw__coupon-copy:hover,
.rollpix-saw__coupon-copy:focus-visible {
    border-color: var(--rpx-button-bg);
}

.rollpix-saw__coupon-copy:focus-visible {
    outline: 2px solid var(--rpx-button-bg);
    outline-offset: 2px;
}

/* Two stacked sheets, drawn in CSS. An emoji would render differently on every
   platform and ignore the configured colours — same reasoning as the launcher. */
.rollpix-saw__coupon-copy::before,
.rollpix-saw__coupon-copy::after {
    content: '';
    position: absolute;
    box-sizing: border-box;
    width: 12px;
    height: 14px;
    border: 2px solid currentColor;
    border-radius: 3px;
}

.rollpix-saw__coupon-copy::before {
    transform: translate(3px, -3px);
}

/* Painted after, so it reads as the sheet in front. Filled with the modal
   background to punch a hole in the one behind it. */
.rollpix-saw__coupon-copy::after {
    background: var(--rpx-modal-bg);
    transform: translate(-3px, 3px);
}

.rollpix-saw__coupon-copy.is-copied {
    border-color: var(--rpx-button-bg);
    color: var(--rpx-button-bg);
}

.rollpix-saw__coupon-copy.is-copied::before {
    width: 7px;
    height: 13px;
    border-width: 0 2px 2px 0;
    border-radius: 0;
    background: none;
    transform: translateY(-2px) rotate(45deg);
}

.rollpix-saw__coupon-copy.is-copied::after {
    content: none;
}

/* Reserves its line so the box does not jump when the confirmation appears. */
.rollpix-saw__coupon-feedback {
    display: block;
    min-height: 1.2em;
    margin-top: 6px;
    font-size: var(--rpx-fs-consent);
    color: var(--rpx-muted);
}

/* ── Launcher: round icon ──────────────────────────────────── */

/*
 * Hardened against the host theme: Luma themes style `button` heavily, and
 * inherited padding, line-height or font would knock the circle out of shape.
 * Everything that matters is reset here rather than assumed.
 */
.rollpix-saw__icon {
    position: fixed;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: var(--rpx-icon-size);
    height: var(--rpx-icon-size);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--rpx-icon-bg);
    color: var(--rpx-icon-text);
    font: inherit;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow .15s ease, filter .15s ease;
}

/*
 * No hover transform on purpose: the middle positions already use
 * translateY(-50%) to centre themselves, and a scale() here would overwrite it
 * and drop the launcher half a height down the page.
 */
.rollpix-saw__icon:hover,
.rollpix-saw__icon:focus-visible {
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    filter: brightness(1.08);
}

.rollpix-saw__icon:focus-visible {
    outline: 2px solid var(--rpx-icon-text);
    outline-offset: 2px;
}

/*
 * The glyph is a little wheel drawn in CSS, not an emoji: emoji render
 * differently on every platform, sit off-centre inside a circle, and ignore
 * the configured icon colour. It scales with the configured size.
 */
.rollpix-saw__icon::before {
    content: '';
    width: calc(var(--rpx-icon-size) * .5);
    height: calc(var(--rpx-icon-size) * .5);
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px currentColor;
    background: conic-gradient(
        currentColor 0 45deg,
        transparent 45deg 90deg,
        currentColor 90deg 135deg,
        transparent 135deg 180deg,
        currentColor 180deg 225deg,
        transparent 225deg 270deg,
        currentColor 270deg 315deg,
        transparent 315deg 360deg
    );
}

/* Hub, punched out in the icon's own background colour. */
.rollpix-saw__icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--rpx-icon-size) * .155);
    height: calc(var(--rpx-icon-size) * .155);
    margin: calc(var(--rpx-icon-size) * -.0775) 0 0 calc(var(--rpx-icon-size) * -.0775);
    border-radius: 50%;
    background: var(--rpx-icon-bg);
}

/* An uploaded image replaces the drawn glyph outright — both pseudo-elements
   have to go, or the wheel keeps showing through the artwork. */
.rollpix-saw__icon--custom {
    overflow: hidden;
}

.rollpix-saw__icon--custom::before,
.rollpix-saw__icon--custom::after {
    content: none;
}

.rollpix-saw__icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.rollpix-saw__icon--bottom-right {
    right: var(--rpx-icon-x);
    bottom: var(--rpx-icon-y);
}

.rollpix-saw__icon--bottom-left {
    left: var(--rpx-icon-x);
    bottom: var(--rpx-icon-y);
}

.rollpix-saw__icon--top-right {
    right: var(--rpx-icon-x);
    top: var(--rpx-icon-y);
}

.rollpix-saw__icon--top-left {
    left: var(--rpx-icon-x);
    top: var(--rpx-icon-y);
}

/* The middle positions are centred vertically, so only the horizontal
   distance applies to them. */
.rollpix-saw__icon--middle-right {
    right: var(--rpx-icon-x);
    top: 50%;
    transform: translateY(-50%);
}

.rollpix-saw__icon--middle-left {
    left: var(--rpx-icon-x);
    top: 50%;
    transform: translateY(-50%);
}

/* ── Launcher: tab with a label ────────────────────────────── */

/*
 * A pull-tab flush against the left or right edge, with the text running
 * vertically. It exists because a bare circle reads as "some widget" and the
 * visitor has to click it to find out; a label says what it is before the click.
 *
 * It shares the launcher colours and the six positions with the icon — only the
 * side and the vertical anchor of the chosen position apply, since a tab hanging
 * in a corner away from the edge would read as a stray button. It sits flush
 * against the edge, so the horizontal distance setting does not apply either.
 *
 * Same button reset as the icon, and for the same reason.
 */
.rollpix-saw__tab {
    position: fixed;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    max-height: 76vh;
    min-width: 0;
    margin: 0;
    padding: 18px 10px;
    border: 0;
    background: var(--rpx-icon-bg);
    color: var(--rpx-icon-text);
    font: inherit;
    font-size: var(--rpx-fs-tab);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: .02em;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    -webkit-appearance: none;
    appearance: none;
    transition: box-shadow .15s ease, filter .15s ease;
}

.rollpix-saw__tab:hover,
.rollpix-saw__tab:focus-visible {
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    filter: brightness(1.08);
}

.rollpix-saw__tab:focus-visible {
    outline: 2px solid var(--rpx-icon-text);
    outline-offset: 2px;
}

.rollpix-saw__tab-text {
    display: block;
    max-height: calc(76vh - 36px);
    overflow: hidden;
    /* Reads top-to-bottom on the right edge; the left-edge rules flip it so it
       reads bottom-to-top, which is the convention on that side. */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.rollpix-saw__tab--top-left,
.rollpix-saw__tab--bottom-left,
.rollpix-saw__tab--middle-left {
    left: 0;
    border-radius: 0 var(--rpx-radius) var(--rpx-radius) 0;
}

.rollpix-saw__tab--top-left .rollpix-saw__tab-text,
.rollpix-saw__tab--bottom-left .rollpix-saw__tab-text,
.rollpix-saw__tab--middle-left .rollpix-saw__tab-text {
    transform: rotate(180deg);
}

.rollpix-saw__tab--top-right,
.rollpix-saw__tab--bottom-right,
.rollpix-saw__tab--middle-right {
    right: 0;
    border-radius: var(--rpx-radius) 0 0 var(--rpx-radius);
}

.rollpix-saw__tab--top-left,
.rollpix-saw__tab--top-right {
    top: var(--rpx-icon-y);
}

.rollpix-saw__tab--bottom-left,
.rollpix-saw__tab--bottom-right {
    bottom: var(--rpx-icon-y);
}

.rollpix-saw__tab--middle-left,
.rollpix-saw__tab--middle-right {
    top: 50%;
    transform: translateY(-50%);
}

/* ── Template: split (dos columnas, modal centrado) ────────── */

/*
 * Wheel on the left, form on the right, both fully visible. Unlike `side` the
 * modal stays centred and the wheel is not clipped, which suits a wide desktop
 * without taking over the viewport.
 *
 * The row numbers are the flow children of the modal: title, description, form,
 * status, coupon. The wheel spans all of them in the first column.
 */

.rollpix-saw--split .rollpix-saw__modal {
    display: grid;
    grid-template-columns: auto minmax(240px, 1fr);
    column-gap: 26px;
    align-items: center;
    max-width: calc(var(--rpx-modal-w) + var(--rpx-wheel-w));
    text-align: left;
}

.rollpix-saw--split .rollpix-saw__wheel {
    grid-area: 1 / 1 / 6 / 2;
    align-self: center;
    margin-bottom: 0;
}

.rollpix-saw--split .rollpix-saw__title { grid-area: 1 / 2; align-self: end; }
.rollpix-saw--split .rollpix-saw__description { grid-area: 2 / 2; }
.rollpix-saw--split .rollpix-saw__form { grid-area: 3 / 2; }
.rollpix-saw--split .rollpix-saw__status { grid-area: 4 / 2; }
.rollpix-saw--split .rollpix-saw__coupon { grid-area: 5 / 2; text-align: center; }

@media (max-width: 720px) {
    .rollpix-saw--split .rollpix-saw__modal {
        display: block;
        max-width: var(--rpx-modal-w);
        text-align: center;
    }

    .rollpix-saw--split .rollpix-saw__wheel {
        margin-bottom: 16px;
    }
}

/* ── Template: sheet (barra inferior) ──────────────────────── */

/*
 * A bar along the bottom, but a bounded and centred one rather than edge to
 * edge: stretched across a 1920px screen the wheel drifts to the far left and
 * the form spreads over a thousand-odd pixels, which reads as a mistake. The
 * bar is capped, floats just above the bottom edge, and the wheel-plus-form
 * pair is centred inside it, so the composition holds at any screen width.
 *
 * Sized by the viewport rather than by the Tamaño setting, like the side one.
 */

.rollpix-saw--sheet {
    --rpx-fs-title: calc(21px * var(--rpx-font-scale));
    --rpx-fs-description: calc(15px * var(--rpx-font-scale));
}

.rollpix-saw--sheet .rollpix-saw__overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0 24px 24px;
}

.rollpix-saw--sheet .rollpix-saw__modal {
    display: grid;
    /* The form column is capped as well: centring a pair whose second half
       keeps growing only moves the wheel further from the middle. */
    grid-template-columns: auto minmax(240px, 440px);
    justify-content: center;
    column-gap: 28px;
    align-items: center;
    width: 100%;
    max-width: min(920px, 100%);
    max-height: 60vh;
    padding: 16px 28px;
    border-radius: var(--rpx-radius);
    text-align: left;
}

.rollpix-saw--sheet .rollpix-saw__canvas {
    width: 170px;
}

.rollpix-saw--sheet .rollpix-saw__wheel {
    grid-area: 1 / 1 / 6 / 2;
    align-self: center;
    margin-bottom: 0;
}

.rollpix-saw--sheet .rollpix-saw__title { grid-area: 1 / 2; align-self: end; }
.rollpix-saw--sheet .rollpix-saw__description { grid-area: 2 / 2; margin-bottom: 8px; }
.rollpix-saw--sheet .rollpix-saw__form { grid-area: 3 / 2; }
.rollpix-saw--sheet .rollpix-saw__status { grid-area: 4 / 2; }
.rollpix-saw--sheet .rollpix-saw__coupon { grid-area: 5 / 2; text-align: center; }

@media (max-width: 720px) {
    .rollpix-saw--sheet .rollpix-saw__overlay {
        padding: 0 12px 12px;
    }

    .rollpix-saw--sheet .rollpix-saw__modal {
        display: block;
        max-height: 88vh;
        overflow-y: auto;
        padding: 20px;
        text-align: center;
    }

    .rollpix-saw--sheet .rollpix-saw__wheel {
        margin: 0 auto 14px;
    }

    .rollpix-saw--sheet .rollpix-saw__canvas {
        width: 200px;
    }
}

/* ── Template: corner (tarjeta anclada) ────────────────────── */

/*
 * A small card docked to the bottom-right, like a chat widget. The one layout
 * that does NOT block the page: the backdrop is transparent and lets clicks
 * through, so the visitor can keep browsing with the wheel sitting there.
 * The overlay colour setting therefore has no effect on this layout.
 */

.rollpix-saw--corner {
    --rpx-fs-title: calc(21px * var(--rpx-font-scale));
}

.rollpix-saw--corner .rollpix-saw__overlay {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 18px;
    background: transparent;
    pointer-events: none;
}

.rollpix-saw--corner .rollpix-saw__modal {
    pointer-events: auto;
    width: auto;
    max-width: min(var(--rpx-modal-w), 380px);
    max-height: 86vh;
    padding: 22px 20px 20px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .3);
}

.rollpix-saw--corner .rollpix-saw__canvas {
    width: min(var(--rpx-wheel-w), 230px);
}

@media (max-width: 720px) {
    .rollpix-saw--corner .rollpix-saw__overlay {
        align-items: center;
        justify-content: center;
    }
}

/* ── Template: side (media rueda a pantalla completa) ──────── */

/*
 * A panel flush against the left edge of the viewport, full height, with an
 * oversized wheel whose centre sits off-screen so the visible half runs from
 * top to bottom. The pointer is on the inner edge at 3 o'clock, which is why
 * this template declares `pointer_angle: 0` in di.xml — the spin animation
 * reads that angle, so moving the pointer in CSS alone would stop the wheel on
 * the wrong slice.
 *
 * The three sizes go through custom properties so the admin preview can render
 * the same layout inside a box instead of a viewport.
 */

.rollpix-saw--side {
    --rpx-panel-h: 100vh;
    --rpx-wheel-size: min(104vh, 860px);
    --rpx-wheel-visible: min(52vh, 430px);
    --rpx-fs-title: calc(32px * var(--rpx-font-scale));
}

.rollpix-saw--side .rollpix-saw__overlay {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
}

.rollpix-saw--side .rollpix-saw__modal {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: min(960px, 100vw);
    max-width: none;
    height: var(--rpx-panel-h);
    max-height: var(--rpx-panel-h);
    margin: 0;
    padding: 40px 40px 40px 0;
    border-radius: 0 var(--rpx-radius) var(--rpx-radius) 0;
    overflow: hidden;
}

/* Out of the flex flow: the wheel is decoration positioned against the edge,
   and the form column centres itself without having to account for it. */
.rollpix-saw--side .rollpix-saw__wheel {
    position: absolute;
    top: 50%;
    left: 0;
    margin: 0;
    transform: translate(-52%, -50%);
}

.rollpix-saw--side .rollpix-saw__canvas {
    width: var(--rpx-wheel-size);
    max-width: none;
}

.rollpix-saw--side .rollpix-saw__pointer {
    top: 50%;
    right: -2px;
    left: auto;
    transform: translateY(-50%);
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-right: 22px solid var(--rpx-pointer);
    border-left: 0;
}

/* Clear the visible half of the wheel. */
.rollpix-saw--side .rollpix-saw__title,
.rollpix-saw--side .rollpix-saw__description,
.rollpix-saw--side .rollpix-saw__form,
.rollpix-saw--side .rollpix-saw__status,
.rollpix-saw--side .rollpix-saw__coupon {
    position: relative;
    z-index: 1;
    margin-left: calc(var(--rpx-wheel-visible) + 44px);
    max-width: 420px;
    text-align: left;
}

.rollpix-saw--side .rollpix-saw__title {
    margin-bottom: 8px;
}

.rollpix-saw--side .rollpix-saw__coupon {
    text-align: center;
}

/*
 * Narrow viewports keep the very same composition — half wheel against the
 * edge, form beside it — instead of falling back to another layout. Two things
 * change.
 *
 * The panel takes half the screen rather than all of it: a phone-sized viewport
 * covered edge to edge reads as taking over the site, and the popup is meant to
 * be an offer, not a wall. It centres vertically and stays glued to the left.
 *
 * And the wheel takes its diameter from whichever of height and width is
 * smaller, showing a narrower slice of itself than on desktop. On a wide screen
 * the diameter follows the viewport HEIGHT, which is what makes the visible half
 * run top to bottom; in portrait that same rule yields an ~880px wheel whose
 * visible half eats the entire width and leaves nothing for the form.
 *
 * `--rpx-wheel-visible` has to stay exactly half of `--rpx-wheel-size`: it is
 * what the form column's offset is measured against, and if the two drift the
 * copy lands on top of the wheel.
 *
 * The pointer stays at 3 o'clock throughout, so `pointer_angle: 0` holds and
 * the wheel cannot stop on a different slice than the one the server drew.
 *
 * This breakpoint is about how the layout copes with a narrow screen, not about
 * *which* layout the device gets — that is the widget's call and it uses its own
 * 768px line. A site running `side` on both sizes still needs this.
 */
@media (max-width: 900px) {
    .rollpix-saw--side {
        /* Half the screen, with a floor so a landscape phone — which has very
           little height to give — still fits the form. */
        --rpx-panel-h: min(100vh, max(50vh, 340px));
        --rpx-wheel-size: min(52vh, 64vw);
        --rpx-wheel-visible: min(26vh, 32vw);
        --rpx-fs-title: calc(22px * var(--rpx-font-scale));
        --rpx-fs-description: calc(15px * var(--rpx-font-scale));
        --rpx-fs-coupon: calc(20px * var(--rpx-font-scale));
    }

    /* A half-height panel centres vertically instead of stretching, and stays
       flush against the left edge. */
    .rollpix-saw--side .rollpix-saw__overlay {
        align-items: center;
        justify-content: flex-start;
    }

    .rollpix-saw--side .rollpix-saw__modal {
        width: 100vw;
        padding: 20px 16px 20px 0;
        border-radius: 0 var(--rpx-radius) var(--rpx-radius) 0;
    }

    .rollpix-saw--side .rollpix-saw__title,
    .rollpix-saw--side .rollpix-saw__description,
    .rollpix-saw--side .rollpix-saw__form,
    .rollpix-saw--side .rollpix-saw__status,
    .rollpix-saw--side .rollpix-saw__coupon {
        margin-left: calc(var(--rpx-wheel-visible) + 16px);
        max-width: none;
    }

    .rollpix-saw--side .rollpix-saw__coupon-code {
        letter-spacing: 1px;
    }
}

/* ── Template: bottom (mitad inferior, rueda sangrada) ─────── */

/*
 * The layout the client asked for by pointing at eroship: a full-width panel
 * over the bottom of the screen, a big wheel bleeding out of its top-left
 * corner so only the inner quadrant shows, and the copy stacked and centred
 * underneath.
 *
 * It is the opposite call to `sheet`, which was pulled back from edge to edge
 * in 1.6.3 precisely because a full-width bar strands the wheel on the far left
 * of a 1920px screen. This one gets away with full width because nothing is
 * centred *against* the wheel: the wheel is anchored decoration in a corner and
 * the copy centres in the panel on its own.
 *
 * Sized by the viewport like `side` and `sheet`, so the Tamaño setting does not
 * apply. Everything goes through custom properties so the admin preview can
 * reproduce it inside a box instead of a viewport.
 */

.rollpix-saw--bottom {
    --rpx-panel-h: min(92vh, max(62vh, 430px));
    /* Capped against the height too: a landscape phone has almost none to give,
       and a wheel sized off width alone would leave no room for the form. */
    --rpx-wheel-size: min(68vw, 52vh, 460px);
    /*
     * Centre of the wheel, measured from the panel's top-left corner and
     * expressed as a fraction of the diameter — NOT of the panel. A percentage
     * of the panel would drift right as the screen widens and the wheel would
     * stop bleeding off the edge, which is the whole effect.
     */
    --rpx-wheel-cx: calc(var(--rpx-wheel-size) * .27);
    --rpx-wheel-cy: calc(var(--rpx-wheel-size) * .05);
    --rpx-fs-title: calc(30px * var(--rpx-font-scale));
    --rpx-fs-description: calc(17px * var(--rpx-font-scale));
    --rpx-fs-button: calc(19px * var(--rpx-font-scale));
}

.rollpix-saw--bottom .rollpix-saw__overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.rollpix-saw--bottom .rollpix-saw__modal {
    position: relative;
    width: 100%;
    max-width: none;
    height: var(--rpx-panel-h);
    max-height: var(--rpx-panel-h);
    margin: 0;
    /*
     * The top padding clears the visible bottom of the wheel: the centre offset
     * plus the radius, plus air. It is tied to the same custom properties as the
     * wheel on purpose — hardcode it and the copy lands on top of the wheel the
     * first time either number changes.
     */
    padding: calc(var(--rpx-wheel-cy) + var(--rpx-wheel-size) / 2 + 32px) 24px 28px;
    border-radius: var(--rpx-radius) var(--rpx-radius) 0 0;
    /*
     * Overflow past the top and left edges is clipped and never scrollable, so
     * `auto` crops the wheel exactly like `hidden` would while still letting a
     * long form scroll on a short screen. `hidden` would trap it.
     */
    overflow-x: hidden;
    overflow-y: auto;
    text-align: center;
}

.rollpix-saw--bottom .rollpix-saw__wheel {
    position: absolute;
    top: var(--rpx-wheel-cy);
    left: var(--rpx-wheel-cx);
    z-index: 0;
    margin: 0;
    transform: translate(-50%, -50%);
}

.rollpix-saw--bottom .rollpix-saw__canvas {
    width: var(--rpx-wheel-size);
    max-width: none;
}

/*
 * The pointer rides the diagonal, not the top: the wheel's centre is tucked
 * against the panel's top-left corner, so 12 o'clock would be off-screen and the
 * visitor would never see where the wheel stops. `pointer_angle: 30` in di.xml
 * has to keep matching the rotation here — the spin lands the winning slice at
 * that angle, and a pointer drawn anywhere else would be pointing at a prize
 * nobody won.
 *
 * The element is a bar as wide as the diameter, centred on the hub and rotated:
 * its far end therefore always lands on the rim, whatever the wheel measures.
 */
.rollpix-saw--bottom .rollpix-saw__pointer {
    top: 50%;
    left: 50%;
    width: var(--rpx-wheel-size);
    height: 26px;
    margin: -13px 0 0 calc(var(--rpx-wheel-size) / -2);
    border: 0;
    background: none;
    transform: rotate(30deg);
}

.rollpix-saw--bottom .rollpix-saw__pointer::after {
    content: '';
    position: absolute;
    top: 0;
    right: -2px;
    width: 0;
    height: 0;
    border-top: 13px solid transparent;
    border-bottom: 13px solid transparent;
    border-right: 20px solid var(--rpx-pointer);
}

/* Above the wheel, and capped so the copy does not spread across a wide screen
   just because the panel does. */
.rollpix-saw--bottom .rollpix-saw__title,
.rollpix-saw--bottom .rollpix-saw__description,
.rollpix-saw--bottom .rollpix-saw__form,
.rollpix-saw--bottom .rollpix-saw__status,
.rollpix-saw--bottom .rollpix-saw__coupon {
    position: relative;
    z-index: 1;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.rollpix-saw--bottom .rollpix-saw__title {
    margin-bottom: 8px;
}

.rollpix-saw--bottom .rollpix-saw__description {
    margin-bottom: 18px;
}
