/* RechnerHub Core – Minimal structural system (no heavy theming, CLS-safe)
   - Mobile-first, single column
   - Neutral tokens via CSS variables
   - Result container reserves space to prevent CLS
*/

:root {
  /* Surfaces */
  --rh-bg: #ffffff;
  --rh-surface: #ffffff;
  --rh-border: #d7dbe0;

  /* Text */
  --rh-text: #1b1f24;
  --rh-muted: #5b6570;

  /* UI */
  --rh-focus: #2d6cdf;
  --rh-accent: #2d6cdf;

  /* Status */
  --rh-flag-bg: #fff5d6;
  --rh-flag-border: #f0c36d;
  --rh-flag-text: #5a3a00;

  /* Geometry */
  --rh-radius: 12px;
  --rh-radius-sm: 10px;
  --rh-gap: 14px;
  --rh-pad: 14px;

  /* Typography */
  --rh-font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --rh-font-size: 16px;
  --rh-line: 1.45;

  /* CLS-safe reserved space (default for multi-card results + flags) */
  --rh-results-min-h: 260px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --rh-bg: #0f1216;
    --rh-surface: #151a20;
    --rh-border: #2a313a;

    --rh-text: #e7ecf2;
    --rh-muted: #b1bcc8;

    --rh-focus: #7aa7ff;
    --rh-accent: #7aa7ff;

    --rh-flag-bg: #2a2316;
    --rh-flag-border: #7a5a22;
    --rh-flag-text: #f4d08c;
  }
}

/* Base container */
.rh-master {
  font-family: var(--rh-font);
  font-size: var(--rh-font-size);
  line-height: var(--rh-line);
  color: var(--rh-text);
  background: transparent;
  max-width: 760px;
  margin: 0 auto;
  padding: 0;
}

/* Single-column stack (mobile-first) */
.rh-master,
.rh-card {
  box-sizing: border-box;
}

.rh-card {
  background: var(--rh-surface);
  border: 1px solid var(--rh-border);
  border-radius: var(--rh-radius);
  padding: var(--rh-pad);
  display: flex;
  flex-direction: column;
  gap: var(--rh-gap);
}

/* Input card block */
.rh-card-input {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rh-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.rh-label {
  font-weight: 600;
  color: var(--rh-text);
}

.rh-help {
  font-size: 0.925rem;
  color: var(--rh-muted);
}

/* Inputs */
.rh-input,
.rh-select,
.rh-textarea {
  width: 100%;
  box-sizing: border-box;
  appearance: none;
  border: 1px solid var(--rh-border);
  border-radius: var(--rh-radius-sm);
  padding: 10px 12px;
  background: var(--rh-bg);
  color: var(--rh-text);
  font: inherit;
}

.rh-textarea {
  min-height: 96px;
  resize: vertical;
}

/* Accessible focus styles */
.rh-input:focus,
.rh-select:focus,
.rh-textarea:focus,
.rh-btn:focus {
  outline: 3px solid color-mix(in srgb, var(--rh-focus) 55%, transparent);
  outline-offset: 2px;
}

.rh-input:focus-visible,
.rh-select:focus-visible,
.rh-textarea:focus-visible,
.rh-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--rh-focus) 70%, transparent);
  outline-offset: 2px;
}

/* Buttons */
.rh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--rh-radius-sm);
  border: 1px solid var(--rh-border);
  background: var(--rh-surface);
  color: var(--rh-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
}

.rh-btn:hover {
  border-color: color-mix(in srgb, var(--rh-border) 55%, var(--rh-accent));
}

.rh-btn:active {
  transform: translateY(0);
}

/* Result card block */
.rh-card-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* CLS-safe reserved results container */
.rh-results {
  border: 1px dashed var(--rh-border);
  border-radius: var(--rh-radius-sm);
  padding: 12px;
  background: var(--rh-bg);
  min-height: var(--rh-results-min-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Optional overrides for other tools (future-safe) */
.rh-results.is-compact { --rh-results-min-h: 120px; }
.rh-results.is-tall    { --rh-results-min-h: 360px; }

.rh-result-title { font-weight: 700; }
.rh-result-value { font-size: 1.125rem; font-weight: 700; }

/* Notes / info */
.rh-card-note {
  font-size: 0.95rem;
  color: var(--rh-muted);
  border-top: 1px solid var(--rh-border);
  padding-top: 10px;
}

/* Neutral warning / flag */
.rh-flag {
  border: 1px solid var(--rh-flag-border);
  background: var(--rh-flag-bg);
  color: var(--rh-flag-text);
  border-radius: var(--rh-radius-sm);
  padding: 10px 12px;
}

/* Simple spacing helpers */
.rh-stack {
  display: flex;
  flex-direction: column;
  gap: var(--rh-gap);
}

.rh-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.rh-spacer { height: 10px; }

/* Wider screens: optional label/input alignment */
@media (min-width: 720px) {
  .rh-field.is-inline {
    grid-template-columns: 220px 1fr;
    align-items: center;
    gap: 12px;
  }

  .rh-field.is-inline .rh-label {
    margin: 0;
  }
}
/* RH CLS FIX (A1): prevent Astra header animations/transitions that change layout */
.ast-header-break-point .site-header,
.ast-header-break-point .ast-primary-header-bar,
.ast-header-break-point .ast-mobile-header-wrap,
.ast-header-break-point .ast-builder-layout-element {
  animation: none !important;
  transition: none !important;
}

/* Keep header height stable to avoid jump (tweak if needed) */
.ast-header-break-point .site-header {
  min-height: 56px;
}