/* ============================================================
   Rasmus Sorri — portfolio
   Design goals: minimal, calm, typographic. No frameworks.
   ============================================================ */

:root {
  --bg:            #fafaf8;
  --bg-raised:     #ffffff;
  --text:          #17150f;
  --text-muted:    #6b6459;
  --line:          #e6e2d9;
  --line-strong:   #d6d0c4;
  --accent:        #b4531f;   /* muted terracotta, used sparingly */
  --focus:         #1f6feb;

  --maxw: 44rem;
  --pad: clamp(1.25rem, 5vw, 2.5rem);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --step: 0.18s ease;
}

:root[data-theme="dark"] {
  --bg:            #131210;
  --bg-raised:     #1c1a17;
  --text:          #ece7dd;
  --text-muted:    #9a9285;
  --line:          #2a2721;
  --line-strong:   #3a362e;
  --accent:        #e08a4f;
  --focus:         #5b9dff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #131210;
    --bg-raised:   #1c1a17;
    --text:        #ece7dd;
    --text-muted:  #9a9285;
    --line:        #2a2721;
    --line-strong: #3a362e;
    --accent:      #e08a4f;
    --focus:       #5b9dff;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: 0 var(--pad);
}

body > * {
  max-width: var(--maxw);
  margin-inline: auto;
}

/* ---------- Masthead ---------- */
.masthead { padding-top: clamp(3rem, 10vw, 6rem); }

.masthead__inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.name {
  font-size: clamp(1.9rem, 6vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}

.tagline {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color var(--step), background var(--step);
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle__label::before { content: "◐"; font-size: 1.1rem; }

/* ---------- Intro ---------- */
.intro {
  margin-top: clamp(2.5rem, 8vw, 4rem);
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}
.intro p { margin: 0; max-width: 34rem; }

.intro__controls {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.link-button {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}
.link-button:hover { color: var(--accent); text-decoration-color: var(--accent); }
.dot-sep { margin: 0 0.5rem; }

/* ---------- Timeline ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* <li> owns the rail, border and vertical position context */
.entry {
  position: relative;
  border-bottom: 1px solid var(--line);
  padding-left: 1.75rem;
}

/* the vertical rail; stops short on the last row */
.entry::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.entry:last-child::before { bottom: auto; height: 1.9rem; }

/* <details> is the disclosure; carries the [open] state */
.disclosure { }

.entry__summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.15rem 0;
  outline: none;
}
.entry__summary::-webkit-details-marker { display: none; }

/* node dot on the rail */
.entry__summary::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.55rem;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background var(--step), transform var(--step);
}
.disclosure[open] > .entry__summary::before,
.entry__summary:hover::before { background: var(--accent); }

.entry__year {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 5.5rem;
}
.disclosure[open] > .entry__summary .entry__year { color: var(--text); }

.entry__title {
  font-size: 1.05rem;
  font-weight: 500;
  flex: 1;
}
.entry__title--empty { color: var(--text-muted); font-weight: 400; font-style: italic; }

.entry__chevron {
  flex: none;
  color: var(--text-muted);
  transition: transform var(--step);
  font-size: 0.8rem;
  align-self: center;
}
.disclosure[open] > .entry__summary .entry__chevron { transform: rotate(90deg); }

.entry__badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  align-self: center;
}

.entry__body {
  padding: 0 0 1.4rem 6.5rem;
  color: var(--text-muted);
  max-width: 36rem;
}
.entry__body p { margin: 0 0 0.75rem; }
.entry__body p:last-child { margin-bottom: 0; }
.entry__body ul { margin: 0 0 0.75rem; padding-left: 1.1rem; }
.entry__body li { margin-bottom: 0.2rem; }
.entry__body a { color: var(--accent); }

/* image galleries inside a chapter */
.entry__gallery {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;   /* captions vary the height; keep tops aligned */
  gap: 0.75rem;
  margin: 0.25rem 0 1.1rem;
}
.entry__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  width: fit-content;        /* shrink the figure to the photo's width... */
  gap: 0.4rem;
}
/* two or more photos sharing one caption — caption spans the whole row */
.entry__figure-row {
  display: flex;
  gap: 0.6rem;
}
/* one consistent, compact size for every photo on the site */
.entry__gallery img {
  height: 128px;
  width: auto;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  display: block;
}
/* small title under a photo — wraps to the photo's width, never wider */
.entry__caption {
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-muted);
  width: min-content;
  min-width: 100%;   /* ...so the caption matches the photo, not the reverse */
}

/* open animation (respects reduced motion below) */
.disclosure[open] > .entry__body {
  animation: reveal var(--step);
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Projects ---------- */
.section-heading {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: clamp(3rem, 9vw, 4.5rem) 0 1.5rem;
}

.projects {
  scroll-margin-top: 2rem;
}

.projects__grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;   /* full-width cards, stacked — no ragged gaps */
}

.project {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.35rem 1.5rem;
  background: var(--bg-raised);
  scroll-margin-top: 2rem;
  transition: border-color var(--step), box-shadow var(--step);
}

/* When linked to from the timeline (#project-...), briefly flash the card
   and settle back to normal — no persistent outline. */
.project:target {
  animation: project-flash 1.6s ease;
}
@keyframes project-flash {
  0%, 12% {
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 14%, var(--bg-raised));
  }
  100% {
    border-color: var(--line);
    background: var(--bg-raised);
  }
}

.project__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.project__tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.7rem 0 0;
  padding: 0;
}
.tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.project__body {
  margin-top: 0.85rem;
  color: var(--text-muted);
}
.project__body p { margin: 0 0 0.6rem; }
.project__body p:last-child { margin-bottom: 0; }

.project__links {
  margin: 1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.project__links a { color: var(--accent); text-decoration: none; }
.project__links a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: clamp(3rem, 10vw, 5rem);
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.site-footer__links { display: flex; gap: 1.25rem; }
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer__meta { margin: 0; color: var(--text-muted); }

.noscript { color: var(--accent); }

/* ---------- Focus & motion ---------- */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
