/* John Astral 360 · shared typography and form surfaces.
   Preserve density tiers for metadata and status labels, and don't touch logic. */
@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@400;700&family=Amethysta&family=Oxygen:wght@400;700&display=swap');

html[data-ja360-type] {
  --ja360-font-page: "Amethysta", Georgia, serif;
  --ja360-font-card: "Almarai", "Oxygen", Arial, sans-serif;
  --ja360-font-body: "Oxygen", "Segoe UI", Arial, sans-serif;
  --ja360-size-page: 2rem;
  --ja360-size-card: 1.125rem;
  --ja360-size-body: .875rem;
  --ja360-size-control: .875rem;
  --ja360-size-label: .75rem;
  --ja360-line-page: 1.15;
  --ja360-line-card: 1.25;
  --ja360-line-body: 1.5;
  --ja360-line-control: 1.25;
  --ja360-line-label: 1.35;
  --ja360-gold: #dcbf82;
  --ja360-field-ink: #f3f0fa;
  --ja360-field-surface: #1a2338;
  --ja360-dialog-line: rgba(220, 191, 130, .37);
  --ja360-dialog-surface: linear-gradient(145deg, #202a47, #151e34);
  --ja360-dialog-backdrop: rgba(8, 12, 27, .74);
  /* Compatibility for existing templates that reference the prior names. */
  --font-title-main: var(--ja360-font-page);
  --font-title-section: var(--ja360-font-card);
  --font-body: var(--ja360-font-body);
}

@media (max-width: 640px) {
  html[data-ja360-type] { --ja360-size-page: 1.75rem; }
}

/* Legacy section sheets use !important with long selectors. Isolate the
   intentional typography overrides in one layer, independent of those selectors. */
@layer ja360-type {
  html[data-ja360-type],
  html[data-ja360-type] body :where(*):not(:where(svg, svg *, [data-type-role="keep"], [data-type-role="keep"] *, .brand-mark, .nav-icon)) {
    font-family: var(--ja360-font-body) !important;
  }

  html[data-ja360-type] body,
  html[data-ja360-type] :is([data-type-role="body-text"], .section-header-description,
    .module-header-copy > p, .panel-heading > div > p, dialog p, [role="dialog"] p, td):not(:is(.eyebrow, .kicker)),
  html[data-ja360-type] p:not(:where(.eyebrow, .kicker, .assistant-kicker, .subtitle-label,
    [data-type-role]:not([data-type-role="body-text"]), .metric-copy > p, .sidebar-foot p)) {
    font-family: var(--ja360-font-body) !important;
    font-size: var(--ja360-size-body) !important;
    font-weight: 400 !important;
    line-height: var(--ja360-line-body) !important;
  }

  html[data-ja360-type] :is(h2, h3, h4, h5, h6, .card-title, .metric-copy > p,
    .account-purchase-head b, [data-type-role="card-title"]):not(:where([data-type-role="keep"])) {
    font-family: var(--ja360-font-card) !important;
    font-size: var(--ja360-size-card) !important;
    font-weight: 700 !important;
    line-height: var(--ja360-line-card) !important;
    letter-spacing: 0 !important;
    text-wrap: pretty;
  }

  html[data-ja360-type] :is(h1, .module-header-copy > h2, [data-type-role="page-title"]):not(:where([data-type-role="keep"], [data-type-role="card-title"])) {
    font-family: var(--ja360-font-page) !important;
    font-size: var(--ja360-size-page) !important;
    font-weight: 400 !important;
    line-height: var(--ja360-line-page) !important;
    letter-spacing: -.015em !important;
    text-wrap: pretty;
  }

  html[data-ja360-type] :is(h1, h2, h3, h4, h5, h6, .card-title,
    [data-type-role="page-title"], [data-type-role="card-title"]) :where(span, em, b, strong, a):not(:where(.badge, .chip, .count-label, [data-type-role], [data-type-role="keep"] *)) {
    font-family: inherit !important;
  }

  html[data-ja360-type] :is(label, legend, th, .eyebrow, .kicker, .assistant-kicker, [data-type-role="label"]) {
    font-family: var(--ja360-font-body) !important;
    font-size: var(--ja360-size-label) !important;
    font-weight: 700 !important;
    line-height: var(--ja360-line-label) !important;
  }

  html[data-ja360-type] :is(input, textarea, select, option, optgroup,
    .ja360-select-trigger, .ja360-select-value, .ja360-select-option,
    [role="listbox"] [role="option"], [role="combobox"]),
  html[data-ja360-type] :is(dialog, .modal, [role="dialog"]) button:not(:where(.icon-button, .modal-close, .dialog-close, [data-type-role="keep"])) {
    font-family: var(--ja360-font-body) !important;
    font-size: var(--ja360-size-control) !important;
    line-height: var(--ja360-line-control) !important;
  }

  html[data-ja360-type] :is(textarea, select, input:not([type="button"], [type="submit"], [type="reset"]),
    option, .ja360-select-value, .ja360-select-option:not(.is-selected)) {
    font-weight: 400 !important;
  }

  html[data-ja360-type] :is(select, option, optgroup) { color-scheme: dark; }
  html[data-ja360-type] :is(option, optgroup) {
    color: var(--ja360-field-ink);
    background-color: var(--ja360-field-surface);
  }

  html[data-ja360-type] dialog {
    background: var(--ja360-dialog-surface) !important;
    border-color: var(--ja360-dialog-line) !important;
    max-block-size: calc(100dvh - 2rem);
  }
  html[data-ja360-type] dialog::backdrop { background: var(--ja360-dialog-backdrop) !important; }
  html[data-ja360-type] :is(.ja360-select-trigger, select):focus-visible {
    outline: 2px solid var(--ja360-gold) !important;
    outline-offset: 2px;
  }
  html[data-ja360-type] .ja360-select-menu { border-color: var(--ja360-dialog-line) !important; }
  html[data-ja360-type] :is(.ja360-select-option, [role="listbox"] [role="option"]) { overflow-wrap: anywhere; }
}

@media (max-width: 640px) {
  html[data-ja360-type] dialog { max-inline-size: calc(100vw - 1.5rem); }
}
