/* An illuminated page. Vellum by day, lapis by night; the hero is always the night page. */
:root {
  --vellum: #e8d9b3;
  --vellum-deep: #dcc99a;
  --ink: #1f1a12;
  --ink-soft: #4d4230;
  --lapis: #141f57;
  --lapis-deep: #0f1a4d;
  --bone: #f4ecd8;
  --gold: #c9a227;
  --gold-bright: #e8c660;
  --vermilion: #a52317; /* 5.3:1 on vellum */

  --ground: var(--vellum);
  --panel: var(--vellum-deep);
  --text: var(--ink);
  --muted: var(--ink-soft);
  --rubric: var(--vermilion);
  --title: var(--lapis);
  --rule: #c4ae7c;
  --ornament: var(--ink-soft);
  --link: var(--lapis);
  --seal: var(--vermilion);
  --seal-text: var(--bone);

  --display: "Pirata One", "Grenze Gotisch", "Old English Text MT", Georgia, serif;
  --text-face: "Alegreya", "Iowan Old Style", "Palatino", Georgia, serif;

  --gutter: clamp(16px, 5vw, 64px);
  --measure: 62ch;
  --gloss: 15rem;
  /* The window keeps a fixed 520:760 shape so the tracery drawn inside it never distorts. */
  --win-h: min(78svh, 760px, calc(38vw / 0.684));
  --win-w: calc(var(--win-h) * 0.684);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: var(--lapis);
    --panel: var(--lapis-deep);
    --text: var(--bone);
    --muted: #d2c8ab;
    --rubric: var(--gold-bright);
    --title: var(--bone);
    --rule: #33428f;
    --ornament: var(--gold-bright);
    --link: var(--gold-bright);
    --seal: var(--gold-bright);
    --seal-text: var(--lapis-deep);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: var(--lapis);
  --panel: var(--lapis-deep);
  --text: var(--bone);
  --muted: #d2c8ab;
  --rubric: var(--gold-bright);
  --title: var(--bone);
  --rule: #33428f;
  --ornament: var(--gold-bright);
  --link: var(--gold-bright);
  --seal: var(--gold-bright);
  --seal-text: var(--lapis-deep);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 1.15rem/1.6 var(--text-face);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img { display: block; max-width: 100%; height: auto; }
[hidden] { display: none !important; }
.defs { position: absolute; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--rubric); }
:focus-visible { outline: 3px solid var(--rubric); outline-offset: 3px; }
.bar :focus-visible, .hero :focus-visible { outline-color: var(--gold-bright); }

h1, h2 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.02;
  margin: 0;
  letter-spacing: 0.01em;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--vermilion); color: var(--bone);
  padding: 10px 16px; font-size: 1rem; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Top bar: sits over the hero only ---------- */

.bar {
  position: absolute; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: center; gap: 1.25rem;
  padding: 14px var(--gutter) 40px;
  color: var(--bone);
  background: linear-gradient(to bottom, rgb(15 26 77 / 0.7), transparent);
}
.mark {
  font-family: var(--display); font-weight: 400; font-size: 1.6rem; line-height: 1;
  color: var(--gold-bright); text-decoration: none; margin-right: auto;
  padding: 6px 0;
}
.mark:hover { color: var(--bone); }
.bar nav { display: flex; gap: 1.1rem; }
.bar nav a { color: var(--bone); font-size: 1.05rem; text-decoration: none; padding: 8px 0; }
.bar nav a:hover { color: var(--gold-bright); text-decoration: underline; }
.mode {
  font: 500 1rem var(--text-face); color: var(--bone);
  background: rgb(15 26 77 / 0.55); border: 1px solid rgb(244 236 216 / 0.35); border-radius: 999px;
  padding: 9px 14px; cursor: pointer;
}
.mode:hover { border-color: var(--gold-bright); color: var(--gold-bright); }
@media (max-width: 40em) {
  .bar nav { gap: 0.9rem; }
  .bar nav a:not(.keep) { display: none; }
}

/* ---------- Hero: the night page with a window cut into it ---------- */

.hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 100svh;
  background: var(--lapis-deep);
  color: var(--bone);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
}
/* The ink backdrop shows the river side of the scene; Omar himself is only in the window. */
.hero-photo {
  position: absolute; inset: 0; z-index: -2;
  background: url("img/hudson.jpg") 100% 40% / 200% auto no-repeat;
  filter: grayscale(1) contrast(1.05);
  animation: drift 16s ease-out both;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to top, rgb(15 26 77 / 0.92) 0%, rgb(15 26 77 / 0.6) 45%, rgb(20 31 87 / 0.5) 100%),
    var(--lapis);
  mix-blend-mode: multiply;
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to top, rgb(15 26 77 / 0.75), transparent 55%);
}
/* Coloured light from the window, drawn by fx.js. Sits over the ink backdrop, under the text. */
.light {
  position: absolute; inset: 0; z-index: -1;
  width: 100%; height: 100%;
  mix-blend-mode: screen; opacity: 0.75;
  pointer-events: none;
}

/* The window bay, built from photographs. The head (top 29.7%) is stone with a tracery light
   set in it; the transom is stone; the portrait fills the light below. They never overlap. */
.window {
  position: absolute; z-index: 0;
  right: var(--gutter); bottom: 0;
  width: calc(var(--win-h) * 0.684); height: var(--win-h);
  --band: calc(var(--win-h) * 0.022);
  --col-w: calc(var(--win-h) * 0.135);
  animation: open-window 1.2s 0.2s cubic-bezier(.2,.8,.2,1) both;
}
.stone {
  position: absolute; left: calc(-1 * var(--band)); right: calc(-1 * var(--band)); top: calc(-1 * var(--band)); bottom: 0;
  clip-path: url(#arch);
  background: url("img/stone.webp") center / 34% auto;
}
.stone::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.22), rgb(0 0 0 / 0.1) 40%, rgb(0 0 0 / 0.45));
  mix-blend-mode: multiply;
}
.stone.outer {
  left: calc(-1.9 * var(--band)); right: calc(-1.9 * var(--band)); top: calc(-1.9 * var(--band));
  filter: brightness(0.38) saturate(0.8);
}
.arch {
  position: absolute; inset: 0; clip-path: url(#arch);
  background: url("img/stone.webp") center top / 62% auto;
}
.arch::before {
  /* the recess of the head, darker toward the glass */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 31%;
  background: radial-gradient(60% 70% at 50% 45%, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0.15) 70%, rgb(0 0 0 / 0.3));
}
.head {
  position: absolute; left: 0; right: 0; top: 0; height: 29.7%;
  display: grid; place-items: center;
}
.glass {
  width: 42%; height: auto;
  filter: drop-shadow(0 0 14px rgb(255 214 120 / 0.55)) drop-shadow(0 0 34px rgb(255 170 60 / 0.35));
}
.arch::after {
  /* the transom's shadow falling onto the light below it */
  content: ""; position: absolute; left: 0; right: 0; top: 31.9%; height: 20%;
  background: linear-gradient(180deg, rgb(15 20 40 / 0.72), rgb(15 20 40 / 0.25) 45%, transparent);
  pointer-events: none;
}
.transom {
  position: absolute; left: 0; right: 0; top: 29.7%; height: 2.2%;
  background: url("img/stone.webp") center / 40% auto;
  box-shadow: 0 5px 12px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.25);
}
.portrait {
  position: absolute; left: 0; right: 0; top: 31.9%; bottom: 0;
  width: 100%; height: 68.1%;
  object-fit: cover; object-position: 44% 50%;
}
.column {
  position: absolute; bottom: 0; z-index: 2;
  width: var(--col-w); height: calc(var(--win-h) * 0.62);
  display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(5px 8px 12px rgb(0 0 0 / 0.55)) brightness(0.92);
}
.capital { width: 100%; height: auto; flex: none; }
.shaft {
  flex: 1; width: 56%; margin-top: -2px;
  background: url("img/shaft.webp") center top / 100% auto repeat-y;
}
.col-l { left: calc(var(--col-w) * -0.5 - var(--band) * 1.1); }
.col-r { right: calc(var(--col-w) * -0.5 - var(--band) * 1.1); }
.hero-text {
  position: relative; z-index: 1;
  padding: 10vh var(--gutter) clamp(36px, 6vh, 64px);
  max-width: 60ch;
  text-shadow: 0 2px 24px rgb(15 26 77 / 0.6);
}
h1 {
  font-size: clamp(4.6rem, 11vw, 9.5rem);
  line-height: 0.86;
  color: var(--gold-bright);
  animation: ink 1.1s 0.25s ease-out both;
}
.hello {
  margin: 1.2rem 0 0;
  font: italic 500 clamp(1.5rem, 3vw, 2rem)/1.15 var(--text-face);
  animation: ink 0.9s 0.6s ease-out both;
}
.intro {
  margin: 0.7rem 0 0; max-width: 48ch;
  font-size: clamp(1.1rem, 1.5vw, 1.25rem); line-height: 1.5;
  animation: ink 0.9s 0.8s ease-out both;
}
/* Fun facts: each fact's picture sits in the margin beside it, like marginalia. */
.fact {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0.4rem 1rem; align-items: start;
  padding: 1rem 0;
}
.fact + .fact { border-top: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.fact-text { grid-column: 2; max-width: var(--measure); }
.fact-text p { margin: 0; }
.fact-text strong { font-weight: 700; color: var(--title); }
.fact-pic { grid-column: 1; grid-row: 1; margin: 0; }
.fact-pic img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); }
.fact-pic figcaption { display: none; }
@media (min-width: 56.01em) {
  .fact { grid-template-columns: minmax(0, 1fr) var(--gloss); gap: 0.5rem 4rem; }
  .fact-text { grid-column: 1; }
  .fact-pic { grid-column: 2; width: 7.5rem; }
  .fact-pic figcaption { display: block; margin-top: 0.4rem; font-style: italic; font-size: 0.92rem; line-height: 1.4; color: var(--rubric); }
}

@media (min-width: 56.01em) {
  /* Keep the text clear of the window at any text size. */
  .hero-text { max-width: min(60ch, calc(100% - var(--win-w) - var(--win-h) * 0.2 - 2rem)); }
}
@media (max-width: 56em) {
  .hero { grid-template-rows: auto 1fr; align-items: start; }
  .hero-photo { background-size: cover; background-position: 85% 35%; }
  .window {
    --win-h: min(52svh, 480px, calc(64vw / 0.684));
    position: relative; right: auto; bottom: auto;
    margin: 92px auto 0;
  }
  .hero-text { padding-top: 1.5rem; max-width: none; }
}

@keyframes ink { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }
@keyframes open-window { from { opacity: 0; transform: translateY(24px); } }
@keyframes drift { from { transform: scale(1.06); } }

/* ---------- The folio: leaves with a gloss margin ---------- */

.folio {
  max-width: calc(var(--measure) + var(--gloss) + 4rem + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(48px, 8vw, 104px) var(--gutter) 0;
}

.leaf {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem 4rem;
  padding: clamp(32px, 5vw, 56px) 0;
}
.leaf + .leaf { border-top: 1px solid var(--rule); }
.leaf > h2, .leaf > .entry, .leaf > .fleuron { grid-column: 1 / -1; }

h2 {
  font-size: clamp(2.6rem, 5.5vw, 3.9rem);
  color: var(--rubric);
  margin-bottom: 0.6rem;
}
/* Entry titles in the text face: the blackletter is for the name and the rubrics only. */
h3 {
  font: 700 clamp(1.45rem, 2.4vw, 1.7rem)/1.2 var(--text-face);
  color: var(--title);
  margin: 0 0 0.35rem;
  letter-spacing: 0.005em;
}

.text { max-width: var(--measure); min-width: 0; }
.text p { margin: 0 0 1.1em; }
.text p:last-child { margin-bottom: 0; }
.text h3 + .gloss-inline { margin-top: 0; }

.gloss, .gloss-inline {
  font-style: italic; font-size: 1.02rem; line-height: 1.5;
  color: var(--rubric);
}
.gloss p { margin: 0 0 0.5em; }
/* The planet, standing in for the word, like a marginal illustration. */
.earth { display: inline-block; vertical-align: -0.28em; width: 1.5em; height: 1.5em; position: relative; }
.earth img { width: 100%; height: 100%; border-radius: 50%; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.35)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gloss a { color: inherit; display: inline-block; padding: 5px 0; }
.gloss-inline { margin: 0 0 0.6em; }

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem 4rem;
  padding: 1.6rem 0 0.4rem;
}
.entry + .entry { margin-top: 1.6rem; border-top: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.entry > h3 { grid-column: 1 / -1; }

@media (min-width: 56.01em) {
  .leaf, .entry { grid-template-columns: minmax(0, 1fr) var(--gloss); }
  .gloss { grid-column: 2; grid-row: 2; padding-top: 0.45em; }
  .text { grid-column: 1; grid-row: 2; }
}

/* Drop cap: the rubricator's initial, on the first paragraph of a leaf. */
.dropcap::first-letter {
  font-family: var(--display); font-weight: 400;
  font-size: 4.1em; line-height: 0.78;
  float: left; padding: 0.08em 0.1em 0 0;
  color: var(--rubric);
}

/* Fleuron between the big parts. */
.fleuron {
  display: block; width: min(240px, 60%); height: 28px;
  margin: clamp(20px, 3vw, 36px) auto;
  color: var(--ornament);
}

/* The graduation miniature: a second arch window. */
.miniature {
  margin: 0; grid-column: 2; grid-row: 2;
  width: var(--gloss); max-width: 100%;
}
.miniature img {
  width: 100%; height: auto; aspect-ratio: 3 / 4.3; object-fit: cover; object-position: 50% 18%;
  clip-path: url(#arch);
}
.miniature figcaption {
  margin-top: 0.6rem; font-style: italic; font-size: 1.02rem; line-height: 1.5; color: var(--rubric);
}
@media (max-width: 56em) {
  .miniature { grid-column: 1; grid-row: 2; width: min(60vw, 280px); margin: 0.5rem auto 1rem; }
  .leaf-photo .text { grid-row: 3; }
}

/* Music player with a visible way out if it never loads. */
.player { margin: 1.2rem 0 0.6rem; background: var(--panel); border-radius: 12px; overflow: hidden; }
.player iframe { display: block; width: 100%; border: 0; }
.player-fallback { font-size: 1rem; color: var(--muted); }

/* CV button as a wax seal. */
.seal {
  display: inline-flex; align-items: center; gap: 0.9rem;
  text-decoration: none; color: var(--text); font-weight: 500;
}
.seal-mark {
  display: grid; place-items: center;
  width: 4.2rem; height: 4.2rem; border-radius: 50%;
  background: var(--seal); color: var(--seal-text);
  font: 400 1.9rem/1 var(--display);
  box-shadow: inset 0 0 0 4px var(--ground), inset 0 0 0 5px var(--seal);
  transition: transform 0.2s;
}
.seal:hover .seal-mark { transform: rotate(-6deg) scale(1.04); }
.seal:hover { color: var(--rubric); }

.email {
  font-family: var(--text-face); font-weight: 500;
  font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.15;
  overflow-wrap: anywhere; margin: 0.4em 0 0.6em;
}
.email a { text-decoration-thickness: 2px; text-underline-offset: 0.12em; }

/* Colophon. */
.colophon {
  max-width: calc(var(--measure) + var(--gloss) + 4rem + 2 * var(--gutter));
  margin: 0 auto; padding: 8px var(--gutter) 56px;
  text-align: center; font-style: italic; font-size: 1.02rem; line-height: 1.5; color: var(--muted);
}
.colophon p { margin: 0.3em 0; }
.colophon a { display: inline-block; padding: 5px 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-photo, .window, h1, .hello, .intro { animation: none; }
  .seal-mark { transition: none; }
}

@media print {
  .bar, .window, .light, .player, .fleuron, .mode { display: none; }
  .hero { min-height: 0; color: #000; background: none; }
  .hero-photo, .hero::before, .hero::after { display: none; }
  h1 { color: #000; }
  body { background: #fff; color: #000; }
}
