/* ---- Grade selector (rendered from product-variants.tpl) ---- */
/* Anchor the info link to the top-right of the grade block (next to the label) */
.product-variants-item:has(.grade-cards) { position: relative; }

.grade-subtitle {
  font-size: 12px;
  color: #8a8a8a;
  margin: 2px 0 10px;
}
.grade-info-link {
  position: absolute;
  top: 2px;
  right: 0;
  font-size: 12px;
  color: #6b6b6b;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.grade-info-link:hover { color: #1a1a1a; }
.grade-info-link .gi-i {
  display: inline-flex;
  width: 15px;
  height: 15px;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 10px;
  font-style: italic;
}

.grade-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
/* Phones & small tablets: 2 columns; let the info link drop below the heading
   instead of being pinned top-right where it overlaps the title on narrow screens. */
@media (max-width: 767px) {
  .grade-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grade-info-link {
    position: static;
    margin: 4px 0 2px;
  }
  .grade-subtitle { margin-top: 0; }
}

/* Small phones: tighten padding/typography so cards don't feel cramped. */
@media (max-width: 400px) {
  .grade-cards { gap: 8px; }
  .grade-card { padding: 18px 8px 12px; }
  .grade-letter { font-size: 22px; }
  .grade-title { font-size: 12px; }
  .grade-desc { font-size: 10px; }
}

.grade-card-item { margin: 0; }

.grade-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  height: 100%;
  margin: 0;
  padding: 22px 12px 16px;
  border: 1px solid #e6e6e6;
  border-radius: 14px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.grade-card:hover { border-color: #cfcfcf; }

/* selected: driven ONLY by the live :checked state so the highlight switches
   instantly on click (radios share one name → exactly one is ever checked).
   Relying on a server-rendered class would leave the old card lit until the
   AJAX refresh lands, making two cards look selected at once. */
.grade-card:has(input.grade-radio:checked) {
  border-color: #f0a500;
  background: #fff8ec;
  box-shadow: 0 0 0 1px #f0a500 inset;
}

/* native radio hidden but accessible */
.grade-card .grade-radio {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.grade-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  color: #b07400;
  background: #ffe8b8;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Soft amber glow on the badge when the A+ card is selected */
.grade-card:has(input.grade-radio:checked) .grade-badge {
  box-shadow: 0 0 7px 1px rgba(240, 165, 0, 0.7);
}

.grade-icon {
  font-size: 20px;
  line-height: 1;
  margin: 16px 0 8px;
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f3f3f3;
  color: #555;
}
.grade-card:has(input.grade-radio:checked) .grade-icon {
  background: #ffe8b8;
}

.grade-letter {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.05;
}
.grade-title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-top: 4px;
}
.grade-desc {
  font-size: 11px;
  color: #8a8a8a;
  margin-top: 8px;
  line-height: 1.4;
}
.grade-price {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  margin-top: 8px;
}
.grade-price:empty { display: none; }

.grade-check {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f0a500;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  opacity: 0;
}
.grade-card:has(input.grade-radio:checked) .grade-check { opacity: 1; }

/* On a badged card (A+) the badge sits center-top; hide the corner check to avoid overlap on narrow cards */
.grade-card:has(.grade-badge) .grade-check { display: none; }
