/* Threads of the Wild Shadow — styles
   Colors are set once here; dark mode swaps them below. */
:root {
  /* all colors are sampled from the card artwork */
  --paper: #f4eee2;           /* lighter Grief frame cream */
  --paper-deep: #ece4d2;      /* Grief frame cream */
  --ink: #2b2a27;
  --ink-soft: #625c52;
  --thread: #9e4b3b;          /* the red stitching, deepened so it reads as text */
  --line: rgba(43, 42, 39, 0.12);
  --thread-soft: rgba(158, 75, 59, 0.45);  /* the same red, for stitched lines */

  --font-head: "Jost", "Avenir Next", "Helvetica Neue", sans-serif;
  --font-body: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  --gutter: 1.25rem;
  --measure: 36rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141414;         /* the black of the card back */
    --paper-deep: #1e1e1d;
    --ink: #ece6d8;           /* the white stitching of the card back */
    --ink-soft: #aaa497;
    --thread: #cf8a76;        /* the red stitching, lightened for dark backgrounds */
    --line: rgba(236, 230, 216, 0.12);
    --thread-soft: rgba(207, 138, 118, 0.45);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter) 3rem; }

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 400; line-height: 1.2; margin: 0; }

a { color: var(--thread); }

img { max-width: 100%; }

[hidden] { display: none !important; }

/* ---------- header and footer ---------- */

.site-header {
  padding: 1rem var(--gutter);
  padding-top: max(1rem, env(safe-area-inset-top));
  text-align: center;
  border-bottom: 1px dashed var(--thread-soft);
}

.site-title {
  font-family: var(--font-head);
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--ink);
  text-decoration: none;
}

.site-footer {
  padding: 1.5rem var(--gutter);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-top: 1px dashed var(--thread-soft);
}
.site-footer p { margin: 0; }

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.button:hover { background: var(--paper-deep); }
.button-primary { background: var(--ink); color: var(--paper); }
.button-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); }

:focus-visible { outline: 2px dashed var(--thread); outline-offset: 4px; }

.small { font-size: 0.95rem; color: var(--ink-soft); }

/* ---------- home ---------- */

.hero { text-align: center; max-width: var(--measure); margin: 0 auto; padding-top: 2rem; }

.hero-card {
  width: 7.5rem;
  height: auto;
  transform: rotate(-4deg);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.22));
  margin-bottom: 1.25rem;
}

.hero h1 {
  font-size: clamp(1.9rem, 8vw, 2.8rem);
  font-weight: 300;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
}

.lede { font-size: 1.15rem; }

.pause { font-style: italic; color: var(--ink-soft); }

.pull-one { text-align: center; margin: 0 auto; max-width: var(--measure); }
.pull-one .button { width: 100%; max-width: 20rem; }
.pull-one .small { margin-top: 0.75rem; }

.section-heading {
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}

.spread-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: grid;
  gap: 1rem;
  max-width: var(--measure);
}

.spread-link {
  display: block;
  padding: 1.25rem 1.25rem 1.1rem;
  border: 1px dashed var(--thread-soft);
  border-radius: 1rem;
  background: var(--paper-deep);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
}
.spread-link:hover { border-color: var(--thread); }
.spread-link h3 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.spread-link .count {
  font-family: var(--font-head);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.spread-link p { margin: 0.5rem 0 0; }
.spread-link .when { font-size: 0.95rem; color: var(--ink-soft); }

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

.reading-head { text-align: center; max-width: var(--measure); margin: 2rem auto 2.5rem; }
.reading-head h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); font-weight: 300; margin-bottom: 0.5rem; }
.reading-head .hint { color: var(--ink-soft); font-style: italic; margin: 0; }

.positions { display: grid; gap: 3.5rem; }

.position { max-width: var(--measure); margin: 0 auto; width: 100%; }

.position-label {
  text-align: center;
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--thread);
  margin: 0 0 0.35rem;
}
.position-asks { text-align: center; color: var(--ink-soft); margin: 0 0 1.25rem; font-size: 0.98rem; }

/* the card and its flip */
.card {
  display: block;
  width: min(68vw, 17rem);
  aspect-ratio: 479 / 800;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1400px;
  -webkit-tap-highlight-color: transparent;
}
.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card.is-turned .card-inner { transform: rotateY(180deg); }
.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.card .card-face { transform: rotateY(180deg); }
.card:not(.is-turned):hover .card-inner { transform: translateY(-4px); transition-duration: 0.3s; }
.card.is-turned { cursor: default; }

.card-shadow {
  display: block;
  width: min(60vw, 15rem);
  height: 1rem;
  margin: -0.4rem auto 0;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.22), transparent);
}

.tap-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0.5rem 0 0;
}

.card-text { margin-top: 1.5rem; animation: rise 0.8s ease both; animation-delay: 0.45s; }

.card-name { font-size: 1.6rem; text-align: center; margin-bottom: 0.75rem; }
.message {
  font-family: var(--font-head);
  font-weight: 300;
  font-size: 1.3rem;
  line-height: 1.4;
  text-align: center;
  margin: 0 0 1.5rem;
}
.card-text h4, .fieldwork h3 {
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 1.25rem 0 0.35rem;
}
.card-text p, .fieldwork p { margin: 0 0 0.85rem; }
/* spread context, fieldwork, actions */
.panel {
  max-width: var(--measure);
  margin: 3.5rem auto 0;
  padding: 1.5rem 1.25rem;
  border: 1px dashed var(--thread-soft);
  border-radius: 1rem;
  background: var(--paper-deep);
}
.panel h2 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.panel p:last-child { margin-bottom: 0; }
.closing { font-family: var(--font-head); font-weight: 300; font-size: 1.15rem; white-space: pre-line; }

.fieldwork { animation: rise 0.8s ease both; }
.fieldwork ul { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.fieldwork li { margin-bottom: 0.4rem; }
.fieldwork li::marker { content: "×  "; color: var(--thread); }

.fieldwork-wait { text-align: center; color: var(--ink-soft); font-style: italic; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 2rem auto 0;
  max-width: var(--measure);
}
.actions .button { flex: 1 1 12rem; }

.copy-status { text-align: center; color: var(--thread); min-height: 1.6em; margin: 0.75rem 0 0; }

.load-error { text-align: center; color: var(--thread); margin: 3rem auto; max-width: var(--measure); }

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

/* ---------- wider screens: cards sit side by side, as in the book ---------- */

@media (min-width: 760px) {
  :root { --gutter: 2rem; }
  .positions[data-count="3"], .positions[data-count="4"], .positions[data-count="6"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3.5rem 2.5rem;
  }
  .positions[data-count="3"] .position:last-child { grid-column: 1 / -1; max-width: 50%; }
  .card { width: min(100%, 15rem); }
  .spread-list { max-width: 48rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1080px) {
  .positions[data-count="3"], .positions[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .positions[data-count="3"] .position:last-child { grid-column: auto; max-width: var(--measure); }
  .positions[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3.5rem 1.75rem; }
  .positions[data-count="4"] .card-name { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card-inner { transition: none; }
  .card img { transition: opacity 0.4s; }
  .card.is-turned .card-inner { transform: none; }
  .card.is-turned .card-back { opacity: 0; }
  .card .card-face { transform: none; opacity: 0; transition: opacity 0.4s; }
  .card.is-turned .card-face { opacity: 1; }
  .card-text, .fieldwork { animation: none; }
  .spread-link:hover, .card:not(.is-turned):hover .card-inner { transform: none; }
}

/* The home page already shows the title large, so the small header is only shown on readings. */
body[data-view="home"] .site-header { display: none; }

/* A sashiko-style row of running stitches and crosses, in the red thread color. */
.stitch {
  display: block;
  width: min(15rem, 70%);
  height: 12px;
  margin: 2.5rem auto;
  background-color: var(--thread);
  opacity: 0.75;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M2 6H16M24 2l8 8M32 2l-8 8' stroke='%23000' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / 40px 12px repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M2 6H16M24 2l8 8M32 2l-8 8' stroke='%23000' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / 40px 12px repeat-x;
}
.stitch + .panel { margin-top: 0; }
.positions + .stitch { margin-top: 3.5rem; }

/* ---------- About this deck (#/about) ---------- */

.about { max-width: var(--measure); margin: 0 auto; padding-top: 2.5rem; }
.about .label {
  text-align: center;
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--thread);
  margin: 0 0 0.5rem;
}
.about h2 {
  text-align: center;
  font-size: clamp(1.7rem, 7vw, 2.4rem);
  font-weight: 300;
  letter-spacing: 0.02em;
}
.about .stitch { margin: 1.5rem auto 2rem; }
.about .lede { font-style: italic; text-align: center; margin: 0 0 1rem; }
.about h3 { font-size: 1.2rem; font-weight: 400; margin: 2.25rem 0 0.6rem; }
.about p { margin: 0 0 0.85rem; }
.about a:not(.button) { text-underline-offset: 3px; }
.about .actions { margin-top: 2.75rem; }

.site-footer .footer-note { margin-bottom: 0.35rem; }
.site-footer a { text-underline-offset: 3px; }
