/* ---------- Design tokens ---------- */
:root {
  --bg: #f6f5f1;
  --bg-elev: #ffffff;
  --fg: #131312;
  --fg-soft: #5b5b58;
  --fg-muted: #8a8a85;
  --line: #e6e4dd;
  --accent: #ff5b22;
  --accent-soft: #ffe9df;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 10px 30px -12px rgba(20,20,20,.18);
  --shadow-lg: 0 30px 60px -20px rgba(20,20,20,.25);
  --ease: cubic-bezier(.22,.61,.36,1);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --container: 1180px;
}

[data-theme="dark"] {
  --bg: #0e0e0d;
  --bg-elev: #181816;
  --fg: #f4f3ee;
  --fg-soft: #b8b6ad;
  --fg-muted: #7a786f;
  --line: #2a2a27;
  --accent: #ff7a45;
  --accent-soft: #2a1a13;
  --shadow-md: 0 10px 30px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 60px -20px rgba(0,0,0,.8);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .4s var(--ease), color .4s var(--ease);
}
img, video { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; margin: 0; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--fg); color: var(--bg); padding: .75rem 1rem; z-index: 1000;
}
.skip-link:focus { left: 1rem; top: 1rem; border-radius: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(16px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
}
.nav {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 600; letter-spacing: -.01em;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 18%, transparent);
}
.nav-links {
  display: flex; gap: .25rem;
}
.nav-link {
  padding: .5rem .9rem;
  border-radius: 999px;
  font-size: .9rem;
  color: var(--fg-soft);
  transition: color .25s var(--ease), background .25s var(--ease);
}
.nav-link:hover { color: var(--fg); background: color-mix(in oklab, var(--fg) 6%, transparent); }
.nav-link.is-active { color: var(--fg); background: color-mix(in oklab, var(--fg) 8%, transparent); }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  transition: transform .3s var(--ease), background .25s var(--ease);
}
.theme-toggle:hover { background: color-mix(in oklab, var(--fg) 5%, transparent); transform: rotate(20deg); }
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hamburger {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  z-index: 100;
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  margin: 5px 0;
  background-color: var(--fg);
  border-radius: 2px;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

/* ---------- Layout ---------- */
main { max-width: var(--container); margin: 0 auto; padding: 0 1.5rem; }

.view {
  display: none;
  animation: viewIn .55s var(--ease) both;
  padding: 4rem 0 6rem;
}
.view.is-active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 4rem;
  align-items: center;
  min-height: calc(100vh - 200px);
}
.eyebrow {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--fg-muted);
  margin: 0 0 1rem;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 5.5vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -.02em;
  margin: 0 0 1.5rem;
}
.accent {
  color: var(--accent);
  font-style: italic;
}
.hero-lead {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--fg-soft);
  max-width: 46ch;
  margin: 0 0 2.25rem;
}
.hero-cta { display: flex; gap: .75rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .85rem 1.4rem;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 500;
  transition: transform .25s var(--ease), background .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.btn-primary {
  background: var(--fg); color: var(--bg);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-ghost {
  background: transparent; color: var(--fg);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: color-mix(in oklab, var(--fg) 5%, transparent); }
.btn-back {
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-back:hover { transform: translateX(-3px); }

/* Hero visual & Profile Image */
.hero-visual {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.about-visual {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.profile-img {
  width: 80%;
  height: 80%;
  object-fit: cover;
  position: relative;
  z-index: 10;
  border-radius: var(--radius);
}
.om-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 10;
}
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(40px);
  opacity: .85;
  animation: float 12s ease-in-out infinite;
  z-index: 1; /* Placera bakom bilden om bilden är transparent (.png) */
}
.orb-1 { width: 55%; height: 55%; left: -10%; top: -10%; background: var(--accent); opacity: .55; }
.orb-2 { width: 45%; height: 45%; right: -5%; bottom: 5%; background: #ffd2bc; animation-delay: -4s; }
[data-theme="dark"] .orb-2 { background: #6e2a14; }
@keyframes float {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(20px,-15px) scale(1.05); }
  66% { transform: translate(-15px,10px) scale(.95); }
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, color-mix(in oklab, var(--fg) 6%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklab, var(--fg) 6%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
  z-index: 2;
}

/* ---------- Section heads ---------- */
.section-head { margin-bottom: 3rem; max-width: 640px; }
.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 .75rem;
  line-height: 1.1;
}
.section-lead { color: var(--fg-soft); margin: 0; }

/* ---------- Project grid ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1.5rem;
}
.project-card {
  position: relative;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .25s var(--ease);
  text-align: left;
  width: 100%;
  padding: 0;
  display: block;
}
.project-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in oklab, var(--fg) 18%, transparent);
}
.project-thumb {
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
  background-color: var(--line);
}
.project-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s var(--ease);
  position: relative;
  z-index: 2;
}
.thumb-fallback {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--bg-elev), var(--line));
  z-index: 1;
}
.project-card:hover .project-img { transform: scale(1.05); }

.project-meta {
  padding: 1.25rem 1.4rem 1.5rem;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
}
.project-meta h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 .35rem;
  letter-spacing: -.01em;
}
.project-meta p { margin: 0; color: var(--fg-muted); font-size: .85rem; }
.project-arrow {
  font-size: 1.2rem; color: var(--fg-soft);
  transition: transform .35s var(--ease);
}
.project-card:hover .project-arrow { transform: translate(4px,-4px); color: var(--accent); }

/* ---------- Detail ---------- */
.detail-extra {
  margin-bottom: 2rem;
}

.pdf-box {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 3rem;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}

.pdf-box:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
}

.pdf-icon {
  font-size: 2rem;
}

.pdf-info {
  display: flex;
  flex-direction: column;
}

.pdf-title {
  font-weight: 600;
  color: var(--fg);
}

.pdf-size {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.detail-stickybar {
  position: sticky; top: 76px; z-index: 20;
  padding: 1rem 0;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
}
.detail-hero {
  margin-bottom: 3rem;
  max-width: 760px;
}
.detail-tags {
  display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.tag {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg-soft);
  border: 1px solid var(--line);
  padding: .35rem .7rem; border-radius: 999px;
}
.detail-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: 0 0 1.25rem;
}
.detail-desc {
  font-size: 1.1rem;
  color: var(--fg-soft);
  margin: 0;
  max-width: 60ch;
}

.detail-cover {
  border-radius: var(--radius);
  aspect-ratio: 21 / 9;
  max-height: 450px;
  margin-bottom: 2.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  position: relative;
  background-color: var(--line);
}

.project-img-detail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  position: relative;
  z-index: 2;
}

.gallery {
  display: flex;
  gap: 3rem;
  overflow: hidden;
  padding: 3rem 0;
  cursor: grab;
  user-select: none;
  background: transparent;
  align-items: center;
  height: 400px;
  will-change: transform;
}

.gallery-inner {
  display: flex;
  gap: inherit;
  align-items: center;
  height: 100%;
  will-change: transform;
}

.gallery:active {
  cursor: grabbing;
}

.gallery-item {
  flex: 0 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-img {
  max-height: 100%;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.15));
  pointer-events: none;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.95);
  place-items: center;
  padding: 2rem;
  cursor: zoom-out;
}
.modal.is-active { display: grid; }
.modal-content {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}

/* ---------- contact ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 3rem;
  align-items: start;
}
.contact-grid p {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  line-height: 1.4;
  margin: 0;
  color: var(--fg);
}
.contact-list li {
  display: flex; justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .95rem;
}
.contact-list li span:first-child { color: var(--fg-muted); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--fg-muted);
  font-size: .85rem;
}
.site-footer a { color: var(--fg-soft); border-bottom: 1px solid var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 2.5rem; min-height: auto; padding-top: 2rem; }
  .hero-visual { max-width: 380px; }
  .about-visual { max-width: 380px; }
  .about-grid { grid-template-columns: 1fr; gap: 2rem; }
  .detail-stickybar { top: 68px; }
  .view { padding: 2rem 0 4rem; }

  .hamburger { display: block; }
  
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 1.5rem 0;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  }

  .nav-links.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .hamburger.is-active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .hamburger.is-active .hamburger-line:nth-child(2) {
    opacity: 0;
  }
  .hamburger.is-active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

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