/* ============================================================
   Quest System — shared styles for the fishing-line quest scroll.
   Include on every page with:
     <link rel="stylesheet" href="quest-system.css">

   All custom properties are prefixed --qs- so they can never
   collide with a page's own :root tokens (this site already
   defines --ink, --ink-soft, etc. — reusing those names here
   would silently overwrite them site-wide).
   ============================================================ */

:root {
  --qs-parchment: #ecdfb8;
  --qs-parchment-dark: #d3bd88;
  --qs-parchment-edge: #8b6f47;
  --qs-rope: #5c4128;
  --qs-rope-light: #7a5a38;
  --qs-wax: #a63d40;
  --qs-wax-dark: #7a2e30;
  --qs-text: #2c2416;
  --qs-text-soft: #6b5b3a;
  --qs-title: #3a2e18;
  --qs-done-bg: #7a8a52;
  --qs-done-border: #5f6f3d;
  --qs-done-check: #f4ecd8;
  --qs-font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --qs-font-body: 'Spectral', Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --qs-parchment: #d8c290;
    --qs-parchment-dark: #b89e68;
    --qs-parchment-edge: #4a3720;
    --qs-rope: #3a2818;
    --qs-rope-light: #5a4228;
    --qs-wax: #8f3336;
    --qs-wax-dark: #641f22;
  }
}
:root[data-theme="dark"] {
  --qs-parchment: #d8c290;
  --qs-parchment-dark: #b89e68;
  --qs-parchment-edge: #4a3720;
  --qs-rope: #3a2818;
  --qs-rope-light: #5a4228;
  --qs-wax: #8f3336;
  --qs-wax-dark: #641f22;
}

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Spectral:ital,wght@0,400;0,500;0,600;1,400&display=swap');

/* ---------- Fishing rig (rope + closed scroll) ----------
   The container sits fixed at the anchor point (under the brand
   name in the site header) and never transforms except when
   flying off-screen on a reel-up. The rope's curve and the hook's
   position are redrawn every frame in JS from two plain numbers —
   an offsetX (how far sideways, tracking the cursor 1:1 while
   dragging) and a length (how far down it hangs). */
.fish-rig {
  position: fixed;
  display: none;
  z-index: 900;
  pointer-events: none;
}
.fish-rig.reel-up {
  transition: transform 0.5s cubic-bezier(0.6,0,0.85,0.25), opacity 0.42s ease-in 0.06s;
}
.fish-rope {
  position: absolute;
  top: 0; left: 0;
  overflow: visible;
  pointer-events: none;
}

.hook-scroll {
  position: absolute;
  top: 0; left: 0;
  width: 66px;
  height: 80px;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
  transition: filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}
.hook-scroll svg { display: block; pointer-events: none; }
.hook-hit-area {
  position: absolute;
  top: 0;
  left: -5px;
  right: -5px;
  bottom: 17px; /* roughly: top of the hook down to the bottom of the scroll body, +5px */
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.hook-hit-area:active { cursor: grabbing; }
.hook-hit-area:hover ~ svg .scroll-body { filter: brightness(1.05); }

.hook-scroll.armed {
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35)) drop-shadow(0 0 9px rgba(166,61,64,0.85));
}

/* "Click me to unfold" pulse — runs continuously while the closed
   scroll is just hanging there waiting, and stops the instant the
   visitor actually touches it (drag, open, or reel-away all count).
   Targets the SVG scroll-body GROUP rather than the outer .hook-scroll
   element, because JS continuously drives .hook-scroll's own inline
   transform (rope tilt) every frame — animating that same property
   via CSS here would fight with it. The group's own transform
   attribute (translate(0,32)) has to be re-stated inside the keyframes
   too, since a CSS transform animation on an SVG element overrides its
   presentation attribute rather than composing with it. */
@keyframes qsHookPulse {
  0%, 100% { transform: translate(0, 32px) scale(1); }
  50% { transform: translate(0, 32px) scale(1.08); }
}
.hook-scroll.qs-pulse .scroll-body {
  transform-origin: 50px 37px;
  animation: qsHookPulse 1.7s ease-in-out infinite;
}

/* ---------- Open quest scroll (draggable + resizable) ---------- */
.quest-scroll {
  position: fixed;
  display: none;
  flex-direction: column;
  width: min(340px, 84vw);
  min-width: 230px;
  max-width: 92vw;
  min-height: 180px;
  max-height: 85vh;
  transform: translate(-50%, 0) scaleY(1);
  transform-origin: top center;
  z-index: 950;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,0.4));
  user-select: none;
}
.quest-scroll.dragging { transition: none !important; cursor: grabbing; }

/* Eight invisible resize handles along the edges/corners, like a
   normal resizable window. Each just sets the OS resize cursor and
   starts a drag in its own direction(s) on pointerdown. */
.resize-handle { position: absolute; z-index: 20; }
.resize-handle.n { top: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.resize-handle.s { bottom: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.resize-handle.e { top: 12px; right: -4px; bottom: 12px; width: 8px; cursor: ew-resize; }
.resize-handle.w { top: 12px; left: -4px; bottom: 12px; width: 8px; cursor: ew-resize; }
.resize-handle.ne { top: -4px; right: -4px; width: 16px; height: 16px; cursor: nesw-resize; }
.resize-handle.nw { top: -4px; left: -4px; width: 16px; height: 16px; cursor: nwse-resize; }
.resize-handle.se { bottom: -4px; right: -4px; width: 16px; height: 16px; cursor: nwse-resize; }
.resize-handle.sw { bottom: -4px; left: -4px; width: 16px; height: 16px; cursor: nesw-resize; }

.pin {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d9605f, var(--qs-wax) 55%, var(--qs-wax-dark) 100%);
  border: 1px solid rgba(0,0,0,0.35);
  box-shadow: 0 3px 6px rgba(0,0,0,0.4);
  z-index: 10;
  pointer-events: none; /* decorative only — the whole scroll drags */
}
.pin::after {
  content: "";
  position: absolute;
  top: 3px; left: 5px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
}

.scroll-cap {
  flex: none;
  height: 16px;
  border-radius: 50% / 60%;
  background: linear-gradient(180deg, var(--qs-parchment-dark), var(--qs-parchment-edge));
  border: 1px solid rgba(0,0,0,0.25);
}
.scroll-cap.top { margin-bottom: -5px; }
.scroll-cap.bottom { margin-top: -5px; }

.scroll-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    repeating-linear-gradient(0deg, rgba(139,111,71,0.05) 0px, rgba(139,111,71,0.05) 2px, transparent 2px, transparent 4px),
    linear-gradient(135deg, var(--qs-parchment), var(--qs-parchment-dark));
  border-left: 1px solid rgba(0,0,0,0.15);
  border-right: 1px solid rgba(0,0,0,0.15);
  color: var(--qs-text);
  padding: 13px 15px 16px;
  cursor: grab;
  font-family: var(--qs-font-body);
}
.quest-scroll.dragging .scroll-panel { cursor: grabbing; }

.scroll-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(139,111,71,0.4);
  padding-bottom: 10px;
  margin-bottom: 10px;
  gap: 6px;
}
.scroll-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--qs-font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--qs-title);
}
.scroll-header-title svg { width: 15px; height: 15px; flex: none; }

.rollup-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(122,46,48,0.08);
  border: 1px solid rgba(122,46,48,0.35);
  color: #7a2e30;
  font-family: var(--qs-font-body);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s ease;
  flex: none;
}
.rollup-btn:hover { background: rgba(122,46,48,0.16); }
.rollup-btn svg { width: 12px; height: 12px; }
.rollup-btn:focus-visible { outline: 2px solid #7a2e30; outline-offset: 2px; }

/* ---------- Main / Side tabs ---------- */
.quest-tabs {
  flex: none;
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(139,111,71,0.25);
}
.quest-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--qs-font-display);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--qs-text-soft);
  padding: 6px 3px 7px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.quest-tab:hover { color: var(--qs-title); }
.quest-tab.active { color: var(--qs-title); border-bottom-color: #7a2e30; }

/* Scrollable area so a shorter resize clips the list, not the header,
   tabs, or footer hint underneath it. */
.quest-list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.quest-list { list-style: none; margin: 0; padding: 0; }
.quest-list[hidden] { display: none; }
.quest-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 6px 0;
  border-top: 1px solid rgba(139,111,71,0.2);
}
.quest-list li:first-child { border-top: none; }
.quest-check {
  width: 14px; height: 14px;
  flex: none;
  margin-top: 1px;
  border-radius: 3px;
  border: 1.5px solid var(--qs-parchment-edge);
  display: flex;
  align-items: center;
  justify-content: center;
}
.quest-check.done { background: var(--qs-done-bg); border-color: var(--qs-done-border); }
.quest-check.done::after {
  content: "";
  width: 7px;
  height: 4.5px;
  border-left: 1.8px solid var(--qs-done-check);
  border-bottom: 1.8px solid var(--qs-done-check);
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}
.quest-name { font-weight: 600; }
.quest-list li.is-done .quest-text {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-color: rgba(44,36,22,0.4);
}
.side-quest-name { font-style: italic; font-weight: 600; }

/* One-time "this just happened" flash on whichever quest completed and
   triggered the scroll to drop. JS also removes this class a few
   seconds after render, so it genuinely only shows up once — reopening
   the log later (or switching tabs away and back) never reapplies it. */
@keyframes qsQuestGlow {
  0%, 100% { background: transparent; box-shadow: 0 0 0 rgba(166,61,64,0); }
  50% { background: rgba(166,61,64,0.14); box-shadow: 0 0 0 3px rgba(166,61,64,0.3); }
}
.quest-list li.qs-highlight-once {
  animation: qsQuestGlow 1.1s ease-in-out 3;
  border-radius: 6px;
  margin: 0 -6px;
  padding-left: 6px;
  padding-right: 6px;
}

.grab-hint {
  flex: none;
  text-align: center;
  font-size: 10.5px;
  color: var(--qs-text-soft);
  margin-top: 12px;
  opacity: 0.8;
}

/* Second Glance (secret): a full, uninterrupted hover spin.
   No visual affordance beforehand — it should feel found, not
   signposted. Applied to the "|" separator in the brand block. */
@keyframes qsFullSpin { to { transform: rotate(360deg); } }
.qs-spin-target { display: inline-block; }
.qs-spin-target.qs-spinning { animation: qsFullSpin 2.4s linear; }

@media (prefers-reduced-motion: reduce) {
  .fish-rig.reel-up, .quest-scroll {
    animation: none !important;
    transition-duration: 0.01s !important;
  }
  .hook-scroll.qs-pulse .scroll-body,
  .quest-list li.qs-highlight-once {
    animation: none !important;
  }
}
