/* ===========================================================
   Triveni Power - engineered-for-the-forces-that-protect.
   Defence & Naval pillar.
   Layout (iertqa.com style):
     · Full-bleed naval image with dark atmospheric overlay
     · Soft warm/cool color glows for depth
     · Title + body anchored top-centre
     · 5 glassmorphic "fact" cards scattered around the stage
   =========================================================== */

.defence {
  /* Light scope - section flows around a centre image with white side
     vignette holding the title + cards. */
  --ink:        #231F20;
  --ink-80:     rgba(35, 31, 32, 0.80);
  --ink-60:     rgba(35, 31, 32, 0.58);
  --accent:     #F58220;

  position: relative;
  background: #F5F4F1;
  color: var(--ink);
  padding: clamp(80px, 10vw, 140px) 0 clamp(80px, 10vw, 140px);
  overflow: hidden;
  isolation: isolate;
  min-height: 720px;
}

/* =========================================================
   BACKGROUND - naval image + dark overlay + colour glows
   ========================================================= */
.defence__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.defence__bg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.defence__tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Uniform white wash over the image so the title (top centre),
     body copy, CTA, and scattered cards all sit on a consistent
     light surface with reliable contrast. */
  background: rgba(255, 255, 255, 0.78);
}
/* Atmospheric colour glows - toned for the white vignette base.
   Multiply blend so the navy + orange wash as soft tints in the
   corners instead of disappearing behind opaque whites. */
.defence__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.22;
  pointer-events: none;
  mix-blend-mode: multiply;
  will-change: transform;
}
.defence__glow--a {
  top: -10%;
  left: -10%;
  width: 55vw;
  height: 55vw;
  max-width: 720px;
  max-height: 720px;
  background: radial-gradient(circle, rgba(27, 90, 144, 0.55) 0%, rgba(27, 90, 144, 0) 70%);
  animation: defenceGlowA 18s ease-in-out infinite alternate;
}
.defence__glow--b {
  bottom: -15%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  max-width: 700px;
  max-height: 700px;
  background: radial-gradient(circle, rgba(245, 130, 32, 0.40) 0%, rgba(245, 130, 32, 0) 70%);
  animation: defenceGlowB 22s ease-in-out infinite alternate;
}
@keyframes defenceGlowA {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, 30px) scale(1.06); }
}
@keyframes defenceGlowB {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-30px, -20px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .defence__glow { animation: none !important; }
}

/* =========================================================
   CONTAINER - header + stage
   ========================================================= */
.defence__container {
  position: relative;
  z-index: 2;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* =========================================================
   HEADER - title + body (top-centre)
   ========================================================= */
.defence__header {
  text-align: center;
  margin: 0 auto clamp(48px, 6vw, 88px);
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 2vw, 28px);
}

.defence__title {
  font-family: var(--font-display);
  font-size: var(--fs-l);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.12;
  text-transform: uppercase;
  color: #231F20;
  margin: 0;
  text-shadow: 0 1px 16px rgba(255, 255, 255, 0.70);
}
.defence__title em {
  font-style: normal;
  color: var(--accent);
}

.defence__body {
  font-family: var(--font-display);
  font-size: var(--fs-m);
  line-height: 1.65;
  color: rgba(35, 31, 32, 0.8);
  margin: 0 auto;
  max-width: 64ch;
  text-shadow: 0 1px 10px rgba(255, 255, 255, 0.55);
}
.defence__body strong {
  font-weight: 600;
  color: #231F20;
}

/* =========================================================
   CTA - Explore pill below the body copy
   ========================================================= */
/* .defence__cta visual rules moved to css/buttons.css under
   canonical .btn--accent kind. Layout helper + arrow nudge stay. */
.defence__cta {
  align-self: center;
}
.defence__cta svg {
  transition: transform var(--dur-fast) var(--ease-out);
}
.defence__cta:hover svg {
  transform: translateX(3px);
}

/* =========================================================
   STAGE - relative box that holds the 5 floating cards
   On mobile/tablet, cards stack normally; on desktop they
   are absolutely positioned for the iertqa scattered look.
   ========================================================= */
.defence__stage {
  position: relative;
  min-height: clamp(340px, 28vw, 420px);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 1.2vw, 18px);
}

/* Tablet + desktop - BENTO MOSAIC. The DGQA / Indian-Navy card sits in a
   larger hero cell; the other four are supporting tiles. Explicit grid
   areas tile cleanly with NO orphaned second row. All tiles share the
   SAME colour - the hero is distinguished only by size (larger icon/text),
   not by an accent fill. */
@media (min-width: 768px) {
  .defence__stage {
    display: grid;
    align-items: stretch;
    gap: clamp(14px, 1.4vw, 20px);
    max-width: 1040px;
    margin-inline: auto;
    min-height: 0;
  }
  /* Higher specificity (.defence__stage .defence__card) so this beats the
     base .defence__card { max-width: 380px }, which is declared later in the
     file. Without it the hero tile stays capped at 380px and can't span the
     full-width grid area on tablet. */
  .defence__stage .defence__card {
    position: relative;
    inset: auto;
    width: auto;
    max-width: none;
    margin: 0;
  }
  .defence__card--1 { grid-area: c1; }
  .defence__card--2 { grid-area: c2; }
  .defence__card--3 { grid-area: c3; }
  .defence__card--4 { grid-area: c4; }
  .defence__card--5 { grid-area: c5; }

  /* Hero tile - larger icon + text only (no accent fill, so the colour
     stays consistent with the other tiles). */
  .defence__card.defence__card--1 .defence__card-icon {
    width: 56px;
    height: 56px;
  }
  .defence__card.defence__card--1 .defence__card-icon svg,
  .defence__card.defence__card--1 .defence__card-icon img {
    width: 32px;
    height: 32px;
  }
  .defence__card.defence__card--1 .defence__card-text {
    font-size: clamp(17px, 1.35vw, 20px);
  }
}

/* Tablet: hero full-width on top, four supporting tiles as a 2 x 2. */
@media (min-width: 768px) and (max-width: 1023px) {
  .defence__stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "c1 c1"
      "c2 c3"
      "c4 c5";
  }
}

/* Desktop: tall hero on the left, 2 x 2 supporting grid on the right. */
@media (min-width: 1024px) {
  .defence__stage {
    grid-template-columns: 1.12fr 1fr 1fr;
    grid-template-areas:
      "c1 c2 c3"
      "c1 c4 c5";
  }
  /* Tall hero - stack icon over text to use the vertical space. */
  .defence__card.defence__card--1 {
    flex-direction: column;
    justify-content: flex-start;
    gap: clamp(16px, 1.4vw, 22px);
  }
}

/* =========================================================
   MOBILE - image at top, heading + body anchored to the
   bottom of the image (overlapping where it fades to white),
   icons + active text in a clean white area below the image.
   ========================================================= */
@media (max-width: 767px) {
  .defence {
    padding: 0;
    min-height: 0;
    background: #fff;
  }

  /* Image becomes a contained block at the top, not a full-bleed bg. */
  .defence__bg {
    position: relative;
    inset: auto;
    width: 100%;
    height: 62vh;
    min-height: 420px;
  }

  /* White gradient - clear at top of image, fading to opaque
     white at the bottom so the heading sits readably over it. */
  .defence__tint {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    height: 62vh;
    min-height: 420px;
    background: linear-gradient(180deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0) 38%,
      rgba(255, 255, 255, 0.55) 70%,
      rgba(255, 255, 255, 0.92) 90%,
      rgba(255, 255, 255, 1) 100%);
  }

  /* Atmospheric glows aren't needed on the white-image layout. */
  .defence__glow { display: none; }

  /* Pull the container up so the header overlaps the bottom of
     the image area, sitting on the white-fade portion. */
  .defence__container {
    position: relative;
    z-index: 2;
    padding: 0 clamp(18px, 4vw, 24px) clamp(40px, 8vw, 60px);
    margin-top: -180px;
  }

  .defence__header {
    background: transparent;
    padding: 0;
    margin: 0 0 clamp(24px, 6vw, 36px);
    text-align: center;
    align-items: center;
  }
  .defence__title {
    color: #231F20;
    text-shadow: none;
    text-align: center;
  }
  .defence__body {
    color: rgba(35, 31, 32, 0.8);
    text-shadow: none;
    text-align: center;
  }
  .defence__body strong { color: #231F20; }
  .defence__cta { align-self: center; }

  /* Stage: row 1 = 5 icon tabs, row 2 = shared text panel. */
  .defence__stage {
    position: relative;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: auto;
    column-gap: 8px;
    row-gap: clamp(14px, 4vw, 20px);
    margin-top: clamp(16px, 4vw, 24px);
    padding-bottom: 0;
    min-height: 0;
  }

  /* Cards: bare grid cells holding only the icon. The text
     element inside the card is hidden - JS copies it into
     the shared .defence__panel below. */
  .defence__card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    max-width: none;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .defence__card:hover {
    transform: none;
    border-color: transparent;
  }

  /* The icon - tappable square tab. */
  .defence__card-icon {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    max-width: 56px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(35, 31, 32, 0.14);
    border-radius: 14px;
    cursor: pointer;
    transition: background 200ms var(--ease-out),
                border-color 200ms var(--ease-out),
                transform 200ms var(--ease-out),
                box-shadow 200ms var(--ease-out);
  }
  .defence__card-icon:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }
  .defence__card[data-active="true"] .defence__card-icon {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(245, 130, 32, 0.35);
  }
  .defence__card[data-active="true"] .defence__card-icon svg,
  .defence__card[data-active="true"] .defence__card-icon img {
    filter: brightness(0) invert(1);
  }

  /* Hide each card's own text - the shared panel below renders
     whichever card is active (filled by JS). */
  .defence__card-text {
    display: none;
  }

  /* Shared text panel - sits as a full-width grid row 2 child.
     JS copies the active card's text into it. */
  .defence__panel {
    grid-column: 1 / -1;
    padding: clamp(16px, 4vw, 22px) clamp(18px, 5vw, 24px);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(35, 31, 32, 0.12);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(35, 31, 32, 0.10);
    text-align: center;
    font-family: var(--font-display);
    font-size: var(--fs-m);
    line-height: 1.55;
    color: #231F20;
    min-height: 64px;
  }
  .defence__panel:empty {
    display: none;
  }
}

/* Hide the shared panel on tablet/desktop - only used in the
   mobile icon-tabs layout. */
@media (min-width: 768px) {
  .defence__panel { display: none; }
}

/* =========================================================
   CARD - glassmorphic capsule with icon + bold + body text
   ========================================================= */
.defence__card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: clamp(14px, 1.4vw, 18px);
  padding: clamp(14px, 1.2vw, 18px) clamp(18px, 1.6vw, 22px);
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(255, 255, 255, 0.78) 100%);
  border: 1px solid rgba(35, 31, 32, 0.12);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(18px) saturate(140%);
          backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 14px 36px rgba(35, 31, 32, 0.12);
  max-width: 380px;

  /* Hidden by default; .is-in fires the popup on scroll-into-view. */
  opacity: 0;
  transform: translateY(18px) scale(0.88);
  transition:
    opacity 620ms cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 620ms cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 380ms var(--ease-out);
  transition-delay: var(--pop-delay, 0s);
  will-change: transform, opacity;
}
.defence__card.is-in {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.defence__card:hover {
  transform: translateY(-3px) scale(1);
  border-color: rgba(245, 130, 32, 0.50);
  transition-delay: 0s;
}

/* Each card's popup is triggered by JS based on scroll progress,
   so per-card --pop-delay is left at the default 0s. */

@media (prefers-reduced-motion: reduce) {
  .defence__card {
    opacity: 1;
    transform: none;
    transition: none !important;
  }
}

.defence__card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(245, 130, 32, 0.12);
  border: 1px solid rgba(245, 130, 32, 0.22);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.defence__card-icon svg,
.defence__card-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.defence__card-text {
  font-family: var(--font-display);
  font-size: var(--fs-m);
  font-weight: 400;
  line-height: 1.45;
  color: #231F20;
  margin: 0;
}
.defence__card-text strong {
  font-weight: 400;
  color: #231F20;
}

/* (The old 1280px+ absolute "scatter" layout was removed — the cards now
   use the centered flex-wrap above on every width >= 768px.) */


/* =========================================================
   DARK MODE - mirror the white-vignette treatment but with a
   dark side vignette over the image, light text, dark glass
   cards/tabs, and a dark shared panel on mobile.
   ========================================================= */

[data-theme="dark"] .defence {
  --ink:    #F4F0EA;
  --ink-80: rgba(244, 240, 234, 0.84);
  --ink-60: rgba(244, 240, 234, 0.60);
  background: #0A0809;
  color: var(--ink);
}

/* Dark mode - uniform dark wash for consistent text contrast. */
[data-theme="dark"] .defence__tint {
  background: rgba(6, 6, 10, 0.78);
}

/* Aurora glows breathe on dark bg again - screen blend works here. */
[data-theme="dark"] .defence__glow {
  mix-blend-mode: screen;
  opacity: 0.45;
}

[data-theme="dark"] .defence__title {
  color: #FFFFFF;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] .defence__body {
  color: rgba(255, 255, 255, 0.84);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.40);
}
[data-theme="dark"] .defence__body strong {
  color: #FFFFFF;
}

/* .defence__cta dark-mode override removed - canonical .btn--accent
   in css/buttons.css now provides the orange tinted-glass treatment
   in both themes. */

[data-theme="dark"] .defence__card {
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.10) 0%,
    rgba(255, 255, 255, 0.04) 100%);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.10) inset,
    0 18px 40px rgba(0, 0, 0, 0.40);
}
[data-theme="dark"] .defence__card:hover {
  border-color: rgba(245, 130, 32, 0.55);
}
[data-theme="dark"] .defence__card-text,
[data-theme="dark"] .defence__card-text strong {
  color: #FFFFFF;
}
[data-theme="dark"] .defence__card-icon {
  background: rgba(245, 130, 32, 0.14);
  border-color: rgba(245, 130, 32, 0.32);
}

/* Mobile dark overrides - match the image-at-top layout but
   fade to dark instead of white, dark-glass tabs + panel. */
@media (max-width: 767px) {
  [data-theme="dark"] .defence {
    background: #0A0809;
  }

  [data-theme="dark"] .defence__tint {
    background: linear-gradient(180deg,
      rgba(6, 6, 10, 0)    0%,
      rgba(6, 6, 10, 0)    38%,
      rgba(6, 6, 10, 0.55) 70%,
      rgba(6, 6, 10, 0.92) 90%,
      rgba(6, 6, 10, 1)    100%);
  }

  [data-theme="dark"] .defence__title { color: #FFFFFF; text-shadow: none; }
  [data-theme="dark"] .defence__body  { color: rgba(255, 255, 255, 0.84); text-shadow: none; }
  [data-theme="dark"] .defence__body strong { color: #FFFFFF; }

  /* Icon tabs: dark frosted glass with orange icons. */
  [data-theme="dark"] .defence__card-icon {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
  }
  /* Active state is the same orange-filled tab in both themes. */
  [data-theme="dark"] .defence__card[data-active="true"] .defence__card-icon {
    background: var(--accent);
    border-color: var(--accent);
  }

  /* Shared panel - dark surface, light text. */
  [data-theme="dark"] .defence__panel {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: #FFFFFF;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.40);
  }
}
