/* ===== Help: the ? bottom right, and the chat it opens =====================
   The button is the bug button's twin: same size, ring and lift. */
.lafterHelp { position: fixed; right: 20px; bottom: 20px; z-index: 9998; }
.helpBtn {
    width: 46px; height: 46px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--gold);
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, color 0.15s ease;
}
.helpBtn:hover, .helpBtn[aria-expanded="true"] { transform: scale(1.08); color: var(--gold-light); }
@media (max-width: 640px) { .helpBtn { width: 42px; height: 42px; } }
.helpMask {
    display: block; flex: none;
    /* Wider than the button so the question marks drift round the mask, and
       the mask itself is the size the ring used to be. */
    width: 72px; height: 72px;
    fill: none; stroke: currentColor; stroke-width: 0.8; stroke-linecap: round; stroke-linejoin: round;
    overflow: visible;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.55));
}
.helpMask .helpQ { stroke-width: 0.6; }
/* Filled, so it reads as a button rather than a drawing on the page. */
.helpMask .helpMaskFace { fill: var(--bg-card); }
.helpBtn:hover .helpMaskFace { fill: color-mix(in srgb, var(--gold) 10%, var(--bg-card)); }
.helpMask .helpQ circle { fill: currentColor; stroke: none; }
/* The question marks drift, each on its own time, so it never looks like a loop. */
.helpQ > * { animation: helpDrift 4.2s ease-in-out infinite; transform-box: fill-box; }
.helpQ.q2 > * { animation-duration: 5.1s; animation-delay: -1.7s; }
.helpQ.q3 > * { animation-duration: 4.7s; animation-delay: -3.1s; }
@keyframes helpDrift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); opacity: 0.85; }
    33%      { transform: translate(0.6px, -1.1px) rotate(8deg); opacity: 1; }
    66%      { transform: translate(-0.5px, -0.4px) rotate(-6deg); opacity: 0.7; }
}
@media (prefers-reduced-motion: reduce) { .helpQ > * { animation: none; } }
/* Never opened: a dot, and the button breathes. */
.helpDot {
    position: absolute; top: 0; right: -2px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--notify, var(--red-x));
    box-shadow: 0 0 0 2px var(--bg);
}
.helpDot[hidden] { display: none; }
.helpBtn:has(.helpDot:not([hidden])) .helpMask { animation: helpGlow 2.8s ease-in-out infinite; }
@keyframes helpGlow {
    0%, 100% { filter: drop-shadow(0 2px 5px rgba(0,0,0,0.55)); }
    50%      { filter: drop-shadow(0 2px 5px rgba(0,0,0,0.55)) drop-shadow(0 0 6px color-mix(in srgb, var(--gold) 55%, transparent)); }
}
@media (prefers-reduced-motion: reduce) { .helpMask { animation: none !important; } }

/* A temp session is signed out, so the floating theme switch is up too. */
body:has(#lafterHelp) .themeSwitch--floating { right: 78px; }

.helpPanel {
    overflow: hidden; overscroll-behavior: contain;
    position: absolute; right: 0; bottom: calc(100% + 26px);
    width: min(440px, calc(100vw - 40px));
    height: min(620px, 78vh);
    display: flex; flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--gold-dim);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: helpUp 0.2s ease;
}
.helpPanel[hidden] { display: none; }
@keyframes helpUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.helpPanel.isStill { animation: none; }
@media (prefers-reduced-motion: reduce) { .helpPanel { animation: none; } }
/* A tour has the chat: the conversation steps out until the tour is put down. */
#lafterHelp.isTouring .helpLog .helpMsg:not(.isGuide) { display: none; }
.helpHead { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--border); }
.helpTitle { font-family: var(--font-head); font-size: 1.55rem; color: var(--gold); line-height: 1; }
.helpResume {
    margin-left: auto; margin-right: 10px;
    background: none; border: 1px solid var(--gold-dim); border-radius: 999px;
    padding: 0.22rem 0.7rem; font-family: var(--font-mono); font-size: 0.7rem; color: var(--gold); cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.helpResume:hover { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.helpResume[hidden] { display: none; }
.helpResume.isLanding { animation: helpResumeLand 0.35s ease-out; }
@keyframes helpResumeLand { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
/* The step, put down: it shrinks and slides to the button, then is gone. */
.helpMsg.isTour.isLeaving { transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease; transform-origin: top right; pointer-events: none; }
.helpMsg.isTour.isTour { max-width: 100%; }

.helpLog { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.helpMsg {
    max-width: 88%;
    padding: 8px 11px;
    border-radius: 10px;
    font-family: var(--font-mono); font-size: 0.76rem; line-height: 1.55;
    color: var(--text);
    overflow-wrap: anywhere;
}
.helpMsg.isUser { align-self: flex-end; background: color-mix(in srgb, var(--gold) 12%, transparent); border: 1px solid color-mix(in srgb, var(--gold-dim) 60%, transparent); }
.helpMsg.isBot  { align-self: flex-start; background: var(--overlay-soft); border: 1px solid var(--border); }
.helpMsg.isErr  { align-self: center; background: none; border: none; color: var(--red-x); font-size: 0.7rem; padding: 2px 0; }
.helpMsg a { color: var(--gold); text-decoration: none; }
.helpMsg a:hover { color: var(--gold-light); text-decoration: underline; }
/* Lafter and org names, linked by support.js in their own faces. */
.helpName .wordmark { font-size: 1.2em; line-height: 1; }
.helpMsg a.helpName:hover { text-decoration: none; filter: brightness(1.2); }
.helpMsg ul { margin: 4px 0; padding-left: 16px; }
.helpMsg p { margin: 0 0 6px; }
.helpMsg p:last-child { margin-bottom: 0; }
.helpMsg.isWait { color: var(--text-muted); letter-spacing: 0.2em; }

.helpAsk { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.helpAsk textarea {
    flex: 1; min-width: 0; resize: none;
    box-sizing: border-box; height: 34px; max-height: 88px;   /* four lines, then it scrolls */
    padding: 7px 10px; overflow-y: auto;
    background: var(--overlay-soft); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: var(--font-mono); font-size: 0.76rem; line-height: 1.45;
}
.helpAsk textarea:focus { outline: none; border-color: var(--gold-dim); }
.helpSend {
    width: 34px; height: 34px; padding: 0; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: var(--gold); border: 1px solid var(--gold); border-radius: 8px;
    color: var(--bg); cursor: pointer;
}
.helpSend:disabled { opacity: 0.5; cursor: default; }
.helpSend svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lafterHelp:has(.helpPanel:not([hidden])) { z-index: 100000; }

/* ===== Pointing at the page (src/js/guide.js) =====
   A glow that fades, or a dot that stays until the thing is clicked. */
/* Circled, with an arrow from Feste: a layer over everything, drawn in. */
.guidePointer { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 100002; pointer-events: none; overflow: visible; }
.guidePointer .guideRing, .guidePointer .guideArrow, .guidePointer .guideHead {
    fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--gold) 55%, transparent));
}
.guidePointer .guideRing { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: guideDraw 0.7s ease-out forwards; }
.guidePointer .guideArrow { stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: guideDraw 0.6s ease-out 0.45s forwards; }
.guidePointer .guideHead { opacity: 0; animation: guideShow 0.2s ease-out 1s forwards; }
/* Their pointer on the thing: the line steps back and the ring says so. */
.tourPointer.isThere .guideArrow, .tourPointer.isThere .guideHead { animation: none; stroke-dashoffset: 0; opacity: 0; transition: opacity 0.2s; }
.tourPointer.isThere .guideRing { stroke-width: 3.5; filter: drop-shadow(0 0 10px var(--gold)); }
@keyframes guideDraw { to { stroke-dashoffset: 0; } }
@keyframes guideShow { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .guidePointer .guideRing, .guidePointer .guideArrow { animation: none; stroke-dashoffset: 0; }
    .guidePointer .guideHead { animation: none; opacity: 1; }
}
.guideGlow { animation: guideGlow 1.4s ease-in-out 3; border-radius: inherit; }
@keyframes guideGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0); }
    50% { box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.55), 0 0 18px 4px rgba(201, 168, 76, 0.35); }
}
.hasGuideDot { position: relative; }
.guideDot {
    position: absolute; top: -3px; right: -3px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--gold); box-shadow: 0 0 0 2px var(--bg);
    pointer-events: none;
}

/* ===== Tours (src/js/tour.js) =====
   The card sits bottom centre, out of the way of Feste on the right and the
   bug button on the left. The cursor and the ring float over the page. */
.tourBox, .tourAsk {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 100001;
    width: min(440px, calc(100vw - 32px)); padding: 12px 14px 12px;
    background: var(--bg-card, #140d0d); border: 1px solid var(--gold-dim); border-radius: 10px;
    box-shadow: 0 14px 34px rgba(0,0,0,0.5);
    font-family: var(--font-mono); font-size: 0.78rem; color: var(--text);
    animation: tourIn 0.3s ease-out;
}
.tourBox[hidden] { display: none; }
@keyframes tourIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.tourHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.tourCount { font-size: 0.66rem; color: var(--text-muted); letter-spacing: 0.06em; }
.tourEnd { background: none; border: 0; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 2px; }
.tourEnd:hover { color: var(--text); }
.tourSay, .tourAskLine { margin: 0 0 10px; line-height: 1.55; }
.tourActs { display: flex; flex-wrap: wrap; gap: 6px; }
.tourOpt {
    background: none; border: 1px solid var(--border); border-radius: 999px;
    padding: 0.3rem 0.8rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text); cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tourOpt:hover { border-color: var(--gold-dim); color: var(--gold); }
.tourOpt.isGo { border-color: var(--gold-dim); color: var(--gold); background: color-mix(in srgb, var(--gold) 8%, transparent); }
.tourOpt.isGo:hover { background: color-mix(in srgb, var(--gold) 14%, transparent); }
.tourOpt.isQuiet { border-color: transparent; color: var(--text-muted); }
.tourOpt.isQuiet:hover { color: var(--text); }
/* The thing itself: a ring that stays while its step does, not only the glow. */
/* The thing itself glows, its own shape: no box round it. The ring and the arrow do the pointing. */
.tourTarget { position: relative; z-index: 100000; }
.tourTarget.isGlyph { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--gold) 80%, transparent)) drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 45%, transparent)); }
.tourTarget.isEdge { box-shadow: 0 0 0 1.5px var(--gold), 0 0 12px color-mix(in srgb, var(--gold) 35%, transparent) !important; border-color: var(--gold) !important; }
.tourWordmark { font-size: 1.15em; line-height: 1; }
.tourPointer .guideRing { animation-duration: 0.5s; }
/* The cursor: an arrow that slides to the thing and presses. */
.tourCursor { position: fixed; left: 0; top: 0; z-index: 100003; width: 26px; height: 26px; pointer-events: none; margin: -3px 0 0 -3px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6)); }
.tourCursor[hidden] { display: none; }
.tourCursor svg { width: 100%; height: 100%; fill: var(--gold-light, #e0c56a); stroke: #1a0f0f; stroke-width: 1.4; stroke-linejoin: round; transition: transform 0.12s ease; transform-origin: 20% 15%; }
.tourCursor.isTap svg { transform: scale(0.82); }
.tourRipple {
    position: fixed; z-index: 100002; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
    border: 2px solid var(--gold); pointer-events: none; animation: tourRipple 0.65s ease-out forwards;
}
@keyframes tourRipple { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tourBox, .tourAsk { animation: none; } .tourRipple { display: none; } }
@media (max-width: 640px) { .tourBox, .tourAsk { bottom: 76px; } }
/* Feste's name on the card, with the mask; the step count beside it. */
.tourWho { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 0.9rem; color: var(--gold); }
.tourWho .tourCount { margin-left: 4px; font-family: var(--font-mono); }
.tourMask { width: 18px; height: 18px; fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tourMask .helpQ { display: none; }
.helpMsg.isTour { border-left: 2px solid var(--gold-dim); }
/* The first-visit card: Feste's door. Bigger than a step, since it is the one everybody sees. */
.tourAsk { width: min(600px, calc(100vw - 32px)); padding: 14px 18px 16px; font-size: 0.86rem; }
.tourAsk .tourWho { margin-bottom: 4px; font-size: 1rem; }
.tourAsk .tourAskLine { font-size: 0.92rem; margin-bottom: 12px; }
.tourAsk .tourOpt { font-size: 0.78rem; padding: 0.4rem 0.95rem; }
.tourAskForm { display: flex; gap: 6px; margin-top: 12px; }
.tourAskIn {
    flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
    padding: 0.4rem 0.9rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text);
}
.tourAskIn::placeholder { color: var(--text-muted); }
.tourAskIn:focus { outline: none; border-color: var(--gold-dim); }
/* Choices in the chat, from the card: each starts a tour. */
.helpChips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.helpChip {
    background: none; border: 1px solid var(--gold-dim); border-radius: 999px;
    padding: 0.28rem 0.75rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--gold); cursor: pointer;
}
.helpChip:hover { background: color-mix(in srgb, var(--gold) 12%, transparent); }
.helpMsg.isTour .tourCount { font-size: 0.64rem; color: var(--text-muted); letter-spacing: 0.06em; margin-right: 4px; }
.helpChip.isQuiet { border-color: transparent; color: var(--text-muted); }
.helpChip.isQuiet:hover { color: var(--text); background: none; }
.helpChip.isGo { background: color-mix(in srgb, var(--gold) 10%, transparent); }
/* A first visit: Feste's button pulses until it is opened, with a word beside it. */
/* The mask itself outlined, breathing: no box round it. */
.helpBtn.helpNew .helpMask { animation: helpNew 1.8s ease-in-out infinite; }
@keyframes helpNew {
    0%, 100% { filter: drop-shadow(0 0 0 color-mix(in srgb, var(--gold) 0%, transparent)); stroke-width: 1.6; }
    50% { filter: drop-shadow(0 0 5px var(--gold)) drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 55%, transparent)); stroke-width: 2.1; }
}
.helpHint {
    position: fixed; right: 88px; bottom: 34px; z-index: 99999;
    padding: 5px 11px; border: 1px solid var(--gold-dim); border-radius: 999px;
    background: var(--bg-card); font-family: var(--font-mono); font-size: 0.72rem; color: var(--gold); white-space: nowrap;
    /* In, then three flashes, so the eye lands on it before it goes. */
    animation: helpHintIn 0.3s ease-out, helpFlash 0.8s ease-in-out 0.3s 3;
}
@keyframes helpHintIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes helpFlash {
    0%, 100% { border-color: var(--gold-dim); box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 0%, transparent); }
    50% { border-color: var(--gold-light); box-shadow: 0 0 14px 2px color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 12%, var(--bg-card)); }
}
/* The question in the chat flashes the same way when it first shows. */
.helpMsg.isGuide.isAsk { animation: helpFlash 0.8s ease-in-out 0.2s 2; }
@media (prefers-reduced-motion: reduce) { .helpHint, .helpMsg.isGuide.isAsk { animation: none; } }
@media (prefers-reduced-motion: reduce) { .helpBtn.helpNew .helpMask { animation: none; filter: drop-shadow(0 0 5px var(--gold)); } }
.helpMsg.isGuide { width: 100%; max-width: 100%; }
.helpMsg.isGuide.isAsk { text-align: center; }
.helpMsg.isGuide.isAsk .helpChips { justify-content: center; }
/* Back a step: the arrow before the count. */
.tourBack { display: inline-flex; align-items: center; margin: 0 6px 0 0; padding: 0; background: none; border: 0; color: var(--gold); cursor: pointer; line-height: 1; }
.tourBack:hover { color: var(--text); }
.tourWay { margin: -4px 0 10px; font-size: 0.7rem; color: var(--text-muted); }
.tourTitle { display: block; font-family: var(--font-head); font-size: 1.15rem; line-height: 1.1; color: var(--gold); margin: 2px 0 5px; }
/* Arrow and count sit on the text's baseline, as words on the line do. */
.tourSay .tourBack { display: inline-block; height: auto; vertical-align: baseline; margin: 0 5px 0 0; }
.tourSay .tourBack svg { vertical-align: -0.5px; }
.tourSay .tourCount { vertical-align: baseline; }
.tourHeadRow { display: flex; align-items: center; gap: 6px; margin: 0 0 5px; }
.tourHeadRow .tourBack, .tourHeadRow .tourCount { float: none; height: auto; margin: 0; }
.tourHeadRow .tourTitle { margin: 0; }
.tourLink { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; }
.tourLink:hover { color: var(--gold-light); }
/* The panel grows out of the mask: no gap to speak of, a notch on its
   bottom edge pointing at the button, and the corner above it square. */
.helpPanel { border-bottom-right-radius: 4px; overflow: visible; }
.helpPanel::after { content: ''; position: absolute; right: 16px; bottom: -7px; width: 12px; height: 12px; background: var(--bg-card); border-right: 1px solid var(--gold-dim); border-bottom: 1px solid var(--gold-dim); transform: rotate(45deg); }
.helpPanel > * { position: relative; }
.helpHead { border-top-left-radius: 12px; border-top-right-radius: 12px; }
