/* Ember Chat — project viewer, folder tree, lightbox. Desktop: content 640 + ON THIS PAGE 232. */

/* ---------- folder tree in the sidebar ---------- */

.tree__row {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
}
.tree__row .tree__chevron { flex: none; transition: transform var(--dur-fast) var(--ease-out); }
.tree__row[aria-expanded="true"] .tree__chevron { transform: rotate(90deg); }
.tree__icon { flex: none; }
.tree__icon--open,
.tree__row[aria-expanded="true"] .tree__icon--closed { display: none; }
.tree__row[aria-expanded="true"] .tree__icon--open { display: block; }
.tree__row[aria-expanded="true"] { color: var(--text); }
.tree__row:focus-visible { border-radius: var(--radius-md); }
.tree__row .badge { margin-left: auto; }

.tree__files { margin: 2px 0 var(--space-1); }
.tree__files[hidden] { display: none; }
.no-js .tree__files[hidden] { display: block; }
.no-js .tree__chevron { visibility: hidden; } /* folders are always open without JS */

.tree__file {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-2) 0 calc(var(--space-2) + 24px);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--mono-body-size);
  line-height: var(--mono-body-lh);
}
.tree__file .icon { flex: none; color: var(--text-subtle); }
.tree__file:hover { background: var(--hover-fill); color: var(--text); }
.tree__file:focus-visible { border-radius: var(--radius-sm); }
.tree__file[aria-current="page"] { background: var(--surface-raised); box-shadow: var(--elevation-1); color: var(--text); }
.tree__file[aria-current="page"] .icon { color: var(--accent-text); }

.tooltip {
  position: fixed;
  z-index: 70;
  max-width: 260px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--glass-fill-strong), var(--popover-under);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-rim), var(--elevation-2);
  color: var(--text-muted);
  font-size: var(--caption-size);
  line-height: var(--caption-lh);
  pointer-events: none;
}
.tooltip[hidden] { display: none; }

/* ---------- viewer layer ---------- */

.viewer {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: var(--aurora-ambient);
}
.viewer[hidden] { display: none; }
.no-js .viewer { position: static; }

.viewer__bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--servicebar-h);
  padding: 0 var(--space-4) 0 var(--space-6);
  box-shadow: inset 0 -1px 0 var(--divider);
}
.viewer__menu { display: none; }
.viewer__close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  box-shadow: var(--line-edges);
}
.viewer__close:focus-visible { border-radius: var(--radius-sm); box-shadow: var(--line-edges), var(--focus-ring); }
.crumbs { display: flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--text-subtle); white-space: nowrap; }
.crumbs a { display: inline-block; padding: 5px 0; color: var(--text-muted); }
.crumbs a:hover { color: var(--text); }
.crumbs__project { overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.crumbs__file { color: var(--text); }

.viewer__body {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 232px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--surface-hover) transparent;
}

.viewer__main { padding: var(--space-9) var(--space-6) var(--space-10); }

.file { max-width: 640px; margin: 0 auto; }
.js .viewer .file:not(.is-active) { display: none; }
.no-js .file + .file { margin-top: var(--space-12); }

.file__name { color: var(--text-subtle); }
.file__title {
  margin-top: var(--space-2);
  font-size: var(--h1-size);
  line-height: var(--h1-lh);
  font-weight: 500;
  letter-spacing: var(--h1-track);
}
.file__title:focus-visible { box-shadow: none; outline: none; }
.file__meta { margin-top: var(--space-2); color: var(--text-muted); font-size: var(--body-lg-size); line-height: var(--body-lg-lh); }
.file__cover {
  width: 100%;
  height: auto;
  margin-top: var(--space-6);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-2);
  cursor: zoom-in;
}

/* .md: a typographic page */
.file__content {
  margin-top: var(--space-8);
  color: var(--text-muted);
  font-size: var(--body-lg-size);
  line-height: var(--body-lg-lh);
}
.file__content > * + * { margin-top: var(--space-4); }
.file__content h3 {
  margin-top: var(--space-8);
  color: var(--text);
  font-size: var(--h3-size);
  line-height: var(--h3-lh);
  font-weight: 500;
  letter-spacing: var(--h3-track);
  scroll-margin-top: var(--space-6);
}
.file__content > h3:first-child { margin-top: 0; }
.file__content h4 { color: var(--text); font-size: var(--body-lg-size); font-weight: 500; }
.file__content strong { color: var(--text); font-weight: 500; }
.file__content a:not(.btn) { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-subtle); text-underline-offset: 3px; }
.file__content ul:not([class*="is-style"]),
.file__content ol:not([class*="is-style"]) { padding-left: var(--space-5); }
.file__content li + li { margin-top: var(--space-2); }
.file__content blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--elevation-1);
  color: var(--text);
}
.file__content figure { margin: var(--space-6) 0 0; }
.file__content figcaption { margin-top: var(--space-2); color: var(--text-subtle); font-size: var(--caption-size); line-height: var(--caption-lh); }
.file__content img { width: 100%; height: auto; border-radius: var(--radius-lg); }
.file__content img[data-zoom] { cursor: zoom-in; }

.is-style-ember-metric {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--mono-metric-size);
  line-height: var(--mono-metric-lh);
  letter-spacing: var(--mono-metric-track);
  font-feature-settings: "tnum";
}
.wp-block-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }
.wp-block-column > * + * { margin-top: var(--space-2); }

/* .fig: images full width with soft depth */
.file--fig .file__content img { box-shadow: var(--elevation-2); }

/* .png: gallery grid */
.file__content .wp-block-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.file__content .wp-block-gallery figure { margin: 0; }
.file__content .wp-block-gallery img { aspect-ratio: 4 / 3; object-fit: cover; }

/* .url: preview + live link */
.live-link { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-6) !important; }
.live-link__host { color: var(--text-subtle); }

/* CTA at the end of the case — the one red action on this screen */
.case-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-10);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--elevation-1);
}
.case-cta__q { color: var(--text); font-size: var(--body-lg-size); font-weight: 500; }
.case-cta__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.btn--accent {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent-fill));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: var(--on-accent);
}
.btn--accent:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), var(--glow-accent); }
.btn--accent:active { background: var(--accent-pressed); }
.btn--accent:focus-visible { box-shadow: var(--focus-ring); }

/* Prev / Next */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  box-shadow: inset 0 1px 0 var(--divider);
}
.pager__link { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2); border-radius: var(--radius-md); }
.pager__link:hover { background: var(--hover-fill); }
.pager__link:focus-visible { border-radius: var(--radius-md); }
.pager__link--next { grid-column: 2; align-items: flex-end; text-align: right; }
.pager__label { color: var(--text); font-weight: 500; }
.pager__file { color: var(--text-subtle); }
.pager__link.is-disabled .pager__label { color: var(--text-subtle); font-weight: 400; }

.swipe-counter { display: none; }

/* ON THIS PAGE */
.toc {
  position: sticky;
  top: 0;
  align-self: start;
  padding: var(--space-7) var(--space-4) var(--space-6);
  box-shadow: inset 1px 0 0 var(--divider);
  min-height: 100%;
}
.js .toc__file:not(.is-active) { display: none; }
.toc__label { color: var(--text-subtle); padding: 0 var(--space-3); }
.toc__count { margin-top: 4px; padding: 0 var(--space-3); color: var(--text-muted); }
.toc__list { margin-top: var(--space-3); }
.toc__item {
  display: block;
  padding: 7px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--body-size);
  line-height: 18px;
}
.toc__item:hover { background: var(--hover-fill); color: var(--text); }
.toc__item.is-current { background: var(--surface-raised); box-shadow: var(--elevation-1); color: var(--text); }
.no-js .toc { display: none; }

/* ---------- lightbox ---------- */

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(6, 6, 7, 0.96);
  color: var(--text);
}
.lightbox::backdrop { background: rgba(0, 0, 0, 0.6); }
.lightbox__stage {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
}
.lightbox__stage img {
  max-width: 92vw;
  max-height: 88dvh;
  border-radius: var(--radius-md);
  transform-origin: 0 0;
  transition: transform var(--dur-base) var(--ease-out);
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox.is-zoomed .lightbox__stage { cursor: grab; }
.lightbox.is-dragging .lightbox__stage img { transition: none; cursor: grabbing; }
.lightbox__tools {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  gap: var(--space-2);
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--glass-fill-strong), var(--popover-under);
  box-shadow: var(--glass-rim), var(--elevation-2);
}

/* ---------- tablet: content 720 + 232 rail ---------- */

@media (max-width: 1199px) {
  .viewer__main { padding: var(--space-8) var(--space-6) var(--space-10); }
  .file { max-width: 672px; }
}

/* ---------- mobile: full screen, swipe between files ---------- */

@media (max-width: 767px) {
  .viewer { position: fixed; z-index: 45; }
  .viewer__bar { height: var(--mobilebar-h); padding: 0 var(--space-2) 0 var(--space-4); }
  .viewer__menu { display: inline-grid; margin-left: calc(-1 * var(--space-2)); } /* the drawer stays reachable over the full-screen case */
  .crumbs { flex: 1; justify-content: center; }
  .crumbs > :nth-child(-n + 4) { display: none; } /* only the file name fits */
  .viewer__body { grid-template-columns: minmax(0, 1fr); touch-action: pan-y; }
  .viewer__main { padding: var(--space-6) var(--space-4) var(--space-8); }
  .file__title { font-size: var(--h2-size); line-height: var(--h2-lh); letter-spacing: var(--h2-track); }
  .file__content { margin-top: var(--space-6); }
  .toc { display: none; }
  .swipe-counter { display: block; margin-top: var(--space-4); text-align: center; color: var(--text-subtle); }
  .case-cta { padding: var(--space-5); }
  .case-cta__actions { width: 100%; }
  .case-cta__actions > * { flex: 1; justify-content: center; }
  .file__content .wp-block-gallery { grid-template-columns: minmax(0, 1fr); }
}
