/* Base: a light reset, typography, and the components shared by every layer. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
ul,
dl,
dd,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

i {
  font-family: var(--font-mono);
  font-style: normal;
  font-weight: 600;
}

mark {
  background: var(--accent);
  color: var(--on-accent);
  padding: 0 0.14em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus, var(--yellow));
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--solid {
  fill: currentColor;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-4);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  border: var(--border) solid var(--ink);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.noscript {
  position: fixed;
  inset: auto 0 0;
  z-index: var(--z-skip);
  padding: var(--space-4);
  background: var(--red);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5);
  background: var(--surface-raised);
  color: var(--on-raised);
  border: var(--border) solid var(--line);
  box-shadow: var(--shadow-sm) var(--shadow-color);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast);
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--shadow-color);
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--shadow-color);
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn--lg {
  min-height: 56px;
  padding: 0 var(--space-6);
  font-size: var(--text-lg);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.btn[aria-busy='true'] .btn__spinner {
  display: block;
}

.btn[aria-busy='true'] .icon {
  display: none;
}

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

/* ---------------------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------------------- */

.card {
  background: var(--surface-raised);
  color: var(--on-raised);
  border: var(--border) solid var(--line);
  box-shadow: var(--shadow-md) var(--shadow-color);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: 800;
}

.card__note {
  color: var(--on-raised-muted);
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------------------------
 * Form fields
 * ------------------------------------------------------------------------- */

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* A legend refuses to be styled like an ordinary block; floating it makes it behave. */
legend {
  float: left;
  width: 100%;
  padding: 0;
}

legend + * {
  clear: both;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field--plain {
  display: block;
}

.field--plain > legend {
  margin-bottom: var(--space-2);
}

.field__label {
  font-weight: 700;
}

.field__label i {
  margin-left: var(--space-1);
  padding: 1px 7px;
  background: var(--ink);
  color: var(--yellow);
  font-size: 0.9em;
}

.field__control {
  display: flex;
  align-items: stretch;
}

.field__control input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0 var(--space-3);
  background: var(--white);
  border: var(--border) solid var(--ink);
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.field__control input:focus-visible {
  position: relative;
  outline-offset: 0;
  z-index: 1;
}

.field__control input[aria-invalid='true'] {
  background: var(--red-soft);
  border-color: var(--red-text);
}

.field__unit,
.field__action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  background: var(--surface-sunken);
  border: var(--border) solid var(--ink);
  border-left: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.field__action {
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-fast);
}

.field__action:hover {
  background: var(--ink);
  color: var(--yellow);
}

.field__help {
  color: var(--on-raised-muted);
  font-size: var(--text-sm);
}

.field__error {
  color: var(--red-text);
  font-size: var(--text-sm);
  font-weight: 700;
}

.field__error:empty {
  display: none;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: var(--space-5);
}

/* Radio options shaped as number boxes (number of servers) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip-radio {
  position: relative;
  cursor: pointer;
}

.chip-radio input,
.option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip-radio span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--white);
  border: var(--border) solid var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.chip-radio:hover span {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-sm) var(--ink);
}

.chip-radio input:checked + span {
  background: var(--ink);
  color: var(--yellow);
  box-shadow: var(--shadow-sm) var(--pink);
}

.chip-radio input:focus-visible + span,
.option input:focus-visible + .option__body {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Radio options shaped as cards (discipline, capacity) */
.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: var(--space-3);
}

.option {
  position: relative;
  display: block;
  cursor: pointer;
}

.option__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  min-height: 72px;
  padding: var(--space-3) var(--space-4);
  background: var(--white);
  border: var(--border) solid var(--ink);
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.option__body b {
  font-size: var(--text-lg);
  font-weight: 800;
}

.option__body small {
  color: var(--on-raised-muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.option:hover .option__body {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-sm) var(--ink);
}

.option input:checked + .option__body {
  background: var(--ink);
  color: var(--yellow);
  box-shadow: var(--shadow-sm) var(--pink);
}

.option input:checked + .option__body small {
  color: var(--paper);
}

.reveal {
  padding: var(--space-4);
  background: var(--surface-sunken);
  border: var(--border-thin) dashed var(--ink);
}

/* ---------------------------------------------------------------------------
 * Notices
 * ------------------------------------------------------------------------- */

.banner {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-raised);
  color: var(--on-raised);
  border: var(--border) solid var(--line);
  font-size: var(--text-sm);
}

.banner .icon {
  width: 24px;
  height: 24px;
  margin-top: 1px;
}

.banner__title {
  margin-bottom: var(--space-1);
  font-size: var(--text-md);
  font-weight: 800;
}

.banner p + p {
  margin-top: var(--space-2);
}

.banner--danger {
  background: var(--red);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm) var(--ink);
}

.banner--info {
  background: var(--blue);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm) var(--ink);
}

.banner--note {
  border-style: dashed;
}

/* Small colored labels: analytic is blue, simulation is pink */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border: var(--border-thin) solid var(--ink);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag--analytic {
  background: var(--color-analytic);
}

.tag--simulated {
  background: var(--color-simulated);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 6px;
  border: var(--border-thin) solid var(--ink);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.status .icon {
  width: 14px;
  height: 14px;
  stroke-width: 3.5;
}

.status--in {
  background: var(--lime);
}

.status--out {
  background: var(--red);
}

.status--na {
  background: var(--surface-sunken);
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

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