/* ----------------------------------------------------------------------------
   lihan.me — frosted, refined, single accent: 青蓝
   ---------------------------------------------------------------------------- */

:root {
  /* base */
  --bg:            #EDF4F7;
  --bg-deep:       #DEEAEF;

  /* aurora blob colors (light) */
  --blob-a:        #5BD9EC;
  --blob-b:        #14A6BF;
  --blob-c:        #8FE3D3;

  /* glass tokens */
  --surface-glass: rgba(255, 255, 255, 0.55);
  --surface-glass-strong: rgba(255, 255, 255, 0.72);
  --glass-border:  rgba(255, 255, 255, 0.65);
  --glass-edge:    rgba(255, 255, 255, 0.95);
  --glass-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 0 0 1px rgba(255, 255, 255, 0.4) inset,
    0 6px 24px -6px rgba(11, 50, 64, 0.14),
    0 1px 2px rgba(11, 50, 64, 0.06);
  --glass-shadow-hover:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 0 0 1px rgba(255, 255, 255, 0.55) inset,
    0 16px 38px -8px rgba(8, 108, 123, 0.22),
    0 2px 4px rgba(11, 50, 64, 0.08);

  /* text */
  --text:          #0A1F2A;
  --text-soft:     #4D6573;
  --text-faint:    #8AA1AE;

  /* accent — 青蓝 */
  --accent:        #0A8DA1;
  --accent-deep:   #086477;
  --accent-bright: #19BCD2;
  --accent-soft:   rgba(10, 141, 161, 0.10);

  /* highlighter (荧光笔) */
  --hl-color:      rgba(255, 232, 120, 0.55);

  /* layout & type */
  --max:           42rem;
  --gutter:        clamp(1.25rem, 4.5vw, 2rem);
  --pad-y:         clamp(4rem, 11vh, 7rem);
  --radius:        18px;
  --radius-sm:     12px;

  --sans:  'Manrope', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --cn:    'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei',
           'Source Han Sans SC', 'Noto Sans SC', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #06121A;
  --bg-deep:       #02090F;

  --blob-a:        #1FBED3;
  --blob-b:        #0A6477;
  --blob-c:        #1A8A6F;

  --surface-glass: rgba(255, 255, 255, 0.04);
  --surface-glass-strong: rgba(255, 255, 255, 0.06);
  --glass-border:  rgba(255, 255, 255, 0.10);
  --glass-edge:    rgba(255, 255, 255, 0.18);
  --glass-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 12px 36px -10px rgba(0, 0, 0, 0.55);
  --glass-shadow-hover:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(45, 196, 216, 0.22) inset,
    0 18px 44px -10px rgba(0, 0, 0, 0.65);

  --text:          #E2EDF2;
  --text-soft:     #93AAB7;
  --text-faint:    #5A7080;

  --accent:        #2DC4D8;
  --accent-deep:   #5BD9EC;
  --accent-bright: #4FE1F3;
  --accent-soft:   rgba(45, 196, 216, 0.14);

  --hl-color:      rgba(255, 235, 120, 0.32);
}

/* —— reset —— */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(15px, 0.4vw + 14px, 16.5px);
  line-height: 1.6;
  letter-spacing: -0.005em;
  font-feature-settings: 'kern' 1, 'liga' 1, 'ss01' 1;
  min-height: 100svh;
  position: relative;
  overflow-x: hidden;
}

:root[lang="zh"] body { font-family: var(--sans), var(--cn); letter-spacing: 0; }

/* —— matte grain overlay (磨砂) ——
   tiny SVG noise, fixed, blended subtly so the whole page reads as "frosted paper"   */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.45;
  mix-blend-mode: overlay;
  z-index: 1;
}
:root[data-theme="dark"] body::after { opacity: 0.35; mix-blend-mode: soft-light; }

::selection { background: var(--accent); color: #fff; }

/* —— aurora blobs —— */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.65;
  will-change: transform;
}
.blob-1 {
  top: -8%;
  left: -10%;
  width: 38vw;
  height: 38vw;
  min-width: 320px;
  min-height: 320px;
  background: radial-gradient(circle at 30% 30%, var(--blob-a) 0%, transparent 65%);
  animation: drift-1 22s ease-in-out infinite alternate;
}
.blob-2 {
  top: 20%;
  right: -12%;
  width: 42vw;
  height: 42vw;
  min-width: 360px;
  min-height: 360px;
  background: radial-gradient(circle at 60% 50%, var(--blob-b) 0%, transparent 65%);
  opacity: 0.55;
  animation: drift-2 28s ease-in-out infinite alternate;
}
.blob-3 {
  bottom: -10%;
  left: 25%;
  width: 36vw;
  height: 36vw;
  min-width: 300px;
  min-height: 300px;
  background: radial-gradient(circle at 50% 50%, var(--blob-c) 0%, transparent 60%);
  opacity: 0.40;
  animation: drift-3 34s ease-in-out infinite alternate;
}
:root[data-theme="dark"] .blob-1 { opacity: 0.45; }
:root[data-theme="dark"] .blob-2 { opacity: 0.35; }
:root[data-theme="dark"] .blob-3 { opacity: 0.28; }

@keyframes drift-1 {
  0%   { transform: translate3d(0, 0, 0)        scale(1); }
  100% { transform: translate3d(4vw, 3vh, 0)    scale(1.08); }
}
@keyframes drift-2 {
  0%   { transform: translate3d(0, 0, 0)        scale(1); }
  100% { transform: translate3d(-3vw, -4vh, 0)  scale(1.05); }
}
@keyframes drift-3 {
  0%   { transform: translate3d(0, 0, 0)        scale(1); }
  100% { transform: translate3d(2vw, -3vh, 0)   scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* ============================================================================
   GLASS UTILITY — the frosted look
   ============================================================================ */

.glass {
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  position: relative;
}

/* a faint top-edge highlight that sells the "lit glass" feel */
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    var(--glass-edge) 0%,
    transparent 24%,
    transparent 76%,
    rgba(255, 255, 255, 0.22) 100%);
  mix-blend-mode: overlay;
  opacity: 0.65;
}
:root[data-theme="dark"] .glass::before { opacity: 0.5; }

/* ============================================================================
   PAGE FRAME
   ============================================================================ */

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--pad-y) var(--gutter);
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   TOP-RIGHT CONTROLS — theme toggle + language switch
   ============================================================================ */

.controls {
  position: fixed;
  top: clamp(1rem, 2.5vh, 1.5rem);
  right: clamp(1rem, 3vw, 1.75rem);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* —— theme toggle button —— */
.theme {
  display: inline-grid;
  place-items: center;
  width: 2.05rem;
  height: 2.05rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  font: inherit;
  color: var(--text-soft);
  cursor: pointer;
  transition:
    color .25s ease,
    transform .25s ease,
    box-shadow .3s ease;
}
.theme:hover {
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--glass-shadow-hover);
}
.theme svg { transition: transform .35s cubic-bezier(.2,.7,.2,1); }
.theme:hover svg { transform: rotate(15deg); }

/* swap which icon is shown depending on current theme */
.theme .icon-moon { display: none; }
:root[data-theme="dark"] .theme .icon-sun  { display: none; }
:root[data-theme="dark"] .theme .icon-moon { display: block; }

/* —— language switch (now lives inside .controls, not fixed) —— */

.lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.74rem;
}
:root[lang="zh"] .lang { font-family: var(--sans); }

.lang-btn {
  background: transparent;
  border: 0;
  padding: 0.34rem 0.7rem;
  margin: 0;
  font: inherit;
  font-family: inherit;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 999px;
  transition: color .25s ease, background-color .35s ease;
  letter-spacing: 0.04em;
}
.lang-btn:hover { color: var(--text); }
.lang-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}
.lang-sep {
  width: 1px;
  height: 12px;
  background: var(--glass-border);
  margin: 0 2px;
}

/* ============================================================================
   HERO
   ============================================================================ */

.hero {
  margin-bottom: clamp(3.5rem, 8vw, 5.5rem);
}

.name {
  margin: 0 0 clamp(2rem, 3.5vw + 0.5rem, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
  font-size: clamp(2.5rem, 5.5vw + 1rem, 4rem);
  display: flex;
  align-items: baseline;
  gap: clamp(.5rem, 1.5vw, .9rem);
  flex-wrap: wrap;
}
.name-en {
  background: linear-gradient(
    135deg,
    var(--text) 0%,
    var(--text) 50%,
    var(--accent-deep) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.name-sub {
  font-family: var(--sans);
  font-size: 0.42em;
  font-weight: 400;
  color: var(--text-faint);
  letter-spacing: -0.005em;
  position: relative;
  top: -0.2em;
}

.bio {
  max-width: 32rem;
  margin: 0 0 2rem;
  font-size: clamp(1.02rem, 0.4vw + 0.92rem, 1.13rem);
  line-height: 1.62;
  font-weight: 400;
  color: var(--text-soft);
}

/* highlighter mark — soft yellow stroke under emphasised phrase */
.hl {
  background-image: linear-gradient(
    180deg,
    transparent 0%,
    transparent 56%,
    var(--hl-color) 56%,
    var(--hl-color) 94%,
    transparent 94%);
  background-size: 0% 100%;
  background-repeat: no-repeat;
  padding: 0 0.14em;
  color: var(--text);
  font-weight: 500;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  animation: highlight-in 1s cubic-bezier(.4, 0, .2, 1) 0.6s forwards;
}
/* stagger multiple highlights so they "draw in" one after another */
.bio .hl:nth-of-type(2) { animation-delay: 0.78s; }
.bio .hl:nth-of-type(3) { animation-delay: 0.96s; }
.bio .hl:nth-of-type(4) { animation-delay: 1.14s; }
@keyframes highlight-in {
  to { background-size: 100% 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .hl { animation: none; background-size: 100% 100%; }
}

/* —— contact pills (frosted) —— */

.contact {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  color: var(--text-soft);
  text-decoration: none;
  transition:
    color .3s ease,
    transform .3s ease,
    box-shadow .3s ease,
    background .3s ease;
}
.pill svg { transition: color .3s ease; }
.pill:hover {
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--glass-shadow-hover);
}

/* ============================================================================
   WORK
   ============================================================================ */

.work { margin-bottom: clamp(3rem, 6vw, 4rem); }

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}
:root[lang="zh"] .section-label {
  text-transform: none;
  letter-spacing: 0.22em;
  font-size: 0.82rem;
}
.section-label .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* —— compact card —— */

.card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.95rem;
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition:
    transform .35s cubic-bezier(.2,.7,.2,1),
    box-shadow .35s ease,
    border-color .35s ease;
  isolation: isolate;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow-hover);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
}
.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.card:hover .card-icon { transform: rotate(-4deg) scale(1.04); }

.card-body { min-width: 0; }

.card-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.18rem;
}

.card-name {
  margin: 0;
  font-family: var(--mono);
  font-feature-settings: 'ss01' 1;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

/* —— project type badge (open source / closed / live) ——
   Add another variant by setting a different background+color combo.   */
.card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  align-self: center;
  transition:
    background .25s ease,
    color .25s ease,
    transform .25s ease;
}
.card-badge svg { display: block; }
.card:hover .card-badge {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* —— variants —— */
.card-badge--closed {
  background: var(--surface-glass-strong);
  color: var(--text-faint);
}
.card:hover .card-badge--closed {
  background: var(--text-faint);
  color: var(--surface-glass-strong);
}
.card-badge--live {
  /* same as default oss tint by design — change if you want a 3rd color */
}

.card-desc {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.5;
  /* keep card slim — clamp to 2 lines on narrow screens */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
:root[lang="zh"] .card-desc { font-size: 0.84rem; }

.card-go {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-glass-strong);
  color: var(--text-faint);
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
  transition:
    background .3s ease,
    color .3s ease,
    transform .35s cubic-bezier(.2,.7,.2,1),
    border-color .3s ease;
}
.card:hover .card-go {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translate(2px, -2px);
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.page-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--glass-border);
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}
.page-foot .domain {
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

/* ============================================================================
   ENTRANCE ANIMATION
   ============================================================================ */

.hero, .work, .page-foot, .controls {
  opacity: 0;
  transform: translateY(8px);
  animation: rise 1s cubic-bezier(.2,.7,.2,1) forwards;
}
.controls  { animation-delay: 0.05s; }
.hero      { animation-delay: 0.10s; }
.work      { animation-delay: 0.28s; }
.page-foot { animation-delay: 0.42s; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero, .work, .page-foot, .controls {
    opacity: 1; transform: none; animation: none;
  }
  .pill, .card, .card-icon, .card-go, .theme { transition: none; }
  html { scroll-behavior: auto; }
}

/* ============================================================================
   RESPONSIVE — H5
   ============================================================================ */

@media (max-width: 32rem) {
  :root { --pad-y: 4rem; }

  .controls { top: 1rem; right: 1rem; gap: 0.35rem; }
  .lang { font-size: 0.72rem; }
  .theme { width: 1.9rem; height: 1.9rem; }

  .name { font-size: 2.4rem; gap: 0.5rem; }
  .name-sub { font-size: 0.95rem; top: -0.4em; }

  .bio { font-size: 1rem; }

  .contact { gap: 0.4rem; }
  .pill { width: 2.15rem; height: 2.15rem; }
  .pill svg { width: 14px; height: 14px; }

  .card { padding: 0.9rem 0.95rem; gap: 0.75rem; grid-template-columns: auto 1fr auto; }
  .card-icon { width: 36px; height: 36px; border-radius: 9px; }
  .card-name { font-size: 0.95rem; }
  .card-desc { font-size: 0.82rem; -webkit-line-clamp: 2; }
  .card-meta { display: none; }      /* free up horizontal space */

  .page-foot { font-size: 0.72rem; }
}

/* ============================================================================
   PRINT
   ============================================================================ */
@media print {
  body { background: #fff; color: #000; }
  body::after, .aurora, .controls { display: none; }
  .glass {
    background: #fff !important;
    border-color: #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  .glass::before { display: none; }
  .name-en { background: none; color: #000; -webkit-text-fill-color: #000; }
}

/* fallback for browsers without backdrop-filter — still readable */
@supports not (backdrop-filter: blur(10px)) {
  .glass { background: var(--surface-glass-strong); }
  :root[data-theme="dark"] .glass { background: rgba(20, 39, 52, 0.85); }
}
