/*
 * Site-wide base styles. Feature CSS (pagy, slimselect, actiontext, chapters_reader,
 * sweetal2, adsense_slots) is linked from the layout via Layout::StylesheetsHelper#page_stylesheets.
 */

/* Montserrat variable (300–900), self-hosted Google Fonts subsets. Browsers fetch only subsets the page uses. */
@font-face {
  font-family: Montserrat;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/assets/montserrat-cyrillic-ext-667bbf34.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: Montserrat;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/assets/montserrat-cyrillic-49925ed2.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Montserrat;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/assets/montserrat-latin-ext-fa47cc46.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: Montserrat;
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/assets/montserrat-latin-9322ad4f.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Local fonts resized to Montserrat's metrics so the swap does not reflow text. */
@font-face {
  font-family: "Montserrat Fallback Segoe UI";
  src: local("Segoe UI");
  size-adjust: 113.452%;
  ascent-override: 85.3224%;
  descent-override: 22.1239%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Montserrat Fallback Helvetica Neue";
  src: local("Helvetica Neue");
  size-adjust: 111.778%;
  ascent-override: 86.6004%;
  descent-override: 22.4553%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Montserrat Fallback Roboto";
  src: local("Roboto");
  size-adjust: 111.96%;
  ascent-override: 86.46%;
  descent-override: 22.42%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Montserrat Fallback Arial";
  src: local("Arial");
  size-adjust: 112.831%;
  ascent-override: 85.7923%;
  descent-override: 22.2457%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Montserrat Fallback Noto Sans";
  src: local("Noto Sans");
  size-adjust: 106.118%;
  ascent-override: 91.2191%;
  descent-override: 23.6529%;
  line-gap-override: 0%;
}

@layer base {
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
}

@layer base {
    *,
    ::after,
    ::before,
    ::backdrop,
    ::file-selector-button {
      border-color: var(--color-gray-200, currentColor);
    }
}

/* Expandable Note styles for TinyMCE content */
.note-reference {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-bottom: 1px dotted rgba(8, 145, 178, 0.6);
  color: inherit;
  transition: all 0.2s ease;
}

.dark .note-reference {
  border-bottom-color: rgba(244, 63, 94, 0.6);
}

.note-reference:hover {
  background-color: rgba(8, 145, 178, 0.1);
  border-bottom-color: rgba(8, 145, 178, 1);
}

.dark .note-reference:hover {
  background-color: rgba(244, 63, 94, 0.1);
  border-bottom-color: rgba(244, 63, 94, 1);
}

.note-reference::after {
  content: '📝';
  font-size: 0.7em;
  margin-left: 2px;
  opacity: 0.7;
}

.note-content {
  display: none;
  margin: 8px 0 16px 0;
  padding: 12px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(8, 145, 178, 0.2);
  border-left: 3px solid rgba(8, 145, 178, 0.6);
  border-radius: 4px;
  font-size: 0.9em;
  line-height: 1.4;
  color: rgba(55, 65, 81, 0.9);
  font-style: italic;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .note-content {
  background: rgba(31, 41, 55, 0.95);
  border-color: rgba(244, 63, 94, 0.3);
  border-left-color: rgba(244, 63, 94, 0.6);
  color: rgba(209, 213, 219, 0.9);
}

.note-content.show {
  display: block;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Turbo Drive transitions (Phase 2) --- */

/* Premium progress bar — fades in only when visit exceeds Turbo.setProgressBarDelay */
.turbo-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgb(8 145 178) 0%,
    rgb(244 63 94) 50%,
    rgb(8 145 178) 100%
  );
  background-size: 200% 100%;
  animation: turbo-progress-shimmer 0.9s ease-in-out infinite;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.turbo-progress-bar[style*="width"] {
  opacity: 1;
}

@keyframes turbo-progress-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.turbo-progress-bar--hidden {
  display: none !important;
}

/* Cross-fade on full body swap (skipped when morph handles the visit) */
html.turbo-transitioning body {
  opacity: 0.92;
  transition: opacity 0.12s ease-out;
}

html:not(.turbo-transitioning) body {
  opacity: 1;
  transition: opacity 0.18s ease-in;
}

/* Navbar wrapper must stack above page shells (e.g. fictions/show z-10) and not clip dropdowns */
#site-navbar {
  overflow: visible;
}

/* View Transitions API — page content only (avoid view-transition-name on navbar; it breaks Flowbite dropdowns) */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.2s;
  animation-timing-function: ease-out;
}

/* Pokémon panels folding and unfolding (panel_fold_controller): the card grows while its content keeps its size and
   is clipped, instead of the snapshot stretching */
::view-transition-group(*) {
  animation-duration: 0.35s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

::view-transition-old(.pokemon-panel),
::view-transition-new(.pokemon-panel) {
  width: 100%;
  height: 100%;
  object-fit: none;
  object-position: left top;
}