/* Instagram-inspired project overview
   Scoped to the igp-* components so the existing site remains unchanged. */

[hidden] {
  display: none !important;
}

.igp-hero {
  padding: calc(var(--header-height) + var(--space-3xl)) 0 var(--space-xl);
  background:
    radial-gradient(circle at 78% 22%, rgba(212, 175, 55, 0.1), transparent 28rem),
    var(--color-secondary);
  border-bottom: 1px solid var(--color-border);
}

.igp-hero .container,
.igp-section .container {
  max-width: 1120px;
}

.igp-hero .section-title {
  margin-bottom: var(--space-sm);
}

.igp-hero-subtitle {
  max-width: 720px;
  color: var(--color-text-light);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.75;
}

.igp-hero-link,
.igp-error-link,
.igp-modal-link {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}

.igp-hero-link:hover,
.igp-error-link:hover,
.igp-modal-link:hover {
  color: var(--color-accent);
}

.igp-section {
  min-height: 55vh;
  padding: var(--space-xl) 0 var(--space-3xl);
  background: var(--color-white);
}

/* Status and controls */
.igp-banner {
  position: relative;
  margin-bottom: var(--space-lg);
  padding: 0.9rem 3.25rem 0.9rem 1rem;
  color: #5f501b;
  background: #fbf7e8;
  border: 1px solid rgba(212, 175, 55, 0.42);
}

.igp-banner-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

.igp-banner-close {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.igp-banner-close:hover {
  background: rgba(212, 175, 55, 0.14);
}

.igp-toggle {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.igp-toggle-btn {
  position: relative;
  min-width: 6.5rem;
  padding: 0.8rem 1.25rem;
  color: var(--color-text-light);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.igp-toggle-btn::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--color-primary);
  content: '';
  opacity: 0;
  transform: scaleX(0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.igp-toggle-btn:hover,
.igp-toggle-btn.active {
  color: var(--color-primary);
}

.igp-toggle-btn.active::after {
  opacity: 1;
  transform: scaleX(1);
}

.igp-loading,
.igp-error {
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}

.igp-loading {
  color: var(--color-text-light);
}

.igp-loading::before {
  display: block;
  width: 2rem;
  height: 2rem;
  margin: 0 auto var(--space-sm);
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  content: '';
  animation: igp-spin 0.8s linear infinite;
}

.igp-error-title {
  margin-bottom: 0.4rem;
  color: var(--color-primary);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
}

.igp-error-text {
  margin-bottom: var(--space-sm);
  color: var(--color-text-light);
}

@keyframes igp-spin {
  to { transform: rotate(360deg); }
}

/* Rotating carousel (replaces the static profile grid) */
.igp-carousel {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "prev viewport next" "dots dots dots";
  align-items: center;
  gap: 12px;
}

.igp-car-viewport {
  grid-area: viewport;
  overflow: hidden;
}

.igp-car-track {
  display: flex;
  gap: 4px;
  transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}

/* Three across by default; the tile itself keeps its square aspect-ratio. */
.igp-car-track > .igp-tile {
  flex: 0 0 calc((100% - 8px) / 3);
}

.igp-car-arrow {
  grid-area: prev;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
  color: inherit;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.igp-car-next { grid-area: next; }

.igp-car-arrow:hover { background: #fff; transform: scale(1.06); }
.igp-car-arrow:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.igp-car-dots {
  grid-area: dots;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.igp-car-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  background: rgba(0, 0, 0, 0.22);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.igp-car-dot.active {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.3);
}

.igp-car-dot:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

@media (max-width: 900px) {
  .igp-car-track > .igp-tile { flex: 0 0 calc((100% - 4px) / 2); }
}

@media (max-width: 600px) {
  .igp-car-track > .igp-tile { flex: 0 0 100%; }
  .igp-car-arrow { width: 34px; height: 34px; font-size: 1.3rem; }
  .igp-carousel { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .igp-car-track { transition: none; }
  .igp-car-arrow, .igp-car-dot { transition: none; }
}

/* Instagram's own player, used for Reels (no media_url is available for them) */
.igp-modal-embed {
  width: 100%;
  max-width: 440px;
  /* Must stay inside .igp-modal-dialog, which caps its own height and clips overflow —
     a taller iframe grows the stage and the player gets cut off entirely. */
  height: calc(100vh - clamp(6rem, 16vw, 12rem));
  max-height: 640px;
  min-height: 280px;
  border: 0;
  background: #000;
}

/* Profile grid */
.igp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.igp-tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  aspect-ratio: 1;
  overflow: hidden;
  background: #ececec;
  border: 0;
  cursor: pointer;
}

.igp-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.25s ease, transform 0.45s cubic-bezier(0.2, 0.65, 0.35, 1);
}

.igp-tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.35rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.igp-tile-stat {
  font-size: 0.95rem;
  font-weight: 700;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.igp-tile:hover .igp-tile-img,
.igp-tile:focus-visible .igp-tile-img {
  filter: saturate(0.75) brightness(0.92);
  transform: scale(1.025);
}

.igp-tile:hover .igp-tile-overlay,
.igp-tile:focus-visible .igp-tile-overlay {
  opacity: 1;
}

.igp-carousel-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  border-radius: 50%;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
}

/* Post feed */
.igp-feed {
  display: grid;
  width: min(100%, 640px);
  margin: 0 auto;
  gap: var(--space-xl);
}

.igp-card {
  overflow: hidden;
  background: var(--color-white);
  border: 1px solid var(--color-border);
}

.igp-card-header {
  display: flex;
  align-items: center;
  min-height: 4.5rem;
  padding: 0.85rem 1rem;
}

.igp-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  margin-right: 0.75rem;
  place-items: center;
  color: var(--color-white);
  background: linear-gradient(145deg, var(--color-primary), #4c4532);
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.igp-username,
.igp-caption-user {
  color: var(--color-primary);
  font-weight: 600;
}

.igp-header-dot {
  margin: 0 0.45rem;
  color: var(--color-text-lighter);
}

.igp-card-time {
  color: var(--color-text-lighter);
  font-size: 0.86rem;
}

.igp-card-media {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  aspect-ratio: 1;
  overflow: hidden;
  background: #efefef;
  border: 0;
  cursor: pointer;
}

.igp-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s cubic-bezier(0.2, 0.65, 0.35, 1);
}

.igp-card-media:hover .igp-card-img {
  transform: scale(1.015);
}

.igp-card-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem 0.5rem;
  color: var(--color-primary);
}

.igp-card-actions svg {
  display: block;
}

.igp-card-likes,
.igp-card-caption,
.igp-card-date {
  margin: 0;
  padding-right: 1rem;
  padding-left: 1rem;
}

.igp-card-likes {
  padding-bottom: 0.35rem;
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.igp-card-caption {
  color: var(--color-text);
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.igp-hashtag {
  color: #516c8d;
}

.igp-more-btn {
  padding: 0;
  color: var(--color-text-lighter);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.igp-more-btn:hover {
  color: var(--color-primary);
}

.igp-card-date {
  padding-top: 0.75rem;
  padding-bottom: 1rem;
  color: var(--color-text-lighter);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Detail modal */
.igp-modal {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  padding: clamp(1rem, 4vw, 3rem);
  place-items: center;
  background: rgba(9, 9, 9, 0.86);
  backdrop-filter: blur(7px);
}

.igp-modal-dialog {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(18rem, 0.75fr);
  width: min(1120px, 100%);
  max-height: calc(100vh - clamp(2rem, 8vw, 6rem));
  overflow: hidden;
  background: var(--color-white);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.35);
}

.igp-modal-close {
  position: fixed;
  z-index: 2;
  top: 0.6rem;
  right: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.igp-modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.igp-modal-media {
  position: relative;
  display: grid;
  min-height: min(72vh, 720px);
  max-height: calc(100vh - clamp(2rem, 8vw, 6rem));
  overflow: hidden;
  place-items: center;
  background: #0d0d0d;
}

.igp-modal-stage {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
}

.igp-modal-img {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - clamp(2rem, 8vw, 6rem));
  object-fit: contain;
}

.igp-modal-nav {
  position: absolute;
  z-index: 1;
  top: 50%;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  font: inherit;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.igp-modal-nav:hover {
  background: rgba(0, 0, 0, 0.7);
}

.igp-modal-prev { left: 1rem; }
.igp-modal-next { right: 1rem; }

.igp-modal-dots {
  position: absolute;
  z-index: 1;
  bottom: 0.9rem;
  left: 50%;
  display: flex;
  gap: 0.45rem;
  transform: translateX(-50%);
}

.igp-modal-dot {
  width: 0.55rem;
  height: 0.55rem;
  padding: 0;
  background: rgba(255, 255, 255, 0.52);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.igp-modal-dot.active {
  background: var(--color-white);
  transform: scale(1.2);
}

.igp-modal-info {
  display: flex;
  min-height: 0;
  /* Without this cap a long caption grows the grid row past the dialog's max-height,
     and the clipped overflow cuts the bottom off the image. */
  max-height: calc(100vh - clamp(2rem, 8vw, 6rem));
  padding: clamp(1.5rem, 3vw, 2.25rem);
  flex-direction: column;
  overflow-y: auto;
}

.igp-modal-caption {
  color: var(--color-text);
  font-size: 0.94rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: normal;
}

.igp-modal-meta {
  margin: auto 0 var(--space-md);
  padding-top: var(--space-xl);
  color: var(--color-text-lighter);
  font-size: 0.78rem;
  line-height: 1.5;
}

.igp-modal-link {
  align-self: flex-start;
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .igp-hero {
    padding-top: calc(80px + var(--space-xl));
  }

  .igp-section {
    padding-top: var(--space-lg);
  }

  .igp-modal {
    padding: 3.5rem 0.75rem 0.75rem;
  }

  .igp-modal-dialog {
    grid-template-columns: 1fr;
    max-height: calc(100vh - 4.25rem);
    overflow-y: auto;
  }

  .igp-modal-media {
    min-height: auto;
    aspect-ratio: 1;
  }

  .igp-modal-img {
    max-height: none;
  }

  .igp-modal-info {
    flex: none;
    max-height: 36vh;
    padding: 1.25rem;
  }

  .igp-modal-meta {
    margin-top: var(--space-lg);
  }
}

@media (max-width: 600px) {
  .igp-hero .container,
  .igp-section .container {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .igp-grid {
    gap: 2px;
  }

  .igp-tile-overlay {
    display: none;
  }

  .igp-carousel-badge {
    top: 0.4rem;
    right: 0.4rem;
    width: 1.7rem;
    height: 1.7rem;
  }

  .igp-carousel-badge svg {
    width: 15px;
    height: 15px;
  }

  .igp-feed {
    gap: var(--space-lg);
  }

  .igp-card-header {
    min-height: 4rem;
  }

  .igp-card-actions {
    padding-top: 0.75rem;
  }

  .igp-modal-nav {
    width: 2.35rem;
    height: 2.35rem;
  }

  .igp-modal-prev { left: 0.6rem; }
  .igp-modal-next { right: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .igp-loading::before {
    animation: none;
  }

  .igp-tile-img,
  .igp-tile-overlay,
  .igp-card-img,
  .igp-toggle-btn::after {
    transition: none;
  }
}
