/* ============================================================
   ENTROPIN — robin westerlundh
   paper, ink & typewriter. violet like the portrait.
   ============================================================ */

:root {
  --paper:        #faf8f2;
  --paper-deep:   #f3f0e7;
  --ink:          #2b2742;
  --ink-soft:     #575170;
  --ink-faint:    #8d88a6;
  --violet:       #6a58c9;
  --violet-deep:  #4d3fa3;
  --violet-wash:  #ece8fa;
  --line:         #d9d4c8;
  --line-violet:  #c9c1ec;

  --mono:  "Courier Prime", "Courier New", Courier, monospace;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;   /* iOS Safari: don't inflate text in landscape */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--paper);
  /* faint paper grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--violet-wash); color: var(--violet-deep); }

img { max-width: 100%; height: auto; }

/* ---------- layout ---------- */

.sheet {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- masthead ---------- */

header.masthead {
  padding: 56px 0 0;
}

.masthead-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}

.wordmark .tilde { color: var(--violet); }

nav.compass {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  display: flex;
  gap: 22px;
}

nav.compass a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 0 4px;   /* taller tap target on touch screens */
}

nav.compass a:hover,
nav.compass a[aria-current="page"] {
  color: var(--violet-deep);
  /* hand-drawn wobbly underline */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='5' viewBox='0 0 80 5'%3E%3Cpath d='M1 3.2 Q 10 1.4 20 3 T 40 2.6 T 60 3.4 T 79 2.4' fill='none' stroke='%236a58c9' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left bottom;
}

/* ruled line under masthead, like a typed page header */
.rule {
  margin-top: 20px;
  border: 0;
  border-top: 1px solid var(--line);
  position: relative;
}

.rule::after {
  /* short violet ink stroke overlapping the rule */
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  width: 72px;
  border-top: 1px solid var(--violet);
}

/* ---------- hero (index) ---------- */

.hero {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 44px;
  align-items: center;
  padding: 64px 0 24px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 42px;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}

.hero h1 em {
  font-style: italic;
  color: var(--violet-deep);
}

.hero .intro {
  font-size: 19px;
  color: var(--ink-soft);
  margin: 0;
}

.kicker {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--violet);
  margin: 0 0 20px;
}

.kicker::before { content: "~ "; }
.kicker::after  { content: " ~"; }

/* portrait: sketch construction-line frame */
.portrait {
  position: relative;
  justify-self: end;
}

.portrait img {
  display: block;
  width: 200px;
  height: auto;
  mix-blend-mode: multiply;   /* lets the paper grain breathe through the white */
}

.portrait::before,
.portrait::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

/* extended construction lines, like the drawing */
.portrait::before {
  inset: -14px auto auto -14px;
  width: 46px; height: 46px;
  border-top: 1px solid var(--line-violet);
  border-left: 1px solid var(--line-violet);
}

.portrait::after {
  inset: auto -14px -14px auto;
  width: 46px; height: 46px;
  border-bottom: 1px solid var(--line-violet);
  border-right: 1px solid var(--line-violet);
}

/* ---------- essay index ---------- */

.index-head {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 56px 0 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.index-head::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--line);
}

ol.essays {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}

ol.essays li {
  border-bottom: 1px solid var(--line);
}

ol.essays a {
  display: grid;
  grid-template-columns: 48px 76px 1fr auto;
  gap: 20px;
  align-items: baseline;
  padding: 22px 8px;
  text-decoration: none;
  color: inherit;
  transition: background-color 120ms ease;
}

ol.essays a:hover { background: var(--violet-wash); }

/* sketch vignette: a cropped window into the ink drawing */
.essay-thumb {
  align-self: center;
  width: 76px;
  height: 76px;
  overflow: hidden;
  position: relative;
}

.essay-thumb::after {
  /* construction-line corner, echoing the portrait frame */
  content: "";
  position: absolute;
  right: 0; bottom: 0;
  width: 18px; height: 18px;
  border-right: 1px solid var(--line-violet);
  border-bottom: 1px solid var(--line-violet);
  pointer-events: none;
}

.essay-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  mix-blend-mode: multiply;              /* sit on the paper, not on white */
  filter: hue-rotate(35deg) saturate(0.8); /* shift the blue ink toward the site violet */
}

/* each essay shows a different region of the drawing */
.thumb-tower  img { transform: scale(2.6); transform-origin: 76% 60%; }
.thumb-keys   img { transform: scale(2.6); transform-origin: 40% 97%; }
.thumb-screen img { transform: scale(1.7); transform-origin: 26% 34%; }

.thumb-record {
  border: 1px solid var(--line-violet);
  background: var(--paper-deep);
}

.thumb-record img {
  filter: none;
  transform: scale(1.7);
  transform-origin: 51% 54%;
}

.thumb-play {
  border: 1px solid var(--line-violet);
  background: var(--paper-deep);
}

.thumb-play img {
  filter: none;
  transform: scale(1.5);
  transform-origin: 50% 42%;
}

.essay-no {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--violet);
}

.essay-title {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
  line-height: 1.3;
}

.essay-title small {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
  margin-top: 4px;
}

.essay-date {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.index-foot {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  margin: 18px 0 0;
}

/* ---------- essay page ---------- */

article.essay { padding: 72px 0 8px; }

.essay-meta {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--violet);
  margin: 0 0 22px;
}

.essay-meta .sep { color: var(--line); padding: 0 10px; }

article.essay h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 40px;
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.deck {
  font-size: 21px;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 44px;
}

article.essay h2 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 52px 0 16px;
}

article.essay h2::before { content: "§ "; color: var(--violet); }

article.essay p { margin: 0 0 1.35em; }

.essay-figure {
  margin: 0 -34px 42px;
  padding: 16px 16px 12px;
  border-top: 1px solid var(--line-violet);
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

.essay-figure img {
  display: block;
  width: 100%;
  mix-blend-mode: multiply;
}

.essay-figure figcaption {
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.fractal-tool {
  margin: 2.2em 0 2.8em;
  padding: 14px;
  border: 1px solid var(--line-violet);
  background: var(--paper-deep);
}

.fractal-canvas {
  display: block;
  width: 100%;
  height: 290px;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(106, 88, 201, 0.16) 50%, transparent 50.5%),
    linear-gradient(transparent 49.5%, rgba(106, 88, 201, 0.16) 50%, transparent 50.5%),
    var(--paper);
  background-size: 26px 26px;
}

.fractal-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 14px;
}

.fractal-control {
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}

.fractal-control label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fractal-control output { color: var(--violet-deep); }

.fractal-control input {
  width: 100%;
  accent-color: var(--violet);
}

.tldr {
  margin: 0 0 46px;
  padding: 18px 20px 2px;
  border-top: 1px solid var(--violet);
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

.tldr h2 {
  margin: 0 0 10px;
  font-size: 12px;
}

.tldr h2::before { content: "// "; }

article.essay a {
  color: var(--violet-deep);
  text-decoration: underline;
  text-decoration-color: var(--line-violet);
  text-underline-offset: 3px;
}

article.essay blockquote {
  margin: 2em 0;
  padding: 4px 0 4px 26px;
  border-left: 2px solid var(--violet);
  font-style: italic;
  font-size: 21px;
  color: var(--ink-soft);
}

article.essay code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
}

article.essay pre {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-left: 2px solid var(--violet);
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.55;
}

article.essay pre code { background: none; border: 0; padding: 0; }

.drop::first-letter {
  font-size: 3.1em;
  font-weight: 500;
  float: left;
  line-height: 0.85;
  padding: 4px 10px 0 0;
  color: var(--violet-deep);
}

/* asterism divider, typewriter style */
.asterism {
  border: 0;
  margin: 2.6em 0;
  text-align: center;
}

.asterism::after {
  content: "*  *  *";
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.3em;
  color: var(--violet);
}

/* signature line at essay end */
.colophon {
  margin-top: 56px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
}

.colophon .sig {
  color: var(--violet-deep);
  font-style: italic;
  font-family: var(--serif);
  font-size: 17px;
}

/* back link */
.crumb {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-decoration: none;
  margin: 40px 0 0;
}

.crumb:hover { color: var(--violet-deep); }

/* ---------- about ---------- */

.about { padding: 72px 0 8px; }

.about-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 48px;
  align-items: start;
}

.about h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 36px;
  margin: 0 0 20px;
}

.about p { margin: 0 0 1.3em; color: var(--ink); }

.facts {
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 2.1;
  color: var(--ink-soft);
}

.facts b {
  font-weight: 400;
  color: var(--ink-faint);
  display: inline-block;
  width: 92px;
}

.facts a { color: var(--violet-deep); text-decoration: none; }
.facts a:hover { text-decoration: underline; }

/* ---------- footer ---------- */

footer.foot {
  margin-top: 96px;
  padding: 28px 0 44px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

footer.foot a { color: var(--ink-soft); text-decoration: none; }
footer.foot a:hover { color: var(--violet-deep); }

/* ---------- small screens ---------- */

/* one breakpoint: full mobile design below, full desktop design above */
@media (max-width: 760px) {
  body { font-size: 17px; line-height: 1.6; }
  .sheet { padding: 0 20px; }

  .hero { grid-template-columns: 1fr; }
  .portrait { justify-self: start; order: -1; }
  .about-grid { grid-template-columns: 1fr; gap: 28px; }
  .about-grid .portrait img { width: 150px; }

  header.masthead { padding-top: 32px; }
  .masthead-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .wordmark { letter-spacing: 0.26em; }
  .rule { margin-top: 14px; }

  .hero { padding-top: 36px; }
  .hero h1 { font-size: 29px; }
  .hero .intro { font-size: 17px; }
  .kicker { font-size: 11px; letter-spacing: 0.18em; margin-bottom: 16px; }
  .portrait img { width: 128px; }
  .portrait::before, .portrait::after { width: 32px; height: 32px; }
  .portrait::before { inset: -10px auto auto -10px; }
  .portrait::after  { inset: auto -10px -10px auto; }

  /* index: number + date on a top line, thumb + title below */
  .index-head { margin-top: 40px; }
  ol.essays a {
    grid-template-columns: 64px 1fr;
    gap: 10px 16px;
    padding: 18px 4px;
  }
  .essay-no   { grid-row: 1; grid-column: 1; font-size: 13px; }
  .essay-date { grid-row: 1; grid-column: 2; justify-self: end; font-size: 12px; }
  .essay-thumb {
    grid-row: 2;
    grid-column: 1;
    align-self: start;
    width: 64px;
    height: 64px;
  }
  .essay-thumb::after { width: 14px; height: 14px; }
  .essay-figure { margin: 0 0 32px; padding: 10px 10px 8px; }
  .essay-figure figcaption { font-size: 11px; }
  .fractal-tool { padding: 10px; }
  .fractal-canvas { height: 220px; }
  .fractal-controls { gap: 10px; }
  .fractal-control { font-size: 10px; }
  .essay-title {
    grid-row: 2;
    grid-column: 2;
    font-size: 20px;
  }
  .essay-title small { font-size: 15px; }

  article.essay { padding-top: 40px; }
  article.essay h1 { font-size: 28px; }
  .deck { font-size: 18px; margin-bottom: 32px; }
  .essay-meta { font-size: 11px; letter-spacing: 0.12em; }
  article.essay h2 { font-size: 13px; margin-top: 40px; }
  article.essay blockquote {
    font-size: 18px;
    padding-left: 18px;
    margin: 1.7em 0;
  }
  article.essay pre { padding: 14px 16px; font-size: 13px; }
  .drop::first-letter { font-size: 2.7em; padding-right: 8px; }
  .colophon { margin-top: 44px; }

  .about { padding-top: 40px; }
  .about h1 { font-size: 28px; }
  .facts b { display: block; width: auto; line-height: 1.2; margin-top: 10px; }
  .facts li { line-height: 1.5; }

  footer.foot {
    margin-top: 64px;
    flex-direction: column;
    gap: 6px;
  }

  /* ---- home splash: full-bleed portrait with the masthead
         floating over it in a translucent paper band ---- */

  body.home { position: relative; }

  body.home header.masthead {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 5;
    padding: 0;
  }

  body.home .rule { display: none; }

  body.home .masthead-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px 11px;
    background: rgba(250, 248, 242, 0.78);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(217, 212, 200, 0.55);
  }

  body.home .wordmark { font-size: 13px; letter-spacing: 0.22em; }
  body.home nav.compass { gap: 16px; }

  body.home .hero { padding-top: 0; gap: 28px; }

  body.home .portrait {
    order: -1;
    justify-self: stretch;
    margin: 0 -20px;          /* escape the sheet padding: full-bleed */
  }

  body.home .portrait img {
    width: 100%;
    height: min(88svh, 135vw); /* fill most of the first screen */
    object-fit: cover;
    object-position: 50% 14%;
  }

  /* the construction-line corners don't suit a full-bleed image */
  body.home .portrait::before,
  body.home .portrait::after { display: none; }
}

@media print {
  body { background: #fff; }
  nav.compass, footer.foot, .crumb { display: none; }
}
