/* ==========================================================================
   edgaragayi.com — "Marginalia"
   An essay, set the way an essay should be. The prose runs down the middle;
   the record — dates, titles, releases, the stack — sits in the margin.
   ========================================================================== */

:root {
  /* Cool grey-green bond, not cream. */
  --paper:    #e9eae5;
  --paper-2:  #f2f3ef;
  --ink:      #16191a;
  --ink-mid:  #4b5350;
  --ink-soft: #6f7773;
  --rule:     #cbcec5;
  --rule-2:   #dcdfd7;
  --oxblood:  #8a2b36;   /* marks, links, the drop cap */
  --slate:    #33505e;   /* the technical margin only */

  --serif: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --col:    33rem;      /* the reading measure */
  --gutter: 3rem;
  --margin: 14.5rem;    /* the apparatus */
  --pad:    clamp(1.35rem, 5vw, 3.5rem);
  --ease:   cubic-bezier(.22, .68, .28, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-lamp="light"]) {
    --paper:    #15181a;
    --paper-2:  #1c2022;
    --ink:      #e4e6e0;
    --ink-mid:  #a3aaa5;
    --ink-soft: #838a86;
    --rule:     #2f3537;
    --rule-2:   #262b2d;
    --oxblood:  #e0838d;
    --slate:    #8fb6c9;
  }
}
:root[data-lamp="dark"] {
  --paper:    #15181a;
  --paper-2:  #1c2022;
  --ink:      #e4e6e0;
  --ink-mid:  #a3aaa5;
  --ink-soft: #838a86;
  --rule:     #2f3537;
  --rule-2:   #262b2d;
  --oxblood:  #e0838d;
  --slate:    #8fb6c9;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html.opening { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 380;
  font-size: clamp(1.06rem, 1.01rem + .26vw, 1.2rem);
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
p { margin: 0 0 1.15em; }
ul, ol, dl { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

::selection { background: var(--oxblood); color: var(--paper); }
:focus-visible { outline: 2px solid var(--oxblood); outline-offset: 3px; }

.skip {
  position: fixed; left: -9999px; top: 0; z-index: 999;
  background: var(--oxblood); color: var(--paper);
  padding: .8rem 1.2rem; font-family: var(--mono); font-size: .8rem;
}
.skip:focus { left: 0; }

/* ---------- links: an underline that belongs to the type ---------- */
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: .18em;
    text-decoration-thickness: 1px; transition: color .2s var(--ease), text-decoration-color .2s var(--ease); }
a:hover { color: var(--oxblood); text-decoration-color: var(--oxblood); }

/* ==========================================================================
   THE OPENING — a rule draws, the name sets, the page lifts. ~1.4s.
   ========================================================================== */
.open {
  position: fixed; inset: 0; z-index: 300;
  background: var(--paper);
  display: grid; place-content: center;
  transition: opacity .9s var(--ease), visibility .9s;
}
.open.lifted { opacity: 0; visibility: hidden; pointer-events: none; }
.open-inner { text-align: center; }
.open-rule {
  display: block; height: 1px; width: 0; margin: 0 auto 1.5rem;
  background: var(--oxblood);
  animation: drawRule .85s var(--ease) .15s forwards;
}
@keyframes drawRule { to { width: 7.5rem; } }
.open-name {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.5rem, 1.1rem + 1.9vw, 2.3rem);
  letter-spacing: -.015em; margin: 0 0 .45rem; opacity: 0;
  animation: settle .9s var(--ease) .55s forwards;
}
.open-sub {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--ink-soft); margin: 0; opacity: 0;
  animation: settle .9s var(--ease) .8s forwards;
}
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* reading progress — one hairline, nothing more */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 100;
  background: var(--oxblood); opacity: .75;
}

/* ---------- masthead ---------- */
.masthead {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem var(--pad);
  opacity: 0; pointer-events: none;
  transition: opacity .5s var(--ease);
}
.masthead.shown { opacity: 1; pointer-events: auto; }
.masthead::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--paper); opacity: .93;
  border-bottom: 1px solid var(--rule-2);
}
.mast-name {
  font-family: var(--serif); font-size: 1rem; font-weight: 500;
  text-decoration: none; letter-spacing: -.01em;
}
.lamp {
  background: none; border: 1px solid var(--rule); border-radius: 50%;
  width: 1.95rem; height: 1.95rem; cursor: pointer; color: var(--ink-soft);
  display: grid; place-items: center; font-size: .85rem; line-height: 1;
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .4s var(--ease);
}
.lamp:hover { color: var(--oxblood); border-color: var(--oxblood); transform: rotate(180deg); }

/* ==========================================================================
   THE ESSAY
   One column. On a wide screen it sits left of centre so the margin has room;
   below that the margin notes fold back into the flow as indented asides.
   ========================================================================== */
.essay {
  max-width: var(--col);
  margin: 0 auto;
  padding: clamp(4.5rem, 12vh, 9rem) var(--pad) 0;
}

@media (min-width: 1160px) {
  .essay {
    margin-left: max(var(--pad), calc(50% - (var(--col) + var(--gutter) + var(--margin)) / 2));
    margin-right: 0;
    padding-left: 0; padding-right: 0;
  }
}

/* ---------- title block ---------- */
.title { margin-bottom: clamp(3rem, 7vh, 5rem); }
.hello {
  font-style: italic; font-weight: 300; color: var(--oxblood);
  font-size: 1.15rem; margin-bottom: .35rem;
}
.title h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.3rem, 1.3rem + 4.4vw, 4.05rem);
  line-height: 1.02; letter-spacing: -.032em;
  margin: 0 0 1.5rem; text-wrap: balance;
}
.deck {
  font-size: clamp(1.12rem, 1.05rem + .4vw, 1.32rem);
  line-height: 1.5; color: var(--ink-mid); font-weight: 300;
  margin-bottom: 1.8rem; max-width: 30rem;
}
.byline {
  display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; margin: 0;
  padding-top: 1.2rem; border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft);
}

/* ---------- body copy ---------- */
.prose { position: relative; }

.prose p { hyphens: auto; }
.prose > p + p { text-indent: 0; }

/* the opening paragraph, with a drop cap */
.lede { margin-bottom: 1.3em; }
.lede::first-letter {
  float: left; font-size: 3.62em; line-height: .8; font-weight: 400;
  padding: .06em .1em 0 0; margin-top: .04em;
  color: var(--oxblood);
}

.prose h2 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(1.32rem, 1.16rem + .7vw, 1.72rem);
  letter-spacing: -.018em; line-height: 1.16;
  margin: 2.9em 0 .9em; padding-top: 1.5rem;
  border-top: 1px solid var(--rule-2);
  text-wrap: balance;
}
.prose h2::before {
  content: "§"; display: block; margin-bottom: .55rem;
  font-family: var(--mono); font-size: .72rem; font-weight: 400;
  color: var(--oxblood);
}

/* technologies named in running text, not in chips */
.stack {
  font-family: var(--mono); font-weight: 400;
  font-size: .84em; letter-spacing: -.01em;
  color: var(--slate);
}

/* the one line he wrote that deserves its own air */
.pull {
  margin: 2.2em 0; padding: 0 0 0 1.6rem;
  border-left: 2px solid var(--oxblood);
  font-style: italic; font-weight: 300;
  font-size: clamp(1.24rem, 1.1rem + .8vw, 1.6rem);
  line-height: 1.38; color: var(--ink);
}

.works-intro { color: var(--ink-mid); font-style: italic; margin-bottom: 0; }

/* ==========================================================================
   THE MARGIN
   Floated on a wide screen so a note aligns with the line that summons it;
   folded inline below that, where there is no margin to sit in.
   ========================================================================== */
.note {
  margin: 1.8rem 0;
  padding-left: 1.1rem;
  border-left: 1px solid var(--rule);
  font-size: .82rem; line-height: 1.5; color: var(--ink-mid);
}
.note-h {
  font-family: var(--mono); font-size: .63rem; letter-spacing: .17em;
  text-transform: uppercase; color: var(--ink-soft);
  margin: 0 0 .7rem;
}
.note-p { margin: 0; }
.note-p b { font-family: var(--mono); font-size: .74rem; font-weight: 500; color: var(--ink); letter-spacing: -.01em; }
.note-tech { border-left-color: var(--slate); }
.note-tech .note-p b { color: var(--slate); }

.note-list li { margin-bottom: .75rem; }
.note-list li:last-child { margin-bottom: 0; }
.note-list a { font-weight: 400; color: var(--ink); }
.note-list span, .note-list i {
  display: block; font-family: var(--mono); font-size: .62rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
  margin-top: .15rem; font-style: normal;
}
.note-list i { display: inline; font-family: var(--serif); font-size: 1em;
  text-transform: none; letter-spacing: 0; font-style: italic; color: inherit; margin: 0; }

.dates { font-family: var(--mono); font-size: .68rem; line-height: 1.45; }
.dates dt {
  float: left; clear: left; width: 4.2rem;
  color: var(--oxblood); letter-spacing: .02em;
}
.dates dd { margin: 0 0 .42rem 4.2rem; color: var(--ink-mid); }

@media (min-width: 1160px) {
  .note {
    float: right; clear: right;
    width: var(--margin);
    margin: .45rem calc((var(--gutter) + var(--margin)) * -1) 1.9rem 0;
    padding-left: 1.1rem;
  }
}

/* ==========================================================================
   THE WORKS — a bibliography, hanging-indented, not a grid of cards.
   ========================================================================== */
.works {
  max-width: var(--col);
  margin: 3rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.works > ol > li {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule-2);
}
.works > ol > li:first-child { padding-top: 0; }

.w-yr {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .12em;
  color: var(--ink-soft); margin: 0 0 .3rem;
}
.w-t {
  font-size: 1.2rem; line-height: 1.28; margin: 0 0 .45rem; font-weight: 400;
}
.w-t a { text-decoration-color: var(--rule-2); }
.w-form {
  display: block; font-family: var(--mono); font-size: .62rem;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin-top: .3rem;
}
.w-d {
  margin: 0; font-size: .93rem; line-height: 1.58; color: var(--ink-mid);
}
.works-foot {
  margin: 1.6rem 0 0; font-size: .9rem; color: var(--ink-mid); font-style: italic;
}

/* on a wide screen the year hangs out into the margin, like a citation */
@media (min-width: 1160px) {
  .works > ol > li { position: relative; padding-left: 0; }
  .w-yr {
    position: absolute; left: calc((var(--gutter) + 3.5rem) * -1);
    top: 1.5rem; width: 3.5rem; text-align: right; margin: 0;
  }
  .works > ol > li:first-child .w-yr { top: 0; }
}

/* ---------- sign-off ---------- */
.signoff {
  margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--rule);
  font-size: 1.1rem; color: var(--ink-mid);
}
.cheers {
  font-style: italic; font-size: 1.55rem; color: var(--oxblood);
  margin: 0 0 1rem;
}

/* ---------- colophon ---------- */
.colophon {
  margin-top: clamp(5rem, 12vh, 8rem);
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  padding: clamp(3rem, 7vh, 4.5rem) var(--pad) 3rem;
}
.colophon-in { max-width: var(--col); margin: 0 auto; }
@media (min-width: 1160px) {
  .colophon-in {
    margin-left: max(0px, calc(50% - (var(--col) + var(--gutter) + var(--margin)) / 2 - var(--pad)));
    margin-right: 0;
  }
}
.col-h {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: .8rem;
}
.col-mail { margin-bottom: 1.8rem; }
.col-mail a {
  font-size: clamp(1.4rem, 1.1rem + 1.5vw, 2.1rem);
  letter-spacing: -.02em; text-decoration-color: var(--rule);
}
.col-links {
  display: flex; flex-wrap: wrap; gap: .5rem 1.4rem;
  padding-bottom: 1.8rem; border-bottom: 1px solid var(--rule-2);
  margin-bottom: 1.4rem;
}
.col-links a { font-size: .95rem; }
.col-fine {
  font-family: var(--mono); font-size: .66rem; line-height: 1.7;
  letter-spacing: .04em; color: var(--ink-soft); margin: 0; max-width: 40ch;
}

/* ---------- quiet reveal: the margin notes arrive as you reach them ---------- */
.note.rv, .works > ol > li.rv { opacity: 0; }
.note.rv.in, .works > ol > li.rv.in {
  opacity: 1; transition: opacity .7s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .open { display: none; }
  html.opening { overflow: auto; }
  .open-rule { width: 7.5rem; }
  .open-name, .open-sub { opacity: 1; }
  .note.rv, .works > ol > li.rv { opacity: 1; }
}

@media print {
  .open, .masthead, .progress, .skip { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .essay { margin: 0 auto; max-width: 100%; padding: 0; }
  .note { float: none; width: auto; margin: 1.2rem 0; page-break-inside: avoid; }
  .works > ol > li { page-break-inside: avoid; }
  .w-yr { position: static; text-align: left; width: auto; }
  a { color: #000; }
}
