/* Password gate for locked case studies (assets/js/locked-case.js).
   The gate sits in the hero's own box: same width, radius and position as the
   case's real hero, so unlocking reads as the frosted cover clearing rather
   than as a page change. The card always sits on the cover's colour, so its
   palette is fixed light-on-glass in both site themes. */

.lk {
  --lk-ink: #fff;
  --lk-soft: rgba(255, 255, 255, 0.74);
  --lk-faint: rgba(255, 255, 255, 0.56);
  --lk-line: rgba(255, 255, 255, 0.22);
  --lk-glass: rgba(14, 12, 18, 0.38);
  --lk-error: #ffc2cd;
}

.lk-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: clamp(16px, 4vw, 48px);
  isolation: isolate;
}

.cp-hero.lk-hero img.lk-cover {
  position: absolute;
  inset: 0;
  z-index: -2;
  transform: scale(1.02);
  transition: transform 1.1s var(--ease), filter 1.1s var(--ease);
}

/* Film grain over the frosted cover: it keeps the blur from reading as a
   low-resolution image and gives the glass something to refract. */
.lk-grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.lk-card {
  width: min(520px, 100%);
  padding: clamp(28px, 3.4vw, 44px);
  border-radius: 28px;
  color: var(--lk-ink);
  background: var(--lk-glass);
  border: 1px solid var(--lk-line);
  box-shadow: 0 40px 80px -36px rgba(8, 4, 20, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  backdrop-filter: blur(28px) saturate(150%);
  animation: lk-in 0.8s var(--ease) 0.12s both;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease), visibility 0s;
}

@keyframes lk-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.lk-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Pixelify Sans', monospace;
  font-size: 13px;
  color: var(--lk-soft);
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--lk-line);
  border-radius: 999px;
}

.lk-eyebrow svg,
.lk-eye svg,
.lk-go svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lk-eyebrow svg { width: 14px; height: 14px; }

.lk-title {
  margin-top: 22px;
  font-size: clamp(42px, 5.4vw, 68px);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.lk-tagline {
  margin-top: 14px;
  font-size: clamp(15px, 1.25vw, 17px);
  line-height: 1.45;
  color: var(--lk-ink);
  text-wrap: balance;
}

.lk-note {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--lk-soft);
}

.lk-form { margin-top: 28px; }

.lk-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.lk-field {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 58px;
  padding: 0 7px 0 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--lk-line);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.lk-field:focus-within {
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.lk-field input {
  flex: 1;
  /* An <input> brings ~20ch of intrinsic width; left alone it sets the card's
     min-content and pushes it past a phone's edge. */
  width: 0;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--lk-ink);
  font: inherit;
  font-size: 16px;            /* 16px or iOS zooms the page on focus */
  letter-spacing: 0.04em;
}

.lk-field input::placeholder { color: var(--lk-faint); letter-spacing: 0; }

.lk-eye,
.lk-go {
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.lk-eye {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  color: var(--lk-soft);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.lk-eye:hover,
.lk-eye[aria-pressed="true"] { color: var(--lk-ink); background: rgba(255, 255, 255, 0.1); }

.lk-go {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff;
  color: #0c0119;
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}

.lk-go:hover { transform: translateX(2px); }
.lk-go:active { transform: scale(0.96); }
.lk-go:disabled { cursor: progress; }

.lk-eye:focus-visible,
.lk-go:focus-visible,
.lk-ask:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* Deriving the key takes a beat (600k PBKDF2 rounds), the arrow becomes a ring. */
.lk.is-busy .lk-go svg { opacity: 0; }
.lk.is-busy .lk-go::after {
  content: '';
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  border: 2px solid rgba(12, 1, 25, 0.18);
  border-top-color: #0c0119;
  animation: lk-spin 0.7s linear infinite;
}

@keyframes lk-spin { to { transform: rotate(360deg); } }

.lk-msg {
  min-height: 20px;
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--lk-soft);
}

.lk-msg[data-tone="error"] { color: var(--lk-error); }

.lk.is-wrong .lk-field {
  border-color: rgba(255, 194, 205, 0.7);
  animation: lk-shake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes lk-shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

.lk-ask {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--lk-ink);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.4);
  text-underline-offset: 4px;
  transition: text-decoration-color 0.2s var(--ease);
}

.lk-ask:hover { text-decoration-color: #fff; }

/* Returning in the same tab: the stored key is tried first, so the card stays
   out of sight instead of flashing up and away. */
.lk.is-resuming .lk-card { visibility: hidden; animation: none; opacity: 0; }

/* Unlocked: the card lifts away and the frosted cover leans in, the real hero
   takes its place in the same box on the next frame. */
.lk.is-open .lk-card { opacity: 0; transform: translateY(-10px) scale(0.98); }
.lk.is-open .lk-cover { transform: scale(1.08); filter: saturate(1.25) brightness(1.06); }

/* On a phone the hero's wide ratio is far too short for the card, so the
   frosted cover simply grows to hold it. */
@media (max-width: 720px) {
  .cp-hero.lk-hero { aspect-ratio: auto !important; min-height: 78svh; border-radius: 22px; }
  .lk-card { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .lk-card, .lk.is-wrong .lk-field, .lk.is-busy .lk-go::after { animation: none; }
  .lk-card, .cp-hero.lk-hero img.lk-cover { transition: none; }
}

/* ---------- inside an unlocked case ---------- */

/* Images still decrypting show the tile's own gradient, then fade in. */
.cp-media img,
.cp-hero img { transition: opacity 0.6s var(--ease); }
img[data-lk="pending"] { opacity: 0; }

/* "In development", the status line in the overview meta. */
.cp-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.cp-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #E9B949;
  box-shadow: 0 0 0 4px rgba(233, 185, 73, 0.18);
  animation: cp-status-pulse 2.4s ease-in-out infinite;
}

@keyframes cp-status-pulse {
  50% { box-shadow: 0 0 0 7px rgba(233, 185, 73, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .cp-status::before { animation: none; }
}
