/* ============================================================
   Howard Leung — CityU CS — Redesigned site
   Concept A: Editorial Academic · CityU navy/red branding
   Shared stylesheet. One file controls the whole site's look.
   ============================================================ */

:root{
  /* CityU branding */
  --navy:#12233f;        /* CityU deep navy */
  --navy-2:#1b3560;
  --red:#c2151c;         /* CityU red accent */
  --red-2:#e03131;
  --blue:#2b5b9a;

  /* neutrals */
  --paper:#fbfaf7;
  --card:#ffffff;
  --ink:#1a202b;
  --muted:#5b6472;
  --rule:#e5e2d9;
  --rule-2:#d8d4c8;

  --sans:"Inter","Segoe UI",system-ui,-apple-system,Roboto,"Helvetica Neue",Arial,sans-serif;
  --serif:"Georgia","Iowan Old Style","Times New Roman",serif;
  --mono:"SF Mono",ui-monospace,Consolas,monospace;

  --radius:14px;
  --max:1120px;
  --shadow:0 6px 24px rgba(18,35,63,.08);
}

*{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{
  margin:0;font-family:var(--sans);color:var(--ink);background:var(--paper);
  line-height:1.7;-webkit-font-smoothing:antialiased;
}
img{max-width:100%;height:auto}
a{color:var(--blue);text-decoration:none;transition:color .15s}
a:hover{color:var(--red)}
h1,h2,h3,h4{font-family:var(--serif);line-height:1.22;color:var(--navy);margin:0 0 .5em;font-weight:700}
h1{font-size:clamp(1.9rem,3.2vw,2.6rem)}
h2{font-size:clamp(1.45rem,2.4vw,1.95rem)}
h3{font-size:clamp(1.15rem,1.8vw,1.4rem)}

.wrap{max-width:var(--max);margin:0 auto;padding:0 clamp(1.1rem,4vw,2.4rem)}

/* ---------- Top utility bar ---------- */
.topbar{background:var(--navy);color:#c7d1e4;font-size:.82rem}
.topbar .wrap{display:flex;justify-content:space-between;align-items:center;padding-top:.45rem;padding-bottom:.45rem}
.topbar a{color:#e6ecf7}
.topbar a:hover{color:#fff}
.topbar .tb-sep{opacity:.4;margin:0 .5rem}

/* ============================================================
   CityU header utility bar — preserves the original site's
   header look: CityUHK logo top-left, search + font-size
   accessibility controls top-right. Matches the classic
   CityU template (logo left / #header-search + #header-wa right).
   ============================================================ */
.mh-top{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:.6rem}
.mh-top .brand{flex:1;min-width:0}
.mh-utils{display:flex;align-items:center;gap:.7rem;flex-shrink:0}
/* search box (Google site search, mirrors #header-search) */
.srch{display:flex;align-items:center;gap:.3rem;border-bottom:1px solid var(--rule-2);padding:.25rem .4rem;background:var(--paper);border-radius:8px 8px 0 0}
.srch input{border:0;outline:0;background:transparent;font-size:.85rem;color:var(--ink);width:180px;padding:.2rem .3rem;font-family:var(--sans)}
.srch input::placeholder{color:#9aa4b0}
.srch button{border:0;background:none;cursor:pointer;color:var(--blue);font-size:.85rem;padding:.2rem .3rem}
.srch button:hover{color:var(--red)}
/* accessibility font-size buttons (mirrors #header-wa .wa-fontsize) */
.fsize{display:flex;align-items:center;gap:.2rem;border:1px solid var(--rule-2);border-radius:8px;padding:.25rem .45rem;background:var(--paper)}
.fsize .fl{font-size:.7rem;color:var(--muted);margin-right:.25rem;letter-spacing:.02em}
.fsize button{border:0;background:none;cursor:pointer;line-height:1;color:#555;padding:.15rem .25rem;border-radius:4px}
.fsize button:hover{color:var(--red)}
.fsize button.sel{color:var(--red);font-weight:700}
.fsize .fs-0{font-size:.72rem}
.fsize .fs-1{font-size:.95rem}
.fsize .fs-2{font-size:1.15rem}
/* font-size scaling driven by a data attribute on <html> */
html[data-fs="1"]{font-size:112.5%}
html[data-fs="2"]{font-size:125%}
@media(max-width:640px){
  .mh-top{flex-wrap:wrap;gap:.5rem}
  .mh-utils{width:100%;flex-wrap:wrap;gap:.45rem}
  .srch{flex:1 1 auto;min-width:0;max-width:100%}
  .srch input{width:auto;flex:1 1 0;min-width:0}
  .fsize{flex:0 0 auto}
  .mh-nav-row{flex-wrap:wrap}
  .brand{flex-wrap:wrap}
  .brand .bt .n,.brand .bt .r{white-space:normal}
  .brand img{height:38px}
}

/* ---------- Masthead ---------- */
.masthead{background:var(--card);border-bottom:1px solid var(--rule);position:sticky;top:0;z-index:60}
.masthead .wrap{display:flex;flex-direction:column;gap:.55rem;padding-top:.9rem;padding-bottom:.9rem}
.brand{display:flex;align-items:center;gap:.7rem;min-width:0}
.brand img{height:44px;width:auto;display:block}
.brand .bt{min-width:0}
.brand .bt .n{font-family:var(--serif);font-size:1.35rem;font-weight:700;color:var(--navy);line-height:1.05;white-space:nowrap}
.brand .bt .r{font-size:.72rem;color:var(--muted);letter-spacing:.02em;white-space:nowrap}

.nav-toggle{display:none;background:none;border:1px solid var(--rule-2);border-radius:8px;padding:.45rem .7rem;font-size:1rem;cursor:pointer;color:var(--navy)}
.mh-nav-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}

nav.site{display:flex;align-items:center;gap:.2rem;flex-wrap:wrap}
nav.site > a{
  display:block;padding:.5rem .85rem;font-size:.93rem;font-weight:600;color:var(--ink);
  border-radius:8px;position:relative;
}
nav.site > a:hover{color:var(--red);background:#f6f3ec}
nav.site > a.active{color:var(--red)}
nav.site > a.active::after{content:"";position:absolute;left:.85rem;right:.85rem;bottom:.15rem;height:2px;background:var(--red);border-radius:2px}
nav.site .has-drop{position:relative}
nav.site .drop{
  position:absolute;top:100%;left:0;min-width:220px;background:var(--card);
  border:1px solid var(--rule);border-radius:12px;box-shadow:var(--shadow);
  padding:.4rem;opacity:0;visibility:hidden;transform:translateY(6px);transition:.18s;z-index:70;
}
nav.site .has-drop:nth-last-child(-n+3) .drop{left:auto;right:0}
nav.site .has-drop:hover .drop,nav.site .has-drop:focus-within .drop{opacity:1;visibility:visible;transform:translateY(0)}
nav.site .drop a{display:block;padding:.5rem .8rem;font-size:.9rem;color:var(--ink);border-radius:8px}
nav.site .drop a:hover{background:#f6f3ec;color:var(--red)}
nav.site .drop a.active{color:var(--red)}

/* ---------- Breadcrumb ---------- */
.crumbs{font-size:.83rem;color:var(--muted);margin:0;padding:1.1rem 0 0}
.crumbs a{color:var(--blue)}
.crumbs .sep{margin:0 .4rem;opacity:.5}
.crumbs .cur{color:var(--ink);font-weight:600}

/* ---------- Page shell ---------- */
main.page{padding:1.2rem 0 3.6rem}
.page-head{border-bottom:1px solid var(--rule-2);padding-bottom:.9rem;margin-bottom:1.6rem}
.page-head h1{ margin-bottom:.2rem}
.page-head .sub{font-family:var(--serif);font-size:1.05rem;color:var(--muted);font-style:italic;margin:0}
.lead{font-size:1.08rem;color:#3c4451;max-width:70ch}
p{margin:0 0 1em}

/* ---------- Photo float (reused from old site) ---------- */
.photo{text-align:center}
.photo img{border-radius:var(--radius);border:1px solid var(--rule-2);box-shadow:var(--shadow)}
.float-left{float:left;margin:0 1.6rem 1.1rem 0}
@media(max-width:640px){.float-left{float:none;margin:0 auto 1.2rem}}
.float-left::after{content:"";display:table;clear:both}

/* ---------- Info / tables (reused) ---------- */
.info{background:var(--card);border:1px solid var(--rule);border-radius:var(--radius);padding:1.3rem 1.5rem;overflow-x:auto}
.info.naked{border:none;padding:0;background:none;overflow:visible}
table{width:100%;border-collapse:collapse;border-spacing:0;font-size:.95rem}
table th{background:var(--navy);color:#fff;text-align:left;padding:.6rem .9rem;font-weight:600;font-size:.85rem;letter-spacing:.02em}
table td{padding:.6rem .9rem;border-bottom:1px solid var(--rule);vertical-align:top}
table td:first-child,table th:first-child{padding-left:0}
table tr:last-child td{border-bottom:none}
table tr:nth-child(even) td{background:#faf8f3}
table a target,table a[target="_new"]{font-weight:600}

/* citation blocks inside publication tables */
td p{margin:0}
td p + p{margin-top:.4em}

/* ---------- Student entries ---------- */
.stu_photo{border-radius:10px;overflow:hidden;max-width:140px}
.stu_photo img{display:block;width:100%;border-radius:10px;border:1px solid var(--rule-2)}
.qualification{font-size:.85rem;color:var(--red);font-weight:700;text-transform:uppercase;letter-spacing:.04em}
table td h2{font-size:1.25rem;margin-bottom:.1rem}

/* ---------- Lists ---------- */
ul,ol{padding-left:1.3rem}
li{margin-bottom:.45rem}
ol > li{margin-bottom:.9rem}

/* ---------- Buttons ---------- */
.btn{display:inline-block;padding:.65rem 1.3rem;border-radius:10px;font-weight:600;font-size:.95rem;transition:.15s}
.btn.primary{background:var(--navy);color:#fff}
.btn.primary:hover{background:var(--red);color:#fff}
.btn.ghost{background:var(--card);border:1px solid var(--rule-2);color:var(--navy)}
.btn.ghost:hover{border-color:var(--red);color:var(--red)}

/* ---------- Cards / focus grid (home) ---------- */
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:1.1rem}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:1.1rem}
.card{background:var(--card);border:1px solid var(--rule);border-radius:var(--radius);padding:1.4rem;box-shadow:var(--shadow)}
.card h3{font-size:1.2rem;margin-bottom:.4rem}
.card p{font-size:.92rem;color:var(--muted)}
.card .ic{font-size:1.6rem;margin-bottom:.5rem}
.card.hl{border-top:3px solid var(--red)}

/* stats */
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:1px;background:var(--rule);border:1px solid var(--rule);border-radius:var(--radius);overflow:hidden}
.stat{background:var(--card);padding:1.5rem 1rem;text-align:center}
.stat .num{font-family:var(--serif);font-size:clamp(1.6rem,3vw,2.3rem);font-weight:700;color:var(--navy)}
.stat .num .u{color:var(--red)}
.stat .lbl{font-size:.8rem;color:var(--muted);margin-top:.2rem;letter-spacing:.02em}

/* ---- Home hero ---- */
.hero{background:linear-gradient(150deg,var(--navy) 0%,var(--navy-2) 70%);color:#fff;padding:3.6rem 0 3.2rem;margin-top:0;position:relative;overflow:hidden}
.hero::after{content:"";position:absolute;top:-40%;right:-10%;width:60%;height:140%;background:radial-gradient(circle,rgba(194,21,28,.35),transparent 60%);pointer-events:none}
.hero .wrap{display:grid;grid-template-columns:1.5fr .85fr;gap:2.6rem;align-items:center;position:relative;z-index:1}
.hero h1{color:#fff;font-size:clamp(2.1rem,4vw,3.1rem);margin-bottom:.6rem}
.hero h1 .accent{color:#ffd9d9}
.hero .eyebrow{font-size:.82rem;letter-spacing:.14em;text-transform:uppercase;color:#93a7c8;margin-bottom:1.1rem}
.hero .role{font-family:var(--serif);font-size:1.15rem;color:#c7d1e4;margin:0 0 1.3rem}
.hero .lede{color:#c7d1e4;max-width:60ch;margin:0 0 1.8rem}
.hero .cta{display:flex;gap:.7rem;flex-wrap:wrap}
.hero .btn.primary{background:#fff;color:var(--navy)}
.hero .btn.primary:hover{background:var(--red);color:#fff}
.hero .btn.ghost{background:transparent;border:1px solid #4a6089;color:#e6ecf7}
.hero .btn.ghost:hover{border-color:#fff;color:#fff}
.hero .portrait{text-align:center}
.hero .portrait img{border-radius:var(--radius);border:3px solid rgba(255,255,255,.15);box-shadow:0 20px 50px rgba(0,0,0,.4)}
.hero .cap{font-size:.8rem;color:#93a7c8;margin-top:.7rem;font-style:italic}

/* section blocks on home */
.band{padding:3rem 0}
.band.alt{background:var(--card);border-top:1px solid var(--rule);border-bottom:1px solid var(--rule)}
.band h2{position:relative;padding-bottom:.5rem;margin-bottom:1.6rem}
.band h2::after{content:"";position:absolute;left:0;bottom:0;width:56px;height:3px;background:var(--red);border-radius:3px}
.see-all{font-size:.9rem;font-weight:600;margin-top:1rem;display:inline-block}

/* mini publications */
.mini-pub{display:grid;grid-template-columns:74px 1fr;gap:1rem;padding:1rem 0;border-bottom:1px solid var(--rule)}
.mini-pub:last-child{border-bottom:none}
.mini-pub .yr{font-family:var(--serif);font-size:1.35rem;color:var(--red);font-weight:700;line-height:1.4}
.mini-pub h4{font-family:var(--sans);font-size:.98rem;margin:0 0 .1rem;font-weight:600;color:var(--ink)}
.mini-pub .ven{font-size:.85rem;color:var(--muted)}

/* section grid links */
.link-tile{display:flex;gap:.9rem;align-items:flex-start;padding:1.1rem;border:1px solid var(--rule);border-radius:var(--radius);background:var(--card);transition:.18s}
.link-tile:hover{transform:translateY(-2px);border-color:var(--red);box-shadow:var(--shadow)}
.link-tile .ic{font-size:1.5rem;line-height:1.3}
.link-tile b{display:block;color:var(--navy);font-size:1rem}
.link-tile span{font-size:.85rem;color:var(--muted)}

/* ---------- Footer ---------- */
footer.site{background:var(--navy);color:#aab7cf;margin-top:auto;padding:3rem 0 1.6rem}
footer.site .fgrid{display:grid;grid-template-columns:repeat(5,1fr);gap:1.6rem}
footer.site h5{color:#e6ecf7;font-size:.78rem;letter-spacing:.08em;text-transform:uppercase;margin:0 0 .8rem;font-family:var(--sans)}
footer.site ul{list-style:none;padding:0;margin:0}
footer.site li{margin:0 0 .45rem}
footer.site a{color:#aab7cf;font-size:.9rem}
footer.site a:hover{color:#fff}
footer.site .fbrand{grid-column:1/-1;display:flex;align-items:center;gap:.8rem;margin-bottom:1.4rem}
footer.site .fbrand img{height:38px}
footer.site .fbrand .t{font-family:var(--serif);font-size:1.05rem;color:#fff;font-weight:700}
footer.site .copy{border-top:1px solid rgba(255,255,255,.12);margin-top:2rem;padding-top:1.1rem;display:flex;justify-content:space-between;flex-wrap:wrap;gap:.5rem;font-size:.8rem}
footer.site .copy .red{color:var(--red);font-weight:600}

/* ---------- Responsive ---------- */
@media(max-width:960px){
  .hero .wrap{grid-template-columns:1fr;gap:1.8rem}
  .hero .portrait{max-width:340px;margin:0 auto}
  .grid-4{grid-template-columns:repeat(2,1fr)}
  .grid-3{grid-template-columns:1fr 1fr}
  .stats{grid-template-columns:repeat(2,1fr)}
  footer.site .fgrid{grid-template-columns:repeat(3,1fr)}
}
@media(max-width:720px){
  .nav-toggle{display:block}
  nav.site{display:none;flex-direction:column;align-items:stretch;width:100%;border-top:1px solid var(--rule);padding-top:.5rem}
  nav.site.open{display:flex}
  nav.site > a{border-radius:8px}
  nav.site .drop{position:static;opacity:1;visibility:visible;transform:none;box-shadow:none;border:none;padding-left:1rem;min-width:0}
  .grid-4,.grid-3{grid-template-columns:1fr}
  footer.site .fgrid{grid-template-columns:repeat(2,1fr)}
  table{font-size:.88rem}
  .info{padding:1rem 1.1rem}
}
@media(max-width:480px){
  .brand .bt .n{font-size:1.1rem}
  .stats{grid-template-columns:1fr 1fr}
}

/* print */
@media print{
  .topbar,nav.site,.crumbs,footer.site,.hero .cta{display:none}
  body{background:#fff}
}

/* ============================================================
   MODERN ANIMATIONS
   Tasteful, performant, and auto-disabled for users who prefer
   reduced motion. Triggered mainly by CSS; scroll-reveal uses
   a tiny IntersectionObserver added in js/animations.js.
   ============================================================ */

/* --- Scroll reveal --- */
/* .reveal stays visible by default; hiding applies only once JS
   confirms it can animate (html has .js-anim, added by animations.js).
   This is fail-safe: no JS => no hidden content. */
.js-anim .reveal{opacity:0;transform:translateY(22px);transition:opacity .7s ease,transform .7s cubic-bezier(.2,.7,.3,1)}
.js-anim .reveal.in{opacity:1;transform:none}

/* --- Hero entrance (on page load) --- */
.hero .wrap > *{animation:heroIn .9s cubic-bezier(.2,.7,.3,1) both}
.hero .wrap > *:nth-child(1){animation-delay:.05s}
.hero .wrap > *:nth-child(2){animation-delay:.18s}
@keyframes heroIn{from{opacity:0;transform:translateY(18px)}to{opacity:1;transform:none}}

/* --- Animated gradient underline on band headings --- */
.band h2::after{background:linear-gradient(90deg,var(--red),#e2733f);background-size:200% 100%;animation:gradShift 6s ease infinite}
@keyframes gradShift{0%,100%{background-position:0 0}50%{background-position:100% 0}}

/* --- Nav link animated underline --- */
nav.site > a::after{content:"";position:absolute;left:.85rem;right:.85rem;bottom:.12rem;height:2px;background:var(--red);border-radius:2px;transform:scaleX(0);transform-origin:left;transition:transform .25s ease}
nav.site > a:hover::after{transform:scaleX(1)}
nav.site > a.active::after{transform:scaleX(1);animation:none}

/* --- Card hover lift + soft glow --- */
.card,.link-tile,.proj-card,.feat{will-change:transform}
.card:hover{box-shadow:0 16px 40px rgba(18,35,63,.12);border-color:var(--rule-2)}

/* --- Stats counter pulse for accent --- */
.stat .num .u{display:inline-block;animation:pulseAccent 2s ease infinite}
@keyframes pulseAccent{0%,100%{opacity:1}50%{opacity:.35}}

/* --- Floating accent blobs in hero (subtle, behind content) --- */
.hero::before{content:"";position:absolute;left:-6%;top:8%;width:34%;height:60%;background:radial-gradient(circle,rgba(194,21,28,.28),transparent 62%);filter:blur(30px);pointer-events:none;animation:floatBlob 12s ease-in-out infinite;z-index:0}
.hero::after{content:"";position:absolute;right:-4%;bottom:4%;width:30%;height:55%;background:radial-gradient(circle,rgba(47,95,158,.4),transparent 62%);filter:blur(30px);pointer-events:none;animation:floatBlob 15s ease-in-out infinite reverse;z-index:0}
@keyframes floatBlob{0%,100%{transform:translateY(0)}50%{transform:translateY(-22px)}}
.hero .wrap{z-index:1}

/* --- Emoji icon gentle pop on hover --- */
.card .ic,.link-tile .ic{display:inline-block;transition:transform .25s ease}
.card:hover .ic,.link-tile:hover .ic{transform:scale(1.12) rotate(-4deg)}

/* --- Reveal groups stagger via transition-delay (applied by JS) --- */
.reveal.d1{transition-delay:.06s}
.reveal.d2{transition-delay:.14s}
.reveal.d3{transition-delay:.22s}
.reveal.d4{transition-delay:.30s}

/* --- Respect users who prefer reduced motion --- */
@media (prefers-reduced-motion: reduce){
  .js-anim .reveal{opacity:1;transform:none;transition:none}
  .hero .wrap > *{animation:none}
  .band h2::after{animation:none}
  .stat .num .u{animation:none}
  .hero::before,.hero::after{animation:none}
}