/* ============================================================================
   Attrition Assessment — a calm analytical instrument for HR risk review.

   Concept   an office-desk instrument for reading one subject, not a dashboard.
             The reading sits on a dark graphite panel (the one bold surface);
             the evidence below is quiet light cards feeding it.
   Palette   cool graphite base + dusk-indigo structure. Risk is a single
             perceptual ramp teal -> drab gold -> oxidised clay — deliberately
             NOT a traffic light.
   Type      Spectral (serif, headings + verdict) · IBM Plex Sans (prose) ·
             IBM Plex Mono (every number, every field label = "this is data").
   ========================================================================== */

:root {
  /* surfaces — cool charcoal, dark theme */
  --mist: #14161A;            /* page base */
  --panel: #15181C;           /* inset controls (inputs, segmented track) */
  --panel-raised: #1D2024;    /* section cards, one step up from base */
  --graphite: #0E1013;        /* the reading band — set below the page */
  --graphite-2: #16181C;
  --graphite-line: #2C3036;

  /* ink — warm off-white, never stark */
  --ink: #E8E6E0;
  --ink-2: #C6C4BE;
  --muted: #8B8D91;
  --line: #2C3036;
  --line-strong: #363B42;

  /* identity accent — warm brass / amber (instrument, not playful) */
  --indigo: #C9A15F;
  --indigo-deep: #D8B274;     /* brighter, for hover */
  --indigo-soft: rgba(201, 161, 95, 0.16);
  --accent-ink: #1A1408;      /* text sitting on the accent fill */

  /* risk signal — desaturated, used ONLY in the verdict / gauge */
  --risk-1: #7A9B76;          /* low  — sage  */
  --risk-2: #A87C4E;          /* mid  — ochre */
  --risk-3: #B85C4A;          /* high — warm red */
  --risk-1-on: #8FB08A;       /* lightened for text/stroke on the band */
  --risk-2-on: #C69C63;
  --risk-3-on: #D07F70;

  --on-graphite: #E8E6E0;
  --on-graphite-muted: #8B8D91;

  /* type */
  --f-display: "Spectral", Georgia, "Times New Roman", serif;
  --f-sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --t-2xs: 0.6875rem;
  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-base: 0.9375rem;
  --t-md: 1.0625rem;
  --t-lg: 1.375rem;

  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h2 { margin: 0; font-weight: 500; }

/* ── top bar ──────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem clamp(1rem, 4vw, 2.75rem);
  background: color-mix(in srgb, var(--panel-raised) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--f-display);
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: 0.005em;
}
.wordmark__mark {
  width: 12px; height: 12px;
  border: 2px solid var(--indigo);
  transform: rotate(45deg);
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  color: var(--muted);
}
.ident { letter-spacing: 0.01em; }
@media (max-width: 560px) { .ident { display: none; } }

.status { display: inline-flex; align-items: center; gap: 0.45rem; }
.status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 25%, transparent);
}
.status[data-state="up"] .status__dot { background: var(--risk-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--risk-1) 25%, transparent); }
.status[data-state="down"] .status__dot { background: var(--risk-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--risk-3) 25%, transparent); }
.status[data-state="checking"] .status__dot { animation: pulse 1.4s var(--ease) infinite; }

/* ── layout shell ─────────────────────────────────────────────────────── */
.app {
  flex: 1;
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3.5vw, 2.25rem) clamp(1rem, 4vw, 2.75rem) 7rem;
  display: flex;
  flex-direction: column;
  gap: clamp(1.1rem, 2.5vw, 1.75rem);
}

/* ── the reading ──────────────────────────────────────────────────────── */
.readout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 600px);
  justify-content: center;
  gap: clamp(1.75rem, 6vw, 5rem);
  align-items: center;
  padding: clamp(1.6rem, 4vw, 3rem);
  background:
    radial-gradient(120% 140% at 15% 0%, #191C22 0%, var(--graphite) 58%),
    var(--graphite);
  border: 1px solid #060708;
  border-radius: 14px;
  color: var(--on-graphite);
  --score-color: var(--on-graphite-muted);
}

.readout__gauge { padding: 0.5rem 0; }
.gauge { width: 100%; height: auto; display: block; overflow: visible; }
.gauge__track { fill: none; stroke: var(--graphite-line); stroke-width: 13; stroke-linecap: round; }
.gauge__progress {
  fill: none;
  stroke: url(#riskGrad);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.95s var(--ease);
}
.gauge__ticks line { stroke: var(--on-graphite-muted); stroke-width: 2; opacity: 0.5; }
.gauge__threshold { stroke: var(--on-graphite-muted); stroke-width: 2; }
.gauge__threshold-label {
  font-family: var(--f-mono); font-size: 9px; fill: var(--on-graphite-muted); letter-spacing: 0.03em;
}
.gauge__needle {
  transform-box: view-box;
  transform-origin: 160px 160px;
  transform: rotate(-90deg);
}
.gauge__needle line { stroke: var(--on-graphite); stroke-width: 3; stroke-linecap: round; }
.gauge__needle circle { fill: var(--on-graphite); }
.gauge__needle { transition: opacity 0.4s var(--ease); }
.readout[data-state="idle"] .gauge__needle { opacity: 0.3; }

.readout__eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--f-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.06em;
  color: var(--on-graphite-muted);
}
.readout__score {
  font-family: var(--f-mono);
  font-size: clamp(2.6rem, 7vw, 3.7rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--score-color);
  transition: color 0.4s var(--ease);
  font-variant-numeric: tabular-nums;
}
.readout__verdict {
  margin-top: 0.55rem;
  font-family: var(--f-display);
  font-size: clamp(1.3rem, 3.5vw, var(--t-lg));
  font-weight: 500;
  color: var(--on-graphite);
}
.readout__reading {
  margin: 0.7rem 0 0;
  max-width: 52ch;
  font-size: var(--t-sm);
  line-height: 1.6;
  color: var(--on-graphite-muted);
}
.readout__chips { margin-top: 1.1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  font-family: var(--f-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.03em;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--graphite-line);
  color: var(--on-graphite-muted);
}
.chip--risk { border-color: var(--score-color); color: var(--score-color); }
.chip--muted { opacity: 0.75; }

/* reading states */
.readout[data-state="loading"] .gauge__progress,
.readout[data-state="loading"] .gauge__needle { opacity: 0.4; }
.readout[data-state="loading"] .readout__score { animation: pulse 1.2s var(--ease) infinite; }
.readout[data-state="error"] { border-color: var(--risk-3); }
.readout[data-state="error"] .readout__verdict,
.readout[data-state="error"] .readout__score { color: var(--risk-3-on); }

/* ── the evidence: input matrix ───────────────────────────────────────── */
.matrix {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(0.8rem, 1.8vw, 1.15rem);
}
.card {
  margin: 0;
  padding: 1.2rem 1.35rem 1.35rem;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.card--demographics { grid-column: span 4; }
.card--role { grid-column: span 8; }
.card--compensation { grid-column: span 4; }
.card--satisfaction { grid-column: span 8; }
.card--history { grid-column: span 12; }

.card legend {
  padding: 0;
  margin-bottom: 1.1rem;
  font-family: var(--f-display);
  font-size: var(--t-md);
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.55rem;
}
.legend__note {
  font-family: var(--f-mono);
  font-size: var(--t-2xs);
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1rem 1.1rem;
}
.card--history .fields { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.field__label {
  font-family: var(--f-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* number + select — styled off the native controls, no browser chrome */
.control {
  width: 100%;
  font-family: var(--f-mono);
  font-size: var(--t-sm);
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.control:hover { border-color: var(--indigo); }
.control:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
.control:-webkit-autofill,
.control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 40px var(--panel) inset;
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
}
select.control {
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238B8D91' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  cursor: pointer;
}
.control::-webkit-outer-spin-button,
.control::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"].control { -moz-appearance: textfield; }

.field--number { position: relative; }
.field--number .field__suffix {
  position: absolute;
  right: 0.65rem;
  bottom: 0.55rem;
  font-family: var(--f-mono);
  font-size: var(--t-2xs);
  color: var(--muted);
  pointer-events: none;
}

/* segmented rating control — one connected track */
.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0.42rem 0.2rem;
  font-family: var(--f-mono);
  font-size: var(--t-sm);
  color: var(--ink-2);
  border-left: 1px solid var(--line-strong);
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
  user-select: none;
}
.segmented label:first-of-type { border-left: none; }
.segmented .cap { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.02em; }
.segmented label:hover { background: var(--indigo-soft); }
.segmented input:checked + label { background: var(--indigo); color: var(--accent-ink); }
.segmented input:checked + label .cap { color: rgba(26, 20, 8, 0.6); }
.segmented input:focus-visible + label { box-shadow: inset 0 0 0 2px var(--indigo-deep); }

/* ── action bar ───────────────────────────────────────────────────────── */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.75rem);
  background: color-mix(in srgb, var(--panel-raised) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.actionbar__hint { font-family: var(--f-mono); font-size: var(--t-2xs); color: var(--muted); }
@media (max-width: 520px) { .actionbar__hint { display: none; } }
.actionbar__buttons { display: flex; gap: 0.6rem; }

.btn {
  font-family: var(--f-sans);
  font-size: var(--t-sm);
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), opacity 0.15s;
}
.btn--primary { background: var(--indigo); color: var(--accent-ink); }
.btn--primary:hover { background: var(--indigo-deep); }
.btn--primary:disabled { opacity: 0.55; cursor: progress; }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.btn--ghost:hover { border-color: var(--indigo); color: var(--indigo); }

/* ── page-load choreography ───────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.readout { animation: rise 0.5s var(--ease) both; }
.card { animation: rise 0.5s var(--ease) both; }
.card--demographics { animation-delay: 0.06s; }
.card--role { animation-delay: 0.1s; }
.card--compensation { animation-delay: 0.14s; }
.card--satisfaction { animation-delay: 0.18s; }
.card--history { animation-delay: 0.22s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .card--demographics, .card--compensation { grid-column: span 5; }
  .card--role, .card--satisfaction { grid-column: span 7; }
}
@media (max-width: 820px) {
  .readout { grid-template-columns: 1fr; }
  .readout__gauge { max-width: 320px; margin: 0 auto; }
  .card--demographics, .card--role,
  .card--compensation, .card--satisfaction { grid-column: span 12; }
}
