/* ============================================================
   echohive: Drift app beacon
   A small paper slip, fixed bottom left, that points to /drift.
   Pairs with components/drift_beacon.html and drift-beacon.js.

   Self-contained on purpose: literal colours and font stacks, and
   selectors two classes deep, so it renders the same in the Open
   Ledger shell (where #main swaps --ink and --paper on legacy pages)
   and on standalone experiment pages with their own resets.

   Page-level knobs (set them on the page, never here):
     --drift-beacon-lift   extra bottom offset, e.g. above a toolbar
     --drift-beacon-z      stacking order; the default 90 sits above
                           content, below the shell header (200) and
                           below typical menus and dialogs
   Markup knobs: data-side="right", data-tone="ink" | "paper".
   ============================================================ */

/* ---------- tokens and frame ---------- */
.drift-beacon {
  --db-surface: #fffdf8;
  --db-hover: #f6f3ec;
  --db-ink: #16171a;
  --db-ink-2: #2c2e34;
  --db-muted: #575b63;
  --db-rule: #bfb8a7;
  --db-accent: #1e40af;
  --db-focus: #1e40af;
  --db-cta: #16171a;
  --db-cta-text: #fffdf8;
  --db-cta-hover: #1e40af;
  --db-cta-hover-text: #ffffff;
  --db-shadow: 0 1px 0 rgba(22, 23, 26, .04), 0 18px 34px -22px rgba(22, 23, 26, .45);
  --db-inset: 20px;
  --db-serif: "Iowan Old Style", Charter, "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --db-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  position: fixed;
  z-index: var(--drift-beacon-z, 90);
  top: auto;
  right: auto;
  bottom: calc(var(--db-inset) + var(--drift-beacon-lift, 0px) + env(safe-area-inset-bottom, 0px));
  left: calc(var(--db-inset) + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  max-width: calc(100vw - 2 * var(--db-inset) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  height: auto;
  margin: 0;
  padding: 0;
  float: none;
  overflow: visible;
  background: var(--db-surface);
  color: var(--db-ink);
  border: 1px solid var(--db-rule);
  border-radius: 8px;
  box-shadow: var(--db-shadow);
  font: 400 14px/1.3 var(--db-sans);
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  text-shadow: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;

  /* Resting: tucked 12px low and transparent. Still in the tab order,
     so a keyboard user who tabs past the footer brings it forward. */
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .24s ease, transform .24s ease;
}
.drift-beacon[hidden] { display: none; }
.drift-beacon.is-shown,
.drift-beacon:focus-within {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: opacity .42s cubic-bezier(.2, .7, .2, 1), transform .42s cubic-bezier(.2, .7, .2, 1);
}
/* Off: a menu or dialog is open, typing, zoom, fullscreen, or a control underneath. */
.drift-beacon.is-off {
  visibility: hidden;
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.drift-beacon *,
.drift-beacon *::before,
.drift-beacon *::after { box-sizing: border-box; }

/* ---------- the link: glyph, words, button ---------- */
.drift-beacon .drift-beacon-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 56px;
  margin: 0;
  padding: 9px 10px 9px 14px;
  border: 0;
  border-radius: 7px 0 0 7px;
  background: transparent;
  color: var(--db-ink);
  text-decoration: none;
  transition: background-color .15s ease;
}
.drift-beacon .drift-beacon-link:hover,
.drift-beacon .drift-beacon-link:focus { color: var(--db-ink); text-decoration: none; }

.drift-beacon .drift-beacon-mark {
  display: block;
  flex: none;
  width: 26px;
  height: 26px;
  max-width: none;
  overflow: visible;
  color: var(--db-ink);
}
.drift-beacon-edge {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.drift-beacon-node { fill: currentColor; }
.drift-beacon-stray { fill: currentColor; opacity: .32; }
.drift-beacon-dest { fill: var(--db-accent); }
.drift-beacon-ring { fill: none; stroke: var(--db-accent); stroke-width: 1.2; opacity: 0; }
.drift-beacon-node,
.drift-beacon-dest,
.drift-beacon-ring { transform-box: fill-box; transform-origin: center; }

.drift-beacon .drift-beacon-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.drift-beacon .drift-beacon-name {
  display: block;
  font: 600 13px/1.25 var(--db-sans);
  letter-spacing: .01em;
  color: var(--db-ink);
  white-space: nowrap;
}
.drift-beacon .drift-beacon-line {
  display: block;
  font: 400 17px/1.2 var(--db-serif);
  letter-spacing: -.01em;
  color: var(--db-ink-2);
}

.drift-beacon .drift-beacon-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 36px;
  margin: 0 0 0 4px;
  padding: 0 13px;
  border-radius: 5px;
  background: var(--db-cta);
  color: var(--db-cta-text);
  font: 600 14px/1 var(--db-sans);
  letter-spacing: 0;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.drift-beacon .drift-beacon-arrow { display: inline-block; transition: transform .15s ease; }

/* ---------- the stub: hide for this visit ---------- */
.drift-beacon .drift-beacon-close {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  min-width: 44px;
  height: auto;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0 7px 7px 0;
  background: transparent;
  box-shadow: none;
  color: var(--db-muted);
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color .15s ease, background-color .15s ease;
}
/* the perforation between ticket and stub */
.drift-beacon .drift-beacon-close::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  border-left: 1px dashed var(--db-rule);
}
.drift-beacon .drift-beacon-close svg {
  display: block;
  width: 10px;
  height: 10px;
  max-width: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* ---------- focus, hover, press ---------- */
.drift-beacon .drift-beacon-link:focus-visible,
.drift-beacon .drift-beacon-close:focus-visible {
  outline: 3px solid var(--db-focus);
  outline-offset: -4px;
}
@media (hover: hover) {
  .drift-beacon .drift-beacon-link:hover { background: var(--db-hover); }
  .drift-beacon .drift-beacon-link:hover .drift-beacon-cta { background: var(--db-cta-hover); color: var(--db-cta-hover-text); }
  .drift-beacon .drift-beacon-link:hover .drift-beacon-arrow { transform: translateX(3px); }
  .drift-beacon .drift-beacon-close:hover { background: var(--db-hover); color: var(--db-ink); }
}
.drift-beacon .drift-beacon-link:active .drift-beacon-cta { background: var(--db-cta-hover); color: var(--db-cta-hover-text); }

/* punctuation for screen readers only */
.drift-beacon .drift-beacon-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- ink tone: dark scenes, and article pages whose reading column is dark ---------- */
.drift-beacon[data-tone="ink"],
.writing-page .drift-beacon:not([data-tone]) {
  --db-surface: #16171a;
  --db-hover: #202229;
  --db-ink: #f5f2eb;
  --db-ink-2: #e2ddd1;
  --db-muted: #b9bdc7;
  --db-rule: rgba(245, 242, 235, .22);
  --db-accent: #9fb3ff;
  --db-focus: #ffffff;
  --db-cta: #f5f2eb;
  --db-cta-text: #16171a;
  --db-cta-hover: #9fb3ff;
  --db-cta-hover-text: #16171a;
  --db-shadow: 0 18px 34px -20px rgba(0, 0, 0, .75);
}

/* ---------- right side, for pages whose bottom left is taken ---------- */
.drift-beacon[data-side="right"] {
  left: auto;
  right: calc(var(--db-inset) + env(safe-area-inset-right, 0px));
}

/* ---------- compact: phones, and short landscape viewports ---------- */
@media (max-width: 560px), (max-height: 480px) {
  .drift-beacon { --db-inset: 12px; }
  .drift-beacon .drift-beacon-link { gap: 9px; min-height: 52px; padding: 7px 8px 7px 10px; }
  .drift-beacon .drift-beacon-mark { width: 22px; height: 22px; }
  .drift-beacon .drift-beacon-name { font-size: 12.5px; }
  .drift-beacon .drift-beacon-line { font-size: 15px; }
  .drift-beacon .drift-beacon-cta { min-height: 34px; margin-left: 0; padding: 0 10px; font-size: 13px; }
  .drift-beacon .drift-beacon-arrow { display: none; }
}
@media (max-width: 359px) {
  .drift-beacon .drift-beacon-mark { display: none; }
}

/* ---------- first reveal of a visit: the little map draws itself once ---------- */
.drift-beacon.is-pulsing .drift-beacon-node-a { animation: drift-beacon-pop .3s cubic-bezier(.2, .7, .2, 1) .3s both; }
.drift-beacon.is-pulsing .drift-beacon-edge-ab { animation: drift-beacon-draw .4s ease-out .48s both; }
.drift-beacon.is-pulsing .drift-beacon-node-b { animation: drift-beacon-pop .3s cubic-bezier(.2, .7, .2, 1) .8s both; }
.drift-beacon.is-pulsing .drift-beacon-edge-bc { animation: drift-beacon-draw .45s ease-out .92s both; }
.drift-beacon.is-pulsing .drift-beacon-dest { animation: drift-beacon-pop .34s cubic-bezier(.2, .7, .2, 1) 1.3s both; }
/* no fill mode: the ring stays invisible before and after its one pass */
.drift-beacon.is-pulsing .drift-beacon-ring { animation: drift-beacon-ring 1.1s cubic-bezier(.2, .7, .2, 1) 1.5s; }

@keyframes drift-beacon-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes drift-beacon-pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }
@keyframes drift-beacon-ring { from { opacity: .55; transform: scale(1); } to { opacity: 0; transform: scale(2.8); } }

/* ---------- reduced motion (ledger.css already does this on shell pages) ---------- */
@media (prefers-reduced-motion: reduce) {
  .drift-beacon,
  .drift-beacon * { animation: none !important; transition: none !important; }
}

/* ---------- forced colours, print, fullscreen display ---------- */
@media (forced-colors: active) {
  .drift-beacon { border-color: CanvasText; }
  .drift-beacon .drift-beacon-cta { border: 1px solid currentColor; }
  .drift-beacon-dest { fill: CanvasText; }
  .drift-beacon-ring { stroke: CanvasText; }
}
@media print, (display-mode: fullscreen) {
  .drift-beacon { display: none !important; }
}

/* Cinematic scenes use their own menu instead of a floating overlay. */
.scene-nav nav .drift-scene-link { color: #c9efd4; font-weight: 700; }
