/* =========================================================================
   TUNEMENT — Components & Primitives
   Pair with colors_and_type.css. Minimal, intentional, no flourish.
   ========================================================================= */

/* -------------------------------------------------------------------------
   THE GRAIN BLOB — Tunement's signature visual motif
   Soft electric-blue radial gradient + grain noise on warm-white.
   Use as a hero background, a card backdrop, or a scaling visual element.
   ------------------------------------------------------------------------- */

.tn-blob-stage {
  position: relative;
  background: var(--tn-warm-white);
  overflow: hidden;
  isolation: isolate;
}

/* Single soft blob — drop into any positioned parent */
.tn-blob {
  position: absolute;
  width: 70%;
  aspect-ratio: 1 / 1;
  pointer-events: none;
  filter: blur(40px);
  background: radial-gradient(
    circle at 50% 50%,
    var(--tn-blue) 0%,
    var(--tn-blue) 18%,
    rgba(23, 80, 255, 0.55) 40%,
    rgba(23, 80, 255, 0.18) 65%,
    rgba(23, 80, 255, 0) 80%
  );
  z-index: 0;
}

.tn-blob--soft {
  filter: blur(80px);
  background: radial-gradient(
    circle at 50% 50%,
    rgba(23, 80, 255, 0.85) 0%,
    rgba(23, 80, 255, 0.5) 30%,
    rgba(23, 80, 255, 0.15) 60%,
    rgba(23, 80, 255, 0) 80%
  );
}

/* Multi-lobe poster blob — like the ZERONODE / Rising Moon posters */
.tn-blob--cluster {
  filter: blur(55px);
  background:
    radial-gradient(circle at 30% 25%, rgba(23, 80, 255, 0.9) 0%, rgba(23, 80, 255, 0) 35%),
    radial-gradient(circle at 70% 35%, rgba(23, 80, 255, 0.85) 0%, rgba(23, 80, 255, 0) 38%),
    radial-gradient(circle at 45% 60%, rgba(23, 80, 255, 0.95) 0%, rgba(23, 80, 255, 0) 32%),
    radial-gradient(circle at 65% 80%, rgba(23, 80, 255, 0.8) 0%, rgba(23, 80, 255, 0) 36%);
  background-color: transparent;
}

/* Grain overlay — sit ABOVE blob, BELOW content (z-index 1) */
.tn-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* Lighter grain — for white surfaces over color blocks */
.tn-grain--soft { opacity: 0.32; }

/* Content sits on top */
.tn-blob-stage > .tn-blob-content { position: relative; z-index: 2; }


/* -------------------------------------------------------------------------
   CAPSULE — the glassy pill from ZERONODE/Transparency/Regeneration
   Translucent, rounded-full, hairline blue interior border, mono caps copy
   ------------------------------------------------------------------------- */
.tn-capsule {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 14px 28px;
  min-height: 44px;
  border-radius: var(--r-pill);
  background: rgba(255, 252, 239, 0.35);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  box-shadow: var(--sh-capsule);
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  font-weight: 500;
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
  color: var(--tn-blue-deep);
  border: none;
  cursor: pointer;
  transition: transform var(--dur-base) var(--ease-out),
              background var(--dur-base) var(--ease-out);
}
.tn-capsule:hover { background: rgba(255, 252, 239, 0.6); }
.tn-capsule:active { transform: scale(0.98); }
.tn-capsule--lg { padding: 18px 36px; min-height: 56px; font-size: var(--fs-body); }
.tn-capsule--solid {
  background: var(--tn-blue);
  color: var(--tn-warm-white);
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
}
.tn-capsule--solid:hover { background: var(--tn-blue-deep); }
.tn-capsule--ghost {
  background: rgba(17, 17, 17, 0.06);
  box-shadow: none;
  color: var(--tn-black);
}
.tn-capsule--ghost:hover { background: var(--tn-black); color: var(--tn-warm-white); }


/* -------------------------------------------------------------------------
   BUTTONS — sharper, rectangular alternative for utility actions
   ------------------------------------------------------------------------- */
.tn-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 12px 20px;
  min-height: 44px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 500;
  letter-spacing: 0;
  border: none;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  background: var(--tn-black);
  color: var(--tn-warm-white);
}
.tn-btn:hover { opacity: 0.8; }
.tn-btn:active { transform: translateY(1px); }
.tn-btn--blue { background: var(--tn-blue); color: var(--tn-warm-white); }
.tn-btn--ghost {
  background: rgba(17, 17, 17, 0.06);
  color: var(--tn-black);
  box-shadow: none;
}
.tn-btn--ghost:hover { background: var(--tn-black); color: var(--tn-warm-white); opacity: 1; }


/* -------------------------------------------------------------------------
   FORM CONTROLS — hairline underline style. No boxed inputs.
   ------------------------------------------------------------------------- */
.tn-field {
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--font-sans);
}
.tn-field label {
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
  color: var(--fg-2);
}
.tn-field input,
.tn-field textarea {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  padding: 10px 0;
  font-family: inherit;
  font-size: var(--fs-body-lg);
  color: var(--fg);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.tn-field input:focus,
.tn-field textarea:focus {
  border-bottom-color: var(--accent);
}
.tn-field input::placeholder,
.tn-field textarea::placeholder { color: var(--fg-3); }


/* -------------------------------------------------------------------------
   LAYOUT HELPERS — corner labels, vertical edge text
   ------------------------------------------------------------------------- */
.tn-layout {
  position: relative;
  min-height: 100vh;
  padding: var(--sp-7) var(--gutter);
}

/* Four-corner meta grid for posters / hero sections */
.tn-corners > .tn-corner-tl,
.tn-corners > .tn-corner-tr,
.tn-corners > .tn-corner-bl,
.tn-corners > .tn-corner-br {
  position: absolute;
  z-index: 3;
}
.tn-corner-tl { top: var(--sp-5); left: var(--sp-5); }
.tn-corner-tr { top: var(--sp-5); right: var(--sp-5); text-align: right; }
.tn-corner-bl { bottom: var(--sp-5); left: var(--sp-5); }
.tn-corner-br { bottom: var(--sp-5); right: var(--sp-5); text-align: right; }

/* Edge vertical labels */
.tn-edge-l, .tn-edge-r {
  position: absolute; z-index: 3;
  top: 50%; transform: translateY(-50%);
}
.tn-edge-l { left: var(--sp-5); }
.tn-edge-r { right: var(--sp-5); }


/* -------------------------------------------------------------------------
   CARDS — flat, hairline border. No drop shadows.
   ------------------------------------------------------------------------- */
.tn-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-6);
}
.tn-card--bare { border: 0; padding: 0; }
.tn-card--invert {
  background: var(--bg-invert);
  color: var(--fg-invert);
  border: 0;
}


/* -------------------------------------------------------------------------
   DIVIDER — hairline rule, often paired with a meta label
   ------------------------------------------------------------------------- */
.tn-rule { border: 0; border-top: 1px solid var(--line-2); margin: 0; }
.tn-rule--strong { border-top-color: var(--fg); }


/* -------------------------------------------------------------------------
   AUDIO WAVEFORM — bespoke "sonic" element
   ------------------------------------------------------------------------- */
.tn-waveform {
  display: flex; align-items: center; gap: 3px;
  height: 32px;
}
.tn-waveform > span {
  display: block;
  width: 3px;
  background: var(--tn-blue);
  border-radius: 2px;
}


/* -------------------------------------------------------------------------
   MARQUEE — continuous right-to-left scroll for case carousel and logo wall.
   Track holds duplicated content; we translate from 0 to -50% so the seam is
   invisible. Uses a CSS variable so each instance can set its own duration.
   ------------------------------------------------------------------------- */
.tn-marquee {
  --tn-marquee-duration: 60s;
  position: relative;
  width: 100%;
  overflow: hidden;
  /* Soft fades on the edges so cards don't pop in/out */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 8%, #000 92%, transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 8%, #000 92%, transparent 100%);
}
.tn-marquee__track {
  display: flex;
  width: max-content;
  animation: tnMarquee var(--tn-marquee-duration) linear infinite;
  will-change: transform;
}
.tn-marquee:hover .tn-marquee__track,
.tn-marquee:focus-within .tn-marquee__track {
  animation-play-state: paused;
}
.tn-marquee__item {
  flex: 0 0 auto;
  padding: 0 16px;
}
@keyframes tnMarquee {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .tn-marquee__track { animation: none; }
  .tn-marquee { -webkit-mask-image: none; mask-image: none; overflow-x: auto; }
}

/* -------------------------------------------------------------------------
   WORK SWIPE CAROUSEL — touch-device alternative to .tn-marquee.
   Horizontal scroll with snap, finger-drag, and edge fade.
   ------------------------------------------------------------------------- */
.tn-work__swipe {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 24px 8px;
  cursor: grab;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
}
.tn-work__swipe::-webkit-scrollbar { display: none; }
.tn-work__swipe:active { cursor: grabbing; }
.tn-work__swipe-item {
  flex: 0 0 46vw;
  min-width: 46vw;
  max-width: 46vw;
  /* Clip overflow so absolute children + nowrap text from neighbours don't bleed through */
  overflow: hidden;
}
@media (max-width: 480px) {
  .tn-work__swipe-item { flex-basis: 62vw; min-width: 62vw; max-width: 62vw; }
}
/* Inside the swipe carousel, hide the meta row below each card —
   the card image already has the title + tag, and "OPEN CASE" was overflowing on phones. */
.tn-work__swipe-item .tn-blob-stage + div { display: none !important; }
/* Shrink the in-image text so long client names ("Foodello / Fiksuruoka", "Runo Hotel Porvoo")
   don't wrap into 3 lines or overflow the small swipe card. */
.tn-work__swipe-item .tn-blob-stage > div:last-child > div:last-child {
  font-size: 18px !important;
  line-height: 1.15 !important;
  word-break: break-word;
}
.tn-work__swipe-item .tn-meta { font-size: 9px !important; }
/* Hide the year corner inside swipe cards — leaves just the file id top-left + title bottom-left */
.tn-work__swipe-item .tn-work-card__year { display: none !important; }

/* Logo wall — static 4-up grid (wraps to 2-up on narrow viewports). Smaller
   cells than the marquee version. We use grayscale only (no brightness shift)
   so logos that are already dark stay legible; the transparency softens
   contrast so the wall reads as one rhythm rather than 8 fighting marks. */
.tn-logo-wall {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.tn-logo-cell {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.tn-logo-cell img {
  max-width: 100%;
  max-height: 56px;
  object-fit: contain;
  /* Some source logos are square PNGs with internal whitespace; we scale them
     up so the visible mark roughly matches the tightly-cropped logos. The
     cell clips any overflow. */
  transform: scale(var(--tn-logo-scale, 1));
  transform-origin: center;
  opacity: 0.85;
  transition: opacity var(--dur-base) var(--ease-out);
}
.tn-logo-cell:hover img { opacity: 1; }

@media (max-width: 760px) {
  .tn-logo-wall { grid-template-columns: repeat(2, 1fr); }
}
