/* Protected case study modal (js/protected-access.js) + card indicator.
   Built on the shared tokens (tokens.css) so Light and Dark both follow the theme. */

html.pa-open, html.pa-open body { overflow: hidden; }

.pa {
  position: fixed;
  inset: 0;
  z-index: 3500;                       /* above header/navigator/lightbox, below the one-time intro */
  display: grid;
  place-items: center;
  padding: 16px;
  font-family: "Montserrat", sans-serif;
  --pa-vh: 100dvh;
}
.pa__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 30, 42, 0.5);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .22s var(--ease-standard, ease);
}
.pa.is-open .pa__backdrop { opacity: 1; }

.pa__dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(var(--pa-vh) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(24px, 4vw, 36px);
  background: var(--surface, #fff);
  color: var(--ink-800, #1f1f1f);
  border: 1px solid var(--line-soft, rgba(20, 19, 19, .08));
  border-radius: var(--radius-xl, 24px);
  box-shadow: var(--shadow-lg, 0 16px 44px rgba(0, 0, 0, .14));
  text-align: left;
  opacity: 0;
  transform: translateY(14px) scale(.97);
  transition: opacity .24s var(--ease-soft, ease), transform .24s var(--ease-soft, ease);
}
.pa.is-open .pa__dialog { opacity: 1; transform: none; }
.pa__dialog::before {                  /* the portfolio's small gradient rule */
  content: "";
  position: absolute; top: -1px; left: clamp(24px, 4vw, 36px);
  width: 56px; height: 3px; border-radius: 999px;
  background: var(--grad-main, linear-gradient(270deg, #398fba 6%, #ff6c63 51%));
}
.pa__dialog.is-shake { animation: paShake .38s var(--ease-standard, ease); }
@keyframes paShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.pa__close {
  position: absolute; top: 14px; right: 14px;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-500, #6b6a6a);
  cursor: pointer;
  transition: background-color .18s, color .18s;
}
.pa__close svg { width: 18px; height: 18px; }

.pa__lock {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin-bottom: 16px;
  border-radius: var(--radius-md, 14px);
  background: var(--surface-soft, #fafafa);
  border: 1px solid var(--line-soft, rgba(20, 19, 19, .08));
  color: var(--blue-deep, #2b6f91);
}
.pa__lock svg { width: 26px; height: 26px; }

.pa__project {
  margin: 0 0 8px;
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--blue-deep, #2b6f91);
}
.pa__title { margin: 0 0 10px; font-size: clamp(1.4rem, 3.4vw, 1.7rem); line-height: 1.2; font-weight: 800; color: var(--ink-900, #141313); }
.pa__text { margin: 0 0 22px; font-size: .95rem; line-height: 1.6; color: var(--ink-600, #4b4a4a); }

.pa__label { display: block; margin-bottom: 8px; font-size: .8rem; font-weight: 700; color: var(--ink-700, #383737); }
.pa__field {
  display: flex; align-items: center;
  min-height: 52px;
  background: var(--surface-soft, #fafafa);
  border: 1.5px solid var(--line-med, rgba(43, 111, 145, .2));
  border-radius: var(--radius-md, 14px);
  transition: border-color .18s, box-shadow .18s, background-color .18s;
}
.pa__field:focus-within { background: var(--surface, #fff); border-color: var(--blue, #398fba); box-shadow: 0 0 0 3px rgba(57, 143, 186, .25); }
.pa__input {
  flex: 1 1 auto; min-width: 0;
  height: 50px; padding: 0 4px 0 16px;
  font: inherit; font-size: 1rem;                 /* 16px: no iOS zoom */
  color: var(--ink-900, #141313);
  background: transparent; border: 0; outline: 0;
}
.pa__input::placeholder { color: var(--ink-500, #6b6a6a); opacity: 1; }
.pa__field:has(.pa__input[aria-invalid="true"]) { border-color: #c4352c; }
.pa__toggle {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 46px; height: 46px; margin-right: 3px;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--ink-600, #4b4a4a); cursor: pointer;
  transition: background-color .18s, color .18s;
}
.pa__toggle svg { width: 20px; height: 20px; }

.pa__error { margin: 10px 2px 0; font-size: .85rem; font-weight: 600; line-height: 1.45; color: #b3261e; }
.pa__submit { width: 100%; margin-top: 18px; }

.pa__request {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px;
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--line-soft, rgba(20, 19, 19, .08));
  font-size: .85rem; color: var(--ink-500, #6b6a6a);
}
.pa__request-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px;
  font-weight: 700; color: var(--blue-deep, #2b6f91); text-decoration: none;
}
.pa__request-link svg { width: 16px; height: 16px; }

.pa__close:focus-visible, .pa__toggle:focus-visible, .pa__request-link:focus-visible, .pa__submit:focus-visible {
  outline: 3px solid var(--blue, #398fba); outline-offset: 3px;
}
@media (hover: hover) {
  .pa__close:hover, .pa__toggle:hover { background: var(--surface-sunken, #f4f5f7); color: var(--ink-900, #141313); }
  .pa__request-link:hover { text-decoration: underline; text-underline-offset: 4px; }
}

/* phones: bottom sheet, keyboard-aware, safe-area padding */
@media (max-width: 600px) {
  .pa { align-items: end; padding: 0; }
  .pa__dialog {
    width: 100%;
    max-height: calc(var(--pa-vh) - 8px);
    padding: 26px 20px calc(22px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    transform: translateY(40px);
  }
  .pa__dialog::before { left: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .pa__backdrop, .pa__dialog { transition: none; transform: none; }
  .pa__dialog.is-shake { animation: none; }
}

/* "Protected Case Study" indicator on project cards: informative, not disabled */
.mw-card__badge--lock { display: inline-flex; align-items: center; gap: 6px; }
.mw-card__badge--lock svg { width: 13px; height: 13px; flex: 0 0 13px; }

/* hide everything but the modal while a protected page is still locked */
html.needs-case-gate .ftx,
html.needs-case-gate .cs-pn,
html.needs-case-gate .csn,
html.needs-case-gate #protectedSite { display: none !important; }

/* ---- Dark mode refinements (tokens already remap surfaces and inks) ---- */
html[data-theme="dark"] .pa__backdrop { background: rgba(2, 8, 14, 0.66); }
html[data-theme="dark"] .pa__dialog { background: var(--surface-elevated, #1a2c3a); border-color: var(--line-soft); }
html[data-theme="dark"] .pa__lock { background: var(--bg-secondary, #0f1d29); color: var(--blue-deep); }
html[data-theme="dark"] .pa__field { background: var(--bg-secondary, #0f1d29); }
html[data-theme="dark"] .pa__field:focus-within { background: var(--surface, #14232f); box-shadow: 0 0 0 3px rgba(143, 205, 238, .22); }
html[data-theme="dark"] .pa__field:has(.pa__input[aria-invalid="true"]) { border-color: #ff8f87; }
html[data-theme="dark"] .pa__error { color: #ff9b94; }
