/* =========================================================
   EXPERIENCE DRAWER (.exp-drawer)
   Side panel with the extended content of a timeline item.
   Right edge on wide screens, bottom sheet on narrow ones.
   Filled by js/ui/experience-drawer.js from the item's markup.
   Own rules so the browser's <dialog> defaults don't leak in.
   The close button reuses .dialog-close (popup.css).
========================================================= */

.exp-drawer {
  /* reset dialog defaults (UA) */
  position: fixed;
  inset: 0 0 0 auto;
  width: min(34rem, 100vw);
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-color);
  border-radius: 0;
  overflow: hidden;

  color: var(--accent-color);
  font-family: var(--font-body);
  line-height: var(--lh-base);

  /* glass, same language as .about-popup */
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  box-shadow: -1rem 0 3rem rgba(0, 0, 0, 0.08);

  &[open] {
    display: flex;
    flex-direction: column;
  }

  /* lighter than the global backdrop: the timeline stays recognizable */
  &::backdrop {
    background: var(--overlay-color);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
}

.dark .exp-drawer {
  background: rgba(0, 0, 0, 0.4);
  box-shadow: -1rem 0 3rem rgba(0, 0, 0, 0.3);
}

/* slightly smaller than in the full-screen popup */
.exp-drawer__close {
  top: 1rem;
  right: 1rem;
  i {
    font-size: 1.5rem;
  }
}

/* ---------- Scrollable content ---------- */
.exp-drawer__inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* horizontal swipes go to js/ui/experience-drawer.js (prev/next), not the browser */
  touch-action: pan-y pinch-zoom;
  padding: 4.5rem clamp(1.5rem, 4vw, 2.5rem) 2rem;
}

.exp-drawer__period {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.4em;
  margin-bottom: 0.5rem;
  font-size: var(--fs-8);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  > * {
    white-space: nowrap;
  }
}

.exp-drawer__org {
  margin-bottom: 0.4rem;
  font-size: var(--fs-2);

  /* copied from .timeline__org */
  .timeline__aka {
    font-family: var(--font-body);
    font-size: var(--fs-8);
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-muted);
  }
}

.exp-drawer__role {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 0.6rem;
  margin: 0;
  line-height: var(--lh-snug);
  font-size: var(--fs-8);
  color: var(--text-muted);

  /* copied from .timeline__role (.badge lives inside .layout) */
  .timeline__mode {
    margin-inline-start: -0.3rem;
    &::before {
      content: "· ";
    }
  }
  .timeline__location {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    flex-basis: 100%;
    &::before {
      content: "";
      flex: none;
      width: 1em;
      height: 1em;
      background: currentColor;
      mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-7-6.1-7-11.5a7 7 0 0 1 14 0C19 14.9 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E") center / contain no-repeat;
    }
  }
  .badge {
    display: inline-block;
    padding: 0.15em 0.65em;
    font-size: var(--fs-9);
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid var(--line-color);
    border-radius: 1em;
  }
}

.exp-drawer__body {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-color);

  p {
    margin-bottom: 1em;
    color: color-mix(in srgb, var(--accent-color) 86%, transparent);
    text-wrap: pretty;
    &:last-child {
      margin-bottom: 0;
    }
  }
}

/* ---------- Prev / next ---------- */
.exp-drawer__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--line-color);
}

.exp-drawer__step {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.4em 0.75em;
  font: inherit;
  font-size: var(--fs-8);
  font-weight: 500;
  color: var(--accent-color);
  background: none;
  border: 0;
  border-radius: var(--radius-chip);
  cursor: pointer;

  span {
    font-size: 1.3em;
    line-height: 1;
  }

  &:hover:not(:disabled) {
    background: var(--surface-color);
  }
  &:disabled {
    opacity: 0.35;
    cursor: default;
  }
  &:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }
}

.exp-drawer__count {
  font-size: var(--fs-9);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* ---------- Narrow screens: bottom sheet ---------- */
@media (max-width: 600px) {
  .exp-drawer {
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    max-height: 88dvh;
    border-left: 0;
    border-top: 1px solid var(--line-color);
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow: 0 -1rem 3rem rgba(0, 0, 0, 0.12);
  }
  .exp-drawer__inner {
    padding-top: 3.5rem;
  }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .exp-drawer[open] {
    animation: exp-drawer-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @media (max-width: 600px) {
    .exp-drawer[open] {
      animation-name: exp-drawer-up;
    }
  }
}

@keyframes exp-drawer-in {
  from {
    opacity: 0;
    transform: translateX(2rem);
  }
}

@keyframes exp-drawer-up {
  from {
    opacity: 0;
    transform: translateY(2rem);
  }
}
