/* Jake Morgan - CV
   The CV is a query result: one row, one person. The career timeline is the
   picture; everything else is set quietly so it reads like a good document. */

@font-face {
  font-family: "Schibsted";
  src: url("../fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --paper: #F6F7F5;     /* cool paper, not cream */
  --ink: #16202B;       /* slate ink */
  --slate: #5B6772;     /* secondary text */
  --rule: #D7DCD8;
  --marker: #FFD84D;    /* daffodil highlighter: the selected row */
  --green: #0F6B4F;     /* Welsh green: links and the current roles */
  --bar: var(--ink);
  --marker-ink: #16202B;

  --pad: clamp(1.1rem, 5vw, 4rem);
  --label: 12rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F151C;
    --ink: #E5E9EC;
    --slate: #94A0AB;
    --rule: #26313C;
    --marker: #E8B923;
    --green: #5CC79E;
    --bar: #C8D0D7;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Schibsted", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
::selection { background: var(--marker); color: var(--marker-ink); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 9; }

.page { max-width: 76rem; margin: 0 auto; padding: 0 var(--pad); }

/* Intro */
.intro { padding: clamp(2.5rem, 8vw, 6rem) 0 clamp(2.5rem, 6vw, 4rem); }
.query {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(.8rem, 1.6vw, .95rem);
  color: var(--slate);
  min-height: 1.6em;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  overflow-wrap: anywhere;
}
.query__caret { display: inline-block; width: .55em; height: 1.1em; vertical-align: -.2em; background: var(--slate); margin-left: 2px; animation: caret 1s steps(1) infinite; }
.is-typed .query__caret { animation: caret 1s steps(1) 3 forwards; }
@keyframes caret { 50% { opacity: 0; } }

.intro__grid {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem 4rem; align-items: end;
}
.name {
  font-size: clamp(3.2rem, 11vw, 9.5rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: .86;
  margin-left: -.05em;
}
.headline {
  font-size: clamp(1.5rem, 3.4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-top: .9rem;
}
.tagline { color: var(--slate); max-width: 34rem; margin-top: 1rem; font-size: 1.1rem; }

.intro__actions { display: grid; gap: 1.25rem; justify-items: start; padding-bottom: .4rem; }
.button {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 6px; padding: .85rem 1.3rem;
  box-shadow: 4px 4px 0 var(--marker);
  transition: transform .15s ease, box-shadow .15s ease;
}
.button:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--marker); }
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--marker); }
.button[aria-busy="true"] { opacity: .7; cursor: progress; }
.contact { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; font-size: .98rem; }
.contact span { color: var(--slate); }

.rows {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: .8rem; color: var(--slate);
  margin-top: clamp(2rem, 5vw, 3rem);
  min-height: 1.4em;
}

/* Reveal: the only orchestrated motion on the page */
.js .intro__grid, .js .page > section, .js .rows { opacity: 0; transform: translateY(10px); transition: opacity .6s ease, transform .6s ease; }
.js.is-ready .intro__grid, .js.is-ready .page > section, .js.is-ready .rows { opacity: 1; transform: none; }
.js.is-ready .page > section { transition-delay: .15s; }

/* Blocks: label on the left, content on the right */
.block {
  display: grid; grid-template-columns: var(--label) minmax(0, 1fr);
  gap: 1.5rem 3rem;
  padding: clamp(2rem, 5vw, 3.25rem) 0;
  border-top: 1px solid var(--rule);
}
.block[hidden] { display: none; }
.block__title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; padding-top: .2rem; }
.block__body { min-width: 0; }
.prose p { max-width: 40rem; }
.prose p + p { margin-top: .9em; }

/* Gantt */
.gantt { position: relative; margin-right: .8rem; }
.gantt__axis {
  position: relative; height: 1.5rem; margin-bottom: .5rem;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .72rem; color: var(--slate);
}
.gantt__tick { position: absolute; top: 0; transform: translateX(-50%); }
.gantt__tick:first-child { transform: none; }
.gantt__grid { position: absolute; inset: 2rem 0 0 0; pointer-events: none; }
.gantt__grid span { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--rule); }
.gantt__rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; position: relative; }
.gantt__row { position: relative; height: 2.6rem; }
.gantt__bar {
  --c: #2F6690; --on: #fff;
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center; min-width: .6rem;
  padding: 0 .7rem; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .85rem; font-weight: 600; text-align: left; white-space: nowrap;
  color: var(--on); overflow: visible;
}
/* One colour per role, oldest first. Each has a light-theme and dark-theme shade. */
.gantt__row:nth-child(6n+1) .gantt__bar { --c: #2F6690; --on: #fff; }
.gantt__row:nth-child(6n+2) .gantt__bar { --c: #3A7D44; --on: #fff; }
.gantt__row:nth-child(6n+3) .gantt__bar { --c: #B5525C; --on: #fff; }
.gantt__row:nth-child(6n+4) .gantt__bar { --c: #6D597A; --on: #fff; }
.gantt__row:nth-child(6n+5) .gantt__bar { --c: #D99A1E; --on: #16202B; }
.gantt__row:nth-child(6n+6) .gantt__bar { --c: #0F7B83; --on: #fff; }
@media (prefers-color-scheme: dark) {
  .gantt__row:nth-child(6n+1) .gantt__bar { --c: #6FA8DC; --on: #0F151C; }
  .gantt__row:nth-child(6n+2) .gantt__bar { --c: #7BC47F; --on: #0F151C; }
  .gantt__row:nth-child(6n+3) .gantt__bar { --c: #EE8B94; --on: #0F151C; }
  .gantt__row:nth-child(6n+4) .gantt__bar { --c: #B79CCB; --on: #0F151C; }
  .gantt__row:nth-child(6n+5) .gantt__bar { --c: #F2C14E; --on: #0F151C; }
  .gantt__row:nth-child(6n+6) .gantt__bar { --c: #5CC7C9; --on: #0F151C; }
}

/* The coloured bar is a separate layer so it can be drawn left to right. */
.gantt__fill {
  position: absolute; inset: 0; border-radius: 4px;
  background: var(--c);
  transform-origin: 0 50%;
}
.gantt__bar--now .gantt__fill { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.gantt__bar--now .gantt__fill::after {
  content: ""; position: absolute; right: -.7rem; top: 0; bottom: 0; width: .7rem;
  background: var(--c); clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.gantt__label { position: relative; overflow: hidden; text-overflow: ellipsis; }
.gantt__bar--outside .gantt__label { position: absolute; right: calc(100% + .6rem); color: var(--ink); font-weight: 500; }
.gantt__bar--right .gantt__label { right: auto; left: calc(100% + .6rem); }
.gantt__bar--now.gantt__bar--right .gantt__label { left: calc(100% + 1.2rem); }
.gantt__bar:hover .gantt__fill, .gantt__bar:focus-visible .gantt__fill { filter: brightness(1.12) saturate(1.1); }
.gantt__bar:hover .gantt__label, .gantt__bar:focus-visible .gantt__label { text-decoration: underline; text-underline-offset: .2em; }

/* Current roles glow gently */
.gantt__bar--now .gantt__fill { animation: gantt-glow 2.4s ease-in-out infinite; }
@keyframes gantt-glow {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(0 0 7px var(--c)) drop-shadow(0 0 2px var(--c)); }
}

/* Draw-in: each bar grows from its start date to its end date, one after another */
.gantt--animate .gantt__fill { transform: scaleX(0); }
.gantt--animate .gantt__label { opacity: 0; }
.gantt--animate.is-drawing .gantt__fill {
  animation: gantt-grow var(--t, .7s) cubic-bezier(.3, .7, .2, 1) var(--d, 0s) forwards;
}
.gantt--animate.is-drawing .gantt__bar--now .gantt__fill {
  animation: gantt-grow var(--t, .7s) cubic-bezier(.3, .7, .2, 1) var(--d, 0s) forwards,
             gantt-glow 2.4s ease-in-out calc(var(--d, 0s) + var(--t, .7s)) infinite;
}
.gantt--animate.is-drawing .gantt__label { transition: opacity .35s ease calc(var(--d, 0s) + var(--t, .7s) * .7); opacity: 1; }
@keyframes gantt-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Experience: each role is a "page" with its own query console on top.
   With motion allowed, the pages stack as you scroll and each query runs
   before its result loads in segments. */
.jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; }
.job {
  --card: color-mix(in srgb, var(--paper) 92%, #fff);
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(22, 32, 43, .04), 0 18px 40px -28px rgba(22, 32, 43, .35);
  scroll-margin-top: 1rem;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .job { --card: color-mix(in srgb, var(--paper) 88%, #fff); box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .7); }
}

/* The query console */
.job__console {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .75rem;
  padding: .7rem 1.1rem;
  background: #16202B; color: #C9D3DB;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .76rem; line-height: 1.55;
  font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0;
}
.job__engine { color: #8FA0AE; border: 1px solid #33424F; border-radius: 4px; padding: 0 .4rem; font-size: .68rem; white-space: nowrap; }
.job__sql { flex: 1 1 22rem; min-width: 0; overflow-wrap: anywhere; font: inherit; color: inherit; }
.job__status { color: #8FA0AE; white-space: nowrap; margin-left: auto; min-height: 1.2em; }
.job.is-running .job__status { color: #FFD84D; }
.sql-k { color: #7CC4FA; }
.sql-s { color: #FFD84D; }
.sql-n { color: #F4A7B9; }
.sql-c { color: #6F8190; }
.job__caret { display: inline-block; width: .5em; height: 1.05em; vertical-align: -.18em; background: #C9D3DB; margin-left: 1px; }

/* The result */
.job__result {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  grid-template-areas: "logo head when" "logo body body";
  gap: .2rem 1.1rem;
  padding: 1.25rem 1.25rem 1.4rem;
}
.job__logo {
  grid-area: logo;
  width: 3.5rem; height: 3.5rem; border-radius: 10px;
  background: #fff; border: 1px solid var(--rule);
  display: grid; place-items: center; overflow: hidden;
}
.job__logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; display: block; }
.job__logo--initials { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 800; letter-spacing: -0.02em; font-size: 1.1rem; }
.job__head { grid-area: head; min-width: 0; }
.job__when { grid-area: when; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .78rem; color: var(--slate); white-space: nowrap; padding-top: .35rem; }
.job__body { grid-area: body; min-width: 0; }
.job__role { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.job__where { color: var(--slate); }
.job__where strong { color: var(--ink); font-weight: 600; }
.job__summary { max-width: 42rem; margin-top: .7rem; }
.job ul { margin: .6rem 0 0; padding-left: 1.1rem; max-width: 42rem; }
.job li { margin: .2rem 0; }
.job li::marker { color: var(--slate); }
.job.is-marked { outline: 3px solid var(--marker); outline-offset: 2px; }

/* Segment reveal (only when animating) */
.exp-anim .job [data-seg] { opacity: 0; transform: translateY(10px); transition: opacity .45s ease, transform .45s ease; }
.exp-anim .job.is-played [data-seg] { opacity: 1; transform: none; }
.exp-anim .job:not(.is-played):not(.is-playing) .job__sql,
.exp-anim .job:not(.is-played):not(.is-playing) .job__status { visibility: hidden; }

/* Stacked pages */
.exp-stack .job {
  position: sticky;
  top: var(--stick, 1rem);
  transform-origin: 50% 0;
  transform: scale(calc(1 - var(--covered, 0) * .05));
}
.exp-stack .job::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: var(--ink); opacity: calc(var(--covered, 0) * .14);
}

@media (max-width: 640px) {
  .job__result {
    grid-template-columns: 2.75rem minmax(0, 1fr);
    grid-template-areas: "logo head" "when when" "body body";
    gap: .3rem .85rem; padding: 1rem;
  }
  .job__logo { width: 2.75rem; height: 2.75rem; border-radius: 8px; }
  .job__logo--initials { font-size: .9rem; }
  .job__when { padding-top: .3rem; }
  .job__role { font-size: 1.12rem; }
  .job__console { padding: .6rem .9rem; font-size: .7rem; }
  .job__status { margin-left: 0; }
}

/* Skills */
.skills { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem 3rem; }
.skills dt { font-weight: 700; margin-bottom: .5rem; }
.skills dd { margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.tag { display: inline-block; padding: .2rem .6rem; border: 1px solid var(--rule); border-radius: 4px; font-size: .92rem; background: color-mix(in srgb, var(--paper) 70%, var(--rule)); }

/* Projects, education, certifications */
.projects { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 3rem; }
.projects a { font-weight: 700; }
.projects p { color: var(--slate); }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.plain strong { font-weight: 700; }
.plain span { color: var(--slate); }

.foot {
  max-width: 76rem; margin: 0 auto; padding: 2rem var(--pad) 3rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  border-top: 1px solid var(--rule); color: var(--slate); font-size: .9rem;
}

/* Contact form */
.contact__intro { max-width: 40rem; margin-bottom: 1.5rem; }
.contact-form { display: grid; gap: 1.25rem; max-width: 44rem; }
.contact-form__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.contact-form__field { display: grid; gap: .35rem; }
.contact-form label { font-weight: 600; font-size: .95rem; }
.contact-form input, .contact-form textarea {
  font: inherit; color: var(--ink); width: 100%;
  background: color-mix(in srgb, var(--paper) 70%, var(--rule)); border: 1px solid var(--rule); border-radius: 6px;
  padding: .75rem .9rem;
}
.contact-form textarea { resize: vertical; min-height: 8rem; }
.contact-form input:focus, .contact-form textarea:focus { outline: 3px solid var(--green); outline-offset: 1px; border-color: transparent; }
.contact-form [aria-invalid="true"] { border-color: #B42318; }
.contact-form__error { font-size: .9rem; color: #B42318; }
.contact-form__error:empty { display: none; }
.contact-form__trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact-form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.contact-form__status { margin: 0; color: var(--slate); }
.contact-form__status.is-error { color: #B42318; }
.contact-form__done { max-width: 44rem; padding: 1.5rem; border-radius: 6px; background: color-mix(in srgb, var(--marker) 30%, transparent); }
.contact-form__done:focus { outline: none; }
.contact-form__done-title { font-size: 1.3rem; font-weight: 700; margin-bottom: .4rem; }
@media (prefers-color-scheme: dark) {
  .contact-form [aria-invalid="true"] { border-color: #FF8A80; }
  .contact-form__error, .contact-form__status.is-error { color: #FF8A80; }
}

@media (max-width: 860px) {
  .contact-form__row { grid-template-columns: 1fr; }
  .intro__grid { grid-template-columns: 1fr; }
  .block { grid-template-columns: 1fr; gap: 1rem; }
  .skills, .projects { grid-template-columns: 1fr; }
  .gantt__bar { font-size: .78rem; padding: 0 .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
}

/* Print: a tidy two-page CV straight from the browser */
@media print {
  @page { margin: 14mm 14mm 16mm; }
  :root { --paper: #fff; --ink: #000; --slate: #444; --rule: #ccc; --green: #000; --bar: #000; }
  body { font-size: 10pt; line-height: 1.45; }
  .query, .rows, .intro__actions .button, .skip, .foot p:last-child, .contact-section { display: none !important; }
  .js .intro__grid, .js .page > section, .js .rows { opacity: 1 !important; transform: none !important; }
  .intro { padding: 0 0 6mm; }
  .name { font-size: 30pt; }
  .headline { font-size: 15pt; margin-top: 2mm; }
  .block { grid-template-columns: 32mm 1fr; padding: 4mm 0; break-inside: avoid-page; }
  .job { break-inside: avoid; margin: 0 0 3mm; box-shadow: none; position: static !important; transform: none !important; border: 0; }
  .job::after, .job__console { display: none !important; }
  .job [data-seg] { opacity: 1 !important; transform: none !important; }
  .job__result { padding: 0; }
  .gantt__bar, .gantt__fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .gantt__fill { transform: none !important; animation: none !important; }
  .gantt__label { opacity: 1 !important; }
  a { color: #000; text-decoration: none; }
}
