/*
 * "Next for you" (nfy-): suggestions after a lesson, a study page or on the dashboard. A dense rail of role-coloured
 * cards — practise, understand, learn, use it, print, look up — numbered in the order they are suggested. Colours come
 * from the site tokens so light and dark both work; logical properties keep Arabic and Urdu mirrored.
 */

.nfy {
  --nfy-practise: #1f7a63;
  --nfy-explain: #b07a12;
  --nfy-learn: #1d5fae;
  --nfy-apply: #8b3fd1;
  --nfy-printable: #b8321d;
  --nfy-reference: #4b5563;
  position: relative;
  margin-block: clamp(20px, 3vw, 36px);
  padding: clamp(16px, 2.4vw, 26px);
  border: 1px solid var(--ip-line, #ebe8df);
  border-radius: var(--ip-radius-xl, 20px);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--ip-accent, #e6b85c) 16%, transparent), transparent 55%),
    radial-gradient(90% 120% at 0% 100%, color-mix(in srgb, var(--ip-primary, #1f7a63) 12%, transparent), transparent 60%),
    var(--ip-surface, #fff);
  box-shadow: var(--ip-shadow-sm);
  overflow: hidden;
  isolation: isolate;
}

/* A faint eight-point star lattice behind the cards. */
.nfy::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72'%3E%3Cpath d='M36 22l4 10 10 4-10 4-4 10-4-10-10-4 10-4z' fill='none' stroke='%231f7a63' stroke-opacity='.10'/%3E%3C/svg%3E");
  mask-image: linear-gradient(90deg, transparent, #000 40%, #000);
  pointer-events: none;
}

.nfy__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "eyebrow path" "title path" "lead path";
  column-gap: 16px;
  align-items: end;
  margin-block-end: 14px;
}

.nfy__head--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.nfy__eyebrow {
  grid-area: eyebrow;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .3rem;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ip-primary, #1f7a63);
}

.nfy__spark {
  inline-size: 10px;
  block-size: 10px;
  background: var(--ip-accent, #e6b85c);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: nfy-twinkle 2.6s ease-in-out infinite;
}

.nfy__title {
  grid-area: title;
  margin: 0;
  font-family: var(--ip-font-display);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.2;
  color: var(--ip-ink, #1c1c1c);
}

.nfy__lead {
  grid-area: lead;
  margin: .3rem 0 0;
  font-size: .86rem;
  color: var(--ip-muted, #5f6673);
  max-inline-size: 70ch;
}

.nfy__path {
  grid-area: path;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .9rem;
  border-radius: var(--ip-radius-pill, 999px);
  font-size: .84rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ip-primary-ink, #fff);
  background: var(--ip-primary, #1f7a63);
  text-decoration: none;
  transition: transform .2s ease, background-color .2s ease;
}

.nfy__path:hover,
.nfy__path:focus-visible {
  color: var(--ip-primary-ink, #fff);
  background: var(--ip-primary-hover, #16624f);
  transform: translateY(-1px);
}

.nfy__rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: nfy;
}

.nfy__rail--compact {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.nfy-card {
  --nfy-c: var(--nfy-reference);
  min-inline-size: 0;
}

.nfy-card--practise { --nfy-c: var(--nfy-practise); }
.nfy-card--explain { --nfy-c: var(--nfy-explain); }
.nfy-card--learn { --nfy-c: var(--nfy-learn); }
.nfy-card--apply { --nfy-c: var(--nfy-apply); }
.nfy-card--printable { --nfy-c: var(--nfy-printable); }

.nfy-card__link {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  block-size: 100%;
  padding: 12px 14px 12px;
  padding-inline-end: 34px;
  border: 1px solid color-mix(in srgb, var(--nfy-c) 22%, var(--ip-line, #ebe8df));
  border-block-start: 3px solid var(--nfy-c);
  border-radius: var(--ip-radius-lg, 16px);
  background: color-mix(in srgb, var(--nfy-c) 5%, var(--ip-surface, #fff));
  color: var(--ip-ink, #1c1c1c);
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.nfy-card__link:hover,
.nfy-card__link:focus-visible {
  transform: translateY(-2px);
  border-color: var(--nfy-c);
  box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--nfy-c) 60%, transparent);
  color: var(--ip-ink, #1c1c1c);
}

.nfy-card__link:focus-visible {
  outline: 3px solid var(--ip-focus, #1f7a63);
  outline-offset: 2px;
}

.nfy-card__top {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.nfy-card__num {
  font-family: var(--ip-font-display);
  font-size: .78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--nfy-c) 70%, var(--ip-muted, #5f6673));
}

.nfy-card__role {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .12rem .5rem;
  border-radius: var(--ip-radius-pill, 999px);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--nfy-c);
}

.nfy-card__title {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.3;
}

.nfy-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  margin-block-start: auto;
  font-size: .76rem;
  color: var(--ip-muted, #5f6673);
}

.nfy-card__conn {
  font-weight: 700;
  color: var(--nfy-c);
}

.nfy-card__topic {
  padding: .05rem .45rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--nfy-c) 9%, transparent);
}

.nfy-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.nfy-card__tags .ip-review-badge {
  font-size: .68rem;
  white-space: nowrap;
  padding-block: .1rem;
}

.nfy-tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1rem .45rem;
  border-radius: var(--ip-radius-pill, 999px);
  font-size: .68rem;
  font-weight: 700;
  color: var(--ip-ink-2, #374151);
  background: var(--ip-surface-2, #f6f4ee);
}

.nfy-tag--kids {
  color: #b8321d;
  background: #fff3f0;
}

.nfy-card__go {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  color: var(--nfy-c);
  transition: transform .2s ease;
}

.nfy-card__link:hover .nfy-card__go {
  transform: translateX(3px);
}

[dir="rtl"] .nfy-card__link:hover .nfy-card__go {
  transform: translateX(-3px);
}

.nfy__empty {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--ip-line-strong, #d9d5c9);
  border-radius: var(--ip-radius-lg, 16px);
  color: var(--ip-muted, #5f6673);
  font-size: .9rem;
}

/* ---------- Dashboard ---------- */

.nfy--dash {
  margin-block: 0 18px;
}

.nfy-dash {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: stretch;
}

.nfy-dash__path {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: 10px 12px;
  padding: 14px;
  border-radius: var(--ip-radius-lg, 16px);
  color: #eef7f2;
  background:
    radial-gradient(100% 80% at 100% 0%, rgba(230, 184, 92, .28), transparent 60%),
    linear-gradient(160deg, #0d3b29, #072a1d);
}

.nfy-dash__path > .nfy-btn,
.nfy-dash__path > .nfy-dash__next,
.nfy-dash__path > .nfy-dash__empty {
  grid-column: 1 / -1;
}

.nfy-dash__path > .nfy-dash__label:first-child {
  grid-column: 1 / -1;
}

.nfy-dash__label {
  margin: 0;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #f1d59a;
}

.nfy-dash__goal {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: .15rem 0 0;
  font-weight: 800;
  color: #fff;
}

.nfy-dash__count,
.nfy-dash__empty {
  margin: .1rem 0 0;
  font-size: .8rem;
  color: rgba(238, 247, 242, .8);
}

.nfy-dash__ring {
  position: relative;
  inline-size: 64px;
  block-size: 64px;
}

.nfy-dash__ring svg {
  inline-size: 100%;
  block-size: 100%;
  transform: rotate(-90deg);
}

.nfy-dash__ring strong {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.nfy-dash__ring small {
  font-size: .6rem;
}

.nfy-ring__track {
  fill: none;
  stroke: rgba(255, 255, 255, .14);
  stroke-width: 7;
}

.nfy-ring__fill {
  fill: none;
  stroke: #e6b85c;
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset .8s ease;
}

.nfy-dash__next {
  display: grid;
  gap: .15rem;
  padding: 10px 12px;
  border: 1px solid rgba(241, 213, 154, .35);
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, .06);
  text-decoration: none;
}

.nfy-dash__next:hover,
.nfy-dash__next:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}

.nfy-dash__next-label {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #f1d59a;
}

.nfy-dash__next-title {
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.3;
}

.nfy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem .9rem;
  border-radius: var(--ip-radius-btn, 10px);
  font-size: .85rem;
  font-weight: 700;
  color: #072a1d;
  background: #e6b85c;
  text-decoration: none;
}

.nfy-btn:hover,
.nfy-btn:focus-visible {
  color: #072a1d;
  background: #f1d59a;
}

.nfy-btn--ghost {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .28);
}

.nfy-btn--ghost:hover,
.nfy-btn--ghost:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

/* ---------- Dark ---------- */

:root[data-theme="dark"] .nfy,
body.dark .nfy {
  --nfy-practise: #3ed39a;
  --nfy-explain: #f2c46d;
  --nfy-learn: #6ea8ff;
  --nfy-apply: #c39bff;
  --nfy-printable: #ff8d77;
  --nfy-reference: #a6b0bd;
}

:root[data-theme="dark"] .nfy-card__role,
body.dark .nfy-card__role {
  color: #07130e;
}

:root[data-theme="dark"] .nfy-tag--kids,
body.dark .nfy-tag--kids {
  color: #ffb79a;
  background: rgba(255, 138, 106, .14);
}

@media (max-width: 760px) {
  .nfy__head {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "eyebrow" "title" "lead" "path";
    row-gap: 4px;
  }

  .nfy__path {
    justify-self: start;
    margin-block-start: 8px;
  }

  .nfy-dash {
    grid-template-columns: minmax(0, 1fr);
  }

  .nfy__rail,
  .nfy__rail--compact {
    grid-template-columns: minmax(0, 1fr);
  }
}

@keyframes nfy-twinkle {
  0%, 100% { transform: scale(1) rotate(0); opacity: 1; }
  50% { transform: scale(.7) rotate(45deg); opacity: .7; }
}

@media (prefers-reduced-motion: reduce) {
  .nfy__spark { animation: none; }
  .nfy-card__link,
  .nfy__path,
  .nfy-ring__fill,
  .nfy-card__go { transition: none; }
  .nfy-card__link:hover,
  .nfy__path:hover { transform: none; }
}
