/* Colors and themes */
:root {
  --bg-light: #fdfdff;
  --color-light: #1C1C1D;
  --bg-dark: #393d3f;
  --color-dark: #fdfdff;
  --color-link-light: #ce645f;
  --color-link-dark: #e08f8b;
  --color-link-hover-light: #81403a;
  --color-link-hover-dark: #fdc7c4;
}

/* Theme classes */
.latex-light-auto {
  background-color: var(--bg-light);
  color: var(--color-light);
}
.latex-light-auto a {
  color: var(--color-link-light) !important;
}
@media (hover: hover) and (pointer: fine) {
  .latex-light-auto a:hover {
    color: var(--color-link-hover-light) !important;
  }
}
.latex-dark-auto {
  background-color: var(--bg-dark);
  color: var(--color-dark);
}
.latex-dark-auto a {
  color: var(--color-link-dark) !important;
}
@media (hover: hover) and (pointer: fine) {
  .latex-dark-auto a:hover {
    color: var(--color-link-hover-dark) !important;
  }
}

/* Base reset + typography */
*:not(h1) {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  font-size: 0.975em;
  hyphens: manual;
}
h1 {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  margin: 0px;
}
body {
  margin-top: 50px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  line-height: 1.6;
}

/* Container to match homepage */
.container {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  padding: 20px;
}

/* Header layout */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.header-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.back-link {
  text-decoration: none;
  font-weight: 500;
  color: var(--color-link-light) !important;
}
@media (hover: hover) and (pointer: fine) {
  .back-link:hover {
    color: var(--color-link-hover-light) !important;
  }
}

/* Loading + spinner */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 250px;
  justify-content: center;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(57, 61, 63, 0.2);
  border-top: 4px solid var(--color-link-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error panel */
.error {
  text-align: center;
  padding: 20px;
}
.error button {
  background: #dc3545;
  color: white;
  padding: 8px 15px;
  border: none;
  border-radius: 5px;
}
@media (hover: hover) and (pointer: fine) {
  .error button:hover {
    background: #c82333;
  }
}
.hidden {
  display: none !important;
}

/* Resume iframe */
#resume-frame {
  width: 100%;
  height: 800px;
  border: 2px solid var(--color-link-light);
  border-radius: 5px;
  display: none;
}

/* Download button: use the exact same visual rules as #refresh-btn */
.download-section {
  display: flex;
  width: 100%;
  justify-content: center;
  margin: 20px 0px;
}

.download-btn {
  background: var(--color-link-light);
  color: var(--bg-light);
  border: none;
  padding: 16px 30px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.2s, transform 0.2s ease;
  font-weight: 500;
  display: inline-block;
  text-decoration: none;
  min-height: 40px;
  font-size: 1.25em;
}

/* Hover (light theme) */
@media (hover: hover) and (pointer: fine) {
  .download-btn:hover {
    background: var(--color-link-hover-light);
    transform: translateY(-2px);
  }
}

/* Active state for better mobile feedback */
.download-btn:active {
  transform: translateY(1px);
}

/* Disabled state (matches #refresh-btn:disabled) */
.download-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
  color: var(--bg-light);
  transform: none;
}

/* Dark-theme overrides (matches .latex-dark-auto #refresh-btn) */
.latex-dark-auto .download-btn {
  background: var(--color-link-dark);
  color: var(--bg-dark) !important;
}
@media (hover: hover) and (pointer: fine) {
  .latex-dark-auto .download-btn:hover {
    background: var(--color-link-hover-dark);
  }
}

/* Info panel */
.info-panel {
  padding: 20px 0;
}
.info-panel h3 {
  margin-bottom: 10px;
}
.last-updated,
.commit-info {
  padding: 8px 0;
  border-bottom: 0.5px solid currentColor;
  opacity: 0.7;
}

/* Theme toggle button */
.btn {
  position: fixed !important;
  height: 55px !important;
  border: none;
  border-radius: 100%;
  padding: 10px;
  box-shadow: none;
}
.btn:active {
  box-shadow: none;
  outline: none;
}
.btn-light {
  background-color: var(--bg-light);
  color: var(--color-light);
  transition: 0.15s ease-in background-color;
}
@media (hover: hover) and (pointer: fine) {
  .btn-light:hover {
    cursor: pointer;
    background-color: #dddcda;
  }
}
.btn-dark {
  background-color: var(--bg-dark);
  color: var(--color-dark);
  transition: 0.15s ease-in background-color;
}
@media (hover: hover) and (pointer: fine) {
  .btn-dark:hover {
    cursor: pointer;
    background-color: #54565a;
  }
}
#toggle-theme {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Dark theme overrides */
.latex-dark-auto .back-link {
  color: var(--color-link-dark) !important;
}
@media (hover: hover) and (pointer: fine) {
  .latex-dark-auto .back-link:hover {
    color: var(--color-link-hover-dark) !important;
  }
}
.latex-dark-auto .spinner {
  border-color: rgba(253, 253, 255, 0.2);
  border-top: 4px solid var(--color-link-dark);
}
.latex-dark-auto .download-btn {
  background: var(--color-link-dark);
  color: var(--color-dark);
}
@media (hover: hover) and (pointer: fine) {
  .latex-dark-auto .download-btn:hover {
    background: var(--color-link-hover-dark);
    transform: translateY(-2px);
  }
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .container {
    padding: 15px;
    margin-top: 10px;
  }

  header {
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
  }

  .header-left {
    width: 100%;
  }

  .download-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 1em;
    min-height: 44px; /* Better touch target */
  }

  .download-section {
    margin: 25px 0;
  }

  #resume-frame {
    height: 70vh;
    min-height: 500px;
  }

  .info-panel {
    padding: 25px 0;
  }

  .info-panel h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
  }

  .info-panel p {
    line-height: 1.7;
    margin-bottom: 15px;
  }
}

@media (max-width: 949px) {
  body {
    margin-top: 20px;
  }

  .container {
    padding: 12px;
  }

  .back-link {
    font-size: 0.95em;
    margin-bottom: 8px;
    display: block;
  }

  .download-btn {
    padding: 14px 20px;
    font-size: 0.95em;
    border-radius: 8px;
  }

  #resume-frame {
    height: 65vh;
    min-height: 450px;
    border-radius: 8px;
  }

  .info-panel h3 {
    font-size: 1em;
  }

  .info-panel p {
    font-size: 0.9em;
    line-height: 1.6;
  }

  .last-updated,
  .commit-info {
    font-size: 0.85em;
    padding: 10px 0;
  }
}

/* Extra small screens (phones in landscape) */
@media (max-width: 360px) {
  .container {
    padding: 10px;
  }

  .download-btn {
    font-size: 0.9em;
    padding: 12px 16px;
  }

  #resume-frame {
    height: 60vh;
    min-height: 400px;
  }
}
