/* ------------------------------------------------------------------ *
 * Sexfakta -- the encyclopedia's own layer
 *
 * Loaded only on the four fact routes, on top of app.css rather than
 * instead of it. Every colour here is either a variable app.css already
 * defines or --tone, which each category sets inline to its own accent.
 * Nothing in this file redefines a base token: the section should read as
 * the same site in a different room, not as a second site.
 * ------------------------------------------------------------------ */

.fakta { --tone: var(--accent); }

/* ------------------------------------------------------------- heroes */

.fakta-hero { padding-top: clamp(2.5rem, 7vw, 5rem); }
.fakta-hero h1 { margin-top: .4rem; }
.fakta-hero .lede { margin-top: 1.2rem; max-width: 46ch; }
.fakta-hero__meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.6rem; }

.fakta-back { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line); }
.fakta-back:hover { color: var(--ink); border-color: var(--line-strong); }
.fakta-sep { color: var(--ink-dim); margin: 0 .45rem; }

.fakta-h { font-size: clamp(1.15rem, 2.4vw, 1.45rem); margin-bottom: .9rem; }

/* ------------------------------------------------------------ feature */

.fakta-feature {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(1.2rem, 3vw, 2.4rem);
  align-items: center;
  margin-top: clamp(1.6rem, 4vw, 2.6rem);
  padding: clamp(1rem, 2.4vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color .25s var(--ease), transform .25s var(--ease);
}
.fakta-feature:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.fakta-feature__art { position: relative; display: block; }
.fakta-feature__art img {
  width: 100%; height: auto; display: block;
  border-radius: var(--radius-sm);
}
.fakta-feature__text h2 { margin: .55rem 0 .5rem; font-size: clamp(1.4rem, 3.2vw, 2rem); }

@media (max-width: 760px) {
  .fakta-feature { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------- the shelf */

.fakta-cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .9rem;
  margin-top: 1rem;
}
.fakta-cats--row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.fakta-cat {
  display: block;
  padding: 1.1rem 1.2rem 1.25rem;
  border: 1px solid var(--line);
  border-top: 2px solid var(--tone);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.fakta-cat:hover { background: var(--surface-2); transform: translateY(-2px); }
.fakta-cat h3 { margin: .3rem 0 .35rem; font-size: 1.05rem; }
.fakta-cat__n {
  font-size: .72rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--tone);
}

/* ---------------------------------------------------------- the cards */

.fakta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.fakta-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  text-decoration: none; color: inherit;
  transition: border-color .25s var(--ease), transform .25s var(--ease);
}
.fakta-card:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.fakta-card__art { display: block; position: relative; aspect-ratio: 16 / 9; }
.fakta-card__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fakta-card__body { display: block; padding: .95rem 1.05rem 1.15rem; }
.fakta-card__body h3 { margin: .35rem 0 .4rem; font-size: 1.02rem; line-height: 1.3; }

.fakta-tag {
  display: inline-block;
  font-size: .7rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--tone);
}

/* --------------------------------------------------------- the number */

.fakta-figure { display: block; margin-top: 1rem; }
.fakta-figure b { font-size: clamp(1.8rem, 5vw, 2.8rem); font-family: var(--serif); color: var(--tone); }
.fakta-figure i { font-style: normal; font-size: 1rem; color: var(--tone); margin-left: .15rem; }
.fakta-figure em { display: block; font-style: normal; font-size: .8rem; color: var(--ink-dim); }
.fakta-figure--sm { margin: 0 0 .1rem; }
.fakta-figure--sm b { font-size: 1.45rem; }

.fakta-stat {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  margin: 1.6rem 0;
  padding: 1.1rem 1.3rem;
  border-left: 3px solid var(--tone);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.fakta-stat b { font-family: var(--serif); font-size: clamp(2.2rem, 6vw, 3.2rem); color: var(--tone); line-height: 1; }
.fakta-stat i { font-style: normal; font-size: 1.1rem; color: var(--tone); }
.fakta-stat em { font-style: normal; color: var(--ink-dim); font-size: .9rem; flex-basis: 100%; }

/* -------------------------------------------------------- the article */

.fakta-article article { max-width: 46rem; padding-top: clamp(2rem, 6vw, 4rem); }
.fakta-article h1 { margin-top: .5rem; }
.fakta-article .lede { margin-top: 1rem; }

.fakta-figure-img { margin: clamp(1.6rem, 4vw, 2.4rem) 0 0; }
.fakta-figure-img img { width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }

.fakta-prose { margin-top: 1.6rem; }
.fakta-prose p { margin: 0 0 1.1rem; line-height: 1.72; color: var(--ink-soft); }

.fakta-nugget {
  margin: 2rem 0 0;
  padding: 1.3rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.fakta-nugget h2 {
  font-size: .72rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--tone); margin: 0 0 .55rem;
}
.fakta-nugget p { margin: 0; line-height: 1.66; }

.fakta-sources { margin-top: 2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.fakta-sources h2 {
  font-size: .72rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-dim); margin: 0 0 .4rem;
}

/* ------------------------------------------------------ placeholders */

/* Visible, small, and honest. A placeholder that pretends to be a
   photograph is one nobody ever gets round to replacing. */
.fakta-ph {
  position: absolute; left: .6rem; bottom: .6rem;
  padding: .2rem .5rem;
  font-size: .64rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim);
  background: rgba(18, 10, 16, .72);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.fakta-ph--fig { position: static; display: inline-block; margin-top: .5rem; }

/* -------------------------------------------------------------- foot */

.fakta-cta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.4rem; flex-wrap: wrap;
  padding: clamp(1.3rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.fakta-cta h2 { margin: 0 0 .4rem; font-size: clamp(1.15rem, 2.6vw, 1.5rem); }
.fakta-cta p { margin: 0; }
.fakta-disclaimer { margin-top: 1rem; }


/* --------------------------------------------------------------- the lab */

/* "Where do I fall": a slider against the study's own distribution. The
   whole point is that the reader's guess about the norm is usually far
   above the measured one, and a curve says that faster than a paragraph. */

.lab {
  margin: 2rem 0 0;
  padding: clamp(1.2rem, 3vw, 1.8rem);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.lab h2 {
  font-size: .72rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--tone); margin: 0 0 .5rem;
}
.lab__chart {
  position: relative;
  margin: 1.4rem 0 .2rem;
  height: 150px;
}
.lab__chart svg { width: 100%; height: 100%; display: block; overflow: visible; }

.lab__curve { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.lab__curve--ghost { stroke: var(--tone); opacity: .28; }
.lab__curve--lit   { stroke: var(--tone); opacity: 1; }

/* The marker is a DOM element rather than part of the SVG so it can move
   with a CSS transition without the path being redrawn. */
.lab__marker {
  position: absolute; top: -6px; bottom: -6px; left: 50%;
  width: 0; pointer-events: none;
  transition: left .08s linear;
}
.lab__marker i {
  position: absolute; top: 0; bottom: 0; left: -1px;
  width: 2px; background: var(--tone); opacity: .9;
}
.lab__marker i::after {
  content: ""; position: absolute; left: -4px; bottom: -5px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--tone);
}

.lab__control { display: block; margin: .4rem 0 1rem; }
.lab__range {
  width: 100%; -webkit-appearance: none; appearance: none;
  background: transparent; cursor: grab;
}
.lab__range:active { cursor: grabbing; }
.lab__range::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px; background: var(--line-strong);
}
.lab__range::-moz-range-track {
  height: 3px; border-radius: 3px; background: var(--line-strong);
}
.lab__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -12px;
  border-radius: 50%; border: 2px solid var(--ground);
  background: var(--tone);
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .9);
}
.lab__range::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%; border: 2px solid var(--ground);
  background: var(--tone);
}
.lab__range:focus-visible { outline: 2px solid var(--tone); outline-offset: 6px; }

.lab__value {
  margin: 0; font-family: var(--serif);
  font-size: clamp(1.8rem, 5vw, 2.6rem); color: var(--tone); line-height: 1.1;
}
.lab__verdict { margin: .3rem 0 0; font-size: 1.02rem; color: var(--ink-soft); }
.lab__note { margin-top: .9rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .lab__marker { transition: none; }
}


/* ------------------------------------------------------------- the doors */

/* Two ways on from a fact: the seven questions, and the couples' twenty.
   Side by side so neither reads as the afterthought, and only at the foot. */

.fakta-doors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.door {
  display: block;
  padding: clamp(1.3rem, 3vw, 1.9rem);
  border: 1px solid var(--line);
  border-top: 2px solid var(--tone);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none; color: inherit;
  transition: background .25s var(--ease), transform .25s var(--ease),
              border-color .25s var(--ease);
}
.door:hover {
  background: var(--surface-2); transform: translateY(-3px);
  border-color: var(--line-strong);
}
.door--alt { border-top-color: var(--accent-warm); }
.door--alt .door__kicker, .door--alt .door__go { color: var(--accent-warm); }

.door__kicker {
  display: block;
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--tone); margin-bottom: .45rem;
}
.door h2 { margin: 0 0 .5rem; font-size: clamp(1.1rem, 2.4vw, 1.4rem); line-height: 1.25; }
.door p { margin: 0 0 1rem; font-size: .95rem; line-height: 1.6; }
.door__go {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 600; color: var(--tone);
}
.door:hover .door__go svg { transform: translateX(3px); }
.door__go svg { transition: transform .25s var(--ease); }


/* ---------------------------------------------------------- the art frame */

/* One frame for every picture on the site, and the reason it exists is the
   pictures that are not here yet.
 *
 * Today each fact carries a drawing in the site's own two dark tones, so
 * nothing clashes. A photograph will not be that considerate: it arrives
 * with its own light, its own contrast and its own colour temperature, and
 * dropped into these cards unmediated it would look pasted on. The scrim
 * gives every image the same ground and the same falloff into the text, and
 * the filter pulls a photograph's saturation toward the page instead of
 * away from it. The drawings pass through it almost unchanged -- they are
 * already the right colour -- so the frame costs nothing now and is the
 * whole difference later. */

.art { position: relative; display: block; overflow: hidden; }

.art img {
  display: block; width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .5s var(--ease), filter .4s var(--ease);
  /* Gentle on a drawing, decisive on a photograph. */
  filter: saturate(.92) contrast(1.02);
}

/* Painted over the picture rather than under it, so it works on any source.
   Weighted to the bottom, which is where the text sits. */
.art__scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom,
      rgba(18, 10, 16, 0) 30%,
      rgba(18, 10, 16, .42) 78%,
      rgba(18, 10, 16, .72) 100%),
    radial-gradient(120% 90% at 50% 30%,
      rgba(18, 10, 16, 0) 40%, rgba(18, 10, 16, .5) 100%);
}

.art--hero .art__scrim {
  background: linear-gradient(to bottom,
    rgba(18, 10, 16, 0) 55%, rgba(18, 10, 16, .5) 100%);
}

/* The card lifts; the picture inside it moves a little less, which is what
   makes the lift read as depth rather than as a jump. */
.fakta-card:hover .art img,
.fakta-feature:hover .art img { transform: scale(1.035); filter: saturate(1) contrast(1.04); }

@media (prefers-reduced-motion: reduce) {
  .art img { transition: none; }
  .fakta-card:hover .art img, .fakta-feature:hover .art img { transform: none; }
}

/* ---------------------------------------------------------- frames, sized */

.fakta-card__art { aspect-ratio: 16 / 9; border-radius: 0; }
.fakta-feature__art { border-radius: var(--radius-sm); aspect-ratio: 16 / 9; }
.fakta-figure-img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.fakta-figure-img img { border-radius: 0; }


/* The licence's line, not ours. Small, quiet, and never omitted. */
.fakta-credit {
  margin-top: .55rem;
  font-size: .72rem;
  color: var(--ink-dim);
  letter-spacing: .01em;
}
.fakta-credit a { color: var(--ink-soft); text-decoration: none;
                  border-bottom: 1px solid var(--line); }
.fakta-credit a:hover { color: var(--ink); border-color: var(--line-strong); }


/* ------------------------------------------------------------- the guess */

.guess {
  margin: 1.6rem 0;
  padding: clamp(1.2rem, 3vw, 1.7rem);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--tone);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
}
.guess h2 {
  font-size: .72rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--tone); margin: 0 0 .45rem;
}
.guess__value {
  margin: 1rem 0 .2rem; font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3rem); color: var(--ink); line-height: 1;
}
.guess__control { display: block; margin: .6rem 0 1.1rem; }
.guess__range {
  width: 100%; -webkit-appearance: none; appearance: none;
  background: transparent; cursor: grab;
}
.guess__range:active { cursor: grabbing; }
.guess__range:disabled { cursor: default; opacity: .5; }
.guess__range::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px; background: var(--line-strong);
}
.guess__range::-moz-range-track {
  height: 3px; border-radius: 3px; background: var(--line-strong);
}
.guess__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -12px;
  border-radius: 50%; border: 2px solid var(--ground); background: var(--tone);
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .9);
}
.guess__range::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%; border: 2px solid var(--ground); background: var(--tone);
}
.guess__range:focus-visible { outline: 2px solid var(--tone); outline-offset: 6px; }

.guess__actions { margin: 0; }
.guess__go {
  background: var(--tone); color: #170d14; border: 0;
  padding: .6rem 1.1rem; border-radius: 999px; font: inherit; font-weight: 600;
  cursor: pointer;
}
.guess__go:disabled { opacity: .4; cursor: default; }

.guess__verdict { margin: .9rem 0 0; color: var(--ink-soft); }
.guess--done .guess__value { color: var(--ink-dim); }

/* The answer arrives rather than having always been there. */
.fakta-stat--revealed { animation: statIn .45s var(--ease) both; }
@keyframes statIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fakta-stat--revealed { animation: none; }
}


/* ------------------------------------------------------------ the filter */

.filter { margin: 1rem 0 .4rem; display: flex; align-items: center;
          gap: .8rem; flex-wrap: wrap; }
.filter__input {
  flex: 1 1 240px; min-width: 0;
  padding: .7rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink); font: inherit;
}
.filter__input::placeholder { color: var(--ink-dim); }
.filter__input:focus-visible { outline: 2px solid var(--tone); outline-offset: 2px; }
.filter__count { font-size: .85rem; color: var(--ink-dim); }

[data-empty="1"]::after {
  content: attr(data-empty-text);
  display: block; padding: 2rem 0; color: var(--ink-dim);
}

/* -------------------------------------------------------- surprise link */

.surprise {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1.05rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--ink); text-decoration: none;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.surprise:hover { background: var(--surface-2); border-color: var(--tone); }
