/* The Logbook: one column, a text serif, one accent kept for links. */

:root {
  --paper: #f7f6f2;
  --ink: #1c1b1f;
  --dim: #66626d;
  --rule: #e2dfd8;
  --accent: #5b3fc4;

  --small: 15px;
  --body: 19px;
  --large: 32px;

  /* About 65 to 70 characters of Newsreader at the body size. */
  --column: 31rem;
  --wide: 58rem;
  --margin: max(1.5rem, calc((100vw - var(--wide)) / 2));
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161519;
    --ink: #ece9f1;
    --dim: #9d99a7;
    --rule: #2c2a31;
    --accent: #b9a4ff;
  }
}

/* One text face and one for labels. Newsreader is loaded at 400 and 500 only, so nothing asks for 600. */
:root {
  --serif: 'Newsreader', Georgia, serif;
  --meta: 'IBM Plex Mono', ui-monospace, monospace;
  --meta-size: 13.5px;
}

/* Headings balance their lines; paragraphs avoid a lone last word. */
h1, h2, .entry-title, .pull { text-wrap: balance; }
p, li, dd, figcaption { text-wrap: pretty; }

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "onum";
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: text-decoration-color 0.15s ease;
}

a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: var(--margin);
  top: -3rem;
  font-family: var(--meta);
  font-size: var(--meta-size);
}

.skip:focus { top: 1rem; }

/* The page sits a little left of centre, like a notebook. */
.page {
  max-width: calc(var(--column) + 2 * var(--margin));
  padding: 0 var(--margin) 6rem;
}

/* ---------- Home ---------- */

.intro { padding: 7rem 0 1rem; }

.mark {
  display: block;
  width: 56px;
  height: auto;
  margin-bottom: 1.5rem;
}

.mark path { fill: var(--ink); }

.name {
  font-size: var(--body);
  font-weight: 500;
  line-height: 1.6;
}

.lede { max-width: 30em; margin-top: 0.4rem; color: var(--dim); }

.block { margin-top: 3.5rem; }

.label {
  margin-bottom: 0.75rem;
  font-family: var(--meta);
  font-size: var(--meta-size);
  font-weight: 400;
  color: var(--dim);
}

.plain { list-style: none; }
.plain li + li { margin-top: 0.35rem; }

.block p + p { margin-top: 0.75rem; }

.entries { list-style: none; }

.entry {
  position: relative;
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
}

/* On wide screens each entry carries its work in the margin, on the company's colour. */
.entry-thumb {
  display: none;
}

@media (min-width: 1100px) {
  .entry { min-height: calc(15rem * 9 / 16 + 2.2rem); }

  .entry-thumb {
    display: block;
    position: absolute;
    top: 1.1rem;
    left: calc(100% + 3rem);
    width: 15rem;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 6px;
    background: var(--stage);
  }

  .entry-thumb img {
    position: absolute;
    left: 9%;
    top: 12%;
    width: 82%;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .entry:hover .entry-thumb img { transform: translateY(-6px); }
}

@media (prefers-reduced-motion: reduce) {
  .entry-thumb img { transition: none; }
}

.entry:last-child { border-bottom: 1px solid var(--rule); }

.entry-title {
  font-weight: 500;
}

.entry-deck { margin-top: 0.2rem; }

.meta,
.facts dt {
  font-family: var(--meta);
  font-size: var(--meta-size);
  color: var(--dim);
}

.entry .meta { margin-top: 0.35rem; }

.sign-off { margin-top: 4.5rem; }

/* ---------- Case study ---------- */

.essay { padding-top: 4rem; }

.back {
  font-family: var(--meta);
  font-size: var(--meta-size);
}

.essay-head { margin: 4rem 0 3rem; }

.essay-title {
  font-size: var(--large);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  max-width: 18em;
}

.deck {
  margin-top: 1rem;
  font-style: italic;
  color: var(--ink);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2.5rem;
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.facts dd { font-size: var(--meta-size); font-family: var(--meta); }

.prose h2 {
  margin: 3.5rem 0 0.75rem;
  font-size: var(--body);
  font-weight: 500;
  line-height: 1.4;
}

.prose p,
.prose ul { margin-bottom: 1.1rem; }

.prose ul { padding-left: 1.2rem; }

.prose strong { font-weight: 500; }

.pull {
  margin: 2.75rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--accent);
  /* Smaller than the title, so the title stays the loudest thing on the page. */
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* Figures run wider than the column, into the right margin, on a plate in the company's colour. */
.fig {
  width: min(var(--wide), calc(100vw - 2 * var(--margin)));
  margin: 2.5rem 0 3rem;
}

.plate {
  padding: clamp(1rem, 4vw, 2.75rem);
  border-radius: 6px;
  background: var(--stage);
}

.plate img {
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* Never wider than the plate, on any screen. */
.fig-narrow .plate img { max-width: min(30rem, 100%); }
.fig-phone .plate img { max-width: min(19rem, 100%); border-radius: 20px; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
}

.pair-item { display: flex; flex-direction: column; gap: 0.6rem; }

.pair-label {
  font-family: var(--meta);
  font-size: var(--meta-size);
  color: var(--stage-ink);
}

.fig figcaption {
  max-width: var(--column);
  margin-top: 0.75rem;
  font-size: var(--small);
  line-height: 1.5;
  color: var(--dim);
}

/* Only the figure number is a label; the caption itself is text. */
.fig-n { font-family: var(--meta); font-size: var(--meta-size); color: var(--ink); margin-right: 0.5em; }

.fig-cover { margin-top: 0; }

.essay-foot {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

@media (max-width: 640px) {
  :root { --body: 18px; --large: 27px; }
  .intro { padding-top: 4rem; }
  .pair { grid-template-columns: 1fr !important; }
}

/* ---------- Zoom ---------- */

.zoomable { display: block; cursor: zoom-in; }

.zoom {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh; /* the visible area, so Safari's toolbar doesn't cover the image */
  max-height: none;
  margin: 0;
  padding: 3rem 2rem 2rem;
  border: 0;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  color: var(--ink);
}

.zoom::backdrop { background: transparent; }

.zoom img {
  max-width: 100%;
  max-height: calc(100vh - 5rem);
  max-height: calc(100dvh - 5rem);
  margin: 0 auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  cursor: zoom-out;
}

.zoom-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  padding: 0.25rem 0.5rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-family: var(--meta);
  font-size: var(--meta-size);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

/* ---------- At a glance ---------- */

.glance {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.75rem;
  padding: 1.25rem 1.4rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.glance div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; }

.glance dt {
  padding-top: 0.2rem;
  font-family: var(--meta);
  font-size: var(--meta-size);
  color: var(--dim);
}

.glance dd { font-size: calc(var(--body) * 0.92); line-height: 1.5; }

@media (max-width: 640px) {
  .glance div { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* ---------- Password ---------- */

.unlock {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.unlock > p { margin-bottom: 1.25rem; }

.unlock label {
  display: block;
  margin-bottom: 0.4rem;
  font-family: var(--meta);
  font-size: var(--meta-size);
  color: var(--dim);
}

.unlock-row { display: flex; gap: 0.6rem; }

.unlock input,
.unlock button {
  min-height: 2.75rem;
  border-radius: 6px;
  font: inherit;
  font-size: var(--small);
}

.unlock input {
  flex: 1;
  min-width: 0;
  padding: 0 0.85rem;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  color: var(--ink);
}

.unlock input[aria-invalid='true'] { border-color: #d14b4b; }

.unlock button {
  padding: 0 1.1rem;
  border: 0;
  background: var(--accent);
  color: var(--paper);
  font-weight: 500;
  cursor: pointer;
}

.unlock-error {
  margin-top: 0.6rem;
  font-size: var(--small);
  color: #d14b4b;
}

.lock-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.6rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
}

.lock-tag svg { width: 0.75em; height: 0.75em; fill: currentColor; }

/* A locked entry keeps its plate in the margin, with a lock in place of the screen. */
.entry-thumb-locked svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.6rem;
  height: 1.6rem;
  fill: var(--stage-ink);
  opacity: 0.55;
}
