/* ================================================================
   pwa.css — PWA UI chrome for V Notes
   Components: install banner, offline toast, update banner, iOS overlay
   Standalone file — no Tailwind dependency.
   Fonts (Manrope, Inter, Material Symbols Outlined) are already
   loaded on every page via Google Fonts.
   ================================================================ */

/* ── Design token bridge ── */
:root {
  --pwa-primary:               #0058be;
  --pwa-on-primary:            #ffffff;
  --pwa-primary-container:     #2170e4;
  --pwa-surface:               #f8f9ff;
  --pwa-on-surface:            #0b1c30;
  --pwa-on-surface-variant:    #424754;
  --pwa-surface-container-low: #eff4ff;
  --pwa-surface-container:     #e5eeff;
  --pwa-outline-variant:       #c2c6d6;
  --pwa-secondary:             #006c49;
  --pwa-error:                 #ba1a1a;

  --pwa-font-headline: 'Manrope', sans-serif;
  --pwa-font-body:     'Inter', sans-serif;

  /* Z-index layers — above bottom nav (9000) and title bar (9999) */
  --pwa-z-toast:   9200;
  --pwa-z-banner:  9100;
  --pwa-z-install: 9300;

  /* Bottom clearance: matches --mob-bottomnav-h + safe area */
  --pwa-bottom-offset: calc(62px + env(safe-area-inset-bottom, 0px));
}

/* ================================================================
   OFFLINE TOAST
   Dark pill, slides up from below bottom nav.
   ================================================================ */
.pwa-offline-toast {
  position: fixed;
  z-index: var(--pwa-z-toast);
  bottom: calc(var(--pwa-bottom-offset) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(160%);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);

  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9999px;
  background: var(--pwa-on-surface);
  color: #f8f9ff;

  font-family: var(--pwa-font-body);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(11, 28, 48, 0.25);
  pointer-events: none;
}

.pwa-offline-toast.pwa-visible {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.pwa-offline-toast .pwa-icon {
  font-size: 17px;
  font-family: 'Material Symbols Outlined';
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  flex-shrink: 0;
}

@media (min-width: 769px) {
  .pwa-offline-toast {
    left: 20px;
    bottom: 20px;
    transform: translateX(0) translateY(160%);
  }
  .pwa-offline-toast.pwa-visible {
    transform: translateX(0) translateY(0);
  }
}

/* ================================================================
   UPDATE AVAILABLE BANNER
   Full-width blue bar, slides down from top of viewport.
   ================================================================ */
.pwa-update-banner {
  position: fixed;
  z-index: var(--pwa-z-banner);
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  transition: transform 0.3s ease;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--pwa-primary);
  color: var(--pwa-on-primary);
  font-family: var(--pwa-font-body);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 12px rgba(0, 88, 190, 0.35);
}

.pwa-update-banner.pwa-visible {
  transform: translateY(0);
}

.pwa-update-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.pwa-update-banner .pwa-icon {
  font-size: 18px;
  font-family: 'Material Symbols Outlined';
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  flex-shrink: 0;
}

.pwa-update-banner-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pwa-update-banner-reload {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.40);
  color: var(--pwa-on-primary);
  font-family: var(--pwa-font-headline);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.pwa-update-banner-reload:hover {
  background: rgba(255, 255, 255, 0.30);
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.03);
}

.pwa-update-banner-dismiss {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Material Symbols Outlined';
  font-size: 18px;
  font-style: normal;
  font-weight: 400;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  transition: color 0.15s, transform 0.15s;
  border-radius: 50%;
}

.pwa-update-banner-dismiss:hover {
  color: var(--pwa-on-primary);
  transform: scale(1.15);
}

/* ================================================================
   INSTALL PROMPT
   Mobile: bottom sheet. Desktop (≥769px): floating card top-right.
   ================================================================ */
.pwa-install-sheet {
  position: fixed;
  z-index: var(--pwa-z-install);
  left: 0;
  right: 0;
  bottom: var(--pwa-bottom-offset);
  transform: translateY(120%);
  transition: transform 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);

  background: var(--pwa-surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -8px 40px rgba(11, 28, 48, 0.13);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: none;
}

.pwa-install-sheet.pwa-visible {
  transform: translateY(0);
  pointer-events: auto;
}

/* Drag handle */
.pwa-install-sheet::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: var(--pwa-outline-variant);
  border-radius: 9999px;
}

@media (min-width: 769px) {
  .pwa-install-sheet {
    bottom: auto;
    top: 72px;
    left: auto;
    right: 20px;
    width: 340px;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(11, 28, 48, 0.13);
    border: 1px solid var(--pwa-outline-variant);
    padding: 20px;
    transform: translateX(calc(100% + 28px));
    transition: transform 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
  }
  .pwa-install-sheet.pwa-visible {
    transform: translateX(0);
  }
  .pwa-install-sheet::before {
    display: none;
  }
}

.pwa-install-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-install-app-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--pwa-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.pwa-install-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwa-install-app-name {
  font-family: var(--pwa-font-headline);
  font-size: 16px;
  font-weight: 700;
  color: var(--pwa-on-surface);
  line-height: 1.2;
}

.pwa-install-app-desc {
  font-family: var(--pwa-font-body);
  font-size: 12px;
  color: var(--pwa-on-surface-variant);
  margin-top: 2px;
  line-height: 1.4;
}

.pwa-install-body {
  font-family: var(--pwa-font-body);
  font-size: 13px;
  color: var(--pwa-on-surface-variant);
  line-height: 1.6;
  margin: 0;
}

.pwa-install-actions {
  display: flex;
  gap: 10px;
}

.pwa-install-btn-primary {
  flex: 1;
  background: var(--pwa-primary);
  color: var(--pwa-on-primary);
  font-family: var(--pwa-font-headline);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 20px;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 88, 190, 0.22);
}

.pwa-install-btn-primary .pwa-icon {
  font-size: 18px;
  font-family: 'Material Symbols Outlined';
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.pwa-install-btn-primary:hover {
  background: var(--pwa-primary-container);
  box-shadow: 0 6px 20px rgba(0, 88, 190, 0.3);
}

.pwa-install-btn-primary:active {
  transform: scale(0.97);
}

.pwa-install-btn-secondary {
  background: var(--pwa-surface-container-low);
  color: var(--pwa-on-surface-variant);
  font-family: var(--pwa-font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 16px;
  border: 1px solid var(--pwa-outline-variant);
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.pwa-install-btn-secondary:hover {
  background: var(--pwa-surface-container);
  border-color: var(--pwa-on-surface-variant);
}

/* ================================================================
   iOS INSTALL INSTRUCTIONS OVERLAY
   Full-screen backdrop + bottom sheet with numbered steps.
   ================================================================ */
.pwa-ios-overlay {
  position: fixed;
  z-index: var(--pwa-z-install);
  inset: 0;
  background: rgba(11, 28, 48, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pwa-ios-overlay.pwa-visible {
  opacity: 1;
  pointer-events: auto;
}

.pwa-ios-card {
  background: var(--pwa-surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 28px 20px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 -8px 48px rgba(11, 28, 48, 0.18);
}

/* Drag handle for iOS card */
.pwa-ios-card::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--pwa-outline-variant);
  border-radius: 9999px;
  margin: 0 auto 20px;
}

.pwa-ios-title {
  font-family: var(--pwa-font-headline);
  font-size: 18px;
  font-weight: 700;
  color: var(--pwa-on-surface);
  margin-bottom: 16px;
  text-align: center;
}

.pwa-ios-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--pwa-surface-container-low);
  border-radius: 14px;
  margin-bottom: 10px;
  transition: background-color 0.15s, transform 0.15s;
}

.pwa-ios-step:hover {
  background: var(--pwa-surface-container);
  transform: translateX(2px);
}

.pwa-ios-step-num {
  width: 26px;
  height: 26px;
  min-width: 26px;
  background: var(--pwa-primary);
  color: var(--pwa-on-primary);
  border-radius: 9999px;
  font-family: var(--pwa-font-headline);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-ios-step-text {
  font-family: var(--pwa-font-body);
  font-size: 13px;
  color: var(--pwa-on-surface);
  line-height: 1.55;
}

.pwa-ios-step-text strong {
  font-weight: 600;
  color: var(--pwa-on-surface);
}

.pwa-ios-close {
  display: block;
  width: 100%;
  margin-top: 18px;
  background: var(--pwa-primary);
  color: var(--pwa-on-primary);
  font-family: var(--pwa-font-headline);
  font-size: 15px;
  font-weight: 700;
  padding: 14px;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 88, 190, 0.22);
  transition: background 0.15s;
}

.pwa-ios-close:hover {
  background: var(--pwa-primary-container);
  box-shadow: 0 6px 20px rgba(0, 88, 190, 0.3);
}

.pwa-ios-hint {
  text-align: center;
  margin-top: 12px;
  font-family: var(--pwa-font-body);
  font-size: 12px;
  color: var(--pwa-on-surface-variant);
}
