/* =========================================================
   Anders Kullenberg personal site
   Hand-built, no dependencies. Light + dark theme.
   ========================================================= */

:root {
  --bg: #fbfbfa;
  --bg-elev: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --border: #e6e5e2;
  --accent: #1f6feb;
  --accent-soft: rgba(31, 111, 235, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --maxw: 1040px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --text: #e9edf1;
  --text-muted: #9aa4af;
  --border: #262c34;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --bg-elev: #161b22;
    --text: #e9edf1;
    --text-muted: #9aa4af;
    --border: #262c34;
    --accent: #58a6ff;
    --accent-soft: rgba(88, 166, 255, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus {
  left: 12px;
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 600;
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
}
.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}
.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.theme-icon {
  width: 16px;
  height: 16px;
  display: block;
}
/* sun (shown in dark mode → click to go light) */
.theme-icon::before {
  content: "☀";
  font-size: 16px;
  line-height: 1;
}
:root[data-theme="dark"] .theme-icon::before,
:root:not([data-theme="light"]) .theme-icon::before {
  content: "☀";
}
:root[data-theme="light"] .theme-icon::before {
  content: "☾";
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-icon::before {
    content: "☀";
  }
}

/* ---------- Hero ---------- */
.hero {
  padding-top: clamp(60px, 12vw, 130px);
  padding-bottom: clamp(50px, 9vw, 90px);
}
.hero-inner {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 320px);
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}
.hero-portrait {
  margin: 0;
}
.hero-portrait img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  aspect-ratio: 560 / 614;
  object-fit: cover;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 18px;
}
.hero-title {
  font-size: clamp(2rem, 5.4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0 0 24px;
  max-width: 18ch;
}
.hero-lead {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0 0 34px;
}
.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(48px, 8vw, 86px);
  border-top: 1px solid var(--border);
}
.section-head {
  margin-bottom: 42px;
}
.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.section-sub {
  color: var(--text-muted);
  margin: 0;
  font-size: 1.05rem;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 40px;
  align-items: start;
}
.about-text p {
  margin: 0 0 18px;
  font-size: 1.06rem;
}
.about-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.about-card h3 {
  margin: 0 0 16px;
  font-size: 1rem;
}
.tag-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag-list li {
  font-size: 0.85rem;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* ---------- Projects ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}
.project-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.2s ease;
}
.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}
.project-icon {
  font-size: 1.7rem;
  margin-bottom: 14px;
}
.project-card h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}
.project-card p {
  color: var(--text-muted);
  margin: 0 0 18px;
  font-size: 0.98rem;
}
.project-tags {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.project-tags li {
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ---------- Timeline / experience ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.timeline-item {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 30px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child {
  border-bottom: none;
}
.timeline-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.timeline-date {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.timeline-org {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}
.timeline-body h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.timeline-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.99rem;
}

/* ---------- Writing / posts ---------- */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.post {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.post:last-child {
  border-bottom: none;
}
.post-date {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding-top: 3px;
}
.post-body h3 {
  margin: 0 0 6px;
  font-size: 1.12rem;
}
.post-body p {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- Article series (Summer reading) ---------- */
.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: none;
}
.article-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.article-num,
.article-status-wrap {
  margin-top: 3px;
}
.article-status-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
}
.article-audio-icon {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.article-body p {
  max-width: 70ch;
}
.article-item:last-child {
  border-bottom: none;
}
.article-num {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.article-body h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.article-body h3 a {
  color: var(--text);
}
.article-body h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}
.article-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96rem;
}
.article-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ---------- Article page (long-form prose) ---------- */
.article-hero {
  padding-top: clamp(48px, 8vw, 92px);
  padding-bottom: clamp(28px, 4vw, 48px);
}
.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 26px;
}
.article-back:hover {
  color: var(--accent);
  text-decoration: none;
}
.article-hero .eyebrow {
  margin-bottom: 14px;
}
.article-title {
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  max-width: 20ch;
}
.article-deck {
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.5;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 22px;
  max-width: 46ch;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.article-meta .dot {
  opacity: 0.5;
}

/* Audio player (listen to the article) */
.audioplayer {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 68ch;
  margin: 0 auto 34px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.ap-toggle {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease;
}
.ap-toggle:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.ap-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.ap-icon-pause {
  display: none;
}
.audioplayer.is-playing .ap-icon-play {
  display: none;
}
.audioplayer.is-playing .ap-icon-pause {
  display: block;
}
.ap-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ap-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ap-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 26%, transparent);
  cursor: pointer;
}
.ap-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
}
.ap-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 4ch;
  text-align: right;
}
.ap-speed {
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.ap-speed:hover {
  border-color: var(--accent);
  color: var(--accent);
}
@media (max-width: 520px) {
  .ap-label {
    display: none;
  }
}

/* Reading column + prose */
.prose {
  max-width: 68ch;
  margin-inline: auto;
  padding-bottom: clamp(48px, 8vw, 90px);
  font-size: 1.12rem;
  line-height: 1.75;
}
.prose > .lead {
  font-size: 1.3rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 32px;
}
.prose p {
  margin: 0 0 22px;
}
.prose h2 {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin: 44px 0 14px;
  line-height: 1.25;
}
.prose h3 {
  font-size: 1.25rem;
  margin: 32px 0 12px;
}
.prose ul,
.prose ol {
  margin: 0 0 22px;
  padding-left: 1.3em;
}
.prose li {
  margin-bottom: 8px;
}
.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose blockquote {
  margin: 32px 0;
  padding: 4px 0 4px 24px;
  border-left: 3px solid var(--accent);
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--text);
  font-style: italic;
}
.prose blockquote p:last-child {
  margin-bottom: 0;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}
.prose figure {
  margin: 34px 0;
}
/* full-bleed-ish figures break out of the reading column a little */
.prose figure.wide {
  margin-inline: calc(50% - 50vw);
  max-width: 100vw;
  padding-inline: 24px;
}
.prose figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.prose figure.wide img {
  max-width: var(--maxw);
  margin-inline: auto;
}
.prose figcaption {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}
.article-nav {
  max-width: 68ch;
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 clamp(40px, 6vw, 70px);
  border-top: 1px solid var(--border);
}
.article-nav a {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 45%;
}
.article-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}
.article-nav .article-nav-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-bottom: 3px;
}
.article-nav .next {
  text-align: right;
  margin-left: auto;
}

/* ---------- Contact ---------- */
.contact-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(30px, 5vw, 56px);
  box-shadow: var(--shadow);
  text-align: center;
}
.contact-card h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 12px;
}
.contact-card p {
  color: var(--text-muted);
  max-width: 52ch;
  margin: 0 auto 26px;
  font-size: 1.05rem;
}
.contact-links {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 30px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.site-footer p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero-portrait {
    max-width: 240px;
    order: -1;
  }
}

@media (max-width: 760px) {
  .nav-links {
    gap: 16px;
  }
  .brand-name {
    display: none;
  }
  .about-grid {
    grid-template-columns: 1fr;
  }
  .projects-grid {
    grid-template-columns: 1fr;
  }
  .post {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .article-item {
    grid-template-columns: 40px 1fr;
    grid-template-areas: "num body" "num status";
    gap: 6px 16px;
  }
  .article-num {
    grid-area: num;
    align-self: start;
    padding-top: 2px;
  }
  .article-body {
    grid-area: body;
  }
  .article-status-wrap {
    grid-area: status;
    justify-self: start;
    margin-top: 8px;
  }
}

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