/* ── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ig-white:      #ffffff;
  --ig-black:      #000000;
  --ig-text:       #262626;
  --ig-gray:       #8e8e8e;
  --ig-border:     #dbdbdb;
  --ig-blue:       #0095f6;
  --ig-blue-dark:  #00376b;
  --ig-bg:         #fafafa;
  --ig-overlay:    rgba(0,0,0,.88);
  --ig-grid-gap:   3px;
  --nav-h-mobile:  49px;
  --nav-h-desktop: 61px;
  --max-width:     935px;
}

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  background: var(--ig-bg);
  color: var(--ig-text);
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; border: none; background: none; font: inherit; }
img    { display: block; max-width: 100%; }

/* ── Desktop top nav ────────────────────────────────────────────────── */
.nav-desktop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h-desktop);
  background: var(--ig-white);
  border-bottom: 1px solid var(--ig-border);
  z-index: 100;
}
.nav-desktop-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.nav-logo {
  font-family: 'Billabong', 'Dancing Script', cursive, sans-serif;
  font-size: 26px;
  color: var(--ig-text);
  letter-spacing: -.5px;
  line-height: 1;
  user-select: none;
}
.nav-icons { display: flex; gap: 22px; }
.nav-icon-btn { color: var(--ig-text); padding: 4px; border-radius: 50%; transition: opacity .15s; }
.nav-icon-btn:hover { opacity: .6; }

/* ── Main page wrapper ──────────────────────────────────────────────── */
.ig-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-bottom: calc(var(--nav-h-mobile) + 16px);
}

/* ── Profile header ─────────────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  padding: 24px 16px 20px;
}

.profile-avatar-wrap { flex-shrink: 0; }

.story-ring {
  width: 77px; height: 77px;
  border-radius: 50%;
  background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888);
  padding: 2px;
  display: flex; align-items: center; justify-content: center;
}
.profile-avatar {
  width: 71px; height: 71px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--ig-white);
}
.avatar-fallback {
  width: 71px; height: 71px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a5c2a, #2d9e44);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ig-white);
}

.profile-meta { flex: 1; min-width: 0; }

.profile-username-row { margin-bottom: 14px; }
.profile-username {
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-cta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.btn-follow {
  flex: 1;
  background: var(--ig-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 8px;
  transition: opacity .15s;
}
.btn-follow:hover { opacity: .85; }
.btn-message {
  flex: 1;
  background: var(--ig-border);
  color: var(--ig-text);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 8px;
  transition: background .15s;
}
.btn-message:hover { background: #c7c7c7; }
.btn-chevron {
  background: var(--ig-border);
  border-radius: 8px;
  padding: 7px 10px;
}

.profile-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 14px;
}
.stat strong { font-size: 16px; }
.stat-label { color: var(--ig-text); font-size: 13px; }

.profile-bio { font-size: 14px; line-height: 1.5; }
.bio-name { font-weight: 600; }

/* ── Story highlights ───────────────────────────────────────────────── */
.highlights-row {
  display: flex;
  gap: 16px;
  padding: 8px 16px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.highlights-row::-webkit-scrollbar { display: none; }

.highlight-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.highlight-circle {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--ig-white);
  border: 1px solid var(--ig-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  transition: opacity .15s;
}
.highlight-circle:hover { opacity: .8; }
.highlight-label {
  font-size: 12px;
  color: var(--ig-text);
  max-width: 64px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Tab bar ────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-top: 1px solid var(--ig-border);
  border-bottom: 1px solid var(--ig-border);
}
.tab {
  flex: 1;
  padding: 12px 0;
  color: var(--ig-gray);
  border-top: 1px solid transparent;
  margin-top: -1px;
  transition: color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tab-active {
  color: var(--ig-text);
  border-top-color: var(--ig-text);
}

/* ── Post grid ──────────────────────────────────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--ig-grid-gap);
}

.post-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  background: #e8e8e8;
}
.post-thumb:hover .thumb-overlay { opacity: 1; }

.thumb-bg {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Gradient placeholder when no real image */
.thumb-gradient {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  gap: 20px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* Type badge (top-right) */
.thumb-badge {
  position: absolute;
  top: 8px; right: 8px;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}

/* Bottom gradient on thumbnails */
.thumb-gradient-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(0,0,0,.35), transparent);
}

/* ── Modal overlay (shared) ─────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--ig-overlay);
  z-index: 500;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
}
.modal-overlay.open { display: flex; }

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  z-index: 10;
  padding: 6px 10px;
  border-radius: 50%;
  background: rgba(0,0,0,.3);
  transition: background .15s;
}
.modal-close:hover { background: rgba(0,0,0,.6); }

/* ── Reel modal ─────────────────────────────────────────────────────── */
.reel-container {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 430px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shown when no video file exists */
.reel-no-video {
  color: #fff;
  text-align: center;
  padding: 40px 24px;
  font-size: 15px;
  line-height: 1.6;
  opacity: .8;
}
.reel-no-video strong { display: block; font-size: 20px; margin-bottom: 12px; }

.reel-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
}

.reel-sidebar {
  position: absolute;
  right: 12px;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  pointer-events: all;
}
.reel-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
}
.reel-icon-count {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.reel-audio-indicator {
  font-size: 20px;
  animation: spin 4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reel-caption {
  position: absolute;
  bottom: 16px;
  left: 12px;
  right: 60px;
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  pointer-events: all;
}
.reel-username { font-weight: 700; margin-right: 6px; }

.reel-mute-btn {
  position: absolute;
  bottom: 90px;
  left: 14px;
  background: rgba(0,0,0,.4);
  border-radius: 50%;
  padding: 8px;
  color: #fff;
  z-index: 5;
}

/* ── Carousel modal ─────────────────────────────────────────────────── */
.carousel-container {
  position: relative;
  width: 100%;
  max-width: 614px;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.carousel-slides-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  position: relative;
}
.carousel-slides {
  display: flex;
  height: 100%;
  transition: transform .3s ease;
}
.carousel-slide {
  flex: 0 0 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px;
  flex-direction: column;
  gap: 20px;
}

/* Slide colour themes */
.slide-dark  { background: #0f1923; color: #fff; }
.slide-green { background: #0d3320; color: #fff; }
.slide-gold  { background: #1a1200; color: #f5c518; }

.slide-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: .6;
}
.slide-headline {
  font-size: clamp(20px, 5vw, 30px);
  font-weight: 700;
  line-height: 1.2;
}
.slide-body {
  font-size: clamp(14px, 3vw, 17px);
  line-height: 1.6;
  opacity: .85;
}
.slide-cta {
  font-size: 15px;
  font-weight: 700;
  background: var(--ig-blue);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 8px;
}
.slide-logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: .5;
  margin-top: 8px;
}
.slide-emoji { font-size: 48px; margin-bottom: 4px; }

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background .15s;
  z-index: 5;
}
.carousel-arrow:hover { background: rgba(255,255,255,.3); }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }
.carousel-arrow.hidden { display: none; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 10px 0;
  background: #000;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  transition: background .2s;
}
.dot.active { background: var(--ig-blue); }

.carousel-caption {
  padding: 10px 14px 14px;
  background: var(--ig-white);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ig-text);
}
.carousel-username { font-weight: 700; margin-right: 6px; }

/* ── Photo modal ────────────────────────────────────────────────────── */
.photo-container {
  width: 100%;
  max-width: 614px;
  background: var(--ig-white);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
}

.photo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ig-border);
}
.photo-header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a5c2a, #2d9e44);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-header-username { font-size: 14px; font-weight: 600; }

.photo-image-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
}

.photo-footer { padding: 12px 14px; }
.photo-actions { display: flex; gap: 16px; margin-bottom: 8px; }
.photo-action-btn { padding: 4px; color: var(--ig-text); transition: opacity .15s; }
.photo-action-btn:hover { opacity: .5; }
.photo-likes { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.photo-caption-row { font-size: 14px; line-height: 1.5; }
.photo-caption-username { font-weight: 700; margin-right: 6px; }

/* ── Mobile bottom nav ──────────────────────────────────────────────── */
.nav-mobile {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h-mobile);
  background: var(--ig-white);
  border-top: 1px solid var(--ig-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}
.nav-mobile-btn {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ig-text);
  opacity: .5;
  transition: opacity .15s;
}
.nav-mobile-btn:hover,
.nav-mobile-active { opacity: 1 !important; }

/* ── Desktop layout ─────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .nav-desktop { display: block; }
  .nav-mobile  { display: none; }

  .ig-page {
    padding-top: calc(var(--nav-h-desktop) + 30px);
    padding-bottom: 40px;
  }

  .profile-header {
    padding: 30px 0 24px;
    gap: 60px;
  }

  .story-ring { width: 150px; height: 150px; padding: 3px; }
  .profile-avatar  { width: 142px; height: 142px; border-width: 4px; }
  .avatar-fallback { width: 142px; height: 142px; font-size: 56px; border-width: 4px; }

  .profile-username { font-size: 28px; }

  .profile-stats {
    flex-direction: row;
    gap: 36px;
  }
  .stat { flex-direction: row; align-items: baseline; gap: 6px; }
  .stat strong { font-size: 16px; }

  .profile-cta-row { display: none; } /* desktop IG shows these inline with username */

  .highlights-row { padding: 16px 0 20px; gap: 24px; }
  .highlight-circle { width: 70px; height: 70px; }

  .carousel-container { border-radius: 0; }
  .photo-container    { border-radius: 0; }
}
