/* ============================================================
   DudeFactory — work index + case study detail pages
   Loads after styles.css and reuses its tokens/components.
   ============================================================ */

/* ---------- Page hero (work index + case details) ---------- */

.page-hero {
  position: relative;
  padding: 172px 0 72px;
  overflow: hidden;
}
.page-hero .hero-bg { position: absolute; inset: 0; pointer-events: none; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 34px;
  transition: color 0.25s, transform 0.25s var(--ease);
}
.back-link:hover { color: var(--accent); transform: translateX(-3px); }
.back-link svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.page-hero .hero-inner { text-align: left; }
.page-title { font-size: clamp(2.4rem, 5.4vw, 4.2rem); margin-bottom: 22px; }
.page-dek {
  max-width: 640px;
  font-size: clamp(1.0625rem, 1.6vw, 1.1875rem);
  color: var(--text-dim);
}

/* ---------- Work index grid ---------- */

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 26px;
  padding-bottom: 128px;
}

.work-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
  transition: transform 0.45s var(--ease), border-color 0.45s var(--ease),
              box-shadow 0.45s var(--ease);
}
.work-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 194, 51, 0.4);
  box-shadow: 0 30px 70px -35px rgba(0, 0, 0, 0.95), 0 0 70px -35px var(--accent-glow);
}

.work-card-preview {
  padding: 34px 34px 0;
  background:
    radial-gradient(ellipse 80% 70% at 50% -10%, rgba(255, 194, 51, 0.07), transparent 70%),
    var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.work-card-preview .mock {
  transform: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 0;
  box-shadow: none;
  padding: 22px;
  gap: 12px;
  transition: transform 0.5s var(--ease);
}
.work-card:hover .work-card-preview .mock { transform: translateY(-5px); }

.work-card-body { padding: 30px 34px 34px; display: flex; flex-direction: column; flex: 1; }
.work-card-body .case-tags { margin: 0 0 14px; }
.work-card-body h2 { font-size: 1.5rem; margin-bottom: 12px; }
.work-card-body p { color: var(--text-dim); font-size: 0.9688rem; flex: 1; }

.work-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 24px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9688rem;
  color: var(--accent);
}
.work-card-cta svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}
.work-card:hover .work-card-cta svg { transform: translateX(4px); }

@media (max-width: 860px) {
  .work-grid { grid-template-columns: 1fr; }
}

/* ---------- Case detail: meta bar ---------- */

.meta-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
  margin-bottom: 0;
}
.meta-cell { padding: 24px 28px; }
.meta-cell + .meta-cell { border-left: 1px solid var(--border); }
.meta-cell dt {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.meta-cell dd { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.meta-cell dd .pulse-dot { display: inline-block; margin-right: 8px; vertical-align: 1px; }

@media (max-width: 860px) {
  .meta-bar { grid-template-columns: 1fr 1fr; }
  .meta-cell:nth-child(3) { border-left: 0; }
  .meta-cell:nth-child(n + 3) { border-top: 1px solid var(--border); }
}

/* ---------- Case detail: sections ---------- */

.case-section { padding: 96px 0 0; }
.case-section:last-of-type { padding-bottom: 128px; }

.case-section .section-head { margin-bottom: 48px; }
.case-section .section-title { font-size: clamp(1.7rem, 3.4vw, 2.5rem); }

.prose {
  max-width: 72ch;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 1.0625rem;
}
.prose strong { color: var(--text); }

/* ---------- Animated system flow ---------- */

.flow {
  max-width: 660px;
  display: flex;
  flex-direction: column;
}

.flow-step {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  padding: 22px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.35s;
}
.flow-step:hover { border-color: rgba(255, 194, 51, 0.35); }

.flow-step .pipe-icon { width: 48px; height: 48px; flex: none; }
.flow-step h4 {
  font-size: 1.0938rem;
  margin-bottom: 5px;
}
.flow-step p { color: var(--text-dim); font-size: 0.9375rem; }

.flow-connector {
  position: relative;
  width: 2px;
  height: 52px;
  margin-left: 50px;
  background-image: linear-gradient(rgba(255, 194, 51, 0.4) 50%, transparent 50%);
  background-size: 2px 10px;
}
.flow-connector i {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(255, 194, 51, 0.55);
  transform: translateX(-50%);
  animation: drip 1.7s linear infinite;
}
@keyframes drip {
  0% { top: -7px; opacity: 0; }
  18% { opacity: 1; }
  82% { opacity: 1; }
  100% { top: calc(100% + 1px); opacity: 0; }
}

/* ---------- Feature cards ---------- */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.feature-card {
  padding: 30px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: transform 0.4s var(--ease), border-color 0.4s var(--ease);
}
.feature-card:hover { transform: translateY(-4px); border-color: rgba(255, 194, 51, 0.35); }
.feature-card .service-icon { width: 46px; height: 46px; margin-bottom: 18px; border-radius: 14px; }
.feature-card .service-icon svg { width: 22px; height: 22px; }
.feature-card h4 { font-size: 1.0938rem; margin-bottom: 9px; }
.feature-card p { color: var(--text-dim); font-size: 0.9188rem; }

@media (max-width: 900px) { .feature-grid { grid-template-columns: 1fr; } }

/* ---------- Live demo loop ---------- */

.demo-wrap {
  display: grid;
  place-items: center;
  padding: 56px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 70% 90% at 50% 110%, rgba(255, 194, 51, 0.07), transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg-raised);
  background-size: 100% 100%, 42px 42px, 42px 42px, 100% 100%;
}
.demo-wrap .mock {
  width: 100%;
  max-width: 560px;
  transform: none;
}
.demo-caption {
  margin-top: 22px;
  font-size: 0.9375rem;
  color: var(--text-faint);
  text-align: center;
}

/* Sequenced appearance — all elements share one 14s clock; each slot
   owns a window inside it, so the loop stays in sync forever. */
.demo .s1, .demo .s2, .demo .s3, .demo .s4, .demo .s5, .demo .s6, .demo .s7 {
  opacity: 0;
  animation-duration: 14s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-out;
}
.demo .s1 { animation-name: slot1; }
.demo .s2 { animation-name: slot2; }
.demo .s3 { animation-name: slot3; }
.demo .s4 { animation-name: slot4; }
.demo .s5 { animation-name: slot5; }
.demo .s6 { animation-name: slot6; }
.demo .s7 { animation-name: slot7; }

@keyframes slot1 { 0%, 2% { opacity: 0; transform: translateY(9px); } 5%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes slot2 { 0%, 12% { opacity: 0; transform: translateY(9px); } 15%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes slot3 { 0%, 24% { opacity: 0; transform: translateY(9px); } 27%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes slot4 { 0%, 38% { opacity: 0; transform: translateY(9px); } 41%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes slot5 { 0%, 52% { opacity: 0; transform: translateY(9px); } 55%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes slot6 { 0%, 66% { opacity: 0; transform: translateY(9px); } 69%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes slot7 { 0%, 79% { opacity: 0; transform: translateY(9px); } 82%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }

/* Funnel bars that fill inside the same 14s clock */
.demo .funnel-bar i { width: 0; animation-duration: 14s; animation-iteration-count: infinite; animation-timing-function: var(--ease); }
.demo .fb1 i { animation-name: fill1; }
.demo .fb2 i { animation-name: fill2; }
.demo .fb3 i { animation-name: fill3; }
@keyframes fill1 { 0%, 27% { width: 0; } 36%, 92% { width: var(--w); } 96%, 100% { width: 0; } }
@keyframes fill2 { 0%, 41% { width: 0; } 50%, 92% { width: var(--w); } 96%, 100% { width: 0; } }
@keyframes fill3 { 0%, 55% { width: 0; } 64%, 92% { width: var(--w); } 96%, 100% { width: 0; } }

/* Status pill swap (logistics) — dim pill dims out as hot pill lights up */
.demo .swap-out { animation: swapout 14s infinite; }
.demo .swap-in { animation: swapin 14s infinite; }
@keyframes swapout { 0%, 38% { opacity: 1; } 44%, 92% { opacity: 0.35; } 96%, 100% { opacity: 1; } }
@keyframes swapin { 0%, 38% { opacity: 0.25; transform: scale(0.96); } 44%, 92% { opacity: 1; transform: none; } 96%, 100% { opacity: 0.25; } }

/* Calendar strip (clinic demo) */
.mock-calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mock-slot {
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
}
.mock-slot strong { display: block; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.mock-slot.taken { opacity: 0.38; text-decoration: line-through; }
.mock-slot.free {
  border-color: rgba(255, 194, 51, 0.55);
  background: var(--accent-glow);
  color: var(--accent);
}
.mock-slot.free strong { color: var(--accent); }

/* ---------- Stat tiles ---------- */

.tile-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.tile {
  padding: 34px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.tile-num {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin-bottom: 10px;
}
.tile p { color: var(--text-dim); font-size: 0.9375rem; }

@media (max-width: 860px) { .tile-row { grid-template-columns: 1fr; } }

/* ---------- Build timeline ---------- */

.timeline { list-style: none; max-width: 720px; }
.timeline li {
  position: relative;
  padding: 0 0 40px 56px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 30px;
  bottom: 2px;
  width: 2px;
  background-image: linear-gradient(rgba(255, 255, 255, 0.12) 50%, transparent 50%);
  background-size: 2px 9px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }

.timeline-dot {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 194, 51, 0.5);
  background: var(--bg-raised);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}
.timeline h4 { font-size: 1.0938rem; margin-bottom: 6px; }
.timeline p { color: var(--text-dim); font-size: 0.9375rem; max-width: 58ch; }

/* ---------- Case CTA + next link ---------- */

.case-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 44px 48px;
  border: 1px solid rgba(255, 194, 51, 0.3);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 60% 120% at 0% 50%, rgba(255, 194, 51, 0.1), transparent 60%),
    var(--bg-card);
}
.case-cta h3 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: 8px; }
.case-cta p { color: var(--text-dim); }
.case-cta-actions { display: flex; flex-wrap: wrap; gap: 14px; }

.next-case {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  padding: 30px 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.35s, transform 0.4s var(--ease);
}
.next-case:hover { border-color: rgba(255, 194, 51, 0.4); transform: translateY(-3px); }
.next-case small {
  display: block;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.next-case strong { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.next-case svg {
  width: 26px; height: 26px; flex: none;
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}
.next-case:hover svg { transform: translateX(5px); }

@media (max-width: 700px) {
  .case-cta, .next-case { padding: 30px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .demo .s1, .demo .s2, .demo .s3, .demo .s4, .demo .s5, .demo .s6, .demo .s7 { opacity: 1; animation: none; }
  .demo .funnel-bar i { width: var(--w); animation: none; }
  .demo .swap-out, .demo .swap-in { animation: none; }
  .flow-connector i { animation: none; opacity: 0; }
}
