/* ============================================================
   Tock — the Beale Clock Tower, as a guide.

   The mark in the masthead is the tower drawn as an institution;
   Tock is the same tower drawn as a person. Both are on screen at
   once, so this has to sit in the app's own palette (paper, brass,
   a hairline rule) rather than arrive as a cartoon pasted on top.

   The button lives above the scan dock rather than beside it: the
   dock's job is "go to the map", and a second full-width control
   next to it would read as an equal choice, which it isn't.
   ============================================================ */

.tock-fab {
  position: fixed;
  right: max(16px, var(--safe-right));
  /* Clears the scan dock: 16px inset + a 44px button + 16px of air. */
  bottom: calc(76px + var(--safe-bottom));
  z-index: 41;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  /* The right pad is the space Tock stands in. He is positioned, not a flex
     child, so the pill's height comes from the label alone and the artwork
     can be resized without moving the button. */
  padding: 10px 58px 10px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--brass);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  /* Tock's spire and his raised hand break the top of the pill on purpose —
     that overhang is what makes him read as a character standing there
     rather than an icon inside a chip. */
  overflow: visible;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.tock-fab:active {
  transform: scale(.96);
  border-color: var(--brass-deep);
}

.tock-fab-avatar {
  position: absolute;
  right: 9px;
  /* Feet a hair below the pill's edge, so he reads as standing in front of
     it rather than pasted onto it. */
  bottom: -3px;
  width: 40px;
  height: 68px;
  pointer-events: none;
}
.tock-fab-avatar img {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  transform-origin: 50% 100%;
  /* Grounds him on the pill. Kept neutral rather than tinted, since the
     pill behind him is near-white in light mode and near-black in dark. */
  filter: drop-shadow(0 2px 4px rgba(28, 24, 21, .4));
}

/* Entrance only — the resting state is the rule above, never the keyframes.
   An `animation: … both` here would leave him invisible in a backgrounded
   tab, which is exactly how the portal's scrub FAB broke once. */
@keyframes tock-arrive {
  from { opacity: 0; transform: translateY(14px) scale(.9); }
  to   { opacity: 1; transform: none; }
}
.tock-fab.is-new {
  animation: tock-arrive .55s cubic-bezier(.22, .8, .28, 1);
}

/* A slow lean, so he's alive without demanding attention. Killed outright
   by the global prefers-reduced-motion block in base.css. */
@keyframes tock-lean {
  0%, 88%, 100% { transform: rotate(0deg); }
  92%           { transform: rotate(-5deg); }
  96%           { transform: rotate(4deg); }
}
.tock-fab-avatar img { animation: tock-lean 7s ease-in-out infinite; }

/* ---------- The video ---------- */

.tock-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
}
.tock-modal.is-open { display: block; }

.tock-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 11, 8, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s ease;
}
.tock-modal.is-open .tock-modal-backdrop { opacity: 1; }

.tock-modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(100% - 28px, 560px);
  max-height: calc(100svh - 28px);
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .28s ease;
}
.tock-modal.is-open .tock-modal-card { opacity: 1; }

.tock-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 12px;
}
.tock-modal-head .eyebrow { margin: 0; }
.tock-modal-head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.15;
}
.tock-modal-head .sub {
  display: block;
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
}

.tock-close {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--paper-2);
  color: var(--ink);
  transition: background-color .18s ease;
}
.tock-close:active { background: var(--paper-3); }
.tock-close svg { width: 20px; height: 20px; }

.tock-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #0d0a07;
  /* The corner radius is on the element, so the painted video has to be
     clipped to it too — Safari won't do that for a bare <video>. */
  overflow: hidden;
  object-fit: cover;
}

.tock-note {
  margin: 10px 2px 2px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-3);
}

/* Landscape phones: the card is height-bound, so drive the video off the
   viewport height instead and let the width follow. */
@media (max-height: 460px) {
  .tock-modal-card { width: min(100% - 28px, 760px); }
  .tock-video { aspect-ratio: auto; height: min(58svh, 300px); }
}
