/* =====================================================================
   TRIERS' CLUB: SHARED DESIGN TOKENS + COMPONENTS
   Used by app.html (member app), partner.html, employer.html and index.html.
   Change a value here and it changes on every page.
   Look: a members' club. Cream paper, forest ink, one racket-green accent,
   a serif for the big moments and a quiet sans for everything else.
   ===================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap");

/* =====================================================================
   1. DESIGN TOKENS
   Paper (light) is the default. Dark mode further down only redefines colours.
   ===================================================================== */
:root {
  color-scheme: light;

  /* ---- Colour (paper, the default) ---- */
  --stage:          #E7E1D3;  /* page behind the phone (desktop only) */
  --frame:          #17211B;  /* phone bezel */
  --bg:             #F5F1E8;  /* app and portal background: cream paper */
  --surface:        #FBF9F4;  /* cards */
  --surface-2:      #FBF9F4;  /* sheets, raised cards */
  --fill:           #ECE6D9;  /* icon circles, chips, tags, inputs, segmented track */
  --line:           rgba(23, 33, 27, 0.10);  /* hairlines around cards and between rows */
  --ink:            #17211B;  /* main text and icons: forest black */
  --ink-muted:      #5E665D;  /* secondary text */
  --ink-faint:      #A19F92;  /* inactive tabs, placeholders */
  --accent:         #1F5A3D;  /* THE racket green: growth, rewards, primary buttons only */
  --accent-ink:     #F5F1E8;  /* text/icons sitting on --accent */
  --accent-soft:    #E2E9DC;  /* green wash behind growth and rewards */
  --flag:           #9A5A14;  /* flagged-spend text (gentle amber, not red) */
  --flag-soft:      #F3E6D1;
  --card-face:      #1F3D2E;  /* the payment card: club green */
  --card-ink:       #F3ECDC;  /* text on the payment card */
  --court-line:     rgba(243, 236, 220, 0.16);  /* the court markings on the card */
  --chart-bar:      var(--accent);
  --logo-color:     var(--accent);  /* the racket logo */
  --chart-grid:     #DAD3C3;
  --map-land:       #F1ECE0;  /* Nearby map on Deals */
  --map-water:      #D6E0DA;
  --map-park:       #DFE6D3;
  --map-road:       #FBF9F4;
  --map-label:      #7D8478;
  --map-you-halo:   rgba(23, 33, 27, 0.10);
  --scrim:          rgba(23, 33, 27, 0.32);  /* behind bottom sheets */
  --grain:          0.05;     /* paper grain over every page; 0 = off */

  /* ---- Glow (off for the club look; raise these to bring it back) ---- */
  --glow:           transparent;  /* strong glow colour (badges, reward mark) */
  --glow-soft:      transparent;  /* halo behind the balance */
  --glow-button:    none;     /* buttons are flat */
  --glow-text:      none;
  --halo-size:      320px;    /* size of the halo behind the balance */
  --aurora-1:       rgba(31, 90, 61, 0.10);  /* reward-moment background wash */
  --aurora-2:       rgba(176, 146, 92, 0.10);
  --confetti-2:     #8DAF94;  /* confetti colours besides --accent */
  --confetti-3:     #D9CBA8;

  /* ---- Typography ---- */
  --font:           "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display:   "Instrument Serif", "Iowan Old Style", Georgia, serif;  /* titles and the balance */
  --font-num:       var(--font);  /* amounts in lists and tables (tabular figures) */
  --fs-hero:        68px;     /* the balance */
  --fs-cents:       34px;     /* the cents after the balance */
  --fs-stat:        40px;     /* big numbers on portal dashboards */
  --fs-xl:          36px;     /* page titles */
  --fs-lg:          20px;     /* pushed-screen titles, portal card titles */
  --fs-md:          15px;     /* body, row titles, buttons */
  --fs-sm:          14px;     /* secondary text */
  --fs-xs:          12px;     /* tags, meta */
  --fs-tab:         11px;     /* tab bar labels */
  --fs-section:     24px;     /* serif section headings */
  --fw-regular:     400;
  --fw-medium:      500;
  --fw-bold:        600;
  --tracking-tight: -0.02em;  /* big serif numbers */
  --tracking-title: -0.01em;  /* titles */
  --tracking-label: 0.08em;   /* small caps-style labels */

  /* ---- Spacing (4px scale) ---- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;
  --gutter:   20px;           /* left/right padding inside the app */

  /* ---- Radius (tighter inside, softer outside) ---- */
  --radius-card:    18px;
  --radius-sheet:   24px;     /* top corners of bottom sheets */
  --radius-button:  14px;     /* set to 999px for pill buttons */
  --radius-pill:    999px;    /* tags, chips, segmented controls */
  --radius-input:   10px;     /* portal form fields */
  --radius-bank:    16px;     /* the payment card */
  --radius-phone:   54px;

  /* ---- Sizes ---- */
  --phone-width:    390px;
  --phone-height:   844px;
  --bezel:          10px;
  --portal-width:   1080px;   /* max content width on partner/employer portals */
  --button-height:  52px;
  --input-height:   48px;
  --row-icon:       40px;
  --stamp-size:     96px;     /* Tried stamps */
  --icon-size:      22px;
  --logo-size:      28px;     /* racket logo next to the name */
  --logo-size-lg:   72px;     /* racket logo on the hub page */
  --icon-stroke:    1.5;      /* one stroke weight for every icon */

  /* ---- Shadow (tinted forest, one light source from above) ---- */
  --shadow-card:    0 0 0 1px var(--line), 0 1px 2px rgba(23, 33, 27, 0.03);
  --shadow-bar:     0 -1px 0 var(--line);
  --shadow-sheet:   0 -12px 40px rgba(23, 33, 27, 0.12);
  --shadow-phone:   0 40px 90px rgba(31, 45, 36, 0.28), 0 8px 24px rgba(31, 45, 36, 0.12);

  /* ---- Motion ---- */
  --tick-duration:   900ms;   /* balance digits rolling */
  --reward-duration: 650ms;
  --spring-stiffness: 320;    /* springs: higher = snappier */
  --spring-damping:   26;     /* springs: lower = bouncier */
  --confetti-count:   36;     /* particles when cashback lands; 0 = off */
  --ease:            cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring:     cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Colour (dark): deep forest, only when the viewer picks dark ---- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --stage: #0A110D; --frame: #26332B; --bg: #0F1813; --surface: #15211A; --surface-2: #1A271F; --fill: #213028;
  --line: rgba(238, 232, 218, 0.08);
  --ink: #EEE8DA; --ink-muted: #A3A898; --ink-faint: #5E685C;
  --accent: #9BC7A4; --accent-ink: #0F1813; --accent-soft: rgba(155, 199, 164, 0.12);
  --flag: #D9A55F; --flag-soft: rgba(217, 165, 95, 0.12); --card-face: #1F3D2E; --card-ink: #F3ECDC;
  --map-land: #18241D; --map-water: #0E1A16; --map-park: #1C2B21; --map-road: #223028; --map-label: #6F7A6C; --map-you-halo: rgba(238, 232, 218, 0.10);
  --chart-grid: #26332B; --scrim: rgba(0, 0, 0, 0.55); --grain: 0.06;
  --glow-button: none;
  --aurora-1: rgba(155, 199, 164, 0.10); --aurora-2: rgba(217, 190, 140, 0.06);
  --confetti-2: #5E8C6A; --confetti-3: #D9CBA8;
  --shadow-card: 0 0 0 1px var(--line);
  --shadow-sheet: 0 -12px 40px rgba(0, 0, 0, 0.4);
  --shadow-phone: 0 40px 120px rgba(0, 0, 0, 0.6);
}

/* =====================================================================
   2. BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  font-synthesis-weight: none;  /* Instrument Serif has one weight; never fake-bold it */
}
/* Paper grain over everything. Strength is --grain. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 1000; pointer-events: none;
  opacity: var(--grain); mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::after { mix-blend-mode: screen; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.icon {
  width: var(--icon-size); height: var(--icon-size); flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--icon-stroke);
  stroke-linecap: round; stroke-linejoin: round;
}

/* =====================================================================
   3. SHARED COMPONENTS
   ===================================================================== */

/* Text */
.wordmark { font-family: var(--font-display); font-size: 22px; font-weight: var(--fw-regular); letter-spacing: var(--tracking-title); text-decoration: none; }
.page-title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: var(--fw-regular); letter-spacing: var(--tracking-title); line-height: 1.05; text-wrap: balance; }
.card-title { font-family: var(--font-display); font-size: 26px; font-weight: var(--fw-regular); letter-spacing: var(--tracking-title); line-height: 1.15; }
.section-title { font-family: var(--font-display); font-size: var(--fs-section); font-weight: var(--fw-regular); letter-spacing: var(--tracking-title); line-height: 1.2; }
.eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--ink-muted); }
.field-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-muted); }
.subtle { font-size: var(--fs-xs); color: var(--ink-muted); line-height: 1.5; }
.body-muted { font-size: var(--fs-sm); color: var(--ink-muted); line-height: 1.5; }
.link { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-muted); text-decoration: none; }

/* Buttons */
.btn-primary, .btn-dark, .btn-quiet {
  height: var(--button-height); padding: 0 var(--space-6);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border-radius: var(--radius-button);
  font-size: var(--fs-md); font-weight: var(--fw-bold);
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow-button); }
.btn-primary:disabled { opacity: 0.4; box-shadow: none; }
.btn-primary, .btn-dark, .btn-quiet, .chip, .list-row, .icon-btn { transition: transform 160ms var(--ease), filter 160ms var(--ease), background-color 160ms var(--ease); }
.btn-primary:hover, .btn-dark:hover { filter: brightness(1.08); }
.btn-primary:active, .btn-dark:active, .btn-quiet:active, .chip:active, .icon-btn:active { transform: scale(0.98); }
.btn-dark    { background: var(--ink); color: var(--bg); }
.btn-quiet   { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-quiet:hover { background: var(--surface); }
.btn-block { width: 100%; }
.actions { display: flex; justify-content: center; gap: var(--space-3); flex-wrap: wrap; }

/* Sections and cards */
.section { display: flex; flex-direction: column; gap: var(--space-3); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-2) var(--space-4);
}

/* List row: icon · title + meta · amount */
.list-row {
  display: grid; grid-template-columns: var(--row-icon) 1fr auto;
  align-items: center; gap: var(--space-3);
  padding-block: var(--space-3);
  width: 100%; text-align: left;
}
.row-icon {
  width: var(--row-icon); height: var(--row-icon); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fill);
}
.row-icon .icon { width: 20px; height: 20px; }
.row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-title { font-size: var(--fs-md); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-xs); color: var(--ink-muted); min-width: 0; }
.row-note { font-size: var(--fs-xs); color: var(--flag); }
.row-amount { font-family: var(--font-num); font-size: var(--fs-md); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.row-amount.is-plus { color: var(--accent); }
.row-chevron { color: var(--ink-faint); }

/* Tags: move / eat well / recover / everyday / flagged */
.tag {
  display: inline-flex; align-items: center; flex: none;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--fill); color: var(--ink-muted);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.tag-flagged { background: var(--flag-soft); color: var(--flag); }
.tag-live    { background: var(--accent-soft); color: var(--accent); }

/* Reward pill on deal cards */
.reward-pill {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); white-space: nowrap;
}

/* Segmented control and chips */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: var(--space-1); border-radius: var(--radius-pill);
  background: var(--fill);
}
.segmented button {
  height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.chips.left { justify-content: flex-start; }
.chip {
  height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--fill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* Form fields (portals) */
.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.input {
  height: var(--input-height); width: 100%;
  padding: 0 var(--space-4);
  border: 0; border-radius: var(--radius-input);
  background: var(--bg); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font: inherit; font-size: var(--fs-md);
}
textarea.input { height: auto; min-height: 120px; padding: var(--space-3) var(--space-4); line-height: 1.5; resize: vertical; }
.input:focus { outline: none; box-shadow: 0 0 0 1.5px var(--accent); }
.hint { font-size: var(--fs-xs); color: var(--ink-muted); }

/* Logo: crossed vintage rackets + name */
.brand { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; }
.logo { width: var(--logo-size); height: var(--logo-size); flex: none; color: var(--logo-color); }
.logo-lg { width: var(--logo-size-lg); height: var(--logo-size-lg); }
.card > .list-row + .list-row { box-shadow: inset 0 1px 0 var(--line); }
