/* ==========================================================
   DISC Personality Test — modern theme
   Signature: the D-I-S-C four-colour strip echoes the classic
   test's own colour coding (Dominance/Influence/Steadiness/
   Compliance) instead of a generic accent gradient.
   ========================================================== */

:root {
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --ink: #1C2130;
  --muted: #667085;
  --border: #E3E6EC;
  --border-strong: #CBD1DC;
  --accent: #3552D6;
  --accent-ink: #2540AD;

  --disc-d: #E15554;   /* Dominance  */
  --disc-i: #E7B531;   /* Influence  */
  --disc-s: #3BA776;   /* Steadiness */
  --disc-c: #3552D6;   /* Compliance */

  --radius: 12px;
  --radius-sm: 8px;

  --font-display: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-body: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 20px 0;
}

header h1 {
  max-width: 1040px;
  margin: 0 auto;
  padding-bottom: 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem);
  letter-spacing: -0.01em;
}

header h1::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  margin-bottom: 14px;
  background: linear-gradient(
    90deg,
    var(--disc-d) 0 25%,
    var(--disc-i) 25% 50%,
    var(--disc-s) 50% 75%,
    var(--disc-c) 75% 100%
  );
}

/* ---------- layout shell ---------- */

#container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 96px;
}

/* ---------- instruction card ---------- */

.info-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  font-size: 0.95rem;
  color: var(--ink);
}

.info-box b {
  font-family: var(--font-display);
  font-size: 1.02rem;
  letter-spacing: 0.02em;
}

.info-box ol {
  margin: 10px 0 12px;
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 6px;
  color: var(--muted);
}

.info-box li::marker {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- table shell (QUIZ page: index.php only) ----------
   Scoped to '#container form table' on purpose. result.php's TALLY
   BOX table is a direct child of #container (no <form> wrapper),
   so these rules can never leak into it — previously they did,
   which is the main reason result.php rendered broken. */

form { display: block; }

#container form table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  table-layout: auto;
}

#container form table,
#container form thead,
#container form tbody {
  display: table;
  width: 100%;
}

#container form thead th {
  background: var(--ink);
  color: #EDEFF5;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid var(--ink);
}

#container form tbody th {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-ink);
  background: #c4cbfb;
  text-align: center;
  vertical-align: middle;
  width: 34px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#container form tbody td {
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

#container form tbody td.first {
  border-left: 3px solid transparent;
}

#container form tbody tr:hover td {
  background: #FAFBFF;
}

#container form tbody tr.dark td,
#container form tbody tr.dark th {
  background-color: #FAFAFC;
}

#container form tbody tr.dark:hover td {
  background: #F5F6FF;
}

/* P / K radio cells */

#container form td:has(input[type="radio"]) {
  text-align: center;
  width: 52px;
}

input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

input[type="radio"]:hover {
  border-color: var(--accent);
}

input[type="radio"]::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.12s ease;
  background: var(--accent);
}

input[type="radio"]:checked::before {
  transform: scale(1);
}

input[type="radio"]:checked {
  border-color: var(--accent);
}

input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* distinguish "Most" (P) vs "Least" (K) columns subtly */
th:nth-of-type(3n) { } /* reserved */

/* ---------- footer / submit ---------- */

tfoot th {
  background: var(--surface);
  padding: 18px 12px;
  border-top: 1px solid var(--border);
}

.btn,
input[type="submit"] {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 12px 32px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover,
input[type="submit"]:hover {
  background: var(--accent-ink);
}

.btn:active,
input[type="submit"]:active {
  transform: scale(0.98);
}

/* ---------- footer ---------- */

footer {
  text-align: center;
  padding: 24px 20px 40px;
  font-size: 0.8rem;
  color: var(--muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ==========================================================
   RESULT page (result.php)
   Selectors below target '.tally-table', '.result-panel',
   '.result-body' and '#graph' — classes added directly in
   result.php (additive only, no PHP data logic touched). This
   replaces the earlier '#container > table' / '#container + div'
   structural guesses, which were fragile and based on rendered
   output rather than source.
   ========================================================== */

.tally-table {
  width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  overflow: hidden;
}

.tally-table caption {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  caption-side: top;
}

.tally-table th {
  background: var(--ink);
  color: #EDEFF5;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px;
  text-align: center;
}

.tally-table td.badge {
  text-align: center;
  padding: 14px 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
}

.tally-table td.badge::before {
  content: attr(data-badge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin-right: 8px;
  font-size: 0.7rem;
  color: #fff;
  vertical-align: middle;
}

.tally-table td[data-badge="D"]::before { background: var(--disc-d); }
.tally-table td[data-badge="I"]::before { background: var(--disc-i); }
.tally-table td[data-badge="S"]::before { background: var(--disc-s); }
.tally-table td[data-badge="C"]::before { background: var(--disc-c); }
.tally-table td[data-badge="N"]::before { background: var(--muted); }

/* Chart cell: 'resize:true' was added to the Morris.Line() init in
   result.php, so this now genuinely resizes on viewport change
   rather than only sizing once at load. overflow-x stays as a
   safety net for very narrow screens. */
#graph {
  background: var(--surface);
  padding: 8px;
  overflow-x: auto;
}

/* ---------- RESULT narrative panel ---------- */

.result-panel {
  width: min(1040px, 100% - 40px);
  margin: 0 auto 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 28px 28px;
}

.result-panel > h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.result-body h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-top: 28px;
  color: var(--accent-ink);
}

.result-body b {
  display: block;
  margin-top: 16px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.result-body h3 {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--accent);
  padding: 4px 14px;
  border-radius: 999px;
  margin: 6px 0 10px;
}

.result-body ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.result-body li {
  margin-bottom: 4px;
  color: var(--ink);
}

.result-body p {
  color: var(--ink);
  line-height: 1.7;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  #container {
    padding: 20px 12px 80px;
  }

  #container form table,
  #container > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }

  #container form thead th,
  #container form tbody td,
  #container form tbody th {
    font-size: 0.8rem;
    padding: 8px 8px;
  }

  header h1 {
    font-size: 1.3rem;
  }
}