/* Saga Member V4 — Editorial Coffee Utility */
:root {
  --v4-ink: #211a17;
  --v4-espresso: #38251f;
  --v4-roast: #6f3f2c;
  --v4-clay: #b96742;
  --v4-lime: #c8e58b;
  --v4-sage: #aebb97;
  --v4-paper: #f5f0e8;
  --v4-milk: #fffdf8;
  --v4-concrete: #d8d3cb;
  --v4-line: rgb(33 26 23 / 11%);
  --v4-shadow-1: 0 1px 0 rgb(33 26 23 / 5%), 0 8px 22px rgb(33 26 23 / 6%);
  --v4-shadow-2: 0 18px 42px rgb(33 26 23 / 18%);
}

html { background: #d6d1ca; }

body {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  color: var(--v4-ink);
  background: var(--v4-paper);
}

.topbar {
  min-height: calc(58px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: rgb(245 240 232 / 97%);
}

.brand { font-size: 0.79rem; }
.brand b { color: var(--v4-roast); }
.brand span { color: #6e6660; font-size: 0.55rem; }
#runtime-scope { display: none; }
.topbar .icon-button { background: transparent; border-color: var(--v4-line); }

.scale-context {
  max-width: calc(100% - 32px);
  min-height: 30px;
  margin: 5px 16px 0;
  padding: 6px 10px;
  border: 0;
  background: #e9e2d8;
  color: #655c55;
  font-size: 0.62rem;
  font-weight: 650;
}

main {
  min-height: calc(100dvh - 120px);
  padding: 15px 16px 40px;
}

.member-view {
  display: grid;
  gap: 24px;
  animation: none;
}

.member-view > * {
  animation: v4-reveal 180ms ease-out both;
}

.member-view > :nth-child(2) { animation-delay: 20ms; }
.member-view > :nth-child(3) { animation-delay: 40ms; }
.member-view > :nth-child(n + 4) { animation-delay: 60ms; }

@keyframes v4-reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.member-view h1,
.member-view h2,
.member-view h3 { color: var(--v4-ink); text-wrap: balance; }
.member-view p,
.member-view small { text-wrap: pretty; }
.member-view h1 { font-size: clamp(1.85rem, 8.7vw, 2.3rem); font-weight: 780; line-height: 1.04; }
.member-view h2 { font-size: 1.14rem; font-weight: 690; line-height: 1.25; }
.member-view h3 { font-weight: 690; line-height: 1.3; }
.member-view p { color: #655e58; font-size: 0.86rem; line-height: 1.58; }
.eyebrow { margin: 0 0 5px; color: #4f281a; font-size: 0.65rem; font-weight: 740; opacity: 1; }
.tabular,
.v4-wallet-balance strong,
.v4-wallet-footer strong,
.v4-profile-stats strong,
.v4-points-orb strong { font-variant-numeric: tabular-nums; }

.v4-home-greeting {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.v4-home-greeting h1 { margin: 0; font-size: 1.75rem; }
.v4-home-greeting .pill { max-width: 134px; }

.v4-member-wallet {
  position: relative;
  display: grid;
  min-height: 232px;
  padding: 20px;
  overflow: hidden;
  border-radius: 28px;
  color: #1d2b1d;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 54%), transparent 46%),
    linear-gradient(130deg, #e7f0d2, var(--v4-lime));
  box-shadow: var(--v4-shadow-1);
  isolation: isolate;
}

.v4-member-wallet::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(circle, rgb(29 43 29 / 16%) 0 1px, transparent 1.2px);
  background-size: 13px 13px;
  content: "";
  opacity: 0.12;
}

.v4-wallet-top,
.v4-wallet-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.v4-wallet-top > span:first-child { font-size: 0.65rem; font-weight: 760; }
.v4-wallet-top .tier-chip { background: rgb(255 253 248 / 70%); }
.v4-wallet-balance { display: grid; align-content: center; margin-top: 20px; }
.v4-wallet-balance strong { font-size: 3.75rem; font-weight: 780; line-height: 0.95; }
.v4-wallet-balance span,
.v4-wallet-footer span { font-size: 0.68rem; font-weight: 600; opacity: 0.72; }
.v4-wallet-footer { align-self: end; }
.v4-wallet-footer > div { display: grid; }
.v4-wallet-footer strong { font-size: 1.12rem; }
.v4-wallet-pass {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 6px;
  padding: 9px 12px;
  border: 1px solid rgb(29 43 29 / 14%);
  border-radius: 12px;
  background: rgb(255 253 248 / 72%);
  color: #1d2b1d;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
}
.v4-wallet-star,
.v4-scene-star {
  position: absolute;
  width: 32px;
  height: 32px;
  background: currentColor;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}
.v4-wallet-star { top: 72px; right: 28px; color: rgb(33 26 23 / 18%); transform: rotate(12deg); }

.editorial-section-heading { align-items: end; margin: 0; }
.editorial-section-heading h2 { margin: 0; font-size: 1.16rem; }
.editorial-section-heading .eyebrow { color: #66331f; }
.content-section { gap: 12px; }

.destination-grid { gap: 8px; }
.destination-card {
  min-height: 84px;
  gap: 5px;
  padding: 9px 3px;
  border: 0;
  border-radius: 16px;
  background: transparent;
}
.destination-card > .feather-icon:first-child {
  padding: 10px;
  border: 1px solid var(--v4-line);
  border-radius: 14px;
  background: var(--v4-milk);
  color: var(--v4-espresso);
  box-shadow: 0 2px 8px rgb(33 26 23 / 4%);
}
.destination-card span { display: grid; }
.destination-card strong { font-size: 0.69rem; font-weight: 690; }
.destination-card small { display: block; color: #5d554f; font-size: 0.58rem; font-weight: 600; }

.v4-progress-story {
  padding: 17px;
  border: 1px solid var(--v4-line);
  border-radius: 18px;
  background: var(--v4-milk);
}
.v4-progress-story p { margin: 10px 0 0; font-size: 0.68rem; }
.progress { height: 7px; border-radius: 999px; background: #e7e0d8; overflow: hidden; }
.progress span {
  height: 100%;
  border-radius: inherit;
  background: var(--v4-clay);
  transform-origin: left;
  animation: v4-progress-in 200ms ease-out both;
}
@keyframes v4-progress-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.v4-context-list { display: grid; border-top: 1px solid var(--v4-line); border-bottom: 1px solid var(--v4-line); }
.v4-context-list button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 20px;
  align-items: center;
  min-height: 68px;
  gap: 10px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--v4-line);
  background: transparent;
  color: var(--v4-ink);
  font: inherit;
  text-align: left;
}
.v4-context-list button:last-child { border-bottom: 0; }
.v4-context-list button > span:nth-child(2) { display: grid; min-width: 0; }
.v4-context-list small { color: #5d554f; font-size: 0.62rem; font-weight: 600; }
.v4-context-list strong { overflow: hidden; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.v4-context-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 13px; background: #e7dfd4; }
.v4-demo-note { margin: -8px 0 0; color: #5b534d !important; font-size: 0.63rem !important; font-weight: 600; text-align: center; }

.activity-preview { border-top: 1px solid var(--v4-line); }
.activity-preview li { min-height: 62px; padding: 10px 2px; border-color: var(--v4-line); background: transparent; }
.activity-preview small { color: #5d554f; }

.v4-page-head { padding: 11px 4px 2px; }
.v4-page-head h1 { max-width: 12ch; margin: 0 0 10px; }
.v4-page-head > p:last-child { max-width: 32ch; margin: 0; }
.v4-page-head-compact { padding-bottom: 0; }

.v4-sticky-tools {
  position: sticky;
  top: calc(58px + env(safe-area-inset-top));
  z-index: var(--z-header);
  margin: -8px -4px 0;
  padding: 8px 4px 10px;
  background: rgb(245 240 232 / 97%);
}
.search-field { border-radius: 16px; box-shadow: 0 2px 12px rgb(33 26 23 / 4%); }
.search-field input { font-size: 1rem; }
.filter-chip { border-radius: 12px; background: transparent; }
.filter-chip[aria-pressed="true"] { background: var(--v4-ink); }

.v4-discovery-list { gap: 13px; }
.tenant-card { border: 1px solid var(--v4-line); box-shadow: none; }
.v4-tenant-featured { grid-template-columns: 46% minmax(0, 1fr); min-height: 220px; border-radius: 24px; }
.v4-tenant-row { grid-template-columns: 108px minmax(0, 1fr); min-height: 146px; border-radius: 18px; }
.v4-scene { position: relative; min-height: 100%; overflow: hidden; isolation: isolate; }
.v4-scene::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: repeating-linear-gradient(0deg, transparent 0 12px, rgb(33 26 23 / 6%) 12px 13px);
  content: "";
  opacity: 0.24;
}
.v4-scene-coffee { color: #3b2118; background: linear-gradient(145deg, #f2c18d, #c96f43); }
.v4-scene-studio { color: #20301f; background: linear-gradient(145deg, #dce7cf, var(--v4-sage)); }
.v4-scene-quest { color: #342817; background: linear-gradient(145deg, #f4df8d, #e4bb53); }
.v4-scene-reward { color: #1f311e; background: linear-gradient(145deg, #e6f1cb, var(--v4-lime)); }
.v4-scene-index { position: absolute; top: 11px; left: 12px; font-size: 0.62rem; font-weight: 760; }
.v4-scene-kicker { position: absolute; right: 9px; bottom: 11px; font-size: 0.56rem; font-weight: 700; writing-mode: vertical-rl; }
.v4-scene-icon { position: absolute; top: 50%; left: 50%; display: grid; width: 68px; height: 68px; place-items: center; border: 1px solid rgb(255 255 255 / 46%); border-radius: 50%; background: rgb(255 253 248 / 62%); transform: translate(-50%, -50%); }
.v4-scene-star { right: 12px; top: 18px; width: 18px; height: 18px; opacity: 0.3; }
.v4-tenant-row .v4-scene-icon { width: 54px; height: 54px; }
.tenant-copy { padding: 16px; }
.tenant-copy h2 { font-size: 1rem; }
.tenant-copy p { margin-bottom: 8px; }
.card-meta > span:last-child { font-size: 0.6rem; }

.v4-community-card { min-height: 156px; border-radius: 18px; background: var(--v4-ink); }
.v4-community-card .wide-story-visual { background: var(--v4-lime); }
.v4-community-card .wide-story-visual span { border-radius: 50%; }
.v4-community-card h2 { color: var(--v4-milk); }

.v4-member-pass {
  min-height: 286px;
  padding: 22px;
  border-radius: 28px;
  background: linear-gradient(145deg, #1f1714, #4b2d25 62%, #815039);
  box-shadow: var(--v4-shadow-2);
}
.v4-member-pass::before { background-size: 16px 16px; opacity: 0.26; }
.v4-member-pass .pass-identity { margin-top: 52px; }
.v4-member-pass .pass-identity p,
.v4-member-pass .pass-balances span,
.v4-member-pass .pass-disclosure { color: #f4decc; opacity: 0.86; }
.v4-member-pass .pass-identity h2,
.v4-member-pass .pass-balances strong,
.v4-member-pass .masked-code { color: var(--v4-milk); }
.v4-member-pass .pass-identity h2 { font-size: 1.65rem; }
.v4-pass-rings { position: absolute; top: 54px; right: -40px; width: 148px; height: 148px; border: 1px solid rgb(255 255 255 / 13%); border-radius: 50%; }
.v4-pass-rings::before { position: absolute; inset: 22px; border: 1px solid rgb(255 255 255 / 12%); border-radius: inherit; content: ""; }
.v4-pass-meta { display: grid; gap: 10px; padding: 0 3px 5px; }
.v4-pass-meta > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 0.72rem; }
.v4-pass-meta > div:first-child span { color: #5d554f; font-weight: 600; }
.v4-pass-meta p { margin: 0; font-size: 0.68rem; }
.v4-instruction { grid-template-columns: 110px minmax(0, 1fr); min-height: 178px; border: 1px solid var(--v4-line); border-radius: 18px; }
.v4-scan-symbol { position: relative; display: grid; align-self: stretch; place-items: center; background: #d6c2b4; color: var(--v4-espresso); }
.v4-scan-symbol::before { position: absolute; width: 66px; height: 66px; border: 1px solid rgb(56 37 31 / 22%); border-radius: 50%; content: ""; }
.v4-scan-symbol span { position: absolute; top: 12px; left: 12px; font-size: 0.64rem; font-weight: 760; }
.v4-instruction > div:last-child { padding: 16px; }

.v4-reward-head { display: grid; grid-template-columns: minmax(0, 1fr) 88px; align-items: end; gap: 12px; padding: 10px 3px 2px; }
.v4-reward-head h1 { margin: 0; font-size: 2rem; }
.v4-points-orb { display: grid; width: 88px; height: 88px; place-items: center; align-content: center; border-radius: 50%; background: var(--v4-lime); color: #20311f; }
.v4-points-orb strong { font-size: 1.3rem; line-height: 1; }
.v4-points-orb span { font-size: 0.58rem; font-weight: 690; }
.v4-quest-strip { display: grid; grid-template-columns: 54px minmax(0, 1fr) 44px; align-items: center; min-height: 112px; gap: 10px; padding: 14px; border: 0; border-radius: 18px; background: #f0d777; }
.v4-quest-strip .v4-quest-stamp { display: grid; width: 54px; height: 54px; place-items: center; border: 1px dashed rgb(52 40 23 / 24%); border-radius: 50%; background: rgb(255 253 248 / 55%); }
.v4-quest-strip h2 { margin: 5px 0 2px; font-size: 0.94rem; }
.v4-quest-strip p { margin: 0; color: #564521; font-size: 0.66rem; }
.v4-quest-strip .icon-button { min-width: 44px; min-height: 44px; border-color: rgb(52 40 23 / 16%); background: rgb(255 253 248 / 46%); }

.reward-grid { grid-template-columns: 1fr; gap: 10px; }
.reward-card { display: grid; grid-template-columns: 78px minmax(0, 1fr); min-height: 150px; border: 1px solid var(--v4-line); border-radius: 18px; }
.reward-card.featured { grid-template-columns: 45% minmax(0, 1fr); min-height: 236px; border-radius: 24px; }
.reward-card.featured .v4-scene { min-height: 236px; }
.reward-monogram { min-height: 100%; aspect-ratio: auto; background: #e4ecd7; }
.reward-copy { padding: 13px; }
.reward-copy h3 { font-size: 0.94rem; }
.reward-copy p { margin: 0 0 8px; }
.reward-action strong { font-size: 0.7rem; }
.reward-action .button { min-width: 78px; }
.owned-reward-list { border-top: 1px solid var(--v4-line); }
.owned-reward { min-height: 68px; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--v4-line); border-radius: 0; background: transparent; }

.v4-profile-head { display: grid; grid-template-columns: 62px minmax(0, 1fr) 44px; align-items: center; gap: 13px; padding: 18px 3px 6px; }
.v4-profile-head .profile-avatar { width: 62px; height: 62px; margin: 0; border: 0; background: var(--v4-espresso); color: var(--v4-milk); font-size: 1.3rem; }
.v4-profile-head h1 { margin: 0; font-size: 1.7rem; }
.v4-profile-head p:last-child { margin: 3px 0 0; font-size: 0.68rem; }
.v4-profile-head .icon-button { min-width: 44px; min-height: 44px; border-color: var(--v4-line); background: var(--v4-milk); }
.v4-profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); padding: 15px 0; border-top: 1px solid var(--v4-line); border-bottom: 1px solid var(--v4-line); }
.v4-profile-stats div { display: grid; padding: 0 13px; border-right: 1px solid var(--v4-line); }
.v4-profile-stats div:last-child { border-right: 0; }
.v4-profile-stats strong { overflow: hidden; font-size: 1rem; text-overflow: ellipsis; }
.v4-profile-stats span { color: #5d554f; font-size: 0.6rem; font-weight: 600; }
.settings-list { overflow: hidden; border-top: 1px solid var(--v4-line); border-bottom: 1px solid var(--v4-line); border-radius: 0; }
.settings-row { min-height: 66px; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--v4-line); border-radius: 0; background: transparent; }
.settings-row:last-child { border-bottom: 0; }
.settings-row > .feather-icon:first-child { background: #e8e1d8; }
.v4-profile-panels { gap: 0; border-top: 1px solid var(--v4-line); }
.v4-profile-panels .editorial-card { padding: 15px 2px; border: 0; border-bottom: 1px solid var(--v4-line); border-radius: 0; background: transparent; }

.button { min-height: 44px; border-radius: 12px; background: var(--v4-ink); }
.button.secondary { background: var(--v4-milk); }
.button:active,
.destination-card:active,
.settings-row:active,
.v4-context-list button:active,
.v4-wallet-pass:active { transform: scale(0.985); }
.text-action { min-height: 44px; color: var(--v4-roast); font-weight: 680; }

.bottom-nav {
  right: max(12px, calc((100vw - 430px) / 2 + 12px));
  bottom: calc(9px + env(safe-area-inset-bottom));
  left: max(12px, calc((100vw - 430px) / 2 + 12px));
  max-width: 406px;
  padding: 5px;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 20px;
  background: rgb(33 26 23 / 97%);
  box-shadow: var(--v4-shadow-2);
}
.bottom-nav button {
  min-height: 52px;
  border-radius: 15px;
  color: #d7d0ca;
  font-size: 0.59rem;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}
.bottom-nav button[aria-current="page"] { background: var(--v4-lime); color: var(--v4-ink); }
.bottom-nav button[aria-current="page"] .feather-icon { transform: translateY(-1px); }
.bottom-nav .pass-destination[aria-current="page"],
.bottom-nav .pass-destination[aria-current="page"] .feather-icon { color: var(--v4-ink); }

@media (max-width: 350px) {
  main { padding-right: 12px; padding-left: 12px; }
  .v4-member-wallet { min-height: 218px; padding: 17px; }
  .v4-wallet-balance strong { font-size: 3.2rem; }
  .v4-tenant-featured { grid-template-columns: 42% minmax(0, 1fr); }
  .v4-reward-head { grid-template-columns: minmax(0, 1fr) 78px; }
  .v4-points-orb { width: 78px; height: 78px; }
  .reward-card.featured { grid-template-columns: 42% minmax(0, 1fr); }
}

@media (min-width: 700px) {
  body,
  .topbar,
  .scale-context,
  main { width: 430px; }
}

@media (prefers-reduced-motion: reduce) {
  .member-view > *,
  .progress span { animation: none; }
  .button,
  .destination-card,
  .settings-row,
  .v4-context-list button,
  .v4-wallet-pass,
  .bottom-nav button { transition: none; }
}

@media (forced-colors: active) {
  .v4-member-wallet,
  .v4-scene,
  .v4-member-pass,
  .v4-quest-strip,
  .v4-points-orb { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
}
