/* ==========================================================================
   Crescent Air -- reset, document defaults and form primitives
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd,
ul, ol {
  margin: 0;
}

ul[class],
ol[class] {
  list-style: none;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--surface-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-normal);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 0;
}

/* --- Headings ------------------------------------------------------------
   One scale, applied by class rather than by tag, so a heading's level is
   chosen for document structure and its size for visual hierarchy.        */

.h-page {
  font-size: var(--fs-20);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
}

.h-section {
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}

.h-card {
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}

.text-sub {
  color: var(--text-secondary);
  font-size: var(--fs-13);
}

.text-muted {
  color: var(--text-muted);
  font-size: var(--fs-13);
}

.text-micro {
  color: var(--text-muted);
  font-size: var(--fs-12);
  line-height: var(--lh-snug);
}

/* Tabular figures keep numbers in a column from shifting as they change. */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95em;
  letter-spacing: -0.01em;
}

/* --- Focus ---------------------------------------------------------------
   A single visible focus treatment for the whole product. Focus is never
   removed; :focus-visible keeps it off mouse clicks.                       */

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.icon {
  flex: none;
  vertical-align: middle;
}

/* Content that is announced but not shown, e.g. a chart's data summary. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard users land here first; hidden until focused. */
.skip-link {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  z-index: var(--z-toast);
  padding: var(--s-2) var(--s-4);
  background: var(--c-brand-600);
  color: var(--text-inverse);
  border-radius: var(--r-md);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  transform: translateY(-200%);
  transition: transform var(--t-base) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
  text-decoration: none;
}

/* ==========================================================================
   Form primitives
   Labels are always visible: a placeholder disappears the moment someone
   starts typing, which is exactly when they need the label most.
   ========================================================================== */

.field {
  display: grid;
  gap: var(--s-2);
}

.field + .field {
  margin-top: var(--s-4);
}

.field__label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}

.field__optional {
  color: var(--text-muted);
  font-weight: var(--fw-regular);
}

.field__hint {
  font-size: var(--fs-12);
  color: var(--text-muted);
}

.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  font-size: var(--fs-12);
  color: var(--c-danger-600);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: var(--s-2) var(--s-3);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  color: var(--text-primary);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.textarea {
  min-height: 96px;
  padding: var(--s-3);
  resize: vertical;
  line-height: var(--lh-normal);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-disabled);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--c-brand-500);
  box-shadow: var(--ring);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--c-danger-600);
}

.input[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  box-shadow: var(--ring-danger);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-sunken);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* Native arrow replaced with a token-coloured chevron so selects match
   inputs across browsers. */
.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b8098' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
}

/* Input with a leading icon, used by the global search field. */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group__icon {
  position: absolute;
  left: var(--s-3);
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
}

.input-group .input {
  padding-left: var(--s-8);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  font-size: var(--fs-13);
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--c-brand-600);
  cursor: pointer;
}
