/* The Good Life: styles
   Warm dark editorial theme. One serif for headings (EB Garamond), one sans for UI (Geist).
   Corner radius lock: 10px everywhere interactive. */

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/EBGaramond-var.woff2") format("woff2");
}
@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/EBGaramond-italic-var.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/Geist-var.woff2") format("woff2");
}

:root {
  --bg: #1b1916;
  --bg-2: #211e1a;
  --bg-3: #29251f;
  --line: #3b352e;
  --line-soft: #2e2a24;
  --text: #ece5d8;
  --text-2: #cfc6b7;
  --muted: #a89e90;
  --now: #e0a15e;
  --now-soft: rgba(224, 161, 94, 0.18);
  --could: #8dbccd;
  --could-soft: rgba(141, 188, 205, 0.16);
  --community: #9a9286;
  --focus: #f3d9a6;
  --radius: 10px;
  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 220ms;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0ms; }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100dvh;
  padding: 0 clamp(1rem, 4vw, 2.5rem) env(safe-area-inset-bottom);
  max-width: 1280px;
  margin-inline: auto;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--text);
}

p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute;
  left: 1rem; top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  z-index: 3;
}
.skip:focus { top: 1rem; outline: none; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* Masthead */
.masthead {
  padding: clamp(2.5rem, 7vw, 5rem) 0 0;
  max-width: 44rem;
}
.title {
  font-size: clamp(2.6rem, 8vw, 4.25rem);
  line-height: 1.02;
  font-weight: 600;
}
.subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.35rem, 3.6vw, 1.85rem);
  line-height: 1.2;
  color: var(--text-2);
  margin-top: 0.4rem;
  padding-bottom: 0.15em; /* italic descender clearance */
}
.lede {
  margin-top: 1.25rem;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 38rem;
}

.banner {
  margin: -1.25rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 0.9375rem;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}
.results, .primary { display: contents; }
.masthead, .banner { order: 0; }
.chart-block { order: 1; }
.rate { order: 2; min-width: 0; }
.gaps-block { order: 3; }

/* Chart */
.chart-frame {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0.5rem;
}
.radar { display: block; width: 100%; height: auto; }
.radar .grid-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar .grid-ring.outer { stroke: #4a433a; }
.radar .spoke { stroke: var(--line-soft); stroke-width: 1; }
.radar .ring-now { fill: var(--now-soft); stroke: var(--now); stroke-width: 2; stroke-linejoin: round; }
.radar .ring-could { fill: var(--could-soft); stroke: var(--could); stroke-width: 2; stroke-linejoin: round; }
.radar .ring-community { fill: none; stroke: var(--community); stroke-width: 1.75; stroke-dasharray: 5 4; stroke-linejoin: round; }
.radar .dot-now { fill: var(--now); }
.radar .dot-could { fill: var(--could); }
.radar .label {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  fill: var(--text-2);
  letter-spacing: 0.005em;
}
.radar .label.is-top { fill: var(--text); }
.radar .label.is-long { font-size: 11px; }
.radar .tick { font-family: var(--sans); font-size: 9px; fill: var(--muted); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-2);
}
.legend li { display: inline-flex; align-items: center; gap: 0.5rem; }
.swatch { width: 18px; height: 0; border-top: 2px solid; display: inline-block; }
.legend-now .swatch { border-color: var(--now); }
.legend-could .swatch { border-color: var(--could); }
.legend-community .swatch { border-top-style: dashed; border-color: var(--community); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 0.6rem 0.95rem;
  min-height: 44px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), transform 80ms var(--ease), border-color var(--dur) var(--ease);
  text-align: left;
}
.btn:hover { background: #312c25; border-color: #4a433a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--bg-2); }

/* Rating list */
.rate h2, .gaps-block h2, .community h2 {
  font-size: clamp(1.6rem, 4vw, 2rem);
  line-height: 1.15;
}
.rate-hint, .gaps-hint {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
  max-width: 40rem;
}
.k-now { color: var(--now); font-weight: 600; }
.k-could { color: var(--could); font-weight: 600; }

.metrics { margin-top: 1.5rem; border-top: 1px solid var(--line-soft); }

.metric {
  padding: 1.25rem 0 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}
.metric-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.metric-num {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--muted);
  min-width: 1.4rem;
  font-variant-numeric: tabular-nums;
}
.metric-title {
  font-size: 1.45rem;
  line-height: 1.15;
}
.metric-title button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}
.metric-title button:hover { color: var(--focus); }
.metric-title .chev {
  display: inline-block;
  width: 0.55em; height: 0.55em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.2em) rotate(45deg);
  transition: transform var(--dur) var(--ease);
  color: var(--muted);
  flex: none;
}
.metric.is-open .metric-title .chev { transform: translateY(0) rotate(225deg); }
.metric-edit {
  appearance: none;
  margin-left: auto;
  align-self: center;
  flex: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  min-height: 36px;
  cursor: pointer;
}
.metric-edit:hover { color: var(--text); border-color: var(--line); }
.metric.is-custom .metric-edit { color: var(--text-2); }
.metric-restore-row { margin: 0.2rem 0 0 2.15rem; line-height: 1; }
.metric-restore-row:empty { display: none; }
.metric-restore {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.3rem 0;
  min-height: 28px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
  cursor: pointer;
}
.metric-restore:hover { color: var(--text-2); text-decoration-color: currentColor; }
.metric-restore[hidden] { display: none; }
.metric-ten {
  margin: 0.35rem 0 0 2.15rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.sliders {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}
.slider {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) 2.6rem;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
}
.slider-label {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.slider-now .slider-label { color: var(--now); }
.slider-could .slider-label { color: var(--could); }
.slider output {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color var(--dur) var(--ease);
}
.slider-now output { color: var(--now); }
.slider-could output { color: var(--could); }
.slider.is-untouched output { color: var(--muted); font-weight: 500; }
.slider.is-untouched output::after {
  content: "";
  display: block;
  border-bottom: 1px dashed var(--muted);
  margin-top: 3px;
}

/* Range input */
input[type="range"] {
  --pct: 44.4%;
  --accent: var(--now);
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.slider-could input[type="range"] { --accent: var(--could); }
.slider.is-untouched input[type="range"] { --accent: #7a7065; }

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) 0 var(--pct), var(--line) var(--pct) 100%);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px; height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 80ms var(--ease);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.08); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--focus); }

/* Guidance panel */
.guide {
  margin: 1rem 0 0 0;
  padding: 1.1rem 1.15rem 1.25rem;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: grid;
  gap: 1rem;
}
.guide[hidden] { display: none; }
.guide h4 {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.guide p, .guide li {
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.guide .ten {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--text);
}
.guide ol { list-style: decimal; padding-left: 1.25rem; display: grid; gap: 0.35rem; }
.guide ol li::marker { color: var(--muted); }
.guide .caveat { border-left: 2px solid var(--line); padding-left: 0.85rem; }
.note label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.edit {
  margin-top: 1rem;
  padding: 1rem 1.15rem 1.1rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 0.85rem;
}
.edit .field label, .note label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.edit input[type="text"], .edit textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  min-height: 44px;
}
.edit input[type="text"] { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.edit textarea { resize: vertical; }
.edit input:focus-visible, .edit textarea:focus-visible { outline-offset: 0; }
.edit-help { font-size: 0.8125rem; color: var(--muted); }
.edit-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-small { min-height: 38px; padding: 0.4rem 0.8rem; font-size: 0.875rem; }
.guide-origin {
  font-size: 0.875rem;
  color: var(--text-2);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.guide-origin[hidden] { display: none; }
.note textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}
.note textarea::placeholder { color: #8a8175; }
.note textarea:focus-visible { outline-offset: 0; }

/* Gap list */
.gaps { margin-top: 1.25rem; display: grid; gap: 0.35rem; }
.gap {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  grid-template-areas: "rank name gap" "rank bar bar";
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.4rem;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.gap.is-start { background: var(--bg-2); border-color: var(--line-soft); }
.gap.is-untouched .gap-name a { color: var(--muted); }
.gap.is-untouched .gap-rank { color: #8a8175; }
.gap-rank {
  grid-area: rank;
  font-family: var(--serif);
  color: var(--muted);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  align-self: start;
  padding-top: 0.1rem;
}
.gap-name {
  grid-area: name;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.gap-name a { color: inherit; text-decoration: none; }
.gap-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.tag {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--text);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  line-height: 1.4;
}
.tag.tag-muted { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.gap-val {
  grid-area: gap;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}
.gap-val.is-zero, .gap-val.is-neg { color: var(--muted); font-weight: 500; }
.gap-bar {
  grid-area: bar;
  position: relative;
  height: 12px;
  margin: 0 5px; /* room for the end dots */
}
.gap-bar .seg {
  position: absolute;
  top: 5px;
  height: 2px;
  background: var(--text-2);
}
.gap-bar .p {
  position: absolute;
  top: 1px;
  width: 10px; height: 10px;
  margin-left: -5px;
  border-radius: 50%;
}
.gap-bar .p-now { background: var(--now); }
.gap-bar .p-could { background: var(--could); }
.gap-bar .p-community { background: transparent; border: 1.5px solid var(--community); width: 12px; height: 12px; top: 0; margin-left: -6px; }
.gap.is-untouched { grid-template-areas: "rank name name"; }

/* Community */
.community {
  margin-top: 3.5rem;
  padding: 2rem clamp(1rem, 3vw, 2rem);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.community-inner { max-width: 44rem; }
.community-status { margin-top: 0.6rem; font-size: 1.0625rem; color: var(--text); }
.community-explain { margin-top: 0.75rem; color: var(--muted); font-size: 0.9375rem; }
.community-original { margin-top: 0.75rem; color: var(--text-2); font-size: 0.9375rem; font-weight: 500; }
.community-list { margin-top: 1rem; display: grid; gap: 0.3rem; font-size: 0.9375rem; }
.community-list li { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid var(--line-soft); }
.community-list .cl-name { font-family: var(--serif); font-size: 1.1rem; color: var(--text); }
.community-list .cl-yours { color: var(--muted); font-size: 0.875rem; }
.community-list .cl-vals { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }
.community-actions { margin-top: 1.25rem; display: grid; gap: 0.6rem; justify-items: start; }
.community-actions .btn { width: 100%; }
@media (min-width: 640px) { .community-actions .btn { width: auto; } }
.community-note { color: var(--text-2); font-size: 0.9375rem; min-height: 1.4em; }

/* Footer */
.footer {
  margin-top: 3rem;
  padding: 2rem 0 2.5rem;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.875rem;
  display: grid;
  gap: 0.35rem;
}
.footer p:first-child { color: var(--text-2); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 1rem);
  opacity: 0;
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 2;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Tablet */
@media (min-width: 640px) {
  .sliders { grid-template-columns: 1fr; }
  .slider { grid-template-columns: 5.5rem minmax(0, 1fr) 2.8rem; }
  .metric-ten { margin-left: 2.35rem; }
  .metric-restore-row { margin-left: 2.35rem; }
}

@media (min-width: 768px) {
  .chart-frame { padding: 1rem; }
  .layout { gap: 3rem; }
}

/* Desktop: two columns, results sticky on the right */
@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 4rem;
  }
  .results {
    display: block;
    position: sticky;
    top: 2rem;
    max-height: calc(100dvh - 4rem);
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 2px;
    order: 2;
    margin-top: 2.5rem;
  }
  .primary { display: block; order: 1; min-width: 0; }
  .banner { margin: 1.5rem 0 0; }
  .rate { margin-top: 3rem; }
  .gaps-block { margin-top: 2rem; }
  .gaps-block h2 { font-size: 1.5rem; }
  .gaps-hint { font-size: 0.875rem; }
  .gap { padding: 0.55rem 0.65rem; }
  .gap-name { font-size: 1.1rem; }
  .gap-val { font-size: 1.1rem; }
}

@media (min-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1fr) 440px; gap: 5rem; }
}

@media print {
  .results { position: static; max-height: none; }
  .actions, .community, .toast, .skip { display: none; }
}
