/* ============================================================
   nemurin.top personal homepage
   Dark-first. Full-bleed slideshow with a slow Ken Burns zoom.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono&family=Inter:wght@400;500;600;700&display=swap");

/* ---------- theme tokens ---------- */
:root {
  --bg:            #15131c;
  --bg-soft:       rgba(24, 21, 32, 0.50);
  --bg-card:       rgba(28, 25, 38, 0.58);
  --border:        rgba(255, 255, 255, 0.10);
  --headings:      #c8d6ff;
  --text:          #d7d3e0;
  --text-dim:      #9b95ab;
  --links:         #a8b4ff;
  --accent:        #7bd6cf;
  --highlight:     #41c7c7;
  --overlay-rgb:   18, 16, 24;      /* dark scrim over background */
  --overlay-a:     0.44;
}

html[data-theme="light"] {
  --bg:            #eef0f7;
  --bg-soft:       rgba(255, 255, 255, 0.62);
  --bg-card:       rgba(255, 255, 255, 0.55);
  --border:        rgba(20, 20, 40, 0.12);
  --headings:      #2b3356;
  --text:          #2c2f3a;
  --text-dim:      #5c6173;
  --links:         #4f51d8;
  --accent:        #1d8f86;
  --highlight:     #ffd866;
  --overlay-rgb:   232, 232, 245;
  --overlay-a:     0.30;
}

/* ---------- reset / base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100%;
  overflow-x: hidden;
}
a { color: var(--links); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--headings); line-height: 1.25; }
img { max-width: 100%; display: block; }

/* smooth theme switch */
html.transition, html.transition *, html.transition *::before, html.transition *::after {
  transition: background-color 400ms ease, color 400ms ease, border-color 400ms ease !important;
}

/* ============================================================
   BACKGROUND  (fixed, behind everything)
   - three full-bleed images cross-fade with a slow Ken Burns zoom
   - lightly softened so text stays readable, but the art shows
   - particles drifting on top of the imagery
   - a graded scrim that frames the art and holds text contrast
   ============================================================ */
#bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 20%, #221d33 0%, #0c0a12 100%);
}
html[data-theme="light"] #bg {
  background: radial-gradient(120% 120% at 50% 20%, #dfe2f2 0%, #b9bed6 100%);
}

.bg-img {
  position: absolute;
  inset: -3%;                 /* small bleed so the slow zoom never shows an edge */
  background-size: cover;
  background-position: center;
  opacity: 0;
  will-change: opacity;
  animation: show 33s ease-in-out infinite;
}
#bg1 { background-image: url("../img/bg1.webp"); animation-delay: 0s; }
#bg2 { background-image: url("../img/bg2.webp"); animation-delay: 11s; }
#bg3 { background-image: url("../img/bg3.webp"); animation-delay: 22s; }

/* the artwork is the hero: only a light softening and gentle grade */
.bg-img { filter: blur(3px) brightness(0.82) saturate(1.08); }
html[data-theme="light"] .bg-img { filter: blur(3px) brightness(1.05) saturate(1.06); }

/* subtle particles drifting over the imagery */
#particles-js {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* refined scrim: a vignette that frames the art and keeps text readable,
   lighter in the upper middle, darker toward the edges and the bottom */
#scrim {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(135% 105% at 50% 26%,
      rgba(var(--overlay-rgb), 0.08) 0%,
      rgba(var(--overlay-rgb), 0.36) 58%,
      rgba(var(--overlay-rgb), 0.66) 100%),
    linear-gradient(180deg,
      rgba(var(--overlay-rgb), 0.32) 0%,
      rgba(var(--overlay-rgb), 0.28) 48%,
      rgba(var(--overlay-rgb), 0.52) 100%);
}

/* pure cross-fade: the three frames are the same street at morning,
   noon and evening, so they stay perfectly registered (no zoom/pan) */
@keyframes show {
  0%   { opacity: 0; }
  7%   { opacity: 1; }
  30%  { opacity: 1; }
  37%  { opacity: 0; }
  100% { opacity: 0; }
}

/* gentle reveal of the whole page */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .bg-img { animation: none; }
  #bg1 { opacity: 1; }                   /* show one still frame */
  .page { animation: none !important; }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(2.2rem, 5vw, 3.8rem) clamp(1.1rem, 4vw, 2rem) 4rem;
  animation: fadeUp 700ms ease both;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .page { text-shadow: 0 1px 4px rgba(255, 255, 255, 0.65); }

/* content sits directly over the full-bleed image (no glass box) */
.panel { background: transparent; padding: 0; }

/* cards have their own surface, so they don't need the page text-shadow */
.card, .card *, .tag { text-shadow: none; }

/* top bar */
.topbar { display: flex; gap: 1.4rem; font-size: 0.9rem; margin-bottom: 1.6rem; }
.topbar a { color: var(--text-dim); }
.topbar a:hover { color: var(--links); }
.topbar .spacer { flex: 1; }

/* header / identity */
.identity { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.avatar {
  width: 144px; height: 144px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--border);
  box-shadow: 0 8px 26px rgba(0,0,0,0.4);
  transition: transform 250ms ease;
}
.avatar:hover { transform: scale(1.04) rotate(-1deg); }
.identity h1 { margin: 0 0 0.2rem; font-size: clamp(1.7rem, 5vw, 2.3rem); letter-spacing: -0.5px; }
.identity .role { color: var(--text); font-weight: 500; }
.identity .sub { color: var(--text-dim); font-size: 0.92rem; }

.intro { margin: 1.6rem 0 0; color: var(--text); }

.divider { height: 1px; background: var(--border); border: 0; margin: 2.2rem 0; }

/* section heading */
.section { margin-top: 2.4rem; }
.section > h2 {
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 2.5px;
  color: var(--accent); margin: 0 0 1.1rem; font-weight: 600;
}

/* timeline-style entries (education / experience) */
.entry { margin-bottom: 1.3rem; }
.entry-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.entry-title { font-weight: 600; color: var(--headings); }
.entry-date { color: var(--text-dim); font-family: "Roboto Mono", monospace; font-size: 0.78rem; white-space: nowrap; }
.entry-org { color: var(--text-dim); font-size: 0.9rem; }
.entry ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.entry li { color: var(--text); font-size: 0.92rem; margin: 0.25rem 0; }

/* card grid (research / projects / competitions) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.card {
  position: relative;
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.15rem 1.35rem;
  color: var(--text);
  overflow: hidden;
  transition: transform 220ms ease, border-color 220ms ease, background 220ms ease, box-shadow 220ms ease;
}
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--links));
  transform: scaleY(0); transform-origin: top;
  transition: transform 260ms ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: transparent;
  background: var(--bg-soft);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  text-decoration: none;
}
.card:hover::before { transform: scaleY(1); }

/* compact index-style list (used for research / projects / competition) */
.list { margin-top: 0.2rem; }
.row {
  display: block;
  padding: 0.95rem 0.5rem;
  border-top: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  transition: background 200ms ease, padding-left 200ms ease;
}
.row-title { display: block; color: var(--headings); font-weight: 600; font-size: 1rem; letter-spacing: -0.2px; }
.row-desc  { display: block; color: var(--text-dim); font-size: 0.86rem; line-height: 1.55; margin-top: 0.18rem; }
a.row:hover { text-decoration: none; background: var(--bg-card); padding-left: 0.95rem; }
a.row:hover .row-title { color: var(--links); }

/* Live2D mascot: silent (Chinese speech bubble hidden), drag handle */
.pio-dialog { display: none !important; }
.pio-container { cursor: grab; user-select: none; -webkit-user-select: none; }
.card .card-title { color: var(--headings); font-weight: 600; font-size: 0.95rem; display: block; }
.card .card-title mark, .row-title mark {
  background: var(--highlight); color: #1a1730; font-size: 0.6rem; font-weight: 700;
  padding: 0.1rem 0.4rem; border-radius: 5px; vertical-align: middle; margin-left: 0.4rem;
  letter-spacing: 1px; text-transform: uppercase;
}
.card hr { border: 0; border-top: 1px solid var(--border); margin: 0.6rem 0; }
.card .card-body { color: var(--text-dim); font-size: 0.82rem; line-height: 1.6; }

/* tags / skills */
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
  font-family: "Roboto Mono", monospace; font-size: 0.74rem; color: var(--text-dim);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 0.3rem 0.7rem; border-radius: 20px;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; font-size: 0.9rem; }
.kv dt { color: var(--text-dim); font-family: "Roboto Mono", monospace; font-size: 0.8rem; }
.kv dd { margin: 0; color: var(--text); }

/* footer */
.foot { margin-top: 2.8rem; text-align: center; color: var(--text-dim); font-size: 0.8rem; }
.foot a { color: var(--text-dim); font-weight: 600; }

/* theme toggle */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 5;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.theme-toggle:hover { color: var(--links); }

/* article (detail pages) */
.article h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); margin: 0.2rem 0 0.4rem; }
.article .byline { color: var(--text-dim); font-family: "Roboto Mono", monospace; font-size: 0.78rem; margin-bottom: 1.2rem; }
.article p { margin: 1em 0; }
.article img { border-radius: 10px; margin: 1.2rem auto; height: auto; }
.article .back { font-size: 0.85rem; color: var(--text-dim); }
.article a.back:hover { color: var(--links); }

@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; }
  .entry-head { flex-direction: column; gap: 0.1rem; }
  /* phones have no margins, so darken the artwork a touch for contrast */
  .bg-img { filter: blur(3px) brightness(0.68) saturate(1.06); }
  /* the mascot has nowhere to go on a phone and would overlap content */
  .pio-container { display: none !important; }
}

/* figures inside detail pages */
.article figure { margin: 1.4rem 0; }
.article figure img { margin: 0 auto; }
.article figcaption { margin-top: 0.5rem; text-align: center; opacity: 0.8; font-size: 0.95rem; }
