/* Resources library and gated resource pages.
   Page-family styles, kept here rather than in site.css until something outside
   /resources/ needs them. Shared tokens come from /assets/site.css. */

/* ---------- Library index ---------- */

.library-hero {
  padding: 68px 0 0;
  max-width: 700px;
}
.library-hero h1 {
  font-size: clamp(36px, 5vw, 54px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -1.2px;
}
.library-hero .lede {
  max-width: 58ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17.5px;
}

.filters {
  display: flex;
  align-items: baseline;
  gap: 14px 18px;
  flex-wrap: wrap;
  margin-top: 40px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}
.filters-label {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}
.filter-set {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter {
  padding: 6px 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}
.filter:hover {
  color: var(--ink);
  border-color: rgba(0, 200, 140, 0.4);
}
.filter[aria-pressed="true"] {
  color: var(--ground);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
/* Without JS every card is shown, so a control that cannot filter is a lie. */
html:not(.js) .filters { display: none; }

.result-count {
  margin: 20px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.4px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 26px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}
.card-grid:empty { display: none; }

.resource-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  background: linear-gradient(165deg, var(--panel-2) 0%, var(--panel) 60%, #09120C 100%);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.resource-card:hover {
  border-color: rgba(0, 200, 140, 0.42);
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow:
    0 22px 60px -38px rgba(0, 200, 140, 0.5),
    0 18px 50px -30px rgba(0, 0, 0, 0.85);
}
/* An explicit height rather than aspect-ratio: the card is a column flex
   container, so the image's flex base size comes from its intrinsic height and
   an aspect-ratio would never get a chance to apply. Cropped from the top, which
   is where a document cover keeps its title. */
.resource-card .thumb {
  display: block;
  flex: none;
  width: 100%;
  height: 178px;
  object-fit: cover;
  object-position: top center;
  background: var(--panel);
  border-bottom: 1px solid var(--hairline);
}
.resource-card .body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  padding: 18px 18px 20px;
}
.resource-card h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
}
.resource-card:hover h2 { color: var(--accent); }
.resource-card .dek {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.resource-card .get {
  margin-top: auto;
  padding-top: 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.4px;
}

.type-badge {
  align-self: flex-start;
  padding: 3px 9px;
  color: var(--accent);
  background: rgba(0, 200, 140, 0.1);
  border: 1px solid rgba(0, 200, 140, 0.26);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

/* The grid used to run straight into the footer rule. */
.card-grid { margin-bottom: 72px; }

.no-results {
  margin: 34px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Resource detail ---------- */

.back-link {
  display: inline-block;
  margin: 34px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.4px;
}
.back-link:hover { color: var(--accent); }

.resource-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 52px;
  align-items: start;
  margin-top: 26px;
}
.resource-detail h1 {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -1px;
}
.resource-detail .dek {
  max-width: 56ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16.5px;
}
.resource-detail .inside {
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
}
.resource-detail .inside li {
  position: relative;
  margin: 0 0 10px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.resource-detail .inside li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 2px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 2px;
}
.resource-detail .inside strong {
  color: var(--ink);
  font-weight: 600;
}

/* The preview image is already only the top of the document - the rest of the
   page is not in the file at all, so it cannot be read by opening the asset
   directly. The fade is the visual half of that: it makes the crop read as "the
   page continues" rather than as a whole document that happens to be short. */
.cover-figure {
  max-width: 460px;
  margin: 34px 0 0;
}
.cover {
  display: block;
  width: 100%;
  /* The height attribute is a presentational hint that survives width:100% and
     would otherwise stretch the preview to 414px tall at any width. */
  height: auto;
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
}
.cover-figure figcaption {
  margin: 10px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3px;
}

.resource-meta {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  align-items: center;
  margin: 22px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.4px;
}

/* ---------- Gate panel ---------- */

.gate {
  position: sticky;
  top: 24px;
  isolation: isolate;
  padding: 11px;
  overflow: hidden;
  background: linear-gradient(160deg, var(--panel-2) 0%, var(--panel) 52%, #09120C 100%);
  border: 1px solid rgba(0, 200, 140, 0.2);
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 rgba(233, 245, 238, 0.04),
    0 28px 80px -40px rgba(0, 200, 140, 0.32),
    0 24px 70px -34px rgba(0, 0, 0, 0.9);
}
.gate::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: -1px;
  right: 14%;
  left: 14%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 200, 140, 0.72), transparent);
  pointer-events: none;
}
.gate-head {
  padding: 14px 12px 12px;
}
.gate-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.gate-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.form-embed {
  position: relative;
  height: 420px;
  overflow: hidden;
  background: var(--panel);
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(233, 245, 238, 0.04);
  contain: layout paint;
}
.form-loading { display: none; }
.js .form-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle, rgba(0, 200, 140, 0.07), transparent 18rem),
    var(--panel);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.4px;
  transition: opacity 180ms ease, visibility 0s linear 180ms;
}
.form-loading-inner {
  display: flex;
  align-items: center;
  gap: 11px;
}
.form-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: form-spin 700ms linear infinite;
}
@keyframes form-spin {
  to { transform: rotate(360deg); }
}
/* no-background="false" on the embed is deliberate, and is the opposite of what
   the name suggests here. Setting it true strips the Interfaces page background,
   which exposed the default white *behind* the themed form rather than leaving
   it transparent - so the form arrived as a dark card inside a white frame.
   Keeping the background lets the form's own dark theme cover the whole embed. */
zapier-interfaces-page-embed {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}
.js zapier-interfaces-page-embed {
  opacity: 0;
  transition: opacity 180ms ease;
}
.js .form-embed.is-ready zapier-interfaces-page-embed { opacity: 1; }
.js .form-embed.is-ready .form-loading {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.gate-consent {
  margin: 12px 0 0;
  padding: 0 10px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}
.gate-consent a { color: var(--muted); text-decoration: underline; }
.gate-consent a:hover { color: var(--accent); }

.gate-fallback {
  margin: 10px 0 0;
  padding: 10px 10px 1px;
  border-top: 1px solid rgba(157, 181, 168, 0.12);
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}
.gate-fallback a { color: var(--faint); text-decoration: underline; }
.gate-fallback a:hover { color: var(--accent); }

/* ---------- Unlocked panel ---------- */

.unlocked {
  padding: 26px 20px 22px;
  text-align: center;
}
.unlocked .tick {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  color: var(--accent);
  background: rgba(0, 200, 140, 0.12);
  border: 1px solid rgba(0, 200, 140, 0.3);
  border-radius: 50%;
}
.unlocked h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.unlocked p {
  max-width: 34ch;
  margin: 9px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 20px 0 0;
  padding: 12px 22px;
  color: var(--ground);
  background: var(--accent);
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
}
.download-btn:hover {
  background: #17E0A3;
  text-decoration: none;
}
.download-note {
  margin: 14px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3px;
}

/* The gate swaps between two panels; the inactive one is removed from the flow
   entirely so it cannot be tabbed into behind the visible panel. */
[hidden] { display: none !important; }

/* ---------- Standalone unlocked page ---------- */

.thanks {
  display: flex;
  min-height: 60vh;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}
.thanks .unlocked { max-width: 440px; }

/* Rendered inside the Zapier form's iframe: no site chrome, transparent ground,
   sized to the panel it replaces rather than to a page. */
body.framed { background: transparent; }
body.framed .shell { max-width: none; padding: 0; }
body.framed nav,
body.framed footer,
body.framed .back-link { display: none; }
body.framed .thanks { min-height: 100vh; padding: 20px; }

@media (max-width: 900px) {
  .resource-layout { grid-template-columns: minmax(0, 1fr); gap: 34px; }
  .gate { position: static; }
  .cover { margin-inline: auto; }
}
@media (max-width: 560px) {
  .library-hero { padding-top: 48px; }
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .gate { padding: 6px; border-radius: 12px; }
  .form-embed { height: 440px; border-radius: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .form-loading-spinner { animation: none; }
  .resource-card { transition: none; }
  .resource-card:hover { transform: none; }
  .js .form-loading,
  .js zapier-interfaces-page-embed { transition: none; }
}
