/* Witz Mini Assessment — brand stylesheet.
   Standalone: tokens copied from witz-website/css/style.css :root rather
   than linking the live site (this app must work offline / self-hosted).
   See README.md for the brand-colour divergence note (the spec's
   "slate blue #6b93a5-ish" print-artifact approximation vs. the live
   site's purple, which wins). */

:root {
  --color-charcoal: #202020;
  --color-dark: #515251;
  --color-light-gray: #F8F9F9;
  --color-accent: #6C4D9E;
  --color-accent-hover: #5a3f87;
  --color-accent-light: #e8e0f3;
  --color-accent-deep: #3d2d5c;
  --color-coral: #D85D64;
  --color-orange: #F09F43;
  --color-gold: #FAD37C;
  --font-heading: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-quote: Georgia, 'Times New Roman', serif;

  /* Official egoSTATE Guidebook identity colors (per state) */
  --state-cp: #D4593B;
  --state-np: #5B3E96;
  --state-a: #E0B93E;
  --state-sc: #D9534F;
  --state-wc: #4E6E8E;
  --state-ac: #A02C5B;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even over display:flex/grid
   rules on the same element (UA stylesheet loses that fight). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-heading);
  color: var(--color-charcoal);
  background: var(--color-light-gray);
  line-height: 1.5;
}

.site-header {
  background: var(--color-charcoal);
  color: #fff;
  padding: 1.25rem 1rem;
  position: relative;
}

/* Six-state gradient strip — the system's identity, on every page header */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--state-ac) 0%, var(--state-ac) 16.6%,
    var(--state-cp) 16.6%, var(--state-cp) 33.3%,
    var(--state-sc) 33.3%, var(--state-sc) 50%,
    var(--state-wc) 50%, var(--state-wc) 66.6%,
    var(--state-np) 66.6%, var(--state-np) 83.3%,
    var(--state-a) 83.3%, var(--state-a) 100%);
}

.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

/* Franchise wordmark: lowercase "better" + caps "MOMENTS" */
.brand-name {
  letter-spacing: 0.01em;
}

.brand-name .brand-lower {
  font-weight: 300;
  color: var(--color-accent-light);
}

.brand-name .brand-upper {
  font-weight: 800;
  color: #fff;
}

.site-header p {
  margin: 0.25rem 0 0;
  color: var(--color-accent-light);
  font-size: 0.9rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

section.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

h2 {
  color: var(--color-accent-deep);
  font-size: 1.1rem;
  margin-top: 0;
}

.instructions {
  color: var(--color-dark);
  font-size: 0.92rem;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="date"],
textarea {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
}

input[readonly] {
  background: var(--color-light-gray);
  color: var(--color-dark);
}

details.optional-block {
  margin-top: 0.5rem;
  border-top: 1px solid #eee;
  padding-top: 0.75rem;
}

details.optional-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-accent);
}

.skill-field {
  margin-bottom: 0.6rem;
}

.question {
  padding: 0.9rem 0;
  border-bottom: 1px solid #eee;
}

.question:last-child {
  border-bottom: none;
}

.question-text {
  font-weight: 600;
  margin-bottom: 0.6rem;
  display: block;
}

.scale-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
}

.scale-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 400;
  font-size: 0.85rem;
  flex: 1 1 auto;
  min-width: 130px;
}

.scale-option input {
  accent-color: var(--color-accent);
  width: 1.05rem;
  height: 1.05rem;
}

@media (max-width: 480px) {
  .scale-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .scale-option {
    min-width: unset;
  }
}

.progress-bar-track {
  background: #e6e6e6;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 0.5rem 0 0.35rem;
}

.progress-bar-fill {
  background: var(--color-accent);
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--color-dark);
}

.submit-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-light-gray);
  padding: 0.75rem 0;
  text-align: center;
}

button[type="submit"] {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.85rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
}

button[type="submit"]:disabled {
  background: #b9aecb;
  cursor: not-allowed;
}

button[type="submit"]:not(:disabled):hover {
  background: var(--color-accent-hover);
}

#form-error {
  color: var(--color-coral);
  font-weight: 600;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* ---------------------------------------------------------------------
   Report page
   --------------------------------------------------------------------- */

.report-header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}

.report-header .report-kicker {
  color: var(--color-accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.report-header h1 {
  margin: 0.2rem 0 0.4rem;
  color: var(--color-charcoal);
}

.report-meta {
  color: var(--color-dark);
  font-size: 0.9rem;
}

.style-bar-row {
  margin-bottom: 1rem;
}

.style-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.style-bar-label .style-name {
  font-weight: 700;
  color: var(--color-accent-deep);
}

.style-bar-label .style-band {
  color: var(--color-dark);
}

.style-bar-track {
  background: var(--color-light-gray);
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  height: 20px;
  overflow: hidden;
}

.style-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-hover));
}

/* Official guidebook state colors on the questionnaire's six bars */
.style-bar-fill.fill-dominant { background: var(--state-cp); }
.style-bar-fill.fill-giving { background: var(--state-np); }
.style-bar-fill.fill-rational { background: var(--state-a); }
.style-bar-fill.fill-free { background: var(--state-sc); }
.style-bar-fill.fill-private { background: var(--state-wc); }
.style-bar-fill.fill-reactionary { background: var(--state-ac); }

.se-gauge-track {
  background: var(--color-light-gray);
  border: 1px solid #e2e2e2;
  border-radius: 999px;
  height: 26px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.se-gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-gold), var(--color-orange), var(--color-coral));
}

.se-gauge-label {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-accent-deep);
}

.interpretation-block {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.interpretation-block:last-child {
  border-bottom: none;
}

.draft-notice {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--color-coral);
  font-style: italic;
  margin-top: 0.3rem;
}

.report-footer {
  text-align: center;
  color: var(--color-dark);
  font-size: 0.8rem;
  padding: 1.5rem 1rem;
}

/* ---------------------------------------------------------------------
   Admin
   --------------------------------------------------------------------- */

.admin-banner {
  background: var(--color-coral);
  color: #fff;
  padding: 0.6rem 1rem;
  font-weight: 600;
  text-align: center;
}

table.submissions {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

table.submissions th,
table.submissions td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

table.submissions th {
  color: var(--color-accent-deep);
  border-bottom: 2px solid var(--color-accent-light);
}

table.submissions a {
  color: var(--color-accent);
}

/* ---------------------------------------------------------------------
   Print (report export path is browser Print to PDF — see README)
   --------------------------------------------------------------------- */

@media print {
  .site-header,
  .admin-banner,
  .submit-bar,
  #form-error {
    display: none;
  }
  body {
    background: #fff;
  }
  section.card,
  main {
    box-shadow: none;
  }
}

/* ---------------------------------------------------------------------
   Moment Check
   --------------------------------------------------------------------- */

.site-nav {
  margin-top: 0.6rem;
  display: flex;
  gap: 1rem;
}

.site-nav a {
  color: var(--color-accent-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  padding-bottom: 0.15rem;
}

.site-nav a.nav-active {
  color: #fff;
  border-bottom-color: var(--color-accent);
}

.notice-card {
  border-left: 4px solid var(--color-coral);
  color: var(--color-dark);
}

.optional-tag {
  font-weight: 400;
  color: var(--color-dark);
  font-size: 0.85rem;
}

/* --- Thinking state ------------------------------------------------- */

.thinking-wrap {
  text-align: center;
  padding: 0.5rem 0;
}

.thinking-text {
  color: var(--color-accent);
  font-weight: 600;
  margin: 0 0 0.5rem;
  min-height: 1.4em;
}

.thinking-dots {
  display: inline-flex;
  gap: 0.4rem;
}

.thinking-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: dot-pulse 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* --- State color utilities ------------------------------------------ */

.sc-cp { --state-color: var(--state-cp); }
.sc-np { --state-color: var(--state-np); }
.sc-a  { --state-color: var(--state-a); }
.sc-sc { --state-color: var(--state-sc); }
.sc-wc { --state-color: var(--state-wc); }
.sc-ac { --state-color: var(--state-ac); }

.state-chip {
  display: inline-block;
  background: var(--state-color, var(--color-accent));
  color: #fff;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* --- State hero (the "you were the Critical Parent" moment) --------- */

.state-hero {
  text-align: center;
  padding: 0.75rem 0 1rem;
}

.state-hero-circle {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--state-color, var(--color-accent));
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.6rem;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--state-color, var(--color-accent)) 45%, transparent);
}

body.js .reveal-hero .state-hero-circle {
  animation: hero-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             hero-glow 1.4s ease-out 0.45s 1;
}

@keyframes hero-pop {
  from { transform: scale(0.55); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes hero-glow {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--state-color, var(--color-accent)) 45%, transparent); }
  100% { box-shadow: 0 0 0 26px transparent; }
}

.state-hero-name {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--state-color, var(--color-accent-deep));
}

.state-hero-sub {
  margin-top: 0.35rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.confidence-pill {
  display: inline-block;
  border: 1px solid #ddd;
  color: var(--color-dark);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  text-transform: capitalize;
  background: #fff;
}

.secondary-note {
  color: var(--color-dark);
  font-size: 0.85rem;
}

.secondary-note .state-chip {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
}

/* --- Section labels -------------------------------------------------- */

.section-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-dark);
  margin: 1.4rem 0 0.6rem;
}

/* --- Evidence cards -------------------------------------------------- */

.evidence-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0.9rem;
  display: grid;
  gap: 0.6rem;
}

.evidence-card {
  border-left: 4px solid var(--state-color, var(--color-accent));
  background: color-mix(in srgb, var(--state-color, var(--color-accent)) 6%, #fff);
  border-radius: 0 6px 6px 0;
  padding: 0.7rem 0.85rem;
}

.evidence-quote {
  font-family: var(--font-quote);
  font-style: italic;
  font-size: 1.02rem;
  display: block;
  margin-bottom: 0.35rem;
}

.evidence-quote::before { content: "\201C"; }
.evidence-quote::after { content: "\201D"; }

.evidence-why {
  font-size: 0.88rem;
  color: var(--color-dark);
}

/* --- Hook flow (you -> them) ----------------------------------------- */

.hook-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin: 0.6rem 0 0.75rem;
  flex-wrap: wrap;
}

.hook-side {
  text-align: center;
}

.hook-side-label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-dark);
  margin-bottom: 0.3rem;
}

.hook-chips {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}

.hook-arrow {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--state-color, var(--color-accent)), #bbb);
  width: 64px;
  position: relative;
  flex: 0 0 auto;
}

.hook-arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 8px solid #bbb;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

body.js #moment-result.revealed .hook-arrow {
  animation: arrow-grow 0.6s ease-out both;
  animation-delay: inherit;
  transform-origin: left center;
}

@keyframes arrow-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* --- Realization + redo ----------------------------------------------- */

.realization-text {
  background: color-mix(in srgb, var(--state-color, var(--color-accent)) 7%, #fff);
  border-left: 4px solid var(--state-color, var(--color-accent));
  padding: 1rem 1.1rem;
  border-radius: 0 8px 8px 0;
  font-size: 1.04rem;
  line-height: 1.65;
}

.realization-text::first-line {
  font-weight: 700;
}

.redo-text {
  background: color-mix(in srgb, var(--state-a) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--state-a) 45%, #fff);
  border-left: 4px solid var(--state-a);
  padding: 1rem 1.1rem;
  border-radius: 0 8px 8px 0;
  font-family: var(--font-quote);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.6;
}

.redo-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--state-a) 60%, var(--color-charcoal));
  font-weight: 700;
  font-family: var(--font-heading);
  font-style: normal;
  display: block;
  margin-bottom: 0.4rem;
}

/* --- Tools ------------------------------------------------------------ */

.tools-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0.5rem;
  display: grid;
  gap: 0.55rem;
}

.tool-card {
  background: var(--color-light-gray);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.tool-name {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  margin-right: 0.45rem;
  vertical-align: 1px;
}

/* --- Staged reveal -----------------------------------------------------
   Pure CSS animations with per-block delays (set inline by JS as
   --reveal-delay). `both` fill means blocks start invisible only once
   the .revealed class is present and ALWAYS end fully visible — a
   throttled timer or hidden tab can delay the show, never strand it. */

body.js #moment-result.revealed .reveal {
  animation: reveal-in 0.45s ease both;
  animation-delay: var(--reveal-delay, 0s);
}

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* --- Rewrite ladder ----------------------------------------------------- */

.ladder-track {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.75rem 0 1rem;
}

.ladder-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.7rem;
  color: var(--color-dark);
}

.ladder-chip .chip-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--state-color) 45%, #fff);
  color: color-mix(in srgb, var(--state-color) 80%, #000);
  background: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.ladder-chip.lit .chip-dot {
  background: var(--state-color);
  color: #fff;
  transform: scale(1.12);
}

body.js .ladder-chip.pulse .chip-dot {
  animation: chip-pulse 0.9s ease-out 1;
}

@keyframes chip-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--state-color) 50%, transparent); }
  100% { box-shadow: 0 0 0 18px transparent; }
}

.ladder-chip.target .chip-label::after {
  content: " \2605";
  color: var(--state-a);
}

.ladder-arrow-hint {
  color: #b5b5b5;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
  /* chips are icon+label columns; nudge the chevron up to dot height */
  transform: translateY(-11px);
}

.rewrite-history {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.6rem;
}

.attempt-card {
  border: 1px solid #eee;
  border-left: 4px solid var(--state-color, var(--color-accent));
  border-radius: 0 6px 6px 0;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.attempt-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}

.attempt-number {
  font-size: 0.72rem;
  color: var(--color-dark);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.attempt-rewrite {
  font-family: var(--font-quote);
  font-style: italic;
  color: var(--color-dark);
  margin-bottom: 0.3rem;
}

.ladder-success {
  text-align: center;
  font-weight: 800;
  color: color-mix(in srgb, var(--state-a) 65%, var(--color-charcoal));
  background: radial-gradient(closest-side, color-mix(in srgb, var(--state-a) 22%, transparent), transparent);
  padding: 0.7rem;
  margin-top: 0.6rem;
  border-radius: 8px;
}

body.js .ladder-success {
  animation: hero-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#moment-rewrite-card h2 {
  margin-bottom: 0.25rem;
}

/* --- Motion + print safety --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  body.js #moment-result.revealed .reveal,
  body.js .reveal-hero .state-hero-circle,
  body.js #moment-result.revealed .hook-arrow,
  body.js .ladder-chip.pulse .chip-dot,
  body.js .ladder-success,
  .thinking-dots span {
    animation: none !important;
    transition: none !important;
    opacity: 1;
    transform: none;
  }
}

@media print {
  body.js #moment-result.revealed .reveal,
  body.js #moment-result .reveal {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
