/* jasen.ca */

@font-face {
  font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url("../fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Schibsted Grotesk"; font-style: italic; font-weight: 400 900; font-display: swap;
  src: url("../fonts/schibsted-grotesk-latin-wght-italic.woff2") format("woff2");
}

:root {
  --bg:      #eef0f3;
  --ink:     #14171c;
  --muted:   #5d6470;
  --line:    #d3d7de;
  --field:   #ffffff;
  --accent:  #2c45d6;
  --on-accent: #ffffff;
  --dot:     20, 23, 28;
  --danger:  #b42318;
  --ok:      #146c43;

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --max: 82rem;
  --radius: 10px;
  --ease: cubic-bezier(.2, .7, .1, 1);

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101318; --ink: #e8ebf0; --muted: #949cab; --line: #262b34;
    --field: #161a21; --accent: #8fa0ff; --on-accent: #0d1020; --dot: 232, 235, 240;
    --danger: #ff8a7a; --ok: #6fd3a0; --icon-plate: #ffffff; --icon-pad: .12em; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101318; --ink: #e8ebf0; --muted: #949cab; --line: #262b34;
  --field: #161a21; --accent: #8fa0ff; --on-accent: #0d1020; --dot: 232, 235, 240;
  --danger: #ff8a7a; --ok: #6fd3a0; --icon-plate: #ffffff; --icon-pad: .12em; color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-behavior: smooth; scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 5rem); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s, color .3s;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 1rem; z-index: 100; background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: var(--radius); }
.skip:focus { left: 1rem; }

/* Header */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 1rem) var(--gutter) 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  transition: background-color .3s, border-color .3s, backdrop-filter .3s;
  border-bottom: 1px solid transparent;
}
.bar.is-scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom-color: var(--line);
}
.mark { font-weight: 800; font-size: 1.125rem; letter-spacing: -.02em; text-decoration: none; }
.mark span { color: var(--muted); font-weight: 500; }
.nav { display: flex; align-items: center; gap: clamp(.6rem, 1.6vw, 1.25rem); font-size: .95rem; }
.nav a { text-decoration: none; color: var(--muted); transition: color .2s; }
.nav a:hover { color: var(--ink); }
.theme {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--ink);
  width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  transition: border-color .2s, transform .5s var(--ease);
}
.theme:hover { border-color: var(--muted); }

/* Social links: two matching tiles. LinkedIn's official bug is already a rounded square,
   so X gets a tile of the same size and corner radius with its logo knocked out of it.
   Both take the text colour, and pick up their brand colour on hover. */
.social {
  --size: 1.9rem;
  position: relative; flex: none; display: block;
  width: var(--size); height: var(--size);
  color: var(--muted);
  transition: color .2s, transform .25s var(--ease);
}
.nav a.social { color: var(--muted); }
.social:hover, .nav a.social:hover { color: var(--ink); transform: translateY(-1px); }
.social--linkedin:hover, .nav a.social--linkedin:hover { color: #0a66c2; }
.social--linkedin {
  background: currentColor;
  -webkit-mask: url("../icons/linkedin.png") center / contain no-repeat;
  mask: url("../icons/linkedin.png") center / contain no-repeat;
}
.social--x { background: currentColor; border-radius: 9%; }
.social--x::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 54%; height: 54%;
  background: var(--bg);
  -webkit-mask: url("../icons/x.svg") center / contain no-repeat;
  mask: url("../icons/x.svg") center / contain no-repeat;
}
.foot .social { --size: 1.4rem; }
.theme svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.6; }
.theme svg path { fill: currentColor; stroke: none; }
:root[data-theme="dark"] .theme { transform: rotate(180deg); }

/* Layout: everything fits on one screen on desktop; stacks and scrolls on small screens */
body { display: grid; grid-template-rows: auto 1fr auto; min-height: 100svh; }
.bar {
  position: sticky; top: 0;
  padding-block: calc(env(safe-area-inset-top, 0px) + .9rem) .9rem;
  padding-inline: max(var(--gutter), (100% - var(--max)) / 2);
}
main {
  width: 100%; max-width: calc(var(--max) + var(--gutter) * 2); margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid; gap: 2rem;
}

/* Hero */
.hero {
  position: relative;
  display: flex; align-items: flex-end;
  padding: 3rem 0 .5rem;
  isolation: isolate;
}
.field {
  position: absolute; inset: 0 calc(var(--gutter) * -1); width: calc(100% + var(--gutter) * 2); height: 100%; z-index: -1;
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent 98%);
  mask-image: linear-gradient(to right, #000 55%, transparent 98%);
}
.hero__line {
  margin: 0;
  font-size: clamp(2.4rem, min(4.2vw, 7.2vh), 4.2rem);
  font-weight: 800;
  line-height: .95;
  letter-spacing: -.04em;
}
.hero__line span {
  display: block;
  animation: rise 1s var(--ease) both;
  animation-delay: calc(var(--i) * 130ms + 120ms);
}
.hero__line span:nth-child(2) { font-weight: 500; font-style: italic; letter-spacing: -.03em; padding-left: .02em; }
.hero__line span:nth-child(3) { color: var(--muted); font-weight: 400; }
@keyframes rise {
  from { opacity: 0; transform: translateY(.35em); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.section-title {
  margin: 0 0 .75rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}

/* Projects */
.projects { display: flex; flex-direction: column; }
.project {
  display: flex; flex-direction: column; gap: .5rem;
  padding: clamp(.9rem, 2.4vh, 1.4rem) 0;
  border-top: 1px solid var(--line);
}
.project:last-of-type { border-bottom: 1px solid var(--line); }
.project__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .25rem 1rem; }
.project__name { margin: 0; display: flex; align-items: center; gap: .6rem; font-size: clamp(1.3rem, 1.9vw, 1.65rem); font-weight: 750; line-height: 1.1; letter-spacing: -.025em; }
.project__icon {
  flex: none; width: 1.1em; height: 1.1em; border-radius: 22%; object-fit: contain;
  /* Dark mode: a white tile keeps dark logos (like World Watch Exchange's) visible */
  background: var(--icon-plate, transparent); padding: var(--icon-pad, 0);
}
.project__link {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--accent); font-size: .9rem; font-weight: 500; text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color .2s;
}
.project__link:hover { border-bottom-color: var(--accent); }
.project__link svg { width: .6rem; height: .6rem; fill: none; stroke: currentColor; stroke-width: 1.6; transition: transform .25s var(--ease); }
.project__link:hover svg { transform: translate(2px, -2px); }
.project__body { display: flex; flex-direction: column; gap: .6rem; }
.project__summary { margin: 0; font-size: 1rem; line-height: 1.45; max-width: 40em; }
.project__details { display: none; }
.project__stack { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0; }
.project__stack li { font-size: .75rem; padding: .15rem .6rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

/* Contact */
.contact__intro p { margin: 0 0 1rem; color: var(--muted); font-size: .95rem; }
.reveal {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: .55rem;
  font: 600 .9rem var(--font); color: var(--ink);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: .6rem 1.15rem;
  transition: border-color .2s, background-color .2s, color .2s;
}
.reveal:hover { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.reveal svg { width: .7rem; height: .7rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.reveal[aria-busy="true"] { opacity: .6; pointer-events: none; }
.reveal[hidden] { display: none; }
.reveal__note { font-size: .85rem !important; color: var(--muted); margin: .5rem 0 0 !important; }
.contact:has(.form:not([hidden])) .contact__intro p { margin-bottom: .75rem; }
.form[hidden] { display: none; }
.form:not([hidden]) { animation: open .45s var(--ease) both; }
@keyframes open { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.form { display: grid; gap: .75rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.input { display: grid; gap: .3rem; }
.input label { font-size: .8rem; font-weight: 600; }
.input input, .input textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .55rem .8rem;
  transition: border-color .2s, box-shadow .2s;
}
.input textarea { resize: none; height: 6.5rem; line-height: 1.45; }
.input input:hover, .input textarea:hover { border-color: var(--muted); }
.input input:focus, .input textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[data-invalid] input, .input[data-invalid] textarea { border-color: var(--danger); }
.input__error { margin: 0; font-size: .8rem; color: var(--danger); }
.input__error:empty { display: none; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.form__foot { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem 1.25rem; }
.send {
  position: relative; appearance: none; border: 0; cursor: pointer;
  font: 600 .9rem var(--font);
  background: var(--ink); color: var(--bg);
  padding: .65rem 1.3rem; border-radius: 999px;
  transition: transform .2s var(--ease), background-color .2s;
}
.send:hover { background: var(--accent); color: var(--on-accent); }
.send:active { transform: scale(.97); }
.send[aria-busy="true"] { pointer-events: none; opacity: .75; }
.send[aria-busy="true"] .send__label::after {
  content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .6em; vertical-align: -.08em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.form__status { margin: 0; font-size: .875rem; color: var(--muted); }
.form__status[data-state="ok"] { color: var(--ok); }
.form__status[data-state="error"] { color: var(--danger); }
.form.is-sent .send { background: var(--ok); color: var(--bg); }

/* Footer */
.foot {
  width: 100%; max-width: calc(var(--max) + var(--gutter) * 2); margin: 0 auto;
  padding: 1rem var(--gutter) 1.25rem;
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .8rem; color: var(--muted);
}
.foot p { margin: 0; }
.foot__links { display: flex; align-items: center; gap: .5rem; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); }

/* Desktop: one screen, no scrolling. Intro and contact on the left, projects on the right. */
@media (min-width: 1024px) and (min-height: 640px) {
  body { height: 100svh; }
  main {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "hero projects" "contact projects";
    column-gap: clamp(2.5rem, 6vw, 6rem);
    row-gap: 1.75rem;
    padding-block: 1rem;
  }
  .hero { grid-area: hero; align-items: flex-start; padding: 2.25rem 0 .75rem; }
  .projects { grid-area: projects; min-height: 0; }
  .contact { grid-area: contact; align-self: start; }
  .nav a[href^="#"] { display: none; }
}
@media (min-width: 1280px) and (min-height: 1000px) {
  .project__details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1.5rem; margin: 0; }
  .project__details dt { font-size: .8rem; font-weight: 650; }
  .project__details dd { margin: 0; font-size: .8rem; line-height: 1.4; color: var(--muted); }
}

/* Small screens */
@media (max-width: 1023px), (max-height: 639px) {
  .bar { background: color-mix(in srgb, var(--bg) 85%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .hero { min-height: 38svh; }
  main { padding-bottom: 2rem; }
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
