/* ==========================================================================
   Project documentation – project page additions
   Isolated styles: every gallery/lightbox selector uses the project- prefix.
   ========================================================================== */

.project-history-gallery {
  margin: 30px 0 36px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8fbff;
  overflow: hidden;
}

.project-gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.project-gallery-toolbar > div:first-child {
  min-width: 0;
}

.project-gallery-toolbar > div:first-child > strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.project-gallery-toolbar > div:first-child > span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .88rem;
}

.project-gallery-counter {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.project-gallery-stage {
  position: relative;
  background: #edf4fc;
}

.project-gallery-viewport {
  overflow: hidden;
  touch-action: pan-y;
}

.project-gallery-track {
  display: flex;
  transition: transform .38s cubic-bezier(.2,.7,.2,1);
  will-change: transform;
}

.project-gallery-slide {
  flex: 0 0 100%;
  min-width: 0;
  margin: 0;
  background: #fff;
}

.project-gallery-open {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: #eef4fb;
  cursor: zoom-in;
}

.project-gallery-open:focus-visible {
  outline: 3px solid rgba(11, 99, 243, .35);
  outline-offset: -3px;
}

.project-gallery-open img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #eef4fb;
}

.project-gallery-nav {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  padding: 0;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 999px;
  background: rgba(12, 31, 60, .78);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(10, 37, 74, .18);
  transition: background .2s ease, transform .2s ease, opacity .2s ease;
}

.project-gallery-nav svg,
.project-lightbox-nav svg,
.project-lightbox-close svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.project-gallery-nav:hover,
.project-gallery-nav:focus-visible {
  background: var(--blue);
  transform: translateY(-50%) scale(1.04);
}

.project-gallery-nav:disabled {
  opacity: .3;
  cursor: default;
}

.project-gallery-prev { left: 14px; }
.project-gallery-next { right: 14px; }

.project-lightbox[hidden] { display: none !important; }

.project-lightbox {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
}

.project-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 14, 28, .88);
  backdrop-filter: blur(5px);
}

.project-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100vw - 44px));
  max-height: calc(100vh - 44px);
  max-height: calc(100dvh - 44px);
  display: grid;
  grid-template-columns: 56px minmax(0,1fr) 56px;
  grid-template-rows: minmax(0,1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  background: #07111f;
  box-shadow: 0 28px 90px rgba(0,0,0,.5);
}

.project-lightbox-media {
  grid-column: 2;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px 0 10px;
}

.project-lightbox-media img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  object-fit: contain;
}

.project-lightbox-caption {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  padding: 13px 86px 17px 62px;
  border-top: 1px solid rgba(255,255,255,.12);
  color: #fff;
  text-align: center;
  font-size: .95rem;
}

.project-lightbox-caption strong {
  color: #fff;
  font-weight: 800;
}

.project-lightbox-caption span {
  color: rgba(255,255,255,.82);
}

.project-lightbox-counter {
  position: absolute;
  z-index: 4;
  right: 14px;
  bottom: 12px;
  min-width: 58px;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(5, 14, 28, .72);
  color: #fff;
  font-size: .82rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}

.project-lightbox-close {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  background: rgba(0,0,0,.5);
  color: #fff;
  cursor: pointer;
}

.project-lightbox-close svg {
  width: 20px;
  height: 20px;
}

.project-lightbox-nav {
  width: 44px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
}

.project-lightbox-prev { grid-column: 1; grid-row: 1; }
.project-lightbox-next { grid-column: 3; grid-row: 1; }

.project-lightbox-nav:hover,
.project-lightbox-nav:focus-visible,
.project-lightbox-close:hover,
.project-lightbox-close:focus-visible {
  background: var(--blue);
  outline: none;
}

.project-lightbox-nav:disabled {
  opacity: .28;
  cursor: default;
}

body.project-lightbox-open { overflow: hidden; }

@media (max-width: 760px) {
  /* Mobile gallery: reserve a stable text area and move the counter below the image. */
  .project-history-gallery {
    position: relative;
    padding-bottom: 34px;
  }
  .project-gallery-toolbar {
    display: block;
    padding: 15px 16px;
  }
  .project-gallery-toolbar > div:first-child {
    min-height: 6.7em;
  }
  .project-gallery-toolbar > div:first-child > strong {
    line-height: 1.35;
  }
  .project-gallery-toolbar > div:first-child > span {
    margin-top: 4px;
    font-size: .8rem;
    line-height: 1.45;
  }
  .project-gallery-counter {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: 6px;
    min-width: 50px;
    padding: 4px 8px;
    transform: translateX(-50%);
    font-size: .74rem;
    line-height: 1;
  }
  .project-gallery-nav { width: 38px; height: 38px; }
  .project-gallery-nav svg { width: 20px; height: 20px; }
  .project-gallery-prev { left: 7px; }
  .project-gallery-next { right: 7px; }

  /* Mobile lightbox: full-width image, navigation beside a stable caption area. */
  .project-lightbox { padding: 8px; }
  .project-lightbox-panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    grid-template-columns: 46px minmax(0,1fr) 46px;
    grid-template-rows: minmax(0,1fr) auto;
    border-radius: 14px;
  }
  .project-lightbox-media {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 54px 8px 8px;
  }
  .project-lightbox-media img {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 205px);
  }
  .project-lightbox-caption {
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: calc(6.75em + 44px);
    padding: 10px 4px 31px;
    font-size: .85rem;
    line-height: 1.35;
  }
  .project-lightbox-caption strong,
  .project-lightbox-caption span {
    display: block;
    width: 100%;
  }
  .project-lightbox-caption strong {
    line-height: 1.35;
  }
  .project-lightbox-caption span {
    margin-top: 3px;
    line-height: 1.35;
  }
  .project-lightbox-nav {
    grid-row: 2;
    align-self: center;
    width: 38px;
    height: 52px;
  }
  .project-lightbox-prev { grid-column: 1; }
  .project-lightbox-next { grid-column: 3; }
  .project-lightbox-nav svg { width: 21px; height: 21px; }
  .project-lightbox-close { width: 38px; height: 38px; top: 9px; right: 9px; }
  .project-lightbox-close svg { width: 18px; height: 18px; }
  .project-lightbox-counter {
    right: 50%;
    bottom: 8px;
    min-width: 50px;
    padding: 4px 8px;
    transform: translateX(50%);
    font-size: .72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-gallery-track,
  .project-gallery-nav { transition: none; }
}


/* Project documentation – media blocks */
.project-doc-media {
  margin: 26px 0 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
}
.project-doc-media img {
  display: block;
  width: 100%;
  height: auto;
  background: #eef4fb;
}
.project-doc-media figcaption {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}
@media (max-width: 700px) {
  .project-doc-media { margin: 20px 0 28px; border-radius: 14px; }
  .project-doc-media figcaption { padding: 10px 12px 12px; font-size: .84rem; }
}

/* Project documentation – responsive video embeds */
.project-video-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 26px 0 34px;
  overflow: hidden;
  border-radius: 18px;
  background: #000;
}
.project-video-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
@media (max-width: 700px) {
  .project-video-embed {
    margin: 20px 0 28px;
    border-radius: 14px;
  }
}

/* Shared project documentation page rules migrated from inline HTML */
.documentation-section { padding-top: 54px; padding-bottom: 84px; background: #fff; }
      .documentation-card { padding: clamp(26px, 4vw, 52px); }
      .documentation-flow { max-width: 100%; }
      .doc-chapter + .doc-chapter { margin-top: 76px; }
      .doc-chapter-heading { margin: 0 0 22px; }
      .doc-chapter-heading .eyebrow { margin-bottom: 10px; }
      .doc-chapter-heading h2 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; letter-spacing: -0.035em; }
      .documentation-card > :first-child { margin-top: 0; }
      .documentation-card h3 { font-size: clamp(1.25rem, 2.2vw, 1.55rem); line-height: 1.2; margin: 34px 0 12px; }
      .documentation-card h4 { font-size: 1.02rem; margin: 24px 0 8px; }
      .documentation-card p, .documentation-card li { line-height: 1.72; }
      .documentation-card p { margin: 0 0 16px; }
      .documentation-card ul { margin: 8px 0 22px; padding-left: 24px; }
      .documentation-card li + li { margin-top: 7px; }
      .doc-lead { font-size: 1.08rem; color: var(--ink); }
      .doc-muted { color: var(--muted); }
      .doc-callout { margin: 24px 0; padding: 18px 20px; border-left: 4px solid var(--blue); background: #f6f9ff; border-radius: 0 12px 12px 0; }
      .doc-callout strong { display: block; margin-bottom: 6px; }
      .doc-table { width: 100%; border-collapse: collapse; margin: 18px 0 28px; font-size: .94rem; }
      .doc-table th, .doc-table td { text-align: left; vertical-align: top; padding: 13px 14px; border-bottom: 1px solid var(--line); }
      .doc-table th { background: #f7faff; color: var(--ink); }
      .media-placeholder { min-height: 230px; margin: 30px 0; border: 1.5px dashed #a9c6f4; border-radius: 18px; background: #f8fbff; display: grid; place-items: center; text-align: center; padding: 28px; color: var(--muted); }
      .media-placeholder strong { display: block; color: var(--blue); margin-bottom: 6px; }
      .media-placeholder.wide { min-height: 300px; }
      .doc-link { color: var(--blue); font-weight: 700; overflow-wrap: anywhere; }
      @media (max-width: 760px) {
        .documentation-section { padding-top: 34px; padding-bottom: 58px; }
        .documentation-card { padding: 22px 12px; }
        .doc-chapter + .doc-chapter { margin-top: 54px; }
        .doc-chapter-heading { margin-bottom: 16px; }
        .doc-chapter-heading h2 { font-size: clamp(1.72rem, 8vw, 2.25rem); }
        .doc-table { display: block; overflow-x: auto; }
        .media-placeholder, .media-placeholder.wide { min-height: 180px; }
      }
    
      html { scroll-behavior: smooth; }
      .doc-chapter, .doc-toc { scroll-margin-top: 110px; }
      .doc-toc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-top: 18px; }
      .doc-toc-link { display: block; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font-weight: 700; text-decoration: none; background: #fff; transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
      .doc-toc-link:hover { border-color: #9fc2ff; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(10, 73, 173, .08); }
      .doc-toc-link span { color: var(--blue); margin-right: 6px; }
      .todo-note { margin: 0; font-weight: 700; color: var(--muted); }
      @media (max-width: 760px) { .doc-toc-grid { grid-template-columns: 1fr; } }


/* Project documentation – expandable AI role details */
.project-doc-media-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style: none;
}
.project-doc-media-details summary::-webkit-details-marker { display: none; }
.project-doc-media-details-toggle {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
}
.project-doc-media-details-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: .88rem;
  font-weight: 400;
}
.project-doc-media-details-body ul {
  margin: 0;
  padding-left: 20px;
}
.project-doc-media-details-body li + li { margin-top: 8px; }
@media (max-width: 700px) {
  .project-doc-media-details summary { gap: 10px; }
  .project-doc-media-details-toggle { font-size: .78rem; }
  .project-doc-media-details-body { font-size: .84rem; }
}
