/* Den vanliga portfolion. Samma färger som 3D-spelet (PALETTE i js/core.js).
   Allt är avgränsat till .site-root (body på site/index.html, och rubriken + sektionerna i
   index.html under 3D-spelet), så att reglerna inte krockar med css/style.css. Grundreglerna för
   element ligger i :where(), vilket ger dem samma (låga) styrka som de hade förut. */

.site-root {
  /* Mörk skymningslila är standard, som spelets bakgrund. */
  --bg: #3d3358;          /* PALETTE.background */
  --bg-deep: #2f2745;     /* lite mörkare, för hero och sidfot */
  --surface: #4a3f69;     /* kort */
  --surface-2: #51467a;
  --text: #fff3d6;        /* PALETTE.sign, grädde */
  --text-dim: #d9cfe6;    /* dämpad text, AA mot --bg */
  --accent: #ffb45e;      /* PALETTE.warmLamp: länkar och markeringar */
  --glow: #f0561a;        /* PALETTE.signGlow: dekor */
  --btn: #bd3d0b;         /* mörkare signGlow: kremtext 4,96:1 (AA) */
  --btn-text: #fff3d6;
  --line: rgba(255, 243, 214, 0.18);
  --line-strong: rgba(255, 243, 214, 0.5); /* kontrollkanter, minst 3:1 */
  --sp-1: 8px; --sp-2: 16px; --sp-3: 24px; --sp-4: 40px; --sp-5: 64px; /* spacing-skala */
  --focus: #ffd27a;       /* PALETTE.windowGlow */
  --frame: #2b2d33;       /* PALETTE.frame */
  --ink: #25323d;         /* PALETTE.signText */
  --leaf-1: #c1121f; --leaf-2: #e85d04; --leaf-3: #f48c06;
  --shadow: 0 10px 30px rgba(15, 8, 30, 0.35);
  --radius: 16px;
  --display: 'Bungee', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

/* Ljus variant: krämfärgad bakgrund, samma accenter. */
@media (prefers-color-scheme: light) {
  .site-root {
    --bg: #fff3d6;
    --bg-deep: #ffe8bd;
    --surface: #ffffff;
    --surface-2: #fff8e8;
    --text: #25323d;
    --text-dim: #4b5560;
    --accent: #a8340a;
    --glow: #f0561a;
    --btn: #bd3d0b;
    --btn-text: #fff3d6;
    --line: rgba(37, 50, 61, 0.2);
    --line-strong: rgba(37, 50, 61, 0.55);
    --focus: #1d4ed8;
    --shadow: 0 10px 28px rgba(80, 40, 10, 0.16);
    color-scheme: light;
  }
}

html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
.site-root, .site-root * { box-sizing: border-box; }
.site-root {
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.65 var(--body);
  overflow-x: clip;
}
:where(.site-root) :is(img, video) { max-width: 100%; display: block; }
:where(.site-root) a { color: var(--accent); text-underline-offset: 3px; }
:where(.site-root) a:hover { text-decoration-thickness: 2px; }
:where(.site-root) :is(h1, h2, h3) { line-height: 1.15; margin: 0 0 0.5em; }
:where(.site-root) p { margin: 0 0 1em; }
:where(.site-root) ul { margin: 0; padding: 0; list-style: none; }

:where(.site-root) :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; }
.eyebrow { display: flex; align-items: center; gap: 10px; font: 700 13px/1 var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
/* Litet löv som accent framför överrubriken */
.eyebrow::before { content: ''; flex: none; width: 16px; height: 10px; background: var(--glow); border-radius: 0 100% 0 100%; transform: rotate(-12deg); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.skip-link { position: absolute; left: 12px; top: -80px; z-index: 100; background: var(--btn); color: var(--btn-text); padding: 12px 18px; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg-deep) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-height: 44px; }
.brand img { border-radius: 8px; }
.brand-name { font-family: var(--display); font-size: 18px; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.site-nav ul { display: flex; gap: 2px; }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 12px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; border-radius: 999px; }
.site-nav ul a:hover { background: var(--line); }
.site-nav ul a.active { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }
.site-nav button.nav-drive { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; font: 600 15px var(--body); cursor: pointer; }
.nav-drive { background: var(--btn); color: var(--btn-text) !important; }
.nav-drive:hover { filter: brightness(1.1); }
.icon-link { gap: 6px; border: 1.5px solid var(--line); }
.icon-link:hover { border-color: var(--accent); }
.nav-toggle { display: none; min-width: 44px; min-height: 44px; border: 1.5px solid var(--line); background: transparent; color: var(--text); border-radius: 12px; cursor: pointer; align-items: center; justify-content: center; }

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; padding: 12px 16px 18px; background: var(--bg-deep); border-bottom: 1px solid var(--line); }
  .site-nav.open { display: flex; }
  .site-nav ul { flex-direction: column; }
  .site-nav ul a.active { box-shadow: none; background: var(--line); border-radius: 999px; }
  .nav-drive, .icon-link { justify-content: center; }
}

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; background: radial-gradient(900px 500px at 85% 0%, rgba(240, 86, 26, 0.22), transparent 70%), linear-gradient(180deg, var(--bg-deep), var(--bg)); padding: clamp(40px, 8vw, 96px) 0 clamp(48px, 8vw, 96px); }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(28px, 5vw, 64px); align-items: center; }
.hero h1 { margin: 0 0 18px; }
.hero h1 .display { display: block; font-size: clamp(36px, 7vw, 76px); color: var(--text); }
.hero-sub { display: block; font: 700 clamp(20px, 3vw, 30px)/1.2 var(--body); color: var(--accent); margin-top: 8px; }
.lede { font-size: clamp(18px, 2vw, 21px); max-width: 36em; color: var(--text); }
.skill-line { display: flex; flex-wrap: wrap; gap: 6px 0; margin: 0 0 28px; color: var(--text-dim); font-weight: 600; font-size: 15px; }
.skill-line li:not(:last-child)::after { content: '•'; margin: 0 10px; color: var(--glow); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 24px; border-radius: 999px; font: 800 16px var(--body); text-decoration: none; border: 2px solid transparent; cursor: pointer; transition: transform .15s, filter .15s, background .15s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--btn); color: var(--btn-text); box-shadow: 0 6px 18px rgba(200, 66, 13, 0.4); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Biljetten: samma form som startknappen i spelet. */
.ticket { display: inline-block; align-self: flex-start; position: relative; margin-top: 8px; padding: 13px 28px 13px 44px; background: linear-gradient(90deg, transparent 26px, rgba(255, 243, 214, 0.55) 26px 28px, transparent 28px) 0 50% / 100% 70% no-repeat, var(--btn); color: #fff3d6; font: 800 16px var(--body); border-radius: 4px;
  -webkit-mask: radial-gradient(circle at 0 50%, transparent 9px, #000 9.5px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 9px, #000 9.5px) right / 51% 100% no-repeat;
  mask: radial-gradient(circle at 0 50%, transparent 9px, #000 9.5px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 9px, #000 9.5px) right / 51% 100% no-repeat; transition: transform .2s; }

.drive-card, .drive-mini { display: flex; flex-direction: column; background: var(--surface); color: var(--text); text-decoration: none; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .25s; }
.drive-card:hover, .drive-mini:hover { transform: translateY(-4px) rotate(-0.4deg); }
.drive-card:hover .ticket, .drive-mini:hover .ticket { transform: rotate(-1.5deg) scale(1.04); }
.drive-card img { width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; }
.drive-body { display: flex; flex-direction: column; gap: 4px; padding: 20px 22px 22px; }
.drive-mini { padding: 24px; gap: 4px; background: linear-gradient(160deg, var(--surface), var(--surface-2)); }
.drive-kicker { font: 700 12px/1 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.drive-title { font: 400 clamp(22px, 3vw, 30px)/1.1 var(--display); margin: 6px 0; }
.drive-sub { color: var(--text-dim); font-size: 15px; line-height: 1.5; margin-bottom: 8px; }

@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }

/* Löv i hero: bara CSS-animation, skapas av site.js. Av för reduced motion. */
.leaves { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.leaf { position: absolute; top: -40px; width: var(--s); height: calc(var(--s) * 0.62); background: var(--c); border-radius: 0 100% 0 100%; opacity: .85; animation: fall var(--d) linear var(--delay) infinite; will-change: transform; }
@keyframes fall {
  0% { transform: translate3d(0, -40px, 0) rotate(0); }
  50% { transform: translate3d(var(--sway), 50vh, 0) rotate(180deg); }
  100% { transform: translate3d(calc(var(--sway) * -0.5), 105vh, 0) rotate(360deg); }
}

/* ---------- Sektioner ---------- */
.section { padding: clamp(56px, 8vw, 104px) 0; }
.section-alt { background: var(--bg-deep); }
.section-head { margin-bottom: 28px; }
.section h2.display { font-size: clamp(28px, 4.5vw, 46px); }
.section-lede { color: var(--text-dim); max-width: 40em; }
.big { font-size: clamp(19px, 2.2vw, 24px); line-height: 1.4; font-weight: 600; }

/* ---------- Filter + grid ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.chip { min-height: 44px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--line-strong); background: transparent; color: var(--text); font: 700 15px var(--body); cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.chip:hover { transform: translateY(-1px); }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--btn); border-color: var(--btn); color: var(--btn-text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 22px; }
.card[hidden] { display: none; }
.card-open { all: unset; box-sizing: border-box; display: flex; flex-direction: column; width: 100%; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); transition: transform .25s, border-color .2s; }
.card-open:hover, .card-open:focus-visible { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 16px 36px rgba(15, 8, 30, 0.45), 0 0 0 1px var(--accent); }
.card-open:hover .card-title, .card-open:focus-visible .card-title { color: var(--accent); }
.card-media img { transition: transform .5s ease; }
.card-open:hover .card-media img { transform: scale(1.04); }
.card-open:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.card-media { position: relative; aspect-ratio: 16 / 10; background: var(--frame); overflow: hidden; }
.card-media img, .card-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card.phone .card-media img, .card.phone .card-media video { object-fit: contain; }
.card-media video { opacity: 0; transition: opacity .25s; }
.card-media video.on { opacity: 1; }
.badge { position: absolute; left: 10px; top: 10px; z-index: 2; padding: 4px 10px; border-radius: 999px; background: var(--frame); color: #fff3d6; font: 800 12px/1.3 var(--body); letter-spacing: .04em; }
.badge.star { background: #ffb45e; color: #25323d; left: auto; right: 10px; } /* 7,45:1 */
.play-hint { position: absolute; right: 10px; bottom: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; background: rgba(43, 45, 51, .8); display: grid; place-items: center; transition: opacity .2s; }
.play-hint::after { content: ''; border-left: 11px solid #fff3d6; border-block: 7px solid transparent; margin-left: 3px; }
.card-media video.on ~ .play-hint { opacity: 0; }
.card-text { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.card-cat { font: 700 12px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.card-title { font: 400 19px/1.2 var(--display); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags li, .tags .tag { padding: 5px 12px; border-radius: 999px; background: var(--line); color: var(--text); font: 600 13px/1.3 var(--body); }
.tags-sm li, .tags-sm .tag { font-size: 12px; padding: 3px 10px; }
.noscript-note { grid-column: 1 / -1; }

/* ---------- Reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- About / Clients & collaborators ---------- */
.about-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(28px, 5vw, 64px); align-items: start; }
.about-grid p { max-width: 38em; }
.pillars { display: grid; gap: 16px; }
.pillars li { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--glow); border-radius: var(--radius); padding: 18px 20px; }
.pillars h3 { font: 800 18px var(--body); margin-bottom: 4px; }
.pillars p { margin: 0; color: var(--text-dim); font-size: 15.5px; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }

.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 22px; }
.quotes figure { margin: 0; height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; position: relative; }
.quotes figure::before { content: '\201C'; position: absolute; top: 2px; left: 18px; font: 400 64px/1 var(--display); color: var(--glow); }
.quotes blockquote { margin: 0; padding-top: 26px; font-size: 17px; }
.quotes blockquote p { margin: 0; }
.quotes figcaption { display: flex; flex-direction: column; font-size: 14px; color: var(--text-dim); }
.quotes figcaption strong { color: var(--text); font-size: 16px; }

/* Clients & collaborators: kompakt, ligger först. Citaten är mindre och verktygen en smal rad under. */
.section-tight { padding: clamp(40px, 6vw, 72px) 0; }
.quotes-compact { gap: 16px; }
.quotes-compact figure { padding: 20px 22px; gap: 14px; }
.quotes-compact figure::before { font-size: 52px; left: 16px; }
.quotes-compact blockquote { padding-top: 20px; font-size: 16px; }
.toolbelt { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.toolbelt-title { margin: 0; font: 700 12px/1 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); }
.toolbelt .tags { gap: 6px; }

/* ---------- CV + kontakt ---------- */
.cta-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; padding: clamp(24px, 4vw, 44px); border-radius: 24px; background: linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--line); box-shadow: var(--shadow); }
.cta-panel h2 { margin-bottom: 6px; }
.cta-panel p { margin: 0; color: var(--text-dim); }
.contact-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: clamp(28px, 5vw, 64px); align-items: center; }
.mail { display: inline-block; min-height: 44px; font: 800 clamp(20px, 3.4vw, 30px) var(--body); overflow-wrap: anywhere; }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }

.site-footer { background: var(--bg-deep); border-top: 1px solid var(--line); padding: 28px 0; color: var(--text-dim); font-size: 15px; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer-row p { margin: 0; }
.footer-row a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; }
.footer-row nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; }

/* ---------- Projektdialog ---------- */
.project-dialog { margin: auto; width: min(860px, 100% - 24px); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); overflow: hidden; }
.project-dialog[open] { display: flex; }
.project-dialog::backdrop { background: rgba(20, 12, 34, .72); backdrop-filter: blur(3px); }
.dlg { display: flex; flex-direction: column; width: 100%; max-height: calc(100dvh - 24px); }
.dlg-head { display: flex; justify-content: space-between; gap: 16px; padding: 22px 22px 14px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: clamp(22px, 4vw, 32px); margin-bottom: 10px; }
.dlg-cat { font: 700 12px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.dlg-close { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; color: var(--text); font-size: 28px; line-height: 1; cursor: pointer; }
.dlg-close:hover { border-color: var(--accent); color: var(--accent); }
.dlg-body { overflow-y: auto; padding: 20px 22px; overscroll-behavior: contain; }
.dlg-body h2, .dlg-body h3 { font: 800 20px/1.3 var(--body); margin: 1.4em 0 .5em; }
.dlg-body figure { margin: 18px 0; }
.dlg-body figcaption { color: var(--text-dim); font-size: 14px; margin-top: 6px; }
.dlg-body img, .dlg-body video { width: 100%; height: auto; border-radius: 12px; background: var(--frame); }
.dlg-body .dlg-hero { margin: 0 0 16px; }
.dlg-body .dlg-hero.phone img, .dlg-body .dlg-hero.phone video { max-height: 60vh; width: auto; margin-inline: auto; }
.dlg-body iframe { max-width: 100%; border: 0; border-radius: 12px; }
.dlg-body ul { list-style: disc; padding-left: 1.3em; margin-bottom: 1em; }
.dlg-body li { margin-bottom: .3em; }
.dlg-foot { display: flex; flex-wrap: wrap; gap: 12px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.dlg-error { color: var(--text-dim); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .leaves { display: none; }
  .btn, .card-open, .drive-card, .drive-mini, .ticket { transition: none; }
  .btn:hover, .card-open:hover, .drive-card:hover, .drive-mini:hover, .chip:hover { transform: none; }
  .card-media img { transition: none; }
  .card-open:hover .card-media img { transform: none; }
}

/* ---------- Utskrift: bara det viktiga ---------- */
@media print {
  .site-header, .skip-link, .leaves, .chips, .hero .btn-row, .drive-card, .drive-mini, .grid, #work .section-lede, .nav-toggle, .site-footer a[href^="mailto"] { display: none !important; }
  .site-root { --bg: #fff; --bg-deep: #fff; --surface: #fff; --text: #000; --text-dim: #333; --accent: #7a2a08; --line: #bbb; }
  .site-root { background: #fff; color: #000; font-size: 11pt; }
  .hero, .section, .section-alt { background: none; padding: 16pt 0; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  a { color: #000; }
  #cv a[href]::after, .mail::after { content: ' (' attr(href) ')'; font-size: 9pt; font-weight: 400; }
  .quotes figure, .pillars li, .cta-panel { box-shadow: none; break-inside: avoid; }
}

@media (max-width: 480px) {
  .site-root { font-size: 16.5px; }
  .brand-name { font-size: 16px; }
  .btn-row .btn { flex: 1 1 100%; }
  .dlg-foot .btn { flex: 1 1 100%; }
}
.arrow { margin-left: .5em; }
.brand-role { display: block; font: 600 12px/1.1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.brand-text { display: flex; flex-direction: column; gap: 3px; }
@media (max-width: 520px) { .brand-role { display: none; } }
