/* ============================================================
   storyforkehlani — reader tools
   Contents + search panel, share sheet, type size, sleep timer.
   Everything here borrows the page's own tokens (--noc-glass,
   --noc-cyan, --sfk-ink) so it reads as part of the room, not
   as chrome bolted on top.
   ============================================================ */

:root { --sfk-read-scale: 1; }

/* the story's measure follows the reader's chosen size */
.sfk-story { font-size: calc(1.19rem * var(--sfk-read-scale)); }
@media (max-width: 640px) { .sfk-story { font-size: calc(1.05rem * var(--sfk-read-scale)); } }

/* ---------------- the dock button ---------------- */

.sfk-tools-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  background: var(--noc-glass, rgba(255, 255, 255, 0.6));
  border: 1px solid rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: rgba(27, 27, 31, 0.8);
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.sfk-tools-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; }
.sfk-tools-btn:hover { border-color: rgba(15, 126, 156, 0.5); color: #1B1B1F; }
.sfk-tools-btn:focus-visible { outline: 2px solid var(--noc-cyan, #0F7E9C); outline-offset: 3px; }

/* ---------------- scrim + panel ---------------- */

.sfk-scrim {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(20, 20, 26, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
body.sfk-panel-open .sfk-scrim { opacity: 1; pointer-events: auto; }

.sfk-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 610;
  width: min(420px, 100vw);
  display: flex;
  flex-direction: column;
  background: rgba(250, 250, 252, 0.94);
  border-left: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: -30px 0 70px -40px rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  transform: translateX(102%);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
body.sfk-panel-open .sfk-panel { transform: translateX(0); }

.sfk-panel-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 0.9rem 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.sfk-find {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.8);
  font-family: inherit;
  font-size: 0.92rem;
  color: #26262A;
  -webkit-appearance: none;
  appearance: none;
}
.sfk-find::placeholder { color: rgba(38, 38, 42, 0.45); }
.sfk-find:focus { outline: none; border-color: rgba(15, 126, 156, 0.6);
  box-shadow: 0 0 0 3px rgba(15, 126, 156, 0.12); }

.sfk-panel-x {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(38, 38, 42, 0.55);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.sfk-panel-x:hover { color: #1B1B1F; background: rgba(0, 0, 0, 0.05); }

.sfk-panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.5rem 0 1.2rem;
}

.sfk-panel-label {
  padding: 0.9rem 1.1rem 0.45rem;
  font-family: var(--mono, monospace);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(38, 38, 42, 0.45);
}

/* ---------------- contents ---------------- */

.sfk-toc { list-style: none; margin: 0; padding: 0; }

.sfk-toc button {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  width: 100%;
  padding: 0.5rem 1.1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: rgba(38, 38, 42, 0.78);
  line-height: 1.4;
}
.sfk-toc button:hover { background: rgba(15, 126, 156, 0.07); color: #1B1B1F; }
.sfk-toc button:focus-visible { outline: 2px solid var(--noc-cyan, #0F7E9C); outline-offset: -2px; }

.sfk-toc .t { flex: 1 1 auto; font-size: 0.9rem; }
.sfk-toc .n {
  flex: none;
  font-family: var(--mono, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: rgba(38, 38, 42, 0.4);
}

.sfk-toc li.major button { padding-top: 0.85rem; }
.sfk-toc li.major .t {
  font-family: 'Sentient', var(--serif, Georgia), serif;
  font-size: 1.02rem;
  color: #1F1F26;
}
.sfk-toc li.minor .t { padding-left: 0.9rem; opacity: 0.86; }
.sfk-toc li.cur .t { color: #9A4432; }
.sfk-toc li.cur button::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 1.3em;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(180deg, #B4543E, #C08A3E);
}
.sfk-toc li { position: relative; }

/* ---------------- search results ---------------- */

.sfk-results { display: none; }
body.sfk-searching .sfk-results { display: block; }
body.sfk-searching .sfk-toc,
body.sfk-searching .sfk-hl-wrap,
body.sfk-searching .sfk-toc-label { display: none; }

.sfk-hit {
  display: block;
  width: 100%;
  padding: 0.7rem 1.1rem;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.055);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.5;
  color: rgba(38, 38, 42, 0.72);
}
.sfk-hit:hover { background: rgba(15, 126, 156, 0.07); }
.sfk-hit mark { background: rgba(192, 138, 62, 0.28); color: #1B1B1F; border-radius: 2px; }
.sfk-hit i {
  display: block;
  margin-top: 0.28rem;
  font-family: var(--mono, monospace);
  font-style: normal;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: rgba(38, 38, 42, 0.4);
}
.sfk-none { padding: 1.4rem 1.1rem; color: rgba(38, 38, 42, 0.5); font-size: 0.9rem; }

/* ---------------- panel footer: size + sleep ---------------- */

.sfk-panel-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.1rem calc(0.7rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.5);
}

.sfk-size { display: flex; align-items: center; gap: 0.3rem; }
.sfk-size button {
  width: 34px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-family: inherit;
  color: rgba(38, 38, 42, 0.8);
  line-height: 1;
}
.sfk-size button:hover { border-color: rgba(15, 126, 156, 0.5); color: #1B1B1F; }
.sfk-size button:disabled { opacity: 0.35; cursor: default; }
.sfk-size .sm { font-size: 0.72rem; }
.sfk-size .lg { font-size: 1.02rem; }

.sfk-sleep {
  margin-left: auto;
  height: 32px;
  padding: 0 1.9rem 0 0.7rem;
  border-radius: 9px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  background: rgba(255, 255, 255, 0.75)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23555' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 0.6rem center / 10px 7px;
  font-family: inherit;
  font-size: 0.78rem;
  color: rgba(38, 38, 42, 0.8);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.sfk-sleep.armed { border-color: rgba(15, 126, 156, 0.55); color: #0F7E9C; }

/* ---------------- share sheet ---------------- */

.sfk-share {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  z-index: 700;
  width: min(440px, calc(100vw - 1.6rem));
  transform: translate(-50%, 130%);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 22px;
  padding: 1.1rem 1.1rem 0.9rem;
  background: rgba(250, 250, 252, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 30px 70px -30px rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  padding-bottom: calc(0.9rem + env(safe-area-inset-bottom));
}
.sfk-share.show { transform: translate(-50%, 0); }

.sfk-share blockquote {
  margin: 0 0 0.95rem;
  padding-left: 0.85rem;
  border-left: 2px solid rgba(180, 84, 62, 0.5);
  font-family: 'Sentient', var(--serif, Georgia), serif;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.5;
  color: #2E2E36;
  max-height: 7.5em;
  overflow: hidden;
}

.sfk-share-acts { display: flex; gap: 0.5rem; }
.sfk-share-acts button {
  flex: 1 1 0;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  color: rgba(38, 38, 42, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.sfk-share-acts button:hover { border-color: rgba(15, 126, 156, 0.55); color: #1B1B1F; }
.sfk-share-acts svg { width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sfk-share-x {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: rgba(38, 38, 42, 0.45);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* ---------------- toast ---------------- */

.sfk-toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 720;
  transform: translate(-50%, 140%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0.62rem 1.1rem;
  border-radius: 999px;
  background: rgba(20, 20, 24, 0.9);
  color: #F2F2F4;
  font-family: var(--mono, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sfk-toast.show { transform: translate(-50%, 0); }

/* ---------------- deep-link landing flash ---------------- */

.sfk-story .w.sfk-flash {
  animation: sfk-flash 2.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  border-radius: 3px;
}
@keyframes sfk-flash {
  0%, 45% { background: rgba(192, 138, 62, 0.34); box-shadow: 0 0 0 3px rgba(192, 138, 62, 0.34); }
  100% { background: transparent; box-shadow: 0 0 0 3px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .sfk-panel, .sfk-scrim, .sfk-share, .sfk-toast { transition: none; }
  .sfk-story .w.sfk-flash { animation-duration: 0.01s; }
}

@media (max-width: 640px) {
  .sfk-panel { width: 100vw; border-left: 0; }
  .sfk-share { border-radius: 18px; }
}

/* ---------------- the two downloads, side by side ---------------- */

.sfk-gets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  margin-top: 1.7rem;
}
.sfk-gets .sfk-pdf { margin-top: 0; }

/* ---------------- highlights ---------------- */

/* one continuous stroke, not a row of blocks: the kept line is a single inline
   <mark>, and box-decoration-break gives each wrapped line its own clean ends */
.sfk-story mark.sfk-hl {
  background: rgba(192, 138, 62, 0.23);
  color: inherit;
  padding: 0.08em 0.12em;
  margin: 0 -0.12em;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.sfk-hl-wrap { border-bottom: 1px solid rgba(0, 0, 0, 0.07); padding-bottom: 0.5rem; }

.sfk-hl-row { display: flex; align-items: flex-start; }

.sfk-hl-go {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.3rem 0.55rem 1.1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: 'Sentient', var(--serif, Georgia), serif;
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.45;
  color: rgba(38, 38, 42, 0.82);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sfk-hl-go:hover { color: #1B1B1F; }
.sfk-hl-go i {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--mono, monospace);
  font-style: normal;
  font-size: 0.6rem;
  color: rgba(38, 38, 42, 0.4);
}

.sfk-hl-x {
  flex: none;
  width: 38px;
  align-self: center;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: rgba(38, 38, 42, 0.35);
}
.sfk-hl-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sfk-hl-x:hover { color: #9A4432; }
