/* tools.html — Admin Tools (daily member-login codes), black theme. Loads
   after home.css / theme-v2.css / castle.css. One card per guild: the code
   as six mono digit boxes (like index's member-code modal) that roll in
   slot-machine style, a bar draining with what's left of the day, and the
   copy / LINE actions. Card motion follows draft-v2.css (pointer glow, tilt,
   rise-in) plus index's grid walkers, since there are at most 3 cards. */

/* ---- Head: countdown pill ------------------------------------------------ */
.tools-countdown {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--h-card); border: 1px solid var(--h-line); color: var(--h-muted);
  font: 600 13px 'Anuphan', sans-serif; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: border-color .3s, color .3s;
}
.tools-countdown b { color: var(--h-fg); font-size: 14px; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.tools-countdown svg { color: var(--h-fg); }
.tools-countdown.is-soon { border-color: rgba(234, 179, 8, .45); }
.tools-countdown.is-soon :is(b, svg) { color: var(--h-yellow); }
.ico-clock-hand { transform-origin: 12px 12px; animation: tools-hand 60s steps(60) infinite; }
@keyframes tools-hand { to { rotate: 360deg; } }

/* ---- Guild code cards ---------------------------------------------------- */
.tools-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 28px; }
.tools-grid[data-count="1"] { grid-template-columns: minmax(0, 520px); }
.tools-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tools-grid > .draft-empty { grid-column: 1 / -1; }

.tools-code-card {
  --g: 250, 250, 250; --mx: 50%; --my: 0%; --rx: 0deg; --ry: 0deg; --lift: 0px;
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 16px; min-width: 0;
  padding: 24px; border-radius: 26px;
  background: var(--h-mcard-bg); border: 1px solid var(--h-line); color: var(--h-fg);
  font-family: 'Anuphan', sans-serif;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  transition: transform .5s cubic-bezier(.23, 1, .32, 1), border-color .25s, background .25s, box-shadow .4s,
    opacity .7s cubic-bezier(.23, 1, .32, 1), filter .7s;
}
.tools-code-card:hover {
  --lift: -4px; background: var(--h-mcard-hover); border-color: rgba(var(--g), .3);
  box-shadow: 0 24px 48px rgba(0, 0, 0, .5), 0 0 30px rgba(var(--g), .05);
  transition: transform .15s ease-out, border-color .25s, background .25s, box-shadow .4s;
}
/* background grid, faded from the top-left corner (index's .tool) */
.tools-code-card::before {
  content: ''; position: absolute; inset: 0; z-index: -2; pointer-events: none;
  background-image: linear-gradient(var(--h-grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--h-grid-line) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(120% 90% at 0% 0%, #000 20%, transparent 75%); mask-image: radial-gradient(120% 90% at 0% 0%, #000 20%, transparent 75%);
}
.tools-code-card > .m-snake { position: absolute; z-index: -1; }
.tools-code-card:hover .m-snake { opacity: 1; }
.tools-card-glow {
  position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  background: radial-gradient(280px circle at var(--mx) var(--my), rgba(var(--g), .08), transparent 65%);
  opacity: 0; transition: opacity .4s;
}
.tools-card-glow::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: radial-gradient(200px circle at var(--mx) var(--my), rgba(var(--g), .7), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.tools-code-card:hover .tools-card-glow { opacity: 1; }
/* the guild's icon as a big faded watermark in the corner */
.tools-card-mark {
  position: absolute; right: -30px; bottom: -34px; z-index: -1; pointer-events: none;
  color: var(--h-fg); opacity: .045; stroke-width: 1.1;
  transition: transform .8s cubic-bezier(.23, 1, .32, 1), opacity .5s, color .5s;
}
.tools-code-card:hover .tools-card-mark { opacity: .09; transform: rotate(-8deg) scale(1.06); }
.tools-code-card.is-copied .tools-card-mark { color: var(--h-lime); opacity: .12; }

.tools-code-card.rise:not(.risen) { opacity: 0; filter: blur(6px); --lift: 26px; }
.tools-code-card.rise { transition-delay: calc(var(--i, 0) * 90ms); }
.tools-code-card.risen:hover { transition-delay: 0s; }

.tc-top { display: flex; align-items: center; gap: 12px; }
.tc-guild-ico {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(145deg, #1d1d1d, #0e0e0e); border: 1px solid var(--h-line); color: var(--h-fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  transition: rotate .5s cubic-bezier(.34, 1.56, .64, 1), scale .5s cubic-bezier(.34, 1.56, .64, 1);
}
.tools-code-card:hover .tc-guild-ico { rotate: -8deg; scale: 1.08; }
.tc-guild { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tc-guild .picker-kicker { margin: 0; }
.tc-guild b { font-size: 20px; font-weight: 800; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-index { align-self: flex-start; font-size: 11px; font-weight: 600; letter-spacing: .12em; color: var(--h-muted); }
.tc-date { margin-top: -6px; font-size: 13px; font-weight: 600; color: var(--h-muted); }

/* six digit boxes, 3 + 3 */
.tc-digits { display: flex; gap: 8px; }
.tc-digit {
  flex: 1 1 0; min-width: 0; max-width: 64px; aspect-ratio: 5 / 6;
  display: grid; place-items: center;
  font: 800 clamp(22px, 2.2vw, 32px) 'JetBrains Mono', monospace; color: var(--h-fg);
  background: #0c0c0c; border: 1.5px solid var(--h-line); border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: translate .45s cubic-bezier(.34, 1.56, .64, 1), border-color .25s, color .25s, box-shadow .3s;
}
.tc-digit:nth-child(3) { margin-right: 10px; }
.tc-digit.is-rolling { color: var(--h-muted); }
.tc-digit.is-landed { animation: tc-land .45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes tc-land {
  0% { scale: 1.18; border-color: rgba(250, 250, 250, .7); box-shadow: 0 0 18px rgba(255, 255, 255, .15); }
  100% { scale: 1; }
}
/* hover: the digits lift in a wave */
.tools-code-card:hover .tc-digit { translate: 0 -3px; border-color: rgba(250, 250, 250, .22); transition-delay: calc(var(--i) * 35ms); }
/* copied: a lime wave runs across */
.tools-code-card.is-copied .tc-digit { animation: tc-copied .8s cubic-bezier(.23, 1, .32, 1) calc(var(--i) * 55ms) backwards; border-color: var(--h-lime-line); color: var(--h-lime); }
@keyframes tc-copied {
  0% { translate: 0 0; color: var(--h-fg); border-color: var(--h-line); }
  35% { translate: 0 -7px; box-shadow: 0 0 18px rgba(190, 242, 100, .25); }
}

/* what's left of today */
.tc-life-wrap { --life: 1; display: flex; flex-direction: column; gap: 8px; }
.tc-life-text { font-size: 12.5px; font-weight: 600; color: var(--h-muted); }
.tc-life-text b { color: var(--h-fg); font-weight: 800; font-variant-numeric: tabular-nums; }
.tc-life-wrap.is-soon .tc-life-text b { color: var(--h-yellow); }
.tc-life { position: relative; height: 4px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .06); }
.tc-life-bar {
  position: absolute; inset: 0; transform-origin: left; scale: var(--life) 1; border-radius: inherit;
  background: linear-gradient(90deg, #6b6b6b, #fafafa); transition: scale 1s linear, background .4s;
}
.tc-life-bar::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .8), transparent);
  translate: -100% 0; animation: tc-life-shine 3.2s ease-in-out infinite;
}
@keyframes tc-life-shine { 60%, 100% { translate: 100% 0; } }
.tc-life-wrap.is-soon .tc-life-bar { background: linear-gradient(90deg, #7a5a06, var(--h-yellow)); }

.tc-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tc-actions .pill-btn { flex: 1 1 140px; justify-content: center; }

/* tomorrow, locked */
.tc-next {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px dashed var(--h-line);
  font-size: 12.5px; font-weight: 600; color: var(--h-muted);
}
.tc-next-label { display: inline-flex; align-items: center; gap: 7px; }
.tc-next-code { display: inline-flex; gap: 3px; }
.tc-mini {
  display: inline-grid; place-items: center; width: 20px; height: 24px; border-radius: 6px;
  font-size: 13px; font-weight: 800; color: var(--h-fg); background: #0c0c0c; border: 1px solid var(--h-line);
}
.tc-mini.is-masked { color: transparent; position: relative; overflow: hidden; }
.tc-mini.is-masked::before {
  content: ''; position: absolute; inset: 5px 4px; border-radius: 3px;
  background: linear-gradient(90deg, #262626, #4a4a4a, #262626); background-size: 200% 100%;
  animation: tc-mask-shimmer 1.8s linear infinite; animation-delay: calc(var(--i) * 120ms);
}
@keyframes tc-mask-shimmer { to { background-position: -200% 0; } }
.ico-lock-shackle { transition: translate .35s cubic-bezier(.34, 1.56, .64, 1); }
.tc-next:hover .ico-lock-shackle { translate: 0 -2px; }

/* ---- Icon motion for this page's buttons -------------------------------- */
.ico-copy-front, .ico-copy-back { transition: translate .35s cubic-bezier(.34, 1.56, .64, 1); }
.tools-copy-btn:is(:hover, :focus-visible) .ico-copy-front { translate: 1.5px 1.5px; }
.tools-copy-btn:is(:hover, :focus-visible) .ico-copy-back { translate: -1.5px -1.5px; }
.tools-copy-btn .ico-done { display: none; }
.tools-copy-btn.is-done .ico-copy { display: none; }
.tools-copy-btn.is-done .ico-done { display: block; }
.tools-copy-btn.is-done .ico-done path { stroke-dasharray: 1; animation: ico-draw .45s cubic-bezier(.23, 1, .32, 1); }
.tools-line-btn:is(:hover, :focus-visible) .ico-chat-dot { animation: tools-typing .9s ease-in-out infinite; }
.tools-line-btn:is(:hover, :focus-visible) .ico-chat-dot:nth-of-type(3) { animation-delay: .12s; }
.tools-line-btn:is(:hover, :focus-visible) .ico-chat-dot:nth-of-type(4) { animation-delay: .24s; }
@keyframes tools-typing { 0%, 60%, 100% { translate: 0 0; } 30% { translate: 0 -2.5px; } }
#closeLineModal:is(:hover, :focus-visible) .ico-x { rotate: 90deg; }
.ico-x { transform-origin: 12px 12px; }

/* ---- How-to panel -------------------------------------------------------- */
.tools-help.rise:not(.risen) { opacity: 0; filter: blur(6px); translate: 0 26px; }
.tools-help.rise { transition: opacity .7s cubic-bezier(.23, 1, .32, 1), filter .7s, translate .7s cubic-bezier(.23, 1, .32, 1); transition-delay: calc(var(--i, 0) * 90ms); }
.tools-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tools-step {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  padding: 20px; border-radius: 20px; background: var(--h-card); border: 1px solid var(--h-line);
  font-family: 'Anuphan', sans-serif; transition: border-color .25s, background .25s, translate .4s cubic-bezier(.23, 1, .32, 1);
}
.tools-step:hover { border-color: rgba(250, 250, 250, .22); background: var(--h-card-hover); translate: 0 -3px; }
.tools-step-no { position: absolute; top: 18px; right: 20px; font-size: 11px; font-weight: 600; letter-spacing: .12em; color: var(--h-muted); }
.tools-step-ico { color: var(--h-fg); margin-bottom: 4px; overflow: visible; }
.tools-step b { font-size: 16px; font-weight: 800; color: var(--h-fg); }
.tools-step p { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--h-muted); }
.tools-step p b { font-size: inherit; font-weight: 700; }
.ico-key { transform-box: fill-box; transform-origin: 30% 70%; }
.tools-step:hover .ico-key { animation: tools-key-turn .8s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes tools-key-turn { 40% { rotate: -25deg; } 70% { rotate: 8deg; } }
.tools-step:hover .ico-send { animation: tools-send .9s cubic-bezier(.65, 0, .35, 1); }
@keyframes tools-send { 45% { translate: 6px -6px; opacity: 0; } 46% { translate: -6px 6px; opacity: 0; } 100% { translate: 0 0; opacity: 1; } }
.ico-user-check { stroke-dasharray: 1; stroke-dashoffset: 0; }
.tools-step:hover .ico-user-check { animation: ico-draw .6s cubic-bezier(.23, 1, .32, 1); color: var(--h-lime); stroke: var(--h-lime); }

/* ---- LINE message popup -------------------------------------------------- */
.home-v2 .tools-line-box { width: min(480px, 100%); max-width: 480px; padding: 24px; }
.tools-line-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.tools-line-head .picker-kicker { margin: 0; }
.tools-line-title { margin: 2px 0 0; font: 800 20px 'Anuphan', sans-serif; color: var(--h-fg); }
.admin-tools-page .dp-close-btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: #1a1a1a; border: 1px solid var(--h-line); color: #d4d4d4; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.admin-tools-page .dp-close-btn:hover { background: #262626; border-color: rgba(250, 250, 250, .25); color: var(--h-fg); }
/* the message as a chat bubble, tail at the bottom-left */
.tools-line-bubble {
  position: relative; padding: 16px 18px; border-radius: 20px 20px 20px 6px;
  background: #151515; border: 1px solid var(--h-line);
}
.modal-overlay.open .tools-line-bubble { animation: tools-bubble-in .55s cubic-bezier(.34, 1.4, .64, 1) .12s backwards; }
@keyframes tools-bubble-in { from { opacity: 0; scale: .9; translate: -8px 10px; } }
.tools-line-bubble .line-message-pre {
  margin: 0; padding: 0; background: none; border: 0; white-space: pre-wrap; word-break: break-word;
  font: 500 14px/1.75 'Anuphan', sans-serif; color: var(--h-fg);
}
.tools-line-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.modal-overlay.open .tools-line-actions > * { animation: pop-rise .45s cubic-bezier(.23, 1, .32, 1) .24s backwards; }

/* ---- Responsive / reduced motion ---------------------------------------- */
@media (max-width: 1100px) {
  .tools-grid, .tools-grid[data-count="2"] { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .tools-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .tools-steps { grid-template-columns: 1fr; }
  .tools-code-card { padding: 18px; }
  .tc-digits { gap: 6px; }
  .tc-digit:nth-child(3) { margin-right: 6px; }
  .tools-countdown { height: 36px; padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tools-code-card, .tools-help.rise, .tc-digit, .tc-guild-ico, .tools-card-mark, .tools-step { transition: none; }
  .tools-code-card.rise:not(.risen) { opacity: 1; filter: none; --lift: 0px; }
  .tools-help.rise:not(.risen) { opacity: 1; filter: none; translate: none; }
  .ico-clock-hand, .tc-life-bar::after, .tc-mini.is-masked::before, .tc-digit, .tools-line-bubble,
  .tools-line-actions > *, .tools-step svg *, .tools-step svg, .ico-chat-dot, .ico-done path { animation: none !important; }
  .tools-code-card:hover .tc-digit, .tools-step:hover { translate: none; }
}
