/* Redwood cards — the one component the bundle ships.
 *
 * The style guide is tokens and rules rather than a component spec, and this
 * file is the deliberate exception. A card is the shape every application in
 * the suite draws most, it is the one most often drawn wrong, and every value
 * it needs is already a token: this adds no color, no length and no scale step.
 * Values were read out of the JET 21.0.0 Redwood theme, from .oj-panel and the
 * ListView card layout, and mapped onto the --rw-* names.
 *
 * Load after redwood-tokens.css, and after redwood-dark.css if you use it. Load
 * your own component styles after this, so they can override it.
 *
 * Four things people get wrong when they draw a Redwood card by eye:
 *
 *   A resting card has no shadow. It is a 1px hairline at 12% and nothing else.
 *   Elevation is a decision, taken with .rw-card-shadow-*, not a default.
 *
 *   Redwood prescribes no padding for a card, and this is the one number here
 *   that is a choice rather than a reading. .oj-panel pads 8px, but .oj-panel is
 *   a bare box; a ListView card pads nothing and lets its content template
 *   decide; the Preact Card takes padding as a prop with no default. So
 *   --rw-card-padding is 4x, matching the gutter between cards, because that is
 *   what the applications in this suite had already converged on. .rw-card-tight
 *   gives the 8px panel instead. Change it per application if you have a reason;
 *   do not read 4x as something Oracle published.
 *
 *   The radius is lg, .375rem. Not xl, and not a pill.
 *
 *   Hover is an alpha overlay that composites over the card's own background,
 *   which is why it is a background-image layer rather than a background-color.
 *   Setting background-color here would replace the surface instead of tinting
 *   it, and the card would go transparent to the page behind it.
 *
 * (c) Oracle. Internal brand asset — see NOTICE. */

:root {
  --rw-card-padding: var(--rw-space-4x);
  --rw-card-gutter: var(--rw-space-4x);
  --rw-card-radius: var(--rw-radius-lg);
  --rw-card-min-width: 16rem;
}

/* Redwood's compact density tightens the gutter between cards and leaves the
   padding inside them alone. */
.rw-density-compact {
  --rw-card-gutter: var(--rw-space-3x);
}

.rw-card {
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rw-divider);
  border-radius: var(--rw-card-radius);
  background-color: var(--rw-bg-content);
  padding: var(--rw-card-padding);
  /* Text stays inside the card (STYLE-GUIDE §9a). The card clips to its
     rounded corners, so anything that fails to wrap would vanish silently:
     let long words and figures break, and let a card shrink in a grid. */
  min-width: 0;
  overflow-wrap: break-word;
  /* What am I sitting on. Redwood publishes this so a nested control's alpha
     overlay composites against the card rather than against an assumed white. */
  --rw-current-bg: var(--rw-bg-content);
}

/* The bare panel: .oj-panel's own 8px, for a card that holds one line or one
   control rather than a block of content. */
.rw-card-tight { --rw-card-padding: var(--rw-space-2x); }

/* Elevation, opt in. The steps grow on the Y axis with the blur and stay
   near-black at low alpha; a colored or spread shadow is off-system. */
.rw-card-shadow-xs { box-shadow: var(--rw-shadow-xs); }
.rw-card-shadow-sm { box-shadow: var(--rw-shadow-sm); }
.rw-card-shadow-md { box-shadow: var(--rw-shadow-md); }
.rw-card-shadow-lg { box-shadow: var(--rw-shadow-lg); }
.rw-card-shadow-xl { box-shadow: var(--rw-shadow-xl); }

/* A header band over a body, for a card that is not a single padded box. The
   card drops its own padding so the band can reach the rounded corners. */
.rw-card:has(> .rw-card-head) { padding: 0; }

.rw-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rw-space-3x);
  padding: var(--rw-space-3x) var(--rw-space-4x);
  border-bottom: 1px solid var(--rw-divider);
}

.rw-card-body { padding: var(--rw-space-4x); }
.rw-card-body.rw-flush { padding: 0; }

.rw-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rw-space-3x);
  padding: var(--rw-space-3x) var(--rw-space-4x);
  border-top: 1px solid var(--rw-divider);
}

/* A grid of cards. The gutter is the gutter token, so compact density moves
   every grid at once. */
.rw-card-grid {
  display: grid;
  gap: var(--rw-card-gutter);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--rw-card-min-width)), 1fr));
}

/* Optional clinical information hierarchy, arranged from existing tokens.
   The accent identifies an information group; clinical state stays in a
   labeled badge or banner. These are house patterns, not JET readings. */
.rw-card-accent { border-inline-start: var(--rw-space-1x) solid var(--rw-text-brand); }
.rw-card-head-subtle { background-color: var(--rw-bg-subtle); }
.rw-card-title { margin: 0; font-weight: var(--rw-heading-weight); }
.rw-card-label { font-weight: 600; color: var(--rw-text-primary); }
.rw-card-meta {
  font-size: var(--rw-body-sm-size);
  line-height: var(--rw-body-sm-lh);
  font-weight: 400;
  color: var(--rw-text-secondary);
}
.rw-card-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.rw-card-head > *, .rw-card-foot > * { min-width: 0; overflow-wrap: anywhere; }

/* Opt-in task grouping. These house patterns use existing spacing, type and
   surface tokens; they add no clinical behavior, state or automatic hiding. */
.rw-flow-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rw-space-2x) var(--rw-space-4x);
  min-inline-size: 0;
  padding: var(--rw-space-3x) var(--rw-space-4x);
  border-block-end: 1px solid var(--rw-divider);
  background-color: var(--rw-bg-subtle);
  color: var(--rw-text-primary);
}
.rw-flow-context > * { min-inline-size: 0; overflow-wrap: anywhere; }
.rw-flow-context strong { font-weight: 600; }
.rw-flow-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rw-space-2x);
  min-inline-size: 0;
}
.rw-flow-actions > * { min-inline-size: 0; max-inline-size: 100%; }
.rw-disclosure {
  min-inline-size: 0;
  border-block-start: 1px solid var(--rw-divider);
  color: var(--rw-text-primary);
  overflow-wrap: anywhere;
}
.rw-disclosure > summary {
  box-sizing: border-box;
  min-block-size: var(--rw-space-11x);
  padding: var(--rw-space-3x) var(--rw-space-2x);
  font-weight: 600;
  cursor: pointer;
}
.rw-disclosure > summary:focus-visible {
  outline: 2px solid var(--rw-focus-ring);
  outline-offset: -2px;
}
.rw-disclosure > :not(summary) { min-inline-size: 0; overflow-wrap: anywhere; }
@media (forced-colors: active) {
  .rw-disclosure > summary:focus-visible { outline-color: Highlight; }
}

/* A card that can be chosen. Redwood tints rather than swaps: hover is a
   layer over the card's background, and selection puts a layer of its own
   underneath it, so a selected card under the pointer shows both. */
.rw-card-interactive {
  cursor: pointer;
  /* An interactive card is often a <button>, which does not wrap by default. */
  white-space: normal;
  text-align: start;
  -webkit-tap-highlight-color: transparent;
}

.rw-card-interactive:hover {
  background-image: linear-gradient(var(--rw-bg-hover), var(--rw-bg-hover));
}

.rw-card-interactive:active {
  background-image: linear-gradient(var(--rw-bg-active), var(--rw-bg-active));
}

/* Selection moves the border as well as the fill. The border is what reads at
   a glance across a grid; the fill is what reads once the eye has landed. */
.rw-card-interactive.rw-selected {
  border-color: var(--rw-border-selected);
  background-image: linear-gradient(var(--rw-bg-selected), var(--rw-bg-selected));
  --rw-current-bg: var(--rw-bg-selected);
}

.rw-card-interactive.rw-selected:hover {
  background-image:
    linear-gradient(var(--rw-bg-hover), var(--rw-bg-hover)),
    linear-gradient(var(--rw-bg-selected), var(--rw-bg-selected));
}

/* The card focus ring is not the application focus ring.
 *
 * Everywhere else Redwood draws 2px solid at 2px offset. A card sits in a grid,
 * where an outset ring lands on the neighbour, so the ring goes inside: a
 * dotted hairline one pixel in from the border, drawn by a pseudo-element that
 * takes no pointer events and so cannot swallow the click it is marking. */
.rw-card-interactive:focus-visible {
  outline: none;
}

.rw-card-interactive:focus-visible::after {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  outline: dotted 1px var(--rw-focus-ring);
}

/* Windows high contrast drops author colors. Redwood widens the selected
   border there rather than relying on a hue that will not survive. */
@media (forced-colors: active) {
  .rw-card-interactive.rw-selected { border-width: 3px; }
  .rw-card-interactive:focus-visible::after { outline-color: Highlight; }
}
