/* ============== Fonts ============== */
/* Display: New Spirit (Light + Regular + Medium). Body: Hanken Grotesk
   (Light/Regular/Medium/SemiBold). Sketch: Shantell Sans (Light/Regular)
   for the loyalty tracker. Mirrors AppFonts.swift. */

@font-face {
  font-family: 'New Spirit';
  src: url('./fonts/NewSpiritTRIAL-Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'New Spirit';
  src: url('./fonts/NewSpiritTRIAL-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'New Spirit';
  src: url('./fonts/NewSpiritTRIAL-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hanken Grotesk';
  src: url('./fonts/HankenGrotesk-Light.ttf') format('truetype');
  font-weight: 300;
}
@font-face {
  font-family: 'Hanken Grotesk';
  src: url('./fonts/HankenGrotesk-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Hanken Grotesk';
  src: url('./fonts/HankenGrotesk-Medium.ttf') format('truetype');
  font-weight: 500;
}
@font-face {
  font-family: 'Hanken Grotesk';
  src: url('./fonts/HankenGrotesk-SemiBold.ttf') format('truetype');
  font-weight: 600;
}

@font-face {
  font-family: 'Shantell Sans';
  src: url('./fonts/ShantellSans-Light.ttf') format('truetype');
  font-weight: 300;
}
@font-face {
  font-family: 'Shantell Sans';
  src: url('./fonts/ShantellSans-Regular.ttf') format('truetype');
  font-weight: 400;
}

/* ============== Tokens ============== */

:root {
  /* Brand colors — pulled from AppFonts.swift */
  --fresso-green: #266B21;        /* RGB(0.15, 0.32, 0.13) */
  --fresso-gradient-start: #267B2E; /* RGB(0.15, 0.32, 0.18) */
  --fresso-gradient-end: #143419;   /* RGB(0.08, 0.20, 0.10) */
  --fresso-green-tint: rgba(38, 123, 46, 0.06);
  --fresso-green-border: rgba(38, 123, 46, 0.15);
  --banner-bg: #E8F3E2;

  --bg: #fafaf8;
  --card-bg: #ffffff;
  --border: #ececec;
  --text: #1a1a1a;
  --text-muted: #6c6c6c;
  --error: #c53030;

  --radius: 12px;
}

/* ============== Reset / base ============== */

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

/* Force hidden elements to stay hidden. Several class rules below set
   display:flex (.login-form, .login-view, .boot-loading), and they out-
   specify the UA's [hidden] { display:none } — so without this, JS-set
   hidden="" wouldn't actually hide anything and all three login sub-views
   would render at once. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Hanken Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; }

a { color: var(--fresso-green); text-decoration: underline; }
a:hover { text-decoration: none; }

hr.rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* ============== Typography helpers ============== */
/* Mapped 1:1 from AppFonts.swift — same font + weight + size combos so the
   web matches what the iOS membership tab uses. Tracking -0.3 mirrors the
   .displayTracking() modifier on display fonts. */

.display-large   { font-family: 'New Spirit'; font-weight: 300; font-size: 34px; letter-spacing: -0.3px; line-height: 1.15; margin: 0; }
.display-medium  { font-family: 'New Spirit'; font-weight: 300; font-size: 28px; letter-spacing: -0.3px; line-height: 1.2;  margin: 0; }
.display-small   { font-family: 'New Spirit'; font-weight: 300; font-size: 22px; letter-spacing: -0.3px; line-height: 1.25; margin: 0; }

.body-13         { font-family: 'Hanken Grotesk'; font-weight: 400; font-size: 13px; margin: 0; }
.body-12         { font-family: 'Hanken Grotesk'; font-weight: 300; font-size: 12px; margin: 0; }
.body-15-medium  { font-family: 'Hanken Grotesk'; font-weight: 500; font-size: 15px; margin: 0; }
.body-16-semibold{ font-family: 'Hanken Grotesk'; font-weight: 600; font-size: 16px; margin: 0; }

.sketch-17       { font-family: 'Shantell Sans'; font-weight: 300; font-size: 17px; }
.sketch-18       { font-family: 'Shantell Sans'; font-weight: 400; font-size: 18px; }
.sketch-19       { font-family: 'Shantell Sans'; font-weight: 400; font-size: 19px; margin: 0; }
.sketch-22       { font-family: 'Shantell Sans'; font-weight: 400; font-size: 22px; }

.muted { color: var(--text-muted); }
.center { text-align: center; }
.fresso-green { color: var(--fresso-green); }

/* ============== Banner ============== */

.banner {
  background: var(--banner-bg);
  color: var(--fresso-green);
  padding: 14px 20px;
  text-align: center;
}
.banner p {
  margin: 0;
  font-family: 'Hanken Grotesk';
  font-weight: 500;
  font-size: 15px;
}
.banner a {
  color: var(--fresso-green);
  text-decoration: underline;
  font-weight: 600;
}
.banner a:hover { text-decoration: none; }

/* ============== Boot loader ============== */

.boot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--fresso-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============== Login view ============== */

.login-view {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px 80px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.login-card .display-large { margin-bottom: 8px; }
.login-subtitle {
  font-family: 'Hanken Grotesk';
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 28px;
}
.reset-heading { margin-bottom: 8px; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-family: 'Hanken Grotesk';
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.field-hint {
  font-family: 'Hanken Grotesk';
  font-weight: 300;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -2px;
}
input[type="tel"],
input[type="text"],
input[type="password"] {
  font-family: 'Hanken Grotesk';
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
input:focus {
  border-color: var(--fresso-green);
}

.form-error {
  font-family: 'Hanken Grotesk';
  font-size: 13px;
  color: var(--error);
  margin: 0;
}

.primary-button {
  background: linear-gradient(to right, var(--fresso-gradient-start), var(--fresso-gradient-end));
  color: white;
  font-family: 'Hanken Grotesk';
  font-weight: 600;
  font-size: 16px;
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  width: 100%;
  transition: opacity 0.15s, transform 0.05s;
}
.primary-button:hover:not(:disabled) { opacity: 0.92; }
.primary-button:active:not(:disabled) { transform: scale(0.99); }
.primary-button:disabled {
  background: rgba(0, 0, 0, 0.18);
  cursor: not-allowed;
}

.text-button {
  background: none;
  border: none;
  color: var(--fresso-green);
  font-family: 'Hanken Grotesk';
  font-weight: 500;
  font-size: 14px;
  padding: 4px 0;
  text-align: center;
  text-decoration: underline;
}
.text-button:hover { text-decoration: none; }

.login-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-family: 'Hanken Grotesk';
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ============== Dashboard view ============== */

.dashboard-header {
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.dashboard-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
#logout-button { padding: 6px 4px; }

.dashboard-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ---- Membership card ---- */

.loyalty-header { margin-bottom: 4px; }
.loyalty-header p + p { margin-top: 6px; }
#loyalty-identity { color: var(--text); }

.cup-section {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 0 16px;
}
.cup-wrapper {
  flex: 0 0 auto;
  width: 160px;
}
.cup-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
}
.cup-meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stars-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
}

#redeem-button { margin-top: 8px; }
#redeem-helper {
  margin: 8px 0 0;
  min-height: 16px;
}
#redeem-message { margin: 8px 0 0; }

.section-title { margin: 8px 0 14px; }

.rewards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reward-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--fresso-green-border);
  background: var(--fresso-green-tint);
  border-radius: var(--radius);
}
.reward-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.reward-card-title {
  font-family: 'Hanken Grotesk';
  font-weight: 500;
  font-size: 15px;
  margin: 0;
}
.reward-card-sub {
  font-family: 'Hanken Grotesk';
  font-weight: 300;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}
.reward-card-tag {
  font-family: 'Hanken Grotesk';
  font-weight: 600;
  font-size: 12px;
  color: var(--fresso-green);
  text-transform: none;
}
.reward-card-tag.urgent { color: var(--error); }

.empty-state {
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  font-family: 'Hanken Grotesk';
  font-weight: 300;
  font-size: 14px;
  color: var(--text-muted);
}

/* ---- Orders card ---- */

.orders-title { margin-bottom: 18px; }
.orders-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.order-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}
.order-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.order-date {
  font-family: 'Hanken Grotesk';
  font-weight: 500;
  font-size: 14px;
}
.order-total {
  font-family: 'Hanken Grotesk';
  font-weight: 600;
  font-size: 14px;
}
.order-items {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.order-item {
  font-family: 'Hanken Grotesk';
  font-size: 13px;
  color: var(--text);
}
.order-item-mods {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
.order-receipt {
  display: inline-block;
  margin-top: 10px;
  font-family: 'Hanken Grotesk';
  font-weight: 500;
  font-size: 13px;
  color: var(--fresso-green);
}

/* ---- Footer ---- */
.dashboard-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  text-align: center;
  font-family: 'Hanken Grotesk';
  font-weight: 300;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============== Mobile ============== */

@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    padding: 20px 16px;
    gap: 16px;
  }
  .card { padding: 20px; }
  .dashboard-header-inner { padding: 16px 16px; }
  .dashboard-header h1 { font-size: 22px; }

  .cup-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .cup-wrapper { width: 50%; min-width: 140px; max-width: 200px; align-self: center; }
  .cup-meta { width: 100%; align-items: center; text-align: center; }

  .login-card { padding: 28px 22px; }
  .display-large { font-size: 28px; }
  .display-medium { font-size: 24px; }

  .banner p { font-size: 14px; }
}
