/*
SPDX-FileCopyrightText: 2026 ursa.nz <code@ursa.nz>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
*/

/* ---- Settings ---------------------------------------------- */
/* Defaults at zero specificity. Override any of them on .made-with-ursa. */
:where(.made-with-ursa) {
  --made-with-ursa-ink: #1C211F;
  --made-with-ursa-ink-soft: #4B5550;
  --made-with-ursa-paper: #FFFDF8;
  --made-with-ursa-shadow: #F5C443;
  --made-with-ursa-hover: #B23F1B;
  --made-with-ursa-underline: #D9532B;
  --made-with-ursa-font: "Atkinson Hyperlegible", "Helvetica Neue", Arial, sans-serif;
  --made-with-ursa-text: 0.9375rem;
  --made-with-ursa-size: 40px;
  --made-with-ursa-bubble-width: 66px;
  --made-with-ursa-border: 2px;
  --made-with-ursa-gap: 8px;
  --made-with-ursa-tap: 48px;
  --made-with-ursa-right: max(16px, env(safe-area-inset-right));
  --made-with-ursa-bottom: max(16px, env(safe-area-inset-bottom));
  --made-with-ursa-lift: 0px;
  --made-with-ursa-layer: 35;
}

/* ---- Anchor ------------------------------------------------ */
.made-with-ursa-top {
  position: absolute; top: 0; left: 0;
  width: 1px; height: 8rem;
  pointer-events: none;
}

/* ---- Dock -------------------------------------------------- */
.made-with-ursa,
.made-with-ursa *,
.made-with-ursa *::before,
.made-with-ursa *::after { box-sizing: border-box; }

.made-with-ursa {
  position: fixed; z-index: var(--made-with-ursa-layer);
  right: var(--made-with-ursa-right);
  bottom: calc(var(--made-with-ursa-bottom) + var(--made-with-ursa-lift));
  display: flex; align-items: center; gap: var(--made-with-ursa-gap);
  pointer-events: none;
}
.made-with-ursa__button {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: var(--made-with-ursa-size); height: var(--made-with-ursa-size);
  margin: 0; padding: 0;
  border: var(--made-with-ursa-border) solid var(--made-with-ursa-ink);
  border-radius: 999px;
  background: var(--made-with-ursa-paper); color: var(--made-with-ursa-ink);
  box-shadow: 3px 3px 0 var(--made-with-ursa-shadow);
  cursor: pointer; text-decoration: none;
  pointer-events: auto;
}
.made-with-ursa__button:hover { color: var(--made-with-ursa-hover); }
/* Each button answers a tap across --made-with-ursa-tap, larger than it draws. */
.made-with-ursa__button::after {
  content: ""; position: absolute;
  inset: calc((var(--made-with-ursa-size) - var(--made-with-ursa-tap)) / 2 - var(--made-with-ursa-border));
}
.made-with-ursa__bubble { width: var(--made-with-ursa-bubble-width); }
.made-with-ursa__icon { display: block; flex: none; width: 18px; height: 18px; }

/* The star crossfades between its two frames on hover and while the popover is open. */
.made-with-ursa__star { position: relative; flex: none; width: 22px; height: 22px; }
.made-with-ursa__star::before,
.made-with-ursa__star::after {
  content: ""; position: absolute; inset: 0;
  background: center / contain no-repeat;
}
.made-with-ursa__star::before { background-image: url("../svg/star-dy.svg"); }
.made-with-ursa__star::after { background-image: url("../svg/star-yd.svg"); opacity: 0; }
.made-with-ursa__bubble:hover .made-with-ursa__star::before,
.made-with-ursa__bubble:has(+ .made-with-ursa__pop:popover-open) .made-with-ursa__star::before { opacity: 0; }
.made-with-ursa__bubble:hover .made-with-ursa__star::after,
.made-with-ursa__bubble:has(+ .made-with-ursa__pop:popover-open) .made-with-ursa__star::after { opacity: 1; }
.made-with-ursa__bubble:has(+ .made-with-ursa__pop:popover-open) {
  box-shadow: 1px 1px 0 var(--made-with-ursa-shadow);
  transform: translate(2px, 2px);
}

.made-with-ursa :focus-visible {
  outline: 3px solid var(--made-with-ursa-ink);
  outline-offset: 3px;
}

/* ---- Popover ----------------------------------------------- */
/* Above the bubble and flush with the dock's right edge. */
.made-with-ursa__pop {
  position: fixed;
  inset: auto var(--made-with-ursa-right)
    calc(var(--made-with-ursa-bottom) + var(--made-with-ursa-lift) + var(--made-with-ursa-size) + 12px) auto;
  margin: 0; overflow: visible;
  width: max-content; max-width: min(20rem, calc(100vw - 2 * var(--made-with-ursa-right)));
  padding: 1rem 1.1rem;
  border: var(--made-with-ursa-border) solid var(--made-with-ursa-ink); border-radius: 6px;
  background: var(--made-with-ursa-paper); color: var(--made-with-ursa-ink-soft);
  box-shadow: 4px 4px 0 var(--made-with-ursa-shadow);
  font-family: var(--made-with-ursa-font); font-size: var(--made-with-ursa-text); line-height: 1.5;
  pointer-events: auto;
}
.made-with-ursa__pop:popover-open { display: flex; flex-direction: column; gap: 0.75rem; }
.made-with-ursa__pop::after {
  content: ""; position: absolute; bottom: -8px;
  right: calc(var(--made-with-ursa-bubble-width) / 2 - 7px);
  width: 12px; height: 12px;
  background: var(--made-with-ursa-paper);
  border-right: var(--made-with-ursa-border) solid var(--made-with-ursa-ink);
  border-bottom: var(--made-with-ursa-border) solid var(--made-with-ursa-ink);
  transform: rotate(45deg);
}
.made-with-ursa__line { margin: 0; }
.made-with-ursa__pop a {
  font-weight: 700; color: var(--made-with-ursa-ink);
  text-decoration-line: underline;
  text-decoration-color: var(--made-with-ursa-underline);
}
.made-with-ursa__pop a:hover { color: var(--made-with-ursa-hover); text-decoration-color: currentColor; }
.made-with-ursa__link {
  padding-top: 0.7rem;
  border-top: 2px dashed color-mix(in srgb, var(--made-with-ursa-ink) 20%, transparent);
}
.made-with-ursa__link::after { content: "\2192" / ""; display: inline-block; margin-left: 0.35em; }

/* ---- Back to top ------------------------------------------- */
/* The arrow shows once the script marks it data-away. */
@media (scripting: enabled) {
  .made-with-ursa__top:not([data-away]) {
    opacity: 0; visibility: hidden; transform: translateY(6px);
  }
}

/* ---- Media ------------------------------------------------- */
@media print {
  .made-with-ursa { display: none; }
}

@media (prefers-contrast: more) {
  .made-with-ursa { --made-with-ursa-ink-soft: var(--made-with-ursa-ink); }
  .made-with-ursa__pop a { text-decoration-color: currentColor; }
  .made-with-ursa__link { border-top-color: var(--made-with-ursa-ink); }
}

@media (forced-colors: active) {
  .made-with-ursa :focus-visible { outline-color: Highlight; }
}

@media (prefers-reduced-motion: no-preference) {
  .made-with-ursa__top { transition: opacity 0.2s ease, visibility 0.2s, transform 0.2s ease; }
  .made-with-ursa__star::before,
  .made-with-ursa__star::after { transition: opacity 0.5s ease; }
  .made-with-ursa__pop { transition: opacity 0.2s ease, transform 0.2s ease; }
  @starting-style {
    .made-with-ursa__pop:popover-open { opacity: 0; transform: translateY(6px); }
  }
}
