/* ============================================
   HAIS-Q — Kesadaran Keamanan Informasi
   Design tokens
   ============================================ */
:root {
  /* Palette — deep ink + warm accent, quiet cream ground */
  --ink: #14202b;
  --ink-2: #2b3947;
  --ink-3: #566574;
  --muted: #8a97a5;
  --line: #dfe4ea;
  --line-soft: #eef1f4;
  --cream: #faf7f2;
  --paper: #ffffff;
  --accent: #c25a3c;       /* warm burnt sienna, used sparingly */
  --accent-deep: #8f3d24;
  --focus-ring: #14202b33;

  /* Category colors (NJI) */
  --cat-sb: #2e7d32;   /* Sangat Baik   */
  --cat-b:  #689f38;   /* Baik          */
  --cat-kb: #f9a825;   /* Kurang Baik   */
  --cat-tb: #ef6c00;   /* Tidak Baik    */
  --cat-stb: #c62828;  /* Sangat Tidak Baik */

  /* Typography */
  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Rhythm */
  --step-1: 0.25rem;
  --step-2: 0.5rem;
  --step-3: 0.75rem;
  --step-4: 1rem;
  --step-5: 1.5rem;
  --step-6: 2rem;
  --step-7: 3rem;
  --step-8: 4rem;
  --step-9: 6rem;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
}

/* ============================================
   Reset + base
   ============================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ============================================
   Layout containers
   ============================================ */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--step-5);
}
.container.narrow {
  max-width: 680px;
}

.section {
  display: none;
  min-height: 100vh;
  padding: var(--step-8) 0 var(--step-9);
}
.section.active { display: block; }

/* ============================================
   Typography
   ============================================ */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 5.5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 var(--step-5);
  color: var(--ink);
}
.display em {
  font-style: italic;
  color: var(--accent);
}
.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.1;
  margin: 0 0 var(--step-3);
}
.eyebrow, .section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--step-4);
  display: block;
}
.section-label {
  color: var(--ink-3);
}
.lead {
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 var(--step-6);
  max-width: 60ch;
}
.page-sub {
  color: var(--ink-3);
  margin: 0 0 var(--step-6);
  max-width: 60ch;
}

/* ============================================
   Welcome / Hero
   ============================================ */
.hero { margin-bottom: var(--step-6); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--step-6);
}
.info-cell {
  background: var(--paper);
  padding: var(--step-5) var(--step-4);
  text-align: left;
}
.info-value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1;
  color: var(--ink);
  margin-bottom: var(--step-2);
}
.info-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
@media (max-width: 600px) {
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}

.notice {
  background: var(--paper);
  border-left: 3px solid var(--accent);
  padding: var(--step-4) var(--step-5);
  margin-bottom: var(--step-6);
  color: var(--ink-2);
  font-size: 0.95rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.notice strong { color: var(--ink); }

.page-footer {
  margin-top: var(--step-8);
  padding-top: var(--step-5);
  border-top: 1px solid var(--line);
}
.footer-line {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--paper); border-color: var(--ink-3); }

.btn.primary:disabled,
.btn.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn .arrow, .btn .arrow-back { font-size: 1.1em; line-height: 1; }

.actions {
  display: flex;
  gap: var(--step-3);
  margin-top: var(--step-6);
}
.actions.between { justify-content: space-between; }
.actions.center { justify-content: center; flex-wrap: wrap; }

/* ============================================
   Form (demographics)
   ============================================ */
.section-header { margin-bottom: var(--step-6); }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--step-4);
  background: var(--paper);
  padding: var(--step-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}
.field { display: flex; flex-direction: column; gap: var(--step-2); }
.field.span-2 { grid-column: span 2; }
.field-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-2);
}
.field input,
.field select {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field input:invalid:not(:placeholder-shown),
.field select:invalid.dirty {
  border-color: #c62828;
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; padding: var(--step-4); }
  .field.span-2 { grid-column: span 1; }
}

/* ============================================
   Questionnaire — top bar
   ============================================ */
.q-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  padding: var(--step-4) 0;
  margin-bottom: var(--step-6);
  backdrop-filter: blur(8px);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--step-5);
  flex-wrap: wrap;
}
.topbar-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--ink);
  margin-top: var(--step-1);
}
.topbar-progress { min-width: 260px; }
.progress-text {
  font-size: 0.85rem;
  color: var(--ink-3);
  margin-bottom: var(--step-2);
  text-align: right;
}
.progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

/* ============================================
   Questionnaire — scale legend
   ============================================ */
.q-scale-legend {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--step-3) var(--step-4);
  margin-bottom: var(--step-5);
}
.scale-legend-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--step-2);
}
.scale-legend-items {
  display: flex;
  gap: var(--step-4);
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.scale-legend-items b {
  color: var(--ink);
  font-family: var(--font-mono);
  margin-right: 0.35rem;
}

/* ============================================
   Questionnaire — sub-area cards
   ============================================ */
.sub-area {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--step-5) var(--step-6);
  margin-bottom: var(--step-4);
}
.sub-area-header {
  display: flex;
  align-items: baseline;
  gap: var(--step-3);
  padding-bottom: var(--step-4);
  margin-bottom: var(--step-4);
  border-bottom: 1px solid var(--line-soft);
}
.sub-area-index {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 3ch;
}
.sub-area-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--ink);
  margin: 0;
  font-weight: 400;
}

.question {
  display: grid;
  grid-template-columns: 100px 1fr 320px;
  gap: var(--step-4);
  align-items: center;
  padding: var(--step-3) 0;
}
.question + .question {
  border-top: 1px dashed var(--line-soft);
}
.q-dim {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.q-dim .q-dim-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  background: var(--line-soft);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  width: fit-content;
}
.q-text {
  color: var(--ink);
  line-height: 1.55;
  font-size: 0.98rem;
}

.likert {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.likert input { position: absolute; opacity: 0; pointer-events: none; }
.likert label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink-3);
  transition: all 0.12s;
  user-select: none;
}
.likert label:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}
.likert input:checked + label {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}
.likert input:focus-visible + label {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.question.unanswered .likert label {
  border-color: var(--accent);
  border-style: dashed;
}
.question.unanswered .likert label:has(+*),
.question.unanswered .likert input:checked + label {
  border-style: solid;
}

@media (max-width: 900px) {
  .question {
    grid-template-columns: 1fr;
    gap: var(--step-3);
    padding: var(--step-4) 0;
  }
  .q-dim { flex-direction: row; align-items: center; }
  .sub-area { padding: var(--step-4); }
}

.q-nav { margin-top: var(--step-6); margin-bottom: var(--step-6); }

/* ============================================
   Results
   ============================================ */
.results-header { text-align: center; margin-bottom: var(--step-7); }
.results-header .display { margin-bottom: var(--step-3); }
.results-header .page-sub { margin-left: auto; margin-right: auto; }

.total-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--step-7);
  text-align: center;
  margin-bottom: var(--step-8);
  position: relative;
  overflow: hidden;
}
.total-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--total-color, var(--accent));
}
.total-card-inner { max-width: 500px; margin: 0 auto; }
.total-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--step-4);
}
.total-score {
  font-family: var(--font-display);
  font-size: clamp(5rem, 12vw, 7rem);
  line-height: 1;
  color: var(--ink);
  margin-bottom: var(--step-3);
  letter-spacing: -0.02em;
}
.total-category {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 100px;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  background: var(--total-color, var(--accent));
  margin-bottom: var(--step-4);
}
.total-desc {
  color: var(--ink-3);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 46ch;
  margin: 0 auto;
}

.results-section-title {
  margin: var(--step-8) 0 var(--step-5);
  border-top: 1px solid var(--line);
  padding-top: var(--step-6);
}
.results-section-title h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.75rem;
  margin: 0 0 var(--step-2);
}
.results-section-title p {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.95rem;
}

.focus-results {
  display: grid;
  gap: var(--step-3);
}
.focus-row {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--step-4) var(--step-5);
  display: grid;
  grid-template-columns: 60px 1fr 200px 90px 130px;
  gap: var(--step-4);
  align-items: center;
}
.focus-row-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  letter-spacing: 0.08em;
}
.focus-row-name {
  font-weight: 500;
  color: var(--ink);
}
.focus-row-bar {
  height: 8px;
  background: var(--line);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
.focus-row-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s ease;
}
.focus-row-score {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}
.focus-row-cat {
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  color: white;
  font-weight: 500;
  text-align: center;
  width: fit-content;
  justify-self: end;
}
@media (max-width: 800px) {
  .focus-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "code cat"
      "name score"
      "bar bar";
    gap: var(--step-2) var(--step-3);
  }
  .focus-row-code { grid-area: code; }
  .focus-row-name { grid-area: name; }
  .focus-row-bar { grid-area: bar; margin-top: var(--step-2); }
  .focus-row-score { grid-area: score; }
  .focus-row-cat { grid-area: cat; }
}

.kab-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--step-4);
}
.kab-cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--step-5);
  text-align: center;
}
.kab-cell-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--step-2);
}
.kab-cell-dim {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: var(--step-4);
}
.kab-cell-score {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  color: var(--ink);
  margin-bottom: var(--step-3);
}
.kab-cell-cat {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  border-radius: 100px;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
}
@media (max-width: 700px) {
  .kab-grid { grid-template-columns: 1fr; }
}

.nji-table {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.nji-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: var(--step-4);
  padding: var(--step-3) var(--step-5);
  border-top: 1px solid var(--line-soft);
  align-items: center;
  position: relative;
}
.nji-row:first-child { border-top: none; }
.nji-row.header-row {
  background: var(--line-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: var(--step-3) var(--step-5);
}
.nji-row:not(.header-row) div:last-child {
  padding-left: var(--step-4);
  border-left: 4px solid var(--c);
  font-weight: 500;
}

/* ============================================
   Print
   ============================================ */
@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .q-topbar, .section:not(.active) { display: none; }
  .section.active { padding: 0; }
  .total-card, .focus-row, .kab-cell, .nji-table {
    box-shadow: none;
    break-inside: avoid;
  }
}
