/*
 * components/earn.css
 *
 * Earn Cashback page (/earn): restaurant picker, the per-restaurant review/
 * share type cards (icon + reward + example screenshot + admin instructions +
 * claim status + submit), the submit modal, and the example-screenshot
 * lightbox. Colours/spacing come from base.css :root tokens (single source).
 * Desktop/mobile tweaks live in desktop.css / mobile.css per convention.
 */

.earn {
    max-width: 920px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4) var(--space-16);
}

/* ── Header ──────────────────────────────────────────────────────── */
.earn__head { text-align: center; margin-bottom: var(--space-8); }
.earn__title { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.earn__title span { color: var(--color-primary); }
.earn__sub { color: var(--color-text-muted); margin: var(--space-2) 0 0; }

/* ── Restaurant bar (per-restaurant view) ───────────────────────── */
.earn__bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-3); margin-bottom: var(--space-6);
}
.earn__back { color: var(--color-text-muted); font-weight: 600; font-size: 0.92rem; }
.earn__back:hover { color: var(--color-primary); }
.earn__resto { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; }
.earn__resto-badge {
    width: 30px; height: 30px; border-radius: var(--radius-pill);
    display: grid; place-items: center; font-size: 0.9rem; color: #fff;
    background: var(--color-primary);
}

/* ── Restaurant picker ───────────────────────────────────────────── */
.earn-restos { display: grid; gap: var(--space-3); }
.eresto {
    display: flex; align-items: center; gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--color-bg); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.eresto:hover { box-shadow: var(--shadow-2); border-color: var(--color-text-soft); transform: translateY(-1px); }
.eresto__badge {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: var(--radius-pill);
    display: grid; place-items: center; font-size: 1.2rem; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}
.eresto__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.eresto__name { font-weight: 700; color: var(--color-text); }
.eresto__meta { font-size: 0.85rem; color: var(--color-text-muted); }
.eresto__reward {
    flex: 0 0 auto; font-weight: 700; font-size: 0.9rem; color: var(--color-success);
    background: #E9F8F0; border-radius: var(--radius-pill); padding: 4px 12px;
}

/* ── Type cards — HORIZONTAL rows: example shot LEFT, copy RIGHT ──────
   Was a 3-up grid of ~280px columns, which squeezed the long CMS
   instructions into a narrow column where they overflowed and got clipped
   by the card's overflow:hidden. One full-width row per type gives the copy
   the whole remaining width. */
.earn-grid {
    display: flex; flex-direction: column; gap: var(--space-5);
}
.ecard {
    display: flex; align-items: stretch;
    background: var(--color-bg); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
    overflow: hidden;
}
/* Left column — the example screenshot, letterboxed to a fixed width. */
.ecard__shot {
    position: relative; flex: 0 0 240px; min-width: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-bg-alt);
    border-right: 1px solid var(--color-border-soft);
}
.ecard__shot img {
    display: block; width: 100%; height: 100%; max-height: 340px;
    object-fit: contain; cursor: zoom-in;
}
.ecard__shot-tag {
    position: absolute; top: var(--space-2); left: var(--space-2);
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--color-text-muted); background: rgba(255, 255, 255, 0.92);
    border-radius: var(--radius-sm); padding: 2px 7px;
}
/* Right column — head + copy + actions stacked. `min-width: 0` is the fix
   that lets long text WRAP inside a flex child instead of overflowing. */
.ecard__body {
    flex: 1 1 auto; min-width: 0;
    display: flex; flex-direction: column;
}
.ecard__head {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-soft);
}
.ecard__icon { font-size: 1.4rem; line-height: 1; }
.ecard__name {
    flex: 1 1 auto; min-width: 0; font-weight: 700;
    overflow-wrap: anywhere;
}
.ecard__reward {
    flex: 0 0 auto; font-weight: 800; font-size: 0.95rem; color: #fff;
    background: var(--color-primary); border-radius: var(--radius-pill);
    padding: 3px 12px;
}
.ecard__desc {
    flex: 1 1 auto; min-width: 0;
    padding: var(--space-4) var(--space-5);
    color: var(--color-text-muted); font-size: 0.92rem; line-height: 1.5;
    overflow-wrap: anywhere; word-break: break-word;
}
/* Admin CMS copy can carry fixed widths / wide tables — keep it inside. */
.ecard__desc > * { max-width: 100%; }
.ecard__desc table { display: block; width: 100%; overflow-x: auto; }
.ecard__desc p { margin: 0 0 var(--space-2); }
.ecard__desc p:last-child { margin-bottom: 0; }
.ecard__desc ul, .ecard__desc ol { margin: 0 0 var(--space-2); padding-left: 1.2em; }
.ecard__desc a { color: var(--color-primary-dark); font-weight: 600; }
.ecard__desc img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* Wide card → status on the left, action on the right. */
.ecard__foot {
    margin-top: auto;
    display: flex; flex-direction: row; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border-soft);
}
/* Claim-status alert — legacy showed pending / approved / rejected as a
   full-width coloured bar with a left accent, not a pill. Same three colours. */
.ecard__alert {
    display: flex; align-items: flex-start; gap: var(--space-2);
    margin: 0 var(--space-5) var(--space-4);
    padding: var(--space-3) var(--space-4);
    font-size: 0.9rem; font-weight: 600; line-height: 1.45;
    border-radius: var(--radius-sm); border-left: 4px solid currentColor;
}
.ecard__alert-ic { flex: 0 0 auto; }
.ecard__alert strong { font-weight: 700; }
.ecard__alert.is-pending  { color: #9A6A00; background: #FFF4DA; }
.ecard__alert.is-approved { color: var(--color-success); background: #E9F8F0; }
.ecard__alert.is-rejected { color: var(--color-primary-dark); background: var(--color-primary-soft); }
.ecard__btn {
    appearance: none; cursor: pointer;
    margin-left: auto; min-width: 190px;
    font-family: inherit; font-weight: 700; font-size: 0.95rem;
    color: #fff; background: var(--color-primary);
    border: 0; border-radius: var(--radius-md); padding: 11px 16px;
    transition: background-color 0.16s ease;
}
.ecard__btn:hover { background: var(--color-primary-dark); }
.ecard__btn.is-done { background: var(--color-bg-alt); color: var(--color-text-soft); cursor: default; }

/* ── Narrow screens — stack the horizontal card back to a column ────── */
@media (max-width: 760px) {
    .ecard { flex-direction: column; }
    .ecard__shot {
        flex: 0 0 auto;
        border-right: 0; border-bottom: 1px solid var(--color-border-soft);
    }
    .ecard__shot img { height: auto; max-height: 240px; }
    .ecard__foot { flex-direction: column; align-items: stretch; }
    .ecard__btn { margin-left: 0; min-width: 0; width: 100%; }
}

/* On phones this is a focused screen inside the account shell — the
   .acct-mobilebar shows the "Earn Cashback" title, so hide the page's own
   heading to avoid a duplicate. */
@media (max-width: 767px) {
    .earn__head { display: none; }
    .acct .earn { max-width: 100%; padding-top: var(--space-3); }
}

/* ── Empty state ─────────────────────────────────────────────────── */
.earn-empty {
    text-align: center; padding: var(--space-12) var(--space-4);
    color: var(--color-text-muted);
}
.earn-empty__ic { font-size: 2.6rem; display: block; margin-bottom: var(--space-3); }

/* ── Submit modal ────────────────────────────────────────────────── */
.earn-modal {
    position: fixed; inset: 0; z-index: 1200;
    display: flex; align-items: center; justify-content: center;
    padding: var(--space-4);
}
.earn-modal[hidden] { display: none; }
.earn-modal__backdrop { position: absolute; inset: 0; background: rgba(20, 20, 20, 0.5); }
.earn-modal__panel {
    position: relative; z-index: 1; width: 100%; max-width: 440px;
    background: var(--color-bg); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3); overflow: hidden;
    display: flex; flex-direction: column; max-height: 90vh;
}
.earn-modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border-soft);
}
.earn-modal__title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.earn-modal__x {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    font-size: 1.1rem; color: var(--color-text-muted); line-height: 1; padding: 4px;
}
.earn-modal__x:hover { color: var(--color-text); }
.earn-modal__body { padding: var(--space-5); overflow-y: auto; }
.earn-modal__reward { margin: 0 0 var(--space-4); color: var(--color-success); font-weight: 600; font-size: 0.9rem; }
.earn-modal__foot {
    display: flex; justify-content: flex-end; gap: var(--space-3);
    padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border-soft);
}

.earn-field { margin-bottom: var(--space-4); }
.earn-field:last-child { margin-bottom: 0; }
.earn-field__lbl { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: var(--space-2); }
.earn-field__opt { color: var(--color-text-soft); font-weight: 400; }
.earn-field__err { margin: var(--space-2) 0 0; color: var(--color-primary-dark); font-size: 0.85rem; }
.earn-field.has-err .earn-input,
.earn-field.has-err .earn-file { border-color: var(--color-primary); }

.earn-input {
    width: 100%; font-family: inherit; font-size: 0.95rem; color: var(--color-text);
    background: var(--color-bg); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); padding: 10px 12px;
}
.earn-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.earn-input--area { resize: vertical; min-height: 56px; }

.earn-file { display: block; cursor: pointer; }
.earn-file__input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.earn-file__face {
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: 88px; padding: var(--space-4);
    color: var(--color-text-muted); font-size: 0.9rem;
    background: var(--color-bg-soft); border: 1.5px dashed var(--color-border);
    border-radius: var(--radius-md);
}
.earn-file:hover .earn-file__face { border-color: var(--color-primary); color: var(--color-text); }

body.earn-modal-open { overflow: hidden; }

/* ── Example-screenshot lightbox ─────────────────────────────────── */
.earn-zoom {
    position: fixed; inset: 0; z-index: 1300;
    display: flex; align-items: center; justify-content: center;
    padding: var(--space-6); background: rgba(20, 20, 20, 0.82);
}
.earn-zoom[hidden] { display: none; }
.earn-zoom img { max-width: 100%; max-height: 86vh; border-radius: var(--radius-md); box-shadow: var(--shadow-3); }
.earn-zoom__close {
    position: absolute; top: var(--space-4); right: var(--space-4);
    appearance: none; border: 0; cursor: pointer;
    width: 40px; height: 40px; border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 1.1rem;
}
.earn-zoom__close:hover { background: rgba(255, 255, 255, 0.28); }

/* ── PWA-audit mobile fixes ──────────────────────────────────────── */
@media (max-width: 767px) {
    /* C1: 16px input so iOS doesn't zoom on focus. */
    .earn-input { font-size: 16px; }
    /* C2: enlarge the modal-close hit area to >=44px without growing the glyph. */
    .earn-modal__x {
        min-width: 44px; min-height: 44px;
        display: inline-flex; align-items: center; justify-content: center;
    }
    /* C2: lightbox close is fixed 40px — override to 44px. */
    .earn-zoom__close { width: 44px; height: 44px; }
}
