/* Page CSS for siliconarcana.com. The design kit under assets/ carries the system. This file holds
   only what sits inside a visual and the kit lacks: the animated logo on the hero's stage. */

/* ---- The logo: the painted underwing and the Register wordmark ------------------------------------
   The moth stands still and sharp. The wordmark beside it drifts out of focus, flickers, and
   snaps back. All motion is CSS. It stops under
   prefers-reduced-motion and when the pause control is pressed.
   Tune the loop with --sa-period and the depth of the blur with --sa-soft. */
.hero__stage.sa-logo {
  --sa-teal: #1fd6c2; --sa-violet: #9a6bff; --sa-paper: #eef2ef; --sa-amber: #e8a13a;
  --sa-period: 11s;
  --sa-soft: clamp(5px, 0.7cqw, 10px);
  --sa-off: 9px;
  --sa-slip-1: 14.2px; --sa-slip-2: -9px;
  container-type: inline-size;
}
.sa-logo > .sa-logo__word {
  --sa-depth: 1;
  position: absolute; display: block; height: auto; overflow: visible;
  animation: sa-focus var(--sa-period) cubic-bezier(0.4, 0, 0.2, 1) infinite,
             sa-flicker var(--sa-period) steps(1, end) infinite;
}
/* wide screens: the moth on the left half, the wordmark from the middle to the right line */
@media (min-width: 1024px) {
  .sa-logo > img.is-cutout { inset: 0 auto 0 0; width: 50%; padding: 1% 0; }
  .sa-logo > .sa-logo__word { left: 52%; width: 48%; top: 50%; translate: 0 -50%; }
}
/* tablets and phones: the moth above, the wordmark under it */
@media (max-width: 1023px) {
  .sa-logo > img.is-cutout { inset: 0 0 auto 0; height: 74%; padding: 0; }
  .sa-logo > .sa-logo__word { left: 0; bottom: 0; width: 100%; }
}
/* the wordmark powers on once at load; the moth is never animated */
.sa-logo__word > :is(g, .sa-kana, .sa-stamp) { animation: sa-power 1.6s steps(1, end) both; }
.sa-bloom { fill: var(--sa-teal); opacity: 0.35; }
.sa-ch { mix-blend-mode: screen; }
.sa-ch--teal { fill: var(--sa-teal); transform: translateX(calc(var(--sa-off) * -1));
  animation: sa-split-teal var(--sa-period) cubic-bezier(0.4, 0, 0.2, 1) infinite; }
.sa-ch--violet { fill: var(--sa-violet); transform: translateX(var(--sa-off));
  animation: sa-split-violet var(--sa-period) cubic-bezier(0.4, 0, 0.2, 1) infinite; }
.sa-ch--paper { fill: var(--sa-paper); }
.sa-slip--1 { transform: translateX(var(--sa-slip-1)); animation: sa-slip-1 5.3s steps(1, end) infinite; }
.sa-slip--2 { transform: translateX(var(--sa-slip-2)); animation: sa-slip-2 3.9s steps(1, end) infinite; }
.sa-kana { fill: var(--sa-teal); }
.sa-stamp { fill: var(--sa-amber); }
.sa-logo.is-paused, .sa-logo.is-paused * { animation-play-state: paused !important; }

/* Focus: sharp, a slow drift out, a hard snap back with a hot frame, then one short relapse. */
@keyframes sa-focus {
  0%, 34%    { filter: blur(0) brightness(1); }
  43%        { filter: blur(calc(var(--sa-depth) * var(--sa-soft) * 0.4)) brightness(0.93); }
  50%        { filter: blur(calc(var(--sa-depth) * var(--sa-soft) * 0.9)) brightness(0.86); }
  53.5%      { filter: blur(calc(var(--sa-depth) * var(--sa-soft))) brightness(0.8); }
  55%        { filter: blur(calc(var(--sa-depth) * var(--sa-soft) * 0.08)) brightness(1.28); }
  56.5%, 80% { filter: blur(0) brightness(1); }
  82.5%      { filter: blur(calc(var(--sa-depth) * var(--sa-soft) * 0.5)) brightness(0.9); }
  84%        { filter: blur(0) brightness(1.14); }
  85%, 100%  { filter: blur(0) brightness(1); }
}
/* Flicker: hard cuts where the focus goes, never more than three in any one second. */
@keyframes sa-flicker {
  0%    { opacity: 1; }    40%   { opacity: 0.6; }  40.7% { opacity: 1; }
  44.5% { opacity: 0.3; }  45.3% { opacity: 0.9; }
  48.5% { opacity: 0.22; } 49.2% { opacity: 0.82; }
  52.8% { opacity: 0.12; } 53.6% { opacity: 0.7; }  55%   { opacity: 1; }
  82%   { opacity: 0.35; } 82.7% { opacity: 1; }    100%  { opacity: 1; }
}
/* The two registers pull apart as focus goes, and meet for one frame at the snap. */
@keyframes sa-split-teal {
  0%, 34%   { transform: translateX(calc(var(--sa-off) * -1)); }
  50%, 53.5% { transform: translateX(calc(var(--sa-off) * -3.4)); }
  55%       { transform: translateX(0); }
  58%, 80%  { transform: translateX(calc(var(--sa-off) * -1)); }
  82.5%     { transform: translateX(calc(var(--sa-off) * -2.3)); }
  84%, 100% { transform: translateX(calc(var(--sa-off) * -1)); }
}
@keyframes sa-split-violet {
  0%, 34%   { transform: translateX(var(--sa-off)); }
  50%, 53.5% { transform: translateX(calc(var(--sa-off) * 3.4)); }
  55%       { transform: translateX(0); }
  58%, 80%  { transform: translateX(var(--sa-off)); }
  82.5%     { transform: translateX(calc(var(--sa-off) * 2.3)); }
  84%, 100% { transform: translateX(var(--sa-off)); }
}
/* The slipped bands twitch on their own clocks, so the loop never lines up the same way twice in a row. */
@keyframes sa-slip-1 {
  0%   { transform: translateX(var(--sa-slip-1)); }
  31%  { transform: translateX(calc(var(--sa-slip-1) * -0.7)); }
  34%  { transform: translateX(var(--sa-slip-1)); }
  72%  { transform: translateX(calc(var(--sa-slip-1) * 2)); }
  74%  { transform: translateX(0); }
  76%  { transform: translateX(var(--sa-slip-1)); }
  100% { transform: translateX(var(--sa-slip-1)); }
}
@keyframes sa-slip-2 {
  0%   { transform: translateX(var(--sa-slip-2)); }
  18%  { transform: translateX(calc(var(--sa-slip-2) * 2.4)); }
  21%  { transform: translateX(var(--sa-slip-2)); }
  63%  { transform: translateX(calc(var(--sa-slip-2) * -1.2)); }
  66%  { transform: translateX(var(--sa-slip-2)); }
  100% { transform: translateX(var(--sa-slip-2)); }
}
/* Power on, once, when the page loads. */
@keyframes sa-power {
  0%  { opacity: 0; }   8%  { opacity: 0.6; }  11% { opacity: 0; }   24% { opacity: 0.85; }
  28% { opacity: 0.15; } 41% { opacity: 1; }   46% { opacity: 0.4; } 52% { opacity: 1; } 100% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sa-logo, .sa-logo *, .sa-navword { animation: none !important; }
}

/* ---- Frames the kit leaves to the page ------------------------------------------------------------- */
/* the world's key art: a 16:9 frame that takes what one screen leaves under the heading */
#overlay .frame { --ratio: 56.25%; }
/* the studio's split stacks on a tablet: a wider crop keeps the section one screen */
@media (min-width: 640px) and (max-width: 1023px) { #studio .frame { --ratio: 50%; } }
/* the name set across the close, from the left line to the right line at every width */
.close--word { container-type: inline-size; }
.close--word .close__word { font-size: 15.9cqw; }
.close--word .close__word { line-height: 1.04; overflow: visible; }
/* a phone: the key art as a tall crop, so the screen ends on the picture */
@media (max-width: 639px) { #overlay .frame { --ratio: 120%; } }
/* where the wordmark sits under the moth, the pause control moves to the stage's top corner */
@media (max-width: 1023px) { .sa-logo > .loop-pause { top: 12px; bottom: auto; } }
/* a tablet held upright: taller pictures, so each screen is filled */
@media (min-width: 640px) and (max-width: 1023px) {
  #overlay .frame { --ratio: 90%; }
}
/* a phone: the footer keeps to one screen */
@media (max-width: 639px) { .closing__links .footer__lede { display: none; } .closing__links { gap: var(--s-5); } }
/* the narrowest phones: the studio section takes two screens */
@media (max-width: 359px) { #studio { --hm: 2; } }
@media (min-width: 640px) and (max-width: 1023px) and (min-height: 1100px) { #overlay .frame { --ratio: 105%; } }
@media (max-width: 639px) { .close--word .close__word { line-height: 0.86; } }

/* ---- The nav logo: the Register wordmark, small, on a failing tube ----------------------------------
   It borrows the lettering from the hero's SVG and runs its own flicker: steady, then a short
   stutter, a sag, one more blink. The pause control and reduced motion both rest it. */
.nav__logo svg.sa-navword {
  height: 18px; width: auto; overflow: visible; flex: none;
  filter: drop-shadow(0 0 5px rgb(31 214 194 / 0.4));
  animation: sa-fault 7.3s steps(1, end) infinite;
}
.sn-ch { mix-blend-mode: screen; }
.sn-ch--teal { fill: #1fd6c2; transform: translateX(-12px); }
.sn-ch--violet { fill: #9a6bff; transform: translateX(12px); }
.sn-ch--paper { fill: #eef2ef; }
.sa-still .sa-navword { animation: none; }
@keyframes sa-fault {
  0%    { opacity: 1; }
  41%   { opacity: 0.35; }  41.8% { opacity: 1; }
  43.4% { opacity: 0.2; }   44%   { opacity: 0.9; }
  45.1% { opacity: 0.4; }   46.6% { opacity: 1; }
  78%   { opacity: 0.75; }  84%   { opacity: 1; }
  91%   { opacity: 0.3; }   91.7% { opacity: 1; }
  100%  { opacity: 1; }
}

/* ---- Buttons -------------------------------------------------------------------------------------- */
html[data-buttons] .btn.btn--primary {
  background: #2b4c3e;
  padding: 0 24px;
  border-radius: 8px;
  color: #f7f8f6;
  font: 500 13px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
}
html[data-buttons] .btn.btn--primary:hover { background: #37594a; }
html[data-buttons] .btn.btn--primary:active { background: #243f34; }
/* the second button: the same shape as a plain outline */
html[data-buttons] .btn.btn--secondary {
  padding: 0 20px;
  border: 1px solid color-mix(in oklab, var(--ink) 34%, transparent); border-radius: 8px;
  background: none; text-decoration: none;
  color: var(--ink);
  font: 500 13px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
}
html[data-buttons] .btn.btn--secondary:hover { background: color-mix(in oklab, var(--bg) 90%, var(--ink)); text-decoration: none; }
/* the pause control beside the nav logo: it stills the flicker and the hero loop from any screen */
.nav__bar > .loop-pause.sa-navpause { position: static; flex: none; margin-left: 12px; box-shadow: none; }
/* the narrowest phones: a smaller wordmark, so the logo, the pause control and the menu fit the bar */
@media (max-width: 359px) {
  .nav__logo svg.sa-navword { height: 13px; }
  .nav__bar > .loop-pause.sa-navpause { margin-left: 6px; }
}
