/* Visual polish for the homepage. Loaded after my_style.css, which is left untouched.
   Content and structure stay as they are; remove this file's <link> (and polish.js) to get the plain page back. */

/* ---------- Typeface: Source Serif 4, served from this site (SIL Open Font License) ---------- */
@font-face {
  font-family: 'Source Serif 4'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(common_resources/fonts/SourceSerif4-Roman-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(common_resources/fonts/SourceSerif4-Roman-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Source Serif 4'; font-style: italic; font-weight: 400 700; font-display: swap;
  src: url(common_resources/fonts/SourceSerif4-Italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4'; font-style: italic; font-weight: 400 700; font-display: swap;
  src: url(common_resources/fonts/SourceSerif4-Italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Theme ----------
   The colour of the page is one number per mode: a hue, 0-360 as in hsl()
   (0 red, 30 orange, 60 yellow, 140 green, 200 blue, 270 purple, 330 pink).
   Links, bullets, the lightsaber, glows and the tint of the page are all derived from it. */
:root {
  --hue-light: 140;   /* light mode: green */
  --hue-dark: 330;    /* dark mode: pink */
}
:root {
  color-scheme: light;
  --hue: var(--hue-light);
  --tint: calc(var(--hue) - 46);                       /* the page itself leans towards yellow, as it always did */
  --paper: hsl(var(--tint) 100% 96%);
  --paper-2: hsl(var(--tint) 77% 93%);
  --glow-a: rgba(255, 255, 255, .85);
  --glow-b: hsl(var(--tint) 70% 80% / .35);
  --ink: hsl(var(--hue) 20% 14%);
  --ink-2: hsl(var(--hue) 16% 20%);
  --ink-3: hsl(var(--hue) 18% 30%);
  --muted: hsl(var(--hue) 8% 40%);
  --accent: hsl(calc(var(--hue) + 6) 64% 31%);
  --accent-deep: hsl(calc(var(--hue) + 7) 74% 22%);
  --visited: hsl(calc(var(--hue) + 9) 29% 34%);
  --saber: hsl(var(--hue) 68% 51%);
  --blade-edge: hsl(var(--hue) 75% 65%);
  --blade-core: hsl(var(--hue) 100% 97%);
  --select: hsl(var(--hue) 70% 83%);
  --line: hsl(calc(var(--tint) + 3) 47% 83%);
  --card: rgba(255, 255, 255, .72);
  --frame: #fff;
  --shadow: hsl(var(--hue) 50% 15%);
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --hue: var(--hue-dark);
  --tint: var(--hue);
  --paper: hsl(var(--hue) 14% 9%);
  --paper-2: hsl(var(--hue) 18% 6%);
  --glow-a: hsl(var(--hue) 70% 60% / .13);
  --glow-b: hsl(var(--hue) 80% 50% / .09);
  --ink: hsl(var(--hue) 20% 92%);
  --ink-2: hsl(var(--hue) 14% 82%);
  --ink-3: hsl(var(--hue) 12% 72%);
  --muted: hsl(var(--hue) 8% 62%);
  --accent: hsl(var(--hue) 90% 74%);
  --accent-deep: hsl(var(--hue) 100% 84%);
  --visited: hsl(var(--hue) 40% 66%);
  --saber: hsl(var(--hue) 100% 66%);
  --blade-edge: hsl(var(--hue) 100% 72%);
  --blade-core: hsl(var(--hue) 100% 97%);
  --select: hsl(var(--hue) 60% 34%);
  --line: hsl(var(--hue) 16% 24%);
  --card: rgba(255, 255, 255, .06);
  --frame: hsl(var(--hue) 12% 22%);
  --shadow: #000;
}

/* ---------- Page ---------- */
html { background: var(--paper); transition: background-color .45s; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 420px at 18% -80px, var(--glow-a), transparent 70%),
    radial-gradient(700px 500px at 105% 30%, var(--glow-b), transparent 70%),
    linear-gradient(var(--paper), var(--paper-2));
}
body {
  max-width: 900px; margin: 44px auto 14%; padding: 0 28px; box-sizing: border-box;
  background-color: transparent !important;   /* the colour now sits on <html>, so the glow behind shows */
  color: var(--ink);
  font: 400 18px/1.62 'Source Serif 4', 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Times New Roman', 'Songti SC', 'Noto Serif CJK SC', SimSun, serif;
  font-optical-sizing: auto; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
::selection { background: var(--select); }
table { border-collapse: collapse; font: inherit; color: inherit; }
td { padding: 0; }
p { margin: .6em 0; }
small { font-size: .82em; }
b, strong { font-weight: 650; }
li p:empty { display: none; }   /* stray </p> tags in the lists create empty paragraphs */

/* ---------- Links ---------- */
a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 32%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color .2s, text-decoration-color .2s, background-color .2s; border-radius: 3px; }
a:visited { color: var(--visited); }
a:hover { color: var(--accent-deep); text-decoration-color: currentColor; background-color: color-mix(in srgb, var(--saber) 14%, transparent); }
a:focus-visible { outline: 2px solid var(--saber); outline-offset: 2px; }
a[href^="javascript"] { background: none !important; }

/* ---------- Name and lightsaber rule ---------- */
h1 { margin: 0 0 .25em; font-size: 2.45rem; font-weight: 700; line-height: 1.15; letter-spacing: -.015em; text-wrap: balance; }
hr {
  position: relative; height: 6px; margin: 16px 0 30px; border: 0; background: none; overflow: visible; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
hr::before {   /* hilt */
  content: ''; position: absolute; left: 0; top: -4px; width: 62px; height: 14px; border-radius: 3px 2px 2px 3px;
  background:
    linear-gradient(90deg, transparent 0 7px, #15191b 7px 10px, transparent 10px 15px, #15191b 15px 18px, transparent 18px 23px, #15191b 23px 26px, transparent 26px 50px, #d7dde0 50px 53px, transparent 53px),
    linear-gradient(#aeb6bb, #5d666c 38%, #7f888e 52%, #2c3236);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .35);
}
hr::after {    /* blade */
  content: ''; position: absolute; left: 60px; right: calc(var(--blade-gap, 0px) + 5px); top: 0; height: 6px; border-radius: 0 6px 6px 0;   /* ends 5px short of the rule; --blade-gap: set by polish.js where the mode button needs more room */
  background: linear-gradient(var(--blade-edge), var(--blade-core) 42%, var(--blade-core) 58%, var(--blade-edge));
  box-shadow: 0 0 5px 1px color-mix(in srgb, var(--saber) 90%, transparent), 0 0 14px 3px color-mix(in srgb, var(--saber) 50%, transparent), 0 0 30px 8px color-mix(in srgb, var(--saber) 22%, transparent);
  transform-origin: 0 50%; transition: transform .45s var(--ease), opacity .3s, filter .3s;
  animation: ignite .9s var(--ease) .35s backwards, hum 2.4s ease-in-out 1.4s infinite;
}
hr:hover::after { filter: brightness(1.08) saturate(1.25); }
hr.is-off::after { transform: scaleX(0); opacity: .2; animation: none; }
@keyframes ignite { from { transform: scaleX(0); opacity: .3; } }
@keyframes hum { 50% { box-shadow: 0 0 6px 1px color-mix(in srgb, var(--saber) 95%, transparent), 0 0 18px 4px color-mix(in srgb, var(--saber) 58%, transparent), 0 0 38px 10px color-mix(in srgb, var(--saber) 28%, transparent); } }

/* ---------- Top intro ---------- */
#td-top-intro { padding: 4px 22px 4px 0; white-space: normal; vertical-align: middle; }
#td-top-intro img {
  display: block; object-fit: cover; border: 5px solid var(--frame); border-radius: 10px;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow) 20%, transparent), 0 10px 26px color-mix(in srgb, var(--shadow) 18%, transparent);
  transition: transform .45s var(--ease), box-shadow .45s;
  transform: rotate(-2deg);
}
#td-top-intro img:hover { transform: rotate(-1.4deg) scale(1.05); box-shadow: 0 2px 4px color-mix(in srgb, var(--shadow) 20%, transparent), 0 18px 38px color-mix(in srgb, var(--shadow) 24%, transparent); }
#td-top-intro + td { vertical-align: middle; line-height: 1.5; color: var(--ink-2); }
#td-top-intro + td::first-line { font-size: 1.2em; font-weight: 650; color: var(--ink); }
body > table:first-of-type { margin-bottom: 18px; }

/* ---------- Hello there ---------- */
#td-sec-title { vertical-align: bottom; }   /* the hint under the bubble ends level with the picture */
#obi-wan { display: block; border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 20px color-mix(in srgb, var(--shadow) 20%, transparent); }
#td-sec-title a { position: relative; display: block; border-radius: 10px; }
#td-sec-title a::before, #td-sec-title a::after {   /* sound rings, fired by polish.js */
  content: ''; position: absolute; inset: 0; border: 2px solid var(--saber); border-radius: 12px; opacity: 0; pointer-events: none;
}
.said #td-sec-title a::before { animation: ring .9s ease-out; }
.said #td-sec-title a::after { animation: ring .9s ease-out .18s; }
@keyframes ring { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.35, 1.6); } }
/* speech bubble: common_resources/speech_bubble.png, cut out of its grey backdrop and enlarged (speech_bubble.png).
   It is drawn as nine slices: the corners, one of which holds the tail, keep their size and the edges stretch with the text. */
#td-sec-title h2 {
  position: relative; top: -30px; z-index: 0; display: inline-block; margin: 0 0 0 -8px; padding: 25px 32px 47px 30px;   /* lifted, so that the tail points at Obi-Wan */
  font-size: 1.3rem; line-height: 1.25; color: #1c2a1e; white-space: nowrap; transform-origin: 12% 92%;
}
#td-sec-title h2::before {
  content: ''; position: absolute; inset: 0; z-index: -1; border-style: solid; border-width: 26px 26px 42px 83px;
  border-image: url(common_resources/speech_bubble.png) 80 80 128 256 fill stretch;
}
.said #td-sec-title h2 { animation: pop .5s var(--ease); }
@keyframes pop { 35% { transform: scale(1.12) rotate(-2deg); } }
#td-sec-title h2 ~ i { display: block; margin: -24px 0 -3px 14px; line-height: 1.15; color: var(--muted); }   /* in the room the lifted bubble leaves; its letters stand on the picture's lower edge */
.hi-count { white-space: nowrap; }                                   /* tally of all clicks, added by polish.js */
.hi-count b { display: inline-block; color: var(--accent); font-variant-numeric: tabular-nums; }
.said .hi-count b { animation: pop .5s var(--ease); }

/* ---------- Section headings ---------- */
h2 { position: relative; margin: .2em 0 .55em; font-size: 1.6rem; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
body > h2 { padding-left: .72em; }
body > h2::before { content: ''; position: absolute; left: 0; top: .16em; bottom: .14em; width: 5px; border-radius: 3px; background: linear-gradient(var(--saber), var(--accent)); box-shadow: 0 0 10px color-mix(in srgb, var(--saber) 45%, transparent); }

/* ---------- Lists ---------- */
ul { margin: .7em 0; padding-left: .3em; list-style: none; }
li { position: relative; margin: .42em 0; padding-left: 1.25em; }
li::before { content: ''; position: absolute; left: .12em; top: .66em; width: .42em; height: .42em; border-radius: 1px; background: var(--accent); transform: rotate(45deg); }

/* Where have I been: a timeline */
ul.timeline { margin-left: .42em; padding-left: 0; border-left: 2px solid var(--line); }
ul.timeline li { margin: 0; padding: .3em 0 .3em 1.35em; }
ul.timeline li::before { left: -.4em; top: .82em; width: .62em; height: .62em; border: 2px solid var(--accent); border-radius: 50%; background: var(--paper); transform: none; box-sizing: border-box; transition: background-color .25s, transform .25s; }
ul.timeline li:hover::before { background: var(--saber); transform: scale(1.25); }
ul.timeline li:first-child::before { background: var(--saber); box-shadow: 0 0 0 0 color-mix(in srgb, var(--saber) 50%, transparent); animation: here 2.4s ease-out infinite; }
@keyframes here { to { box-shadow: 0 0 0 9px color-mix(in srgb, var(--saber) 0%, transparent); } }
.when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Honors: stars */
ul.honors li::before { content: '★'; top: .14em; left: 0; width: auto; height: auto; background: none; transform: none; color: #d9a514; font-size: .82em; text-shadow: 0 0 8px rgba(217, 165, 20, .35); }

/* ---------- Publications ---------- */
.imgtable { width: calc(100% + 28px); margin: .4em -14px 0; border-collapse: separate; border-spacing: 0 6px; }   /* thumbnails line up with the text edge; the hover card bleeds out a little */
.imgtable td { transition: background-color .3s, box-shadow .3s; }
.imgtable tr:hover td { background-color: var(--card); }
#td-pubs-fig { width: 200px; padding: 14px 20px 14px 14px; border-radius: 14px 0 0 14px; vertical-align: top; }
#td-pubs-text { padding: 12px 16px 14px 4px; border-radius: 0 14px 14px 0; vertical-align: top; line-height: 1.5; }
#td-pubs-fig img, .thumb { border-radius: 7px; }
#td-pubs-fig img { display: block; border: 0; box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow) 22%, transparent), 0 8px 20px color-mix(in srgb, var(--shadow) 16%, transparent); transition: transform .45s var(--ease), box-shadow .45s; }
.imgtable tr:hover #td-pubs-fig img { transform: scale(1.035); box-shadow: 0 2px 4px color-mix(in srgb, var(--shadow) 22%, transparent), 0 14px 30px color-mix(in srgb, var(--shadow) 22%, transparent); }
/* glossy highlight that follows the cursor; the wrapper is added by polish.js */
.thumb { position: relative; display: block; overflow: visible; transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .35s var(--ease); }
.thumb::after {
  content: ''; position: absolute; inset: 0; border-radius: 7px; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .7), rgba(255, 255, 255, .12) 32%, transparent 55%);
  mix-blend-mode: soft-light;
}
.imgtable tr:hover .thumb::after { opacity: 1; }
.imgtable tr:hover .thumb img { transform: none; }
h4 { margin: 0 0 .28em; font-size: 1.14rem; font-weight: 650; line-height: 1.32; }
#td-pubs-text > i { color: var(--ink-3); }
body > p > i { color: var(--muted); }

/* ---------- Mode button (added by polish.js) ----------
   It shows the side one would switch to: Vader in light mode, Anakin in dark mode. polish.js puts it just beyond the tip of the lightsaber; it is fixed to the window,
   so it stays at that spot while the page scrolls. The values below only apply until the script has placed it. */
.theme-btn {
  position: fixed; top: 88px; right: 16px; z-index: 5; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1.5px solid var(--saber); border-radius: 50%; background: #0b0b0d; cursor: pointer; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 6px 1px color-mix(in srgb, var(--saber) 70%, transparent), 0 0 18px 4px color-mix(in srgb, var(--saber) 30%, transparent);
  transition: box-shadow .25s, transform .25s var(--ease), opacity .25s, background-color .45s, border-color .45s;
}
.theme-btn.is-away { opacity: 0; transform: scale(.6); pointer-events: none; }   /* narrow windows: out of the way of the text while the page is scrolled */
.theme-btn:hover { transform: scale(1.12) rotate(-8deg); box-shadow: 0 0 8px 2px color-mix(in srgb, var(--saber) 85%, transparent), 0 0 26px 7px color-mix(in srgb, var(--saber) 40%, transparent); }
.theme-btn:focus-visible { outline: 2px solid var(--saber); outline-offset: 3px; }
.theme-btn img { display: block; width: 30px; height: 30px; }
.theme-btn .to-light, [data-theme="dark"] .theme-btn .to-dark { display: none; }
[data-theme="dark"] .theme-btn .to-light { display: block; }
[data-theme="dark"] .theme-btn { background: #fff; }   /* Vader stands on black, Anakin on white */

/* ---------- Reveal on scroll (only once polish.js is running) ---------- */
.fx .rv { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.fx .rv.in { opacity: 1; transform: none; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  body { margin-top: 28px; padding: 0 18px; font-size: 17px; }
  h1 { font-size: 2rem; }
  #td-top-intro, #td-top-intro + td { display: block; padding: 0; }
  #td-top-intro img { margin-bottom: 14px; }
  .imgtable, .imgtable tbody, .imgtable tr, .imgtable td { display: block; width: auto; }
  .imgtable { margin: .4em -12px 0; }
  .imgtable tr { margin-bottom: 14px; }
  #td-pubs-fig { padding: 12px 12px 4px; border-radius: 14px 14px 0 0; }
  #td-pubs-text { padding: 6px 12px 12px; border-radius: 0 0 14px 14px; }
  #td-sec-title h2 { font-size: 1.12rem; padding-right: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
