/**
 * mtm.css — "My Threat Model" v5.6 — DARK-ONLY STANDALONE BUILD
 * Fork by editing the palette block.
 *
 * v5.2 additions:
 *   - .topbar: persistent Back | progress-ring | restart row
 *   - progress ring: gradient stroke fills with %, number centered,
 *     gentle 2s pulse loop
 *   - restart: circular X button, hover tooltip "Start over",
 *     inline confirm state with ✓ / ✕ buttons
 */

/* ----------------------------- Palette ------------------------------ */
:root {
  --bg-0: #070b16;
  --bg-1: #0b1224;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.35);
  --text: #e6eaf2;
  --muted: #94a3b8;
  --acc-a: #7c6cff;
  --acc-b: #22d3ee;
  --grad: linear-gradient(120deg, var(--acc-a), var(--acc-b));
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.07);
  --warn-border: rgba(251, 191, 36, 0.35);
  --tier-green: #34d399;
  --tier-amber: #fbbf24;
  --tier-red: #f87171;
  --radius: 14px;
}

/* ------------------------------ Base ------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.65;
  font-size: 1.0625rem;
  background: radial-gradient(1200px 800px at 70% -10%, #141b33 0%, transparent 60%),
              linear-gradient(180deg, var(--bg-0), var(--bg-1));
  background-color: var(--bg-0);
  background-repeat: no-repeat;
  min-height: 100vh;
}

html, body { overflow-x: clip; }

#app { max-width: 44rem; margin: 0 auto; padding: 3rem 1.75rem 5rem; }

/* ----------------------------- Cards ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.75rem 2.5rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.card.welcome { animation: rise 0.4s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-inner.anim { animation: rise-inner 0.28s ease both; }
@keyframes rise-inner {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------- Typography --------------------------- */
h1.brand {
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 800; line-height: 1.15; letter-spacing: -0.02em;
  text-align: center;
}
h1.brand span {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.card h2 { font-size: 1.45rem; font-weight: 700; line-height: 1.35; margin: 0 0 0.5rem; }
.kicker {
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.28em; font-size: 0.72rem; font-weight: 700;
  text-align: center; margin-bottom: 0.4rem;
}
.lede { color: var(--muted); text-align: center; font-size: 1.1rem; max-width: 32rem; margin: 0.75rem auto 0; }
.sub { color: var(--muted); margin: 0.25rem 0 1.5rem; }
.stem { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.4rem; }

/* ----------------------------- Facts ------------------------------ */
.facts { list-style: none; margin: 1.75rem auto 0; max-width: 26rem; text-align: left; }
.facts li { color: var(--muted); padding: 0.55rem 0 0.55rem 1.6rem; position: relative; }
.facts li::before {
  content: ""; position: absolute; left: 0; top: 1.05rem;
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--grad);
}

/* ----------------------- Top bar (persistent) ---------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 2rem; min-height: 3rem;
}
.topbar .spacer { flex: 0 0 auto; width: 1px; }
.topbar .btn { min-height: 2.5rem; padding: 0.35rem 1.5rem; font-size: 0.9rem; }

/* ------------------------- Progress ring -------------------------- */
.prog {
  position: relative; width: 4.4rem; height: 4.4rem;
  display: grid; place-items: center;
  animation: progPulse 2s ease-in-out infinite;
}
@keyframes progPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}
.pringsvg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.pring-bg { fill: none; stroke: var(--border-strong); stroke-width: 7; }
.pring-fill {
  fill: none; stroke: var(--acc-b); stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.5));
}
.ppct {
  font-weight: 800; font-size: 0.85rem; letter-spacing: -0.01em;
  color: var(--text);
}

/* -------------------------- Restart button ------------------------ */
.restart {
  display: flex; align-items: center; gap: 0.6rem;
  min-height: 2.5rem;
}
.restart-x {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(248, 113, 113, 0.55);
  color: var(--tier-red);
  font-size: 1rem; line-height: 1; cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.restart-x:hover { background: rgba(248, 113, 113, 0.12); transform: scale(1.05); }
.restart-x::after {
  content: attr(data-tip);
}
/* tooltip on hover */
.restart { position: relative; }
.restart-x:hover { position: relative; }
.restart .tip {
  position: absolute; top: calc(100% + 0.4rem); right: 0;
  background: #1e2740; border: 1px solid var(--border-strong);
  color: var(--text); font-size: 0.8rem;
  padding: 0.3rem 0.7rem; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s ease;
}
.restart:hover .tip { opacity: 1; }

.restart-q { color: var(--muted); font-size: 0.9rem; }
.confirm-yes, .confirm-no {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: none; font-size: 1rem; cursor: pointer;
  display: inline-grid; place-items: center; line-height: 1;
}
.confirm-yes { background: rgba(52, 211, 153, 0.15); color: var(--tier-green); border: 1.5px solid var(--tier-green); }
.confirm-no  { background: rgba(248, 113, 113, 0.15); color: var(--tier-red);   border: 1.5px solid var(--tier-red); }
.confirm-yes:hover, .confirm-no:hover { transform: scale(1.1); }

/* ---------------------------- Options ----------------------------- */
.opts { display: grid; gap: 0.85rem; margin-top: 1.75rem; }
.opt {
  display: flex; align-items: center; gap: 0.85rem;
  min-height: 3.4rem; padding: 0.9rem 1.35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease,
              transform 0.1s ease;
  user-select: none;
}
.opt:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.opt:focus-within { outline: 2px solid var(--acc-a); outline-offset: 2px; }
.opt.sel { border-color: var(--acc-a); background: rgba(124, 108, 255, 0.12); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .mark {
  width: 1.15rem; height: 1.15rem; flex-shrink: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.opt.check .mark { border-radius: 4px; }
.opt.sel .mark { border-color: var(--acc-b); box-shadow: inset 0 0 0 3.5px var(--acc-b); }

/* ---------------------------- Buttons ----------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad);
  border: none; border-radius: 999px;
  color: #06101f;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  min-height: 3rem; padding: 0.7rem 2.2rem;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { filter: grayscale(0.6) brightness(0.55); cursor: not-allowed; }
.btn.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); filter: none; }

.nav { display: flex; justify-content: flex-end; gap: 0.9rem; margin-top: 2.25rem; }
.welcome .btn { display: block; width: min(300px, 100%); margin: 2.5rem auto 0; }

/* ----------------------------- Results ---------------------------- */
.results-head { text-align: center; margin-bottom: 2.25rem; }
.results-head .kicker { margin-bottom: 0.75rem; }

.tier-word {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 800; line-height: 1.1; letter-spacing: 0.01em;
  margin: 0 auto 0.6rem; max-width: 34rem;
}
.tier-word.relaxed  { color: var(--tier-green); }
.tier-word.moderate { color: var(--tier-amber); }
.tier-word.strict   { color: var(--tier-red); }

.divergence { color: var(--muted); font-style: italic; margin-top: 0.5rem; }

.tier {
  display: inline-block; padding: 0.35em 0.95em;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.09em; text-transform: uppercase;
  border: 1.5px solid currentColor;
  white-space: nowrap;
}
.tier.relaxed  { color: var(--tier-green); }
.tier.moderate { color: var(--tier-amber); }
.tier.strict   { color: var(--tier-red); }

.flagged {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 5px solid var(--warn);
  border-radius: 12px;
  padding: 1.75rem;
  margin: 2rem 0;
}
.flagged .lead { font-weight: 700; margin-bottom: 1.25rem; }
.flagged .item { border-top: 1px solid rgba(251, 191, 36, 0.2); padding-top: 1.25rem; margin-top: 1.25rem; }
.flagged .item:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.flagged .item h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.flagged .item p { color: var(--muted); }

/* Radar */
.radar-wrap { margin: 2.25rem 0; text-align: center; }
.radar {
  display: inline-block; width: 100%; max-width: 560px; height: auto;
  animation: bloom 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  transform-origin: 50% 50%;
}
@keyframes bloom { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
.ring  { fill: none; stroke: var(--border); }
.spoke { stroke: var(--border); }
.shape { fill: rgba(124, 108, 255, 0.25); stroke: url(#mtmGrad); stroke-width: 2.5; }
.rlabel { font-size: 16px; fill: var(--muted); font-family: inherit; }
.rscale { font-size: 11px; fill: var(--border-strong); font-family: inherit; }
.radar-wrap figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 0.75rem; }

/* Accordions */
.cats { display: grid; gap: 0.9rem; margin-top: 1.75rem; }
.cat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.cat summary {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.6rem;
  cursor: pointer; list-style: none;
  transition: background-color 0.15s ease;
}
.cat summary::-webkit-details-marker { display: none; }
.cat summary:hover { background: var(--surface-2); }
.cat summary h3 { font-size: 1.15rem; flex: 1; }
.cat summary::after { content: "▾"; color: var(--muted); transition: transform 0.2s ease; }
.cat[open] summary::after { transform: rotate(180deg); }
.cat .body { padding: 0.25rem 1.6rem 1.6rem; }

.advice {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 1.35rem 1.6rem;
  margin-top: 1.1rem;
}
.advice h4 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.advice h4::before {
  content: ""; display: inline-block;
  width: 0.5em; height: 0.5em; border-radius: 50%;
  background: var(--grad); margin-right: 0.6em; vertical-align: 0.1em;
}
.advice p { color: var(--muted); line-height: 1.7; margin-top: 0.6rem; }
.advice.cond { border-left: 4px solid var(--acc-a); }
.advice .said { color: var(--acc-b); font-size: 0.95rem; }

.endrow {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 0.9rem; margin-top: 2.25rem;
}

/* --------------------------- Mobile ------------------------------- */
@media (max-width: 30rem) {
  #app { padding: 1.75rem 1.1rem 3.5rem; }
  .card { padding: 2rem 1.4rem; }
  .nav { flex-direction: column-reverse; }
  .nav .btn { width: 100%; }
  .topbar .btn { padding: 0.35rem 1.1rem; }
}

/* --------------------------- Landing page -------------------------- */
.site-header {
  display: flex; align-items: center;
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  width: 100%;
}
.site-header a {
  display: flex; align-items: center; gap: 0.65rem;
  text-decoration: none; color: var(--text);
  font-weight: 800; letter-spacing: -0.02em; font-size: 1.05rem;
}
.site-header a:hover { color: var(--acc-b); }
.site-header .logo { width: 3rem; height: 3rem; flex-shrink: 0; }

main.landing { max-width: 80rem; margin: 0 auto; padding: 3rem 1.75rem 5rem; }

.welcome .hero-cta,
.hero-cta {
  display: flex; align-items: center; justify-content: center;
  width: 250px; max-width: 100%;
  margin: 2.75rem auto 0;
  font-size: 1rem; min-height: 3rem;
  text-decoration: none; color: #06101f;
}
.section { margin-top: 2.75rem; }
.section h2 {
  font-size: 1.45rem; font-weight: 700; line-height: 1.35;
  margin: 0 0 0.75rem;
}
.section p { color: var(--muted); margin-bottom: 1rem; }
.section p strong { color: var(--text); }
.cards-3 {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1rem; margin: 2rem 0 0;
}
.mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.35rem 1.25rem;
}
.mini h3 {
  font-size: 1rem; margin-bottom: 0.4rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.mini h3::before {
  content: ""; width: 0.5em; height: 0.5em;
  border-radius: 50%; background: var(--grad); flex-shrink: 0;
}
.mini p { color: var(--muted); font-size: 0.92rem; margin: 0; }
@media (max-width: 40rem) {
  .site-header { padding: 1rem 1.1rem; }
  .cards-3 { grid-template-columns: 1fr; }
}

.hero-split {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 3rem;
  align-items: center;
}
.hero-split .hero-copy { text-align: left; }
.hero-split .kicker, .hero-split .lede { text-align: left; margin-left: 0; }
.hero-split .facts { margin-left: 0; }
.hero-split .hero-cta { margin-left: 0; }
.hero-split h1.brand { 
    text-align: left;
    font-size: clamp(2rem, 3.8vw, 2.7rem);
      line-height: 1.2;
}

.hero-art {
  align-self: center;
  max-width: 100%;
}

.hero-art svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transform: scale(1.45);
  transform-origin: bottom left;
}

@media (max-width: 46rem) {
  /* stack the columns — text full-width, then art below */
  .hero-split { grid-template-columns: 1fr; gap: 1.5rem; }
  /* everything left-aligned */
  .hero-split .kicker, .hero-split .lede,
  .hero-split h1.brand { text-align: left; margin-left: 0; }
  .hero-split .facts { margin-left: 0; }
  .hero-split .hero-cta { margin-left: 0; }
  /* breathing room between CTA and art, art scaled for mobile */
  .hero-art { margin-top: 2.5rem; justify-self: start; }
  .hero-art svg { transform: scale(1.2); transform-origin: bottom left; }
}

/* ---- Hero illustration animation ---- */
#mtm-orb1, #mtm-orb2, #mtm-orb3 {
  transform-box: view-box;
  transform-origin: 630px 307px;
}
#mtm-eye, #mtm-sclera, #mtm-pupil {
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform;
}
#mtm-orb1 { animation: revolve 14s linear infinite; }
#mtm-orb2 { animation: revolve 22s linear infinite reverse; }
#mtm-orb3 { animation: revolve 30s linear infinite reverse; }
#mtm-pupil {
  animation: pupilGlance 6.5s
             cubic-bezier(0.6, 0, 0.9, 0.4) infinite;
}
#mtm-eye { animation: eyeDrift 9s ease-in-out infinite; }
#mtm-sclera {
  animation: scleraFollow 6.5s
             cubic-bezier(0.6, 0, 0.9, 0.4) infinite;
}
@keyframes pupilGlance {
  0%, 3%    { transform: translate(0, 0); }
  /* peek upper-left */
  6%, 20%   { transform: translate(-30px, -24px); }
  /* caught — retreat right */
  23%, 45%  { transform: translate(54px, -6px); }
  /* the position you liked: lower-right */
  48%, 58%  { transform: translate(32px, 26px); }
  /* NEW — directly above it, at the top of the whites */
  61%, 74%  { transform: translate(22px, -38px); }
  /* lingering glance, then home */
  77%, 88%  { transform: translate(8px, -10px); }
  91%, 100% { transform: translate(0, 0); }
}

@keyframes eyeDrift {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes scleraFollow {
  0%, 3%    { transform: translate(0, 0); }
  6%, 20%   { transform: translate(-8px, -6px); }
  23%, 45%  { transform: translate(13px, -2px); }
  48%, 58%  { transform: translate(8px, 6px); }
  61%, 74%  { transform: translate(5px, -9px); }
  77%, 88%  { transform: translate(2px, -3px); }
  91%, 100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  #mtm-eye, #mtm-sclera, #mtm-orb1, #mtm-orb2, #mtm-orb3, #mtm-pupil, #mtm-guy {
    animation: none;
  }
}

@keyframes revolve { to { transform: rotate(360deg); } }

#mtm-guy {
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: guySway 4.2s ease-in-out infinite;
}
@keyframes guySway {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50%      { transform: rotate(1.2deg) translateY(-3px); }
}

/* ------------------------ Print / PDF export ----------------------- */
@media print {
  body { background: #fff; color: #111; }
  .card, .cat, .advice, .flagged { background: #fff; border-color: #bbb; }
  .flagged { border-left-color: #b45309; }
  .tier.relaxed { color: #15803d; } .tier.moderate { color: #b45309; }
  .tier.strict { color: #b91c1c; }
  .tier-word.relaxed { color: #15803d; } .tier-word.moderate { color: #b45309; }
  .tier-word.strict { color: #b91c1c; }
  .rlabel { fill: #333; } .ring, .spoke { stroke: #999; }
  .rscale { fill: #777; }
  .endrow, .prog, .restart, .topbar { display: none; }
}
