/* =========================================================
   Test Mengetik / Typing Speed Test — pelajaransekolahonline.com
   Theme: White base, deep red accent, gold highlight
   ========================================================= */

:root {
  --c-white: #ffffff;
  --c-bg: #fafafa;
  --c-red: #b3122b;
  --c-red-dark: #850e21;
  --c-gold: #c8a34d;
  --c-gold-light: #f4e9d0;
  --c-text: #1c1c1c;
  --c-text-muted: #6b6b6b;
  --c-border: #e7e3db;
  --c-success: #1f8a45;
  --c-success-bg: #e8f6ec;
  --c-error: #b3122b;
  --c-error-bg: #fbe9ec;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
  --max-width: 1100px;

  --font-main: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--c-red); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------- Header ---------------- */
.site-header {
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
}

.brand img { width: 79px; height: 31px; object-fit: contain; }

.nav-test-label {
  display: none;
  font-size: 0.85rem;
  color: var(--c-text-muted);
  border-left: 1px solid var(--c-border);
  padding-left: 12px;
}

@media (min-width: 640px) {
  .nav-test-label { display: inline; }
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 4px;
}

.lang-switcher a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-decoration: none;
}

.lang-switcher a.active {
  background: var(--c-red);
  color: var(--c-white);
}

/* ---------------- Hero ---------------- */
.hero {
  text-align: center;
  padding: 56px 0 32px;
}

.hero-badge {
  display: inline-block;
  background: var(--c-gold-light);
  color: var(--c-red-dark);
  border: 1px solid var(--c-gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.2;
  margin: 0 0 14px;
  font-weight: 800;
}

.hero p {
  max-width: 640px;
  margin: 0 auto;
  color: var(--c-text-muted);
  font-size: 1.05rem;
}

/* ---------------- Panels / Cards ---------------- */
.panel {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  margin: 0 auto 24px;
  max-width: var(--max-width);
}

.panel h2, .panel h3 {
  margin-top: 0;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  background: var(--c-red);
  border-radius: 2px;
  display: inline-block;
}

/* ---------------- Form fields ---------------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--c-text);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font-main);
  background: var(--c-white);
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
  outline: none;
  border-color: var(--c-red);
  box-shadow: 0 0 0 3px rgba(179,18,43,0.12);
}

.field-error {
  color: var(--c-error);
  font-size: 0.8rem;
  margin-top: 6px;
  display: none;
}

.field.has-error input { border-color: var(--c-error); }
.field.has-error .field-error { display: block; }

/* ---------------- Difficulty cards ---------------- */
.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 768px) {
  .difficulty-grid { grid-template-columns: repeat(3, 1fr); }
}

.difficulty-card {
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  background: var(--c-white);
  transition: border-color .15s, transform .15s, box-shadow .15s;
  text-align: left;
}

.difficulty-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.difficulty-card.selected {
  border-color: var(--c-red);
  box-shadow: 0 0 0 3px rgba(179,18,43,0.10);
}

.difficulty-card .badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-gold);
  border: 1px solid var(--c-gold);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}

.difficulty-card h4 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.difficulty-card .sub {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  margin: 0 0 10px;
}

.difficulty-card .desc {
  font-size: 0.88rem;
  color: var(--c-text);
  margin: 0;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
  text-decoration: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--c-red) 0%, var(--c-red-dark) 100%);
  color: var(--c-white);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-gold {
  background: linear-gradient(135deg, var(--c-gold) 0%, #a9843a 100%);
  color: var(--c-white);
}

.btn-gold:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-outline {
  background: var(--c-white);
  color: var(--c-red);
  border: 1.5px solid var(--c-red);
}

.btn-outline:hover:not(:disabled) { background: var(--c-red); color: var(--c-white); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.btn-block { width: 100%; }

/* ---------------- Test info ---------------- */
.test-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
}

.test-info-item .k {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-muted);
  font-weight: 700;
}

.test-info-item .v {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-red);
}

.instruction-box {
  background: var(--c-gold-light);
  border: 1px solid var(--c-gold);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #5c4a1e;
  margin-top: 16px;
}

/* ---------------- Typing test area ---------------- */
#typing-section { display: none; }
#typing-section.active { display: block; }

.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 14px 8px;
}

.stat-box .label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.stat-box .value {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  color: var(--c-red);
  font-family: var(--font-mono);
}

.stat-box.time .value { color: var(--c-gold); }

.passage-wrapper {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
}

#passage-display {
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  line-height: 1.9;
  letter-spacing: 0.2px;
  user-select: none;
  color: #b8b8b8;
  word-break: break-word;
}

#passage-display .char {
  border-bottom: 2px solid transparent;
}

#passage-display .char.correct { color: var(--c-text); }
#passage-display .char.incorrect {
  color: var(--c-error);
  background: var(--c-error-bg);
  border-radius: 2px;
}
#passage-display .char.current {
  border-bottom: 2px solid var(--c-red);
  color: var(--c-text);
}

#typing-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 0;
  width: 0;
}

.press-key-hint {
  text-align: center;
  color: var(--c-text-muted);
  font-size: 0.9rem;
  margin-top: 14px;
}

/* ---------------- Result ---------------- */
#result-section { display: none; }
#result-section.active { display: block; }

.result-card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  text-align: center;
}

.result-card .brand-strip {
  background: linear-gradient(135deg, var(--c-red) 0%, var(--c-red-dark) 100%);
  color: var(--c-white);
  padding: 14px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.result-card .body { padding: 28px; }

.result-card .headline { font-size: 0.85rem; color: var(--c-text-muted); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }

.result-hero {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 14px 0 22px;
}

.result-hero .metric .num {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--c-red);
  line-height: 1;
  font-family: var(--font-mono);
}

.result-hero .metric .lab {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-top: 4px;
}

.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  border-top: 1px dashed var(--c-border);
  border-bottom: 1px dashed var(--c-border);
  padding: 18px 0;
  margin-bottom: 18px;
}

.result-details .row { display: flex; justify-content: space-between; font-size: 0.88rem; }
.result-details .row .k { color: var(--c-text-muted); }
.result-details .row .v { font-weight: 700; }

.status-pill {
  display: inline-block;
  padding: 8px 22px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.05em;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.status-pill.pass { background: var(--c-success-bg); color: var(--c-success); }
.status-pill.fail { background: var(--c-error-bg); color: var(--c-error); }

.benchmark-note {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  font-style: italic;
  margin-bottom: 4px;
}

.cta-message { font-size: 0.95rem; margin: 14px 0; }

/* ---------------- Certificate ---------------- */
#certificate-section { display: none; margin-top: 24px; }
#certificate-section.active { display: block; }

.certificate {
  max-width: 720px;
  margin: 0 auto;
  background: var(--c-white);
  border: 3px solid var(--c-gold);
  border-radius: var(--radius);
  padding: 40px 30px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-md);
}

.certificate::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--c-gold-light);
  border-radius: 8px;
  pointer-events: none;
}

.certificate .cert-domain {
  color: var(--c-red);
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.certificate .cert-title {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.certificate .cert-subtitle {
  color: var(--c-gold);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.certificate .cert-intro { color: var(--c-text-muted); font-size: 0.9rem; }

.certificate .cert-name {
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  font-weight: 800;
  color: var(--c-red-dark);
  margin: 8px 0 8px;
  font-family: "Georgia", serif;
}

.certificate .cert-for { color: var(--c-text-muted); font-size: 0.9rem; margin-bottom: 22px; }
.certificate .cert-test-name { font-weight: 700; }

.certificate .cert-perf {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 24px;
}

.certificate .cert-perf .num { font-size: 1.8rem; font-weight: 800; color: var(--c-red); font-family: var(--font-mono); }
.certificate .cert-perf .lab { font-size: 0.72rem; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.certificate .cert-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 440px;
  margin: 0 auto 20px;
  font-size: 0.82rem;
  text-align: left;
}

.certificate .cert-meta .row { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--c-border); padding-bottom: 4px; }
.certificate .cert-meta .k { color: var(--c-text-muted); }
.certificate .cert-meta .v { font-weight: 700; }

.certificate .cert-id {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 16px;
}

.certificate .cert-footer {
  border-top: 1px solid var(--c-gold-light);
  padding-top: 14px;
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.certificate .cert-footer a { color: var(--c-red); font-weight: 600; }

/* ---------------- SEO content ---------------- */
.seo-section h2 {
  font-size: 1.25rem;
  margin: 28px 0 10px;
}
.seo-section h2:first-child { margin-top: 0; }
.seo-section p { color: var(--c-text-muted); margin: 0 0 6px; }

/* ---------------- Footer ---------------- */
.site-footer {
  background: var(--c-white);
  border-top: 1px solid var(--c-border);
  padding: 28px 0;
  margin-top: 40px;
  font-size: 0.85rem;
  color: var(--c-text-muted);
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--c-text-muted); }

.footer-powered { text-align: center; margin-top: 16px; font-size: 0.8rem; }
.footer-powered a { color: var(--c-red); font-weight: 700; }

/* ---------------- Ad interstitial modal ---------------- */
.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.ad-overlay.active { display: flex; }

.ad-modal {
  background: var(--c-white);
  border-radius: var(--radius);
  max-width: 460px;
  width: 100%;
  padding: 18px;
  text-align: center;
  position: relative;
}

.ad-slot-label {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.ad-container {
  min-height: 250px;
  background: var(--c-bg);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  overflow: hidden;
}

.ad-close-btn {
  background: var(--c-red);
  color: var(--c-white);
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
}

.ad-close-btn:disabled { background: var(--c-border); color: var(--c-text-muted); cursor: not-allowed; }

/* ---------------- Utility ---------------- */
.text-center { text-align: center; }
.hidden { display: none !important; }
.mt-16 { margin-top: 16px; }

@media (max-width: 480px) {
  .stats-bar { gap: 8px; }
  .result-hero { gap: 20px; }
  .certificate { padding: 28px 16px; }
  .certificate .cert-meta { grid-template-columns: 1fr; }
}
