/* ==========================================================================
   case.css: case-study panel (a <dialog> that slides in) and the buttons,
   links and rows that open it
   ========================================================================== */

html.case-open {
  overflow: hidden;
}

/* ---------- Panel ---------- */
.case {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--white);
}
/* One cell the size of the screen, so the panel's height is fixed and it scrolls inside */
.case[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
}
.case::backdrop {
  background: transparent;
}
.case-overlay {
  grid-area: 1 / 1;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.45s var(--ease-soft);
}
.case-panel {
  position: relative;
  z-index: 1; /* above the blurred overlay, which forms its own layer */
  grid-area: 1 / 1;
  justify-self: end;
  display: flex;
  flex-direction: column;
  width: min(900px, 100%);
  height: 100%;
  border-left: 1px solid var(--edge);
  border-radius: 28px 0 0 28px;
  background: var(--ink);
  box-shadow: -40px 0 80px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: translateX(6%);
  transition:
    transform 0.6s var(--ease),
    opacity 0.45s var(--ease-soft);
}
.case.show .case-overlay {
  opacity: 1;
}
.case.show .case-panel {
  opacity: 1;
  transform: none;
}

.case-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1.25rem, 4vw, 3rem);
  border-bottom: 1px solid var(--edge);
}
.case-count {
  margin-left: 0.5rem;
  color: var(--white);
}
.case-nav {
  display: flex;
  gap: 0.5rem;
}
.case-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #333;
  border-radius: 50%;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  transition:
    background-color 0.25s,
    border-color 0.25s,
    color 0.25s;
}
.case-icon:hover {
  border-color: var(--white);
  background: var(--white);
  color: var(--black);
}
.case-icon svg {
  width: 16px;
  height: 16px;
}
.case-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.75rem, 4vw, 3rem) clamp(1.25rem, 4vw, 3rem) 2.5rem;
}

/* Sections rise in one after another each time a case study opens */
.case.show .case-body > * {
  animation: case-in 0.7s var(--ease) both;
  animation-delay: calc(0.12s + var(--k, 0) * 0.06s);
}
@keyframes case-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

/* ---------- Case study content ---------- */
.case-head h2 {
  margin-top: 0.6rem;
  font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.045em;
}
.case-lede {
  max-width: 52ch;
  margin-top: 1rem;
  color: var(--soft);
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  line-height: 1.55;
}
.case-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1px;
  margin: 1.75rem 0 0;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--edge);
}
.case-meta div {
  padding: 0.85rem 1rem;
  background: var(--raise);
}
.case-meta dt {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--grey);
}
.case-meta dd {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.case-shot {
  margin-top: 2rem;
  overflow: hidden;
  border: 1px solid #1f1f1f;
  border-radius: var(--radius-lg);
  background: #111;
}
.case-shot img {
  width: 100%;
  height: auto;
}
.case-shots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.case-shots .case-shot {
  margin-top: 0;
}
.case-shots img {
  height: 100%;
  aspect-ratio: 14 / 9;
  object-fit: cover;
  object-position: top;
}

/* Projects without screenshots reuse their preview from the page */
.case-visual {
  display: grid;
  place-items: center;
  margin-top: 2rem;
  padding: clamp(1.75rem, 5vw, 3.5rem) 1rem;
  overflow: hidden;
  border: 1px solid #1b1b1b;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 0%, #1a1a1a, #0e0e0e 70%);
}
.case-visual .mq-ui {
  flex: none;
  width: 300px;
  min-height: 150px;
  zoom: 1.55;
}
.case-visual .mq-ui.phone {
  width: 140px;
}
.case-visual .win,
.case-visual .tag-scene {
  width: min(100%, 470px);
}

.case-block {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 0.75rem 2rem;
  margin-top: 2.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--edge);
}
.case-block h3 {
  padding-top: 0.3rem;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--grey);
}
.case-block p {
  max-width: 60ch;
  color: var(--soft);
  line-height: 1.7;
}
.case-block p + p {
  margin-top: 1rem;
}
.case-list {
  display: grid;
  gap: 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: feature;
}
.case-list li {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  counter-increment: feature;
}
.case-list li::before {
  content: counter(feature, decimal-leading-zero);
  padding-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--grey);
}
.case-list strong {
  font-weight: 600;
  color: var(--white);
}
.case-list span {
  grid-column: 2;
  margin-top: 0.2rem;
  color: var(--grey);
  line-height: 1.6;
}

.case-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--edge);
}
.case-next {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--white);
  font: 600 clamp(1.5rem, 3.2vw, 2.4rem) / 1.1 var(--sans);
  letter-spacing: -0.035em;
  text-align: left;
  cursor: pointer;
}
.case-next svg {
  flex: none;
  width: 0.8em;
  height: 0.8em;
  transition: transform 0.4s var(--ease);
}
.case-next:hover svg {
  transform: translateX(6px);
}

/* ---------- Triggers on the page ---------- */
.pcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.case-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.3rem;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  font: 600 0.75rem / 1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.3s,
    color 0.3s;
}
.case-btn:hover {
  background: transparent;
  color: var(--white);
}
.case-btn svg {
  width: 1.1em;
  height: 1.1em;
}
.case-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 0 0 0.2rem;
  border: 0;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  color: var(--white);
  font: 500 0.92rem / 1.2 var(--sans);
  cursor: pointer;
  transition: background-size 0.45s var(--ease);
}
.case-link:hover {
  background-position: 100% 100%;
  background-size: 0 1px;
}

/* Whole rows in "Everything else" open their case study */
.index li {
  position: relative;
  padding-right: 2.25rem;
}
.index li::after {
  content: '↗';
  position: absolute;
  top: 1.15rem;
  right: 0.6rem;
  color: var(--grey);
  transition:
    color 0.3s,
    transform 0.3s var(--ease);
}
.index li:hover::after {
  color: var(--white);
  transform: translate(2px, -2px);
}
.case-row {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.case-row:focus-visible {
  outline-offset: -2px;
}

/* ---------- Phones: panel rises from the bottom ---------- */
@media (max-width: 640px) {
  .case-panel {
    align-self: end;
    width: 100%;
    height: calc(100% - 2.5rem);
    border-top: 1px solid var(--edge);
    border-left: 0;
    border-radius: 22px 22px 0 0;
    transform: translateY(8%);
  }
  .case-block {
    grid-template-columns: 1fr;
  }
  .case-shots {
    grid-template-columns: 1fr;
  }
  .case-visual .mq-ui {
    zoom: 1.15;
  }
}
