/* ==========================================================================
   about / blog / contact pages

   Sections
     1. Fonts & design tokens
     2. Base (reset, page frame, nav, footer)
     3. Links
     4. Typography & content blocks
     5. Blog (post list, single post)
     6. Code blocks & syntax colours
     7. Small screens
   ========================================================================== */


/* ==========================================================================
   1. Fonts & design tokens
   ========================================================================== */

/* Arexa (text): put arexa.otf in portfolio/fonts/ */
@font-face {
  font-family: "Arexa";
  src: url("../fonts/arexa.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* page: sand #c0c08a   text: black #000000
   code: black #000000, orange #fd4200, dark green #0d3b27 */
:root {
  --bg: #c0c08a;
  --fg: #000000;
  --fg-dim: #fd4200;
  --code-bg: #000000;
  --code-fg: #fd4200;
  --green: #0d3b27;
  --green-hi: #2f9a63;
  --blue: #0747af;

  --font: "Arexa", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "Fira Code", "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --panel-border: 3px solid var(--fg);
}


/* ==========================================================================
   2. Base: reset, page frame, nav, footer
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
}

body {
  min-height: 100dvh;
  padding: 16px;
  padding-top: max(clamp(16px, 4vw, 48px), env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: clamp(19px, .8vw + 13px, 25px);
  line-height: 1.6;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

/* The boxed panel that holds nav, content and footer. */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 800px);
  max-width: 800px;
  margin: 0 auto;
  border: var(--panel-border);
  box-shadow: 8px 8px 0 var(--fg);
}

main {
  flex: 1;
  padding: clamp(18px, 4vw, 36px);
  text-align: left;
}

/* ---------- top nav ---------- */
nav.top {
  display: flex;
  flex-wrap: wrap;
  border-bottom: var(--panel-border);
}

nav.top a {
  flex: 1 1 0;
  min-width: 5.2em;
  padding: .45em .3em;
  text-align: center;
  text-decoration: none;
  border-right: var(--panel-border);
}

nav.top a:last-child {
  border-right: 0;
}

/* Hover / focus is handled by the shared link rule; this keeps the
   current page highlighted all the time. */
nav.top a[aria-current="page"] {
  background: var(--fg);
  color: var(--bg);
}

/* ---------- footer ---------- */
footer {
  width: 100%;
  margin: 2rem 0 0;
  padding: 1.2rem 0;
  border-top: 3px solid currentColor;
  color: var(--fg-dim);
  font-size: 1rem;
  letter-spacing: .08em;
  text-align: center;
  opacity: .8;
}

footer a {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  transition: opacity .2s ease;
}

footer a:hover {
  opacity: .6;
}


/* ==========================================================================
   3. Links

   One "highlighted" look (black background, sand text) shared by:
     - mouse hover and keyboard focus
     - touch press on blog links: the native :active state, plus a
       .pressed class that js/blog.js adds so the flash stays visible
       until the post opens.
   ========================================================================== */

a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover,
a:focus-visible,
.posts a:active,
.posts a.pressed {
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  outline: none;
}


/* ==========================================================================
   4. Typography & content blocks
   ========================================================================== */

h1 {
  margin-bottom: .7em;
  font-size: 1.9em;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: .02em;
  text-align: left;
}

h2 {
  margin: 2em 0 .5em;
  font-size: 1.25em;
  font-weight: 400;
}

p+p,
p+ul,
ul+p {
  margin-top: 1em;
  list-style: none;
}

/* "> item" lists; add class="dash" to a <ul> for "- item" instead. */
ul li::before {
  content: "> ";
}

main ul.dash {
  list-style: none;
}

main ul.dash li::before {
  content: "- ";
}

.lead {
  margin-bottom: 1.6em;
  text-align: left;
}

.meta {
  color: var(--fg-dim);
  font-size: .88em;
  text-align: left;
}

/* ascii art */
pre.art {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 1.8em;
  font-family: var(--mono);
  font-size: .85em;
  line-height: 1.2;
  white-space: pre;
  overflow: visible;
}

/* key / value list (about + contact) */
.kv {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: start;
  gap: .25em 2em;
  margin: 1.2em 0;
  text-align: left;
}

.kv dt {
  color: var(--fg-dim);
}

.kv dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* placeholders */
.ph {
  padding: 0 .25em;
  background: rgba(7, 71, 175, .12);
  outline: 1px dashed rgba(7, 71, 175, .55);
  outline-offset: 1px;
  font-style: normal;
}


/* ==========================================================================
   5. Blog
   ========================================================================== */

/* Blog text is plain black; the orange meta colour is only for other pages. */
.index,
.post,
.index .meta,
.post .meta {
  color: var(--fg);
}

/* ---------- post list ---------- */
.posts {
  width: fit-content;
  max-width: 100%;
  margin-top: 1.4em;
  list-style: none;
}

.posts li+li {
  margin-top: .3em;
}

/* Flex row: the "> " marker stays beside the link even when a long title
   wraps, instead of being left alone on the line above it. */
.posts li {
  display: flex;
  align-items: baseline;
  gap: .25em;
}

.posts li::before {
  flex: none;
}

.posts a {
  min-width: 0;
}

.posts a {
  display: inline-flex;
  align-items: baseline;
  gap: .5em;
  margin: 0 -.4em;
  padding: .05em .4em;
  text-align: left;
  text-decoration: none;
  transition:
    color .2s ease,
    text-decoration-color .2s ease,
    transform .15s ease;
}

.posts time {
  color: var(--fg);
  white-space: nowrap;
}

.posts a:hover time,
.posts a:focus-visible time,
.posts a:active time,
.posts a.pressed time {
  color: var(--bg);
}

/* ---------- single post ----------
   Posts are <article class="post" id="..."> sections. A post is shown
   when the URL hash matches its id (:target), and the list is hidden. */
.post {
  display: none;
  text-align: left;
}

.post:target {
  display: block;
}

body:has(.post:target) .index {
  display: none;
}

.post .meta {
  margin: -.3em 0 1.6em;
}

.post p {
  margin-top: 1em;
}

.post .back {
  margin-top: 2.4em;
}


/* ---------- sub-headings inside long posts ---------- */
.post h3 {
  margin: 1.8em 0 .4em;
  padding-left: .6em;
  border-left: 4px solid var(--fg-dim);
  font-size: 1.1em;
  font-weight: 400;
  line-height: 1.3;
}

.post h4 {
  margin: 1.4em 0 .3em;
  color: var(--blue);
  font-size: 1em;
  font-weight: 400;
  letter-spacing: .02em;
}

.post h4::before {
  content: "# ";
  color: var(--fg-dim);
}

/* ---------- numbered lists: same look as the "> " lists ---------- */
.post ol {
  margin-top: 1em;
  list-style: none;
  counter-reset: step;
}

.post ol li {
  counter-increment: step;
}

.post ol li::before {
  content: counter(step) ". ";
  color: var(--fg-dim);
}

.post ol[start="3"] { counter-reset: step 2; }
.post ol[start="4"] { counter-reset: step 3; }

/* ---------- callout (proposition, example) ---------- */
.post .note {
  margin: 1.2em 0;
  padding: .2em 1em .9em;
  background: rgba(7, 71, 175, .1);
  border-left: 4px solid var(--blue);
}

.post .note h3 {
  margin-top: .8em;
  padding-left: 0;
  border-left: 0;
  color: var(--blue);
}

/* ---------- key results: block version of the .ph look ---------- */
.post .math-box {
  display: block;
  margin: 1.2em 0;
  padding: .4em .8em;
  overflow-x: auto;
}

.post .math-box .katex-display {
  margin: .5em 0;
}

/* ordinary display maths: scroll instead of overflowing the panel */
.post .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---------- bullets: only the "> " marker, no round dot ---------- */
.post ul {
  list-style: none;
}

/* ---------- maths inside .ph: keep it tight and the box a clean rectangle ---------- */
.post span.ph:has(.katex) {
  display: inline-block;
  margin: 0 .12em;
  padding: 0 .3em;
  line-height: 1.25;
  vertical-align: baseline;
  outline-offset: 0;
}

.post .ph .katex {
  font-size: 1em;
}

.post .math-box .katex {
  font-size: 1.1em;
}

/* ---------- images ---------- */
.post figure {
  margin: 1.6em 0;
}

.post figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 3px solid var(--fg);
}

.post figcaption {
  margin-top: .5em;
  color: var(--fg-dim);
  font-size: .8em;
}

.post figcaption::before {
  content: "fig. ";
}

/* source links */
.post .reference {
  margin-top: .4em;
  color: var(--fg-dim);
  font-size: .8em;
}

.post .reference::before {
  content: "src ";
  color: var(--fg-dim);
}


/* ==========================================================================
   6. Code blocks & syntax colours
   ========================================================================== */

/* inline code */
code {
  padding: .05em .4em;
  border-radius: 3px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--mono);
  font-size: .92em;
}

/* block wrapper */
.code {
  width: 100%;
  margin: 1.6em 0;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--green);
  border-radius: 6px;
  box-shadow: 4px 4px 0 var(--green);
}

.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3em .5em .3em .9em;
  background: var(--green);
  color: var(--green-hi);
  font-family: var(--mono);
  font-size: max(11px, .55em);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.code-head button {
  padding: 0 .7em;
  background: transparent;
  color: var(--green-hi);
  border: 1px solid var(--green-hi);
  border-radius: 3px;
  font: inherit;
  letter-spacing: .06em;
  text-transform: lowercase;
  cursor: pointer;
}

.code-head button:hover,
.code-head button:focus-visible {
  background: var(--green-hi);
  color: #000;
  outline: none;
}

/* Long lines scroll sideways inside the block. */
.code pre {
  margin: 0;
  padding: 1em 1.1em;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  color: var(--code-fg);
  font-family: var(--mono);
  font-size: max(13px, .6em);
  line-height: 1.6;
  tab-size: 4;
  scrollbar-width: thin;
  scrollbar-color: var(--green-hi) var(--code-bg);
}

.code pre::-webkit-scrollbar {
  height: 10px;
}

.code pre::-webkit-scrollbar-track {
  background: var(--code-bg);
}

.code pre::-webkit-scrollbar-thumb {
  background: var(--green);
  border: 1px solid var(--green-hi);
  border-radius: 6px;
}

.code pre code {
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
}

/* token colours: orange-red + dark green on black */
.t-k    { color: #fd4200; font-weight: 700; }   /* keywords */
.t-s    { color: var(--green-hi); }             /* strings */
.t-c    { color: #1f6b45; font-style: italic; } /* comments */
.t-n    { color: #ff7a45; }                     /* numbers (lighter orange-red) */
.t-f    { color: #ffd2bf; }                     /* function calls */
.t-t    { color: #ff7a45; }                     /* types / classes */
.t-v    { color: var(--green-hi); }             /* $vars, @decorators */
.t-key  { color: #ff7a45; }
.t-tag  { color: #fd4200; }
.t-attr { color: var(--green-hi); }
.t-fl   { color: var(--green-hi); }


/* ==========================================================================
   7. Small screens
   ========================================================================== */

@media (max-width: 600px) {
  /* keep all four nav links on one row */
  nav.top a {
    min-width: 0;
    padding: .45em .1em;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .kv dd {
    margin-bottom: .8em;
  }

  .posts a {
    padding: .35em .4em;
  }

  .code {
    box-shadow: 3px 3px 0 var(--green);
  }
}

/* ---------- Selected Work logos ---------- */
.works {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 1.2rem 0;
}

.works a {
  display: block;
  line-height: 0;
}

.works img {
  display: block;
  height: 100px;
  width: auto;
  max-width: 100%;
  border: 2px solid #000000;
}

/* phones: stack them, same width, edges lined up */
@media (max-width: 600px) {
  .works {
    flex-direction: column;
  }

  .works a {
    width: min(100%, 320px);
  }

  .works img {
    width: 100%;
    height: auto;
  }
}
