/* ====================================================================
 * player-active-effects.css — Spec B Task 9.
 *
 * Styles the "Aktive virkninger" accordion on the player character sheet
 * (index.php). The accordion structure itself reuses the shared .hd-richrow__*
 * primitive (player-rich-row.css); this file only adds the section wrapper, the
 * "+ Tilstand" header button, the per-row controls (Afslut / −1 round), the
 * empty-state line, and the muted --kamp (DM-sourced, read-only) row modifier.
 *
 * Tokens only (no hex literals — hex-zero gate). Any px sizing follows the
 * content-zoom grow contract: calc(<px> * var(--hd-player-content-zoom, 1)),
 * so it scales with the player's zoom and stays byte-identical at zoom 1.
 *
 * Safari 16.6 / iPadOS 16: color-mix er understøttet (16.2+).
 *
 * @layer components — same cascade layer as other component CSS.
 * ==================================================================== */

@layer components {

/* Section wrapper — matches the other sheet sections. */
.hd-karakterark__section--activeEffects {
  display: block;
}

/* Base button styles shared by both the text-form and the --circle modifier.
   The base class is kept for backwards-compat; --circle is the new visual. */
.hd-active-effects__add {
  font: inherit;
  font-size: var(--hd-text-ui-small);
  font-weight: var(--hd-weight-semibold);
  color: var(--hd-accent-primary);
  background: var(--hd-surface-2);
  border: 1px solid color-mix(in srgb, var(--hd-accent-primary) 40%, transparent);
  border-radius: var(--hd-radius-sm);
  padding: var(--hd-space-1) var(--hd-space-2);
  min-height: calc(44px * var(--hd-player-content-zoom, 1));
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--hd-motion-fast, 120ms) var(--hd-ease-ui, ease);
}
.hd-active-effects__add:hover {
  background: var(--hd-surface-3);
}
.hd-active-effects__add:focus-visible {
  outline: 2px solid var(--hd-accent-primary);
  outline-offset: 2px;
}

/* --circle modifier: replaces "+ Tilstand" text with a 28px circular icon
   button (spec §2). 28px is the spec-defined size for this control; it sits
   inside a 44px-min-height header so the tap-target for the header row itself
   satisfies WCAG 2.5.5. The button resets min-height from the base class
   since the surrounding header provides the touch surface. */
.hd-active-effects__add--circle {
  width: calc(28px * var(--hd-player-content-zoom, 1));
  height: calc(28px * var(--hd-player-content-zoom, 1));
  min-width: calc(28px * var(--hd-player-content-zoom, 1));
  min-height: unset;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--hd-active-effects-add-icon-size, 18px);
  line-height: var(--hd-leading-icon);
  padding: 0;
  border: none;
  background: var(--hd-accent-primary);
  color: var(--hd-text-on-accent);
}
.hd-active-effects__add--circle:hover {
  background: color-mix(in srgb, var(--hd-accent-primary) 80%, var(--hd-text-primary));
}
.hd-active-effects__manual {
  font: inherit;
  width: calc(28px * var(--hd-player-content-zoom, 1));
  height: calc(28px * var(--hd-player-content-zoom, 1));
  min-width: calc(28px * var(--hd-player-content-zoom, 1));
  min-height: unset;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--hd-active-effects-add-icon-size, 18px);
  line-height: var(--hd-leading-icon);
  padding: 0;
  background: var(--hd-surface-3);
  color: var(--hd-accent-primary);
  border: 1px solid color-mix(in srgb, var(--hd-accent-primary) 35%, transparent);
  cursor: pointer;
}
.hd-active-effects__manual:hover {
  background: color-mix(in srgb, var(--hd-accent-primary) 16%, var(--hd-surface-3));
}
.hd-active-effects__manual-icon {
  --hd-player-icon-size: var(--hd-active-effects-add-icon-size, 18px);
}
.hd-active-effects__dodge {
  font: inherit;
  width: calc(28px * var(--hd-player-content-zoom, 1));
  height: calc(28px * var(--hd-player-content-zoom, 1));
  min-width: calc(28px * var(--hd-player-content-zoom, 1));
  min-height: unset;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--hd-active-effects-add-icon-size, 18px);
  line-height: var(--hd-leading-icon);
  padding: 0;
  background: color-mix(in srgb, var(--hd-accent-warning) 14%, var(--hd-surface-3));
  color: var(--hd-text-primary);
  border: 1px solid color-mix(in srgb, var(--hd-accent-warning) 45%, transparent);
  cursor: pointer;
}
.hd-active-effects__dodge-icon {
  --hd-player-icon-size: var(--hd-active-effects-add-icon-size, 18px);
}
.hd-active-effects__dodge:hover {
  background: color-mix(in srgb, var(--hd-accent-warning) 24%, var(--hd-surface-3));
}
.hd-active-effects__dodge:disabled {
  opacity: 0.55;
  cursor: default;
}
.hd-active-effects__title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: currentColor;
}
.hd-active-effects__title-icon-glyph {
  display: block;
  width: 100%;
  height: 100%;
}
.hd-active-effects__end-temporary {
  font: inherit;
  font-size: var(--hd-text-micro);
  font-weight: var(--hd-weight-semibold);
  color: var(--hd-accent-warning);
  background: color-mix(in srgb, var(--hd-accent-warning) 10%, var(--hd-surface-2));
  border: 1px solid color-mix(in srgb, var(--hd-accent-warning) 36%, transparent);
  border-radius: var(--hd-radius-sm);
  padding: var(--hd-space-1) var(--hd-space-2);
  min-height: calc(32px * var(--hd-player-content-zoom, 1));
  cursor: pointer;
  white-space: nowrap;
}
.hd-active-effects__end-temporary:hover {
  background: color-mix(in srgb, var(--hd-accent-warning) 18%, var(--hd-surface-2));
}
.hd-active-effects__end-temporary:focus-visible {
  outline: 2px solid var(--hd-accent-primary);
  outline-offset: 2px;
}

/* Active-condition chip strip — inline in the group-title area. */
.hd-active-effects__chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 var(--hd-space-1);
  align-items: center;
}

/* Individual chip for each active condition name. */
.hd-active-effects__chip {
  font-size: var(--hd-text-micro);
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--hd-surface-3);
  color: var(--hd-text-primary);
  white-space: nowrap;
}

/* Empty-state line inside the (collapsed) body. */
.hd-active-effects__empty {
  padding: var(--hd-space-2) var(--hd-space-3);
  font-size: var(--hd-text-ui-small);
  font-style: italic;
  color: var(--hd-text-tertiary);
}

/* Per-row control cluster (Afslut / −1 / DM-marker), right-aligned. */
.hd-active-effects__ctrls {
  display: inline-flex;
  align-items: center;
  gap: var(--hd-space-1);
  margin-left: auto;
  flex-shrink: 0;
}

/* Shared button base for the per-row controls. */
.hd-active-effects__end,
.hd-active-effects__minus {
  font: inherit;
  font-size: var(--hd-text-ui-small);
  font-weight: var(--hd-weight-medium);
  border-radius: var(--hd-radius-sm);
  border: 1px solid var(--hd-border-medium);
  background: var(--hd-surface-2);
  color: var(--hd-text-primary);
  padding: var(--hd-space-1) var(--hd-space-2);
  min-width: calc(44px * var(--hd-player-content-zoom, 1));
  min-height: calc(44px * var(--hd-player-content-zoom, 1));
  cursor: pointer;
  transition: background var(--hd-motion-fast, 120ms) var(--hd-ease-ui, ease);
}
.hd-active-effects__end:hover,
.hd-active-effects__minus:hover {
  background: var(--hd-surface-3);
}
.hd-active-effects__end:focus-visible,
.hd-active-effects__minus:focus-visible {
  outline: 2px solid var(--hd-accent-primary);
  outline-offset: 2px;
}

/* "Afslut" = ending an effect → warning-tinted to read as a removal. */
.hd-active-effects__end {
  color: var(--hd-accent-warning);
  border-color: color-mix(in srgb, var(--hd-accent-warning) 40%, transparent);
  background: color-mix(in srgb, var(--hd-accent-warning) 12%, var(--hd-surface-2));
}
.hd-active-effects__end:hover {
  background: color-mix(in srgb, var(--hd-accent-warning) 22%, var(--hd-surface-2));
}

/* "−1" round counter control — numeric, compact. */
.hd-active-effects__minus {
  font-weight: var(--hd-weight-bold);
}

/* Task 9 — oneliner summary under the condition name in expanded rows. */
.hd-active-effects__summary {
  font-size: var(--hd-text-micro);
  color: var(--hd-text-tertiary);
  margin-top: 2px;
  line-height: var(--hd-leading-snug);
}

.hd-active-effects__conflict-note {
  font-size: var(--hd-text-micro);
  line-height: var(--hd-leading-snug);
  color: var(--hd-text-tertiary);
  background: color-mix(in srgb, var(--hd-accent-primary) 8%, transparent);
  border-left: 2px solid color-mix(in srgb, var(--hd-accent-primary) 45%, transparent);
  border-radius: var(--hd-radius-xs, var(--hd-radius-sm));
  padding: var(--hd-space-1) var(--hd-space-2);
  margin-top: var(--hd-space-1);
  overflow-wrap: anywhere;
}

/* Task 9 — rows with a detail modal are pointer-interactive. */
.hd-active-effects__row--clickable {
  cursor: pointer;
}
.hd-active-effects__row--clickable:hover {
  background: var(--hd-surface-2);
}

/* Task 9 — condition detail modal body. */
.hd-condition-detail {
  padding: var(--hd-space-2) 0;
}
.hd-condition-detail__summary {
  display: flex;
  align-items: flex-start;
  gap: var(--hd-space-2);
  font-size: var(--hd-text-ui);
  color: var(--hd-text-primary);
  margin: 0 0 var(--hd-space-2);
  line-height: var(--hd-active-effects-detail-leading, 1.5);
}
.hd-condition-detail__source {
  font-size: var(--hd-text-micro);
  color: var(--hd-text-tertiary);
  margin: 0 0 var(--hd-space-2);
}
.hd-condition-detail__mechanics {
  font-size: var(--hd-text-ui-small);
  color: var(--hd-text-secondary);
  margin: 0;
  line-height: var(--hd-active-effects-detail-leading, 1.5);
}
.hd-condition-detail__fallback {
  display: flex;
  align-items: flex-start;
  gap: var(--hd-space-2);
  font-size: var(--hd-text-ui);
  color: var(--hd-text-secondary);
  margin: 0;
}

.hd-manual-effect {
  display: flex;
  flex-direction: column;
  gap: var(--hd-space-3);
  padding: var(--hd-space-2) 0;
}
.hd-manual-effect__field {
  display: flex;
  flex-direction: column;
  gap: var(--hd-space-1);
}
.hd-manual-effect__label {
  font-size: var(--hd-text-micro);
  font-weight: var(--hd-weight-semibold);
  color: var(--hd-text-secondary);
}
.hd-manual-effect__input,
.hd-manual-effect__select {
  font: inherit;
  font-size: var(--hd-text-ui);
  color: var(--hd-text-primary);
  background: var(--hd-surface-2);
  border: 1px solid var(--hd-border-medium);
  border-radius: var(--hd-radius-sm);
  padding: var(--hd-space-2) var(--hd-space-3);
  min-height: calc(44px * var(--hd-player-content-zoom, 1));
}
.hd-manual-effect__input:focus,
.hd-manual-effect__select:focus {
  outline: 2px solid var(--hd-accent-primary);
  outline-offset: 2px;
}
.hd-manual-effect__actions {
  display: flex;
  justify-content: flex-end;
}
.hd-manual-effect__submit {
  font: inherit;
  font-size: var(--hd-text-ui-small);
  font-weight: var(--hd-weight-semibold);
  color: var(--hd-text-on-accent);
  background: var(--hd-accent-primary);
  border: none;
  border-radius: var(--hd-radius-sm);
  padding: var(--hd-space-2) var(--hd-space-4);
  min-height: calc(44px * var(--hd-player-content-zoom, 1));
  cursor: pointer;
}
.hd-manual-effect__submit:hover {
  background: color-mix(in srgb, var(--hd-accent-primary) 84%, var(--hd-text-primary));
}

/* --kamp modifier: DM/combat-sourced rows are read-only (muted, no controls). */
.hd-active-effects__row--kamp {
  opacity: 0.85;
}
.hd-active-effects__kamp-marker {
  font-size: var(--hd-text-micro);
  font-weight: var(--hd-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hd-text-tertiary);
  background: var(--hd-surface-3);
  border-radius: var(--hd-radius-sm);
  padding: var(--hd-space-1) var(--hd-space-2);
  white-space: nowrap;
}

/* ====================================================================
 * Task 10 — manual "+ Tilstand" picker (lives inside a ModalManager
 * dialog). Lightweight tap-select list of Danish-sorted condition names,
 * with a level-1..6 sub-picker for exhaustion. Tokens only.
 * ==================================================================== */

.hd-condition-picker__list {
  display: flex;
  flex-direction: column;
  gap: var(--hd-space-1);
}

.hd-condition-picker__option {
  font: inherit;
  font-size: var(--hd-text-ui);
  font-weight: var(--hd-weight-medium);
  text-align: left;
  background: var(--hd-surface-2);
  color: var(--hd-text-primary);
  border: 1px solid var(--hd-border-medium);
  border-radius: var(--hd-radius-sm);
  padding: var(--hd-space-2) var(--hd-space-3);
  min-height: calc(44px * var(--hd-player-content-zoom, 1));
  cursor: pointer;
  transition: background var(--hd-motion-fast, 120ms) var(--hd-ease-ui, ease);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hd-condition-picker__option:hover {
  background: var(--hd-surface-3);
}
.hd-condition-picker__option:focus-visible {
  outline: 2px solid var(--hd-accent-primary);
  outline-offset: 2px;
}

/* Task 9 — option name + oneliner summary inside the picker button. */
.hd-condition-picker__option-name {
  font-size: var(--hd-text-ui);
  font-weight: var(--hd-weight-medium);
  color: var(--hd-text-primary);
}
.hd-condition-picker__option-desc {
  font-size: var(--hd-text-micro);
  font-weight: var(--hd-weight-regular);
  color: var(--hd-text-tertiary);
  line-height: var(--hd-condition-picker-desc-leading, 1.3);
}

.hd-condition-picker__sub-label {
  font-size: var(--hd-text-ui);
  font-weight: var(--hd-weight-semibold);
  color: var(--hd-text-secondary);
  padding: var(--hd-space-1) var(--hd-space-1) var(--hd-space-2);
}

.hd-condition-picker__levels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hd-space-2);
}

.hd-condition-picker__level {
  font: inherit;
  font-size: var(--hd-text-ui);
  font-weight: var(--hd-weight-bold);
  min-width: calc(44px * var(--hd-player-content-zoom, 1));
  min-height: calc(44px * var(--hd-player-content-zoom, 1));
  border-radius: var(--hd-radius-sm);
  border: 1px solid color-mix(in srgb, var(--hd-accent-primary) 40%, transparent);
  background: color-mix(in srgb, var(--hd-accent-primary) 14%, var(--hd-surface-2));
  color: var(--hd-accent-primary);
  cursor: pointer;
  transition: background var(--hd-motion-fast, 120ms) var(--hd-ease-ui, ease);
}
.hd-condition-picker__level:hover {
  background: color-mix(in srgb, var(--hd-accent-primary) 24%, var(--hd-surface-2));
}
.hd-condition-picker__level:focus-visible {
  outline: 2px solid var(--hd-accent-primary);
  outline-offset: 2px;
}

/* D1 — per-condition icon. The monochrome Foundry SVG is applied as a CSS
 * mask and tinted with `background-color: currentColor`, so it inherits the
 * surrounding text colour and renders with correct contrast in BOTH light and
 * dark themes (no hard-coded fills). px sizing follows the content-zoom grow
 * contract so it scales with the player's zoom. */
.hd-active-effects__chip-icon,
.hd-active-effects__row-icon,
.hd-condition-detail__title-icon,
.hd-condition-detail__body-icon {
  display: inline-block;
  flex: 0 0 auto;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.hd-active-effects__chip-icon {
  width: calc(13px * var(--hd-player-content-zoom, 1));
  height: calc(13px * var(--hd-player-content-zoom, 1));
  margin-right: calc(4px * var(--hd-player-content-zoom, 1));
  vertical-align: -0.12em;
}
.hd-active-effects__row-icon {
  width: calc(18px * var(--hd-player-content-zoom, 1));
  height: calc(18px * var(--hd-player-content-zoom, 1));
  margin-right: calc(6px * var(--hd-player-content-zoom, 1));
  vertical-align: -0.2em;
}
.hd-condition-detail__title-icon {
  width: 1em;
  height: 1em;
  margin-right: 0.45em;
  vertical-align: -0.12em;
}
.hd-condition-detail__body-icon {
  width: calc(18px * var(--hd-player-content-zoom, 1));
  height: calc(18px * var(--hd-player-content-zoom, 1));
  margin-top: 0.08em;
}

/* Rune-cirkel baggrund (magi §4.4) — placeret bag de aktive virkninger. Selve
 * ringene (.runec .r1/.r2 + animation) defineret i portal-magic.css. Host-klassen
 * scoper z-index-løftet, så delt .hd-richrow__body ikke påvirkes andre steder. */
.hd-active-effects__rune-host { position: relative; }
.hd-active-effects__rune-host .hd-active-effects__rune {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}
.hd-active-effects__rune-host > :not(.hd-active-effects__rune) {
  position: relative;
  z-index: 1;
}

} /* end @layer components */
