/* IM Connected site styles, layered on Bootstrap 5.3. */

:root {
  --imc-ink: #1f2d3a;
  --imc-muted: #5b6b79;
  --imc-accent: #128f76;
  --imc-accent-dark: #0d6e5b;
  --imc-accent-soft: #e6f4f1;
  --imc-surface: #ffffff;
  --imc-surface-alt: #f5f7f8;
  --imc-border: #dfe5e9;
  --imc-radius: 14px;
  --imc-nav-height: 64px;

  --bs-body-font-family: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --bs-body-color: var(--imc-ink);
  --bs-link-color-rgb: 18, 143, 118;
  --bs-link-hover-color-rgb: 13, 110, 91;
}

/* Bootstrap display utilities (.d-flex etc.) would otherwise override [hidden]. */
[hidden] {
  display: none !important;
}

html {
  scroll-padding-top: calc(var(--imc-nav-height) + 12px);
}

body {
  background: var(--imc-surface);
  line-height: 1.8;
}

h1, h2, h3, .navbar-brand, .display-font {
  font-family: 'Montserrat', var(--bs-body-font-family);
}

/* ---------- Navbar ---------- */

.site-navbar {
  min-height: var(--imc-nav-height);
  background: rgba(31, 45, 58, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.site-navbar .navbar-brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.site-navbar .brand-year {
  color: #6fd6bf;
}

.site-navbar .nav-link {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 500;
}

.site-navbar .nav-link:hover,
.site-navbar .nav-link:focus-visible,
.site-navbar .nav-link.show {
  color: #fff;
}

.site-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.35);
}

.site-navbar .navbar-toggler-icon {
  filter: invert(1);
}

.year-menu {
  max-height: 60vh;
  overflow-y: auto;
  min-width: 8rem;
}

/* Desktop pointers open the year menu on hover (and on keyboard focus);
   touch devices keep Bootstrap's tap-to-open behaviour. */
@media (hover: hover) and (min-width: 992px) {
  .site-navbar .dropdown:hover > .dropdown-menu,
  .site-navbar .dropdown:focus-within > .dropdown-menu {
    display: block;
  }

  .site-navbar .dropdown > .dropdown-menu {
    top: 100%;
    right: 0;
    left: auto;
    margin-top: 0;
  }
}

/* ---------- Image skeletons ---------- */

/* Shimmering placeholder shown in a fixed-ratio box until the image loads,
   so loading photos never shifts the layout. */
.skeleton {
  background: linear-gradient(90deg, #e9edf0 25%, #f5f7f8 37%, #e9edf0 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}

.skeleton.is-loaded {
  animation: none;
  background: var(--imc-surface-alt);
}

img.skeleton {
  color: transparent; /* hide alt text while loading */
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

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

.btn-accent {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--imc-accent);
  --bs-btn-border-color: var(--imc-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--imc-accent-dark);
  --bs-btn-hover-border-color: var(--imc-accent-dark);
  --bs-btn-active-bg: var(--imc-accent-dark);
  --bs-btn-active-border-color: var(--imc-accent-dark);
  --bs-btn-focus-shadow-rgb: 18, 143, 118;
  font-weight: 600;
}

.btn-outline-light {
  font-weight: 600;
}

/* ---------- Sections ---------- */

.section {
  padding: 88px 0;
}

.section-alt {
  background: var(--imc-surface-alt);
}

.section-eyebrow {
  color: var(--imc-accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.section-title {
  font-weight: 700;
  margin-bottom: 2rem;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  min-height: min(92vh, 760px);
  display: flex;
  align-items: center;
  padding: calc(var(--imc-nav-height) + 48px) 0 64px;
  color: #fff;
  background: var(--imc-ink) center / cover no-repeat;
  background-image: var(--hero-image);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(20, 32, 43, 0.92) 0%, rgba(20, 32, 43, 0.72) 55%, rgba(20, 32, 43, 0.35) 100%);
}

.hero > .container {
  position: relative;
}

.hero-kicker {
  font-size: 1.05rem;
  font-weight: 500;
  color: #bfeee3;
  margin-bottom: 0.75rem;
}

.hero-title {
  font-size: clamp(2.6rem, 7vw, 4.75rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 1.5rem;
}

.hero-title .accent {
  color: #6fd6bf;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding: 0;
  list-style: none;
}

.hero-meta li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.95rem;
}

.hero-meta svg {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

.hero-ended {
  display: inline-block;
  margin-bottom: 1.25rem;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--imc-ink);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- About ---------- */

.letter {
  max-width: 760px;
  margin: 0 auto;
  font-size: 1.075rem;
  color: #2f3f4d;
}

.letter .signoff {
  font-family: 'Montserrat', var(--bs-body-font-family);
  font-style: italic;
  color: var(--imc-accent);
  font-size: 1.1rem;
}

/* ---------- Info ---------- */

.info-card {
  height: 100%;
  padding: 1.5rem;
  border-radius: var(--imc-radius);
  background: var(--imc-surface);
  border: 1px solid var(--imc-border);
}

.info-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.fact {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}

.fact + .fact {
  margin-top: 1rem;
}

.fact-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--imc-accent-soft);
  color: var(--imc-accent);
}

.fact-icon svg {
  width: 22px;
  height: 22px;
}

.fact-label {
  display: block;
  font-size: 0.85rem;
  color: var(--imc-muted);
  line-height: 1.4;
}

.fact-value {
  font-weight: 600;
  line-height: 1.5;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding: 0.75rem 0 0.75rem 1.5rem;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1.25rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--imc-accent);
  box-shadow: 0 0 0 4px var(--imc-accent-soft);
}

.timeline li::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1.9rem;
  bottom: -0.6rem;
  width: 2px;
  background: var(--imc-border);
}

.timeline li:last-child::after {
  display: none;
}

.timeline time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--imc-accent-dark);
}

@media (max-width: 575.98px) {
  .timeline li {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.contact + .contact {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--imc-border);
}

.contact-name {
  font-weight: 700;
}

.contact a {
  word-break: break-all;
}

.info-photos {
  display: grid;
  gap: 1rem;
}

.info-photos img,
.recap-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--imc-radius);
}

.info-photos img {
  aspect-ratio: 3 / 2;
}

/* ---------- Signup ---------- */

.signup-frame {
  width: 100%;
  max-width: 760px;
  height: 900px;
  margin: 2rem auto 0;
  display: block;
  border: 1px solid var(--imc-border);
  border-radius: var(--imc-radius);
  background: var(--imc-surface);
}

.ended-card {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  border-radius: var(--imc-radius);
  background: var(--imc-surface);
  border: 1px solid var(--imc-border);
}

/* ---------- Recap ---------- */

.recap-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
}

.recap-grid .recap-main {
  grid-column: 1 / -1;
  aspect-ratio: 21 / 9;
}

.recap-grid > * {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--imc-radius);
}

@media (max-width: 575.98px) {
  .recap-grid {
    grid-template-columns: 1fr 1fr;
  }
  .recap-grid .recap-main {
    aspect-ratio: 3 / 2;
  }
  .recap-grid > :last-child {
    display: none;
  }
}

/* ---------- Gallery page ---------- */

.page-header {
  padding: calc(var(--imc-nav-height) + 48px) 0 32px;
  background: var(--imc-surface-alt);
  border-bottom: 1px solid var(--imc-border);
}

.year-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.year-pill {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--imc-border);
  background: var(--imc-surface);
  color: var(--imc-ink);
  text-decoration: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.year-pill:hover {
  border-color: var(--imc-accent);
  color: var(--imc-accent);
}

.year-pill[aria-current='page'] {
  background: var(--imc-accent);
  border-color: var(--imc-accent);
  color: #fff;
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
}

/* Desktop: keep the size picker beside the year pills; the pills wrap within
   their own column instead of pushing the picker onto a new line. */
@media (min-width: 992px) {
  .gallery-toolbar {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .gallery-toolbar .year-pills {
    flex: 1 1 0;
    min-width: 0;
  }

  .gallery-toolbar .size-picker {
    padding-top: 0.2rem;
  }
}

.size-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
}

.size-picker-label {
  font-size: 0.9rem;
  color: var(--imc-muted);
  white-space: nowrap;
}

.size-picker .btn {
  --bs-btn-active-bg: var(--imc-accent);
  --bs-btn-active-border-color: var(--imc-accent);
  --bs-btn-active-color: #fff;
  min-width: 2.75rem;
  font-weight: 600;
}

/* Fixed 3:2 tiles: every slot has its final size before any photo loads.
   data-size picks the column count: s/m/l are fixed per breakpoint,
   auto fills the row with ~200px tiles. */
.gallery-grid {
  --cols-phone: 2;
  --cols-tablet: 3;
  --cols-desktop: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols-phone), 1fr);
  gap: 0.75rem;
}

.gallery-grid[data-size='s'] { --cols-phone: 3; --cols-tablet: 5; --cols-desktop: 6; }
.gallery-grid[data-size='m'] { --cols-phone: 2; --cols-tablet: 3; --cols-desktop: 4; }
.gallery-grid[data-size='l'] { --cols-phone: 1; --cols-tablet: 2; --cols-desktop: 3; }

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(var(--cols-tablet), 1fr);
    gap: 1rem;
  }
}

@media (min-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(var(--cols-desktop), 1fr);
  }
}

.gallery-grid[data-size='auto'] {
  grid-template-columns: repeat(auto-fill, minmax(min(200px, calc(50% - 0.5rem)), 1fr));
}

.gallery-grid[data-size='s'] {
  gap: 0.5rem;
}

.gallery-item {
  display: block;
  aspect-ratio: 3 / 2;
  border-radius: 10px;
  overflow: hidden;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.3s ease;
}

.gallery-item.is-loaded img {
  opacity: 1;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item img {
    transition: none;
    transform: none;
  }
}

/* ---------- Lightbox ---------- */

.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 14, 18, 0.94);
  color: #fff;
}

.lightbox::backdrop {
  background: rgba(10, 14, 18, 0.94);
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: min(92vw, 1600px);
  max-height: 84vh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
}

.lightbox-btn:hover,
.lightbox-btn:focus-visible {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-close { right: 16px; top: 16px; }

.lightbox-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.lightbox-bar a:not(.btn) {
  color: #bfeee3;
}

.lightbox-save {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.lightbox-save svg {
  width: 1em;
  height: 1em;
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 2rem 0;
  background: var(--imc-ink);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.site-footer a {
  color: #bfeee3;
}
