/* Filmprojekt på portfoliosidan (tools/film_section.py): projektkort med ljudlös teaser + spelare med ljud.
   --case-acc = kundens färg (sätts per projekt, som branding-casen). Sajtens palett och typsnitt i övrigt. */

/* ───────── Sektionen ───────── */
.fw-sec + .sec:not(.s-light) { border-top: 1px solid var(--line-ink); } /* två mörka sektioner i rad: en tunn skarv i stället för ett hål */
.fw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(28px, 5vw, 56px); }
.fw { --case-acc: var(--rec); --case-fg: var(--paper); display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(20px, 3vw, 28px);
  padding: clamp(14px, 2.4vw, 28px); border: 1px solid var(--line-ink); border-radius: 28px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--case-acc) 7%, transparent), rgba(255,255,255,.015) 45%), var(--ink-2);
  scroll-margin-top: calc(var(--nav-h) + 16px); }
/* Från 640 px: teasern i telefonformat bredvid texten (surfplatta och liggande mobil får inte ett kort som är flera skärmar högt) */
@media (min-width: 640px) {
  .fw { grid-template-columns: clamp(200px, 30vw, 380px) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: center; padding: clamp(16px, 2vw, 28px) clamp(20px, 4vw, 56px) clamp(16px, 2vw, 28px) clamp(16px, 2vw, 28px); }
}

/* Liggande projekt (16:9): teasern bred, texten bredvid först från 960 px; två tumnaglar per rad */
.fw.fw--wide { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px), (orientation: landscape) and (min-width: 640px) { .fw.fw--wide { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); } }
.fw--wide .fw-teaser, .fw--wide .fw-reel-img { aspect-ratio: 16 / 9; max-height: none; }
.fw--wide .fw-reels { grid-auto-columns: calc((100% - 10px) / 2); margin-inline: 0; padding-inline: 4px; }
@media (min-width: 640px) { .fw--wide .fw-reels { grid-auto-columns: calc((100% - 10px) / 2); padding-inline: 6px; margin-inline: -6px; } }

/* Teaser: 4:5 i stående mobil, 9:16 bredvid texten */
.fw-stage { position: relative; }
.fw-teaser { position: relative; display: block; width: 100%; aspect-ratio: 4 / 5; padding: 0; border: 0; border-radius: 22px; overflow: hidden; cursor: pointer;
  background: #050506; color: var(--paper); isolation: isolate;
  box-shadow: 0 24px 60px -24px color-mix(in srgb, var(--case-acc) 32%, transparent), 0 0 0 1px rgba(255,255,255,.06); }
@media (min-width: 640px) { .fw-teaser { aspect-ratio: 9 / 16; max-height: 82svh; } }
.fw-loop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform 700ms var(--ease-smooth-out); }
.fw-shade { position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, rgba(6,7,10,.88) 0%, rgba(6,7,10,.4) 34%, rgba(6,7,10,0) 58%); }
.fw-play { position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 12px; text-align: left; }
.fw-play-txt { display: grid; gap: 4px; min-width: 0; }
.fw-play-t { font: 700 clamp(1rem, 1.6vw, 1.12rem)/1.2 var(--f-display); letter-spacing: -0.01em; }
.fw-play-s { font: 500 11.5px/1.3 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: rgba(238,240,246,.86); }
.fw-play-ico { flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); color: var(--ink);
  box-shadow: 0 0 0 0 rgba(238,240,246,.45); transition: transform var(--dur-hover) var(--ease-smooth-out), box-shadow 600ms var(--ease-smooth-out); }
.fw-play-ico svg { width: 22px; height: 22px; fill: currentColor; margin-left: 3px; }
@media (hover: hover) {
  .fw-teaser:hover .fw-loop { transform: scale(1.035); }
  .fw-teaser:hover .fw-play-ico { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(238,240,246,0); }
}
.fw-teaser:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.fw-pause { position: absolute; top: 10px; right: 10px; z-index: 2; width: 44px; padding: 0; justify-content: center; }
.fw-pause .reel-toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .fw-loop, .fw-play-ico { transition: none; } }

/* Text */
.fw-kicker { display: inline-flex; align-items: center; gap: 10px; font: 500 12px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted-ink); }
.fw-kicker::before { content: ""; width: 28px; height: 3px; border-radius: 2px; background: var(--case-acc); }
.fw-name { margin-top: 12px; font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: .95; letter-spacing: -0.035em; }
.fw-intro { margin-top: 14px; max-width: 34rem; font-size: clamp(1.02rem, 1.4vw, 1.15rem); color: rgba(238,240,246,.88); }
.fw .fw-did { margin: 16px 0 0; }

/* De fem filmerna: fem kolumner bredvid texten, svepbar remsa i stående mobil */
.fw-reels { display: grid; grid-auto-flow: column; grid-auto-columns: 30%; gap: 10px; margin: 18px 0 0; padding: 6px 0 8px; list-style: none;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  contain: paint; } /* WebKit räknade annars remsans innehåll in i sidans bredd (scrollWidth 513 på 375) */
.fw-reels::-webkit-scrollbar { display: none; }
@media (max-width: 639px) { .fw-reels { margin-inline: calc(-1 * clamp(14px, 2.4vw, 28px)); padding-inline: clamp(14px, 2.4vw, 28px); scroll-padding-inline: clamp(14px, 2.4vw, 28px); } }
@media (min-width: 640px) {
  .fw-reels { grid-auto-columns: calc((100% - 52px) / 5); padding-inline: 6px; margin-inline: -6px; }
  @media (hover: hover) and (pointer: fine) { .fw-reels { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; } .fw-reels::-webkit-scrollbar { display: block; height: 6px; } }
}
.fw-reels li { scroll-snap-align: start; }
.fw-reel { display: grid; gap: 8px; width: 100%; padding: 0; border: 0; background: none; color: var(--paper); text-align: left; cursor: pointer; }
.fw-reel-img { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #050506; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.fw-reel-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 500ms var(--ease-smooth-out); }
.fw-reel-dur { position: absolute; left: 6px; bottom: 6px; padding: 3px 6px; border-radius: 6px; background: rgba(11,12,16,.74); font: 500 11px/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.fw-reel-t { font-size: 14px; font-weight: 600; line-height: 1.25; }
@media (hover: hover) { .fw-reel:hover .fw-reel-img img { transform: scale(1.05); } }
.fw-reel:focus-visible { outline: none; }
.fw-reel:focus-visible .fw-reel-img { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ───────── Spelaren ───────── */
html:has(.fp[open]) { overflow: hidden; }
.fp { --case-acc: var(--rec); position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, color-mix(in srgb, var(--case-acc) 8%, transparent), transparent 70%), #07080B;
  color: var(--paper); overscroll-behavior: contain; overflow: hidden; }
.fp[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.fp::backdrop { background: rgba(6,7,10,.94); }
.fp.is-fading-in { animation: fp-in 240ms var(--ease-smooth-out) both; }
.fp.is-closing { animation: fp-out 180ms cubic-bezier(0.4, 0, 1, 1) both; }
@keyframes fp-in { from { opacity: 0; transform: scale(.975); } to { opacity: 1; transform: none; } }
@keyframes fp-out { from { opacity: 1; } to { opacity: 0; transform: scale(.985); } }
.fp-top { display: flex; align-items: center; gap: 14px; min-width: 0;
  padding: max(12px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left)); }
.fp-meta { flex: 1; min-width: 0; }
.fp-title { font: 800 clamp(1.3rem, 4vw, 1.9rem)/1 var(--f-display); letter-spacing: -0.02em; }
.fp-sub { display: block; margin-top: 5px; font: 400 12px/1.35 var(--f-mono); letter-spacing: .06em; color: var(--muted-ink); overflow-wrap: anywhere; }
.fp-count { font: 500 13px var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fp-count b { color: var(--case-acc); font-weight: 500; }
.fp .icon-btn { background: rgba(238,240,246,.08); border-color: rgba(238,240,246,.24); color: var(--paper); }
@media (hover: hover) { .fp .icon-btn:not([aria-disabled="true"]):hover { border-color: rgba(238,240,246,.6); } }
.fp .icon-btn:focus-visible, .fp-item:focus-visible, .fp-video:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.fp.by-pointer .fp-video:focus-visible { outline: none; } /* öppnad med mus/touch: ingen ring runt filmen förrän en tangent trycks */
.fp .icon-btn[aria-disabled="true"] { opacity: .35; cursor: default; }

.fp-main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.fp-stage { position: relative; min-height: 0; container-type: size; display: grid; place-items: center; padding: 0 max(8px, env(safe-area-inset-left)) 8px; }
.fp-screen { position: relative; width: min(100cqw, 100cqh * 9 / 16); aspect-ratio: 9 / 16; }
.fp-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; border-radius: 14px; }
.fp[data-ar="16:9"] .fp-screen { width: min(100cqw, 100cqh * 16 / 9); aspect-ratio: 16 / 9; }
.fp[data-ar="16:9"] .fp-item img { width: 85px; height: 48px; }
.fp[data-ar="16:9"] .fp-now { display: block; padding-inline: var(--gutter); text-align: center; }
.fp[data-ar="16:9"] .fp-now-t { font: 800 1.2rem/1.1 var(--f-display); }
.fp[data-ar="16:9"] .fp-now-d { margin-top: 4px; color: rgba(238,240,246,.82); font-size: 15px; }
.fp-prev, .fp-next { position: absolute; top: 42%; translate: 0 -50%; z-index: 2; width: 42px; height: 42px; background: rgba(11,12,16,.55); backdrop-filter: blur(8px); }
.fp-prev { left: 8px; }
.fp-next { right: 8px; }
.fp.is-switching .fp-video { animation: fp-swap 260ms var(--ease-smooth-out) both; }
@keyframes fp-swap { from { opacity: .2; } to { opacity: 1; } }

.fp-side { min-width: 0; padding: 0 0 max(12px, env(safe-area-inset-bottom)); display: grid; gap: 10px; justify-items: center; }
.fp-now { display: none; }
.fp-list { display: flex; justify-content: safe center; gap: 8px; max-width: 100%; margin: 0; padding: 4px max(var(--gutter), env(safe-area-inset-left)); list-style: none; overflow-x: auto; scrollbar-width: none; }
.fp-list::-webkit-scrollbar { display: none; }
.fp-item { position: relative; display: grid; gap: 10px; align-items: center; padding: 0; border: 0; background: none; color: var(--paper); text-align: left; cursor: pointer; border-radius: 10px; }
.fp-item img { display: block; width: 48px; height: 85px; object-fit: cover; border-radius: 8px; opacity: .55; box-shadow: 0 0 0 1px rgba(255,255,255,.12); transition: opacity 200ms; }
.fp-item[aria-current="true"] img { opacity: 1; box-shadow: 0 0 0 2px var(--case-acc); }
.fp-item-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fp-item-d { display: none; }
@media (hover: hover) { .fp-item:hover img { opacity: .9; } }
.fp-cta { min-height: 44px; }

/* Liggande mobil: filmen till vänster, listan som smal kolumn till höger, tunnare topprad */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 560px) {
  .fp-top { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .fp-title { font-size: 1.15rem; }
  .fp-main { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); }
  .fp-side { align-content: start; padding: 0 max(12px, env(safe-area-inset-right)) 8px 0; overflow-y: auto; }
  .fp-list { flex-direction: column; padding: 2px; overflow: visible; }
  .fp-item img { width: 38px; height: 67px; }
  .fp[data-ar="16:9"] .fp-item img { width: 64px; height: 36px; }
  .fp[data-ar="16:9"] .fp-now { display: none; }
  .fp-cta { display: none; }
}
/* Mycket låg och smal (t.ex. 400 % zoom): dialogen får scrolla, filmen behåller en användbar höjd */
@media (max-height: 500px) and (max-width: 559px) {
  .fp { overflow-y: auto; }
  .fp[open], .fp-main { grid-template-rows: auto auto; }
  .fp-stage { height: 88dvh; }
}
@media (min-width: 960px) {
  .fp-main { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); grid-template-rows: minmax(0, 1fr); }
  .fp-stage { padding: 0 96px 24px; }
  .fp-prev, .fp-next { top: 50%; width: 48px; height: 48px; background: rgba(238,240,246,.08); }
  .fp-prev { left: -72px; } .fp-next { right: -72px; }
  .fp-sub { display: none; }
  .fp-side { display: flex; flex-direction: column; justify-items: stretch; gap: 20px; min-height: 0; padding: 4px max(var(--gutter), env(safe-area-inset-right)) 24px 0; overflow-y: auto; }
  .fp-now { display: block; }
  .fp-now-t { font: 800 1.6rem/1.05 var(--f-display); letter-spacing: -0.02em; }
  .fp-now-d { margin-top: 8px; color: rgba(238,240,246,.82); }
  .fp-list { flex-direction: column; overflow: visible; padding: 0; gap: 6px; }
  .fp-item { grid-template-columns: 48px minmax(0, 1fr) auto; width: 100%; padding: 6px; border-radius: 12px; }
  .fp[data-ar="16:9"] .fp-item { grid-template-columns: 85px minmax(0, 1fr) auto; }
  .fp[data-ar="16:9"] .fp-now { padding: 0; text-align: left; }
  .fp[data-ar="16:9"] .fp-now-t { font-size: 1.6rem; }
  .fp[data-ar="16:9"] .fp-stage { padding-inline: 88px; }
  .fp-item[aria-current="true"] { background: color-mix(in srgb, var(--case-acc) 12%, transparent); }
  @media (hover: hover) { .fp-item:not([aria-current="true"]):hover { background: rgba(238,240,246,.05); } }
  .fp-item-t { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; font-weight: 600; line-height: 1.25; }
  .fp-item-d { display: block; font: 500 12px var(--f-mono); color: var(--muted-ink); font-variant-numeric: tabular-nums; }
  .fp-cta { align-self: flex-start; margin-top: auto; }
}
/* Laptop med låg skärm (1280×720): CTA:n ska synas utan att listan scrollar */
@media (min-width: 960px) and (max-height: 780px) {
  .fp-item img { width: 40px; height: 71px; }
  .fp-item { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 4px 6px; }
  .fp-now-d { display: none; }
  .fp-side { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) { .fp.is-fading-in, .fp.is-closing, .fp.is-switching .fp-video { animation: none; } }

/* ───────── Fotoprojekt (ljust ark): mosaik + intro, bilderna öppnas i case-viewern ───────── */
.pj-list { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(28px, 5vw, 56px); }
.pj { --case-acc: var(--rec); --case-fg: var(--ink); --case-bg: var(--paper); display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(20px, 3vw, 32px);
  padding: clamp(14px, 2.4vw, 28px); border: 1px solid var(--line-light); border-radius: 28px; background: #fff;
  box-shadow: 0 1px 2px rgba(11,12,16,.06), 0 18px 40px -22px rgba(11,12,16,.28); scroll-margin-top: calc(var(--nav-h) + 16px); }
@media (min-width: 960px), (orientation: landscape) and (min-width: 640px) {
  .pj { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; padding-right: clamp(20px, 4vw, 56px); }
}
.pj-mosaic { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 3fr 2fr; gap: 8px; aspect-ratio: 4 / 3; }
.pj .pj-cell { position: relative; display: block; width: 100%; height: 100%; aspect-ratio: auto; padding: 0; border: 0; border-radius: 14px; overflow: hidden; cursor: zoom-in; background: #E2E4EC; }
.pj .pj-cell img { width: 100%; height: 100%; object-fit: cover; transition: transform 600ms var(--ease-smooth-out); }
.pj-big { grid-column: 1 / -1; }
@media (hover: hover) { .pj .pj-cell:hover img { transform: scale(1.05); } }
.pj .pj-cell:focus-visible { outline: 3px solid var(--accent-deep); outline-offset: 3px; }
.pj-pill { position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px 8px 10px; border-radius: 999px;
  background: rgba(11,12,16,.72); backdrop-filter: blur(6px); color: var(--paper); font: 500 12px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; }
.pj-pill-ico { width: 14px; height: 14px; background:
  linear-gradient(currentColor, currentColor) 0 0 / 6px 6px no-repeat, linear-gradient(currentColor, currentColor) 100% 0 / 6px 6px no-repeat,
  linear-gradient(currentColor, currentColor) 0 100% / 6px 6px no-repeat, linear-gradient(currentColor, currentColor) 100% 100% / 6px 6px no-repeat; }
.pj .pj-kicker { color: var(--muted-light); }
.pj-intro { margin-top: 14px; max-width: 34rem; font-size: clamp(1.02rem, 1.4vw, 1.15rem); color: var(--muted-light); }
.pj .pj-did { margin: 16px 0 0; }
.pj-peeks { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; }
.pj .pj-peek { aspect-ratio: 1; border-radius: 10px; }
.pj .pj-open { margin-top: 20px; }
@media (max-width: 639px) { .pj-peeks { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .pj .pj-cell img { transition: none; } }
