/* ==========================================================================
   CR BANK SOALAN MATEMATIK — GAYA PAPARAN AWAM PELAJAR (KEMASAN AKHIR)
   Tema: Midnight Navy Gelap, Emas Metalik & Fotografi Mercu Tanda Negeri HD
   ========================================================================== */

:root {
  --cr-navy-deep: #030712;
  --cr-navy-card: #050b18;
  --cr-navy-surface: #0a1329;
  --cr-navy-border: #132347;
  
  --cr-gold-light: #fff3c4;
  --cr-gold-mid: #d4af37;
  --cr-gold-dark: #8c6209;
  --cr-gold-glow: rgba(212, 175, 55, 0.28);
  
  --cr-blue-btn: #1877f2;
  --cr-blue-btn-dark: #0c4bb0;
  --cr-emerald-btn: #059669;
  --cr-emerald-btn-dark: #046a4a;
  --cr-garnet-btn: #dc2626;
  --cr-garnet-btn-dark: #991b1b;
  --cr-amber-btn: #d97706;
  --cr-amber-btn-dark: #92400e;
  
  --cr-radius-card: 24px;
  --cr-radius-btn: 12px;
}

.cr-math-wrapper {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 0 40px;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f1f5f9;
  box-sizing: border-box;
}

.cr-math-wrapper * {
  box-sizing: border-box;
}

/* ==========================================================================
   BARISAN PENAPIS & CARIAN
   ========================================================================== */

.cr-math-wrapper .cr-math-filter-bar {
  background: rgba(8, 15, 33, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 175, 55, 0.15);
  flex-wrap: wrap;
}

.cr-math-wrapper .cr-math-search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.cr-math-wrapper .cr-math-search-input {
  width: 100%;
  background: rgba(4, 8, 20, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 10px;
  padding: 10px 14px 10px 38px;
  color: #ffffff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.cr-math-wrapper .cr-math-search-input:focus {
  border-color: var(--cr-gold-mid);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

.cr-math-wrapper .cr-math-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cr-gold-mid);
  font-size: 14px;
}

.cr-math-wrapper .cr-math-filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cr-math-wrapper .cr-math-select {
  background: rgba(4, 8, 20, 0.92);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
  color: #f1f5f9;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.cr-math-wrapper .cr-math-select:focus {
  border-color: var(--cr-gold-mid);
}

.cr-math-wrapper .cr-math-count-badge {
  font-size: 12.5px;
  color: #cbd5e1;
  font-weight: 600;
  padding: 8px 14px;
  background: rgba(20, 35, 75, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
}

/* ==========================================================================
   GRID RESPONSIF KAD
   Komputer: 3 kad sebaris | Tablet: 2 kad | Telefon: 1 kad
   ========================================================================== */

.cr-math-wrapper .cr-math-grid-container {
  width: 100%;
}

.cr-math-wrapper .cr-math-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 1080px) {
  .cr-math-wrapper .cr-math-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .cr-math-wrapper .cr-math-cards-grid {
    grid-template-columns: 1fr;
  }
  .cr-math-wrapper .cr-math-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .cr-math-wrapper .cr-math-search-box {
    min-width: 100%;
  }
  .cr-math-wrapper .cr-math-filter-group {
    justify-content: space-between;
  }
}

/* ==========================================================================
   ANATOMI REKA BENTUK KAD PREMIUM
   ========================================================================== */

.cr-math-card {
  position: relative;
  background: var(--cr-navy-card);
  border-radius: var(--cr-radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  
  /* Bingkai Emas Metalik Berkilat */
  border: 1.5px solid rgba(212, 175, 55, 0.55);
  box-shadow: 
    0 0 22px var(--cr-gold-glow),
    0 16px 36px rgba(0, 0, 0, 0.75),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), 
              box-shadow 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 0.3s ease;
}

.cr-math-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 235, 150, 0.85);
  box-shadow: 
    0 0 32px rgba(212, 175, 55, 0.42),
    0 22px 48px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* ZON ATAS KAD (HEADER & MERCU TANDA HD) */
.cr-math-card-header {
  position: relative;
  height: 205px;
  padding: 16px 18px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.cr-math-landmark-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  z-index: 1;
}

.cr-math-header-mask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  background: 
    linear-gradient(90deg, rgba(3, 7, 18, 0.95) 0%, rgba(3, 7, 18, 0.88) 38%, rgba(3, 7, 18, 0.38) 75%, rgba(3, 7, 18, 0.15) 100%),
    linear-gradient(180deg, rgba(3, 7, 18, 0.25) 0%, rgba(3, 7, 18, 0.75) 75%, #050b18 100%);
}

.cr-math-filigree-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 45%;
  bottom: 0;
  z-index: 3;
  opacity: 0.16;
  background-image: radial-gradient(circle at 10% 30%, rgba(212, 175, 55, 0.45) 1px, transparent 1px),
                    radial-gradient(circle at 30% 70%, rgba(212, 175, 55, 0.45) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
}

.cr-math-badges-row {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}

.cr-math-flag-box {
  width: 54px;
  height: 34px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

.cr-math-flag-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cr-math-flag-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cr-math-crest-box {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
}

.cr-math-crest-img {
  max-height: 50px;
  max-width: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
}

.cr-math-crest-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--cr-gold-mid);
  background: radial-gradient(circle, rgba(212, 175, 55, 0.25) 0%, rgba(5, 11, 24, 0.8) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cr-gold-light);
  font-size: 18px;
}

.cr-math-set-pill-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 34px;
}

.cr-math-set-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff7d6;
  background: linear-gradient(135deg, rgba(20, 35, 75, 0.95) 0%, rgba(5, 11, 24, 0.95) 100%);
  border: 1px solid rgba(212, 175, 55, 0.75);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7), inset 0 0 8px rgba(212, 175, 55, 0.25);
  border-radius: 6px;
  padding: 4px 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.cr-math-identity-block {
  position: relative;
  z-index: 4;
  text-align: center;
  margin-top: 2px;
  margin-bottom: 6px;
}

.cr-math-year {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--cr-gold-mid);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.cr-math-state-name {
  font-family: 'Cinzel', 'Times New Roman', Georgia, serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  line-height: 1.15;
  margin: 0;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #fff7d6 25%, #e6c86e 55%, #c59324 80%, #7d5203 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.95));
}

.cr-math-sub-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  letter-spacing: 1px;
  margin: 3px 0 1px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
}

.cr-math-subject-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3.5px;
  margin: 0;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #fef08a 35%, #eab308 70%, #854d0e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.9));
}

/* PEMISAH SWOOSH EMAS METALIK */
.cr-math-swoosh-wrap {
  position: relative;
  width: 100%;
  height: 22px;
  margin-top: -6px;
  z-index: 5;
  overflow: hidden;
}

.cr-math-swoosh-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* DEK EMPAT BUTANG PDF */
.cr-math-buttons-deck {
  position: relative;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 18px 22px;
  background: linear-gradient(180deg, #050b18 0%, #030712 100%);
}

.cr-math-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
  border-radius: var(--cr-radius-btn);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  user-select: none;
}

.cr-math-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.04) 100%);
  border-radius: var(--cr-radius-btn) var(--cr-radius-btn) 0 0;
  pointer-events: none;
}

/* 1: Kertas 1 (Biru Premium) */
.cr-btn-blue {
  background: linear-gradient(180deg, #1877f2 0%, #0c4bb0 100%);
  border-color: rgba(144, 202, 249, 0.45);
  box-shadow: 0 4px 12px rgba(12, 75, 176, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.cr-btn-blue:hover:not(.cr-math-btn-disabled) {
  background: linear-gradient(180deg, #2584ff 0%, #1059ce 100%);
  box-shadow: 0 0 18px rgba(33, 150, 243, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  border-color: rgba(191, 227, 255, 0.75);
}

/* 2: Skema K1 (Hijau Zamrud) */
.cr-btn-emerald {
  background: linear-gradient(180deg, #059669 0%, #046a4a 100%);
  border-color: rgba(110, 231, 183, 0.45);
  box-shadow: 0 4px 12px rgba(4, 106, 74, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.cr-btn-emerald:hover:not(.cr-math-btn-disabled) {
  background: linear-gradient(180deg, #05af7a 0%, #057e58 100%);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  border-color: rgba(167, 243, 208, 0.75);
}

/* 3: Kertas 2 (Merah Garnet) */
.cr-btn-garnet {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  border-color: rgba(254, 165, 165, 0.45);
  box-shadow: 0 4px 12px rgba(153, 27, 27, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.cr-btn-garnet:hover:not(.cr-math-btn-disabled) {
  background: linear-gradient(180deg, #ef3333 0%, #b32121 100%);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  border-color: rgba(254, 202, 202, 0.75);
}

/* 4: Skema K2 (Emas Amber) */
.cr-btn-amber {
  background: linear-gradient(180deg, #d97706 0%, #92400e 100%);
  border-color: rgba(253, 224, 71, 0.45);
  box-shadow: 0 4px 12px rgba(146, 64, 14, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.cr-btn-amber:hover:not(.cr-math-btn-disabled) {
  background: linear-gradient(180deg, #f59e0b 0%, #a64d12 100%);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.65), 0 6px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  border-color: rgba(254, 240, 138, 0.75);
}

.cr-math-btn-icon {
  width: 24px;
  height: 28px;
  flex-shrink: 0;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cr-math-btn-icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.cr-math-btn-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
  text-align: left;
  line-height: 1.15;
}

.cr-math-btn-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.cr-math-btn-sub {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.cr-math-btn-arrow {
  width: 13px;
  height: 13px;
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 2.5;
  fill: none;
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform 0.2s ease, stroke 0.2s ease;
}

.cr-math-btn:hover:not(.cr-math-btn-disabled) .cr-math-btn-arrow {
  transform: translateX(3px);
  stroke: #ffffff;
}

/* Keadaan Pautan Tiada / Kosong */
.cr-math-btn-disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(40%);
  box-shadow: none !important;
}

.cr-math-btn-disabled .cr-math-btn-sub {
  color: rgba(255, 255, 255, 0.5);
}

/* Toast Notifikasi */
.cr-math-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(10, 19, 41, 0.95);
  border: 1px solid var(--cr-gold-mid);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(212, 175, 55, 0.3);
  z-index: 999999;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.cr-math-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.cr-math-toast-icon {
  font-size: 18px;
  color: var(--cr-gold-mid);
}

/* Empty State */
.cr-math-empty-state {
  text-align: center;
  padding: 60px 20px;
  background: rgba(8, 15, 33, 0.65);
  border: 1px dashed rgba(212, 175, 55, 0.3);
  border-radius: 20px;
  grid-column: 1 / -1;
}

.cr-math-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  color: var(--cr-gold-mid);
}

.cr-math-empty-title {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.cr-math-empty-desc {
  font-size: 13.5px;
  color: #94a3b8;
  max-width: 480px;
  margin: 0 auto;
}
