/* Evan Ren — personal site
   Design system: UI/UX Pro Max (see design-system/evan-ren/MASTER.md)
   Typography: "Financial Trust" — IBM Plex Sans for headings and body
   Style: Accessible & Ethical — 16px+ text, high contrast, 3px focus rings, 44px targets
   Colour: red, blue and black (owner's brief, overrides the system's light palette)
   Type scale: 14 / 16 / 18 / 20 / 28 / 56 */

:root {
  --bg: #07080a;
  --panel: #0d0f14;
  --line: #20242d;
  --line-2: #323845;
  --text: #f1f2f5;
  --soft: #c9cdd6;
  --muted: #9aa1ae;
  --red: #dc2626;
  --red-text: #f47272;
  --blue: #2563eb;
  --blue-text: #7aaeff;
  --mono: "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --wrap: 70rem;
  --measure: 38rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 1rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--blue-text); outline-offset: 3px; border-radius: 2px; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--blue); color: #fff; padding: .6rem 1rem; text-decoration: none; font-weight: 500; }
.skip:focus { top: .5rem; }

/* ---------- Ticker ---------- */
.tape { display: flex; align-items: stretch; height: 2.25rem; background: #000; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: .8125rem; letter-spacing: .03em; }
.tape-view { flex: 1; min-width: 0; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 3rem, #000 calc(100% - 3rem), transparent); mask-image: linear-gradient(90deg, transparent, #000 3rem, #000 calc(100% - 3rem), transparent); }
.tape-track { display: flex; width: max-content; height: 100%; animation: tape 48s linear infinite; }
.tape:hover .tape-track, .tape:focus-within .tape-track { animation-play-state: paused; }
.tape ul { display: flex; align-items: center; justify-content: space-around; gap: 2.75rem; padding: 0 1.375rem; min-width: 100vw; white-space: nowrap; }
.tape li { color: var(--muted); }
.tape li b { color: var(--text); font-weight: 500; margin-left: .5rem; }
.tape li i { font-style: normal; margin-left: .45rem; color: var(--blue-text); }
.tape .clock { flex: none; display: flex; align-items: center; padding: 0 1.25rem; border-left: 1px solid var(--line); color: var(--muted); white-space: nowrap; background: #000; }
.tape .clock b { color: var(--text); font-weight: 500; margin: 0 .4rem; font-variant-numeric: tabular-nums; }
.dot { width: .45rem; height: .45rem; border-radius: 50%; background: var(--red); margin-right: .55rem; animation: pulse 2.4s ease-in-out infinite; }
@keyframes tape { to { transform: translateX(-50%); } }
@keyframes pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); } 50% { opacity: .55; box-shadow: 0 0 0 .3rem rgba(220, 38, 38, 0); } }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(7, 8, 10, .95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; justify-content: space-between; height: 4rem; position: relative; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; font-size: 1.125rem; font-weight: 600; letter-spacing: -.005em; }
.brand img { width: 2rem; height: 2rem; transition: transform .25s ease; }
.brand:hover img { transform: rotate(-6deg); }
.brand-name { line-height: 1.15; }
.brand-tag { display: block; font-family: var(--mono); font-size: .6875rem; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.site-header { transition: box-shadow .25s ease; }
.site-header.scrolled { box-shadow: 0 12px 30px -18px rgba(37, 99, 235, .55); }

.tabs { display: flex; height: 100%; gap: .25rem; }
.tabs li { display: flex; }
.tabs a {
  display: flex; align-items: center; padding: 0 .9rem; min-height: 2.75rem;
  font-size: .9375rem; text-decoration: none; color: var(--muted);
  position: relative;
  transition: color .2s ease;
}
.tabs a::after { content: ""; position: absolute; left: .9rem; right: .9rem; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--red), var(--blue)); transform: scaleX(0); transform-origin: left; transition: transform .25s ease; }
.tabs a:hover::after, .tabs a[aria-current="page"]::after { transform: scaleX(1); }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 500; }

.menu-btn { display: none; cursor: pointer; width: 2.75rem; height: 2.75rem; padding: 0; background: transparent; border: 1px solid var(--line-2); border-radius: 4px; color: var(--text); align-items: center; justify-content: center; transition: border-color .2s ease; }
.menu-btn:hover { border-color: var(--muted); }
.menu-btn svg { width: 1.25rem; height: 1.25rem; }

main { flex: 1; }

/* ---------- Shared ---------- */
.eyebrow { font-size: .875rem; color: var(--muted); }
.mark { display: block; width: 2.5rem; height: 3px; margin-bottom: 1.25rem; background: linear-gradient(90deg, var(--red) 0 50%, var(--blue) 50% 100%); }
.lede { font-size: 1.125rem; line-height: 1.65; color: var(--soft); max-width: var(--measure); }
.text-link { color: var(--blue-text); text-decoration: underline; text-decoration-color: rgba(122, 174, 255, .4); text-underline-offset: .2em; transition: text-decoration-color .2s ease; }
.text-link:hover { text-decoration-color: var(--blue-text); }

.btn {
  display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  min-height: 2.75rem; padding: .625rem 1.125rem; border-radius: 4px;
  font: 500 .9375rem/1.2 var(--sans); text-decoration: none;
  border: 1px solid transparent; transition: background-color .2s ease, border-color .2s ease;
}
.btn svg { width: 1.0625rem; height: 1.0625rem; flex: none; transition: transform .2s ease; }
.btn:hover svg { transform: translateX(3px); }
.btn--blue { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
.btn--blue:hover { box-shadow: 0 8px 24px -8px rgba(37, 99, 235, .7); }
.btn { transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease; }
.btn--blue { background: var(--blue); color: #fff; }
.btn--blue:hover { background: #1d4fd8; }
.btn--line { border-color: var(--line-2); color: var(--text); }
.btn--line:hover { border-color: var(--muted); background: var(--panel); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.panel-head { padding: .875rem 1.25rem; border-bottom: 1px solid var(--line); font-size: 1rem; font-weight: 600; }

.section { padding: 4rem 0; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 2rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.section-head h2 { font-size: 1.75rem; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }

/* ---------- Home: hero ---------- */
.hero { position: relative; padding: 4.5rem 0 4rem; overflow: hidden; }
.hero > .wrap { position: relative; }
.glow { position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(38rem 22rem at 12% 0%, rgba(220, 38, 38, .16), transparent 70%),
    radial-gradient(40rem 24rem at 88% 10%, rgba(37, 99, 235, .2), transparent 70%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 3.5rem,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 3.5rem 100%;
  -webkit-mask-image: linear-gradient(#000 35%, transparent); mask-image: linear-gradient(#000 35%, transparent); opacity: .7; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 4rem; align-items: start; }
.hero h1 { font-size: clamp(3rem, 7vw, 4.5rem); font-weight: 600; line-height: 1.08; letter-spacing: -.025em; margin-top: .75rem; }
.hero .lede { margin-top: 1.5rem; }
.hero .lede + .lede { margin-top: 1rem; }
.hero .actions { margin-top: 2rem; }

.glance-id { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 1rem; align-items: center; padding: 1.25rem; border-bottom: 1px solid var(--line); }
.glance-id img { width: 5rem; height: 5rem; border-radius: 50%; object-fit: cover; object-position: 50% 18%; }
.glance-id strong { display: block; font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.glance-id span { display: block; font-size: .875rem; color: var(--muted); }
.kv div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 1rem; padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); }
.kv div:last-child { border-bottom: 0; }
.kv dt { font-size: .875rem; color: var(--muted); padding-top: .1rem; }
.kv dd { font-size: 1rem; }

/* ---------- Figures ---------- */
.figures ul { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.figures ul::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 3px; border-radius: 6px 6px 0 0; background: linear-gradient(90deg, var(--red) 0 50%, var(--blue) 50% 100%); }
.figures li { min-width: 0; padding: 1.5rem 1.5rem 1.6rem; border-left: 1px solid var(--line); }
.figures li:first-child { border-left: 0; }
.fig-num { display: block; font-family: var(--mono); font-size: 2rem; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fig-label { display: block; margin-top: .5rem; font-size: .9375rem; line-height: 1.45; color: var(--muted); }

/* ---------- Work cards ---------- */
.work { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.work article { position: relative; padding: 1.5rem 1.5rem 1.6rem; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; transition: border-color .25s ease; }
.work article::before { content: ""; position: absolute; left: -1px; top: 1.5rem; width: 3px; height: 1.6rem; background: var(--red); transition: height .25s ease; }
.work article:nth-child(even)::before { background: var(--blue); }
.work article:hover { border-color: var(--line-2); }
.work article:hover::before { height: calc(100% - 3rem); }
.rows li { transition: background-color .2s ease; }
.rows li:hover { background: #12151c; }
.work h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.work p { margin-top: .5rem; color: var(--soft); }
.work .where { margin-top: .9rem; font-size: .875rem; color: var(--muted); }

/* ---------- Tools + credentials ---------- */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.rows li { display: flex; justify-content: space-between; align-items: baseline; gap: 1.5rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li span:last-child { font-size: .875rem; color: var(--muted); text-align: right; }

/* ---------- Closing contact ---------- */
.closing { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem 3rem; flex-wrap: wrap; }
.closing h2 { font-size: 1.75rem; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.closing p { margin-top: .5rem; color: var(--soft); max-width: 32rem; }

/* ---------- Inner pages ---------- */
.page-head { padding: 4rem 0 2.5rem; }
.page-head h1 { font-size: clamp(2.25rem, 5vw, 3rem); font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.page-head .lede { margin-top: 1rem; }
.page-body { padding-bottom: 5rem; }

.entry { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 2.5rem; padding: 2.25rem 0; border-top: 1px solid var(--line); }
.entry-meta { font-size: .9375rem; color: var(--muted); line-height: 1.6; font-variant-numeric: tabular-nums; }
.entry-meta span { display: block; }
.entry-meta .now { display: inline-block; margin-top: .6rem; padding: .1rem .55rem; border: 1px solid var(--line-2); border-radius: 999px; font-size: .875rem; color: var(--soft); }
.entry h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.entry .org { margin-top: .15rem; color: var(--soft); font-size: 1.0625rem; }
.bullets { margin-top: 1rem; max-width: 42rem; }
.bullets li { position: relative; padding-left: 1.25rem; color: var(--soft); }
.bullets li + li { margin-top: .6rem; }
.bullets li::before { content: ""; position: absolute; left: 0; top: .72em; width: .4rem; height: .4rem; border-radius: 50%; background: var(--red); }

.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.about-grid .wide { grid-column: 1 / -1; }
.panel-body { padding: 1.25rem; }
.school { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.school + p { margin-top: .3rem; color: var(--soft); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.facts div { padding: 1rem 1.25rem; border-left: 1px solid var(--line); }
.facts div:first-child { border-left: 0; }
.facts dt { font-size: .875rem; color: var(--muted); }
.facts dd { margin-top: .2rem; font-size: 1.125rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.prose { max-width: var(--measure); color: var(--soft); }
.prose p + p { margin-top: 1rem; }

.contact-list { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); overflow: hidden; max-width: 44rem; }
.contact-list a { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 1.125rem 1.25rem; border-bottom: 1px solid var(--line); text-decoration: none; cursor: pointer; transition: background-color .2s ease; }
.contact-list li:last-child a { border-bottom: 0; }
.contact-list a:hover { background: #12151c; }
.contact-list a:hover .go { color: var(--blue-text); }
.contact-icon { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; color: var(--soft); }
.contact-icon svg { width: 1.2rem; height: 1.2rem; }
.contact-kind { display: block; font-size: .875rem; color: var(--muted); }
.contact-value { display: block; font-size: 1.125rem; font-weight: 500; overflow-wrap: anywhere; }
.go { color: var(--muted); transition: color .2s ease; }
.go svg { width: 1.25rem; height: 1.25rem; display: block; }

/* ---------- Projects ---------- */
.project-head h2 { margin-top: .35rem; font-size: 1.75rem; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.project-sub { margin-top: .25rem; color: var(--soft); }
.project-figures { margin: 1.75rem 0 2.5rem; }
.project-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 2.5rem; align-items: start; }
.project .prose { font-size: 1.0625rem; }
.valuation { margin-top: 2rem; }
.valuation .rows li span:first-child { flex: none; }
.docs .doc { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1.125rem; align-items: start; padding: 1.25rem; border-bottom: 1px solid var(--line); }
.docs .doc:last-child { border-bottom: 0; }
.doc-thumb { display: block; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; background: #fff; transition: border-color .2s ease, transform .25s ease; }
.doc-thumb img { width: 100%; height: auto; }
.doc-thumb:hover { border-color: var(--blue-text); }
.doc-title { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.doc-meta { margin-top: .2rem; font-size: .875rem; color: var(--muted); }
.doc-actions { display: flex; gap: .5rem; margin-top: .875rem; }
.btn--sm { padding: .5rem .875rem; font-size: .875rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: .5rem 1.5rem; flex-wrap: wrap; padding-top: 1.5rem; padding-bottom: 1.5rem; font-size: .875rem; color: var(--muted); }
.site-footer a { display: inline-flex; align-items: center; min-height: 2.75rem; text-decoration: none; transition: color .2s ease; }
.site-footer a:hover { color: var(--text); }
.foot-links { display: flex; gap: 1.5rem; }

/* ---------- Motion ---------- */
.spot { position: relative; }
.spot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(18rem circle at var(--mx, 50%) var(--my, 50%), rgba(122, 174, 255, .09), transparent 65%); }
.spot:hover::after { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .mark { transform-origin: left; animation: draw .7s cubic-bezier(.2, .7, .2, 1) both; }
  .hero .eyebrow, .hero h1, .hero .lede, .hero .actions, .hero aside,
  .page-head h1, .page-head .lede { animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
  .hero .eyebrow { animation-delay: .08s; }
  .hero h1, .page-head h1 { animation-delay: .14s; }
  .hero .lede, .page-head .lede { animation-delay: .24s; }
  .hero .lede + .lede { animation-delay: .32s; }
  .hero .actions { animation-delay: .4s; }
  .hero aside { animation-delay: .3s; }
  .glow { animation: fade 1.4s ease both; }
  .motion .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease var(--d, 0ms), transform .6s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms), border-color .25s ease, background-color .2s ease; }
  .motion .reveal.in { opacity: 1; transform: none; }
  @keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
  @keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes fade { from { opacity: 0; } to { opacity: .7; } }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .tape-track { transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .tabs { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 1px); height: auto; flex-direction: column; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 6px 6px; }
  .tabs.open { display: flex; }
  .tabs a { width: 100%; padding: .9rem 1.25rem; font-size: 1rem; border-bottom: 1px solid var(--line); margin: 0; }
  .tabs li:last-child a { border-bottom: 0; }
  .tabs a::after { display: none; }
  .tabs a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--blue); }
  .hero { padding: 3rem 0; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .figures ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures li:nth-child(odd) { border-left: 0; }
  .figures li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .two-col, .about-grid, .project-grid { grid-template-columns: 1fr; }
  .project-grid .docs { order: -1; }
  .entry { grid-template-columns: 1fr; gap: .75rem; padding: 2rem 0; }
  .entry-meta span { display: inline; }
  .entry-meta span + span::before { content: " · "; }
  .entry-meta .now { margin: 0 0 0 .5rem; }
  .entry-meta .now::before { content: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div:nth-child(odd) { border-left: 0; }
  .facts div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .section { padding: 3rem 0; }
  .page-head { padding: 3rem 0 2rem; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 1.25rem; }
  .tape .clock, .brand-tag { display: none; }
  .tape ul { gap: 2rem; }
  .work { grid-template-columns: 1fr; }
  .figures li { padding: 1.25rem; }
  .fig-num { font-size: 1.75rem; }
  .kv div { grid-template-columns: 6.5rem minmax(0, 1fr); }
  .rows li { flex-direction: column; gap: .1rem; }
  .rows li span:last-child { text-align: left; }
  .contact-list a { grid-template-columns: 2.75rem minmax(0, 1fr); }
  .contact-list .go { display: none; }
  .btn { flex: 1 1 100%; justify-content: center; }
  .doc-actions .btn { flex: 0 0 auto; }
  .valuation .rows li span:first-child { flex: initial; }
}
