@font-face {
  font-family: "Instrument Serif";
  src: url("./assets/instrument-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Sans";
  src: url("./assets/instrument-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  background-color: var(--paper);
  scroll-padding-block-start: var(--safe-top);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Wada No. 119 pairs Light Glaucous Blue with Dark Tyrian Blue. */
  --paper: #0f2738;
  --paper-highlight-rgb: 18 53 78;
  --paper-shade: #0b1f30;
  --ink: #edf6f5;
  --text: #d6e5e9;
  --muted: #b5cbd4;
  --accent: #a5c8d1;
  --rule: #6f8e9e;
  --fine-rule: #37546a;
  --wave-opacity: 0.17;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", system-ui, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --paper: #eaf4f4;
  --paper-highlight-rgb: 247 251 249;
  --paper-shade: #d4e7eb;
  --ink: #12354e;
  --text: #234658;
  --muted: #385767;
  --accent: #1c576c;
  --rule: #7e9faa;
  --fine-rule: #adc7ce;
  --wave-opacity: 0.19;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  isolation: isolate;
  color: var(--text);
  font: 1rem/1.55 var(--sans);
}

.site-background {
  --paper-glow-size: ellipse;
  --paper-glow-opacity: 1;
  position: fixed;
  inset: 0;
  z-index: 0;
  /* Keep the layers continuous as mobile browser controls expand and retract. */
  min-height: 100lvh;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--paper);
  background-image:
    url("./assets/paper-grain.png"),
    radial-gradient(
      var(--paper-glow-size) at 50% 12%,
      rgb(var(--paper-highlight-rgb) / var(--paper-glow-opacity)) 0%,
      transparent 71%
    ),
    linear-gradient(145deg, var(--paper), var(--paper-shade));
}

.wave-background {
  --wave-fade: radial-gradient(ellipse at 50% 40%, #0003 18%, #0006 48%, #000 96%);
  position: absolute;
  inset: 0;
  opacity: var(--wave-opacity);
  background-image: url("./assets/seigaiha.png");
  background-size: 120px 68px;
  -webkit-mask-image: var(--wave-fade);
  mask-image: var(--wave-fade);
}

.wave-background[data-animated] {
  background-image: none;
}

.wave-canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
}

.theme-switch {
  --bulb-fill: #a5c8d1;
  --bulb-fill-ink: #1c576c;
  position: fixed;
  inset-block-start: 0;
  inset-inline-end: calc(clamp(0.75rem, 3vw, 2.75rem) + var(--safe-right));
  z-index: 2;
  justify-items: center;
  min-inline-size: 2.75rem;
  padding: 0 0.35rem 0.45rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}

.theme-switch:not([hidden]) {
  display: grid;
}

.theme-switch::before {
  content: "";
  inline-size: 1px;
  block-size: calc(clamp(1.15rem, 4.6vw, 2.6rem) + var(--safe-top));
  background: currentColor;
  opacity: 0.55;
}

.theme-bulb {
  position: relative;
  display: grid;
  justify-items: center;
}

.theme-bulb::before {
  content: "";
  inline-size: 9px;
  block-size: 7px;
  border-radius: 1px;
  background: repeating-linear-gradient(to bottom, currentColor 0 2px, transparent 2px 3px);
}

.theme-bulb-glass {
  position: relative;
  inline-size: 22px;
  block-size: 32px;
  margin-block-start: -1px;
  border: 1px solid currentColor;
  border-radius: 36% 36% 50% 50% / 56% 56% 36% 36%;
}

.theme-switch[aria-checked="true"] .theme-bulb-glass {
  --bulb-filament-color: var(--bulb-fill-ink);
  background-color: var(--bulb-fill);
}

@supports (mask-image: none) or (-webkit-mask-image: none) {
  .theme-bulb-filament {
    --filament-mask: url("./assets/bulb-filament.png");
    position: absolute;
    inset: 0;
    color: var(--bulb-filament-color, inherit);
    background-color: currentColor;
    -webkit-mask: var(--filament-mask) center / 100% 100% no-repeat;
    mask: var(--filament-mask) center / 100% 100% no-repeat;
  }
}

.theme-bulb-rays {
  position: absolute;
  /* Pivot at the center of the glass's rounded end. */
  inset: auto auto 11px 50%;
  display: none;
  inline-size: 0;
  block-size: 0;
  opacity: 0.8;
  pointer-events: none;
}

.theme-bulb-rays > span {
  position: absolute;
  inset: -0.5px auto auto 0;
  inline-size: 4px;
  block-size: 1px;
  border-radius: 1px;
  background-color: currentColor;
  transform-origin: left center;
  transform: rotate(var(--ray-angle, 0deg)) translateX(15px);
}

.theme-bulb-rays > :nth-child(2) {
  --ray-angle: 45deg;
}

.theme-bulb-rays > :nth-child(3) {
  --ray-angle: 90deg;
}

.theme-bulb-rays > :nth-child(4) {
  --ray-angle: 135deg;
}

.theme-bulb-rays > :nth-child(5) {
  --ray-angle: 180deg;
}

.theme-switch[aria-checked="true"] .theme-bulb-rays {
  display: block;
}

@supports (clip-path: path(evenodd, "M 0 0 H 1 V 1 Z")) {
  .theme-bulb-glass {
    border: 0;
    border-radius: 0;
    clip-path: path("M 7 0 H 15 V 4 C 15 11 22 13 22 21 A 11 11 0 0 1 0 21 C 0 13 7 11 7 4 Z");
  }

  .theme-bulb-glass::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    clip-path: path(evenodd, "M 7 0 H 15 V 4 C 15 11 22 13 22 21 A 11 11 0 0 1 0 21 C 0 13 7 11 7 4 Z M 8 1 H 14 V 4 C 14 11 21 13 21 21 A 10 10 0 0 1 1 21 C 1 13 8 11 8 4 Z");
  }
}

@media (hover: hover) {
  .theme-switch:hover {
    color: var(--ink);
  }

  .theme-switch:hover .theme-bulb-glass {
    --bulb-filament-color: var(--bulb-fill-ink);
    background-color: var(--bulb-fill);
  }
}

.theme-switch:focus-visible {
  outline: none;
}

.theme-switch:focus-visible .theme-bulb {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.theme-switch[aria-checked="true"]:focus-visible .theme-bulb {
  outline-offset: 9px;
}

a {
  color: inherit;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.skip-link {
  position: absolute;
  inset: var(--safe-top) auto auto calc(1rem + var(--safe-left));
  z-index: 2;
  transform: translateY(calc(-120% - var(--safe-top)));
  background: var(--paper);
  padding: 0.7rem 1rem;
}

.skip-link:focus {
  transform: translateY(0);
}

.page {
  position: relative;
  z-index: 1;
  width: min(100% - 3rem, 47rem);
  margin-inline: auto;
  padding-block: clamp(3rem, 8vh, 5.5rem) 3.5rem;
}

.masthead {
  color: var(--ink);
  text-align: center;
  padding-block-end: 2rem;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  font-kerning: normal;
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(min(4.25rem, 15.5vw), 12vw, 8rem);
  line-height: 1;
  text-wrap: balance;
}

.khan-initial {
  margin-inline-end: 0.04em;
}

.degree-prefix {
  margin-inline-end: 0.12em;
}

.intro {
  margin: 0.8rem auto 0;
  max-width: 42ch;
  color: var(--muted);
  font: italic clamp(1.125rem, 3vw, 1.3125rem)/1.45 Georgia, serif;
  font-kerning: normal;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: clamp(1rem, 6vw, 3.5rem);
  margin: 0;
  padding: 0;
  border-block-start: 2px solid var(--ink);
  border-block-end: 1px solid var(--rule);
  color: var(--ink);
  list-style: none;
}

.profile-links a,
.profile-links span {
  display: flex;
  align-items: center;
  min-height: 2.65rem;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.135em;
  text-transform: uppercase;
  text-decoration: none;
}

.profile-links span {
  color: var(--muted);
}

.profile-links a:hover,
.profile-links a:focus-visible {
  text-decoration: underline;
}

.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-block-start: 2.4rem;
}

.column:first-child {
  padding-inline-end: clamp(1.25rem, 4vw, 2.4rem);
}

.column + .column {
  border-inline-start: 1px solid var(--rule);
  padding-inline-start: clamp(1.25rem, 4vw, 2.4rem);
}

.column h2 {
  font-size: clamp(1.875rem, 5vw, 2.375rem);
  line-height: 1.2;
}

.column,
.contact {
  scroll-margin-block-start: 1.5rem;
}

.column:target h2,
.contact:target h2 {
  color: var(--accent);
}

.entries {
  margin: 0.95rem 0 0;
  padding: 0;
  list-style: none;
}

.entries li {
  padding-block: calc(0.8rem + 1px) 0.8rem;
}

.entries li:first-child {
  border-block-start: 1px solid var(--fine-rule);
  padding-block-start: 0.8rem;
}

.entries li:last-child {
  padding-block-end: 0;
}

.entries h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.entries h3 a {
  text-decoration-color: var(--accent);
}

.entries .entry-location {
  display: inline-block;
  margin-inline-start: 0.5em;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 400;
}

.entries p {
  margin: 0.24rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 1.25rem;
  margin-block-start: 2.7rem;
  padding-block-start: 1.35rem;
  border-block-start: 3px double var(--rule);
}

.contact h2 {
  font-size: 1.65rem;
  line-height: 1.25;
}

.contact p {
  margin: 0.25rem 0 0;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.contact p span {
  color: var(--muted);
}

.copyright {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: end;
}

@media (min-width: 64rem) {
  :root {
    --desktop-scale: 1.25;
  }

  .page,
  .skip-link {
    zoom: var(--desktop-scale);
  }

  .theme-switch {
    transform: scale(var(--desktop-scale));
    transform-origin: top center;
  }
}

@media (max-width: 40rem) {
  .site-background {
    --paper-glow-size: ellipse 30rem 125%;
    --paper-glow-opacity: 0.6;
  }

  .page {
    width: min(100% - 2.5rem, 27.5rem);
    padding-block: 2.75rem;
  }

  .masthead {
    padding-block-end: 1.6rem;
  }

  .columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.95rem;
    margin-block-start: 1.85rem;
  }

  .column:first-child,
  .column + .column {
    border-inline-start: 0;
    padding-inline: 0;
  }

  .contact {
    margin-block-start: 2.2rem;
  }
}
