/* ==== CSS CUSTOM PROPERTIES ==== */
:root {
  --brand-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  --brand-font: "Gabarito", sans-serif;
  --body-font: "InterTight", sans-serif;
  --canvas-light: #f9f9f9;
  --canvas-dark: #000;
  --icon-dark: #000;
  --icon-light: #fff;
  --iOS-padding: max(14px, env(safe-area-inset-top, 14px));
  --android-padding: 14px;
}

@font-face {
  font-family: "Gabarito";
  src: url("Gabarito.ttf") format("truetype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "InterTight";
  src: url("InterTight.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal italic;
  font-display: swap;
}

/* ==== RESET ==== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: #fff;
}

/* ==== SWIPE WRAPPER ==== */
.swipe-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 300vw;
  height: 100dvh;
  display: flex;
  transform: translateX(-100vw);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  touch-action: pan-x pinch-zoom;
}

/* ==== EACH VIEW ==== */
.view {
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

/* ==== BACKGROUND COLORS ==== */
.camera-view { background: #000; }
.gallery-view,
.settings-view { background: #f9f9f9; }

/* Apply shadow to icons and capture logo */
.action-left i,
.action-right i {
  filter: drop-shadow(var(--brand-shadow));
}

/* ==== TOP MENU ==== */
.top-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  padding-top: var(--iOS-padding);
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  z-index: 10;
}

.gallery-view .top-menu { color: #000; }

.top-center {
  flex: 1;
  text-align: center;
}

/* ==== MAIN CONTENT ==== */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.main-content.fixed { overflow: hidden; }

.main-content.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  margin: 0;
}

.title {
  font-family: var(--brand-font);
  font-size: 31px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -1px;
  text-align: center;
  text-shadow: var(--brand-shadow);
}

/* ==== ACTION BUTTONS (BOTTOM BAR) ==== */
.action-buttons {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-inline: 40px;
  pointer-events: none;
  z-index: 20;
}

.action-left,
.action-right {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.action-left i,
.action-right i {
  font-size: 28px;
  color: #fff;
  pointer-events: none;
}

/* Ensure icons are white even in gallery view */
.gallery-view .action-left i,
.gallery-view .action-right i {
  color: #fff;
}

.action-center {
  width: 140px;
  height: 140px;
  margin: 0 18px;
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
}

/* ==== CAPTURE LOGO (HTML/CSS version) ==== */
.capture-button {
  display: inline-block;
  position: relative;
  width: 110px;
  height: 110px;
  padding: 0;
  margin: 0;
  background: transparent;
  overflow: visible;
  transition: transform 0.2s ease;
}

.outer-rim {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 107px;
  height: 107px;
  border: 4px solid white;
  border-radius: 50%;
  background: transparent;
  z-index: 1;
  box-shadow: var(--brand-shadow);
}

.inner-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92px;
  height: 92px;
  background: white;
  border-radius: 50%;
  z-index: 2;
}

/* Pressed state for capture button */
.capture-button.pressed {
  transform: scale(0.82);
  transition: transform 0.2s ease;
}

/* === Virtual Gallery Grid === */
#virtualGallery {
  position: relative;
  width: 100%;
  background: #f9f9f9;
  padding: 0;
  margin: 0;
}

#virtualGallery .tile {
  position: absolute;
  background: #f3f3f3;
  border-radius: 0;
  box-shadow: none;
  border: 0;
  overflow: hidden;
  image-rendering: -webkit-optimize-contrast;
}

/* ==== MAGIC CAMERA PREVIEW ==== */
#magicCamera {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#magicCamera video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fallback message */
.camera-error {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.8);
  text-align: center;
  font-size: 18px;
  padding: 20px;
}

/* ==== EMPTY STATE STYLES ==== */
#no-photos,
#no-friends {
  position: absolute;
  top: calc(50% - (env(safe-area-inset-bottom, 0px) + 40px));
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--brand-font);
  font-size: 27px;
  font-weight: 600;
  color: #bdbdbd;
  text-align: center;
  opacity: 0.8;
  display: none;
  pointer-events: none;
}

#no-photos span,
#no-friends span {
  display: block;
  max-width: 95%;
  margin: 0 auto;
  line-height: 1.2;
}

@keyframes slideInFriction {
  0% { transform: translate(-50%, calc(-50% - 40px)); opacity: 0; }
  10% { opacity: 1; }
  60% { transform: translate(-50%, calc(-50% + 5px)); }
  80% { transform: translate(-50%, calc(-50% - 2px)); }
  100% { transform: translate(-50%, -50%); }
}

@keyframes slideOutFriction {
  0% { transform: translate(-50%, -50%); opacity: 1; }
  20% { transform: translate(-50%, calc(-50% - 3px)); }
  100% { transform: translate(-50%, calc(-50% - 40px)); opacity: 0; }
}


/* ============================================================ */
/* INVITE LINK MODAL - COMPLETE STYLES */
/* ============================================================ */

.invite-link-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 16px;
  box-sizing: border-box;
}

.invite-link-modal.active {
  opacity: 1;
  visibility: visible;
}

.invite-link-modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  width: 340px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.invite-link-modal.active .invite-link-modal-content {
  transform: scale(1);
}

/* Title */
.invite-link-modal-title {
  margin: 0 0 16px;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1a1a1a;
  font-family: var(--brand-font);
}

/* Profile Section */
.invite-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-pic-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  cursor: pointer;
}

.profile-pic {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.edit-icon {
  position: absolute;
  bottom: 0;
  right: 20px;
  background: #007aff;
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.username-section {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 500;
}

.username {
  color: #1a1a1a;
  font-size: 18px;
}

.username-edit {
  color: #666;
  cursor: pointer;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.username-edit:hover {
  color: #0056b3;
}

/* Body Text */
.invite-link-modal-body {
  margin: 20px 0;
  font-size: 15px;
  color: #444;
  line-height: 1.4;
  font-family: var(--body-font);
}

/* Invite Link Display */
.invite-link-modal-link {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  margin-bottom: 20px;
  user-select: all;
}

/* Buttons */
.invite-link-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.invite-link-modal-buttons button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.copy-btn {
  background: #007bff;
  color: white;
  font-family: var(--brand-font);
}

.copy-btn:hover {
  background: #0064d6;
}

.copy-btn.copied {
  background: #0064d6;
}

.exit-btn {
  background: #e0e0e0;
  color: #333;
  font-family: var(--brand-font);
}

.exit-btn:hover {
  background: #e5e5ea;
}

/* Prevent body scroll when modal is open */
.body-modal-open {
  overflow: hidden;
  touch-action: none;
}

/* Responsive Adjustments */
@media (max-width: 380px) {
  .invite-link-modal-content {
    width: 100%;
    max-width: none;
    padding: 20px;
  }

  .invite-link-modal-buttons {
    flex-direction: column;
  }

  .invite-link-modal-buttons button {
    width: 100%;
  }
}


/* ==== BUTTON INTERACTIONS ==== */
#switch-camera.pressed,
#switch-camera:active {
  transform: scale(0.9);
  opacity: 0.7;
}

#switch-camera,
#capture-button,
.action-buttons * {
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* === FRIENDS LIST === */
#friends {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.friend-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.friend-item:active {
  transform: scale(0.98);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.friend-pic-wrapper {
  width: 80px;
  height: 100px;
  border-radius: 21%;
  overflow: hidden;
  flex-shrink: 0;
  background: #eee;
}

.friend-pic {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.friend-name {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
  font-family: var(--brand-font);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friends-view .main-content.scrollable {
  padding-top: calc(70px + var(--iOS-padding)); /* top-menu height + safe area inset */
}

.remove-friend-btn {
  margin-left: auto;
  background: #f9f9f9;
  color: #bdbdbd;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  min-width: 64px;
}

.remove-friend-btn:hover {
  background: #b71c1c;
}

.remove-friend-btn:active {
  transform: scale(0.95);
}

.logo {
  font-family: var(--brand-font);
  font-size: 27px;
  font-weight: 700;
  color: #000;
  letter-spacing: -1px;
  text-align: center;
}