/* Freentity invitation — continuous artwork reader and restrained gallery chrome.
   The supplied invitation remains one untouched raster; layout only controls its
   responsive size and the invisible navigation anchors layered above it. */

.invitation {
  display: block;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  outline: none;
  background: var(--green-950);
}

html[data-state="sealed"] .invitation,
html[data-state="opening"] .invitation {
  display: none;
}

html[data-state="open"],
html[data-state="open"] body {
  background: var(--green-950);
}

/* ------------------------------------------------------------ reading canvas */

.reader-stage {
  position: relative;
  display: block;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(70% 32% at 50% 0%, rgb(73 103 87 / 18%), transparent 78%),
    linear-gradient(90deg, #04110b 0%, #071a12 26%, #081c13 50%, #071a12 74%, #04110b 100%);
}

.reader-stage::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 9%, rgb(222 230 226 / 3%) 10%, transparent 11%),
    linear-gradient(90deg, transparent 43%, rgb(222 230 226 / 2.5%) 44%, transparent 45%),
    linear-gradient(90deg, transparent 78%, rgb(222 230 226 / 2%) 79%, transparent 80%),
    var(--grain);
  background-size: auto, auto, auto, 180px 180px;
  content: "";
  opacity: .18;
  pointer-events: none;
}

.reader {
  position: relative;
  z-index: 1;
  display: block;
  width: min(calc(100% - 24px), 820px);
  margin: 0 auto;
  padding: 12px 0 max(104px, calc(env(safe-area-inset-bottom) + 92px));
}

.invitation-scroll {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgb(225 232 228 / 11%);
  border-radius: 2px;
  background: #071c13;
  box-shadow:
    0 46px 100px rgb(0 5 3 / 50%),
    0 10px 30px rgb(0 5 3 / 34%);
  opacity: 0;
  transform: translateY(18px) scale(.995);
  transform-origin: center top;
  transition:
    opacity 700ms ease,
    transform 980ms var(--ease-expo);
}

.invitation-scroll.is-visible {
  opacity: 1;
  transform: none;
}

.invitation-scroll > img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  filter: none;
  user-select: none;
  pointer-events: none;
}

.invitation-anchor {
  position: absolute;
  top: var(--anchor-y);
  left: 0;
  display: block;
  width: 1px;
  height: 1px;
  scroll-margin-top: 68px;
  pointer-events: none;
}

/* -------------------------------------------------------------- progress bar */

.reader-progress {
  position: fixed;
  z-index: 12;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: rgb(255 255 255 / 7%);
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
}

.reader-progress.is-active {
  opacity: 1;
}

.reader-progress__bar {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #8f9a94, #e1e6e3);
  transform: scaleX(var(--reading-progress, 0));
  transform-origin: left center;
}

/* -------------------------------------------------------------- header bar */

.reader-bar {
  position: fixed;
  z-index: 9;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: 54px;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid rgb(232 237 234 / 9%);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgb(4 18 12 / 86%);
  backdrop-filter: blur(16px) saturate(.95);
  -webkit-backdrop-filter: blur(16px) saturate(.95);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 320ms ease, transform 420ms var(--ease-expo);
  visibility: hidden;
  pointer-events: none;
}

.reader-bar.is-visible {
  opacity: 1;
  transform: none;
  visibility: visible;
  pointer-events: auto;
}

.reader-bar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--stone-100);
  font-size: .84rem;
  font-weight: 560;
  letter-spacing: .08em;
  text-decoration: none;
}

.reader-bar__brand img {
  width: 27px;
  height: 27px;
  filter: none;
  mix-blend-mode: normal;
  opacity: 1;
}

.reader-bar__brand:hover {
  color: #fff;
}

.reader-bar__brand:focus-visible,
.rail__brand:focus-visible {
  outline: 2px solid var(--stone-300);
  outline-offset: 4px;
  border-radius: 4px;
}

.reader-bar__section {
  margin: 0;
  overflow: hidden;
  color: rgb(229 235 232 / 72%);
  font-size: .67rem;
  letter-spacing: .18em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------- tool dock (< 1360px) */

.reader-rail {
  position: fixed;
  z-index: 10;
  inset: auto 0 0;
  display: flex;
  padding: 0 12px max(12px, env(safe-area-inset-bottom));
  justify-content: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 460ms ease, transform 560ms var(--ease-expo);
  visibility: hidden;
  pointer-events: none;
}

.reader-rail.is-visible {
  opacity: 1;
  transform: none;
  visibility: visible;
}

.rail__brand,
.rail__facts,
.rail__nav {
  display: none;
}

.rail__tools {
  display: flex;
  max-width: 100%;
  padding: 5px;
  border: 1px solid rgb(231 236 233 / 15%);
  border-radius: 999px;
  background: rgb(207 214 210 / 90%);
  box-shadow:
    0 18px 42px rgb(0 6 4 / 38%),
    inset 0 1px rgb(255 255 255 / 56%);
  backdrop-filter: blur(18px) saturate(.8);
  -webkit-backdrop-filter: blur(18px) saturate(.8);
  gap: 2px;
  pointer-events: auto;
}

.tool {
  display: flex;
  min-width: 76px;
  min-height: 46px;
  padding: 7px 12px 6px;
  border: 0;
  border-radius: 999px;
  appearance: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--green-800);
  background: transparent;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .035em;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 220ms ease, color 220ms ease, transform 220ms var(--ease-expo);
}

.tool svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.tool:hover {
  color: var(--green-950);
  background: rgb(255 255 255 / 42%);
}

.tool:active {
  transform: scale(.96);
}

.tool:focus-visible {
  outline: 2px solid var(--green-700);
  outline-offset: 2px;
}

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

.reader-toast {
  position: fixed;
  z-index: 11;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 74px));
  left: 50%;
  margin: 0;
  padding: 10px 18px;
  border: 1px solid rgb(235 239 237 / 14%);
  border-radius: 999px;
  color: var(--stone-50);
  background: rgb(4 18 12 / 94%);
  box-shadow: 0 12px 30px rgb(0 6 4 / 38%);
  font-size: .8rem;
  letter-spacing: .04em;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 260ms ease, transform 320ms var(--ease-expo);
  pointer-events: none;
}

.reader-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------- small phones */

@media (max-width: 430px) {
  .reader {
    width: calc(100% - 24px);
  }

  .invitation-scroll {
    box-shadow: 0 24px 54px rgb(0 5 3 / 46%);
  }

  .tool {
    min-width: 68px;
    padding-inline: 9px;
    font-size: .66rem;
  }
}

/* ------------------------------------------------- tablet and small desktop */

@media (min-width: 720px) {
  .reader {
    width: min(calc(100% - 64px), 820px);
    padding: clamp(42px, 6vh, 72px) 0 clamp(112px, 12vh, 152px);
  }

  .invitation-scroll {
    border-radius: 3px;
    box-shadow:
      0 60px 130px rgb(0 5 3 / 54%),
      0 16px 44px rgb(0 5 3 / 34%);
  }
}

/* ------------------------------------------------------------- desktop rail */

@media (min-width: 1360px) and (min-height: 680px) {
  .reader-bar {
    display: none;
  }

  .reader-rail {
    inset: 50% auto auto max(28px, calc((50vw - 410px) / 2 - 262px));
    display: grid;
    width: min(230px, calc((100vw - 820px) / 2 - 56px));
    max-height: calc(100svh - 64px);
    padding: 0;
    overflow: auto;
    align-content: safe center;
    gap: 25px;
    justify-content: stretch;
    transform: translateY(calc(-50% + 12px));
    pointer-events: auto;
  }

  .reader-rail.is-visible {
    transform: translateY(-50%);
  }

  .rail__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--stone-100);
    text-decoration: none;
  }

  .rail__brand img {
    width: 40px;
    height: 40px;
    filter: none;
    mix-blend-mode: normal;
    opacity: 1;
  }

  .rail__brand-text {
    display: grid;
    color: var(--stone-100);
    font-size: 1rem;
    font-weight: 560;
    letter-spacing: .06em;
    line-height: 1.25;
  }

  .rail__brand-text em {
    color: rgb(225 232 228 / 58%);
    font-size: .6rem;
    font-style: normal;
    font-weight: 500;
    letter-spacing: .3em;
  }

  .rail__facts {
    display: grid;
    margin: 0;
    padding: 20px 0 0;
    border-top: 1px solid rgb(225 232 228 / 14%);
    gap: 16px;
  }

  .rail__facts dt {
    color: rgb(225 232 228 / 54%);
    font-size: .6rem;
    font-weight: 600;
    letter-spacing: .26em;
  }

  .rail__facts dd {
    margin: 5px 0 0;
    color: rgb(242 245 243 / 84%);
    font-size: .8rem;
    line-height: 1.68;
  }

  .rail__nav {
    display: grid;
    padding: 18px 0 0;
    border-top: 1px solid rgb(225 232 228 / 14%);
    gap: 2px;
  }

  .rail__nav button {
    position: relative;
    display: flex;
    padding: 9px 8px 9px 0;
    border: 0;
    appearance: none;
    align-items: baseline;
    gap: 12px;
    color: rgb(225 232 228 / 58%);
    background: transparent;
    font-size: .78rem;
    letter-spacing: .04em;
    text-align: left;
    cursor: pointer;
    transition: color 220ms ease, padding-left 300ms var(--ease-expo);
  }

  .rail__nav button i {
    font-size: .6rem;
    font-style: normal;
    font-weight: 600;
    letter-spacing: .14em;
    opacity: .7;
  }

  .rail__nav button:hover {
    padding-left: 6px;
    color: var(--stone-100);
  }

  .rail__nav button:focus-visible {
    outline: 2px solid var(--stone-400);
    outline-offset: 2px;
    border-radius: 2px;
  }

  .rail__nav button[aria-current="true"] {
    padding-left: 12px;
    color: #fff;
    font-weight: 600;
  }

  .rail__nav button[aria-current="true"]::before {
    position: absolute;
    top: 50%;
    left: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--stone-300);
    content: "";
    transform: translateY(-50%);
  }

  .rail__tools {
    display: grid;
    padding: 18px 0 0;
    border: 0;
    border-top: 1px solid rgb(225 232 228 / 14%);
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    gap: 2px;
  }

  .tool {
    min-width: 0;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 6px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    color: rgb(236 240 238 / 76%);
    font-size: .8rem;
    font-weight: 500;
    text-align: left;
  }

  .tool:hover {
    color: #fff;
    background: rgb(225 232 228 / 8%);
  }

  .tool:focus-visible {
    outline-color: var(--stone-400);
  }

  .reader-toast {
    bottom: 32px;
  }
}

/* ------------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  .reader-bar,
  .reader-rail,
  .reader-toast,
  .tool,
  .rail__nav button {
    transition-duration: .01ms;
  }

  .invitation-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

@media print {
  .invitation {
    display: block !important;
    background: #fff;
  }

  .reader-progress,
  .reader-bar,
  .reader-rail,
  .reader-toast,
  .reader-stage::before {
    display: none !important;
  }

  .reader-stage {
    min-height: 0;
    background: #fff;
  }

  .reader {
    width: 100%;
    padding: 0;
  }

  .invitation-scroll {
    opacity: 1;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
  }
}
