/* Paper: the origami vocabulary every surface shares.
   Origami paper is white on the face and coloured on the back, so a folded corner shows the
   colour: fern (the logo's paper) or brass (the dove's one brass facet).

   ─ .sheet-edge   where one section's sheet ends and the next begins: a cut edge, the soft
                   shadow it casts on the sheet below, and a dog-ear at one corner
   ─ .paper        a sheet resting on the page: crisp corner, a resting shadow, no outline glow
   ─ .paper--ear   the same sheet with its top-right corner folded back (lifts on hover)
   Every colour comes from tokens.css. */

:root {
  --paper-radius: var(--radius-sm);
  --paper-edge: color-mix(in srgb, var(--shadow-ink) 16%, transparent);
  --paper-shadow-rest: 0 1px 1px color-mix(in srgb, var(--shadow-ink) 6%, transparent), 0 14px 26px -20px color-mix(in srgb, var(--shadow-ink) 40%, transparent);
  --paper-shadow-lift: 0 2px 3px color-mix(in srgb, var(--shadow-ink) 7%, transparent), 0 26px 40px -24px color-mix(in srgb, var(--shadow-ink) 45%, transparent);
  --paper-flap-shadow: drop-shadow(2px 3px 2px color-mix(in srgb, var(--shadow-ink) 22%, transparent));
}

/* ─── Sheet edge: the section above is a sheet lying on the next one ─── */

.sheet-edge {
  --ear: var(--space-6);
  position: relative;
  width: calc(100% - 2 * var(--gutter));
  max-width: var(--size-content);
  height: var(--space-7);
  margin: var(--space-9) auto 0;
}

/* The cut edge, stopping where the corner is folded away. */
.sheet-edge::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: var(--ear);
  height: 1px;
  background: var(--paper-edge);
}

/* The shadow the edge casts on the sheet below (light from the upper left). */
.sheet-edge::after {
  content: "";
  position: absolute;
  top: 1px;
  left: var(--space-2);
  right: var(--ear);
  height: var(--space-5);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--shadow-ink) 7%, transparent), transparent);
}

/* The dog-ear: the corner folded up over the sheet, its coloured back showing. */
.sheet-edge__ear {
  position: absolute;
  top: calc(-1 * var(--ear));
  right: 0;
  width: var(--ear);
  height: var(--ear);
  filter: var(--paper-flap-shadow);
}

.sheet-edge__ear::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--fern-500), var(--fern-700));
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* Where the corner was folded away, the sheet underneath shows through. */
.sheet-edge__ear::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-surface-sunken);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.sheet-edge--left {
  transform: scaleX(-1);
}

.sheet-edge--left .sheet-edge__ear::before {
  background: linear-gradient(135deg, var(--brass-400), var(--brass-600));
}

/* ─── Paper sheets ─── */

.paper {
  position: relative;
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: var(--paper-radius);
  box-shadow: var(--paper-shadow-rest);
}

/* The folded corner: ::before cuts the corner away (page colour), ::after is the flap. */
.paper--ear {
  --ear-scale: 0.75;
  --ear-back: var(--fern-600);
}

.paper--ear::before,
.paper--ear::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: var(--space-6);
  height: var(--space-6);
  pointer-events: none;
  transform: scale(var(--ear-scale));
  transform-origin: 100% 0;
  transition: transform var(--duration-base) var(--ease-fold);
}

.paper--ear::before {
  background: var(--color-bg);
  border-top-right-radius: var(--paper-radius);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.paper--ear::after {
  background: linear-gradient(225deg, var(--ear-back), color-mix(in srgb, var(--ear-back) 72%, var(--shadow-ink)));
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.paper--ear:hover,
.paper--ear:focus-within {
  --ear-scale: 1;
}

.paper--brass {
  --ear-back: var(--brass-600);
}
