/* ============================================================
   Robert Söderbjörn — personal site
   One page, light theme, no dependencies.

     1. Tokens + base
     2. Intro (photo + text)
     3. Sections
     4. Project cards (shared shell)
     5. Per-project skins
     6. Footer + responsive
   ============================================================ */

/* ---------- 1. Tokens + base ---------- */
:root {
  --paper:     #faf9f6;   /* warm off-white */
  --ink:       #1b1a20;
  --ink-body:  #43414c;
  --ink-muted: #86838f;
  --rule:      #e7e4dd;
  --accent:      #5b53c9;
  --accent-soft: #ecebf9;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-body);
  font: 17px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 72px 28px 72px;
}

/* ---------- Sidebar menu ----------
   Parked to the left of the centred column. It needs ~200px of its
   own, so it only appears once the window is wide enough. */
.sidenav { display: none; }

@media (min-width: 1120px) {
  .sidenav {
    position: fixed;
    top: 210px;
    left: calc(50% - 26rem - 178px);
    width: 160px;
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: 2px;
    font-size: 14px;
  }
  .sidenav a {
    color: var(--ink-muted);
    border-bottom: 0;
    padding: 4px 11px;
    border-radius: 8px;
    transition: color .15s ease, background-color .15s ease;
  }
  .sidenav a:hover { color: var(--ink); background: rgba(27, 26, 32, .045); }
  .sidenav a.is-current {
    color: var(--accent);
    background: var(--accent-soft);
  }
}

html { scroll-behavior: smooth; }

h1 {
  margin: 0 0 34px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
}
a:hover { border-bottom-color: currentColor; }

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

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

/* ---------- 2. Intro ----------
   The photo floats so the text wraps past it instead of leaving a
   tall empty column beside the longer paragraphs. */
.intro::after { content: ""; display: block; clear: both; }

.portrait {
  float: left;
  width: 216px;
  height: 270px;
  margin: 6px 28px 10px 0;
  object-fit: cover;
  object-position: 50% 22%;
  border-radius: 14px;
  filter: saturate(.96);
}

/* ---------- 3. Sections ---------- */
section { scroll-margin-top: 28px; }
.subhead { scroll-margin-top: 28px; }
section + section { margin-top: 52px; }

h2 {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.section-intro { color: var(--ink-body); }

/* ---------- 4. Project cards (shared shell) ---------- */
/* One card per row: wide and short, screenshot on the left */
.cards {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

/* Every card reads these four; the skins below set them. */
.card {
  --card-bg:     #fff;
  --card-bar:    #fff;
  --card-border: var(--rule);
  --card-ink:    var(--ink);
  --card-body:   var(--ink-body);
  --card-accent: var(--accent);

  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 8px 20px -18px rgba(23, 22, 28, .5);
}

/* The "www.…" line stretches over the whole card, so clicking anywhere
   follows it. Links inside the prose sit above that overlay (see
   .card-body p a) and keep their own targets. */
.card:has(.card-link) {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:has(.card-link):hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--card-accent) 45%, var(--card-border));
  box-shadow: 0 14px 26px -20px rgba(23, 22, 28, .6);
}
.card:hover .card-link { border-bottom-color: currentColor; }
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Right column: the screenshot. It comes first in the markup (the
   picture belongs with the name), so `order` moves it across. */
.card-media {
  order: 2;
  flex: 0 0 240px;
  display: flex;
  min-width: 0;
  background: var(--card-bar);
  border-left: 1px solid var(--card-border);
}

/* `contain`, not `cover`: the whole screenshot stays visible however
   tall the text beside it happens to be. */
.shot {
  flex: 1;
  width: 100%;
  min-height: 100px;
  padding: 9px;
  object-fit: contain;
  object-position: center;
}

/* Three shots in the same slot on an 18s loop. Each clip gets roughly
   its own run time on screen: fly-around 0-8s, tab pan 8-13s, still
   layout 13-18s. A layer only fades out once the one above it is fully
   opaque, so the still never ghosts through a cross-fade. */
.shot-stack {
  position: relative;
  flex: 1;
  min-height: 100px;
}
.shot-stack .shot {
  position: absolute;
  inset: 0;
  height: 100%;
}
.shot-stack .shot-1 { animation: shot-1 18s ease-in-out infinite; }
.shot-stack .shot-2 { animation: shot-2 18s ease-in-out infinite; }

@keyframes shot-1 {           /* fly-around: on top of the still */
  0%, 47.8%   { opacity: 1; }
  47.9%, 96.7% { opacity: 0; }
  100%        { opacity: 1; }
}
@keyframes shot-2 {           /* tab pan: on top of everything */
  0%, 44.4%    { opacity: 0; }
  47.8%, 72.2% { opacity: 1; }
  75.6%, 100%  { opacity: 0; }
}

.card-body { flex: 1; padding: 15px 20px 16px; }

.card-body h3,
.card-body h4 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--card-ink);
}
.card-body p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--card-body);
}

/* Links in the prose must clear the stretched card link above them.
   They keep the body colour and are marked by the underline alone. */
.card-body p a {
  position: relative;
  z-index: 2;
  color: inherit;
  border-bottom-color: color-mix(in srgb, currentColor 45%, transparent);
}
.card-body p a:hover { border-bottom-color: currentColor; }
.card-link {
  display: inline-block;
  font-size: 13px;
  color: var(--card-accent);
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
}

/* ---------- 5. Per-project skins ---------- */

/* Lunamux — dark navy, cyan body text and a mono heading, the way
   its own site reads. Colours copied from lunamux-web/styles.css. */
.card--lunamux {
  --card-bg:     #04090f;
  --card-bar:    #0b1626;
  --card-border: rgba(77, 200, 245, .22);
  --card-ink:    #eaf6ff;
  --card-body:   #4dc8f5;
  --card-accent: #66d9ff;
}
/* The whole card body is set in the terminal face. Mono runs wide, so
   the body drops a step in size and gains a little line-height to stay
   comfortable. Delete this block to put the prose back in the sans. */
.card--lunamux .card-body h3 {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: -0.01em;
}
.card--lunamux .card-body p {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
}
.card--lunamux .card-link {
  font-family: var(--mono);
  font-size: 12px;
  color: #ffffff;
}

/* Lunicle — light grey-blue + indigo, same */
.card--lunicle {
  --card-bg:     #ffffff;
  --card-bar:    #f6f7fb;
  --card-border: #e5e8f1;
  --card-ink:    #171a26;
  --card-body:   #565d73;
  --card-accent: #5b57e0;
}

/* Not built yet — no screenshot, so the media column gets a hatch */
.card--soon {
  --card-ink:    #55525c;
  --card-body:   var(--ink-muted);
  --card-border: #e2ded6;
  background: transparent;
  box-shadow: none;
}
.card--soon .card-body h4 { font-weight: 600; }

.placeholder {
  flex: 1;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-linear-gradient(45deg,
      transparent 0 8px,
      rgba(27, 26, 32, .045) 8px 9px);
}
.placeholder span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--paper);
  padding: 3px 7px;
  border-radius: 999px;
}

/* Subsection heading inside a section */
.subhead {
  margin: 34px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.subhead + .cards { margin-top: 14px; }

/* ---------- 6. Footer + responsive ---------- */

/* Quiet line under the project list */
.more {
  margin-top: 22px;
  font-size: 14px;
  color: var(--ink-muted);
}
.more a { color: var(--ink-muted); border-bottom-color: var(--rule); }
.more a:hover { color: var(--accent); }

@media (max-width: 620px) {
  main { padding: 48px 20px 56px; }
  body { font-size: 16px; }
  .intro { margin-bottom: 40px; }
  .portrait {
    float: none;
    width: 152px;
    height: 190px;
    margin: 0 0 18px;
  }
  /* Screenshot back on top when there's no room beside the text */
  .card { flex-direction: column; }
  .card-media {
    order: 0;
    flex: 0 0 auto;
    border-left: 0;
    border-bottom: 1px solid var(--card-border);
  }
  .shot { height: 130px; flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: .001ms !important; }
  /* No cross-fade: settle on the still layout view */
  .shot-stack .shot-1,
  .shot-stack .shot-2 { animation: none; opacity: 0; }
}
