/* components.css — one class per component, differences as modifiers. */

/* ── Card ── .card · --sm --lg --flush --relative --narrow */
.card {
  background: var(--surface-card);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card--sm { padding: var(--space-4); }
.card--lg { padding: var(--space-6); }
.card--flush { padding: 0; }
.card--relative { position: relative; }
.card--narrow { max-width: 600px; }

/* ── Notice ── boxed message · tones: success danger warning info */
.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: var(--border-width) solid transparent;
}
.notice--avatar { display: flex; align-items: center; gap: var(--space-3); }
.notice--success { background: var(--status-success-bg); border-color: var(--status-success-line); color: var(--color-success); }
.notice--danger  { background: var(--status-danger-bg);  border-color: var(--status-danger-line);  color: var(--color-danger); }
.notice--warning { background: var(--status-warning-bg); border-color: var(--status-warning-line); color: var(--color-warning); }
.notice--info    { background: var(--status-info-bg);    border-color: var(--status-info-line);    color: var(--status-info-text); }

/* ── Badge ── small inline label · tones: neutral success danger warning info · brand: forest gold */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-base);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid transparent;
}
.badge--neutral { background: var(--surface-sunken);     border-color: var(--color-border);          color: var(--color-text-muted); }
.badge--success { background: var(--status-success-bg);  border-color: var(--status-success-line);  color: var(--color-success); }
.badge--danger  { background: var(--status-danger-bg);   border-color: var(--status-danger-line);   color: var(--color-danger); }
.badge--warning { background: var(--status-warning-bg);  border-color: var(--status-warning-line);  color: var(--color-warning); }
.badge--info    { background: var(--status-info-bg);     border-color: var(--status-info-line);     color: var(--status-info-text); }
.badge--forest  { background: var(--color-forest); border-color: var(--color-forest); color: var(--color-text-on-dark); }
.badge--gold    { background: var(--color-gold);   border-color: var(--color-gold);   color: var(--color-dark); }

/* ── Pill ── tag, filter, count, checkbox chip. One shape; differences are modifiers.
   .pill (static) · button/a pills are interactive · --active --checked --danger --check --link
   Container: .pills (wrapping row). */
.pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--surface-page);
  border: var(--border-width) solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-base);
  color: var(--color-text-muted);
}
.pill__count { margin-left: var(--space-1); font-weight: var(--weight-normal); opacity: .75; }

button.pill,
a.pill,
label.pill { cursor: pointer; transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast); }
a.pill { text-decoration: none; }

.pill--checked,
.pill.is-released,
.pill--check:has(input:checked) {
  background: var(--status-success-bg);
  border-color: var(--status-success-line);
  color: var(--color-success);
}
.pill--danger { background: var(--status-danger-bg); border-color: var(--status-danger-line); color: var(--color-danger); }

button.pill { white-space: nowrap; }
button.pill:disabled { cursor: default; }
button.pill:hover:not(:disabled), a.pill:hover,
.pill--active, .pill.is-active {
  background: var(--color-forest);
  border-color: var(--color-forest);
  color: var(--color-text-on-dark);
}
button.pill--active:hover:not(:disabled), a.pill--active:hover {
  background: var(--color-forest-mid);
  border-color: var(--color-forest-mid);
}

/* checkbox pill: hidden input, empty box that becomes a tick when on */
.pill--check { position: relative; gap: var(--space-2); user-select: none; }
.pill--check input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.pill--check:has(input:focus-visible) { outline: var(--border-width-strong) solid var(--color-gold); outline-offset: 2px; }
.pill--check::before {
  content: ""; flex: none; width: 14px; height: 14px; box-sizing: border-box;
  border: 1.5px solid var(--color-text-muted); border-radius: var(--radius-sm); background: var(--surface-raised);
}
.pill--check.is-released::before,
.pill--check:has(input:checked)::before,
.pill.is-released:not(.pill--check)::before {
  content: "\2713"; width: auto; height: auto; border: 0; background: none; font-weight: var(--weight-bold);
}
.pill.is-released:not(.pill--check)::before { margin-right: var(--space-2); }

/* ── Button ── .btn is outline by default · --primary --danger --sm --static · .btn--link is a text link.
   Filter-bar and card-action buttons are .pill, not .btn. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: transparent;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-base);
  color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.btn:hover { background: var(--surface-sunken); border-color: var(--color-text-muted); }
.btn--primary { background: var(--color-forest); border-color: var(--color-forest); color: var(--color-text-on-dark); }
.btn--primary:hover { background: var(--color-forest-mid); border-color: var(--color-forest-mid); }
.btn--danger { background: var(--color-danger); border-color: var(--color-danger); color: var(--color-white); }
.btn--danger:hover { background: var(--color-danger); border-color: var(--color-danger); filter: brightness(.9); }
.btn--sm { padding: var(--space-1) var(--space-3); }
.btn--static { pointer-events: none; }
.btn--link {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--color-forest); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.btn--link:hover { color: var(--color-forest-mid); }

/* ── Form fields ── .form-group > .form-label + .form-input | .form-select | .form-textarea, then .form-hint / .form-error */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--text-sm); font-weight: var(--weight-normal); color: var(--color-text);
}
.form-label-link, .form-label-optional { font-size: var(--text-sm); font-weight: var(--weight-normal); color: var(--color-text-muted); }
.form-label-link:hover { color: var(--color-forest); }
.form-hint { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--color-text-muted); }
.form-error { font-size: var(--text-sm); color: var(--color-danger); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--surface-page);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--color-forest); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--color-text-muted); }
.form-input:disabled, .form-select:disabled { opacity: .7; cursor: not-allowed; }
.form-select {
  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' stroke='%236f6556' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-6);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-textarea--tall { min-height: 120px; }

/* ── Check ── label wrapping a checkbox or radio · .checks is a wrapping row of them */
.check {
  display: flex; align-items: center; gap: var(--space-2);
  padding-block: 3px;
  font-size: var(--text-sm); color: var(--color-text);
  cursor: pointer;
}
.check input { accent-color: var(--color-forest); cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-1); }

/* choice pill: hidden checkbox, forest fill when on */
.pill--select { position: relative; cursor: pointer; }
.pill--select input { position: absolute; opacity: 0; pointer-events: none; }
.pill--select:has(input:checked) { background: var(--color-forest); border-color: var(--color-forest); color: var(--color-text-on-dark); }
.pill--select:has(input:focus-visible) { outline: var(--border-width-strong) solid var(--color-gold); outline-offset: 2px; }

/* ── Switch ── label with text on the left and an on/off track on the right */
.switches {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  cursor: pointer;
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--color-border);
}

.switch:last-child {
  border-bottom: none;
}

.switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__text {
  flex: 1;
}

.switch__label {
  display: block;
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
}

.switch__desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.switch__track {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast);
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-raised);
  transition: transform var(--transition-fast);
}

.switch input:checked~.switch__track {
  background: var(--color-forest);
}

.switch input:checked~.switch__track::after {
  transform: translateX(20px);
}

/* ── Segmented ── one boxed row of choices, one is on. .segmented > .segmented__item (+ .is-active) · --block fills the width.
   Species-page tabs are .pills (a .pill per tab), not .segmented. */
.segmented {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-card);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
}
.segmented--block { display: flex; }
.segmented--block .segmented__item { flex: 1; justify-content: center; }
.segmented__item {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-base);
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.segmented__item:hover { color: var(--color-text); }
.segmented__item.is-active { background: var(--color-forest); color: var(--color-text-on-dark); }

/* ── Popover ── floating panel: dropdown menus, pickers, hover notes. Position it (top/left/width) where it is used.
   --card is the roomier hover-note version. */
.popover {
  position: absolute;
  z-index: var(--z-popover);
  padding: var(--space-1);
  background: var(--surface-page);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.popover--card { padding: var(--space-3); background: var(--surface-card); border-radius: var(--radius-lg); }

/* ── Progress ── .progress (track) > .progress__fill (set width inline) · fill tones --good --warn --bad · --range floats a marker (left + width inline) */
.progress {
  position: relative;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress__fill {
  width: 0;
  height: 100%;
  background: var(--color-forest);
  border-radius: var(--radius-pill);
  transition: width var(--transition-base), background var(--transition-base);
}
.progress__fill--good { background: var(--color-stat-green-strong); }
.progress__fill--warn { background: var(--color-stat-amber-strong); }
.progress__fill--bad  { background: var(--color-stat-red-strong); }
.progress__fill--range { position: absolute; top: 0; bottom: 0; height: auto; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th,
.table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}
.table th { color: var(--color-text-muted); }
