/* Enable the rail only after its controls exist. Deployed section styles use
   !important for the old grid, including at mobile breakpoints. */
#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel:has(> .ps-carousel-nav) {
  --ps-gap: clamp(14px, 1.5vw, 24px);
  --ps-card-width: calc((100% - var(--ps-gap)) / 2);
  --ps-ink: var(--vish-text, var(--text));
  --ps-muted: var(--vish-muted, var(--muted));
  --ps-panel: var(--vish-surface, var(--sh-panel));
  --ps-line: var(--vish-line, var(--sh-edge));
  --ps-tint: var(--vish-soft, var(--sh-soft));
  --ps-accent: var(--vish-action, var(--cyan));
  min-width: 0;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-nav[hidden] {
  display: none !important;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-position {
  order: -1;
  margin-right: auto;
  color: var(--ps-ink);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-jump {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
  max-width: 100%;
  color: var(--ps-muted);
  font-size: 13px;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-jump select {
  width: min(28vw, 340px);
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-nav .ps-arrow {
  position: static;
  inset: auto;
  display: inline-flex;
  width: auto;
  min-width: 48px;
  min-height: 48px;
  height: auto;
  padding: 7px 12px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transform: none;
  border: 1px solid var(--ps-line);
  border-radius: 12px;
  background: var(--ps-panel);
  color: var(--ps-ink);
  box-shadow: none;
  line-height: 1;
  cursor: pointer;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-nav .ps-arrow:disabled {
  opacity: .46;
  cursor: default;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel:has(> .ps-carousel-nav) .ps-track {
  position: relative;
  box-sizing: border-box;
  display: flex !important;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
  max-width: none;
  gap: var(--ps-gap) !important;
  margin: 0 !important;
  padding: 0 0 8px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: auto;
  scrollbar-color: var(--ps-muted) transparent;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel :is(.ps-track, button, select):focus-visible {
  outline: 3px solid var(--ps-accent) !important;
  outline-offset: 3px !important;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel:has(> .ps-carousel-nav) .ps-card {
  box-sizing: border-box;
  position: relative;
  display: grid !important;
  flex: 0 0 var(--ps-card-width) !important;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1fr) !important;
  grid-template-rows: auto auto minmax(12px, 1fr) auto auto !important;
  column-gap: clamp(14px, 1.5vw, 24px) !important;
  row-gap: 0 !important;
  align-content: stretch !important;
  align-items: start !important;
  padding: clamp(14px, 1.5vw, 24px) !important;
  scroll-snap-align: start;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card img {
  grid-area: 1 / 1 / -1 / 2 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 260px;
  max-height: 470px !important;
  aspect-ratio: 948 / 1860 !important;
  object-fit: contain !important;
  border-radius: 12px !important;
  background: var(--ps-tint) !important;
  cursor: zoom-in;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-project-meta {
  grid-area: 1 / 2;
  margin: 4px 0 7px;
  color: var(--ps-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .sc-project-title {
  grid-area: 2 / 2 !important;
  padding: 0 !important;
  font-size: clamp(18px, 1.5vw, 24px) !important;
  line-height: 1.3 !important;
  overflow-wrap: anywhere !important;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-poster-open {
  grid-area: 4 / 2;
  justify-self: start;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ps-accent);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: zoom-in;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions {
  grid-area: 5 / 2 !important;
  width: 100%;
  gap: 6px !important;
  align-items: center !important;
  padding: 8px 0 0 !important;
  margin: 0 !important;
  border-top: 1px solid var(--ps-line);
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions > * {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions .ps-favorite-btn {
  width: auto !important;
  flex: 1 1 108px !important;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions .ps-add-choice {
  flex: 1 1 130px !important;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions .ps-favorite-btn.is-favorite {
  border-color: var(--ps-accent) !important;
  background: var(--ps-tint) !important;
  color: var(--ps-accent) !important;
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions .ps-readonly-label {
  box-sizing: border-box;
  flex: 1 0 136px !important;
  max-width: 100%;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  text-align: center;
}

@media (hover: hover) {
  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-nav .ps-arrow:hover:not(:disabled) {
    border-color: var(--ps-accent);
    background: var(--ps-tint);
  }
}

@media (max-width: 959px) {
  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel:has(> .ps-carousel-nav) {
    --ps-card-width: 100%;
  }
}

@media (max-width: 599px) {
  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-jump {
    order: -2;
    flex-basis: 100%;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel-jump select {
    flex: 1 1 160px;
    width: 100%;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel:has(> .ps-carousel-nav) .ps-card {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto 1fr auto auto !important;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-project-meta {
    grid-area: 1 / 1;
    margin: 0 0 4px;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .sc-project-title {
    grid-area: 2 / 1 !important;
    padding-bottom: 12px !important;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card img {
    grid-area: 3 / 1 !important;
    min-height: 0;
    height: clamp(270px, 45svh, 420px) !important;
    aspect-ratio: auto !important;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-poster-open {
    grid-area: 4 / 1;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card-actions {
    grid-area: 5 / 1 !important;
  }

  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card .ps-add-choice {
    flex: 1 1 130px !important;
  }
}

/* Display the actual poster at reading width; the dialog scrolls vertically. */
#pd-student-layout[data-student-page=projects] .sc-poster-dialog {
  box-sizing: border-box;
  width: min(96vw, 820px);
  max-height: 94vh;
  max-height: 94dvh;
  overflow: auto;
  overscroll-behavior: contain;
}

#pd-student-layout[data-student-page=projects] .sc-poster-dialog img {
  width: 100%;
  height: auto;
  max-height: none;
  max-width: 100%;
}

#pd-student-layout[data-student-page=projects] .sc-poster-dialog .sc-poster-close {
  position: sticky;
  top: 0;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  #pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-track {
    scroll-behavior: auto !important;
  }
}

#pd-student-layout[data-student-page=projects] #projects-showcase .ps-carousel .ps-card {
  scroll-margin-block-start: calc(var(--sc-header-height, 0px) + 12px);
}

#pd-student-layout[data-student-page=projects] dialog.sc-poster-dialog.ps-poster-reader[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 94vh;
  max-height: 94dvh;
  overflow: hidden;
}

#pd-student-layout[data-student-page=projects] .ps-poster-reader .ps-poster-tools {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#pd-student-layout[data-student-page=projects] .ps-poster-tools .ps-poster-zoom {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--vish-line, var(--sh-edge));
  border-radius: 10px;
  background: var(--vish-surface, var(--sh-panel));
  color: var(--vish-text, var(--text));
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

#pd-student-layout[data-student-page=projects] .ps-poster-tools .ps-poster-zoom[aria-pressed=true] {
  border-color: var(--vish-action, var(--cyan));
  background: var(--vish-soft, var(--sh-soft));
}

#pd-student-layout[data-student-page=projects] .ps-poster-tools .sc-poster-close {
  position: static;
  margin: 0;
}

#pd-student-layout[data-student-page=projects] .ps-poster-reader .ps-poster-viewport {
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-height: 82vh;
  max-height: 82dvh;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--vish-muted, var(--muted)) transparent;
}

#pd-student-layout[data-student-page=projects] .ps-poster-reader .ps-poster-viewport.is-zoomed img {
  width: max(160%, 720px);
  max-width: none;
  height: auto;
  margin: 0;
}
