/* ---- design tokens (mirror the PDF) -------------------------------------- */
:root {
  --accent: #1F4E79;            /* deep navy, same as the LaTeX accent */
  --accent-rule: rgba(31, 78, 121, 0.35);   /* = accent!35 */
  --muted: rgba(0, 0, 0, 0.55);              /* = black!55 */
  --ink: #1a1a1a;
  --bg: #ffffff;
  --bar-bg: rgba(255, 255, 255, 0.9);        /* sticky top bar */
  --maxw: 820px;
  color-scheme: light;
}

/* Dark theme: applied when JS resolves the OS/saved preference to dark
   (html[data-theme="dark"]). Everything routes through these tokens. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #7fb1e6;                         /* lightened navy for contrast on dark */
  --accent-rule: rgba(127, 177, 230, 0.35);
  --muted: rgba(255, 255, 255, 0.58);
  --ink: #e6e7e9;
  --bg: #14161a;
  --bar-bg: rgba(20, 22, 26, 0.85);
}

/* ---- fonts: SF Compact for Latin, Noto Sans TC for CJK ------------------- */
@font-face {
  font-family: "SF Compact Text";
  src: url("fonts/SF-Compact-Text-Regular.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "SF Compact Text";
  src: url("fonts/SF-Compact-Text-Bold.otf") format("opentype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "SF Compact Text";
  src: url("fonts/SF-Compact-Text-RegularItalic.otf") format("opentype");
  font-weight: 400; font-style: italic; font-display: swap;
}

/* ---- base ---------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  transition: background-color 0.2s ease, color 0.2s ease;
  font-family: "SF Compact Text", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* CJK page: prefer Noto Sans TC, with OS fallbacks. The 67 MB Songti.ttc used
   by the PDF is intentionally NOT shipped to the web. */
body.lang-cjk {
  font-family: "SF Compact Text", "Noto Sans TC", "PingFang TC",
               "Microsoft JhengHei", "Heiti TC", -apple-system, sans-serif;
}

.resume {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

a { color: var(--accent); }

/* ---- top bar: language switcher + theme toggle --------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  background: var(--bar-bg);
  backdrop-filter: saturate(150%) blur(6px);
  border-bottom: 1px solid var(--accent-rule);
}
.lang-switcher {
  display: flex;
  gap: 0.25rem;
}
.lang-switcher button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.lang-switcher button:hover { color: var(--accent); border-color: var(--accent-rule); }
.lang-switcher button.active { color: var(--bg); background: var(--accent); }

/* theme switch: sun -- (sliding knob) -- moon */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  border: 0;
  background: transparent;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
  color: var(--muted);
}
.theme-switch .ico { width: 15px; height: 15px; flex: none; }
.theme-switch .track {
  position: relative;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent-rule);
  transition: background 0.2s ease;
}
.theme-switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s ease;
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(18px); }
.theme-switch[aria-checked="true"] .ico--moon { color: var(--accent); }
.theme-switch[aria-checked="false"] .ico--sun { color: var(--accent); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 999px; }

/* ---- header banner ------------------------------------------------------- */
.resume-header { text-align: center; margin-bottom: 2.2rem; }
.name {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}
.tagline { font-size: 1.1rem; margin: 0 0 0.5rem; }
.actions {
  margin: 1.1rem 0 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.4rem 1.1rem;
  white-space: nowrap;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: var(--bg); }   /* main action; matches .lang-switcher button.active */
.btn--primary:hover { filter: brightness(1.08); }
.btn--secondary { background: transparent; color: var(--accent); }
.btn--secondary:hover { background: var(--accent); color: var(--bg); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ico { width: 1.05em; height: 1.05em; flex: none; }

.summary {
  text-indent: 1.5em;     /* matches the LaTeX intro indent */
  margin: 0 0 1.5rem;
}

/* ---- section headers (= LaTeX \subsection) ------------------------------- */
h2 {
  text-transform: uppercase;
  color: var(--accent);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  margin: 2.2rem 0 0.9rem;
  padding-bottom: 0.3rem;
  border-bottom: 1.5px solid var(--accent-rule);
}

/* ---- entries (= LaTeX \subsubsection with flush-right date) -------------- */
.entry { margin-bottom: 1.3rem; }
.entry h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}
.entry h3 .date {
  font-style: italic;
  font-weight: 400;
  font-size: 0.85em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.location, .detail {
  font-style: italic;
  color: var(--muted);
  margin: 0.1rem 0 0.4rem;
}
.detail { font-style: normal; }

/* ---- lists --------------------------------------------------------------- */
ul { margin: 0.4rem 0; padding-left: 1.4em; }
li { margin: 0.15rem 0; }
li::marker { color: var(--accent); }
.plain-list { list-style: none; padding-left: 0; }
.plain-list li::before { content: "▪"; color: var(--accent); margin-right: 0.6em; }

.load-error {
  background: #fff4f4; border: 1px solid #e0a0a0; color: #842029;
  padding: 0.75rem 1rem; border-radius: 6px;
}
.load-error code { background: rgba(0,0,0,0.06); padding: 0 0.3em; border-radius: 3px; }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 600px) {
  .resume { padding: 1.5rem 1.1rem 3rem; }
  .name { font-size: 1.8rem; }
  .entry h3 { flex-direction: column; gap: 0.1rem; }
  .entry h3 .date { font-size: 0.8rem; }
}

/* ---- print (browser "save as PDF" stays close to the LaTeX look) --------- */
@media print {
  /* always print the light palette, even if the page is in dark mode */
  :root[data-theme="dark"] {
    --accent: #1F4E79;
    --accent-rule: rgba(31, 78, 121, 0.35);
    --muted: rgba(0, 0, 0, 0.55);
    --ink: #1a1a1a;
    --bg: #ffffff;
  }
  .topbar { display: none; }
  .resume { max-width: none; padding: 0; }
  body { font-size: 11pt; }
  a { color: var(--accent); text-decoration: none; }
  /* on paper, drop the download button and show LinkedIn as the plain profile URL */
  .actions { margin: 0.3rem 0 0; }
  .btn { border: 0; padding: 0; }
  .btn--primary { display: none; }
  .btn--secondary .btn-ico, .btn--secondary .btn-label { display: none; }
  .btn--secondary::after { content: attr(href); }
}
