/* ==========================================================================
   Loyalty app - mobile first.
   Hand written on purpose: no build step, no CDN, works offline on the phone.
   ========================================================================== */

:root {
    --red: #e8112d;
    --red-dark: #c20f26;
    --red-soft: #fdecee;
    --black: #14171a;
    --ink: #1b1f23;
    --muted: #6b7480;
    --line: #e8eaed;
    --bg: #f4f5f7;
    --white: #fff;
    --green: #16a34a;
    --amber: #b45309;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 2px 10px rgba(20, 23, 26, .07);
    --shadow-lg: 0 10px 30px rgba(20, 23, 26, .13);
    --tab-h: 62px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    /* Stops the pull-to-refresh gesture fighting the browser's own. */
    overscroll-behavior-y: contain;
}

a { color: var(--red); text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* Screen shell ----------------------------------------------------------- */

.screen {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
}

.screen--tabs { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }

.screen--center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 24px calc(32px + var(--safe-b));
    background: var(--white);
}

.content { padding: 16px; }

/* Top bar ---------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 14px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.topbar__title {
    flex: 1;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
}

.topbar__title--left { text-align: left; }

.iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    position: relative;
    padding: 0;
}

.iconbtn:active { background: var(--bg); }

.iconbtn__dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid var(--white);
}

/* Brand ------------------------------------------------------------------ */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: .02em;
}

.brand__a { color: var(--black); }
.brand__amp { color: var(--muted); font-weight: 700; }
.brand__b { color: var(--red); }

.brand-mark { display: block; margin: 0 auto 22px; }

.brand-wordmark {
    text-align: center;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 26px;
}

/* Typography helpers ----------------------------------------------------- */

.h-greet { font-size: 21px; font-weight: 700; }
.h-section { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }
.h-hero { font-size: 25px; font-weight: 800; text-align: center; margin-bottom: 8px; }

.sub { color: var(--muted); font-size: 13px; }
.sub--center { text-align: center; }
.lead { color: var(--muted); text-align: center; margin: 0 auto 28px; max-width: 19em; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }

/* Points card ------------------------------------------------------------ */

.points-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    padding: 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
    box-shadow: var(--shadow-lg);
}

.points-card--dark {
    background: linear-gradient(135deg, #24282d 0%, var(--black) 70%);
}

.points-card__label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    opacity: .9;
}

.points-card__value {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.points-card__unit { font-size: 14px; opacity: .9; }

.points-card__meta {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .22);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

/* Watermark behind the number, mirroring the mockup. */
.points-card__mark {
    position: absolute;
    right: -18px;
    bottom: -26px;
    opacity: .13;
    pointer-events: none;
}

.points-card__link {
    display: inline-block;
    margin-top: 14px;
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

/* Buttons ---------------------------------------------------------------- */

.btn {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border: 0;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    font-family: inherit;
}

.btn + .btn { margin-top: 12px; }

.btn--primary { background: var(--red); color: #fff; }
.btn--primary:active { background: var(--red-dark); }

.btn--ghost {
    background: var(--white);
    color: var(--ink);
    border: 1.5px solid var(--line);
}

.btn--dark { background: var(--black); color: #fff; }

.btn--link {
    background: none;
    border: 0;
    color: var(--muted);
    font-weight: 600;
    padding: 12px;
}

.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--sm { width: auto; padding: 9px 16px; font-size: 13px; }

/* Forms ------------------------------------------------------------------ */

.field { margin-bottom: 16px; }

.field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.field__input {
    width: 100%;
    padding: 13px 14px;
    font-size: 16px; /* 16px stops iOS zooming on focus */
    font-family: inherit;
    color: var(--ink);
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
}

.field__input:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}

.field__input[readonly] { background: var(--bg); color: var(--muted); }

.field__error { color: var(--red); font-size: 13px; margin-top: 6px; }
.field__help { color: var(--muted); font-size: 12px; margin-top: 6px; }

.field__row { display: flex; gap: 10px; }
.field__row > * { flex: 1; }

/* Cards and lists -------------------------------------------------------- */

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card + .card { margin-top: 12px; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.tile:active { background: var(--bg); }

.list { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.list__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}

.list__item:last-child { border-bottom: 0; }
.list__item:active { background: var(--bg); }

.list__body { flex: 1; min-width: 0; }
.list__title { font-weight: 600; font-size: 14px; }
.list__sub { color: var(--muted); font-size: 12.5px; }

.list__amount { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.list__amount--plus { color: var(--green); }
.list__amount--minus { color: var(--red); }
.list__amount--muted { color: var(--muted); }

.icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    background: var(--bg);
    color: var(--muted);
}

.icon-badge--green { background: #e7f6ec; color: var(--green); }
.icon-badge--red { background: var(--red-soft); color: var(--red); }
.icon-badge--amber { background: #fdf3e3; color: var(--amber); }
.icon-badge--round { border-radius: 50%; }

/* Reward rows ------------------------------------------------------------ */

.reward {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--ink);
}

.reward + .reward { margin-top: 10px; }

.reward__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 14px;
    background: var(--red-soft);
    color: var(--red);
}

.reward__body { flex: 1; min-width: 0; }
.reward__title { font-weight: 700; font-size: 16px; }
.reward__points { color: var(--red); font-weight: 700; font-size: 13.5px; }
.reward__points--muted { color: var(--muted); }
.reward--locked { opacity: .62; }

/* Tabs / filters --------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs__tab {
    flex: 0 0 auto;
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--white);
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid var(--line);
}

.tabs__tab--active {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* Group headings in the history / notification feeds. */
.group-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    margin: 18px 0 8px;
}

/* Bottom tab bar --------------------------------------------------------- */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    max-width: 480px;
    margin: 0 auto;
    background: var(--white);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-b);
}

.tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: var(--tab-h);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.tabbar__item--active { color: var(--red); }

/* Profile ---------------------------------------------------------------- */

.avatar {
    width: 84px;
    height: 84px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--red-soft);
    border: 2px solid var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red);
    font-size: 30px;
    font-weight: 800;
}

.profile-head { text-align: center; padding: 22px 16px 6px; }
.profile-head__name { font-size: 20px; font-weight: 700; }

/* Flash / alerts --------------------------------------------------------- */

.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 14px;
}

.alert--error { background: var(--red-soft); color: #8f0c1e; }
.alert--info { background: #e8f1fd; color: #1b4b87; }
.alert--success { background: #e7f6ec; color: #14682f; }

/* Empty state ------------------------------------------------------------ */

.empty { text-align: center; padding: 46px 24px; color: var(--muted); }
.empty__icon { color: var(--line); margin-bottom: 12px; }
.empty__title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }

/* Pull to refresh -------------------------------------------------------- */

.ptr {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 0;
    overflow: hidden;
    color: var(--muted);
    transition: height .18s ease;
}

.ptr--active { height: 44px; }
.ptr__spinner { animation: spin .9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Balance refresh pulse, so a background change is noticeable. */
.pulse { animation: pulse .6s ease; }

@keyframes pulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .pulse, .ptr__spinner { animation: none; }
}

/* Misc ------------------------------------------------------------------- */

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: 10px; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; }
.kv__k { color: var(--muted); }
.kv__v { font-weight: 600; }
