/* Resume page: the PDF preview, its text version and the enlarged view (see
   js/resume-viewer.js). Colours follow the About Me page in both themes. */

.resume-page {
  --resume-accent: #c9a8ff;
  --resume-text: #f5f1fa;
  --resume-muted: rgb(245 241 250 / 72%);
  --resume-bg: #0e0a1c;
  --resume-line: rgb(201 168 255 / 28%);
  --resume-paper-shadow: 0 24px 60px rgb(0 0 0 / 45%);
  --resume-button: #8447ec;
  --resume-button-hover: #7031e0;
  /* Same width as .portfolio-container so content lines up with the header */
  --resume-content-width: min(1150px, calc(100% - clamp(40px, 11.4vw, 168px)));
  min-width: 320px;
  margin: 0;
  padding: 0;
  color: var(--resume-text);
  background: var(--resume-bg);
  font-family: "Plus Jakarta Sans", sans-serif;
}

:root[data-portfolio-theme="light"] .resume-page {
  --resume-accent: #4d317b;
  --resume-text: #0e0a1c;
  --resume-muted: rgb(14 10 28 / 72%);
  --resume-bg: #f5f1fa;
  --resume-line: rgb(77 49 123 / 22%);
  --resume-paper-shadow: 0 0 0 1px rgb(77 49 123 / 10%),
    0 20px 50px rgb(77 49 123 / 18%);
}

.resume-page .portfolio-header {
  width: 100%;
  margin: 0;
}

.resume-page main {
  width: 100%;
}

.resume-page main section {
  margin: 0;
  padding: 0;
  border: 0;
}

.resume-page .resume-section {
  width: var(--resume-content-width);
  margin: clamp(24px, 3vw, 48px) auto clamp(80px, 10vw, 140px);
}

.resume-section__head {
  display: flex;
  max-width: 880px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  margin: 0 auto clamp(24px, 3vw, 40px);
}

.resume-page .resume-section h1 {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--resume-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 3.5vw, 52px);
  font-weight: 400;
  line-height: 1.23;
  text-align: left;
}

/* Download buttons on the page and in the enlarged view */
.resume-download,
.resume-viewer__download {
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  color: #ffffff;
  background-color: var(--resume-button, #8447ec);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.resume-download {
  min-height: 52px;
  padding: 0 24px;
  font-size: clamp(16px, 1.4vw, 18px);
}

.resume-download:hover,
.resume-viewer__download:hover {
  color: #ffffff;
  background-color: var(--resume-button-hover, #7031e0);
  box-shadow: 0 0 0 4px rgb(154 98 246 / 30%);
}

.resume-download:active,
.resume-viewer__download:active {
  box-shadow: 0 0 0 2px rgb(154 98 246 / 30%);
}

.resume-download:focus-visible {
  outline: 3px solid var(--resume-accent);
  outline-offset: 3px;
}

.resume-download svg,
.resume-viewer svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

/* ----- Preview ----- */

.resume-preview {
  max-width: 880px;
  margin: 0 auto;
}

.resume-preview__pages {
  display: grid;
  gap: clamp(20px, 3vw, 32px);
}

/* Each page is a button that opens the enlarged view. The image keeps the
   PDF's proportions, so nothing is cropped. */
.resume-page .resume-preview__page {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--resume-paper-shadow);
  cursor: zoom-in;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.resume-preview__page img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  margin: 0;
}

.resume-preview__page:focus-visible {
  outline: 3px solid var(--resume-accent);
  outline-offset: 4px;
}

@media (hover: hover) {
  .resume-page .resume-preview__page:hover {
    box-shadow: var(--resume-paper-shadow), 0 0 0 4px rgb(154 98 246 / 30%);
    transform: translateY(-2px);
  }
}

/* ----- Text version ----- */

/* The resume text for screen readers, built from the PDF along with the
   page images. Hidden from sight, since the images show the same thing. */
.resume-text {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ----- Enlarged view ----- */

/* The native dialog traps focus and closes on Esc */
html:has(.resume-viewer[open]) {
  overflow: hidden;
}

.resume-viewer {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  color: #f5f1fa;
  background: transparent;
  font-family: "Plus Jakarta Sans", sans-serif;
}

.resume-viewer[open] {
  display: flex;
  flex-direction: column;
  animation: resume-viewer-fade 220ms ease;
}

.resume-viewer::backdrop {
  background: rgb(14 10 28 / 90%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: resume-viewer-fade 220ms ease;
}

.resume-viewer__toolbar {
  display: grid;
  grid-template-areas: "title zoom actions";
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(12px, 2vw, 24px);
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  background: rgb(14 10 28 / 72%);
}

.resume-viewer .resume-viewer__title {
  grid-area: title;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  color: #f5f1fa;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}

.resume-viewer__zoom {
  display: flex;
  grid-area: zoom;
  align-items: center;
  gap: 4px;
}

.resume-viewer__actions {
  display: flex;
  grid-area: actions;
  justify-self: end;
  align-items: center;
  gap: 8px;
}

/* Toolbar buttons share the lightbox's round, translucent style */
.resume-viewer button,
.resume-viewer__download {
  min-width: 44px;
  height: 44px;
  margin: 0;
  font-family: inherit;
  font-size: 15px;
}

.resume-viewer button {
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 999px;
  color: #ffffff;
  background: rgb(255 255 255 / 6%);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease;
}

.resume-viewer .resume-viewer__icon-button {
  width: 44px;
  padding: 0;
}

.resume-viewer button:hover {
  background: rgb(154 98 246 / 45%);
}

.resume-viewer button:active {
  transform: scale(0.96);
}

.resume-viewer button[aria-disabled="true"] {
  opacity: 0.4;
  cursor: default;
}

.resume-viewer button[aria-disabled="true"]:hover {
  background: rgb(255 255 255 / 6%);
}

.resume-viewer button[aria-disabled="true"]:active {
  transform: none;
}

.resume-viewer__download {
  padding: 0 16px;
  --resume-button: #8447ec;
  --resume-button-hover: #7031e0;
}

.resume-viewer button:focus-visible,
.resume-viewer__download:focus-visible {
  outline: 3px solid #c9a8ff;
  outline-offset: 3px;
}

.resume-viewer__level {
  min-width: 58px;
  color: #f5f1fa;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: center;
}

.resume-viewer__scroller {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(16px, 3vw, 32px) clamp(12px, 3vw, 32px) 48px;
}

.resume-viewer__scroller:focus {
  outline: none;
}

.resume-viewer__scroller:focus-visible {
  outline: 3px solid #c9a8ff;
  outline-offset: -3px;
}

.resume-viewer__scroller.is-pannable {
  cursor: grab;
}

.resume-viewer__scroller.is-dragging {
  cursor: grabbing;
  user-select: none;
}

/* As wide as the zoomed pages, so wide pages scroll sideways instead of
   being cut off on the left */
.resume-viewer__pages {
  display: flex;
  width: max-content;
  min-width: 100%;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin: 0 auto;
}

.resume-viewer__pages img {
  display: block;
  max-width: none;
  margin: 0;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgb(0 0 0 / 50%);
  -webkit-user-drag: none;
  user-select: none;
}

.resume-viewer__instructions {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Narrow screens: title and actions on top, zoom controls under them */
@media (max-width: 640px) {
  .resume-viewer__toolbar {
    grid-template-areas:
      "title actions"
      "zoom zoom";
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px 12px;
  }

  .resume-viewer__zoom {
    justify-self: center;
  }
}

/* Very narrow screens: the actions take the whole top row; the dialog is
   still named by the hidden title */
@media (max-width: 400px) {
  .resume-viewer__toolbar {
    grid-template-areas:
      "actions actions"
      "zoom zoom";
  }

  .resume-viewer .resume-viewer__title {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .resume-viewer__actions {
    justify-self: stretch;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .resume-section__head {
    flex-direction: column;
    align-items: stretch;
  }

  .resume-download {
    width: 100%;
  }
}

@keyframes resume-viewer-fade {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resume-viewer[open],
  .resume-viewer::backdrop {
    animation: none;
  }

  .resume-download,
  .resume-viewer__download,
  .resume-viewer button,
  .resume-preview__page {
    transition: none;
  }

  .resume-page .resume-preview__page:hover {
    transform: none;
  }
}
