/* 투자라이브 logo: the top-left wordmark of every page (the app and the server-rendered article pages).
   Pure CSS on static markup. One 10.5 s loop: 투자라이브 + live dot -> Tooja Live + a chart line that draws itself -> 투라AI + its two candles.
   The words share one grid cell, so the box is always as wide as the widest word and the menu beside it never moves.
   Pointer over the logo pauses it; prefers-reduced-motion shows 투자라이브 and its dot only.
   data-live="off" on the anchor greys the dot (live price stream down); without it the dot is lit.

<a class="brand" href="/" aria-label="투자라이브 홈">
  <span class="tl" aria-hidden="true">
    <span class="tl-w tl-a"><span>투</span><span>자</span><span>라</span><span>이</span><span>브</span><i class="brand-dot"></i></span>
    <span class="tl-w tl-b"><span>T</span><span class="tl-o">o</span><span>o</span><span>j</span><span>a</span><span class="tl-sp"></span><span>L</span><span>i</span><span>v</span><span>e</span><svg class="tl-chart" viewBox="0 0 20 14"><path pathLength="1" d="M1.5 12.2 6.8 6.9l3.6 3.2 6.2-6.3"/><circle cx="17.2" cy="3.2" r="2.1"/></svg></span>
    <span class="tl-w tl-c"><span>투</span><span>라</span><span class="tl-ai">A</span><span>I</span><svg class="tl-cd" viewBox="0 0 16 14"><g class="cd up"><path d="M4.3.6v12.8"/><rect x="2" y="3.2" width="4.6" height="7.6" rx="1"/></g><g class="cd dn"><path d="M11.7.6v12.8"/><rect x="9.4" y="3.2" width="4.6" height="7.6" rx="1"/></g></svg></span>
  </span>
</a>
*/
@font-face {
  font-family: "Tooja Logo";
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url("/fonts/tooja-logo.v2.woff2") format("woff2");
}

.brand {
  /* Tooja Logo = Hahmlet 700 (SIL OFL, renamed subset; fonts/ToojaLogo-OFL.txt).
     Its metrics in em: Hangul bottom and height, Latin cap height */
  --tl-fs: var(--fs-4, 18px);
  --tl-lo: -0.104em;
  --tl-h: 0.9em;
  --tl-cap: 0.761em;
  --tl-t: 10.5s;
  --tl-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  display: inline-flex;
  flex: none;
  align-items: center;
  color: var(--ink, #f2f2f3);
  text-decoration: none;
  white-space: nowrap;
}
.tl {
  display: inline-grid;
  font-family: "Tooja Logo", var(--font-ui, sans-serif);
  font-size: var(--tl-fs);
  font-weight: 400;
  font-synthesis: none;
  line-height: 1;
  letter-spacing: 0;
}
.tl-w {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: baseline;
}
.tl-w > * {
  display: inline-block;
  animation: var(--tl-t) var(--tl-ease) infinite both;
}
.tl-a > * {
  animation-name: tl-a;
}
.tl-b > * {
  animation-name: tl-b;
}
.tl-c > * {
  animation-name: tl-c;
}
/* the letters roll through one after another */
.tl-w > :nth-child(2) { animation-delay: 30ms; }
.tl-w > :nth-child(3) { animation-delay: 60ms; }
.tl-w > :nth-child(4) { animation-delay: 90ms; }
.tl-w > :nth-child(5) { animation-delay: 120ms; }
.tl-w > :nth-child(6) { animation-delay: 150ms; }
.tl-w > :nth-child(7) { animation-delay: 180ms; }
.tl-w > :nth-child(8) { animation-delay: 210ms; }
.tl-w > :nth-child(9) { animation-delay: 240ms; }
.tl-w > :nth-child(10) { animation-delay: 270ms; }
.tl-w > :nth-child(11) { animation-delay: 300ms; }
.tl-sp {
  width: 0.24em;
}
.tl-o {
  margin-left: -0.05em; /* T-o: the kerning the per-letter boxes lose */
}

/* 투자라이브 to 3.2 s · Tooja Live 3.5-7.1 s · 투라AI 7.0-10.2 s: each word melts away in 0.4 s (rising and
   blurring) while the next condenses in from below, letter after letter */
@keyframes tl-a {
  0%, 30.48% { opacity: 1; transform: none; filter: none; }
  34.29% { opacity: 0; transform: translateY(-0.34em) scale(0.96); filter: blur(4px); }
  34.3%, 96.19% { opacity: 0; transform: translateY(0.34em) scale(0.96); filter: blur(4px); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes tl-b {
  0%, 33.33% { opacity: 0; transform: translateY(0.34em) scale(0.96); filter: blur(4px); }
  37.14%, 63.81% { opacity: 1; transform: none; filter: none; }
  67.62%, 100% { opacity: 0; transform: translateY(-0.34em) scale(0.96); filter: blur(4px); }
}
@keyframes tl-c {
  0%, 66.67% { opacity: 0; transform: translateY(0.34em) scale(0.96); filter: blur(4px); }
  70.48%, 93.33% { opacity: 1; transform: none; filter: none; }
  97.14%, 100% { opacity: 0; transform: translateY(-0.34em) scale(0.96); filter: blur(4px); }
}

/* the live dot: while prices stream in it beats (a quick swell and a halo every 1.6 s), and each batch of prices
   that arrives sends a ring out from it */
.tl .brand-dot {
  position: relative;
  width: 0.28em;
  height: 0.28em;
  margin-left: 0.22em;
  bottom: calc(var(--tl-lo) + var(--tl-h) / 2 - 0.14em);
  border-radius: 50%;
  background: var(--up, #f0505e);
  transition: background-color 0.4s;
}
.brand[data-live="off"] .tl .brand-dot {
  background: var(--ink-4, #3d3d40);
}
/* the beat sits on a layer of the dot, so the dot itself keeps its word's fade */
.tl .brand-dot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: brand-beat 1.6s ease-out infinite;
}
.brand[data-live="off"] .tl .brand-dot::before {
  animation: none;
}
@keyframes brand-beat {
  0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--up, #f0505e) 60%, transparent); }
  14% { transform: scale(1.3); }
  32% { transform: scale(1); }
  72%, 100% { transform: scale(1); box-shadow: 0 0 0 0.32em transparent; }
}
.tl .brand-dot::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1.5px solid var(--up, #f0505e);
  border-radius: 50%;
  opacity: 0;
}
.tl .brand-dot[data-ping]::after {
  animation: brand-ping 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes brand-ping {
  from { opacity: 0.9; transform: scale(1); }
  to { opacity: 0; transform: scale(4); }
}

/* Tooja Live: a rising line drawn from the baseline up to cap height, ending in the live dot */
.tl-chart {
  width: calc(var(--tl-cap) * 20 / 14);
  height: var(--tl-cap);
  margin-left: 0.28em;
  overflow: visible;
}
.tl-chart path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  animation: tl-draw var(--tl-t) cubic-bezier(0.45, 0, 0.2, 1) 0.15s infinite both;
}
.tl-chart circle {
  fill: var(--up, #f0505e);
  transform-box: fill-box;
  transform-origin: center;
  animation: tl-tip var(--tl-t) var(--tl-ease) 0.15s infinite both;
}
.brand[data-live="off"] .tl-chart circle {
  fill: var(--ink-4, #3d3d40);
}
@keyframes tl-draw {
  0%, 35.5% { stroke-dashoffset: 1; }
  44%, 100% { stroke-dashoffset: 0; }
}
@keyframes tl-tip {
  0%, 43.5% { transform: scale(0); }
  47%, 100% { transform: none; }
}

/* 투라AI: the two capitals sit a hair apart from the Hangul. Beside them 투라AI's mark, a rising and a falling
   candle that read as a pair of eyes: while the word is up they pull apart once, settle and blink twice */
.tl-ai {
  margin-left: 0.05em;
}
.tl-cd {
  width: calc(var(--tl-cap) * 16 / 14);
  height: var(--tl-cap);
  margin-left: 0.24em;
  overflow: visible;
}
.tl-cd g,
.tl-cd rect {
  transform-box: fill-box;
  transform-origin: center;
}
.tl-cd .up {
  color: var(--up, #f0505e);
}
.tl-cd .dn {
  color: var(--down, #4c8bf5);
}
.tl-cd path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
}
.tl-cd rect {
  fill: currentColor;
}
.tl-cd g {
  animation: tl-cd-blink var(--tl-t) linear infinite both;
}
.tl-cd .up rect {
  animation: tl-cd-up var(--tl-t) cubic-bezier(0.3, 0, 0.2, 1) infinite both;
}
.tl-cd .dn rect {
  animation: tl-cd-dn var(--tl-t) cubic-bezier(0.3, 0, 0.2, 1) infinite both;
}
@keyframes tl-cd-up {
  0%, 73% { transform: none; }
  76.5%, 81% { transform: translateY(-1.8px); }
  84.5%, 100% { transform: none; }
}
@keyframes tl-cd-dn {
  0%, 73% { transform: none; }
  76.5%, 81% { transform: translateY(1.8px); }
  84.5%, 100% { transform: none; }
}
@keyframes tl-cd-blink {
  0%, 85.5% { transform: none; }
  86.4% { transform: scaleY(0.1); }
  87.3%, 89.5% { transform: none; }
  90.4% { transform: scaleY(0.1); }
  91.3%, 100% { transform: none; }
}

.brand:hover .tl *,
.brand:focus-visible .tl * {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .tl-b,
  .tl-c {
    display: none;
  }
  .tl *,
  .tl .brand-dot::before,
  .tl .brand-dot[data-ping]::after {
    animation: none !important;
  }
}
