/*
 * EDGE JOURNAL / UIVERSE EDITORIAL CARDS
 * Inspired by the geometric notch and interactive surface of Smit Prajapati's
 * Uiverse card. Reimplemented in native Hugo/CSS; no React or JS dependencies.
 * Applies ONLY to home dispatch cards, featured story and post/taxonomy cards.
 * Existing content, URLs, pagination, and article templates remain unchanged.
 */
:root {
  --ej-ui-surface: #1b233d;
  --ej-ui-surface-hover: #202b49;
  --ej-ui-cyan: #50f6ff;
  --ej-ui-cyan-deep: #049fbb;
  --ej-ui-ink: #f4f8ff;
  --ej-ui-muted: #adc6dd;
  --ej-ui-rule: rgba(170,222,243,.20);
  --ej-ui-focus: #7ceaff;
  --ej-ui-shadow: 0 18px 42px rgba(0,0,0,.26);
  --ej-ui-curve: cubic-bezier(.175,.885,.32,1.275);
}

/* Restored tools rail: keep utilities visible without hiding the editorial nav. */
.left-sidebar .tools-dock {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(80,246,255,.24);
}
.left-sidebar .tools-dock .dock-section-label {
  color: var(--ej-ui-cyan);
}
.left-sidebar .tools-dock-item a,
.left-sidebar .tools-dock-all {
  min-height: 34px;
  border-radius: 8px;
}
.left-sidebar .tools-dock-item a:hover,
.left-sidebar .tools-dock-all:hover {
  color: var(--ej-ui-cyan);
  background: rgba(80,246,255,.08);
}
.left-sidebar .tools-dock-item.current a {
  color: var(--ej-ui-cyan);
  background: rgba(80,246,255,.12);
}
.left-sidebar .language-switch {
  display: flex;
  align-items: center;
  gap: 4px;
}
.left-sidebar .language-switch__option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ej-ui-muted);
  font-size: 11px;
  text-decoration: none;
}
.left-sidebar .language-switch__option.is-active {
  border-color: var(--ej-ui-cyan);
  color: var(--ej-ui-cyan);
  background: rgba(80,246,255,.1);
}
.journal-mobile-language {
  display: flex;
  gap: 8px;
  padding: 14px 0;
}
.journal-mobile-language a {
  padding: 7px 11px;
  border: 1px solid rgba(80,246,255,.35);
  border-radius: 999px;
  color: var(--ej-ui-cyan, #50f6ff);
  text-decoration: none;
}

/* Keep the journal layout; redesign the article tiles rather than the page. */
body.edge-journal-page .ej-dispatches .ej-grid {
  display: grid !important;
  grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  gap: clamp(16px,1.6vw,24px) !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  align-items: stretch !important;
}
body.posts-index-page .posts-card-grid {
  display: grid !important;
  grid-template-columns: repeat(3,minmax(0,1fr)) !important;
  gap: clamp(16px,1.55vw,24px) !important;
  align-items: stretch !important;
}

/* Uiverse's layered rounded card body; scoped to prevent global UI changes. */
body.edge-journal-page .ej-dispatches .ej-card,
body.posts-index-page .posts-card {
  position: relative !important;
  isolation: isolate;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0;
  height: 100%;
  padding: 7px !important;
  overflow: hidden !important;
  border: 1px solid rgba(80,246,255,.15) !important;
  border-radius: 20px !important;
  background: var(--ej-ui-surface) !important;
  color: var(--ej-ui-ink) !important;
  box-shadow: var(--ej-ui-shadow);
  text-decoration: none !important;
  transform: translateY(0) scale(1);
  transition: transform .48s var(--ej-ui-curve), border-color .25s ease,
    background-color .25s ease, box-shadow .3s ease !important;
}
body.edge-journal-page .ej-dispatches .ej-card {
  grid-template-columns: none !important;
  grid-template-rows: none !important;
  min-height: 0 !important;
}
body.posts-index-page .posts-card {
  min-height: 420px !important;
}
body.edge-journal-page .ej-dispatches .ej-card:hover,
body.posts-index-page .posts-card:hover {
  z-index: 3;
  border-color: rgba(80,246,255,.6) !important;
  background: var(--ej-ui-surface-hover) !important;
  box-shadow: 0 22px 56px rgba(0,0,0,.42), 0 0 0 1px rgba(80,246,255,.12);
  transform: translateY(-5px) scale(1.018) !important;
}
body.edge-journal-page .ej-dispatches .ej-card:focus-visible,
body.posts-index-page .posts-card:focus-visible {
  outline: 3px solid var(--ej-ui-focus) !important;
  outline-offset: 4px;
}
body.edge-journal-page .ej-dispatches .ej-card:active,
body.posts-index-page .posts-card:active {
  transform: translateY(-1px) scale(1.005) !important;
}

/* Upper panel is always a safe image viewport, including posts without cover. */
body.edge-journal-page .ej-dispatches .ej-card-art,
body.posts-index-page .posts-card-media {
  position: relative !important;
  inset: auto !important;
  display: block !important;
  flex: 0 0 auto !important;
  align-self: stretch !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  overflow: hidden !important;
  aspect-ratio: 3 / 2 !important;
  border: 0 !important;
  border-radius: 15px !important;
  background: linear-gradient(45deg,var(--ej-ui-cyan-deep),var(--ej-ui-cyan)) !important;
}
body.posts-index-page .posts-card-media { aspect-ratio: 16 / 10 !important; }
body.edge-journal-page .ej-dispatches .ej-card-art img,
body.posts-index-page .posts-card-media img {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center !important;
  background: #0b1222;
  border-radius: 0 !important;
  filter: saturate(.92) contrast(1.02);
  transform: scale(1) !important;
  transition: transform .55s cubic-bezier(.2,.8,.2,1), filter .35s ease !important;
}
body.edge-journal-page .ej-dispatches .ej-card:hover .ej-card-art img,
body.posts-index-page .posts-card:hover .posts-card-media img {
  filter: saturate(1.05) contrast(1.03) !important;
  transform: scale(1.035) !important;
}

/* Slanted notch is a direct adaptation of the original Uiverse geometry. */
body.edge-journal-page .ej-dispatches .ej-card-art::before,
body.posts-index-page .posts-card-media::before {
  content: "EDGE / JOURNAL" !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 5 !important;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 165px !important;
  height: 33px !important;
  padding: 0 24px 0 14px !important;
  background: var(--ej-ui-surface) !important;
  color: #e4f6ff !important;
  clip-path: polygon(0 0,100% 0,calc(100% - 24px) 100%,0 100%);
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font: 700 10px/1 ui-monospace,SFMono-Regular,Menlo,monospace !important;
  letter-spacing: .11em;
  white-space: nowrap;
  pointer-events: none;
}
body.edge-journal-page .ej-dispatches .ej-card-art::after,
body.posts-index-page .posts-card-media::after {
  content: "" !important;
  position: absolute !important;
  z-index: 2 !important;
  inset: 0 !important;
  border-radius: inherit !important;
  background: linear-gradient(0deg,rgba(2,11,24,.48),transparent 35%) !important;
  pointer-events: none;
}
/* Existing dispatch sequence number stays visible in the media panel. */
body.edge-journal-page .ej-dispatches .ej-card-art > span {
  position: absolute !important;
  top: 11px !important;
  right: 13px !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 6 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 35px;
  height: 27px;
  padding: 0 7px;
  border: 1px solid rgba(255,255,255,.35) !important;
  border-radius: 6px !important;
  background: rgba(6,13,28,.5) !important;
  color: #fff !important;
  font: 600 11px/1 ui-monospace,SFMono-Regular,Menlo,monospace !important;
  backdrop-filter: blur(5px);
}

/* Lower panel: full article title, excerpt and three clear editorial facts. */
body.edge-journal-page .ej-dispatches .ej-card-copy {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  min-width: 0;
  padding: clamp(18px,1.65vw,26px) !important;
  background: transparent !important;
}
body.edge-journal-page .ej-dispatches .ej-card-tags { gap: 8px !important; }
body.edge-journal-page .ej-dispatches .ej-card-tags span,
body.posts-index-page .posts-card-cat {
  color: var(--ej-ui-cyan) !important;
  font: 700 11px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace !important;
  letter-spacing: .095em !important;
  text-transform: uppercase;
}
body.edge-journal-page .ej-dispatches .ej-card-copy h3 {
  display: block !important;
  margin: 16px 0 12px !important;
  max-width: none !important;
  overflow: visible !important;
  color: var(--ej-ui-ink) !important;
  font-size: clamp(20px,1.85vw,28px) !important;
  font-weight: 720 !important;
  line-height: 1.13 !important;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
  -webkit-line-clamp: unset !important;
  text-wrap: pretty;
}
body.edge-journal-page .ej-dispatches .ej-card:hover h3,
body.posts-index-page .posts-card:hover h3 {
  color: #e7fcff !important;
}
body.edge-journal-page .ej-dispatches .ej-card-copy > p {
  display: -webkit-box !important;
  margin: 0 0 18px !important;
  overflow: hidden !important;
  color: var(--ej-ui-muted) !important;
  font-size: 15px !important;
  line-height: 1.58 !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3 !important;
}
body.edge-journal-page .ej-dispatches .ej-meta {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto !important;
  padding-top: 15px !important;
  border-top: 1px solid var(--ej-ui-rule) !important;
  color: #bad5e8 !important;
  font: 500 11px/1.35 ui-monospace,SFMono-Regular,Menlo,monospace !important;
  letter-spacing: .03em !important;
}

/* Archive and category views use the exact same media/body language. */
body.posts-index-page .posts-card-top {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 10px !important;
  padding: 18px 16px 0 !important;
}
body.posts-index-page .posts-card-date {
  color: #a0b9d0 !important;
  font: 500 11px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace !important;
}
body.posts-index-page .posts-card h3 {
  display: block !important;
  max-width: none !important;
  margin: 15px 16px 11px !important;
  color: var(--ej-ui-ink) !important;
  font-size: clamp(20px,1.52vw,25px) !important;
  font-weight: 720 !important;
  line-height: 1.14 !important;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
body.posts-index-page .posts-card > p {
  display: -webkit-box !important;
  margin: 0 16px 20px !important;
  overflow: hidden !important;
  color: var(--ej-ui-muted) !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
body.posts-index-page .posts-card-foot {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin: auto 16px 0 !important;
  padding: 16px 0 14px !important;
  border-top: 1px solid var(--ej-ui-rule) !important;
  color: #ecfaff !important;
  font: 700 12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace !important;
}
body.posts-index-page .posts-card-foot .posts-card-read {
  color: #bed2e4 !important;
  font-size: 11px !important;
  font-weight: 400 !important;
}
body.posts-index-page .posts-card-foot > span:last-child,
body.posts-index-page .posts-card-foot > span:last-child span {
  color: var(--ej-ui-cyan) !important;
  font-size: 12px !important;
}

/* Preserve the editorial lead story, but carry the notch into its artwork. */
body.edge-journal-page .ej-feature-art::before {
  content: "EDGE / PORTADA" !important;
  position: absolute !important;
  z-index: 5 !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  width: 170px !important;
  height: 36px !important;
  display: flex;
  align-items: center;
  padding-left: 15px;
  color: #fff !important;
  background: #1b233d !important;
  clip-path: polygon(0 0,100% 0,calc(100% - 26px) 100%,0 100%);
  font: 700 11px/1 ui-monospace,SFMono-Regular,Menlo,monospace !important;
  letter-spacing: .1em;
  pointer-events: none;
}
body.edge-journal-page .ej-feature {
  transition: border-color .2s ease,box-shadow .3s ease !important;
}
body.edge-journal-page .ej-feature:hover {
  box-shadow: inset 0 0 0 1px rgba(80,246,255,.25),0 15px 35px rgba(0,0,0,.23);
}

/* Fluid breakpoints keep the cards readable in narrower main columns. */
@media (max-width: 1450px) {
  body.posts-index-page .posts-card-grid {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  }
}
@media (max-width: 1040px) {
  body.edge-journal-page .ej-dispatches .ej-grid {
    grid-template-columns: minmax(0,1fr) !important;
  }
}
@media (max-width: 720px) {
  body.posts-index-page .posts-card-grid {
    grid-template-columns: minmax(0,1fr) !important;
  }
  body.edge-journal-page .ej-dispatches .ej-card-copy {
    padding: 20px !important;
  }
  body.edge-journal-page .ej-dispatches .ej-card-copy h3,
  body.posts-index-page .posts-card h3 {
    font-size: clamp(20px,5.6vw,27px) !important;
  }
  body.edge-journal-page .ej-dispatches .ej-card-art,
  body.posts-index-page .posts-card-media {
    aspect-ratio: 3 / 2 !important;
  }
  body.edge-journal-page .ej-dispatches .ej-card:hover,
  body.posts-index-page .posts-card:hover {
    transform: translateY(-3px) !important;
  }
}
@media (prefers-reduced-motion:reduce) {
  body.edge-journal-page .ej-dispatches .ej-card,
  body.edge-journal-page .ej-dispatches .ej-card-art img,
  body.posts-index-page .posts-card,
  body.posts-index-page .posts-card-media img,
  body.edge-journal-page .ej-feature {
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }
}
