/* ==========================================================
   Pill finder (/pills): search, filter chips, pill cards and the
   illustrated pack shown until a real photo is supplied. Cards are
   generated by scripts/build-pills.mjs. Load after lyla-base.css.
   ========================================================== */

/* hero illustration: three cartons in a loose pile */
.shelf {
  position: relative;
  aspect-ratio: 5 / 4;
  max-width: 380px;
}
.shelf .carton {
  position: absolute;
  width: 64%;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 22px 40px rgba(45, 17, 62, 0.16), 0 3px 8px rgba(45, 17, 62, 0.08);
}
.shelf .carton:nth-child(1) {
  left: 0;
  top: 6%;
  transform: rotate(-10deg);
}
.shelf .carton:nth-child(2) {
  right: 0;
  top: 0;
  transform: rotate(7deg);
}
.shelf .carton:nth-child(3) {
  left: 16%;
  top: 36%;
  transform: rotate(-2deg);
}
.shelf .carton-name {
  font-size: clamp(18px, 1.8vw, 24px);
}
.shelf .carton-dose {
  font-size: 10.5px;
}
.finder-search {
  margin-top: 28px;
  position: relative;
  max-width: 560px;
}
.finder-search svg {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--purple-deep);
  pointer-events: none;
}
.finder-search input {
  width: 100%;
  min-height: 58px;
  padding: 0 20px 0 52px;
  border-radius: 999px;
  border: 1px solid rgba(125, 61, 142, 0.3);
  background: var(--white);
  font: inherit;
  font-size: 17px;
  color: var(--dark);
  box-shadow: 0 10px 30px rgba(53, 18, 74, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.finder-search input::placeholder {
  color: #6f5a7b;
}
.finder-search input:focus {
  outline: none;
  border-color: var(--purple-deep);
  box-shadow: 0 0 0 4px rgba(125, 61, 142, 0.16);
}
.finder-search input::-webkit-search-cancel-button {
  cursor: pointer;
}

.finder {
  background: var(--cream);
  padding: 0 0 clamp(64px, 8vw, 104px);
}
.finder-bar {
  position: sticky;
  top: 72px;
  z-index: 10;
  background: rgba(252, 247, 243, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--section-rule);
}
.finder-bar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  padding: 14px 0;
}
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(125, 61, 142, 0.26);
  background: var(--white);
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--purple-deep);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chip:hover {
  border-color: var(--purple-deep);
}
.chip[aria-pressed="true"] {
  background: var(--purple-deep);
  border-color: var(--purple-deep);
  color: var(--white);
}
.chip-count {
  font-family: var(--font-mono);
  font-size: 12px;
}
.finder-status {
  font-size: 14px;
  color: var(--muted);
}

.ec-notice {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-radius: 16px;
  background: var(--amber-pale);
  border: 1px solid rgba(122, 66, 16, 0.2);
}
.ec-notice p {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 70ch;
}
.ec-notice strong {
  color: var(--amber-deep);
  font-weight: 600;
}
.ec-notice a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 600;
  color: var(--amber-deep);
  white-space: nowrap;
}

.pill-group {
  margin-top: clamp(40px, 5vw, 56px);
}
.pill-group[hidden] {
  display: none;
}
.pill-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
}
.pill-group-head h2 {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--purple-deep);
}
.pill-group-head p {
  font-size: 15px;
  color: var(--muted);
  max-width: 60ch;
}
.pill-group-head a {
  color: var(--purple-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.pill-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 1.8vw, 24px);
  list-style: none;
}
@media (max-width: 1100px) {
  .pill-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .pill-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.pill-grid > li[hidden] {
  display: none;
}

.pill-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--white);
  border: 1px solid rgba(125, 61, 142, 0.14);
  overflow: hidden;
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out),
    border-color 0.3s ease;
}
.pill-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-soft);
  border-color: rgba(125, 61, 142, 0.34);
}
.pill-card:focus-visible {
  outline: 3px solid var(--purple-deep);
  outline-offset: 3px;
}

/* the pack: an illustrated carton, or a real photo when one is supplied */
.pack {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 5 / 4;
  background: radial-gradient(
    120% 90% at 30% 10%,
    #fbf6fd 0%,
    var(--lavender-bg) 60%,
    #e6d6f0 100%
  );
  overflow: hidden;
}
.pack.is-sage {
  background: radial-gradient(
    120% 90% at 30% 10%,
    #f5fbf7 0%,
    var(--sage-pale) 60%,
    #cfe6d8 100%
  );
}
/* real pack photos sit on white, so the packs keep their true colours */
.pack.has-photo {
  background: var(--white);
  border-bottom: 1px solid rgba(125, 61, 142, 0.1);
}
.pack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4% 6%;
  transition: transform 0.5s var(--ease-out);
}
.pill-card:hover .pack img {
  transform: scale(1.04);
}
.carton {
  position: relative;
  width: 72%;
  aspect-ratio: 1.55;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 14px 26px rgba(45, 17, 62, 0.14), 0 2px 5px rgba(45, 17, 62, 0.08);
  transform: rotate(-3deg);
  transition: transform 0.5s var(--ease-out);
  display: flex;
  flex-direction: column;
  padding: 0 11% 0 11%;
  overflow: hidden;
}
.pill-card:hover .carton {
  transform: rotate(0deg) translateY(-3px);
}
.carton::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 24%;
  background: var(--band, var(--purple-deep));
}
.carton::after {
  content: "";
  position: absolute;
  right: -12%;
  bottom: -30%;
  width: 55%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--band, var(--purple-deep));
  opacity: 0.1;
}
.carton-name {
  margin-top: 30%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.05;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.carton-dose {
  margin-top: 5%;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.carton-blister {
  margin-top: auto;
  margin-bottom: 11%;
  display: flex;
  gap: 5%;
}
.carton-blister i {
  width: 9%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--band, var(--purple-deep));
  opacity: 0.28;
}

.pill-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 20px;
}
.pill-tag {
  align-self: flex-start;
  font-size: 12.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--lavender-pale);
  color: var(--purple-deep);
}
.pill-tag.is-sage {
  background: var(--sage-pale);
  color: var(--sage-deep);
}
.pill-name {
  display: block;
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--purple-deep);
}
.pill-generic {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.pill-regimen {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.pill-same {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.pill-go {
  margin-top: auto;
  padding-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--purple-deep);
}
.pill-card:hover .pill-go .arrow {
  transform: translateX(3px);
}

.finder-empty {
  margin-top: 48px;
  padding: 36px 28px;
  border-radius: 20px;
  background: var(--white);
  border: 1px dashed var(--lavender-mid);
  text-align: center;
}
.finder-empty[hidden] {
  display: none;
}
.finder-empty h2 {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--purple-deep);
}
.finder-empty p {
  margin: 10px auto 22px;
  max-width: 52ch;
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
}
.finder-notes {
  margin-top: clamp(48px, 6vw, 72px);
  padding-top: 24px;
  border-top: 1px solid var(--section-rule);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px 40px;
}
.finder-notes p {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--muted);
}
.finder-notes strong {
  color: var(--ink-soft);
  font-weight: 600;
}
.finder-empty .hero-actions {
  justify-content: center;
}
.carton-name.is-long {
  font-size: clamp(12.5px, 1.15vw, 15px);
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .finder-hero .shelf {
    display: none;
  }
}
@media (max-width: 767px) {
  .finder-bar {
    top: 64px;
  }
}
@media (max-width: 560px) {
  .pill-info {
    padding: 14px 14px 16px;
  }
  .pill-name {
    font-size: 19px;
  }
  .pill-generic,
  .pill-regimen {
    font-size: 13px;
  }
  .pill-info > .pill-same,
  .pill-go .go-long {
    display: none;
  }
  .carton {
    width: 78%;
  }
  .carton-name {
    font-size: 14px;
  }
  .carton-name.is-long {
    font-size: 11.5px;
  }
  .carton-dose {
    font-size: 8.5px;
  }
  .chip {
    padding: 0 14px;
  }
  .finder-bar .container {
    padding: 10px 0;
  }
  /* the result count is still announced, just not shown */
  .finder-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
@media (max-width: 360px) {
  .pill-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (prefers-reduced-motion: reduce) {
  .pill-card:hover,
  .pill-card:hover .pack img {
    transform: none;
  }
  .pill-card:hover .carton {
    transform: rotate(-3deg);
  }
}
