/* Basic resets */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

/* Normalize form controls (iOS Safari rounded inputs, etc.) */
input,
button,
select,
textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
}
input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

:root {
    --bg: #0e0f12;
    --fg: #e7e9ee;
    --muted: #b8bdc7;
    --card: #1a1d24;
    --accent: #7aa2ff;
    --gap: 16px;
    --container-pad: 24px; /* unified outer padding */
    /* Directory page tokens */
    --ink: #000000;
    --blue-700: #201CAB;
    --teal-900: #13343b;
    --gray-300: #d9d9d9;
    --border: #0f329a;
    --white: #ffffff;
    --space-28: 28px;
    --space-48: 48px;
    --space-80: 80px;
    --space-127: 127px;
    --hero-h: 300px;
    --hero-pad: 50px;
}

@keyframes vt-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes vt-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-12px);
  }
}

@supports (view-transition-name: page) {
  @view-transition {
    navigation: auto;
  }

  :root {
    view-transition-name: page;
  }

  ::view-transition-old(page) {
    animation: vt-fade-out 280ms ease forwards;
  }

  ::view-transition-new(page) {
    animation: vt-fade-in 320ms ease forwards;
  }

  @media (prefers-reduced-motion: reduce) {
    ::view-transition-old(page),
    ::view-transition-new(page) {
      animation-duration: 1ms;
    }
  }
}

body {
    font-family:
        ui-sans-serif,
        system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        Helvetica,
        Arial,
        Apple Color Emoji,
        Segoe UI Emoji,
        Noto Color Emoji,
        Liberation Sans,
        sans-serif;
    background: var(--white);
    color: var(--ink);
    line-height: 1.5;
}

/* Hero */
.hero {
  min-height: 420px;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  padding: var(--container-pad);
  background: var(--blue-700);
}

.hero__inner {
  max-width: 960px;
  text-align: center;
  margin: 0 auto;
}

.hero__top {
  width: 100%;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.hero__logo {
  display: block;
  max-width: 250px;
  width: 100%;
  height: auto;
}

.hero__cta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  font-family: "Manrope", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--ink);
  text-decoration: none;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.hero__cta:hover,
.hero__cta:focus-visible {
  background: var(--blue-700);
  color: var(--white);
  border-color: var(--white);
  outline: none;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 56px);
  letter-spacing: -0.02em;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  color: var(--white);
}

.hero p {
  margin: 0 auto;
  max-width: 70ch;
  color: var(--white);
  font-size: clamp(14px, 2.2vw, 18px);
  font-family: "Fraunces", serif;
  font-weight: 300;
}

/* Tools grid */
.tools {
    width: 100%;
}

.tools__grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  padding: var(--container-pad);
}

/* Subtle transition for card show/hide */
/* (animation removed) */

/* Filters bar */
.tools__filters {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 2fr 1fr; /* 2/3 + 1/3 */
    gap: var(--container-pad);
    align-items: center;
    padding: var(--container-pad);
    border: 1px solid var(--border);
    background: var(--white);
}

.filters__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--container-pad) * 0.5);
    justify-content: flex-start;
}

.filter-btn {
  font-family: "Manrope", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 10px;
  background: var(--white);
  color: var(--blue-700);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.filter-btn.is-active {
  background: var(--blue-700);
  color: var(--white);
}

.filter-btn:hover:not(.is-active),
.filter-btn:focus-visible:not(.is-active) {
  background: color-mix(in oklab, var(--blue-700) 12%, var(--white));
  border-color: var(--blue-700);
  outline: none;
}

.filters__search {
    justify-self: stretch; /* start of column and full width */
    align-self: self-start;
}

.filters__search .filter-input {
    font-family: "Manrope", sans-serif;
    font-size: 14px;
    font-weight: 300;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--ink);
    width: 100%;
}

.is-hidden {
  display: none !important;
}

@media (min-width: 1024px) {
    .tools__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Stack filters and center content on small screens */
@media (max-width: 768px) {
    :root {
        --container-pad: 16px; /* compact padding on small screens */
    }
    .hero {
        min-height: 350px;
    }
    .hero__logo {
        max-width: 200px;
    }

    .tools__grid {
        grid-template-columns: 1fr; /* break to single column earlier */
    }
    .tools__filters {
        grid-template-columns: 1fr;
        /* subtract the 6px scrollbar padding from the vertical gap */
        gap: calc(var(--container-pad) - 6px);
    }
    .filters__buttons {
        /* compact, horizontal scroll list */
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none; /* Firefox */
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding-bottom: 6px; /* room for hidden scrollbar */
        gap: calc(var(--container-pad) * 0.5);
        /* Fade on right edge using mask so it doesn't scroll */
        -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 80%, rgba(0,0,0,0) 100%);
                mask-image: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 80%, rgba(0,0,0,0) 100%);
    }
    .filters__buttons::-webkit-scrollbar { display: none; }
    .filter-btn {
        font-size: 10px;
        padding: 6px 8px;
        scroll-snap-align: start;
        white-space: nowrap; /* keep text on one line */
        flex: 0 0 auto; /* prevent shrinking causing wraps */
    }
    /* (mask used for fade; no pseudo-element needed) */
    .filters__search {
        justify-self: stretch;
        width: 100%;
        display: block;
        align-self: self-start;
    }
    .filters__search .filter-input {
        width: 100%;
    }
    .hero__cta {
        font-size: 10px;
        padding: 6px 8px;
    }
}

/* iOS-only fix to prevent focus zoom on inputs (applies to all iOS WebKit browsers) */
@supports (-webkit-touch-callout: none) and (-webkit-overflow-scrolling: touch) {
  @media (max-width: 768px) {
    .filters__search .filter-input {
      font-size: 16px;
    }
  }
}

/* Detail view (standalone + popup-ready) */
.detail {
  --ink: var(--ink);
  --blue-700: var(--blue-700);
  --border: var(--border);
  --white: var(--white);
  color: var(--ink);
  background: var(--white);
  min-height: 100dvh;
}

.detail__wrap {
  /* Figma frame used 60px offsets and 1320px width */
  max-width: 1320px;
  margin: 60px auto;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  position: relative;
  border: 1px solid var(--ink);
}

.detail__close {
  position: fixed;
  top: 24px;
  right: 24px;
  font-family: "Manrope", sans-serif;
  font-weight: 200;
  font-size: 36px;
  line-height: 1;
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 8px;
  cursor: pointer;
}
.detail__close:focus-visible { outline: 2px solid var(--border); outline-offset: 2px; }

/* Media */
.detail__media { display: flex; }
.detail__media__inner {
  position: relative;
  width: 100%;
  height: 670px; /* aligns with Figma block */
  background: #000;
}
.detail__media-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.95);
}
.detail__media-logo {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 80%;
  max-height: 70%;
  object-fit: contain;
  z-index: 1;
}
.detail__overlay {
  display: none;
}

/* Content */
.detail__body {
  display: flex;
  flex-direction: column;
  gap: 40px;
  align-self: stretch;
  padding: 60px 0;
}

.detail__title {
  margin: 0;
  text-align: center;
  color: var(--border);
  font-family: "Fraunces", serif;
  font-weight: 300;
  font-size: clamp(42px, 6vw, 78px);
  letter-spacing: -0.04em;
}
.detail__desc {
  margin: 10px auto 0;
  max-width: 420px;
  text-align: center;
  font-family: "Manrope", sans-serif;
  font-weight: 300;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.detail__divider {
  height: 1px;
  width: 70px;
  border: 0;
  background: var(--ink);
  margin: 0 auto;
}

.detail__features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.detail__features li {
  text-align: center;
  font-family: "Fraunces", serif;
  font-weight: 300;
  font-size: 22px;
  line-height: 30px;
}
.detail__u { color: var(--border); text-decoration: underline; text-underline-position: from-font; }

.detail__cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail__cta {
  --cta-shadow: rgba(15, 50, 154, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 0 32px;
  border-radius: 2000px;
  background: var(--blue-700);
  background: linear-gradient(135deg,
      color-mix(in srgb, var(--blue-700) 85%, white 15%),
      color-mix(in srgb, var(--blue-700) 92%, black 8%));
  color: var(--white);
  text-decoration: none;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border: 1px solid color-mix(in srgb, var(--blue-700) 65%, white 35%);
  box-shadow: 0 14px 26px var(--cta-shadow);
  transition: transform 220ms ease, box-shadow 220ms ease,
    background 220ms ease, border-color 220ms ease;
}
.detail__cta:hover,
.detail__cta:focus-visible {
  outline: none;
  transform: translateY(-2px);
  background: linear-gradient(135deg,
      color-mix(in srgb, var(--blue-700) 65%, white 35%),
      color-mix(in srgb, var(--blue-700) 95%, black 5%));
  border-color: var(--ink);
  box-shadow: 0 18px 32px rgba(15, 50, 154, 0.28);
}


/* Responsive */
@media (max-width: 1200px) {
  .detail__wrap { gap: 40px; }
  .detail__media__inner { height: 560px; }
}

@media (max-width: 1024px) {
  .detail__wrap { grid-template-columns: 2fr 3fr; }
}

@media (max-width: 768px) {
  .detail {
    padding: 16px;
  }
  .detail__wrap {
    grid-template-columns: 1fr;
    gap: 24px;
    margin: 16px auto 40px;
    border-width: 1px;
    border-radius: 18px;
    padding: 20px;
  }
  .detail__media__inner {
    height: 300px;
    border-radius: 16px;
    overflow: hidden;
  }
  .detail__body {
    padding: 0;
    gap: 24px;
  }
  .detail__cta-row {
    flex-direction: column;
    align-items: stretch;
  }
  .detail__cta {
    width: 100%;
  }
  .detail__close {
    top: 12px;
    right: 12px;
    font-size: 30px;
  }
}

.tool-card {
    background: var(--white);
    border-radius: 0;
    border: 1px solid var(--border);
    height: 300px;
}

.tool-card a {
    text-decoration: none;
    width: 100%;
}

/* Detailed card variant */
.tool-card--detailed {
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0; /* content will pad itself */
}

.tool-card__media {
    position: relative;
    height: 225px;
    overflow: hidden;
}

.tool-card__video,
.tool-card__bg__still {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    filter: saturate(0.95);
}

.tool-card__logo {
    position: absolute;
    inset: 0;
    margin: auto;
    /*width: clamp(80px, 30%, 160px);*/
    max-height: 70%;
    object-fit: contain;
    pointer-events: none;
}

.tool-card__content {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pill {
    align-self: flex-start;
    display: inline-block;
    padding: 5px 12px;
    border-radius: 0;
    font-size: 12px;
    letter-spacing: 1.5px;
    color: var(--white);
    background: var(--blue-700);
    /*border: 1px solid rgba(255, 255, 255, 0.12);*/
}

.tool-card__title {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.tool-card__desc {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* Directory Card styles (mapped to existing classes) */
.tools .tool-card.tool-card--detailed {
    display: flex;
    width: 100%;
    padding-bottom: 20px;
    flex-direction: column;
    align-items: center;
    gap: 20px);
    border: 1px solid var(--border);
    background: var(--white);
}

.tools .tool-card--detailed .tool-card__media {
    display: flex;
    /*height: var(--hero-h);*/
    /*padding: var(--hero-pad);*/
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.tools .tool-card--detailed .tool-card__logo {
    position: absolute;
    inset: 0;
    margin: auto;
    display: block;
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 1;
}

.tools .tool-card--detailed .tool-card__content {
    padding: var(--space-28);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Typography for detailed card */
.tools .tool-card--detailed .pill {
    color: var(--white);
    text-align: center;
    align-self: center;
    display: inline-block;
    padding: 5px 12px;
    background: var(--blue-700);
    border-radius: 0;
    font-family: "Manrope", sans-serif;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.16;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.tools .tool-card--detailed .tool-card__title {
    color: var(--blue-700);
    text-align: center;
    font-family: "Fraunces", serif;
    font-size: 36px;
    font-weight: 300;
    line-height: 1.16;
    letter-spacing: -1.44px;
    text-decoration: none;
}

.tools .tool-card--detailed .tool-card__desc {
    color: var(--teal-900);
    text-align: center;
    font-family: "Manrope", sans-serif;
    font-size: 14px;
    font-weight: 300;
    line-height: 20px;
    letter-spacing: 0.56px;
}

/* Directory Card component (scoped; no global selectors) */
/* Tokens: declared on .card and mapped to existing .tool-card--detailed */
.card,
.tools .tool-card--detailed {
    --ink: #000000;
    --blue-700: #0736c4;
    --teal-900: #13343b;
    --gray-300: #d9d9d9;
    --border: #0f329a;
    --white: #ffffff;
    --space-28: 28px;
    --space-48: 48px;
    --space-80: 80px;
    --space-127: 127px;
    --hero-h: 300px;
    --hero-pad: 50px;
}

/* Component layout (map to existing markup) */
.card,
.tools .tool-card--detailed {
    display: flex;
    width: 100%;
    padding-bottom: 20px;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border);
    background: var(--white);
}

.card__hero,
.tools .tool-card--detailed .tool-card__media {
    display: flex;
    /*height: var(--hero-h);
    padding: var(--hero-pad);*/
    justify-content: center;
    align-items: center;
    height: 300px;
}

.card__img,
.tools .tool-card--detailed .tool-card__logo {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: var(--hero-pad);
}

/* Typography (applied to existing classes within tools only) */
.card__badge,
.tools .tool-card--detailed .pill {
    color: var(--white);
    text-align: center;
    font-family: "Manrope", sans-serif;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.16;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.card__title,
.tools .tool-card--detailed .tool-card__title {
    color: var(--blue-700);
    text-align: center;
    font-family: "Fraunces", serif;
    font-size: 36px;
    font-weight: 300;
    line-height: 1.16;
    letter-spacing: -1.44px;
    text-decoration: none;
}

.card__lead,
.tools .tool-card--detailed .tool-card__desc {
    color: var(--teal-900);
    text-align: center;
    font-family: "Manrope", sans-serif;
    font-size: 14px;
    font-weight: 300;
    line-height: 20px;
    letter-spacing: 0.56px;
}
