/* ==========================================================================
   LATEX CV WEB RENDER STYLE (原版 LaTeX 渲染风格)
   ========================================================================== */

:root {
  /* Classic LaTeX Fonts */
  --font-latex: 'Lora', 'Times New Roman', Times, Georgia, serif;
  
  /* Color Scheme: Standard LaTeX PDF */
  --bg-page: #f0f2f5;       /* Background behind the paper sheet */
  --bg-paper: #ffffff;      /* The paper sheet itself */
  --text-main: #000000;     /* Pure black text */
  --link-color: #0000ee;    /* LaTeX hyperref blue link */
  --rule-color: #000000;    /* titlerule color */
  
  --paper-width: 800px;
  --transition-speed: 0.2s;
}

[data-theme="dark"] {
  /* Inverted Paper Theme for comfortable reading */
  --bg-page: #121212;
  --bg-paper: #1e1e1e;
  --text-main: #e0e0e0;
  --link-color: #58a6ff;
  --rule-color: #e0e0e0;
}

/* ==========================================================================
   RESET & DOCUMENT STYLES
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-latex);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 11pt; /* Exact match for LaTeX 11pt article */
  padding: 40px 10px;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* ==========================================================================
   THE PAPER SHEET
   ========================================================================== */

.paper-sheet {
  background-color: var(--bg-paper);
  max-width: var(--paper-width);
  margin: 0 auto;
  padding: 1.2in; /* standard LaTeX margins (geometry margin=1in, adjusted for web padding) */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* Subtle shadow only to distinguish the sheet of paper */
  position: relative;
  min-height: 297mm; /* Standard A4 height aspect */
}

[data-theme="dark"] .paper-sheet {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Utility to remove paper margins for a flat fluid layout on mobile */
@media (max-width: 768px) {
  body {
    padding: 0;
  }
  
  .paper-sheet {
    padding: 30px 20px;
    box-shadow: none;
    min-height: auto;
  }
  
  .cv-header {
    flex-direction: column-reverse;
    gap: 16px;
    padding-top: 20px;
  }
  
  .cv-header-right {
    margin-left: 0;
  }
}

/* ==========================================================================
   TYPOGRAPHY & CONTENT
   ========================================================================== */

p {
  margin-bottom: 6px; /* LaTeX \parskip=3pt approx */
}

a {
  color: var(--link-color);
  text-decoration: underline;
}

a:hover {
  text-decoration: none;
}

/* Header */
.cv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5in; /* \vspace{0.5cm} */
}

.cv-header-left {
  flex: 1;
}

.cv-header-right {
  margin-left: 20px;
}

.cv-profile-photo {
  width: 240px;
  height: 180px; /* 1440 * 1080 aspect ratio (4:3) scale down */
  border: 1px solid var(--rule-color);
  object-fit: cover;
}

.cv-name {
  font-size: 1.7em; /* \LARGE */
  font-weight: bold;
  margin-bottom: 8px;
}

.cv-contact-table {
  border-collapse: collapse;
  font-size: 1em;
  line-height: 1.5;
}

.cv-contact-table td {
  padding: 2px 0;
  vertical-align: top;
}

.cv-contact-table td.contact-label {
  font-weight: bold;
  width: 90px; /* Perfect aligned spacing for labels */
}

/* Introduction */
.cv-introduction {
  margin-bottom: 0.4in;
  text-align: justify;
}

.cv-introduction p {
  margin-bottom: 12px;
}

.cv-introduction p:last-child {
  margin-bottom: 0;
}

/* Sections */
.cv-section {
  font-size: 1.2em; /* \large */
  font-weight: bold;
  margin-top: 1.5em; /* \titlespacing */
  margin-bottom: 0.6em;
  border-bottom: 1px solid var(--rule-color); /* \titlerule */
  padding-bottom: 2px;
  text-transform: none;
}

/* Layout helpers for LaTeX formatting */
.flex-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
}

.item-title {
  font-weight: bold;
}

.item-date {
  font-weight: normal;
}

.sub-item {
  margin-top: 2px;
}

.item-description {
  margin-top: 6px;
  text-align: justify;
}

/* Spacing utilities matching LaTeX \vspace */
.vspace-sm {
  height: 0.2cm;
}

.vspace-md {
  height: 0.3cm;
}

/* ==========================================================================
   MINIMAL UTILITIES
   ========================================================================== */

/* Discreet Theme Toggle in top-right corner */
.theme-switch-container {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-btn {
  background: transparent;
  border: 1px solid var(--rule-color);
  color: var(--text-main) !important;
  text-decoration: none !important;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-family: var(--font-latex);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.theme-btn:hover {
  opacity: 1;
}

.theme-btn .fa-sun {
  display: none;
}

[data-theme="dark"] .theme-btn .fa-moon {
  display: none;
}

[data-theme="dark"] .theme-btn .fa-sun {
  display: inline;
}

@media (max-width: 768px) {
  .theme-switch-container {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
  }
}
