/* Work experience timeline + publications — bundled via resume-app.ts → resume-app.js (see Makefile) */

/*
 * Chronicle-style rows (reference: code copy.html): left accent border only — no full-height
 * spine through the section (avoids the line cutting into body text).
 */

/* Single panel frame; overrides div.section padding/border from arvind_pereira.css */
#work-experience.work-experience--enhanced {
  position: relative;
  margin-top: 0.5rem;
  padding: 0.75rem 0 1rem;
  padding-left: 0;
  background: var(--surface-container-low, #181d18);
  border: none;
  border-left: 2px solid rgba(0, 255, 65, 0.14);
}

.timeline-exp {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  padding: 0;
  background: var(--surface-container-lowest, #0b0f0b);
  border-left: 2px solid rgba(0, 255, 65, 0.22);
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.timeline-exp:hover,
.timeline-exp:focus-within {
  border-left-color: rgba(0, 255, 65, 0.55);
  box-shadow: 0 0 24px rgba(0, 255, 65, 0.06);
}

.timeline-exp__meta {
  flex: 0 0 auto;
  width: 5.5rem;
  min-width: 4.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.85rem 0.35rem 0.85rem 0.5rem;
  border-right: 1px solid rgba(0, 255, 65, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.timeline-exp__years {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--outline, #84967e);
  text-align: right;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.timeline-exp__node {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-container, #00ff41);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 0.15rem;
}

@media (max-width: 640px) {
  .timeline-exp {
    flex-direction: column;
  }

  .timeline-exp__meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(0, 255, 65, 0.1);
    padding: 0.55rem 0.75rem;
  }

  .timeline-exp__node {
    align-self: center;
    margin-bottom: 0;
  }
}

.timeline-exp__inner {
  position: relative;
  flex: 1;
  min-width: 0;
}

.timeline-exp__head {
  /* Used to compute collapsed clip height: N lines × (font-size × line-height) + vertical padding */
  --head-line-height: 1.45;
  --head-pad-y: 0.85rem;
  --head-collapsed-lines: 3;

  position: relative;
  padding: var(--head-pad-y) 2.75rem var(--head-pad-y) 0.5rem;
  cursor: default;
  line-height: var(--head-line-height);
  transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-exp__head p {
  margin: 0;
  line-height: inherit;
}

/* Collapsed: 3 line boxes (font-size × line-height each) + top/bottom padding — no magic em guess */
@media (hover: hover) and (pointer: fine) {
  .timeline-exp:not(:hover):not(:focus-within) .timeline-exp__head {
    max-height: calc(
      var(--head-collapsed-lines) * 1em * var(--head-line-height) + 2 * var(--head-pad-y)
    );
    overflow: hidden;
  }

  .timeline-exp:hover .timeline-exp__head,
  .timeline-exp:focus-within .timeline-exp__head {
    max-height: 80rem;
    overflow: visible;
  }
}

@media not all and (hover: hover) {
  .timeline-exp:not(.timeline-exp--open) .timeline-exp__head {
    max-height: calc(
      var(--head-collapsed-lines) * 1em * var(--head-line-height) + 2 * var(--head-pad-y)
    );
    overflow: hidden;
  }

  .timeline-exp.timeline-exp--open .timeline-exp__head {
    max-height: 80rem;
    overflow: visible;
  }
}

.timeline-exp__head::after {
  content: "";
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.28rem;
  border-right: 2px solid var(--primary-container, #00ff41);
  border-bottom: 2px solid var(--primary-container, #00ff41);
  transform: rotate(45deg);
  opacity: 0.85;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.timeline-exp__body {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-exp__bodyInner {
  overflow: hidden;
  min-height: 0;
}

.timeline-exp__split {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 0.75rem 1rem 0.75rem;
}

@media (min-width: 768px) {
  .timeline-exp__split {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.25rem;
  }
}

.timeline-exp__media {
  flex: 0 0 auto;
  width: 100%;
  max-width: 12rem;
}

.matrix-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(0, 255, 65, 0.2);
  background: rgba(50, 54, 50, 0.5);
  cursor: zoom-in;
  overflow: hidden;
  font: inherit;
  color: inherit;
}

.matrix-thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  filter: grayscale(0.85) contrast(1.15);
  opacity: 0.55;
  transition: opacity 0.3s ease;
}

.matrix-thumb:hover img,
.timeline-exp:hover .matrix-thumb img {
  opacity: 0.85;
}

.matrix-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 255, 65, 0.06) 100%);
  pointer-events: none;
}

.matrix-thumb__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 8px;
  letter-spacing: 0.06em;
  color: rgba(0, 255, 65, 0.45);
  text-transform: uppercase;
  pointer-events: none;
}

.timeline-exp__listwrap {
  flex: 1;
  min-width: 0;
}

.timeline-exp__bullets {
  margin: 0;
  padding-left: 0.5rem;
  list-style: none;
}

.timeline-exp__bullets > li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.4em;
}

.timeline-exp__bullets > li::before {
  content: ">>";
  position: absolute;
  left: 0;
  color: var(--primary-container, #00ff41);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75em;
  opacity: 0.85;
}

/* Expand bullets + thumb only on this card (hover or keyboard focus) */
@media (hover: hover) and (pointer: fine) {
  .timeline-exp:hover .timeline-exp__body,
  .timeline-exp:focus-within .timeline-exp__body {
    grid-template-rows: 1fr;
  }

  .timeline-exp:hover .timeline-exp__head::after,
  .timeline-exp:focus-within .timeline-exp__head::after {
    transform: rotate(225deg);
    margin-top: 0.1rem;
  }
}

@media not all and (hover: hover) {
  .timeline-exp.timeline-exp--open .timeline-exp__body {
    grid-template-rows: 1fr;
  }

  .timeline-exp.timeline-exp--open .timeline-exp__head::after {
    transform: rotate(225deg);
    margin-top: 0.1rem;
  }

  .timeline-exp__head {
    cursor: pointer;
  }
}

/* --- Lightbox --- */
.matrix-lightbox {
  position: relative;
  margin: auto;
  padding: 0;
  border: 1px solid rgba(0, 255, 65, 0.35);
  background: #050805;
  color: var(--on-surface, #e0e4dc);
  max-width: min(96vw, 1100px);
}

.matrix-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.matrix-lightbox__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 86vh;
  object-fit: contain;
}

.matrix-lightbox__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid rgba(0, 255, 65, 0.4);
  background: rgba(0, 0, 0, 0.6);
  color: var(--primary-container, #00ff41);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.matrix-lightbox__close:hover {
  background: rgba(0, 255, 65, 0.15);
}

/* --- Publications --- */
#publications.publications--enhanced .thebibliography {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pub-card {
  position: relative;
  border: 1px solid rgba(0, 255, 65, 0.15);
  background: rgba(8, 12, 8, 0.55);
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

#publications.publications--enhanced .pub-card {
  opacity: 1;
  transform: none;
}

.pub-card:hover,
.pub-card:focus-within {
  border-color: rgba(0, 255, 65, 0.35);
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.05);
}

.pub-card__summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 2.5rem 0.75rem 0.85rem;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  position: relative;
}

.pub-card__chip {
  flex: 0 0 auto;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--primary-container, #00ff41);
}

.pub-card__preview-title {
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--primary, #ebffe2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pub-card__chev {
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.28rem;
  border-right: 2px solid var(--primary-container, #00ff41);
  border-bottom: 2px solid var(--primary-container, #00ff41);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.pub-card__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pub-card__bodyInner {
  overflow: hidden;
  min-height: 0;
}

#publications.publications--enhanced p.bibitem {
  margin: 0;
  padding: 0 0.85rem 1rem 0.85rem;
  border-left: none;
  text-indent: 0;
  margin-left: 0;
  margin-top: 0;
  margin-bottom: 0;
}

@media (hover: hover) and (pointer: fine) {
  .pub-card:hover .pub-card__body,
  .pub-card:focus-within .pub-card__body {
    grid-template-rows: 1fr;
  }

  .pub-card:hover .pub-card__chev,
  .pub-card:focus-within .pub-card__chev {
    transform: rotate(225deg);
    margin-top: 0.1rem;
  }
}

@media not all and (hover: hover) {
  .pub-card.pub-card--open .pub-card__body {
    grid-template-rows: 1fr;
  }

  .pub-card.pub-card--open .pub-card__chev {
    transform: rotate(225deg);
    margin-top: 0.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .timeline-exp,
  .timeline-exp__body,
  .timeline-exp__head,
  .timeline-exp__head::after,
  .pub-card,
  .pub-card__body,
  .pub-card__chev {
    transition-duration: 0.01ms !important;
  }
}
