/* ============================================================
   site-shared.css — Shared structural CSS for all page types
   Loaded before site-overrides.css and page-specific <style>.
   ============================================================ */

/* --- Reset & Custom Properties --------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f2f4f7; --surface: #ffffff; --text: #1c1e24; --muted: #72757e;
  --accent: #2c5f8a; --accent-light: #e6eff8; --border: #dde1e8;
  --serif: 'EB Garamond', Georgia, serif; --sans: 'DM Sans', system-ui, sans-serif;
}
[data-theme="dark"] {
  --bg: #161922; --surface: #1f242d; --text: #e6e8ee; --muted: #9aa0ad;
  --accent: #7ab8e8; --accent-light: #1f3550; --border: #2e3340;
}
[data-theme="dark"] nav { background: rgba(22,25,34,0.93); }
[data-theme="dark"] .avatar { border-color: var(--border); }
[data-theme="dark"] .rcard:hover,
[data-theme="dark"] .journal-card:hover,
[data-theme="dark"] .proj-card:hover,
[data-theme="dark"] .std-card:hover { box-shadow: 0 2px 12px rgba(100,160,200,0.12); }
[data-theme="dark"] .q1,
[data-theme="dark"] .t-q1,
[data-theme="dark"] .t-first,
[data-theme="dark"] .p-granted { background: #1a3a52; color: #8cc8f0; }
[data-theme="dark"] .q2,
[data-theme="dark"] .t-q2 { background: #1e3040; color: #7ab8e0; }
[data-theme="dark"] .t-corr { background: #2c2540; color: #c6b8ee; }
[data-theme="dark"] .p-pending,
[data-theme="dark"] .conf-role,
[data-theme="dark"] .role-join { background: #3a2e1c; color: #d6b576; }
[data-theme="dark"] .pbadge { color: var(--accent); }
[data-theme="dark"] .news-date { background: var(--accent-light); }
[data-theme="dark"] .author-tag { background: var(--accent-light); }
[data-theme="dark"] .ptable tr,
[data-theme="dark"] .item,
[data-theme="dark"] .pub,
[data-theme="dark"] .conf-item,
[data-theme="dark"] .award-item,
[data-theme="dark"] .edu-item { border-color: var(--border); }
[data-theme="dark"] .alist li::before { color: #d4a960; }
[data-theme="dark"] .std-card { background: #1f242d; border-left-color: #c8a040; }
[data-theme="dark"] .std-number { background: #3a2e1c; color: #d6b576; }
[data-theme="dark"] .btt { background: var(--surface); }
[data-theme="dark"] .lang-switch a:hover,
[data-theme="dark"] .theme-toggle:hover { background: var(--accent-light); }
[data-theme="dark"] code, [data-theme="dark"] pre { background: var(--surface); }

body {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.7; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
.sec, section[id], [id^="tab-"] { scroll-margin-top: 72px; }
@media (max-width: 720px) {
  html { scroll-padding-top: 56px; }
  .sec, section[id], [id^="tab-"] { scroll-margin-top: 56px; }
}

/* Skip to content (accessibility) */
.skip-link {
  position: absolute; top: -100px; left: 1rem; z-index: 200;
  background: var(--accent); color: #fff; padding: 8px 16px;
  border-radius: 0 0 6px 6px; font-size: 13px; font-weight: 500; text-decoration: none;
}
.skip-link:focus { top: 0; }

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, .filter-btn:focus-visible, .tab-btn:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
  border-radius: 4px;
}
nav ul li a:focus-visible { outline-offset: -2px; border-radius: 0; }
.btt:focus-visible, .theme-toggle:focus-visible { outline-offset: 3px; }

/* --- Navigation ------------------------------------------------- */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(242,244,247,0.93); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); padding: 0 2rem;
}
nav ul { display: flex; list-style: none; max-width: 980px; margin: 0 auto; }
nav ul li a {
  display: block; padding: 1rem 1.25rem; font-size: 13px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  text-decoration: none; border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
nav ul li a:hover { color: var(--accent); background: rgba(44,95,138,0.04); }
nav ul li a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* --- Language Switch -------------------------------------------- */
.lang-switch { margin-left: auto; display: flex; align-items: center; padding: 0 0.5rem; gap: 6px; }
.lang-switch a {
  font-size: 12px; font-weight: 500; letter-spacing: 0.05em; color: var(--muted);
  text-decoration: none; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 20px; transition: all 0.2s; white-space: nowrap;
}
.lang-switch a:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 8px; cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--muted); transition: all 0.2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

/* --- Page Layout ------------------------------------------------ */
.container { display: grid; grid-template-columns: 250px 1fr; max-width: 980px; margin: 0 auto; padding: 3rem 2rem; align-items: start; }
.main > * { animation: fadeSlideIn 0.4s ease both; }
.main > *:nth-child(1) { animation-delay: 0.05s; }
.main > *:nth-child(2) { animation-delay: 0.1s; }
.main > *:nth-child(3) { animation-delay: 0.15s; }
.main > *:nth-child(4) { animation-delay: 0.2s; }
.main > *:nth-child(5) { animation-delay: 0.25s; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .main > * { animation: none; }
}
.sidebar { position: sticky; top: 64px; padding-right: 2.5rem; }

/* --- Sidebar Shared Base ---------------------------------------- */
.slinks { list-style: none; }
.avatar { overflow: hidden; }
.avatar img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 22%;
  border-radius: 50%;
  display: block;
}

/* --- Section Title (shared by index + service) ------------------ */
.sec-title {
  font-family: var(--serif); font-size: 20px; font-weight: 400;
  margin-bottom: 1.25rem; display: flex; align-items: center; gap: 10px;
}
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* --- Subpage Title (shared by achievements + projects + service) */
.page-title { font-family: var(--serif); font-size: 32px; font-weight: 400; margin-bottom: 0.5rem; }

/* --- Filter Buttons (shared by achievements + projects) -------- */
.filter-btn {
  font-size: 12px; font-weight: 500; padding: 5px 14px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--surface); color: var(--muted); cursor: pointer;
  transition: all 0.2s; letter-spacing: 0.02em;
}
.filter-btn:hover { color: var(--accent); border-color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- Stat Card Label (shared by achievements + projects + service) */
.stat-card .lbl { font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

/* --- Scroll Progress Bar --------------------------------------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: transparent; z-index: 101; pointer-events: none;
}
.scroll-progress > span {
  display: block; height: 100%; width: 0;
  background: var(--accent); transform-origin: 0 50%;
  transition: width 0.08s linear;
}

/* --- Back to Top ----------------------------------------------- */
.btt {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 99;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.btt.visible { opacity: 1; visibility: visible; cursor: pointer; }
.btt:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* --- Filter Count ----------------------------------------------- */
.filter-count { font-size: 12px; color: var(--muted); margin-left: 8px; font-weight: 400; }

/* --- Card Transitions ------------------------------------------- */
.rcard, .journal-card, .proj-card, .std-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.rcard:hover, .journal-card:hover, .proj-card:hover, .std-card:hover {
  transform: translateY(-2px);
}

/* --- Collapse / Expand ------------------------------------------ */
.collapse-hidden { display: none !important; }
.collapse-control { margin-top: 1rem; }
.collapse-toggle {
  display: inline-flex; align-items: center; justify-content: center; min-height: 32px;
  padding: 6px 13px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--accent); font: 500 12px var(--sans);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.collapse-toggle:hover { border-color: var(--accent); background: var(--accent-light); }

/* --- Footer ----------------------------------------------------- */
footer { text-align: center; padding: 2rem; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-meta {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-meta .dot { opacity: 0.4; }
.footer-icon { width: 13px; height: 13px; vertical-align: -2px; opacity: 0.5; margin-right: 4px; }
.footer-meta .value { color: var(--accent); font-weight: 500; }

/* --- Responsive ------------------------------------------------ */
@media (max-width: 900px) {
  .container { padding: 2rem 1.5rem; }
}

@media (max-width: 720px) {
  .container { grid-template-columns: 1fr; padding: 1.5rem 1rem; }
  .sidebar { position: static; padding-right: 0; margin-bottom: 2rem; }

  nav { padding: 0 0.5rem; }
  nav ul { justify-content: center; flex-wrap: wrap; gap: 2px; }
  nav ul li a { font-size: 12px; padding: 0.75rem 0.75rem; min-height: 44px; display: flex; align-items: center; letter-spacing: 0.02em; }

  .lang-switch { margin-left: 0; }
  .lang-switch a { font-size: 11px; padding: 6px 10px; min-height: 32px; display: inline-flex; align-items: center; }
  .theme-toggle { min-height: 32px; min-width: 32px; }

  .page-title { font-size: 26px; }

  footer { padding: 1.5rem 1rem; font-size: 11px; }

  .btt { bottom: 1rem; right: 1rem; width: 44px; height: 44px; }
}

@media (max-width: 480px) {
  nav ul { gap: 0; }
  nav ul li a { font-size: 11px; padding: 0.7rem 0.55rem; letter-spacing: 0.01em; }

  .container { padding: 1rem 0.75rem; }
  .sec-title { font-size: 18px; margin-bottom: 1rem; }
  .page-title { font-size: 24px; }

  .collapse-toggle { width: 100%; font-size: 13px; min-height: 40px; }
  .filter-btn, .tab-btn { min-height: 36px; }
}

/* --- Print ----------------------------------------------------- */
@media print {
  nav, .sidebar, footer, .collapse-control, .lang-switch, .theme-toggle, .filter-bar, .tab-bar { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; line-height: 1.5; }
  .container { display: block; max-width: 100%; padding: 0; }
  .main { max-width: 100%; }
  a { color: #000; text-decoration: underline; }
  .sec { break-inside: avoid; page-break-inside: avoid; }
  .pub, .edu-item, .alist li { break-inside: avoid; }
  .page-title, .main h1 { font-size: 20px; }
  .sec-title { font-size: 15px; }
}
