/* Haiku Lens — washi paper, sumi ink, and one accent of vermilion. */

:root {
  --paper:      #f7f3ea;
  --paper-deep: #efe8da;
  --ink:        #1c1a17;
  --ink-soft:   #56504a;
  --ink-faint:  #8d867d;
  --rule:       #ddd4c3;
  --vermilion:  #c0392b;
  --radius:     14px;
  --measure:    46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #15140f;
    --paper-deep: #1e1c16;
    --ink:        #f1ece1;
    --ink-soft:   #b3aca0;
    --ink-faint:  #7d766c;
    --rule:       #322e26;
    --vermilion:  #e0614f;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 1.25rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.7 ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* the faintest fibre, so the page reads as paper rather than as a screen */
  background-image:
    radial-gradient(circle at 20% 10%, rgba(0,0,0,.014) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.012) 0 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
}

/* ── masthead ─────────────────────────────────────────────── */

.masthead {
  width: 100%;
  max-width: var(--measure);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 2.75rem 0 2rem;
}

.brandmark {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--vermilion);
  color: #fff;
  font-size: 1.7rem;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  box-shadow: 0 2px 10px rgba(192, 57, 43, .28);
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.tagline {
  margin: .15rem 0 0;
  color: var(--ink-soft);
  font-size: .95rem;
}

main { width: 100%; max-width: var(--measure); }

.stage { animation: rise .45s cubic-bezier(.2,.7,.3,1) both; }

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

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

/* ── dropzone ─────────────────────────────────────────────── */

#dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 3.5rem 1.5rem;
  border: 1.5px dashed var(--rule);
  border-radius: var(--radius);
  background: var(--paper-deep);
  color: var(--ink-faint);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s, transform .18s;
}

#dropzone:hover,
#dropzone:focus-visible,
#dropzone.is-over {
  border-color: var(--vermilion);
  color: var(--vermilion);
  outline: none;
  transform: translateY(-1px);
}

#dropzone.is-over { background: color-mix(in srgb, var(--vermilion) 7%, var(--paper-deep)); }

.dz-title { color: var(--ink); font-size: 1.15rem; }
.dz-sub   { font-size: .85rem; }

.samples { margin-top: 1.5rem; text-align: center; }

.samples-label {
  display: block;
  margin-bottom: .6rem;
  color: var(--ink-faint);
  font-size: .85rem;
}

.sample-strip { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }

.sample-strip button {
  width: 84px;
  height: 84px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  transition: transform .18s, border-color .18s;
}

.sample-strip button:hover { transform: translateY(-2px); border-color: var(--vermilion); }
.sample-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fineprint {
  margin-top: 1.75rem;
  color: var(--ink-faint);
  font-size: .8rem;
  text-align: center;
}

/* ── waiting ──────────────────────────────────────────────── */

#stage-wait { padding: 5rem 0; text-align: center; }

.inkwell { display: flex; gap: .55rem; justify-content: center; margin-bottom: 1.5rem; }

.inkwell span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--vermilion);
  animation: drip 1.25s ease-in-out infinite;
}

.inkwell span:nth-child(2) { animation-delay: .16s; }
.inkwell span:nth-child(3) { animation-delay: .32s; }

@keyframes drip {
  0%, 70%, 100% { opacity: .25; transform: translateY(0); }
  35%           { opacity: 1;   transform: translateY(-7px); }
}

.wait-line {
  margin: 0;
  color: var(--ink-soft);
  font-style: italic;
  transition: opacity .3s;
}

/* ── the card ─────────────────────────────────────────────── */

.card-frame {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.08);
}

#card { display: block; width: 100%; height: auto; }

.readout {
  margin: 2rem 0 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.readout p { margin: 0 0 .55rem; }

.ja {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: 1.4rem;
  line-height: 1.9;
  white-space: pre-line;
}

.romaji { color: var(--ink-faint); font-size: .88rem; font-style: italic; white-space: pre-line; }

.en {
  margin-top: 1rem !important;
  font-size: 1.08rem;
  line-height: 1.85;
  white-space: pre-line;
}

.note {
  margin-top: 1.1rem !important;
  color: var(--ink-soft);
  font-size: .9rem;
  font-style: italic;
}

.badges {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.1rem !important;
}

.badge {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 999px;
  font-size: .78rem;
  letter-spacing: .04em;
}

.badge:empty { display: none; }

.badge-kigo { border: 1px solid var(--vermilion); color: var(--vermilion); }

.badge-metre {
  border: 1px solid var(--rule);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ── buttons ──────────────────────────────────────────────── */

.actions {
  display: flex;
  gap: .6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn {
  padding: .62rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: .92rem;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}

.btn:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn-primary {
  border-color: var(--vermilion);
  background: var(--vermilion);
  color: #fff;
}

.btn-primary:hover { border-color: var(--vermilion); filter: brightness(1.07); }
.btn-quiet { color: var(--ink-faint); }

/* ── error ────────────────────────────────────────────────── */

#stage-error { padding: 4rem 0; text-align: center; }
.err-mark { margin: 0 0 .5rem; color: var(--vermilion); font-size: 2rem; letter-spacing: .3em; }
.err-msg  { margin: 0 0 1.5rem; color: var(--ink-soft); }

/* ── colophon ─────────────────────────────────────────────── */

.colophon {
  width: 100%;
  max-width: var(--measure);
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: .8rem;
  text-align: center;
}

.colophon p { margin: 0; }

@media (max-width: 40rem) {
  body { padding-inline: 1rem; }
  .masthead { padding-top: 2rem; }
  #dropzone { padding: 2.5rem 1rem; }
}
