/* Products page — product blocks and their composed "stage" visuals.
   Default styles are the finished state (no-JS, reduced motion, crawlers).
   js/products.js adds .is-armed (start state), then .is-playing when the stage scrolls into view. */

.project {
  margin-bottom: 80px;
}

.project__link {
  display: block;
}

.project__index {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  margin-bottom: 24px;
}

.project__lead {
  font-size: 20px;
  font-weight: 700;
  line-height: 28px;
  color: var(--color-text-dim);
}

.project__tags {
  margin-top: 24px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.project__cta {
  margin-top: 32px;
  font-size: 16px;
}

.project__cta-link {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--color-link-underline);
  transition: text-decoration-color 0.2s ease;
}

.project__link:hover .project__cta-link {
  text-decoration-color: var(--color-link-underline-hover);
}

.project__note {
  margin-left: 12px;
  font-size: 14px;
  color: var(--color-text-dim);
}

.project__link:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 8px;
}

/* ---------- Stage: same width as the text column ---------- */

.stage {
  --ink: #111111;
  --ink-soft: rgba(0, 0, 0, 0.62);
  --ink-mute: rgba(0, 0, 0, 0.42);
  --red: #e5484d;
  --red-ink: #c0353b;
  --green: #1f8a5b;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: relative;
  margin-bottom: 48px;
  padding: 40px 40px 64px;
  background: #f4f4f3;
  color: var(--ink);
  overflow: hidden;
  transition: background-color 0.4s ease;
}

.project__link:hover .stage {
  background: #efefed;
}

.stage__brand {
  position: absolute;
  right: clamp(20px, 3vw, 32px);
  bottom: clamp(18px, 3vw, 28px);
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.5;
}

.stage__brand img {
  height: 20px;
  width: auto;
}

/* Same lockup as the Samsyn page header: logo | tagline */
.stage__tagline {
  padding-left: 12px;
  border-left: 1px solid rgba(0, 0, 0, 0.35);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  /* The logo's S mark makes the image taller than the word "Samsyn"; centre on the word instead */
  position: relative;
  top: 2px;
}

/* ---------- Samsyn composition ---------- */

.stage__flow {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.s-card {
  width: 82%;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.28);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.s-card--2 {
  margin-left: 9%;
}

.s-card--3 {
  margin-left: 18%;
}

.s-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.s-title {
  font-size: 14px;
  font-weight: 700;
}

.s-meta,
.s-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.s-label {
  margin-bottom: 10px;
}

.s-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* Name → [PERSON_01]: both states stacked in one cell */
.s-name {
  display: inline-grid;
  vertical-align: bottom;
}

.s-name > * {
  grid-area: 1 / 1;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.s-name__raw {
  align-self: center;
  width: 6.5em;
  height: 0.85em;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.22);
  filter: blur(1.5px);
  opacity: 0;
}

.s-name__id {
  background: #fff3c4;
  color: var(--ink);
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
}

/* The sentence the observation quotes */
.s-src {
  background-image: linear-gradient(rgba(229, 72, 77, 0.12), rgba(229, 72, 77, 0.12));
  border-radius: 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transition: background-size 0.7s var(--ease);
}

.s-flag {
  font-size: 15px;
  font-weight: 700;
  color: var(--red-ink);
}

.s-quote {
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.5;
  font-style: italic;
  color: var(--ink-soft);
}

.s-ref {
  font-style: normal;
  font-size: 10px;
  color: #2a6fdb;
}

.s-risk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
}

.s-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  flex: 0 0 auto;
}

.s-status {
  display: grid;
  margin-top: 6px;
  font-size: 13px;
}

.s-status > * {
  grid-area: 1 / 1;
  transition: opacity 0.3s ease;
}

.s-status__wait {
  color: var(--ink-mute);
  opacity: 0;
}

.s-status__done {
  color: var(--green);
  font-weight: 700;
}

.s-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.s-btn {
  position: relative;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #ffffff;
}

.s-btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.s-pointer {
  position: absolute;
  right: 4px;
  bottom: -14px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Directory composition ---------- */

.stage--directory {
  padding-bottom: 40px;
}

.d-panel {
  max-width: 560px;
  margin: 0 auto;
}

.d-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.28);
}

.d-search__icon {
  color: var(--ink-mute);
  font-weight: 400;
}

.d-search__query {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  max-width: 10ch;
}

.d-caret {
  width: 2px;
  height: 1.1em;
  background: var(--ink);
  margin-left: -8px;
  animation: d-blink 1s steps(1) infinite;
}

@keyframes d-blink {
  50% { opacity: 0; }
}

.d-results {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 12px;
  overflow: hidden;
}

.d-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.d-row:last-child {
  border-bottom: none;
}

.d-role {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

/* Name and contact details stay abstract — no invented people */
.d-bar {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.1);
}

.d-bar + .d-bar {
  margin-top: 6px;
}

.d-bar--w1 { width: 150px; }
.d-bar--w2 { width: 110px; }
.d-bar--w3 { width: 180px; }

.d-badge {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  background: rgba(31, 138, 91, 0.1);
  padding: 5px 10px;
  border-radius: 999px;
}

/* ---------- Armed: start state before playing ---------- */

.stage.is-arming *,
.stage.is-arming *::before {
  transition: none !important;
}

/* The case note is already there while waiting, so the panel never looks empty */
.stage.is-armed .s-card--2,
.stage.is-armed .s-card--3 {
  opacity: 0;
  transform: translateY(18px);
}

.stage.is-armed .s-name__raw { opacity: 1; }
.stage.is-armed .s-name__id { opacity: 0; filter: blur(4px); }
.stage.is-armed .s-src { background-size: 0% 100%; }
.stage.is-armed .s-status__wait { opacity: 1; }
.stage.is-armed .s-status__done { opacity: 0; }

.stage.is-armed .d-search__query { max-width: 0; }
.stage.is-armed .d-row {
  opacity: 0;
  transform: translateY(12px);
}

/* ---------- Playing: timeline (~4s, runs once) ---------- */

.stage.is-playing .s-card--1 { transition-delay: 0s; }
.stage.is-playing .s-name > * { transition-delay: 0.7s; }
.stage.is-playing .s-src { transition-delay: 1.3s; }
.stage.is-playing .s-card--2 { transition-delay: 1.8s; }
.stage.is-playing .s-card--3 { transition-delay: 2.5s; }
.stage.is-playing .s-status > * { transition-delay: 3.9s; }

.stage.is-playing .s-pointer {
  animation: s-pointer 1.5s var(--ease) 3.1s both;
}

.stage.is-playing .s-btn--primary {
  animation: s-press 0.3s ease 3.75s both;
}

@keyframes s-pointer {
  0%   { opacity: 0; transform: translate(46px, 34px); }
  45%  { opacity: 1; transform: translate(0, 0); }
  55%  { transform: translate(0, 0) scale(0.88); }
  65%  { transform: translate(0, 0) scale(1); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translate(0, 0); }
}

@keyframes s-press {
  0%   { transform: scale(1); }
  50%  { transform: scale(0.94); background: #333333; }
  100% { transform: scale(1); }
}

.stage.is-playing .d-search__query { animation: d-type 0.9s steps(10) 0.2s both; }

@keyframes d-type {
  from { max-width: 0; }
  to   { max-width: 10ch; }
}
.stage.is-playing .d-row:nth-child(1) { transition-delay: 1.3s; }
.stage.is-playing .d-row:nth-child(2) { transition-delay: 1.5s; }
.stage.is-playing .d-row:nth-child(3) { transition-delay: 1.7s; }

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .project {
    margin-bottom: 48px;
  }

  .stage {
    margin-bottom: 32px;
    padding: 20px 16px 56px;
  }

  .stage--directory {
    padding-bottom: 20px;
  }

  .s-card {
    width: 92%;
    padding: 16px 18px;
  }

  .s-card--2 { margin-left: 4%; }
  .s-card--3 { margin-left: 8%; }

  .s-text { font-size: 14px; }

  .project__lead {
    font-size: 18px;
    line-height: 26px;
  }

  .project__tags {
    font-size: 12px;
  }

  .d-bar--w3 { width: 130px; }
}

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