/* Focus mode core: the trigger buttons, the options popup and bionic reading. Option modules style their own parts. */

/* ---------- Trigger buttons ---------- */
.fx-triggers { display: inline-flex; align-items: center; flex-shrink: 0; }
.fx-trigger {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--fg);
  cursor: pointer;
}
.fx-trigger svg { display: block; width: 20px; height: 20px; }
.fx-trigger:hover { color: var(--accent); }
.fx-trigger[aria-expanded="true"] { background: var(--surface); }
/* Focus mode is on: the lamp lights up in the accent. */
.fx-trigger.is-on { color: var(--accent); }

/* Header: the group sits in the icon row; its outer padding is pulled back like .icon-link. */
.fx-at-top { margin: -6px -6px -6px -12px; }
/* Reading bar: right before "more posts". */
.fx-at-bar { margin: 0 -6px; }
/* Under the title, next to "На полку": an outlined group of the same height as that button. */
.fx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.fx-at-head {
  padding: 1px 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}
.fx-at-head:has(.is-on) { border-color: var(--accent); }

/* Phones: the header and the reading bar are crowded (logo, search, shelf, language; logo, title, "more posts"). */
@media (max-width: 640px) {
  .fx-at-top .fx-trigger, .fx-at-bar .fx-trigger { width: 26px; height: 30px; }
  .fx-at-top .fx-trigger svg, .fx-at-bar .fx-trigger svg { width: 18px; height: 18px; }
  .fx-at-top { margin: -6px -4px -6px -8px; }
  .fx-at-bar { margin: 0 -4px; }
}
/* Narrow phones: at 320px the header row has room for logo, the lamp, search, shelf and the language switch. */
@media (max-width: 480px) {
  .top-links:has(.fx-at-top) { gap: 16px; }
}
@media (max-width: 360px) {
  .top-links:has(.fx-at-top) { gap: 10px; }
}

/* ---------- Popup ---------- */
.fx-pop {
  position: absolute;
  z-index: 80;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 12px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  text-align: left;
}
.fx-pop[hidden], .fx-shade[hidden], .fx-tip[hidden], .fx-tuned[hidden], .fx-reset[hidden] { display: none; }
.fx-pop:focus { outline: none; }
.fx-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 0 6px; }
.fx-pop-title { margin: 0; font: 600 24px/1 var(--display); text-transform: uppercase; letter-spacing: 0.01em; }
.fx-pop-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--fg);
  cursor: pointer;
}
.fx-pop-close:hover { border-color: var(--accent); color: var(--accent); }
.fx-pop-lead { margin: 8px 6px 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }

.fx-bulk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px 6px;
  padding: 6px 14px 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--fg);
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.fx-bulk:hover { border-color: var(--fg); }
.fx-bulk-icon { display: grid; }
.fx-bulk-icon svg { width: 18px; height: 18px; }

.fx-rows { display: flex; flex-direction: column; gap: 4px; }
.fx-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.fx-row:hover { border-color: var(--line-strong); }
.fx-row-icon { flex-shrink: 0; display: grid; place-items: center; width: 22px; height: 22px; }
.fx-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fx-row-name { font: 600 15px/1.3 var(--sans); }
.fx-row-hint { font-size: 12.5px; line-height: 1.35; color: var(--muted); }
/* Selected: inverted, light background with dark text and icon. */
.fx-row[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.fx-row[aria-pressed="true"] .fx-row-hint { color: #55524b; }
/* Not possible on this post (no markup yet). */
.fx-row[aria-disabled="true"] { cursor: default; color: var(--muted); background: none; border-color: transparent; }
.fx-row[aria-disabled="true"] .fx-row-icon { opacity: 0.5; }
.fx-row[aria-disabled="true"] .fx-row-hint { font-style: italic; color: #77746d; }

/* One suggestion of the "adapt" profile. */
.fx-tip { margin: 0 6px 14px; padding: 12px 14px; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: 14px; background: var(--surface); }
.fx-tip-text { margin: 0 0 10px; font-size: 13.5px; line-height: 1.45; color: var(--text); }
.fx-tip-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.fx-tip-yes {
  padding: 6px 13px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.fx-tip-no, .fx-reset {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.fx-tip-no:hover, .fx-reset:hover { color: var(--fg); }
.fx-tuned { margin: 12px 6px 2px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.fx-tuned-text { color: var(--soft); }

/* Phones: a bottom sheet over a dimmed page. */
.fx-shade { position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, 0.55); }
.fx-pop.is-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-height: 85vh;
  max-height: 85dvh;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
}

@media (prefers-reduced-motion: no-preference) {
  .fx-trigger { transition: color 0.15s, background-color 0.15s; }
  .fx-row { transition: background-color 0.15s, color 0.15s, border-color 0.15s; }
  .fx-pop.is-in { animation: fx-pop-in 0.16s ease-out; }
  .fx-pop.is-sheet.is-in { animation: fx-sheet-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .fx-shade { animation: fx-fade 0.2s ease-out; }
  @keyframes fx-pop-in { from { opacity: 0; transform: translateY(-4px); } }
  @keyframes fx-sheet-in { from { transform: translateY(100%); } }
  @keyframes fx-fade { from { opacity: 0; } }
}

/* ---------- The weekly hint: a bubble under the lamp ---------- */
.fx-at-head { position: relative; }
.fx-hint {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  width: max-content;
  max-width: min(300px, calc(100vw - 24px));
  background: var(--accent);
  color: #0b0b0b;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
}
/* The arrow points up at the lamp. */
.fx-hint::before {
  content: "";
  position: absolute;
  top: -6px;
  left: calc(var(--ax, 24px) - 6px);
  width: 12px;
  height: 12px;
  background: inherit;
  border-radius: 2px;
  transform: rotate(45deg);
}
.fx-hint-body {
  display: grid;
  gap: 2px;
  padding: 10px 4px 11px 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.fx-hint-body b { font-size: 14px; }
.fx-hint-body span { font-size: 12.5px; line-height: 1.35; opacity: 0.8; }
.fx-hint-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 2px 2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  cursor: pointer;
}
.fx-hint-x:hover { background: rgb(0 0 0 / 0.1); }
.fx-hint button:focus-visible { outline: 2px solid #0b0b0b; outline-offset: -2px; }
/* The lamp the hint points at glows. */
.fx-trigger.is-hinted { color: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .fx-hint { opacity: 0; transform: translateY(6px); transition: opacity 0.25s ease-out, transform 0.25s ease-out; }
  .fx-hint.is-in { opacity: 1; transform: none; }
  .fx-trigger.is-hinted { animation: fx-hint-glow 1.6s ease-in-out infinite; }
  @keyframes fx-hint-glow { 50% { box-shadow: 0 0 0 6px rgb(228 255 58 / 0.18); } }
}

/* ---------- Bionic reading ---------- */
.prose .fx-bio { font-weight: 700; color: var(--fg); }

@media print {
  .fx-triggers, .fx-pop, .fx-shade, .fx-hint { display: none; }
  .prose .fx-bio { font-weight: inherit; }
}
