/* Tonalux homepage. Each block carries its area colour in --c / --c-rgb. */

.home-block[data-area="tools"]   { --c: #83baff; --c-rgb: 131, 186, 255; }
.home-block[data-area="deals"]   { --c: #88d4b0; --c-rgb: 136, 212, 176; }
.home-block[data-area="journal"] { --c: #bba0ed; --c-rgb: 187, 160, 237; }
.home-block[data-area="studio"]  { --c: #9bbfdd; --c-rgb: 155, 191, 221; }

/* ---------- Hero: the field fills the first screen, the title floats above the horizon ---------- */
.home-hero {
  position: relative;
  isolation: isolate;
  height: clamp(340px, 44vh, 420px);
  overflow: hidden;
}
.hero-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s ease;
  touch-action: pan-y;
}
html[data-hero-field="ready"] .hero-field { opacity: 1; }
/* The field fades out towards the top, so the overscroll bounce shows a soft edge instead of a
   hard line. A gradient in the page colour on top of the field does this; a CSS mask on the
   animated canvas cost Safari a full re-composite every frame. */
.home-hero-fade {
  position: absolute;
  inset: 0 0 auto;
  height: 130px;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, var(--bg-primary) 0, rgba(8, 9, 12, 0.6) 35%, rgba(8, 9, 12, 0) 100%);
}
/* The light from under the header (page-system.css) sits over the particles. */
html[data-section="home"] main .home-hero::before { z-index: 1; }
.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(34% 30% at 50% calc(50% + 39px), rgba(8, 9, 12, 0.72), rgba(8, 9, 12, 0) 100%),
    linear-gradient(180deg, rgba(8, 9, 12, 0) 80%, var(--bg-primary) 100%);
}
/* Text never gets in the way of the field: no selection, clicks go through. */
.home-hero-inner {
  position: absolute;
  top: calc(50% + 39px);
  translate: 0 -50%;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 0 1.5rem;
  text-align: center;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.hx-title {
  font-size: clamp(3rem, 7vw, 5.6rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
/* One text run, so the font's kerning stays intact; the padding keeps the gradient from
   clipping the last letter's overhang. The header logo uses the same style (page-system.css). */
.hx-word {
  padding: 0 0.06em;
  background: linear-gradient(180deg, #ffffff 35%, #a9cfff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hx-sub {
  margin-top: 1.1rem;
  color: #aeb6c3;
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  letter-spacing: 0.01em;
}
.hero-motion-toggle {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(8, 9, 12, 0.5);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}
.hero-motion-toggle:hover, .hero-motion-toggle:focus-visible { opacity: 1; color: var(--text-primary); border-color: rgba(131, 186, 255, 0.5); }
.hero-motion-toggle svg { width: 14px; height: 14px; fill: currentColor; }
.hero-motion-toggle .i-play, .hero-motion-toggle[data-state="paused"] .i-pause { display: none; }
.hero-motion-toggle[data-state="paused"] .i-play { display: block; }

/* ---------- Blocks ---------- */
.home-block { position: relative; padding: 6rem 4rem; }
.home-block::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(55% 45% at 88% 0%, rgba(var(--c-rgb), 0.07), transparent 70%);
}
.home-block + .home-block { border-top: 1px solid var(--border); }
.home-hero + .home-block { padding-top: 3.5rem; }
.home-inner { position: relative; max-width: 1100px; margin: 0 auto; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2.25rem; }
.home-head .section-label { color: var(--c); }
.home-title { font-size: clamp(1.7rem, 3vw, 2.35rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.home-lede { max-width: 430px; color: var(--text-secondary); font-size: 0.98rem; line-height: 1.6; }
.home-lede a, .home-more { color: var(--c); font-weight: 500; text-decoration: none; white-space: nowrap; }
.home-lede a:hover, .home-more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Tools */
.ht-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ht-card, .hd-card, .hl-card, .hd-link {
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: border-color 0.3s, transform 0.3s;
}
.ht-card:hover, .hd-card:hover, .hl-card:hover, .hd-link:hover { border-color: rgba(var(--c-rgb), 0.4); transform: translateY(-2px); }
.ht-card { display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; }
.ht-visual {
  position: relative;
  height: 170px;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(90% 120% at 50% 100%, rgba(var(--c-rgb), 0.16), transparent 70%), #0b0e14;
}
.ht-visual svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ht-visual .tv-dim { opacity: 0.55; }
.ht-body { display: flex; flex: 1; flex-direction: column; gap: 10px; padding: 22px 22px 24px; }
.ht-body h3 { font-size: 1.2rem; font-weight: 600; }
.ht-body p { color: var(--text-secondary); font-size: 0.93rem; line-height: 1.65; }
.ht-link { margin-top: auto; padding-top: 4px; color: var(--c); font-size: 0.88rem; font-weight: 500; }

/* Deals */
.hd-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.hd-card { display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; }
.hd-grid.is-loaded .hd-card { animation: hd-in 0.5s ease both; }
.hd-grid.is-loaded .hd-card:nth-child(2) { animation-delay: 0.06s; }
.hd-grid.is-loaded .hd-card:nth-child(3) { animation-delay: 0.12s; }
.hd-grid.is-loaded .hd-card:nth-child(4) { animation-delay: 0.18s; }
@keyframes hd-in { from { opacity: 0; transform: translateY(8px); } }
.hd-img { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #0b0e14; }
.hd-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.hd-card:hover .hd-img img { transform: scale(1.04); }
.hd-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--c);
  color: #06140d;
  font-size: 0.78rem;
  font-weight: 700;
}
.hd-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; }
.hd-dev { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.hd-name {
  display: -webkit-box;
  min-height: 2.7em;
  overflow: hidden;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.hd-price { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.hd-price b { color: var(--c); font-size: 1.08rem; }
.hd-price s { color: var(--text-muted); font-size: 0.85rem; }
.hd-skel {
  aspect-ratio: 0.78;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(100deg, #111318 30%, #171b23 50%, #111318 70%) 0 0 / 220% 100%;
  animation: hd-shimmer 1.4s linear infinite;
}
@keyframes hd-shimmer { to { background-position: -220% 0; } }
.hd-grid.is-empty { display: none; }
.hd-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.hd-link { display: flex; align-items: center; gap: 18px; padding: 20px 22px; border-radius: 16px; }
.hd-num {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(var(--c-rgb), 0.1);
  border: 1px solid rgba(var(--c-rgb), 0.25);
  color: var(--c);
  font-size: 1.25rem;
  font-weight: 700;
}
.hd-link b { display: block; font-size: 1.05rem; font-weight: 600; }
.hd-link small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 0.88rem; line-height: 1.5; }
.hd-link i { margin-left: auto; color: var(--c); font-style: normal; font-size: 1.1rem; }

/* Blog */
.hl-grid { display: grid; grid-template-columns: 1.3fr 1fr; grid-template-rows: auto auto; gap: 16px; }
.hl-card { display: flex; overflow: hidden; border-radius: 16px; }
.hl-feature { grid-row: span 2; flex-direction: column; }
.hl-img { flex-shrink: 0; overflow: hidden; background: #0b0e14; }
.hl-feature .hl-img { aspect-ratio: 1200 / 630; }
.hl-card:not(.hl-feature) .hl-img { width: 40%; }
.hl-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.hl-card:hover .hl-img img { transform: scale(1.04); }
.hl-body { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 18px 20px 20px; }
.hl-meta { color: var(--c); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.hl-body h3 { font-size: 1.05rem; font-weight: 600; line-height: 1.35; }
.hl-feature .hl-body { padding: 22px 24px 26px; }
.hl-feature .hl-body h3 { font-size: 1.45rem; line-height: 1.25; }
.hl-body p { color: var(--text-secondary); font-size: 0.93rem; line-height: 1.6; }

/* Studio */
.hs-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 30px 40px;
  padding: 36px 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(115deg, rgba(var(--c-rgb), 0.08), transparent 60%), var(--bg-card);
}
.hs-photo {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(var(--c-rgb), 0.35);
  box-shadow: 0 0 40px rgba(var(--c-rgb), 0.15);
}
.hs-text p { max-width: 620px; margin-top: 10px; color: var(--text-secondary); font-size: 0.98rem; line-height: 1.65; }
.hs-text .home-more { display: inline-block; margin-top: 14px; font-size: 0.92rem; }
.hs-logos {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px 72px;
  margin: 0;
  padding: 26px 8px 0;
  border-top: 1px solid var(--border);
  list-style: none;
}
.hs-logos img { display: block; width: auto; height: var(--logo-h, 34px); filter: brightness(0) invert(1); opacity: 0.72; }

/* Newsletter sits on the same rhythm as the blocks */
.newsletter { border-top: 1px solid var(--border); }

/* ---------- Entrances ----------
   page-experience.js stages every target with .tx-in and --tx-delay; on the homepage these rules
   swap the generic fade for richer keyframes. Reduced motion keeps every effect that does not
   move anything: focus pulls out of blur, lines that draw themselves.
   A blur repaints its element on the main thread every frame. The homepage has few cards, so it
   keeps a short, light one; image brightness is composited and costs nothing. */
@keyframes home-focus { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: blur(0); } }
@keyframes home-fade { from { opacity: 0; } }
@keyframes hx-wipe {
  from { opacity: 0; filter: blur(10px); clip-path: inset(-20% 100% -20% -20%); }
  to { opacity: 1; filter: blur(0); clip-path: inset(-20% -20% -20% -20%); }
}
@keyframes tv-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes img-focus { from { filter: brightness(0.45); } }

/* Hero: the title sweeps in out of blur; the line follows in the normal sequence. */
html.tx main .home-hero .hx-title.tx-in {
  animation-name: hx-wipe !important;
  animation-duration: 1.15s !important;
  animation-timing-function: cubic-bezier(0.25, 0.7, 0.2, 1) !important;
}

/* Blocks: everything comes into focus card by card; the tool visuals build themselves. */
html.tx main .home-block :is(.home-head, .ht-card, .hd-link, .hl-card, .hs-card).tx-in {
  animation-name: home-focus !important;
  animation-duration: 0.8s !important;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1) !important;
}
html.tx main .home-block .hd-grid.tx-in { animation: none !important; }
.hd-grid > :nth-child(2) { --n: 1; }
.hd-grid > :nth-child(3) { --n: 2; }
.hd-grid > :nth-child(4) { --n: 3; }
html.tx main .hd-grid.tx-in > * {
  animation: home-focus 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
  animation-delay: calc(var(--tx-delay, 0ms) + var(--n, 0) * 90ms);
}
html.tx main .hd-grid.tx-in .hd-img img {
  animation: img-focus 1.2s ease backwards;
  animation-delay: calc(var(--tx-delay, 0ms) + var(--n, 0) * 90ms);
}
html.tx main .hl-card.tx-in .hl-img img {
  animation: img-focus 1.2s ease backwards;
  animation-delay: var(--tx-delay, 0ms);
}
html.tx main .ht-card.tx-in :is(.tv-bar, .tv-meter) {
  animation: home-fade 0.7s ease backwards;
  animation-delay: calc(var(--tx-delay, 0ms) + 260ms + var(--i, 0) * 18ms);
}
html.tx main .ht-card.tx-in .tv-meter { animation-delay: calc(var(--tx-delay, 0ms) + 700ms); }
html.tx main .ht-card.tx-in .tv-draw {
  stroke-dasharray: 1;
  animation: tv-draw 1.6s cubic-bezier(0.45, 0, 0.2, 1) backwards;
  animation-delay: calc(var(--tx-delay, 0ms) + 300ms);
}
html.tx main .ht-card.tx-in .tv-late { animation-delay: calc(var(--tx-delay, 0ms) + 650ms); }
html.tx main .hs-card.tx-in .hs-logos li {
  animation: home-fade 0.8s ease backwards;
  animation-delay: calc(var(--tx-delay, 0ms) + 350ms + var(--i, 0) * 110ms);
}

/* ---------- Tool cards on hover ----------
   Each visual plays what its tool does. Written after the entrance rules (same specificity
   plus the card's href), so hovering takes over once the card has arrived. */
@keyframes tv-dance { from { transform: scaleY(0.5); } to { transform: scaleY(1.38); } }
@keyframes tv-ab {
  0%, 42%, 100% { transform: none; }
  50%, 92% { transform: translateY(24px); }
}
@keyframes tv-ka { 0%, 42%, 100% { fill: #0b0e14; } 50%, 92% { fill: #9ca3b0; } }
@keyframes tv-kb { 0%, 42%, 100% { fill: #9ca3b0; } 50%, 92% { fill: #0b0e14; } }
@keyframes tv-wa { 0%, 42%, 100% { opacity: 1; } 50%, 92% { opacity: 0.4; } }
@keyframes tv-wb { 0%, 42%, 100% { opacity: 0.55; } 50%, 92% { opacity: 1; } }
@keyframes tv-play { from { transform: translateX(-126px); } to { transform: translateX(112px); } }
@keyframes tv-flow {
  0% { stroke-dashoffset: 0.12; opacity: 0; }
  12% { opacity: 1; }
  85% { opacity: 1; }
  100% { stroke-dashoffset: -1; opacity: 0; }
}
@keyframes tv-hub { from { transform: scale(1); } to { transform: scale(1.14); } }
@keyframes tv-out {
  0%, 45%, 100% { stroke-opacity: 0.3; fill: #0b0e14; }
  15% { stroke-opacity: 1; fill: rgba(131, 186, 255, 0.2); }
}
.ht-card .tv-bar, .ht-card .tv-hub, .ht-card .tv-knob { transform-box: fill-box; }
.ht-card[href="/analyzer"] .tv-bar { transform-origin: 50% 100%; }
.ht-card .tv-hub { transform-origin: 50% 50%; }
.ht-card .tv-limit { transition: stroke-opacity 0.3s ease; }

/* Analyzer: the spectrum plays; whatever rises over the limit line turns red. */
/* The bars also carry the entrance (home-fade). It stays in the list, so leaving the card does not
   restart it: a removed and re-added animation name would replay the whole fade-in. */
:is(html, html.tx) main .ht-card[href="/analyzer"]:is(:hover, :focus-visible) .tv-bar {
  animation: home-fade 0.7s ease backwards, tv-dance 0.62s ease-in-out infinite alternate;
  animation-delay: calc(var(--tx-delay, 0ms) + 260ms + var(--i, 0) * 18ms), calc(var(--i, 0) * -137ms);
}
:is(html, html.tx) main .ht-card[href="/analyzer"]:is(:hover, :focus-visible) .tv-limit { stroke-opacity: 0.45; }

/* Comparer: the playhead runs and the switch flips between mix and reference. */
:is(html, html.tx) main .ht-card[href="/comparer"]:is(:hover, :focus-visible) .tv-play { animation: tv-play 3.2s linear infinite; }
:is(html, html.tx) main .ht-card[href="/comparer"]:is(:hover, :focus-visible) .tv-knob { animation: tv-ab 3.2s cubic-bezier(0.5, 0, 0.2, 1) infinite; }
:is(html, html.tx) main .ht-card[href="/comparer"]:is(:hover, :focus-visible) .tv-ka { animation: tv-ka 3.2s steps(1) infinite; }
:is(html, html.tx) main .ht-card[href="/comparer"]:is(:hover, :focus-visible) .tv-kb { animation: tv-kb 3.2s steps(1) infinite; }
:is(html, html.tx) main .ht-card[href="/comparer"]:is(:hover, :focus-visible) .tv-wave-a { animation: tv-wa 3.2s ease infinite; }
:is(html, html.tx) main .ht-card[href="/comparer"]:is(:hover, :focus-visible) .tv-wave-b { animation: tv-wb 3.2s ease infinite; }

/* Converter: signal flows from the sources through the hub into each format in turn. */
.ht-card .tv-pulse { stroke-dasharray: 0.12 1; stroke-dashoffset: 0.12; opacity: 0; }
:is(html, html.tx) main .ht-card[href="/tools"]:is(:hover, :focus-visible) .tv-pulse {
  animation: tv-flow 1.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  animation-delay: calc(var(--i, 0) * 0.25s);
}
:is(html, html.tx) main .ht-card[href="/tools"]:is(:hover, :focus-visible) .tv-hub { animation: tv-hub 0.6s ease-in-out infinite alternate; }
:is(html, html.tx) main .ht-card[href="/tools"]:is(:hover, :focus-visible) .tv-out {
  animation: tv-out 1.8s ease infinite;
  animation-delay: calc(var(--i, 0) * 0.3s);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .home-head { flex-direction: column; align-items: flex-start; gap: 0.9rem; }
  .ht-grid, .hl-grid, .hd-more { grid-template-columns: 1fr; }
  .hd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hl-feature { grid-row: auto; }
  .ht-card { flex-direction: row; }
  .ht-visual { flex: 0 0 38%; height: auto; min-height: 170px; border-bottom: 0; border-right: 1px solid var(--border); }
}
@media (max-width: 768px) {
  /* Narrow screens: the text block is taller relative to the hero, so the shade under it grows. */
  .home-hero::after {
    background:
      radial-gradient(70% 30% at 50% calc(50% + 39px), rgba(8, 9, 12, 0.78), rgba(8, 9, 12, 0) 100%),
      linear-gradient(180deg, rgba(8, 9, 12, 0) 80%, var(--bg-primary) 100%);
  }
  .home-block { padding: 4.5rem 1.5rem; }
  .hs-card { grid-template-columns: 1fr; justify-items: center; padding: 30px 22px; text-align: center; }
  .hs-text p { margin-left: auto; margin-right: auto; }
  .hs-logos { flex-wrap: wrap; justify-content: center; gap: 20px 36px; width: 100%; }
}
@media (max-width: 560px) {
  .ht-card { flex-direction: column; }
  .ht-visual { flex: none; height: 150px; border-right: 0; border-bottom: 1px solid var(--border); }
  .hd-grid { gap: 12px; }
  .hd-body { padding: 12px; }
  .hd-name { font-size: 0.9rem; }
  .hl-card:not(.hl-feature) { flex-direction: column; }
  .hl-card:not(.hl-feature) .hl-img { width: 100%; aspect-ratio: 1200 / 630; }
  .hero-motion-toggle { right: 16px; bottom: 16px; }
}
