/* Alphabet Explorer (shared styles for /learn pages) */

@font-face {
  font-family: "Hodipotha";
  src: url("../assets/fonts/Hodipotha3.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MartelSans-ExtraLight";
  src: url("../assets/fonts/MartelSans-ExtraLight.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MartelSans-Regular";
  src: url("../assets/fonts/MartelSans-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Adinatha";
  src: url("../assets/fonts/Adinatha.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.script-sinhala .hero-title {
  font-family: 'Hodipotha', sans-serif;
}

.script-devanagari .hero-title {
  font-family: 'MartelSans-ExtraLight', sans-serif;
}

.script-tamil .hero-title {
  font-family: 'Noto Sans Tamil', sans-serif;
}

.script-brahmi .hero-title {
  font-family: 'Noto Sans Brahmi', sans-serif;
}

.script-tamilbrahmi .hero-title {
  font-family: 'Adinatha', sans-serif;
  font-size: 28px;
}

.learn-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 0px 0px;
}

.learn-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e3e8ef;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.20);
}

.learn-input {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d0d7e2;
  font-size: 16px;
  outline: none;
}

.learn-pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d0d7e2;
  background: #f3f4f6;
  color: #374151;
  white-space: nowrap;
}

.learn-section {
  margin-top: 18px;
}

.learn-section h2 {
  margin: 18px 0 10px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.learn-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.learn-grid--4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.learn-grid--5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.learn-grid--6 {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.learn-sound {
  position: absolute;
  left: 8px;
  top: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1;
}

.learn-sound:hover {
  border-color: var(--gold);
}

.learn-glyph {
  font-size: 36px;
  line-height: 1.1;
  color: #d7dfe6;
}

/* per-script grid glyph font */
.script-sinhala .learn-glyph {
  font-family: 'Hodipotha', sans-serif;
}

.script-devanagari .learn-glyph {
  font-family: 'MartelSans-ExtraLight', sans-serif;
}

.script-tamil .learn-glyph {
  font-family: 'Noto Sans Tamil', sans-serif;
}

.script-brahmi .learn-glyph {
  font-family: 'Noto Sans Brahmi', sans-serif;
}

.script-tamilbrahmi .learn-glyph {
  font-family: 'Adinatha', sans-serif;
}

.learn-meta {
  flex: 1;
  min-width: 0;
}

.learn-name {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.learn-roman {
  font-size: 24px;
  color: rgba(226, 232, 240, 0.7);
}

.learn-copy {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  flex-shrink: 0;
}

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

.learn-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.learn-tile {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 18px 18px 16px;
  padding-right: 100px;
  background: #012947;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.20);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  text-decoration: none;
  display: block;
}

.learn-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, rgba(14, 165, 233, 1), rgba(37, 99, 235, 1));
  opacity: .95;
}

.learn-tile::after {
  content: attr(data-mark);
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 88px;
  line-height: 1;
  opacity: .30;
  pointer-events: none;
  transform: rotate(-6deg);
}

/* per-script font for tile watermark glyph (data-mark) */
.learn-tile--si::after {
  font-family: 'Noto Sans Sinhala', sans-serif;
}

.learn-tile--ta::after {
  font-family: 'Noto Sans Tamil', sans-serif;
}

.learn-tile--deva::after {
  font-family: 'MartelSans-Regular', sans-serif;
}

.learn-tile--brahmi::after {
  font-family: 'Noto Sans Brahmi', sans-serif;
}

.learn-tile--tamilbrahmi::after {
  font-family: 'Adinatha', 'Noto Sans Brahmi', sans-serif;
}

.learn-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.18);
}

.learn-tile:hover::after {
  opacity: .75;
  transform: translateY(-6px) rotate(-6deg);
}

.learn-tile h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}

.learn-tile p {
  margin: 0;
  opacity: .85;
}

/* disabled tiles */
.learn-tile.is-disabled {
  opacity: .55;
  cursor: not-allowed;
}

.learn-tile.is-disabled:hover {
  transform: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.20);
}

/* per-script accent bars */
.learn-tile--si::before {
  background: linear-gradient(90deg, #941E32, #7A1829);
}

.learn-tile--ta::before {
  background: linear-gradient(90deg, #DF7500, #B85F00);
}

.learn-tile--deva::before {
  background: linear-gradient(90deg, #0ea5e9, #2563eb);
}

.learn-tile--brahmi::before {
  background: linear-gradient(90deg, #a855f7, #7c3aed);
}

.learn-tile--tamilbrahmi::before {
  background: linear-gradient(90deg, #14b8a6, #22c55e);
}

/* ---- Tile text color (important) ---- */

.learn-tile,
.learn-tile:visited {
  color: rgba(255, 255, 255, 0.92);
  /* base text */
}

.learn-tile h3 {
  color: rgba(255, 255, 255, 0.96);
}

.learn-tile p {
  color: rgba(255, 255, 255, 0.78);
}

/* Hover emphasis */
.learn-tile:hover h3 {
  color: #ffffff;
}

.learn-tile:hover p {
  color: rgba(255, 255, 255, 0.88);
}

/* Disabled tiles */
.learn-tile.is-disabled,
.learn-tile.is-disabled:visited {
  color: rgba(255, 255, 255, 0.65);
}

.learn-tile.is-disabled h3 {
  color: rgba(255, 255, 255, 0.72);
}

.learn-tile.is-disabled p {
  color: rgba(255, 255, 255, 0.55);
}

.learn-tile--si h3 {
  font-family: 'Noto Sans Sinhala', sans-serif;
}

.learn-tile--ta h3 {
  font-family: 'Noto Sans Tamil', sans-serif;
}

.learn-tile--deva h3 {
  font-family: 'MartelSans-ExtraLight', sans-serif;
}

.learn-tile--brahmi h3 {
  font-family: 'Noto Sans Brahmi', sans-serif;
}

.learn-tile--tamilbrahmi h3 {
  font-family: 'Adinatha', sans-serif;
  font-size: 16px
}

.learn-card {
  background: #012947;
  /* same family as help-card */
  border: 1px solid rgba(16, 72, 149, 0.625);
  border-radius: 30px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.learn-card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(254, 218, 21, 0.35);
  transform: translateY(-1px);
}

.learn-card.copied::after {
  content: "Copied ✓";
  position: absolute;
  right: 8px;
  top: 8px;

  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;

  padding: 4px 8px;
  border-radius: 999px;

  background: #feda15;
  /* solid gold */
  color: #1b2533;
  /* dark text for contrast */

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.learn-hint {
  margin: 10px 0 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
  background: rgba(254, 218, 21, 0.12);
  border-radius: 8px;
  font-size: 14px;
  color: #e5e7eb;
}

.learn-hint--primary {
  background: rgba(14, 165, 233, 0.08);
  /* subtle blue */
  border-left: 4px solid #0ea5e9;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.95rem;
}

.learn-hint strong {
  color: var(--gold);
}

/* --- Script Notes (collapsible) --- */

.script-notes {
  margin: 10px 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.script-notes__summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: baseline;
  border-left: 4px solid rgba(14, 165, 233, 0.8);
  background: rgba(14, 165, 233, 0.06);
}

.script-notes__summary::-webkit-details-marker {
  display: none;
}

/* Links inside script notes */
.script-notes__body a {
  color: rgba(226, 232, 240, 0.92);
  text-decoration: underline;
  text-decoration-color: rgba(254, 218, 21, 0.55);
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease, background 0.15s ease;
  border-radius: 6px;
  padding: 0 2px;
}

.script-notes__body a:hover {
  color: #ffffff;
  text-decoration-color: rgba(254, 218, 21, 0.95);
  background: rgba(254, 218, 21, 0.08);
}

.script-notes__body a:focus-visible {
  outline: 2px solid rgba(254, 218, 21, 0.65);
  outline-offset: 2px;
}

.script-notes__body a strong {
  font-weight: 800;
}

/* per-script accent */
.script-sinhala .script-notes__summary {
  border-left-color: #941E32;
  background: rgba(148, 30, 50, 0.10);
}

.script-tamil .script-notes__summary {
  border-left-color: #DF7500;
  background: rgba(223, 117, 0, 0.10);
}

.script-devanagari .script-notes__summary {
  border-left-color: #0ea5e9;
  background: rgba(14, 165, 233, 0.10);
}

.script-brahmi .script-notes__summary {
  border-left-color: #a855f7;
  background: rgba(168, 85, 247, 0.10);
}

.script-tamilbrahmi .script-notes__summary {
  border-left-color: #14b8a6;
  background: rgba(20, 184, 166, 0.10);
}

.script-notes__title {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.script-notes__subtitle {
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.72);
}

.script-notes__body {
  padding: 12px 14px 14px;
  color: rgba(226, 232, 240, 0.86);
}

.script-notes__body p {
  margin: 0 0 10px;
  line-height: 1.65;
}

.script-notes__body ul {
  margin: 0 0 10px 18px;
  padding: 0;
}

.script-notes__body li {
  margin: 6px 0;
  color: rgba(226, 232, 240, 0.84);
}

.script-notes__fine {
  margin-top: 6px;
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.70);
  font-style: italic;
}

/* optional: little affordance */
.script-notes__summary::after {
  content: "▾";
  margin-left: auto;
  font-size: 1.2rem;
  /* bigger */
  font-weight: 700;
  /* stronger */
  color: rgba(226, 232, 240, 0.85);
  /* more visible */
  transform: translateY(-1px);
  transition: transform 0.15s ease;
}

.script-notes[open] .script-notes__summary::after {
  content: "▴";
}

.script-notes__summary:hover::after {
  color: var(--gold);
}

.letter-modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.letter-modal.hidden {
  display: none;
}

.letter-panel {
  position: relative;
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}

.letter-close {
  position: absolute;
  right: 14px;
  top: 10px;
  background: none;
  border: none;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
}

.letter-top {
  padding: 10px 0 12px;
  display: flex;
  justify-content: center;
}

.letter-pair {
  display: inline-grid;
  grid-template-columns: max-content max-content;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: #012947;
  overflow: hidden;
}

/* shared cell styles */
.letter-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
}

/* vertical divider */
.letter-cell--roman {
  border-left: 1px solid rgba(148, 163, 184, 0.25);
}

.letter-glyph {
  font-size: 50px;
  line-height: 1;
  color: #e5e7eb;
}

.script-sinhala .letter-glyph {
  font-family: 'Hodipotha', sans-serif;
}

.script-devanagari .letter-glyph {
  font-family: 'MartelSans-ExtraLight', sans-serif;
}

.script-tamil .letter-glyph {
  font-family: 'Noto Sans Tamil', sans-serif;
}

.script-brahmi .letter-glyph {
  font-family: 'Noto Sans Brahmi', sans-serif;
}

.script-tamilbrahmi .letter-glyph {
  font-family: 'Adinatha', sans-serif;
}

.letter-roman {
  font-size: 50px;
  line-height: 1;
  color: rgba(226, 232, 240, 0.75);
  letter-spacing: 0.02em;
}

.letter-actions {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 10px;
}

.letter-actions .m-btn {
  width: auto;
  padding: 10px 14px;
}

#mPlay {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
}

#mPlay:hover {
  border-color: rgba(34, 197, 94, 0.75);
  background: rgba(34, 197, 94, 0.20);
}

.letter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.letter-group button {
  padding-inline: 14px;
}

.m-btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
}

.m-btn:hover {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.10);
}

.m-btn--primary {
  border-color: rgba(254, 218, 21, 0.55);
  background: linear-gradient(135deg,
      rgba(254, 218, 21, 0.18),
      rgba(217, 174, 0, 0.18));
}

.m-btn--primary:hover {
  border-color: rgba(254, 218, 21, 0.80);
  background: linear-gradient(135deg,
      rgba(254, 218, 21, 0.30),
      rgba(217, 174, 0, 0.30));
}

.m-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.letter-canvasWrap {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

#mCanvas {
  width: 300px;
  height: 300px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.03);
}

/* ---- Editorial hero subtitle ---- */

.hero-subtitleEditorial {
  margin-top: 14px;
  padding-left: 18px;
  position: relative;
  max-width: 820px;
}

/* vertical accent line */
.hero-subtitleEditorial::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 3px;
  height: calc(100% - 8px);
  background: linear-gradient(180deg,
      rgba(14, 165, 233, 0.9),
      rgba(37, 99, 235, 0.4));
  border-radius: 3px;
}

/* per-script accent */
.script-sinhala .hero-subtitleEditorial::before {
  background: linear-gradient(180deg, #941E32, #7A1829);
}

.script-tamil .hero-subtitleEditorial::before {
  background: linear-gradient(180deg, #DF7500, #B85F00);
}

.script-devanagari .hero-subtitleEditorial::before {
  background: linear-gradient(180deg, #0ea5e9, #2563eb);
}

.script-brahmi .hero-subtitleEditorial::before {
  background: linear-gradient(180deg, #a855f7, #7c3aed);
}

.script-tamilbrahmi .hero-subtitleEditorial::before {
  background: linear-gradient(180deg, #14b8a6, rgba(34, 197, 94, 0.40));
}

/* typography */
.hero-lead {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
}

.hero-body {
  margin: 0 0 10px;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.82);
}

.hero-action {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(226, 232, 240, 0.75);
  font-style: italic;
}

/* --- Sinhala variant toggles --- */

.variant-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.variant-btn {
  position: relative;

  border: 1px solid rgba(208, 215, 226, 0.9);
  background: rgba(255, 255, 255, 0.75);
  color: #111827;

  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1;

  cursor: pointer;
  user-select: none;
}

.variant-btn:hover {
  border-color: rgba(254, 218, 21, 0.85);
  box-shadow: 0 0 0 2px rgba(254, 218, 21, 0.16);
}

.variant-btn.is-active {
  border-color: rgba(254, 218, 21, 0.95);
  background: rgba(254, 218, 21, 0.9);
  color: #1b2533;
  font-weight: 700;
}

/* tooltip (desktop) */
.variant-btn::after,
.variant-link::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);

  max-width: min(520px, 92vw);
  width: max-content;

  background: #012947;
  border: 1px solid rgba(255, 255, 255, 0.12);

  color: rgba(226, 232, 240, 0.95);
  padding: 10px 12px;
  border-radius: 8px;

  font-size: 0.82rem;
  line-height: 1.45;
  text-align: left;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;

  opacity: 0;
  pointer-events: none;
  white-space: pre-line;
  z-index: 1000;

  transform: translateX(-50%) translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease;

  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.variant-btn::before,
.variant-link::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);

  border-width: 7px 7px 0 7px;
  border-style: solid;
  border-color: #012947 transparent transparent transparent;

  opacity: 0;
  pointer-events: none;
  z-index: 999;

  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
  transition: opacity 0.15s ease;
}

.variant-btn:hover::after,
.variant-btn:hover::before,
.variant-link:hover::after,
.variant-link:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* status line */
.variant-status {
  margin: 10px 0 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.86);
  font-size: 0.95rem;
}

.variant-link {
  position: relative;

  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.9);

  border-radius: 999px;
  padding: 6px 12px;
  margin-left: 10px;
  font-size: 12px;
  font-weight: 500;

  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.variant-link:hover {
  border-color: var(--gold);
  color: #ffffff;
  background: rgba(254, 218, 21, 0.08);
}

.variant-link.is-active {
  border-style: solid;
  border-color: rgba(254, 218, 21, 0.95);
  background: rgba(254, 218, 21, 0.85);
  color: #1b2533;
  font-weight: 700;
}

.variant-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.variant-divider {
  width: 1px;
  height: 40px;
  background: linear-gradient(180deg,
      transparent,
      rgba(55, 65, 81, 0.35),
      transparent);
}

.learn-hidden--search,
.learn-hidden--variant {
  display: none !important;
}

.learn-dimmed {
  opacity: .35;
  filter: grayscale(0.25);
  pointer-events: none;
}

/* mobile */
@media (max-width: 520px) {
  .hero-subtitleEditorial {
    padding-left: 14px;
  }

  .hero-lead {
    font-size: 1rem;
  }

  .learn-glyph {
    font-size: 20px;
  }

  .learn-roman {
    font-size: 20px;
  }

  .variant-btn {
    padding: 9px 12px;
  }

  /* disable hover tooltips on mobile */
  .variant-btn::after,
  .variant-btn::before,
  .variant-link::after,
  .variant-link::before{
    display: none !important;
  }
}

@media (max-width: 420px) {
  .letter-pair {
    gap: 10px;
    padding: 8px 12px;
  }

  .letter-glyph {
    font-size: 30px;
  }

  .letter-roman {
    font-size: 30px;
  }
}