/* Analiza pola sił — layered on top of styles.css and kolo-zycia.css.
   Force-field analysis: a central horizontal "action" bar with
   supporting forces above and restraining forces below.
   A single large arrow on each side visually channels the forces
   into the action box (subtle background-like, ~25% opacity). */

:root {
  --force-supporting: oklch(43% 0.095 153); /* forest — push */
  --force-supporting-soft: oklch(94% 0.04 145 / 0.55);
  --force-supporting-wash: oklch(43% 0.095 153 / 0.07);
  --force-supporting-glow: oklch(43% 0.095 153 / 0.18);

  --force-restraining: oklch(58% 0.13 35); /* coral — resistance */
  --force-restraining-soft: oklch(94% 0.04 35 / 0.55);
  --force-restraining-wash: oklch(58% 0.13 35 / 0.07);
  --force-restraining-glow: oklch(58% 0.13 35 / 0.18);
}

/* ---------- Force-field layout ---------- */

.forcefield {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 0;
  padding: 24px 22px 24px;
  background: var(--paper);
  border: 1px solid oklch(85% 0.02 130);
  border-radius: 14px;
  box-shadow:
    0 1px 0 oklch(100% 0 0 / 0.5) inset,
    0 14px 40px oklch(35% 0.05 130 / 0.06);
}

.force-side {
  display: flex;
  flex-direction: column;
  /* No gap — head/list spacing is set by head margins so it can match
     the forcefield top/bottom padding exactly (equal breathing room
     above and below each section title). */
  gap: 0;
}

.force-side-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 4px;
}

/* Equal breathing room above and below each section title — both sides
   feel symmetric inside the forcefield. The 24px matches .forcefield's
   top/bottom padding, so the title sits with the same gap on both sides. */
.force-side-supporting .force-side-head {
  margin-bottom: 24px;
}

.force-side-restraining .force-side-head {
  margin-top: 24px;
}

.force-side-label {
  margin: 0;
  font-family: Georgia, Times New Roman, serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.force-side-supporting .force-side-label {
  color: var(--force-supporting);
}

.force-side-restraining .force-side-label {
  color: var(--force-restraining);
}

.force-side-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.force-side-supporting .force-side-count {
  background: var(--force-supporting-soft);
  color: var(--force-supporting);
}

.force-side-restraining .force-side-count {
  background: var(--force-restraining-soft);
  color: var(--force-restraining);
}

/* List of force cards — 2-column grid on desktop, 1-column on mobile. */
.force-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

/* ---------- Single force card ---------- */

.force-arrow {
  --accent: var(--force-supporting);
  --accent-glow: var(--force-supporting-glow);

  position: relative;
  display: grid;
  grid-template-columns: 1fr 30px;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  background: oklch(98% 0.012 96 / 0.85);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition:
    border-color 180ms var(--ease),
    background 180ms var(--ease),
    box-shadow 180ms var(--ease);
  animation: force-in 280ms var(--ease);
}

.force-side-restraining .force-arrow {
  --accent: var(--force-restraining);
  --accent-glow: var(--force-restraining-glow);
}

@keyframes force-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.force-arrow:focus-within {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--accent-glow);
  z-index: 1;
}

.force-arrow input {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.94rem;
  color: var(--ink);
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  transition: border-color 180ms var(--ease);
}

.force-arrow input::placeholder {
  color: oklch(60% 0.02 130);
  font-size: 0.88rem;
  font-style: italic;
}

.force-arrow input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.force-arrow .force-remove {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.force-arrow .force-remove svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
}

.force-arrow .force-remove:hover,
.force-arrow .force-remove:focus-visible {
  background: oklch(92% 0.025 32);
  color: oklch(45% 0.13 32);
  outline: none;
}

/* "Add" button — small icon-only round button parked in the
   right corner of the section head. Out of the way, doesn't
   compete with the title or the funnel arrow. */
.force-add {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--accent, var(--force-supporting));
  border-radius: 50%;
  background: var(--accent-wash, transparent);
  color: var(--accent, var(--force-supporting));
  font: inherit;
  cursor: pointer;
  transition:
    background 180ms var(--ease),
    transform 180ms var(--ease),
    box-shadow 180ms var(--ease);
}

.force-side-supporting .force-add {
  --accent: var(--force-supporting);
  --accent-wash: var(--force-supporting-wash);
  --accent-glow: var(--force-supporting-glow);
}

.force-side-restraining .force-add {
  --accent: var(--force-restraining);
  --accent-wash: var(--force-restraining-wash);
  --accent-glow: var(--force-restraining-glow);
}

.force-add svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
}

/* Hide the visual label — aria-label on the button covers a11y. */
.force-add span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.force-add:hover,
.force-add:focus-visible {
  background: var(--accent);
  color: var(--paper);
  outline: none;
  transform: translateY(calc(-50% - 1px));
  box-shadow: 0 4px 12px var(--accent-glow);
}

.force-add[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  transform: translateY(-50%);
}

/* ---------- Channel arrows ----------
   A row of 5 thick arrows between forces and the action box.
   Each tip starts as a hollow outline; tips fill in left-to-right
   as the user types into the corresponding force input. Mobile
   shows max 3 tips. */

.force-bigarrow {
  position: relative;
  margin: 14px 0;
  pointer-events: none;
  user-select: none;
}

.force-bigarrow.is-supporting {
  color: var(--force-supporting);
}

.force-bigarrow.is-restraining {
  color: var(--force-restraining);
}

.bigarrow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.bigarrow-tip {
  width: 56px;
  height: 48px;
  display: block;
  flex-shrink: 0;
}

.bigarrow-tip svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Restraining tips point up — same SVG, flipped vertically per-tip
   so left-to-right fill order stays consistent with supporting. */
.force-bigarrow.is-restraining .bigarrow-tip {
  transform: scaleY(-1);
}

/* Outline state (default): hollow stroke, dimmed. */
.bigarrow-tip path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  opacity: 0.32;
  transition:
    fill 260ms var(--ease),
    opacity 260ms var(--ease),
    stroke-width 200ms var(--ease);
}

/* Filled state — applied to the first N tips where N = data-filled. */
.force-bigarrow[data-filled="1"] .bigarrow-tip:nth-child(-n+1) path,
.force-bigarrow[data-filled="2"] .bigarrow-tip:nth-child(-n+2) path,
.force-bigarrow[data-filled="3"] .bigarrow-tip:nth-child(-n+3) path,
.force-bigarrow[data-filled="4"] .bigarrow-tip:nth-child(-n+4) path,
.force-bigarrow[data-filled="5"] .bigarrow-tip:nth-child(-n+5) path {
  fill: currentColor;
  fill-opacity: 0.88;
  stroke: currentColor;
  stroke-opacity: 0.88;
  stroke-width: 1;
  opacity: 1;
}

/* ---------- Center action box ---------- */

.force-action {
  display: flex;
  justify-content: center;
}

.force-action-inner {
  width: 100%;
  max-width: 720px;
  padding: 20px 24px 18px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, oklch(96% 0.03 145 / 0.65), oklch(94% 0.04 100 / 0.45)),
    var(--paper);
  border: 1.5px solid oklch(42% 0.1 153 / 0.35);
  box-shadow:
    0 8px 22px oklch(35% 0.05 145 / 0.12),
    inset 0 0 0 1px oklch(100% 0 0 / 0.5);
}

.force-action-label {
  display: block;
  margin: 0 0 6px;
  font-family: Georgia, Times New Roman, serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-green);
}

.force-action-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: Georgia, Times New Roman, serif;
  font-size: 1.18rem;
  line-height: 1.35;
  color: var(--ink-green);
  resize: none;
  padding: 0;
}

.force-action-input::placeholder {
  color: oklch(55% 0.025 135);
  font-style: italic;
  font-size: 1rem;
}

.force-action-input:focus {
  outline: none;
}

/* ---------- Result view ---------- */

.forcefield-result {
  /* Read-only preview keeps the same spatial structure. */
  padding: 24px 18px 24px;
  cursor: pointer;
}

/* The caption sits directly under the forcefield card; without this
   margin it's flush against the bottom edge. */
.result-board .grid-caption {
  margin-top: 14px;
  text-align: center;
}

.forcefield-result .force-arrow {
  cursor: pointer;
  animation: none;
}

.forcefield-result .force-arrow:hover {
  border-color: var(--accent);
  background: var(--paper);
}

.forcefield-result .force-arrow input {
  pointer-events: none;
}

.forcefield-result .force-remove,
.forcefield-result .force-add {
  display: none;
}

.forcefield-result .force-action-input {
  pointer-events: none;
  user-select: text;
}

.forcefield-result .force-list:empty::after {
  content: "Nic tu nie wpisałeś.";
  display: block;
  padding: 10px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-style: italic;
  grid-column: 1 / -1;
}

/* ---------- Balance card (right column on result view) ---------- */

.balance-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: oklch(98% 0.012 96 / 0.85);
}

.balance-label {
  margin: 0 0 10px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.balance-bar {
  position: relative;
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: oklch(92% 0.02 100);
  margin-bottom: 12px;
}

.balance-bar-supporting,
.balance-bar-restraining {
  height: 100%;
  transition: width 320ms var(--ease);
}

.balance-bar-supporting {
  background: var(--force-supporting);
  width: 0%;
}

.balance-bar-restraining {
  background: var(--force-restraining);
  width: 0%;
  margin-left: auto;
}

.balance-summary {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
  line-height: 1.5;
}

.balance-summary strong {
  color: var(--ink-green);
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .result-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}

@media (max-width: 720px) {
  /* Bigger uniform padding on mobile so the supporting head at the top
     and the restraining head at the bottom have matching breathing room. */
  .forcefield {
    padding: 24px 14px 24px;
  }

  /* Stack force cards into a single column. */
  .force-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .force-action-inner {
    padding: 16px 18px 14px;
  }

  .force-action-input {
    font-size: 1.05rem;
  }

  .force-action-input::placeholder {
    font-size: 0.94rem;
  }

  .force-bigarrow {
    margin: 10px 0;
  }

  .bigarrow-row {
    gap: 14px;
  }

  .bigarrow-tip {
    width: 44px;
    height: 38px;
  }

  /* Mobile caps the row at 3 tips. */
  .bigarrow-tip:nth-child(n+4) {
    display: none;
  }

  .forcefield-result {
    padding: 20px 14px 22px;
  }
}

@media (max-width: 480px) {
  .force-side-label {
    font-size: 0.76rem;
    letter-spacing: 0.1em;
  }
}
