/* Hakone: a Swiss page printed in two inks. Prussian blue for the map and rules,
   vermilion used sparingly, Helvetica throughout. */

:root {
  --paper: #fbf8f1;
  --ink: #141a26;
  --grey: #5a5f6b;
  --rule: #dcd8ce;
  --red: #c8402f;
  --prussian-deep: #142c4f;
  --prussian: #1c3f6e;
  --map: url("/img/hakone.jpg");
  --display: "Helvetica Neue", Helvetica, Arial, "Noto Sans JP", sans-serif;
  --body: "Helvetica Neue", Helvetica, Arial, "Noto Sans JP", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --code-bg: #1b2740;
  --syn-fg: #ece3cf;
  --syn-kw: #f39a74;
  --syn-type: #9cc2e6;
  --syn-str: #bcd08f;
  --syn-com: #8f98b0;
  --syn-num: #f2c45a;
  --syn-fn: #f3e2bd;
  --syn-op: #c9bfa9;
  --syn-punct: #9d968a;
  --syn-ln: #5d6680;

  font-size: 17px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  background: var(--paper);
}

/* a strip of the map across the top of every page except home, where it is the hero */
body::before {
  content: "";
  display: block;
  width: 100vw;
  height: 56px;
  margin-left: calc(50% - 50vw);
  background: var(--map) 58% 62% / cover;
}

/* the strip is full bleed, so wide or dense screens get the big map */
@media (min-width: 2400px), (min-width: 1200px) and (min-resolution: 2dppx) {
  :root {
    --map: url("/img/hakone-5120.jpg");
  }
}

body.page-home::before {
  display: none;
}

body {
  margin: 0 auto;
  max-width: 1080px;
  padding: 0 2rem 2rem;
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.65;
  counter-reset: section;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--red);
}

::selection {
  background: var(--red);
  color: #fff;
}

/* header */

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem 0;
  margin-bottom: 4rem;
  border-bottom: 1px solid var(--ink);
  font-family: var(--display);
}

.site-title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

/* home */

.map {
  position: relative;
  margin: 0 0 4.5rem;
}

.map img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2400 / 706;
  object-fit: cover;
  object-position: 58.5% 62%;
}

/* object-position uses the same percentages, so the pin stays on the peak at any width */
.pin {
  position: absolute;
  left: 58.5%;
  top: 62%;
  width: clamp(0.6rem, 1.4vw, 1.1rem);
  height: clamp(0.6rem, 1.4vw, 1.1rem);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--red);
}

.map figcaption {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding-top: 0.6rem;
  border-top: 1px solid var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map figcaption span {
  color: var(--red);
  letter-spacing: 0.15em;
}

/* the archive: years in the left column, posts on the same line as the post body column */
.year {
  display: grid;
  grid-template-columns: 25% 1fr;
  align-items: start;
  padding: 1rem 0 2.5rem;
  border-top: 1px solid var(--ink);
}

.year h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.year ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.year li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.15rem 0 0.9rem;
}

.year a {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.year a:hover {
  color: var(--prussian);
  text-decoration: underline;
  text-decoration-color: var(--red);
}

.year time {
  flex-shrink: 0;
  color: var(--grey);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* section lists (e.g. /posts/) keep the simple list */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.post-list a {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}

.date {
  color: var(--grey);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* post */

article,
main > h1 {
  font-family: var(--body);
}

article h1,
main > h1 {
  margin: 0 0 1.5rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.025em;
  max-width: 16ch;
}

article > .date {
  display: block;
  padding-top: 0.75rem;
  margin-bottom: 3.5rem;
  border-top: 4px solid var(--ink);
  color: var(--red);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.post-body {
  max-width: 680px;
  margin-left: auto;
  margin-right: 8%;
}

.post-body img,
.post-body video {
  display: block;
  max-width: 100%;
  height: auto;
}

.post-body figure {
  margin: 1.5rem 0;
}

.post-body figcaption {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--grey);
}

.post-body figcaption p {
  margin: 0.4rem 0 0;
}

.post-body p,
.post-body ul,
.post-body ol {
  margin: 0 0 1.2em;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--display);
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.post-body h2 {
  position: relative;
  margin: 3.5rem 0 1rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--prussian);
  font-size: 1.9rem;
  font-weight: 800;
  counter-increment: section;
}

/* section numbers hang in the left margin on wide screens */
.post-body h2::before {
  content: counter(section, decimal-leading-zero);
  position: absolute;
  right: calc(100% + 2rem);
  top: 0.65rem;
  color: var(--red);
  font-size: 1.9rem;
}

.post-body h3 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.3rem;
  font-weight: 800;
}

.post-body h4 {
  margin: 2rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.post-body strong {
  font-weight: 600;
}

.post-body ul {
  list-style: none;
  padding-left: 1.5rem;
}

.post-body ul li {
  position: relative;
  margin-bottom: 0.4em;
}

.post-body ul li::before {
  content: "";
  position: absolute;
  left: -1.4rem;
  top: 0.62em;
  width: 0.55rem;
  height: 0.55rem;
  background: var(--red);
}

.post-body ol {
  padding-left: 1.5rem;
}

.post-body ol li::marker {
  color: var(--red);
  font-weight: 800;
}

.post-body blockquote {
  margin: 2.5rem 0;
  padding: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--prussian);
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--ink);
  margin: 3rem 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
}

.post-body th {
  border-top: 4px solid var(--prussian);
  border-bottom: 1px solid var(--ink);
  text-align: left;
  font-weight: 800;
}

.post-body th,
.post-body td {
  padding: 0.5rem 0.75rem 0.5rem 0;
}

.post-body td {
  border-bottom: 1px solid var(--rule);
}

/* code */

code {
  font-family: var(--mono);
  font-variant-ligatures: none;
  font-size: 0.88em;
  background: rgba(28, 63, 110, 0.08);
  padding: 0.1em 0.35em;
}

.code-block {
  margin: 2rem 0;
}

.code-block .highlight pre {
  margin: 0;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  border-left: 6px solid var(--red);
}

.code-block .highlight code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* footer */

footer {
  margin-top: 6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.85rem;
}

footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .post-body {
    margin: 0;
  }

  .post-body h2::before {
    position: static;
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1rem;
  }
}

@media (max-width: 600px) {
  body {
    padding: 0 1rem 1.5rem;
  }

  header {
    margin-bottom: 2.5rem;
  }

  .year {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* syntax highlighting, colours come from the --syn-* variables above */

.chroma { color: var(--syn-fg); background-color: var(--code-bg); -webkit-text-size-adjust: none; }
.chroma .lnlinks { outline: none; text-decoration: none; color: inherit; }
.chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
.chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
.chroma .hl { background-color: rgba(127, 127, 127, 0.15); }
.chroma .lnt,
.chroma .ln { white-space: pre; user-select: none; margin-right: 0.75rem; color: var(--syn-ln); }
.chroma .line { display: flex; }

.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr { color: var(--syn-kw); font-weight: 700; }
.chroma .kt, .chroma .nc, .chroma .na, .chroma .nt { color: var(--syn-type); }
.chroma .s, .chroma .s1, .chroma .s2, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .sd,
.chroma .sh, .chroma .si, .chroma .sx, .chroma .sr, .chroma .se, .chroma .l, .chroma .ld { color: var(--syn-str); }
.chroma .ss { color: var(--syn-type); }
.chroma .c, .chroma .c1, .chroma .cm, .chroma .cp, .chroma .cpf, .chroma .cs, .chroma .ch { color: var(--syn-com); font-style: italic; }
.chroma .m, .chroma .mi, .chroma .mf, .chroma .mh, .chroma .mo, .chroma .mb, .chroma .il { color: var(--syn-num); }
.chroma .nf, .chroma .fm, .chroma .nb, .chroma .bp, .chroma .nn { color: var(--syn-fn); }
.chroma .n, .chroma .nv, .chroma .vc, .chroma .vg, .chroma .vi { color: var(--syn-fg); }
.chroma .o, .chroma .ow { color: var(--syn-op); }
.chroma .p { color: var(--syn-punct); }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: 700; }
.chroma .gd { color: #c62828; }
.chroma .gi { color: #2e7d32; }
.chroma .gl { text-decoration: underline; }
