/* ============================================================
   The builder.

   Deliberately a modern tool rather than a piece of stationery: cool light
   surfaces, one accent, generous space. The warm handmade world stays inside
   the phone — the contrast is the point. The accent is the letter's own
   fountain-pen blue, so the tool still belongs to the thing it makes.
   ============================================================ */

@font-face {
  font-family: "Hand";
  src: url("fonts/cedarville.woff2") format("woff2");
  font-display: swap;
}
/* Cedarville has no Devanagari, so Hindi falls through to this glyph by glyph.
   The unicode-range keeps its 107KB off the wire for a Latin-only letter. */
@font-face {
  font-family: "HandDev";
  src: url("fonts/kalam-devanagari.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+A830-A839, U+A8E0-A8FF;
}

:root {
  color-scheme: light;

  /* the neutrals carry a slight blue bias, so they read as chosen rather than
     as whatever grey came to hand */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --raised: #fbfcfe;
  --line: #e2e6ee;
  --line-strong: #ccd3e0;

  --text: #161b26;
  --text-2: #5b6577;
  --text-3: #8d95a5;

  --accent: #1f3a6e;
  --accent-hi: #2c5099;
  --accent-soft: #eaeff8;

  --ok: #147051;
  --warn: #b03028;
  --warn-soft: #fdf1f0;

  --hand: "Hand", "HandDev", cursive;
  --ui: "Inter var", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r: 10px;
  --shadow: 0 1px 2px rgba(20, 27, 45, 0.05), 0 8px 24px rgba(20, 27, 45, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Top bar and progress
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 26px;
}
.brand {
  font-family: var(--hand);
  font-size: 27px;
  line-height: 1;
  color: var(--accent);
  flex: none;
}

.steps { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; overflow-x: auto; }
.step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
}
.step-n {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--line);
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 700;
  flex: none;
}
.step[data-state="done"] { color: var(--text-2); }
.step[data-state="done"] .step-n { background: var(--accent-soft); color: var(--accent); }
.step[data-state="now"] { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.step[data-state="now"] .step-n { background: var(--accent); color: #fff; }

.progress { height: 2px; background: var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 320ms cubic-bezier(0.4, 0, 0.2, 1); }

/* ============================================================
   Layout
   ============================================================ */
/* One column: the letter is not shown beside the form at all. It waits until
   the last step, where it gets the whole width and plays by itself. */
.shell { max-width: 660px; margin: 0 auto; padding: 26px 22px 44px; }
.panel.wide { max-width: none; }

/* ============================================================
   Panels
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 28px;
  box-shadow: var(--shadow);
}
.panel[hidden] { display: none; }

.panel h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
}
.sub { margin: 0 0 2px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.blurb { margin: 6px 0 20px; color: var(--text-2); font-size: 14px; max-width: 60ch; }

.divider { height: 1px; background: var(--line); margin: 26px 0 22px; }

/* ---------- ready-made letters ---------- */
.grouphead {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 9px; }
.pick {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--raised);
  padding: 11px 13px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}
.pick:hover { border-color: var(--line-strong); background: #fff; }
.pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.pick-name { display: block; font-family: var(--hand); font-size: 20px; line-height: 1.25; color: var(--accent); }
.pick-note { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-2); }

/* ---------- fields ---------- */
.field { margin-top: 18px; }
.field > label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.field .hint { display: block; font-size: 12.5px; color: var(--text-3); margin-bottom: 7px; }
.field > label + input, .field > label + textarea { margin-top: 5px; }

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  font-family: var(--ui);
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
  color: var(--text);
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 58, 110, 0.12);
}
textarea { resize: vertical; min-height: 62px; line-height: 1.5; }

.field.short input, .field.short textarea { max-width: 240px; }
.field.tiny input { max-width: 88px; text-align: center; }

/* what becomes handwriting is asked for in that hand */
.pen input[type="text"], .pen textarea {
  font-family: var(--hand);
  font-size: 21px;
  color: var(--accent);
  padding: 8px 12px;
}

/* ---------- language ---------- */
.langpick { display: inline-flex; gap: 0; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.langbtn {
  border: 0;
  background: var(--surface);
  padding: 9px 20px;
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 130ms ease, color 130ms ease;
}
.langbtn + .langbtn { border-left: 1px solid var(--line); }
.langbtn:hover { background: var(--raised); color: var(--text); }
.langbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.langbtn[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- paragraphs, and how far into the fold they reach ---------- */
.para { position: relative; }
.para textarea { min-height: 78px; padding-bottom: 26px; }
.para .fit {
  position: absolute;
  right: 11px;
  bottom: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  background: #fff;
  padding-left: 6px;
}
.fit.over { color: var(--warn); }
.para.over textarea { border-color: var(--warn); background: var(--warn-soft); }
.para.over .fit { background: var(--warn-soft); }

.select {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  font-family: var(--ui);
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 58, 110, 0.12); }

.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 20px; }

/* what the two names turn into, so nobody has to guess */
.derived {
  margin: 22px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  line-height: 1.5;
}
.derived:empty { display: none; }

/* ============================================================
   The phone
   ============================================================ */
.phone-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 6px; }
.phone {
  position: relative;
  width: 320px;
  padding: 11px;
  border-radius: 40px;
  background: linear-gradient(160deg, #2b3242, #171c26);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 18px 40px rgba(20, 27, 45, 0.28),
    0 3px 10px rgba(20, 27, 45, 0.18);
}
.phone-notch {
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 104px;
  height: 21px;
  border-radius: 0 0 13px 13px;
  background: #171c26;
  z-index: 2;
}
.phone-screen {
  position: relative;
  width: 298px;
  height: 620px;
  border-radius: 30px;
  overflow: hidden;
  background: #a8926f;
}
.phone-screen iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 375px;
  height: 780px;
  border: 0;
  /* the letter is built for a 375px phone, so it is shown at that width and
     scaled down rather than reflowed — a reflowed preview would not be a
     preview */
  transform: scale(0.7947);
  transform-origin: top left;
}

.phone-under { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.phone-note { font-size: 12px; color: var(--text-3); }

/* ============================================================
   Buttons, nav, the link
   ============================================================ */
.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 4px 0;
}
.nav .says { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--ui);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 130ms ease, box-shadow 130ms ease, transform 90ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn[hidden] { display: none; }

.primary { background: var(--accent); color: #fff; }
.primary:hover:not([disabled]) { background: var(--accent-hi); }
.ghost { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ghost:hover { background: var(--raised); }
.quiet { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.quiet:hover { background: var(--surface); color: var(--text); }
.danger { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px rgba(176, 48, 40, 0.28); }
.danger:hover { background: #fbe6e4; }
.tiny-btn { padding: 6px 12px; font-size: 12.5px; background: var(--surface); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tiny-btn:hover { color: var(--text); }

.says { font-size: 13px; font-weight: 600; color: var(--ok); }
.says.warn { color: var(--warn); }

.linkbox {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.linkurl {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  user-select: all;
}
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

.takedown { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
.takedown summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.takedown summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.takedown[open] summary { margin-bottom: 10px; }

#probe { position: absolute; visibility: hidden; white-space: nowrap; left: -9999px; top: 0; }

@media (max-width: 979px) {
  .phone { width: 268px; padding: 9px; border-radius: 34px; }
  /* the screen must equal 375x780 times the scale, or the letter is clipped:
     375 x 0.6667 = 250, 780 x 0.6667 = 520 */
  .phone-screen { width: 250px; height: 520px; border-radius: 26px; }
  .phone-screen iframe { transform: scale(0.6667); }
  .panel { padding: 20px 18px 22px; border-radius: 12px; }
  .topbar-in { gap: 14px; padding: 10px 16px; }
  .step-name { display: none; }
  .step { padding: 5px; }
  .shell { padding: 18px 16px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .pick, input, textarea, .progress i { transition: none; }
}
