/* James Qian — personal site. Four pages, one typeface, one accent. Follows the system theme, or the visitor's choice (data-theme on <html>, stamped by theme.js). */

/* Switzer (Indian Type Foundry, via Fontshare; ITF Free Font License), served from here: no third-party requests */
@font-face { font-family: "Switzer"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/assets/fonts/switzer-400.ddd9595560c35725.woff2") format("woff2"); }
@font-face { font-family: "Switzer"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/assets/fonts/switzer-500.7393d1abac009ede.woff2") format("woff2"); }
@font-face { font-family: "Switzer"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/assets/fonts/switzer-600.d6497c264dbf70ae.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --bg: #F2F1ED;
  --ink: #1A1A19;
  --mute: #6E6D68;
  --line: rgba(26, 26, 25, .14);
  --line-strong: rgba(26, 26, 25, .34);
  --acc: #E85A1B;
  --dust: #1F1E1C;          /* the panel's palette: the icons' black, then the colours, in tones that hold on the light ground */
  --noise: #343330;         /* warm charcoal for the full-noise cloud */
  --sand: #BC8A36;
  --blue: #4668A3;
  --green: #3B8A5C;
  --red: #B8302A;
  --sky: #5F98D4;
  --graphite: #8A8983;      /* lighter than the dust the black parts take, so the two dark greys read apart */
  --snow: #B9B7B1;          /* snow and ice: light in both themes, but dark enough to show on this ground */
  --sans: "Switzer", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.2, 0, 0, 1);
}
/* The dark tokens apply when the system is dark and the visitor has not chosen light, and whenever the visitor has chosen dark;
   theme.js stamps that choice on <html> as data-theme before the first paint (the page's own switch sits under the panel). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --ink: #ECEAE5;
    --mute: #8E8D88;
    --line: rgba(236, 234, 229, .14);
    --line-strong: rgba(236, 234, 229, .32);
    --acc: #F0691F;
    --dust: #B8B6B0;
    --noise: #D8D6D0;       /* soft off-white for the full-noise cloud */
    --sand: #E2BC78;
    --blue: #6F8FC4;
    --green: #5FAE7E;
    --red: #D9483C;
    --sky: #A9CEEC;
    --graphite: #767571;
    --snow: #F8F6F2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --ink: #ECEAE5;
  --mute: #8E8D88;
  --line: rgba(236, 234, 229, .14);
  --line-strong: rgba(236, 234, 229, .32);
  --acc: #F0691F;
  --dust: #B8B6B0;
  --noise: #D8D6D0;
  --sand: #E2BC78;
  --blue: #6F8FC4;
  --green: #5FAE7E;
  --red: #D9483C;
  --sky: #A9CEEC;
  --graphite: #767571;
  --snow: #F8F6F2;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }
img { max-width: 100%; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px; }
main { flex: 1 0 auto; display: flex; flex-direction: column; }   /* the footer sits at the bottom of the window */

/* hairline links: one mechanism for the bio, the profiles, the caption, the Pause button and the theme switch */
.bio a, .links a, .hint a, .hint #motion span, .theme button span {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
  transition: color .2s var(--ease), text-decoration-color .2s var(--ease);
}
.bio a { text-decoration-color: var(--line-strong); }
.links a { color: var(--mute); }
.bio a:hover, .links a:hover, .hint a:hover, .hint #motion:hover span, .theme button:hover span { color: var(--ink); text-decoration-color: var(--acc); }

/* ---------- header ---------- */
.bar { display: flex; justify-content: space-between; align-items: center; height: 76px; }
.name { font-weight: 500; letter-spacing: -.01em; }
.nav { display: flex; gap: 28px; margin-left: auto; }
.nav a { position: relative; color: var(--mute); font-size: 15.5px; padding: 6px 0; transition: color .2s var(--ease); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a:focus-visible { outline-offset: 7px; }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -4px;
  width: 5px; height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--acc);
}
@media (max-width: 560px) {
  .bar { height: auto; flex-direction: column; align-items: flex-start; gap: 12px; padding: 22px 0 16px; }
  .nav { margin-left: 0; gap: 20px; }
}
@media (max-width: 380px) {
  .nav { gap: 16px; }
  .nav a { font-size: 15px; }
}

/* ---------- home: two equal halves, the text block and the square with its caption centred on each other ---------- */
.hero {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px 72px;
  align-items: center;
  padding: 40px 0;
}
.intro { max-width: 480px; }
.side { width: 100%; max-width: 480px; justify-self: end; }
.figure {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  touch-action: pan-y;
}
#diffusion { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hint {
  display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 6px 16px;
  margin: 14px 0 0; color: var(--mute); font-size: 14px; text-align: center;
}
.hint a { padding: 8px 0; }                            /* a taller hit area, same look */
.hint #motion { -webkit-appearance: none; appearance: none; background: none; border: 0; border-radius: 0; font: inherit; color: inherit; cursor: pointer; padding: 8px; margin: -8px; display: inline-grid; text-align: left; }
.hint #motion::after { content: "Pause"; visibility: hidden; height: 0; overflow: hidden; }   /* the wider label's width, so the caption never moves */
.theme { display: inline-flex; gap: 14px; }               /* Dark / Light / System, in the caption's own voice */
.theme button { -webkit-appearance: none; appearance: none; background: none; border: 0; border-radius: 0; font: inherit; color: inherit; cursor: pointer; padding: 8px 0; margin: -8px 0; -webkit-tap-highlight-color: transparent; }   /* Safari paints a native button unless the appearance is off */
.theme button[aria-pressed="true"] span { color: var(--ink); text-decoration-color: var(--acc); }
.portrait {
  display: block;
  width: 88px; height: 88px;
  object-fit: cover;
  border-radius: 3px;
  margin: 0 0 28px calc(.09 * clamp(34px, 4vw, 44px));   /* the J's hook overshoots the margin; the portrait sits on its optical edge */
}
h1 {
  font-size: clamp(34px, 4vw, 44px);
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1.05;
  margin: 0 0 14px;
}
.lede {
  font-size: clamp(20px, 2.2vw, 24px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -.012em;
}
.intro p { margin: 0 0 16px; text-wrap: pretty; }
.intro .lede { margin: 0 0 18px; }
.intro .links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 8px 0 0; }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 16px 0 48px; align-content: space-evenly; }   /* any height to spare is shared evenly above, between and below */
  .intro {
    max-width: 560px;
    display: grid;                                   /* a profile card: the portrait beside the name and the line, the rest under both */
    grid-template-columns: auto 1fr;
    grid-template-areas: "portrait name" "portrait lede" "bio bio" "links links";
    column-gap: 16px;
    align-items: center;
  }
  .portrait { grid-area: portrait; width: 72px; height: 72px; margin: 0; align-self: center; }   /* square, as on desktop */
  .intro h1 { grid-area: name; margin: 0; font-size: 30px; line-height: 1.1; align-self: end; }
  .intro .lede { grid-area: lede; margin: 4px 0 0; font-size: 18px; align-self: start; }
  .intro .bio { grid-area: bio; margin: 16px 0 0; }
  .intro .links { grid-area: links; margin: 12px 0 0; }
  .side { justify-self: center; max-width: min(420px, 70vh); }
}
@media (min-width: 901px) and (max-height: 760px) {
  .hero { padding: 16px 0; }
  .foot { padding: 14px 0 8px; }
}

/* ---------- inner pages ---------- */
.page { max-width: 64ch; padding: 40px 0 80px; }
.page h1 { margin-bottom: 18px; }
.page:has(+ .gallery:not(:empty)) { padding-bottom: 8px; }

/* ---------- photography ---------- */
.gallery { columns: 3; column-gap: 14px; padding: 8px 0 80px; }
.gallery:empty { display: none; }
.gallery figure { margin: 0 0 14px; break-inside: avoid; }
.gallery button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.gallery img { display: block; width: 100%; height: auto; border-radius: 2px; transition: opacity .25s var(--ease); }
.gallery button:hover img { opacity: .85; }
@media (max-width: 900px) { .gallery { columns: 2; } }
@media (max-width: 480px) { .gallery { columns: 1; } }

.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-rows: 1fr auto;
  background: rgba(18, 18, 17, .95);
  color: #ECEAE5;
}
.lightbox[hidden] { display: none; }
.lb-stage { display: grid; place-items: center; padding: 24px; min-height: 0; }
.lb-stage img { display: block; max-width: min(92vw, 1600px); max-height: 82vh; width: auto; height: auto; }
.lb-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 24px 24px; font-size: 14px; color: #8E8D88; }
.lb-nav { display: flex; gap: 8px; }
.lb-bar button {
  background: none; border: 1px solid rgba(236, 234, 229, .3); color: inherit;
  font: inherit; padding: 7px 12px; border-radius: 2px; cursor: pointer;
}
.lb-bar button:hover { color: #ECEAE5; border-color: #ECEAE5; }

/* ---------- footer ---------- */
.foot {
  margin: 0;
  padding: 28px 0 10px;                                     /* the line sits close to the window's bottom edge */
  text-align: center;
  color: var(--mute);
  font-size: 12.5px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- short and small windows (last, so these win): the text block gives up height, main.js gives the rest to the panel ---------- */
@media (max-height: 760px) {
  .portrait { width: 64px; height: 64px; margin-bottom: 14px; }
  .intro p { margin-bottom: 10px; }
  .intro .lede { margin-bottom: 12px; }
  .foot { padding: 10px 0 6px; }
}
@media (max-width: 900px) and (max-height: 960px) {          /* a phone held upright: the caption keeps the page's width, whatever the panel's */
  .hint { position: relative; left: 50%; width: calc(100vw - 48px); transform: translateX(-50%); font-size: 13px; margin-top: 10px; gap: 4px 12px; }
  .hero { gap: 20px; padding: 10px 0 14px; }
  .foot { padding: 10px 0 6px; }
}
@media (max-width: 900px) and (min-height: 701px) and (max-height: 960px) {   /* a tall phone: the text keeps most of its size, so the slack goes into it, not under the caption */
  body { font-size: 16px; }
  .intro .bio { margin-top: 14px; }
  .intro .links { margin-top: 10px; }
}
@media (max-width: 900px) and (max-height: 700px) {                            /* a short phone: everything gives up a little */
  body { font-size: 15.5px; }
  .portrait { width: 60px; height: 60px; }
  .intro h1 { font-size: 27px; }
  .intro .lede { font-size: 16.5px; }
  .intro .bio { margin-top: 10px; }
  .intro .links { margin-top: 8px; }
  .hero { gap: 16px; padding: 8px 0 12px; }
  .foot { padding: 8px 0 6px; }
}
/* ---------- a short window at any width (a phone or a small tablet on its side): two columns, everything smaller ---------- */
@media (max-height: 540px) and (min-width: 640px) {
  /* The panel is square, so on a short window main.js shrinks it to the height that is left. Half-and-half columns would
     then leave the text on one edge and a much narrower panel on the other with a hole between them, so here the two
     columns are sized to their contents and the pair is centred: the slack goes to the outside margins, not the middle. */
  .hero { grid-template-columns: auto auto; justify-content: center; gap: 12px 32px; padding: 6px 0; align-content: center; }
  .intro { width: min(480px, 50vw); max-width: none; display: block; }
  .side { width: min(420px, 42vw); max-width: 100%; justify-self: auto; }
  .hint { position: static; width: auto; transform: none; font-size: 12.5px; margin-top: 8px; gap: 4px 12px; }
  body { font-size: 14px; }
  .intro h1 { font-size: 24px; margin: 0 0 6px; }
  .intro .lede { font-size: 16px; margin: 0 0 8px; }
  .portrait { width: 44px; height: 44px; margin: 0 0 8px calc(.09 * 24px); }
  .intro p { margin-bottom: 8px; }
  .intro .links { margin-top: 6px; }
  .foot { padding: 6px 0 4px; }
}
