/* =======================================================================
   ADJUSTABLE STYLE TOKENS
   Change anything in this :root block to restyle the whole app.
   Colors, fonts, sizes and spacing all live here — nothing below
   hardcodes these values, so tweaking one line updates everywhere.
   ======================================================================= */
:root {
  /* ---- COLORS ---- */
  --color-bg: #08080a; /* page background            */
  --color-panel-bg: #050506; /* inside of each box         */
  --color-panel-border: #f4f4f4; /* thick box outline          */
  --color-text: #ededed; /* stat labels / general text */
  --color-value: #f4c430; /* the numbers (gold)         */
  --color-accent: #d21f1f; /* "RATING" eyebrow (red)     */
  --color-muted: #6d6d72; /* captions / disabled        */
  --color-outline: #ffffff; /* text outline color         */

  /* rating-severity gradient endpoints (best -> worst) */
  --color-sev-good: #3fbf4f;
  --color-sev-mid: #f4c430;
  --color-sev-bad: #d21f1f;

  /* control buttons */
  --color-btn-bg: #111114;
  --color-btn-bg-hover: #1d1d22;
  --color-btn-border: #3a3a40;
  --color-btn-text: #ededed;
  --color-seg-active: #d21f1f;

  /* ---- TYPEFACES ---- */
  --font-display: "Oswald", "Arial Narrow", Impact, sans-serif;
  --font-body: "Barlow", "Helvetica Neue", Arial, sans-serif;

  /* ---- FONT SIZES ---- */
  --fs-caption: 0.72rem; /* "DISPLAY" / "CONTROLS" captions */
  --fs-eyebrow: 1.15rem; /* the word RATING                 */
  --fs-rating: 2.6rem; /* the big rating name             */
  --fs-axis: 0.72rem; /* aggression / exposure sub-line  */
  --fs-label: 1.15rem; /* stat labels                     */
  --fs-value: 1.5rem; /* stat numbers in display         */
  --fs-control: 1rem; /* control labels                  */
  --fs-btn: 1.15rem; /* +/- button glyphs               */

  /* ---- SPACING / SHAPE ---- */
  --gap-panels: 42px; /* space between the two boxes     */
  --panel-pad: 34px; /* padding inside each box         */
  --panel-min-h: 440px; /* minimum box height              */
  --border-width: 3px; /* box outline thickness           */
  --radius: 2px; /* corner rounding                 */
  --row-gap: 14px; /* gap between control rows         */
  --display-row-gap: 10px; /* gap between display rows         */
  --max-width: 960px; /* overall app width                */
}

/* ============================ base ============================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  align-items: start;
  justify-content: center;
  padding: 32px 20px;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: var(--max-width);
  display: flex;
  gap: var(--gap-panels); /* <-- space between display & control */
  align-items: stretch;
}

/* ============================ panels ============================ */
.panel-wrap {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-caption {
  font-family: var(--font-display);
  font-size: var(--fs-caption);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin: 0 0 12px 4px;
}

.panel {
  flex: 1;
  background: var(--color-panel-bg);
  border: var(--border-width) solid var(--color-panel-border);
  border-radius: var(--radius);
  padding: var(--panel-pad);
  min-height: var(--panel-min-h);
}

/* ==================== display panel: rating hero ==================== */
.rating-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-rating);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin-top: 4px;
  color: var(--rating-color, var(--color-text));
  -webkit-text-stroke: 1.4px var(--color-outline);
  paint-order: stroke fill;
  /* fallback outline for engines without text-stroke */
  text-shadow:
    -1px -1px 0 var(--color-outline),
    1px -1px 0 var(--color-outline),
    -1px 1px 0 var(--color-outline),
    1px 1px 0 var(--color-outline);
}
@supports (-webkit-text-stroke: 1px #000) {
  .rating-name {
    text-shadow: none;
  }
}

.rating-name.perfect {
  animation: perfectGlow 2.4s ease-in-out infinite;
}
@keyframes perfectGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 2px rgba(63, 191, 79, 0.35));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(63, 191, 79, 0.75));
  }
}

.axis-line {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: var(--fs-axis);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-muted);
  display: flex;
  gap: 18px;
}
.axis-line b {
  color: var(--color-value);
  font-weight: 600;
}

.rating-divider {
  height: 1px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.28), transparent);
  margin: 22px 0 20px;
}

/* ==================== display panel: stat list ==================== */
.display-list {
  display: flex;
  flex-direction: column;
  gap: var(--display-row-gap);
}

.display-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.display-row .d-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-label);
  letter-spacing: 0.02em;
  color: var(--color-text);
}
.display-row .d-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-value);
  color: var(--color-value);
  min-width: 2ch;
  text-align: right;
}

.display-empty {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-muted);
  font-style: italic;
}

/* ==================== control panel ==================== */
.control-block {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap);
}

/* difficulty segmented control */
.difficulty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.difficulty .c-label {
  font-family: var(--font-display);
  font-size: var(--fs-control);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text);
}
.segments {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.seg {
  flex: 1 1 auto;
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 7px 6px;
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  border: 1px solid var(--color-btn-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.seg:hover {
  background: var(--color-btn-bg-hover);
}
.seg[aria-checked="true"] {
  background: var(--color-seg-active);
  border-color: var(--color-seg-active);
  color: #fff;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.control-row.disabled {
  opacity: 0.32;
}
.control-row .c-label {
  font-family: var(--font-body);
  font-size: var(--fs-control);
  color: var(--color-text);
}
.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--fs-btn);
  line-height: 1;
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  border: 1px solid var(--color-btn-border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.step-btn:hover:not(:disabled) {
  background: var(--color-btn-bg-hover);
  border-color: #55555c;
}
.step-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.step-btn:disabled {
  cursor: not-allowed;
}
.step-btn:focus-visible {
  outline: 2px solid var(--color-value);
  outline-offset: 1px;
}
.step-val {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  min-width: 2.2ch;
  text-align: center;
  color: var(--color-value);
}

/* boolean toggle (suit left on level) */
.toggle-btn {
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 6px 16px;
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  border: 1px solid var(--color-btn-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.toggle-btn[aria-pressed="true"] {
  background: var(--color-seg-active);
  border-color: var(--color-seg-active);
  color: #fff;
}
.toggle-btn:focus-visible {
  outline: 2px solid var(--color-value);
  outline-offset: 1px;
}

/* divider above the view-option toggles */
.options-divider {
  height: 1px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.18), transparent);
  margin: 4px 0;
}

.reset-row {
  margin-top: 8px;
}
.reset-btn {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 14px;
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-btn-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    color 0.12s,
    border-color 0.12s;
}
.reset-btn:hover {
  color: var(--color-text);
  border-color: #55555c;
}

/* ==================== recording / chroma-key mode ====================
   A flat, easily-keyable magenta fills the whole display so an editor can
   remove it with a chroma key, leaving only the outlined text. Magenta is
   used (not green) so it never collides with the green/gold/red rating
   colors — those survive the key while the background drops out.
   ==================================================================== */
body.chroma {
  --color-bg: #ff00ff;
  --color-panel-bg: #ff00ff;
  --color-panel-border: #ff00ff;
}
body.chroma .panel {
  border-color: transparent;
}

/* strong black outline on every readable element so text stays crisp
   against the key color and reads cleanly once the background is removed */
body.chroma .rating-name,
body.chroma .axis-line,
body.chroma .axis-line b,
body.chroma .panel-caption,
body.chroma .display-row .d-label,
body.chroma .display-row .d-value,
body.chroma .display-empty {
  -webkit-text-stroke: 1.2px #000;
  paint-order: stroke fill;
  text-shadow:
    -1.5px -1.5px 0 #000,
    1.5px -1.5px 0 #000,
    -1.5px 1.5px 0 #000,
    1.5px 1.5px 0 #000;
}
@supports (-webkit-text-stroke: 1px #000) {
  body.chroma .rating-name,
  body.chroma .axis-line,
  body.chroma .axis-line b,
  body.chroma .panel-caption,
  body.chroma .display-row .d-label,
  body.chroma .display-row .d-value,
  body.chroma .display-empty {
    text-shadow: none;
  }
}

/* ============================ responsive ============================ */
@media (max-width: 720px) {
  .app {
    flex-direction: column;
  }
  :root {
    --fs-rating: 2.1rem;
  }
}
