/* mementa.page/free, on top of the site's styles.css. New rules only where the site
   has no part for the job: the book, the tray, the viewer. Everything else is the site's
   own classes (page-hero, kicker, btn, fx-toc, fx-cta) or copies their look exactly.
   Type: the site's five tokens only. Inside the book: --fs-h3 for the kit's name,
   --fs-p for section names and buttons, --fs-small for everything else. */

.nav__links a[aria-current="page"] { color: var(--link); }
.page-hero--free .container { max-width: var(--container); }
.page-hero--free h1 { max-width: none; }

.free { padding: 48px 0 80px; }

/* A link that goes somewhere: the site's row link, underlined name and an arrow. */
.go {
  font-weight: 600; color: var(--link);
  text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
/* the arrows are drawn icons, the same stroke and size as the download icon on the buttons */
.go::after {
  content: ""; display: inline-block; width: 1.05em; height: 1.05em; margin-left: 6px; vertical-align: -.2em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M4 12h15m0 0l-5.5-5.5M19 12l-5.5 5.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M4 12h15m0 0l-5.5-5.5M19 12l-5.5 5.5'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .2s var(--ease);
}
.go:hover { color: var(--link-hover); }
.go:hover::after { transform: translateX(3px); }

/* ---------- the book, drawn like the app's ---------- */

.desk { position: relative; }

.book {
  --cover: #2A9D8F;
  --band: #1A6158;
  --page: #F5F3F0;
  --rule: #2B1A14;
  position: relative;
  padding: 18px;
  border-radius: 22px;
  background: var(--cover);
  box-shadow: var(--shadow-md);
}
/* the darker spine cloth at the head and the foot */
.book::before, .book::after {
  content: ""; position: absolute; left: 50%; width: 19.5%; height: 18px;
  transform: translateX(-50%); background: var(--band);
}
.book::before { top: 0; }
.book::after  { bottom: 0; }
/* the headband caps, half hidden behind the pages */
.book__cap {
  position: absolute; left: 50%; z-index: 1; width: 8.6%; height: 24px;
  transform: translateX(-50%);
  background: #EBEAE1; border: 4px solid var(--band); border-radius: 50%;
}
.book__cap--top    { top: 3px; }
.book__cap--bottom { bottom: 3px; }

.book__pages {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr 1fr;
  aspect-ratio: 17 / 11;              /* two Letter pages, the Wide notebook */
  background: var(--page);
  border: 2px solid var(--rule);
  perspective: 3200px;
}
.book__spine {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px;
  background: var(--rule); z-index: 4; pointer-events: none;
}

.slot { position: relative; overflow: hidden; background: var(--page); }
.slot::after { content: ""; position: absolute; top: 0; bottom: 0; width: 36px; pointer-events: none; z-index: 3; }
.slot--left::after  { right: 0; background: linear-gradient(to left, rgba(80,70,64,.55), rgba(217,215,213,.6) 22%, rgba(245,243,240,0)); }
.slot--right::after { left: 0;  background: linear-gradient(to right, rgba(80,70,64,.4), rgba(214,213,210,.55) 22%, rgba(245,243,240,0)); }

/* the leaf that turns */
.leaf {
  position: absolute; top: 0; bottom: 0; width: 50%; z-index: 5;
  transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.45, .05, .25, 1);
}
.leaf--fwd  { left: 50%; transform-origin: left center; }
.leaf--back { left: 0;   transform-origin: right center; }
.leaf__face { position: absolute; inset: 0; overflow: hidden; background: var(--page); backface-visibility: hidden; }
.leaf__face--back { transform: rotateY(180deg); }
.leaf__face::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to right, rgba(40,30,20,0), rgba(40,30,20,.14));
  opacity: 0; transition: opacity .75s;
}
.leaf.is-turning .leaf__face::after { opacity: 1; }

/* the spread's bending leaf (script: bendTurn) */
.leaf3 { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 5; transform-style: preserve-3d; }
.leaf3--fwd  { left: 50%; transform-origin: left center; }
.leaf3--back { left: 0;   transform-origin: right center; }
.strip { position: absolute; top: 0; height: 100%; transform-style: preserve-3d; }
.leaf3--fwd .strip  { transform-origin: left center; }
.leaf3--back .strip { transform-origin: right center; }
.sface { position: absolute; top: 0; bottom: 0; overflow: hidden; backface-visibility: hidden; background: var(--page); }
.sface--back { transform: rotateY(180deg); }
.sface__in { position: absolute; top: 0; }
.sface__in > .pg { height: 100%; }
.sface__shade { position: absolute; inset: 0; background: #2A1D14; opacity: 0; pointer-events: none; }
/* the leaf's own spine shadow, the same as the resting pages', fading with the lift */
.sface__gutter { position: absolute; top: 0; bottom: 0; width: 36px; pointer-events: none; }
.sface__gutter.is-left  { left: 0;  background: linear-gradient(to right, rgba(80,70,64,.4), rgba(214,213,210,.55) 22%, rgba(245,243,240,0)); }
.sface__gutter.is-right { right: 0; background: linear-gradient(to left, rgba(80,70,64,.55), rgba(217,215,213,.6) 22%, rgba(245,243,240,0)); }
/* soft shadows on the flat pages while a leaf is up */
.cast { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 4; pointer-events: none; opacity: 0; }
.cast--left  { left: 0;   background: linear-gradient(to left,  rgba(30,20,12,.30), rgba(30,20,12,.10) 35%, rgba(30,20,12,0) 70%); }
.cast--right { left: 50%; background: linear-gradient(to right, rgba(30,20,12,.30), rgba(30,20,12,.10) 35%, rgba(30,20,12,0) 70%); }
.cast--under.cast--left  { background: linear-gradient(to left,  rgba(30,20,12,.22), rgba(30,20,12,0) 45%); }
.cast--under.cast--right { background: linear-gradient(to right, rgba(30,20,12,.22), rgba(30,20,12,0) 45%); }

/* the corners you can grab */
.corner { position: absolute; bottom: 20px; z-index: 6; width: 56px; height: 56px; border: 0; padding: 0; cursor: pointer; background: transparent; }
.corner--next { right: 20px; }
.corner--prev { left: 20px; }
.corner::before { content: ""; position: absolute; bottom: 0; width: 0; height: 0; border-style: solid; transition: border-width .2s var(--ease); }
.corner--next::before { right: 0; border-width: 0 0 22px 22px; border-color: transparent transparent #E2DFD9 transparent; filter: drop-shadow(-2px -2px 2px rgba(40,30,20,.18)); }
.corner--prev::before { left: 0;  border-width: 22px 0 0 22px; border-color: transparent transparent transparent #E2DFD9; filter: drop-shadow(2px -2px 2px rgba(40,30,20,.18)); }
.corner--next:hover::before { border-width: 0 0 40px 40px; }
.corner--prev:hover::before { border-width: 40px 0 0 40px; }
.corner[hidden] { display: none; }

/* divider tabs, cut from the same paper as the pages */
/* divider tabs drawn like the app's bookmark (Controls/RibbonNameplate): rounded top corners,
   a soft hump in the middle, a straight foot tucked behind the cover. The script cuts each tab
   to that shape at its own size; the shadow follows the cut. */
.tabs {
  position: relative; z-index: 0; display: flex; justify-content: flex-end; gap: 8px;
  margin: 0 40px -4px 0; padding-top: 4px; overflow-x: auto; scrollbar-width: none;
  filter: drop-shadow(1px 3px 4px rgba(0, 0, 0, .22));
}
.tab {
  font: 400 var(--fs-p)/1 var(--font-display); cursor: pointer;
  flex: none; padding: 17px 18px 12px;          /* the top clears the hump */
  color: #9D2A38; background: #E8C6CA; border: 0;   /* a light shade of the open tab's color */
  transform: translateY(6px); transition: transform .2s var(--ease), background .2s, color .2s;
}
.tab:hover { transform: translateY(3px); background: #DDB0B6; }
.tab.is-open { transform: none; background: #9D2A38; color: #FFF8EC; }

.turnbar { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 0; font-size: var(--fs-small); color: var(--ink-faint); }
.turn { font: 600 var(--fs-small)/1 var(--font-body); color: var(--link); background: none; border: 0; padding: 8px 0; cursor: pointer; }
.turn:disabled { color: var(--line-strong); cursor: default; }

.free__cta { max-width: 760px; margin: 72px auto 0; }

/* ---------- pages ---------- */

.pg { position: relative; height: 100%; padding: 8% 9%; }

.pg--title { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.pg__wordmark { width: 78%; height: auto; margin-bottom: 34px; }
.pg__titleword { font: 400 var(--fs-h2)/1.1 var(--font-display); color: var(--ink-title); margin: 0; }
.pg__sub { max-width: 28ch; color: var(--ink-soft); margin: 14px 0 0; }

.pg__heading { font: 400 var(--fs-h3)/1.1 var(--font-display); color: var(--ink-title); margin: 0 0 26px; }
.pg--contents .fx-toc__label { margin: 22px 0 4px; }
.pg--contents .fx-toc__label:first-of-type { margin-top: 0; }
.pg--contents .fx-toc__list a { font-size: var(--fs-p); color: var(--link); font-weight: 600; }
.toc__soon { margin: 4px 0 0; font-size: var(--fs-small); color: var(--ink-faint); }

/* the template is the page itself */
.pg--template { padding: 0; }
.pg__open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; position: relative; }
.pg__open img { width: 100%; height: 100%; object-fit: cover; }
.pg__zoom {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius);
  font: 600 var(--fs-small)/1 var(--font-body); color: #FFF8EC; background: rgba(43, 26, 20, .78);
  opacity: 0; transition: opacity .2s var(--ease);
}
.pg__zoom svg { width: 16px; height: 16px; }
.pg__open:hover .pg__zoom, .pg__open:focus-visible .pg__zoom { opacity: 1; }
@media (hover: none) { .pg__zoom { opacity: 1; } }

/* everything in the kit, four sections that each look the same */
.pg--kit { display: flex; flex-direction: column; padding: 5.5% 8% 4%; }
.kit__head { padding-bottom: 12px; }
.kit__lead { margin: 2px 0 12px; font-size: var(--fs-small); color: var(--ink-soft); }
/* the title and its line stay left; the button, what's inside and the links center as one group */
.kit__get { display: flex; flex-direction: column; align-items: center; text-align: center; }
/* what's inside and the links share one left edge, centered as a group under the button */
.kit__files { text-align: left; }
.kit__head .kit__meta { margin-top: 8px; }
/* each download with its how-to under it: two pairs, in columns */
.kit__just { display: grid; grid-template-columns: repeat(2, max-content); justify-content: start; justify-items: start; gap: 4px 32px; margin: 6px 0 0; font-size: var(--fs-small); text-align: left; }
/* a link that downloads: the same link, with the button's download icon */
.go--dl::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M12 4v11m0 0l-4.5-4.5M12 15l4.5-4.5M5 20h14'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M12 4v11m0 0l-4.5-4.5M12 15l4.5-4.5M5 20h14'/%3E%3C/svg%3E");
}
.go--dl:hover::after { transform: translateY(2px); }

/* fonts and stickers side by side */
.kit__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.kit__cols .kit__name { margin-bottom: 6px; }

/* the home page's marker highlight (site css/home.css, mark.hl), always drawn, no slide in */
mark.hl {
  color: inherit;
  background-color: transparent;
  background-image: linear-gradient(rgba(22, 143, 134, .24), rgba(22, 143, 134, .24));
  background-repeat: no-repeat;
  background-position: 0 88%;
  background-size: 100% 46%;
  padding: 0 .08em;
  margin: 0 -.08em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.fonts li { display: block; padding: 0 0 6px; }
.fonts__line { display: flex; gap: 10px; align-items: baseline; }
.fonts__line .kit__meta { margin: 0; }
.kit__cols .stickers { grid-template-columns: repeat(3, 60px); justify-content: start; gap: 6px 22px; }
/* the caption centers under the grid of stickers */
.stickers__block { width: max-content; max-width: 100%; }
.stickers__block .kit__meta { text-align: center; }
.kit__cols .stickers img { width: 60px; height: 50px; object-fit: contain; object-position: left center; }
/* the kit's name in the kit's own title font; Alata if that font fails to load */
.kit__title { font-family: var(--kit-font), var(--font-display); font-size: var(--fs-h3); font-size-adjust: .5; color: #9B263B; margin: 0; }
.kit-dl { min-height: 40px; padding: 10px 18px; }

.kit__sec { border-top: 1px solid #DDD8CF; padding: 6px 0 8px; }
.kit__row { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.kit__name { font: 400 var(--fs-p)/1.2 var(--font-display); color: var(--ink-title); margin: 0; }
.kit__hint, .kit__meta { font-size: var(--fs-small); color: var(--ink-faint); }
.kit__meta { margin: 6px 0 0; line-height: 1.5; }
.kit__meta .go { margin-left: 4px; }
/* a download inside a section: a square with the arrow, the file named on hover */
.dl-sq { width: 28px; height: 28px; min-height: 0; padding: 0; flex: none; border-radius: 6px; box-shadow: none; }
.dl-sq:hover { transform: none; }
.dl-sq .btn__icon { width: 15px; height: 15px; }

/* the tray, its hint and the names are one block, so the tray centers over the names */
.palette { width: max-content; max-width: 100%; margin-inline: auto; }
.tray { display: block; width: 210px; height: auto; margin: 0 auto; }
.tray__hint { margin: 2px 0 6px; text-align: center; font-size: var(--fs-small); color: var(--ink-faint); }
.tray ellipse { cursor: pointer; transition: transform .15s var(--ease); transform-box: fill-box; transform-origin: center; }
.tray ellipse:hover, .tray ellipse.is-lit { transform: translateY(-6px); }

.hexes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, max-content); grid-template-rows: repeat(3, auto); grid-auto-flow: column; gap: 2px 32px; }
.hexes button {
  display: flex; align-items: center; gap: 7px; width: 100%; padding: 2px 0;
  border: 0; background: none; cursor: pointer; text-align: left;
  font: 600 var(--fs-small)/1.4 var(--font-body); color: var(--ink-title); white-space: nowrap;
}
.hexes i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); flex: none; }
.hexes b { font-weight: 600; margin-right: 6px; }
.hexes span { font-weight: 400; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.hexes button { border-radius: var(--radius); padding: 3px 8px 3px 4px; margin-left: -4px; transition: background .15s; }
.hexes button:hover, .hexes button.is-lit { background: rgba(42,157,143,.1); }
.hexes button:hover span, .hexes button.is-lit span { color: var(--link); }

.fonts { list-style: none; margin: 2px 0 0; padding: 0; }
.fonts .kit__meta { margin: 0; }
.fonts .go { font-size: var(--fs-small); }
.fonts__sample { font-size: var(--fs-p); font-size-adjust: .56; color: var(--ink-title); }

.stickers { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; align-items: center; }
.stickers img { width: 100%; height: auto; transition: transform .2s var(--ease); }
.stickers img:hover { transform: scale(1.25); }
.kit__sec:last-child { padding-bottom: 0; }

.pg--blank { background: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(42,157,143,.14) 31px 32px); background-position: 0 70px; }
.pg__soon { font: 400 var(--fs-h3)/1 Caveat, cursive; color: var(--ink-soft); margin: 54px 0 0; }

/* ---------- the large preview ---------- */

.viewer { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(36, 22, 16, .72); }
.viewer[hidden] { display: none; }
.viewer__panel { display: flex; flex-direction: column; max-height: 100%; background: var(--paper); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); }
.viewer__bar { display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 22px; border-bottom: 1px solid var(--line); }
.viewer__title { flex: 1; margin: 0; font: 400 var(--fs-p)/1.2 var(--font-display); color: var(--ink-title); white-space: nowrap; }
.viewer__switch { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.viewer__switch button { font: 600 var(--fs-small)/1 var(--font-body); padding: 10px 14px; border: 0; background: none; color: var(--ink-soft); cursor: pointer; }
.viewer__switch button[aria-pressed="true"] { background: var(--paper-2); color: var(--ink-title); }
.viewer__bar .dl-sq { width: 40px; height: 40px; border-radius: var(--radius); }
.viewer__bar .dl-sq .btn__icon { width: 18px; height: 18px; }
.viewer__close { width: 40px; height: 40px; border: 0; background: none; color: var(--ink-soft); cursor: pointer; border-radius: var(--radius); }
.viewer__close:hover { background: var(--paper-2); }
.viewer__close svg { width: 22px; height: 22px; }
.viewer__stage { overflow: auto; background: #E9E4DA; }
.viewer__stage img { display: block; height: calc(100vh - 48px - 66px); width: auto; max-width: none; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 300; transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--radius);
  background: var(--ink-title); color: #FFF8EC; font-size: var(--fs-small); font-weight: 600;
  transition: opacity .2s, transform .2s;
}
.toast i { width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(255,255,255,.4); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- a phone: one page at a time ---------- */

body.single {

  .tabs { justify-content: flex-start; margin: 0 0 -3px 14px; }
  .tab { padding: 15px 14px 11px; }



  .book { padding: 12px; border-radius: 16px; }
  .book::before, .book::after, .book__cap { display: none; }
  .book__pages { grid-template-columns: 1fr; aspect-ratio: auto; }
  .book__spine, .slot--right { display: none; }
  .slot--left::after { display: none; }
  .leaf, .leaf--fwd, .leaf--back { left: 0; width: 100%; }

  .pg { min-height: 0; padding: 26px 20px 30px; }
  .pg--title, .pg--contents, .pg--blank { min-height: 440px; }
  .pg--template { padding: 0; aspect-ratio: 8.5 / 11; }

  .corner { bottom: 12px; }
  .corner--next { right: 12px; }
  .corner--prev { left: 12px; }
  .turnbar { margin: 16px 0 0; }

  .viewer { padding: 0; }
  .viewer__panel { width: 100%; height: 100%; border-radius: 0; }
  .viewer__bar { flex-wrap: wrap; padding: 10px 12px; }
  .viewer__title { flex-basis: calc(100% - 54px); }
  .viewer__stage img { width: 100%; height: auto; }
}

body.single {
  .turnbar { margin-top: 16px; }
}

@media (max-width: 760px) {
  .free { padding-top: 28px; }
}

/* The kit page decides by its own width, not the window's: columns stay side by side
   whenever they fit and stack only on a narrow phone page. */
.pg--kit { container-type: inline-size; }
@container (max-width: 470px) {
  .kit__cols { grid-template-columns: 1fr; gap: 14px; }
  .kit__cols .stickers { grid-template-columns: repeat(5, 52px); gap: 8px 14px; }
  .kit__cols .stickers img { width: 52px; height: 46px; }
  .kit__just { grid-template-columns: auto; }
  /* one column keeps the pairs: the PDF and its how-to, then the stickers and theirs */
  .kit__just a:nth-child(3) { order: 1; }
  .kit__just a:nth-child(2) { order: 2; margin-top: 8px; }
  .kit__just a:nth-child(4) { order: 3; }
}
@container (max-width: 400px) {
  .palette { width: auto; }   /* the names use the page's full width */
  /* each hex code goes under its name */
  .hexes { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .hexes button { display: grid; grid-template-columns: 20px 1fr; column-gap: 8px; align-items: center; white-space: normal; }
  .hexes i { grid-row: span 2; }
  .hexes b { margin: 0; line-height: 1.25; }
  .hexes span { line-height: 1.25; }
}

@media (prefers-reduced-motion: reduce) { .leaf { transition: none; } }
