/* Atilis PWA Member Card — clean ID-card layout, barcode-centric on phones. */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --brand: #cc1e1e;
  --brand-dark: #a01515;
  --brand-light: #e53535;
  --ink: #0a0a0a;
  --charcoal: #222;
  --border: #e0e0e0;
  --muted: #666;
  --bg: #f7f7f7;
}

html, body {
  height: 100%;
  font-family: 'Barlow', system-ui, sans-serif;
  background: var(--ink);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  width: 100%;
  max-width: 420px;
  margin: 16px;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  border: 3px solid var(--brand);
  display: flex;
  flex-direction: column;
}

.card-head {
  background: var(--ink);
  color: #fff;
  /* Pad below the iPhone Dynamic Island / notch when running standalone.
     env(safe-area-inset-top) is ~50px on iPhones with the island, 0 otherwise. */
  padding: max(22px, calc(env(safe-area-inset-top, 0px) + 14px)) 22px 16px;
  text-align: center;
  border-bottom: 3px solid var(--brand);
}

.card-head .logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--brand);
  line-height: 1;
}

.card-head .sub {
  margin-top: 5px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #888;
}

.member-section {
  padding: 28px 22px 0;
  text-align: center;
}

.name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 32px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.05;
  color: var(--ink);
  word-break: break-word;
  margin-bottom: 8px;
}

.card-id {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--muted);
}

/* The barcode section uses `auto` top/bottom margins so it floats to the
   vertical center of the card on phones where the card fills the screen.
   On desktop, it naturally sits between member-section and meta. */
.barcode-section {
  margin: 22px;
  padding: 22px 14px 18px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  text-align: center;
}

#barcode {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.barcode-label {
  margin-top: 10px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.meta {
  padding: 0 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.meta-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.meta-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

/* Install banners — pinned to bottom, with safe-area padding for the iPhone
   home-bar gesture area. */
.install-banner {
  margin: 0 22px;
  margin-bottom: max(22px, env(safe-area-inset-bottom, 0px));
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  border-radius: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 14px rgba(204, 30, 30, 0.25);
}

.install-banner-text { flex: 1; min-width: 0; }
.install-banner-text strong {
  display: block;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.install-banner-text span {
  display: block;
  font-size: 12px;
  opacity: 0.95;
  line-height: 1.4;
}

.install-btn {
  flex-shrink: 0;
  background: #fff;
  color: var(--brand);
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.1s;
}
.install-btn:active { transform: scale(0.96); }

/* iOS "Save this card" button on the card itself — re-opens the overlay. */
.install-ios-cta {
  background: var(--ink);
  color: #fff;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  width: calc(100% - 44px);
  transition: transform 0.1s;
}
.install-ios-cta:active { transform: scale(0.98); }
.install-ios-cta .install-banner-text strong { color: var(--brand); }
.install-ios-arrow {
  font-size: 28px;
  font-weight: 900;
  color: var(--brand);
  line-height: 1;
  flex-shrink: 0;
}

/* ── iOS Install Overlay ──────────────────────────────────────────────
   Full-screen modal with three numbered steps. Designed for older users:
   big numbers, big readable fonts, visual mock-ups of each iOS screen
   they'll see. The pulsing highlight on each step shows exactly what to
   tap. */
.ios-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 12px;
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: ios-overlay-fade 0.25s ease-out;
}

@keyframes ios-overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ios-overlay-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 18px;
  padding: 28px 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  margin: auto;
  animation: ios-overlay-slide 0.3s ease-out;
}

@keyframes ios-overlay-slide {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.ios-overlay-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 32px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.ios-overlay-close:active { color: var(--ink); }

.ios-overlay-header {
  text-align: center;
  margin-bottom: 22px;
  padding: 0 20px;
}

.ios-overlay-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 30px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  line-height: 1.05;
}

.ios-overlay-sub {
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--muted);
}

.ios-steps-list {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
}

.ios-step {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1.5px solid var(--border);
}
.ios-step:last-child { border-bottom: none; }

.ios-step-num {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ios-step-body { flex: 1; min-width: 0; }

.ios-step-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink);
  line-height: 1.15;
}

.ios-step-desc {
  margin-top: 4px;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.4;
}

.ios-step-visual {
  margin-top: 12px;
}

.ios-step-caption {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  text-align: center;
}

/* Mock iOS toolbar — looks like the bottom of Safari. */
.ios-mock-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: #f5f5f7;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 20px;
  color: #555;
}

.ios-mock-toolbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #555;
}

/* Mock iOS share sheet — three rows, target row pulses. */
.ios-mock-sheet {
  background: #f5f5f7;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.ios-mock-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e8e8ec;
  font-size: 15px;
  color: var(--ink);
}
.ios-mock-row:last-child { border-bottom: none; }

.ios-mock-row-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 18px;
}

.ios-mock-row-label {
  font-weight: 600;
}

/* Mock iOS dialog top-bar with Cancel / title / Add. */
.ios-mock-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f5f7;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--ink);
}

.ios-mock-titlebar-side {
  font-weight: 600;
  color: #007aff;
}

.ios-mock-titlebar-title {
  font-weight: 700;
  font-size: 14px;
}

/* Highlight + pulse animation — draws the eye to the right tap target. */
.highlight {
  background: rgba(204, 30, 30, 0.12);
  color: var(--brand) !important;
  border-radius: 8px;
  font-weight: 800 !important;
}
.ios-mock-row.highlight { background: rgba(204, 30, 30, 0.12); }
.ios-mock-titlebar-side.highlight {
  padding: 4px 10px;
  background: rgba(204, 30, 30, 0.12);
}

.pulse {
  animation: ios-pulse 1.4s ease-in-out infinite;
}

@keyframes ios-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(204, 30, 30, 0.45);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(204, 30, 30, 0);
    transform: scale(1.05);
  }
}

.ios-overlay-done {
  display: block;
  width: 100%;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin-bottom: 8px;
  transition: transform 0.1s, background 0.15s;
}
.ios-overlay-done:active { transform: scale(0.98); background: var(--brand-dark); }

.ios-overlay-later {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ios-overlay-later:active { color: var(--ink); }

.install-hint {
  margin: 0 22px;
  margin-bottom: max(22px, env(safe-area-inset-bottom, 0px));
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

.error {
  padding: 40px 24px;
  text-align: center;
  color: #fff;
}

.error.hidden { display: none; }
.error-icon { font-size: 48px; margin-bottom: 12px; }
.error-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.error-sub { color: #999; font-size: 14px; }

.hidden { display: none !important; }

/* On phone screens, the card fills the viewport and the barcode floats to
   the visual middle of the screen using auto margins. */
@media (max-width: 480px) {
  .card {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-height: 100vh;
    min-height: 100dvh; /* dvh tracks browser-UI changes on iOS */
  }
  .barcode-section {
    margin-top: auto;
    margin-bottom: auto;
  }
}
