/* ── Resume Viewer Styles ─────────────── */

#resume-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
}

/* ── Header ──────────────────────────── */

#resume-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

#resume-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

#resume-header h1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.3rem;
  margin: 0;
}

#resume-header h1 svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent);
  flex-shrink: 0;
}

#back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-surface);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

#back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateX(-2px);
}

#back-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

#download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #e36414);
  box-shadow: 0 4px 16px rgba(251, 139, 36, 0.25);
  transition: all 0.25s ease;
  flex-shrink: 0;
}

#download-btn:hover {
  box-shadow: 0 6px 24px rgba(251, 139, 36, 0.4);
  transform: translateY(-1px);
}

#download-btn:active {
  transform: translateY(0);
}

#download-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Toolbar ─────────────────────────── */

#pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  margin-bottom: 1rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: background 0.35s ease, border-color 0.35s ease;
}

#toolbar-left,
#toolbar-center,
#toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#toolbar-center {
  gap: 0.25rem;
}

#pdf-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

#pdf-toolbar button:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  color: var(--accent);
  border-color: var(--border-subtle);
}

#pdf-toolbar button:active:not(:disabled) {
  transform: scale(0.93);
}

#pdf-toolbar button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#pdf-toolbar button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#zoom-level {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: color 0.35s ease;
}

/* Page info */
#page-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  transition: color 0.35s ease;
}

#page-input {
  width: 36px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-heading);
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.25rem 0.15rem;
  outline: none;
  -moz-appearance: textfield;
  transition: all 0.2s ease;
}

#page-input::-webkit-outer-spin-button,
#page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#page-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(251, 139, 36, 0.15);
}

#page-separator {
  color: var(--text-muted);
  font-weight: 300;
}

#total-pages {
  font-weight: 600;
  color: var(--text-heading);
}

/* Fullscreen icon toggle */
.icon-compress { display: none; }
.is-fullscreen .icon-expand { display: none; }
.is-fullscreen .icon-compress { display: block; }

/* ── PDF Viewer ──────────────────────── */

#pdf-viewer {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  min-height: 500px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-card);
  transition: background 0.35s ease, border-color 0.35s ease;
  margin-bottom: 2rem;
}

#pdf-canvas-wrapper {
  display: none;
  padding: 16px;
  width: fit-content;
  min-width: 100%;
}

#pdf-page-container {
  position: relative;
  display: block;
  margin: 0 auto;
}

#pdf-canvas {
  display: block;
  border-radius: 4px;
  height: auto;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 2px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.35s ease;
}

#pdf-annotation-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
}

.pdf-link-annotation {
  position: absolute;
  pointer-events: all;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.pdf-link-annotation:hover {
  background: rgba(251, 139, 36, 0.12);
  box-shadow: 0 0 0 2px rgba(251, 139, 36, 0.3);
}

[data-theme="light"] #pdf-canvas {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ── Loading state ───────────────────── */

#pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 3rem;
  min-height: 500px;
}

#pdf-loading p {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Spinner ring */
.loader-ring {
  position: relative;
  width: 48px;
  height: 48px;
}

.loader-ring div {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.loader-ring div:nth-child(1) { animation-delay: -0.45s; }
.loader-ring div:nth-child(2) { animation-delay: -0.3s; }
.loader-ring div:nth-child(3) { animation-delay: -0.15s; }

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Error state ─────────────────────── */

#pdf-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  text-align: center;
  min-height: 500px;
}

#pdf-error svg {
  width: 48px;
  height: 48px;
  stroke: var(--heart);
  opacity: 0.7;
}

#pdf-error p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
}

#pdf-error a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  transition: all 0.2s ease;
}

#pdf-error a:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Fullscreen mode ─────────────────── */

#pdf-viewer:fullscreen,
#pdf-viewer:-webkit-full-screen {
  background: var(--bg-page);
  border-radius: 0;
  border: none;
  padding: 1rem;
}

#pdf-viewer:fullscreen #pdf-canvas-wrapper,
#pdf-viewer:-webkit-full-screen #pdf-canvas-wrapper {
  align-items: center;
  height: 100%;
}

/* ════════════════════════════════════════
   RESPONSIVE — MOBILE
   ════════════════════════════════════════ */

/* ── Tablet & small laptop (≤768px) ──── */
@media (max-width: 768px) {
  #resume-container {
    padding: 0.75rem 0.5rem 0.5rem;
  }

  /* Header: single row — back · title · download */
  #resume-header {
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
  }

  #resume-header-left {
    flex-wrap: nowrap;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
  }

  #resume-header h1 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    gap: 0.35rem;
  }

  #resume-header h1 svg {
    width: 18px;
    height: 18px;
  }

  /* Icon-only back button on mobile */
  #back-link {
    font-size: 0;
    padding: 0.35rem;
    min-width: 32px;
    min-height: 32px;
    justify-content: center;
    gap: 0;
  }

  #back-link svg {
    width: 16px;
    height: 16px;
  }

  /* Icon-only download on mobile */
  #download-btn {
    font-size: 0;
    padding: 0.4rem;
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
    gap: 0;
  }

  #download-btn svg {
    width: 16px;
    height: 16px;
  }

  /* ── Sticky toolbar ── */
  #pdf-toolbar {
    position: sticky;
    top: 41px;
    z-index: 50;
    gap: 0;
    padding: 0.3rem 0.35rem;
    border-radius: 0;
    margin: 0 -0.5rem 0.5rem;
    border-left: none;
    border-right: none;
  }

  #pdf-toolbar button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
  }

  #pdf-toolbar button svg {
    width: 15px;
    height: 15px;
  }

  #toolbar-left,
  #toolbar-center,
  #toolbar-right {
    gap: 0.1rem;
  }

  #zoom-level {
    min-width: 30px;
    font-size: 0.68rem;
  }

  #page-input {
    width: 26px;
    font-size: 0.72rem;
    padding: 0.15rem 0.1rem;
  }

  #page-info {
    font-size: 0.72rem;
    gap: 0.15rem;
  }

  /* ── Viewer ── */
  #pdf-viewer {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin: 0 -0.5rem 1rem;
    min-height: 60vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #pdf-canvas-wrapper {
    padding: 6px;
  }

  #pdf-canvas {
    border-radius: 0;
    box-shadow: none;
  }

  [data-theme="light"] #pdf-canvas {
    box-shadow: none;
  }
}

/* ── Small phones (≤480px) ───────────── */
@media (max-width: 480px) {
  #resume-container {
    padding: 0.5rem 0.35rem 0.35rem;
  }

  #resume-header h1 {
    font-size: 0.88rem;
  }

  #resume-header h1 svg {
    width: 15px;
    height: 15px;
  }

  #pdf-toolbar {
    margin-left: -0.35rem;
    margin-right: -0.35rem;
    padding: 0.25rem 0.25rem;
  }

  #pdf-toolbar button {
    width: 28px;
    height: 28px;
  }

  #pdf-toolbar button svg {
    width: 13px;
    height: 13px;
  }

  /* Hide zoom % and fit-to-width button — save toolbar space */
  #zoom-level,
  #zoom-fit-btn {
    display: none;
  }

  #pdf-viewer {
    margin-left: -0.35rem;
    margin-right: -0.35rem;
    min-height: 55vh;
  }

  #pdf-canvas-wrapper {
    padding: 2px;
  }

  .pdf-link-annotation {
    min-height: 24px;
    min-width: 24px;
  }
}

/* ── Touch device optimizations ──────── */
@media (pointer: coarse) {
  .pdf-link-annotation {
    min-height: 28px;
  }

  #pdf-toolbar button {
    min-width: 36px;
    min-height: 36px;
  }

  .pdf-link-annotation:active {
    background: rgba(251, 139, 36, 0.18);
    box-shadow: 0 0 0 2px rgba(251, 139, 36, 0.4);
  }

  #pdf-toolbar button:active:not(:disabled) {
    background: var(--bg-surface-hover);
    color: var(--accent);
  }
}

/* ── Notch-safe footer ───────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}
