/* ==========================================================================
   UNIT 2 · THE ENTERPRISE PROBLEM
   --------------------------------------------------------------------------
   Visual idea: "the ecosystem stays — the new requirement plugs in".
   • An orbit diagram: the ERP core (warm portrait) at the centre, the five
     functions it already runs (approvals, procurement, inventory,
     reporting, internal controls) as nodes on the orbit, and a teal
     e-invoicing node that arrives from OUTSIDE and docks onto the orbit
     without moving anything else.
   • Copy column: title, the key statement in a highlighted card, the
     supporting paragraph and an everyday invoice-desk photo.
   Light Cloud surface with soft white/teal glows (contrast to the navy hero).
   ========================================================================== */

.problem {
  background-color: var(--c-cloud);
}

.problem__decor {
  background:
    radial-gradient(ellipse 45% 55% at 25% 50%, rgba(255, 255, 255, 0.95), transparent 70%),
    radial-gradient(ellipse 40% 40% at 90% 10%, rgba(0, 169, 182, 0.10), transparent 70%),
    radial-gradient(ellipse 50% 40% at 70% 100%, rgba(1, 62, 106, 0.06), transparent 70%);
}

[dir="rtl"] .problem__decor {
  scale: -1 1;
}

/* ---------------------------------------------------------------------------
   Layout — copy first on mobile; visual at inline-start from tablet up
   --------------------------------------------------------------------------- */
.problem__grid {
  display: grid;
  gap: clamp(3rem, 6vw, 4.5rem);
  align-items: center;
  grid-template-areas:
    "content"
    "visual";
}

@media (min-width: 48rem) {
  .problem__grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "visual content";
  }
}

@media (min-width: 64rem) {
  .problem__grid {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

.problem__content {
  grid-area: content;
  display: grid;
  gap: var(--space-lg);
  justify-items: center;
  text-align: center;
}

@media (min-width: 48rem) {
  .problem__content {
    justify-items: start;
    text-align: start;
  }
}

/* Key statement card — teal rule on the inline-start edge */
.problem__statement {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  max-inline-size: 32rem;
  padding: var(--space-lg);
  border-radius: var(--r-card);
  border: 1px solid var(--c-ink-a10);
  border-inline-start: 3px solid var(--c-teal);
  background-color: var(--c-white);
  box-shadow: var(--shadow-md);
  text-align: start;
}

.problem__statement-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  border-radius: 12px;
  background-color: var(--c-teal-a12);
  color: var(--c-deep-teal);
}

.problem__statement-icon svg {
  inline-size: 1.5rem;
  block-size: 1.5rem;
}

.problem__statement p {
  font-family: var(--ff-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: var(--lh-tight);
  color: var(--c-ink);
}

.problem__body {
  max-inline-size: 32rem;
}

/* Everyday invoice-desk photo with a small "plug-in" badge */
.problem__photo {
  position: relative;
  inline-size: 100%;
  max-inline-size: 32rem;
  margin-block-start: var(--space-xs);
}

.problem__photo-frame {
  overflow: hidden;
  border-radius: var(--r-card);
  aspect-ratio: 3 / 1.35;
  box-shadow: var(--shadow-md);
}

.problem__photo-frame img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

.problem__photo-badge {
  position: absolute;
  inset-block-end: -1rem;
  inset-inline-end: 1.25rem;
  display: grid;
  place-items: center;
  inline-size: 3rem;
  block-size: 3rem;
  border-radius: 14px;
  background-color: var(--c-teal);
  color: var(--c-navy);
  box-shadow: 0 12px 28px -10px rgba(0, 169, 182, 0.7);
}

.problem__photo-badge svg {
  inline-size: 1.375rem;
  block-size: 1.375rem;
}

/* ---------------------------------------------------------------------------
   Orbit ecosystem diagram
   --------------------------------------------------------------------------- */
.eco {
  grid-area: visual;
  position: relative;
  inline-size: min(100%, 34rem);
  aspect-ratio: 1;
  margin-inline: auto;
}

/* SVG layer: orbit rings, spokes and the e-invoicing connector.
   Coordinates are in a 100×100 box, matching the % positions of the nodes. */
.eco__lines {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  overflow: visible;
}

[dir="rtl"] .eco__lines {
  scale: -1 1; /* nodes use inset-inline-start, so the lines mirror with them */
}

.eco__orbit {
  fill: none;
  stroke: var(--c-ink-a20);
  stroke-width: 0.35;
}

/* Slow-turning dotted outer ring — calm ambient motion */
.eco__halo {
  fill: none;
  stroke: rgba(0, 169, 182, 0.35);
  stroke-width: 0.45;
  stroke-dasharray: 0.4 2.2;
  stroke-linecap: round;
  transform-origin: 50px 50px;
  animation: eco-turn 80s linear infinite;
}

@keyframes eco-turn {
  to { transform: rotate(360deg); }
}

.eco__spoke {
  stroke: var(--c-ink-a20);
  stroke-width: 0.3;
  stroke-dasharray: 1 1.4;
}

.eco__connector {
  fill: none;
  stroke: var(--c-teal);
  stroke-width: 0.6;
  stroke-linecap: round;
}

.eco__dock {
  fill: var(--c-teal);
}

/* Centre: ERP core portrait */
.eco__core {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inline-size: 34%;
  aspect-ratio: 1;
  translate: -50% -50%;
  z-index: 2;
}

[dir="rtl"] .eco__core {
  translate: 50% -50%;
}

.eco__core-photo {
  inline-size: 100%;
  block-size: 100%;
  overflow: hidden;
  border-radius: 50%;
  border: 4px solid var(--c-white);
  box-shadow: var(--shadow-lg);
}

.eco__core-photo img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

/* Ring that lights up teal once the e-invoicing node docks */
.eco__core::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 0.6s var(--ease-out), box-shadow 0.6s var(--ease-out);
}

.eco.is-connected .eco__core::before {
  border-color: rgba(0, 169, 182, 0.55);
  box-shadow: 0 0 0 10px rgba(0, 169, 182, 0.08);
}

.eco__core-badge {
  position: absolute;
  inset-block-end: -0.625rem;
  inset-inline-start: 50%;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding-block: 0.3rem;
  padding-inline: 0.75rem;
  border-radius: var(--r-pill);
  background-color: var(--c-navy);
  color: var(--c-white);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

[dir="rtl"] .eco__core-badge {
  translate: 50% 0;
}

.eco__core-badge svg {
  inline-size: 0.875rem;
  block-size: 0.875rem;
  color: var(--c-teal);
}

/* Function nodes — positioned via --x / --y on the orbit */
.eco__node {
  position: absolute;
  inset-block-start: var(--y);
  inset-inline-start: var(--x);
  translate: -50% -50%;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 0.375rem;
  inline-size: max-content;
  max-inline-size: 7rem;
  text-align: center;
}

[dir="rtl"] .eco__node {
  translate: 50% -50%;
}

.eco__node-icon {
  display: grid;
  place-items: center;
  inline-size: clamp(2.5rem, 2.1rem + 1.6vw, 3.25rem);
  block-size: clamp(2.5rem, 2.1rem + 1.6vw, 3.25rem);
  border-radius: 50%;
  border: 1px solid var(--c-ink-a10);
  background-color: var(--c-white);
  color: var(--c-deep-teal);
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-micro) var(--ease-out),
              box-shadow var(--dur-micro) var(--ease-out);
}

.eco__node-icon svg {
  inline-size: 45%;
  block-size: 45%;
}

.eco__node:hover .eco__node-icon {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.eco__node-label {
  padding-block: 0.15rem;
  padding-inline: 0.5rem;
  border-radius: var(--r-pill);
  background-color: rgba(255, 255, 255, 0.85);
  font-size: clamp(0.6875rem, 0.64rem + 0.2vw, 0.8125rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--c-ink);
}

/* The incoming e-invoicing node: teal, glowing, clearly "new" */
.eco__node--new .eco__node-icon {
  border-color: transparent;
  background: var(--c-teal);
  color: var(--c-navy);
  box-shadow: 0 0 0 6px rgba(0, 169, 182, 0.15), 0 14px 30px -10px rgba(0, 169, 182, 0.8);
}

.eco__node--new .eco__node-label {
  background-color: var(--c-navy);
  color: var(--c-white);
}

/* ---------------------------------------------------------------------------
   Pre-animation state (JS motion only)
   --------------------------------------------------------------------------- */
.js-motion .eco [data-eco-anim] {
  opacity: 0;
}

/* Lines start undrawn (pathLength="1" → a dash of 1 covers the whole line) */
.js-motion .eco__orbit,
.js-motion .eco__connector {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
