/* =========================================================
   Tema Etnik Melayu Langkat — Hijau Zamrud & Kuning Emas Diraja
   ========================================================= */

:root {
  --bg-parchment: #faf7ec;
  --bg-parchment-deep: #efe7ce;
  --bg-card: #fffef9;
  --ink-sogan: #0c3327;
  --ink-brown: #2a5445;
  --ink-muted: #527065;
  --accent-terracotta: #0f4c3a;
  --accent-terracotta-dark: #093528;
  --accent-gold: #d4a017;
  --accent-gold-light: #f2d57e;
  --accent-gold-soft: #fbf1cf;
  --accent-indigo: #1a5276;
  --accent-jade: #0f6b4a;
  --accent-crimson: #9b2626;
  --border-ethnic: #d8c27a;
  --shadow-warm: 0 14px 36px rgba(12, 51, 39, 0.1);
  --shadow-card: 0 8px 24px rgba(12, 51, 39, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink-sogan);
  background-color: var(--bg-parchment);
  /* Motif Songket Tampuk Manggis & Bintang Melayu halus sebagai latar */
  background-image:
    radial-gradient(circle at 50% 0%, rgba(212, 160, 23, 0.16), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='68' height='68' viewBox='0 0 68 68'%3E%3Cg fill='none' stroke='%230f4c3a' stroke-opacity='0.065' stroke-width='1'%3E%3Cpath d='M34 6L42 26L62 34L42 42L34 62L26 42L6 34L26 26Z'/%3E%3Ccircle cx='34' cy='34' r='4' fill='%23d4a017' fill-opacity='0.11' stroke='none'/%3E%3Ccircle cx='34' cy='6' r='1.6' fill='%230f4c3a' fill-opacity='0.1' stroke='none'/%3E%3Ccircle cx='6' cy='34' r='1.6' fill='%230f4c3a' fill-opacity='0.1' stroke='none'/%3E%3C/g%3E%3C/svg%3E");
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(196, 146, 53, 0.2);
}

/* Ornamen Pita Pucuk Rebung & Lebah Bergantung Khas Melayu Langkat */
.tumpal-strip {
  width: 100%;
  height: 20px;
  background-color: var(--accent-terracotta-dark);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='20' viewBox='0 0 40 20'%3E%3Cpolygon points='20,2 38,20 2,20' fill='%230f4c3a'/%3E%3Cpolygon points='20,6 31,20 9,20' fill='%23d4a017'/%3E%3Cpolygon points='20,12 25,20 15,20' fill='%23093528'/%3E%3Ccircle cx='20' cy='3.5' r='1.6' fill='%23f2d57e'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 40px 20px;
  border-bottom: 2.5px solid var(--accent-gold);
}

.tumpal-bottom {
  margin-top: auto;
  transform: scaleY(-1);
  border-bottom: 2px solid var(--accent-gold);
}

.page-wrapper {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(1.4rem, 3.5vw, 2.5rem) max(1.25rem, env(safe-area-inset-right)) clamp(2rem, 4vw, 3rem) max(1.25rem, env(safe-area-inset-left));
  flex: 1;
}

/* ========================
   Header
   ======================== */
.hero-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.emblem-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  color: var(--accent-terracotta);
  margin-bottom: 0.6rem;
}

.emblem-svg {
  width: 58px;
  height: 58px;
}

.hero-kicker {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-terracotta);
}

.hero-title {
  margin: 0.3rem 0 0.25rem;
  font-family: "Cinzel", "Playfair Display", Georgia, serif;
  font-size: clamp(1.85rem, 4.5vw, 2.55rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-sogan);
  line-height: 1.15;
}

.hero-subtitle {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-brown);
}

/* Garis Pemisah Ornamen Nusantara */
.ornament-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.25rem auto 0;
  max-width: 280px;
}

.ornament-divider--compact {
  margin: 1.5rem auto;
  max-width: 220px;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

.divider-diamond {
  width: 8px;
  height: 8px;
  background: var(--accent-terracotta);
  transform: rotate(45deg);
  flex-shrink: 0;
}

.divider-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-gold);
  flex-shrink: 0;
}

/* ========================
   Kartu Etnik (Bingkai)
   ======================== */
.ethnic-card {
  position: relative;
  background: var(--bg-card);
  border: 1.5px solid var(--border-ethnic);
  border-radius: var(--radius-lg);
  padding: 2rem 1.85rem;
  box-shadow: var(--shadow-warm);
  margin-bottom: 1.5rem;
}

.ethnic-card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(196, 146, 53, 0.35);
  border-radius: calc(var(--radius-lg) - 5px);
  pointer-events: none;
}

/* Sudut Ornamen Siku */
.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent-gold);
  border-style: solid;
  pointer-events: none;
}

.corner-tl {
  top: 10px;
  left: 10px;
  border-width: 2.5px 0 0 2.5px;
  border-top-left-radius: 4px;
}

.corner-tr {
  top: 10px;
  right: 10px;
  border-width: 2.5px 2.5px 0 0;
  border-top-right-radius: 4px;
}

.corner-bl {
  bottom: 10px;
  left: 10px;
  border-width: 0 0 2.5px 2.5px;
  border-bottom-left-radius: 4px;
}

.corner-br {
  bottom: 10px;
  right: 10px;
  border-width: 0 2.5px 2.5px 0;
  border-bottom-right-radius: 4px;
}

.card-heading {
  margin: 0 0 0.25rem;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.35rem;
  color: var(--ink-sogan);
}

.card-desc {
  margin: 0 0 1.5rem;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

/* ========================
   Form Pencarian
   ======================== */
.form-group {
  margin-bottom: 1.35rem;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-sogan);
  margin-bottom: 0.65rem;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--accent-terracotta);
  color: #fffaf0;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Grid Pilihan Kelas */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 0.65rem;
}

.class-btn {
  appearance: none;
  border: 1.5px solid var(--border-ethnic);
  background: var(--bg-parchment);
  color: var(--ink-sogan);
  border-radius: var(--radius-md);
  min-height: 54px;
  padding: 0.75rem 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}

.class-btn .class-sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.class-btn:hover {
  border-color: var(--accent-gold);
  background: var(--accent-gold-soft);
  transform: translateY(-1px);
}

.class-btn:focus-visible {
  outline: 2.5px solid var(--accent-gold);
  outline-offset: 2px;
}

.class-btn.is-active {
  background: linear-gradient(145deg, var(--accent-terracotta), var(--accent-terracotta-dark));
  border-color: var(--accent-gold);
  color: #fffdf2;
  box-shadow: 0 6px 16px rgba(15, 76, 58, 0.28);
}

.class-btn.is-active .class-sub {
  color: var(--accent-gold-light);
}

/* Input NISN */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.nisn-input {
  width: 100%;
  padding: 0.9rem 2.75rem 0.9rem 1rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-sogan);
  background: #fffcf6;
  border: 1.5px solid var(--border-ethnic);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nisn-input::placeholder {
  color: #b19884;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.nisn-input:focus {
  outline: none;
  border-color: var(--accent-terracotta);
  box-shadow: 0 0 0 3.5px rgba(196, 146, 53, 0.22);
}

.clear-btn {
  position: absolute;
  right: 0.65rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-parchment-deep);
  color: var(--ink-brown);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.clear-btn:hover {
  background: var(--accent-gold-light);
}

.clear-btn[hidden] {
  display: none;
}

/* Feedback Error */
.feedback-box {
  margin-bottom: 1.15rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: #fdf1f0;
  border: 1px solid #e5b7b4;
  border-left: 4px solid var(--accent-crimson);
  color: var(--accent-crimson);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Tombol Utama */
.btn-primary {
  width: 100%;
  padding: 0.95rem 1.4rem;
  border: 1.5px solid var(--accent-gold);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-terracotta-dark) 0%, var(--accent-terracotta) 65%, #16664e 100%);
  color: #fffdf2;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  box-shadow: 0 8px 20px rgba(12, 51, 39, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 76, 58, 0.3);
  filter: brightness(1.06);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ========================
   Kartu Hasil Nilai (Piagam)
   ======================== */
.result-card {
  animation: fadeSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-banner {
  text-align: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--border-ethnic);
}

.result-banner-label {
  margin: 0 0 0.3rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-gold);
}

.result-student-name {
  margin: 0 0 0.85rem;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.25rem, 3.8vw, 1.8rem);
  color: var(--ink-sogan);
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: break-word;
}

.result-meta-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--bg-parchment);
  border: 1px solid var(--border-ethnic);
  font-size: 0.84rem;
  color: var(--ink-sogan);
}

.meta-key {
  color: var(--ink-muted);
  font-weight: 500;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* Medali Nilai */
.score-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 1.5rem 0.5rem 0.25rem;
}

.medallion-wrap {
  position: relative;
  width: 146px;
  height: 146px;
  flex-shrink: 0;
}

.score-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: var(--bg-parchment);
  stroke: var(--accent-gold-soft);
  stroke-width: 9;
}

.ring-progress {
  fill: none;
  stroke: var(--accent-terracotta);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 364.42;
  stroke-dashoffset: 364.42;
  transition: stroke-dashoffset 0.85s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease;
}

.medallion-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.medallion-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.medallion-value {
  font-family: "Cinzel", Georgia, serif;
  font-size: 2.45rem;
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink-sogan);
  margin: 0.1rem 0;
}

.medallion-max {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.score-summary {
  max-width: 300px;
}

.predikat-badge {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.55rem;
}

.predikat-sangat-baik {
  background: #e3f3ec;
  color: var(--accent-jade);
  border: 1px solid #a8d5c2;
}

.predikat-baik {
  background: #e5eff5;
  color: var(--accent-indigo);
  border: 1px solid #b4ccd9;
}

.predikat-cukup {
  background: var(--accent-gold-soft);
  color: #7c5412;
  border: 1px solid var(--accent-gold-light);
}

.predikat-bimbingan {
  background: #fdf1f0;
  color: var(--accent-crimson);
  border: 1px solid #e5b7b4;
}

.score-note {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-brown);
}

/* Rincian Komponen Skor */
.breakdown-title {
  margin: 0 0 0.95rem;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.08rem;
  color: var(--ink-sogan);
  text-align: center;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.breakdown-item {
  background: var(--bg-parchment);
  border: 1px solid var(--border-ethnic);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
}

.breakdown-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.breakdown-code {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-terracotta);
  display: block;
}

.breakdown-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-sogan);
}

.breakdown-score {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-sogan);
  white-space: nowrap;
}

.breakdown-score small {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-parchment-deep);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-terracotta), var(--accent-gold));
  transition: width 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Tombol Aksi Hasil */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.65rem;
}

.btn-secondary,
.btn-ghost {
  padding: 0.72rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.18s ease;
}

.btn-secondary {
  background: var(--accent-gold-soft);
  border: 1.5px solid var(--accent-gold);
  color: var(--ink-sogan);
}

.btn-secondary:hover {
  background: var(--accent-gold-light);
}

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border-ethnic);
  color: var(--ink-brown);
}

.btn-ghost:hover {
  background: var(--bg-parchment);
  border-color: var(--ink-brown);
}

/* ========================
   Responsif (HP, Tablet & Desktop)
   ======================== */
@media (hover: none) {
  .class-btn:hover,
  .btn-primary:hover {
    transform: none;
  }
}

/* Tablet & layar menengah */
@media (max-width: 768px) {
  .page-wrapper {
    max-width: 680px;
  }

  .score-showcase {
    gap: 1.35rem;
  }
}

/* Ponsel standar */
@media (max-width: 640px) {
  .page-wrapper {
    padding: 1.35rem max(0.95rem, env(safe-area-inset-right)) 2rem max(0.95rem, env(safe-area-inset-left));
  }

  .hero-header {
    margin-bottom: 1.35rem;
  }

  .emblem-wrap,
  .emblem-svg {
    width: 48px;
    height: 48px;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .ethnic-card {
    padding: 1.45rem 1.15rem;
    border-radius: 15px;
  }

  .card-heading {
    font-size: 1.22rem;
  }

  .card-desc {
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
  }

  .class-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .nisn-input {
    font-size: 1rem; /* Mencegah auto-zoom di iOS Safari */
    min-height: 48px;
  }

  .btn-primary {
    min-height: 48px;
  }

  .score-showcase {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1.25rem 0.25rem 0.25rem;
  }

  .score-summary {
    max-width: 100%;
  }

  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .result-actions {
    flex-direction: column;
    margin-top: 1.35rem;
  }

  .btn-secondary,
  .btn-ghost {
    justify-content: center;
    width: 100%;
    min-height: 46px;
  }
}

/* Ponsel layar kecil (320px - 380px) */
@media (max-width: 380px) {
  .page-wrapper {
    padding: 1.1rem 0.7rem 1.75rem;
  }

  .ethnic-card {
    padding: 1.25rem 0.95rem;
  }

  .ethnic-card::before {
    inset: 4px;
  }

  .corner {
    width: 14px;
    height: 14px;
  }

  .medallion-wrap {
    width: 128px;
    height: 128px;
  }

  .medallion-value {
    font-size: 2.1rem;
  }

  .meta-pill {
    font-size: 0.78rem;
    padding: 0.3rem 0.65rem;
  }

  .breakdown-head {
    flex-wrap: wrap;
    row-gap: 0.2rem;
  }
}

/* Layar lebar / desktop */
@media (min-width: 1024px) {
  .page-wrapper {
    max-width: 780px;
  }

  .ethnic-card {
    padding: 2.25rem 2.15rem;
  }
}

/* Preferensi kurangi animasi */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================
   Mode Cetak / Simpan PDF
   ======================== */
@media print {
  body {
    background: #ffffff !important;
  }

  .no-print,
  .search-card,
  .tumpal-bottom {
    display: none !important;
  }

  .page-wrapper {
    padding: 0.75rem 0;
    max-width: 100%;
  }

  .ethnic-card {
    box-shadow: none;
    border-color: #bfa57a;
    break-inside: avoid;
  }
}
