/* Ask your question · Grain of Knowledge
   Palette = the reels' universe palette (design-system/universe/palette/palette.json).
   Type = pixel rebuilds of the reels' fonts. One art pixel = var(--px) CSS px, so glyphs stay on the grid. */

@font-face {
  font-family: "Grain Pixel Sans";
  src: url("/fonts/grainpixelsans-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Grain Pixel Sans";
  src: url("/fonts/grainpixelsans-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Grain Pixel Serif";
  src: url("/fonts/grainpixelserif-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light only;

  /* warm gray ramp */
  --paper: #fcfbf8;
  --white: #fffefc;
  --g1: #f3f0eb;
  --g2: #e8e4de;
  --shadow: #ded9d2;
  --g3: #cac5bc;
  --g4: #a6a097;
  --g5: #847e77;
  --g6: #65605a;
  --g7: #514d48;
  --ink: #312e2b;

  /* the one touch of colour */
  --pink: #ff6fa8;
  --pink-shade: #d94f86;
  --pink-text: #b8336b; /* pink that passes AA as text on paper */

  /* pixel grid */
  --px: 2px;            /* body type pixel */
  --tpx: 2px;           /* title type pixel */
  --gpx: 4px;           /* grain / garden pixel */

  --font-sans: "Grain Pixel Sans", Tahoma, Verdana, sans-serif;
  --font-serif: "Grain Pixel Serif", Georgia, serif;
  --text: calc(var(--px) * 11);       /* sans em = 11 art px */
  --line: calc(var(--px) * 16);
  --title: calc(var(--tpx) * 22);     /* serif em = 22 art px */

  --gutter: 24px;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

@media (min-width: 760px) {
  :root { --tpx: 3px; --gutter: 48px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text);
  line-height: var(--line);
  /* soft window light from the upper left, a faint vignette in the far corner */
  background:
    radial-gradient(90% 60% at 8% -6%, var(--white) 0%, rgba(255, 254, 252, 0) 70%),
    radial-gradient(70% 50% at 100% 105%, var(--g1) 0%, rgba(243, 240, 235, 0) 70%),
    var(--paper);
  background-attachment: fixed;
}

a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- page ---------- */

.page {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: calc(30rem + var(--gutter) * 2);
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) var(--gutter) 32px;
}

@media (min-width: 760px) {
  .page { padding-top: clamp(64px, 14vh, 160px); }
}

.view[hidden] { display: none; }

.anchor { display: block; }
.anchor-grain { width: calc(var(--gpx) * 8); height: calc(var(--gpx) * 9); margin-bottom: 20px; }
.anchor-garden { width: calc(var(--gpx) * 25); height: calc(var(--gpx) * 24); margin-bottom: 24px; }

.garden {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--gpx) * 25);
  height: calc(var(--gpx) * 24);
  overflow: visible;
  shape-rendering: crispEdges;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}
.garden.is-placed { opacity: 1; }
.garden .kick rect { opacity: 0; }

/* ---------- type ---------- */

.title {
  margin: 0 0 28px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--title);
  line-height: calc(var(--tpx) * 26);
  letter-spacing: 0;
  text-wrap: balance;
  /* the reels' title treatment: a 1 px extrusion down-right */
  text-shadow: var(--tpx) var(--tpx) 0 var(--shadow);
}

/* ---------- form ---------- */

.ask-form { display: grid; gap: 0; }

.field-question { position: relative; margin-bottom: 28px; }

textarea, input {
  font: inherit;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

textarea {
  display: block;
  width: 100%;
  min-height: calc(var(--line) * 3 + 32px);
  padding: 14px 16px 16px;
  resize: none;
  field-sizing: content;
  background: var(--white);
  border: var(--px) solid var(--g5);
  /* a well pressed into the paper: pixel inner shade top-left, a soft lift around it */
  box-shadow:
    inset var(--px) var(--px) 0 var(--g1),
    0 22px 40px -28px rgba(49, 46, 43, 0.35);
  transition: border-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
  overflow-wrap: anywhere;
}

textarea::placeholder { color: var(--g6); opacity: 1; }

textarea:focus { outline: none; border-color: var(--ink); }
textarea:focus-visible { outline: none; }

.count {
  position: absolute;
  right: 0;
  bottom: -32px;
  margin: 0;
  color: var(--g6);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), color 200ms;
}
.count.is-on { opacity: 1; transform: none; }
.count.is-near { color: var(--pink-text); }

.field-name { margin: 12px 0 36px; max-width: 20rem; }

.field-name label { display: block; margin-bottom: 4px; }
.optional { color: var(--g6); }

input[type="text"] {
  display: block;
  width: 100%;
  padding: 6px 0 8px;
  background: transparent;
  border: 0;
  border-bottom: var(--px) solid var(--g5);
  transition: border-color 200ms var(--ease-out);
}
input[type="text"]:focus { outline: none; border-bottom-color: var(--ink); }

.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- buttons ---------- */

.send {
  font: inherit;
  font-weight: 700;
  width: 100%;
  min-height: 56px;
  padding: 0 24px;
  color: var(--ink);
  background: var(--pink);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  box-shadow: var(--px) var(--px) 0 var(--pink-shade), 0 16px 28px -22px rgba(49, 46, 43, 0.45);
  transition: background-color 240ms var(--ease-out), color 240ms var(--ease-out),
              box-shadow 240ms var(--ease-out), transform 120ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 760px) {
  .send { width: auto; min-width: 12rem; }
}
@media (hover: hover) {
  .send:not(:disabled):hover { background: #ff7fb2; }
}
.send:not(:disabled):active {
  transform: translate(var(--px), var(--px));
  box-shadow: 0 0 0 var(--pink-shade), 0 10px 20px -18px rgba(49, 46, 43, 0.45);
}
.send:disabled {
  cursor: default;
  color: var(--g5);
  background: var(--g1);
  box-shadow: var(--px) var(--px) 0 var(--g2);
}
.send[aria-busy="true"] { cursor: progress; color: var(--g7); background: var(--g2); box-shadow: var(--px) var(--px) 0 var(--g3); }

.send:focus-visible, .again:focus-visible, a:focus-visible {
  outline: var(--px) solid var(--ink);
  outline-offset: 4px;
}

.form-error {
  margin: 16px 0 0;
  min-height: var(--line);
  color: var(--pink-text);
}

/* ---------- thank you ---------- */

.view-thanks { padding-top: clamp(24px, 12vh, 120px); }

.title-thanks { margin-bottom: 16px; }
.title-thanks:focus { outline: none; }

.thanks-line { margin: 0 0 32px; max-width: 24rem; }
/* the handle is written in the grain's pink, underlined only on hover */
.thanks-line a { color: var(--pink); text-decoration: none; }   /* the grain's pink, Zeu's call */
@media (hover: hover) {
  .thanks-line a:hover { text-decoration: underline; text-decoration-thickness: var(--px); text-underline-offset: 6px; }
}

.foot a {
  text-decoration-line: underline;
  text-decoration-thickness: var(--px);
  text-underline-offset: 6px;
}

.again {
  font: inherit;
  min-height: 48px;
  padding: 0;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--g4);
  text-decoration-thickness: var(--px);
  text-underline-offset: 6px;
}
@media (hover: hover) { .again:hover { text-decoration-color: var(--ink); } }

/* ---------- footer ---------- */

.foot {
  width: 100%;
  max-width: calc(30rem + var(--gutter) * 2);
  margin: 0 auto;
  padding: 16px var(--gutter) max(24px, env(safe-area-inset-bottom));
  color: var(--g6);
}
.foot a { color: var(--g6); text-decoration-color: var(--g3); }
body[data-view="thanks"] .foot { visibility: hidden; }

/* ---------- arrival ---------- */

/* arrival in overlapping pairs: each item starts halfway through the one before */
.enter { animation: rise 460ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 230ms); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .enter { animation-name: fade; animation-duration: 300ms; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .count, textarea, input, .send { transition-duration: 1ms; }
}
