/*
  Worth.

  One surface, not two. The card does not flip, it opens, and the hook and the
  mechanism live on the same paper. What separates them is voice: the hook is set
  in italic, which reads as something being said, and the mechanism in roman,
  which reads as something being explained.

  Sized for a phone first. Cards vary from 60 to 110 words, so the face scrolls
  and the buttons stay pinned to the bottom of the viewport either way.
*/

:root {
  --paper: #F2F1EC;
  --paper-sunk: #EAE9E3;
  --ink: #16211E;
  --muted: #8C9088;
  --rule: #DFDFD8;
  --green: #1F5E4C;
  --green-lift: #2A7A63;
  --pad: 1.25rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121614;
    --paper-sunk: #191E1B;
    --ink: #E4E6E1;
    --muted: #6C7671;
    --rule: #242A27;
    --green: #5FA88C;
    --green-lift: #7DC0A5;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Serif 4', Georgia, serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#stage {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

.card {
  flex: 1;
  min-height: 0;          /* without this the child cannot scroll inside flex */
  display: flex;
}

.face {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  animation: rise 280ms cubic-bezier(.2,.7,.3,1) both;
}

/*
  The inner wrapper is what makes the buttons behave. It is at least as tall as
  the scroll port, so a short card still pushes its actions to the bottom, and a
  long one scrolls past them rather than hiding them off screen entirely.
*/
.inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1.6rem var(--pad) 1.25rem;
}

.foot { margin-top: auto; padding-top: 1.6rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .face { animation: none; }
}

/* ------------------------------------------------------------------- labels */

.eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.63rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------- the hook */

.hook {
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.45rem, 6vw, 2.1rem);
  line-height: 1.22;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 1.35rem 0 0;
  text-wrap: pretty;
  overflow-wrap: break-word;
}

/* Not a button so much as a way down. Underline carries the whole affordance. */
.turn {
  display: inline-block;
  background: none;
  border: none;
  border-bottom: 2px solid var(--green);
  border-radius: 0;
  padding: 0 0 3px;
  color: var(--green);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.turn:hover { color: var(--green-lift); border-color: var(--green-lift); }
.turn-arrow { margin-left: 0.4rem; }

/* ---------------------------------------------------------- the mechanism */

.mechanism {
  font-size: 1.02rem;
  line-height: 1.62;
  color: var(--ink);
  margin: 1.05rem 0 0.85rem;
  max-width: 34rem;
}

.source {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.63rem;
  letter-spacing: 0.05em;
  line-height: 1.6;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  padding-top: 0.7rem;
}

/* ------------------------------------------------------------------ actions */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

button {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  border-radius: 0;
  padding: 0.85rem 1rem;
  min-height: 44px;       /* nothing smaller than a fingertip */
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.solid {
  flex: 1 1 auto;
  background: none;
  border: 1px solid var(--green);
  color: var(--green);
}
.solid:hover { background: var(--green); color: var(--paper); }

.ghost {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  padding-left: 0.6rem;
  padding-right: 0.6rem;
}
.ghost:hover { color: var(--ink); }

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

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

.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem var(--pad);
  padding-bottom: calc(0.7rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: var(--paper);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.bar .stat b { color: var(--ink); font-weight: 400; }
.bar #net { margin-left: auto; }
.bar #net.online { color: var(--green); }

.bar .ghost {
  font-size: 0.63rem;
  padding: 0.5rem 0 0.5rem 0.6rem;
  min-height: 0;
  letter-spacing: 0.13em;
}

/* Landscape, or a small phone. */
@media (max-height: 560px) {
  .hook { font-size: clamp(1.25rem, 5vw, 1.7rem); margin-top: 0.9rem; }
  .inner { padding-top: 1rem; }
  .foot { padding-top: 1rem; }
}

@media (min-width: 700px) {
  :root { --pad: 3rem; }
  .inner { padding-top: 3rem; padding-bottom: 2rem; }
  .hook { font-size: clamp(2rem, 3.6vw, 2.7rem); margin-top: 2rem; }
  .mechanism { font-size: 1.12rem; }
  .solid { flex: 0 0 auto; padding-left: 1.6rem; padding-right: 1.6rem; }
}
