/* Challenge pages. Loaded after styles.css, which holds the shared tokens. */

.preview-note {
  background: var(--ink);
  color: var(--ground);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  padding: 0.5rem 1rem;
}

.wide { width: min(100% - 2rem, 72rem); margin-inline: auto; }

/* Opening: the idea as it was sent, and our reply. */
.opening { padding-block: clamp(1.5rem, 5vw, 4rem) clamp(2.5rem, 6vw, 4rem); }

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ground-text);
  font-variant-numeric: tabular-nums;
}
.meta-line a { color: inherit; }

.opening .thread { gap: 1rem; }
.opening .msg--you { max-width: min(100%, 52rem); }
.title-bubble {
  padding: 0.3em 0.55em 0.38em;
  border-radius: 0.5em 0.5em 0.12em 0.5em;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.25rem, 7vw, 4.75rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-wrap: balance;
  transform: rotate(1.25deg);
  transform-origin: 100% 100%;
}
.credit {
  align-self: flex-end;
  margin-top: -0.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ground-text);
}
.opening .msg--ai { max-width: min(100%, 40rem); }
.opening .bubble--lead { margin-top: 0.75rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.btn--outline {
  background: none;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}
.btn--outline:hover { background: var(--ink); color: var(--ground); }
.btn svg { vertical-align: -0.15em; margin-left: 0.35em; }

/* Gallery: one large frame, a strip of thumbnails that swap into it. */
.gallery { padding-bottom: clamp(3rem, 7vw, 5rem); }
.gallery__stage {
  margin: 0;
  border-radius: 1.75rem;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--lift);
}
.gallery__stage .shot { border-radius: 0; }
.gallery__stage figcaption {
  padding: 0.875rem 1.25rem 1rem;
  font-size: 0.9375rem;
  color: var(--paper-text);
}
.gallery__strip {
  display: flex;
  /* No scroller: thumbnails shrink to share the width, so the strip never moves or grows a scrollbar. */
  margin: 1rem 0 0;
  gap: clamp(0.375rem, 1.5vw, 0.75rem);
}
.gallery__thumb {
  flex: 0 1 10rem;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0.875rem;
  overflow: hidden;
  background: none;
  opacity: 0.7;
  transition: opacity 150ms, transform 150ms var(--ease-out);
}
.gallery__thumb:hover { opacity: 1; }
.gallery__thumb[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 3px var(--ink); }
.gallery__thumb:active { transform: scale(0.97); }

/* Placeholder frames standing in for real screenshots. */
.shot {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  border-radius: 0.875rem;
  background: #ece6d6;
  color: var(--paper-text);
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
}
.shot--a { background: #e9e3d2; }
.shot--b { background: #dfe3ff; color: #3b3f6b; }
.shot--c { background: #f6d9d4; color: #6b3b33; }
.shot--d { background: #d9eedf; color: #2f5a3b; }
.gallery__stage .shot { font-size: 1rem; }

/* Body and facts side by side on wide screens. */
.story {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
  padding-bottom: clamp(4rem, 9vw, 6rem);
}
@media (min-width: 62rem) {
  .story { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; }
  .facts { position: sticky; top: 1.5rem; order: 2; }
}

.facts {
  padding: 1.5rem;
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble) var(--r-tail);
  background: var(--paper);
  box-shadow: var(--lift);
}
.facts h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.375rem;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
.facts dl { margin: 0; display: grid; gap: 1.125rem; }
.facts dt {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--paper-text);
  margin-bottom: 0.375rem;
}
.facts dd { margin: 0; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.tag {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--ground);
  font-size: 0.875rem;
  font-weight: 600;
}
.tag--blue { background: var(--blue); color: var(--paper); }
.links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem 0.375rem 0.875rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms, transform 150ms var(--ease-out);
}
.link-pill svg { transition: transform 200ms var(--ease-out); }
.link-pill:hover { background: var(--blue); }
.link-pill:hover svg { transform: translate(2px, -2px); }
.link-pill:active { transform: scale(0.97); }

.prose { max-width: 42rem; }
.prose h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 3.5rem 0 1rem;
}
.prose h3:first-child { margin-top: 0; }
.prose .block + .block, .prose .block + .wrong, .prose .wrong + .block, .prose .block + .media, .prose .media + .block, .prose .block + .gallery--inline, .prose .gallery--inline + .block { margin-top: 2.5rem; }
.prose .block > :first-child { margin-top: 0; }
.prose .payload-richtext > p + p, .prose .payload-richtext > p + ul, .prose .payload-richtext > ul + p { margin-top: 1rem; }
.prose .payload-richtext h3 { margin-top: 2rem; }
.prose .payload-richtext ol { padding-left: 1.25rem; font-size: 1.125rem; line-height: 1.65; }

/* Image or video component, and the inline slider. */
.media { margin: 0; }
.media img, .media video { display: block; width: 100%; height: auto; border-radius: 1.25rem; box-shadow: var(--lift); background: var(--paper); }
.media figcaption { margin-top: 0.625rem; font-size: 0.9375rem; color: var(--paper-text); }
.gallery--inline { padding-bottom: 0; }
.gallery--inline .gallery__stage { border-radius: 1.25rem; }
.gallery--inline .gallery__stage figcaption:empty { display: none; }
.prose p, .prose ul { font-size: 1.125rem; line-height: 1.65; }
.prose p + p, .prose p + ul, .prose ul + p { margin-top: 1rem; }
.prose ul { padding-left: 1.25rem; list-style: disc; }
.prose li + li { margin-top: 0.375rem; }
.prose a { color: var(--blue); font-weight: 600; text-underline-offset: 0.2em; }

/* Progress: dated sessions on a rail. */
.log { margin-top: 1.5rem; display: grid; gap: 0; }
.log li {
  position: relative;
  list-style: none;
  padding: 0 0 1.5rem 2rem;
  border-left: 2px solid var(--ink);
  margin-left: 0.4375rem;
}
.log li:last-child { border-left-color: transparent; padding-bottom: 0; }
.log li::before {
  content: "";
  position: absolute;
  left: -0.5625rem;
  top: 0.3rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--ground);
  box-shadow: inset 0 0 0 3px var(--ink);
}
.log li:last-child::before { background: var(--ink); }
.log time {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ground-text);
  font-variant-numeric: tabular-nums;
}
.log p { margin-top: 0.125rem; }

/* Prompts: the real exchange, as a thread, each prompt copyable. */
.prose .thread { margin-top: 1.5rem; gap: 0.625rem; }
.prompt { position: relative; }
.prompt .bubble { padding-right: 3.25rem; white-space: pre-wrap; font-size: 1rem; line-height: 1.55; }
.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.16);
  color: var(--paper);
  transition: background-color 150ms;
}
.copy:hover { background: rgb(255 255 255 / 0.3); }
.copy .done { display: none; }
.copy.is-done .idle { display: none; }
.copy.is-done .done { display: block; }
.prompt-note {
  align-self: flex-end;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ground-text);
  margin-bottom: 0.75rem;
}
.prose .thread .bubble { font-size: 1rem; }

/* What the AI got wrong: our own red pen. */
.wrong { margin-top: 1.5rem; display: grid; gap: 0.75rem; }
.wrong li {
  list-style: none;
  padding: 1rem 1.25rem;
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble) var(--r-tail);
  background: var(--paper);
  box-shadow: var(--lift);
}
.wrong strong { display: block; color: var(--error); }
.wrong .payload-richtext p + p { margin-top: 0.5rem; }

/* Next and previous challenges. */
.pager {
  display: grid;
  gap: 1rem;
  padding-bottom: clamp(4rem, 9vw, 6rem);
}
@media (min-width: 48rem) { .pager { grid-template-columns: 1fr 1fr; } }
.pager a {
  display: block;
  padding: 1.25rem 1.5rem;
  border-radius: var(--r-bubble);
  color: var(--ink);
  text-decoration: none;
  box-shadow: inset 0 0 0 2px var(--ink);
  transition: background-color 150ms, color 150ms;
}
.pager a:hover { background: var(--ink); color: var(--ground); }
.pager a:last-child { text-align: right; }
.pager span { display: block; font-size: 0.875rem; font-weight: 600; opacity: 0.75; }
.pager strong {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--display);
  font-size: 1.375rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

/* Two builds: a sticky switcher, one panel per person. */
.switcher-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-block: 0.75rem;
  background: rgb(255 208 46 / 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.switcher-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.switcher-label { font-family: var(--display); font-weight: 700; font-size: 1.125rem; }
.switcher {
  display: inline-flex;
  padding: 0.3rem;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--lift);
}
.switcher__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem 0.45rem 0.45rem;
  border: 0;
  border-radius: 999px;
  background: none;
  font-weight: 600;
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out);
}
.switcher__tab:hover { background: #f1ecdf; }
.switcher__tab[aria-selected="true"] { background: var(--ink); color: var(--paper); }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.875rem;
  line-height: 1;
}
.avatar--chris { background: var(--blue); color: var(--paper); }
.avatar--rahul { background: #c8461f; color: var(--paper); }

.build__head { padding-block: clamp(2rem, 5vw, 3rem) clamp(1.5rem, 4vw, 2.5rem); }
.build__title {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.75rem, 4.5vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.build__title .avatar { width: 1.15em; height: 1.15em; font-size: 0.75em; margin-top: 0.11em; } /* centred on the first line's capitals */
.build.is-entering { animation: build-in 380ms var(--ease-out); }
@keyframes build-in { from { opacity: 0; transform: translateY(0.75rem); } }

/* Side by side comparison. */
.compare { padding-bottom: clamp(4rem, 9vw, 6rem); }
.compare__title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.25rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}
.compare__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border-radius: 1.5rem;
  box-shadow: var(--lift);
  overflow: hidden;
  font-size: 1rem;
  table-layout: fixed;
}
.compare__table th, .compare__table td {
  padding: 1rem 1.25rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #ece6d6;
}
.compare__table tr:last-child > * { border-bottom: 0; }
.compare__table thead th { font-family: var(--display); font-size: 1.25rem; font-weight: 800; }
.compare__table thead th .avatar { margin-right: 0.5rem; vertical-align: -0.3em; }
.compare__table tbody th { width: 28%; font-size: 0.875rem; font-weight: 600; color: var(--paper-text); }
@media (max-width: 40rem) {
  .compare__table th, .compare__table td { padding: 0.75rem; font-size: 0.9375rem; }
  .compare__table tbody th { width: 30%; font-size: 0.8125rem; }
  .switcher-label { display: none; }
  .switcher { width: 100%; }
  .switcher__tab { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .build.is-entering { animation: none; } }

/* Real screenshots show whole, at their own shape; only thumbnails are cropped to the 16:10 frame. */
.shot--photo { display: block; width: 100%; height: auto; aspect-ratio: auto; background: var(--paper); }
.gallery__thumb .shot--photo { aspect-ratio: 16 / 10; object-fit: cover; }
/* A slider's frame takes the first image's shape (--ratio); the rest fill it. */
.is-fixed { aspect-ratio: var(--ratio); }
.is-fixed > * { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; }
.compare__scroll { overflow-x: auto; border-radius: 1.5rem; }

/* Lightbox: screenshots open whole over a dark veil (public/challenge.js). */
img[data-zoom] { cursor: zoom-in; }
img[data-zoom]:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(3.5rem, 6vw, 4.5rem) clamp(1rem, 6vw, 5.5rem);
  border: 0;
  background: none;
  cursor: zoom-out;
}
.lightbox[open] { display: grid; place-items: center; animation: lightbox-in 220ms var(--ease-out); }
.lightbox::backdrop { background: rgb(28 19 38 / 0.92); }
.lightbox__figure { display: grid; justify-items: center; gap: 0.875rem; margin: 0; max-height: 100%; }
.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 2 * clamp(3.5rem, 6vw, 4.5rem) - 2.5rem);
  width: auto;
  height: auto;
  border-radius: 0.875rem;
  background: var(--paper);
  cursor: default;
}
.lightbox__caption { color: var(--paper); font-size: 0.9375rem; text-align: center; max-width: 60ch; }
.lightbox__btn {
  position: fixed;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.14);
  color: var(--paper);
  cursor: pointer;
  transition: background-color 150ms;
}
.lightbox__btn:hover { background: rgb(255 255 255 / 0.28); }
.lightbox__btn:focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev, .lightbox__next { top: 50%; translate: 0 -50%; }
.lightbox__prev { left: 1rem; }
.lightbox__next { right: 1rem; }
.lightbox.is-single .lightbox__prev, .lightbox.is-single .lightbox__next { display: none; }
@media (max-width: 40rem) {
  .lightbox__prev, .lightbox__next { top: auto; bottom: 1rem; translate: none; }
}
@keyframes lightbox-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .lightbox[open] { animation: none; } }
