/* Fonts are served from this app, not from Google, so the site can run under a
   strict Content-Security-Policy with no third-party origins. */
@import url("fonts/fonts.css");

:root {
  --ink:        #17251d;
  --ink-soft:   #45564c;
  --pine:       #0f4d2f;
  --pine-deep:  #0a3a23;
  --paper:      #f6f1e3;
  --paper-2:    #fffdf6;
  --rule:       #d9cfb6;
  --gold:       #c08a2d;
  --gold-soft:  #e7d3a3;
  --err:        #a8321f;
  --focus:      #0f4d2f;

  --radius: 4px;
  --maxw: 760px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #12592f 0%, #0a3a23 55%, #072b1a 100%);
  min-height: 100vh;
  padding: clamp(12px, 4vw, 48px);
  line-height: 1.55;
}

/* ---- The sheet of paper ---- */
.sheet {
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.55), 0 2px 0 rgba(0,0,0,.2);
  padding: clamp(20px, 5vw, 56px);
  position: relative;
  overflow: hidden;
}
.sheet::before { /* red margin line, like exercise paper */
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: clamp(14px, 4vw, 40px);
  width: 1px;
  background: rgba(168,50,31,.28);
}

/* ---- Masthead ---- */
.masthead { position: relative; padding-bottom: 28px; margin-bottom: 8px; border-bottom: 2px solid var(--ink); }

.postmark {
  position: absolute;
  top: -6px; right: 0;
  width: 96px; height: 96px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  color: var(--pine);
  transform: rotate(-9deg);
  opacity: .85;
  font-family: var(--mono);
}
.postmark::after {
  content: ""; position: absolute; inset: 6px;
  border: 1px dashed var(--gold); border-radius: 50%;
}
.postmark__top { font-size: 11px; letter-spacing: .18em; font-weight: 700; }
.postmark__mid { font-size: 10px; margin: 2px 0; }
.postmark__bot { font-size: 9px; max-width: 74px; letter-spacing: .04em; line-height: 1.1; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 6px;
}
.title {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(40px, 9vw, 74px);
  line-height: .96;
  letter-spacing: -.02em;
  margin: 0;
  color: var(--pine-deep);
}
.title .cursor { color: var(--gold); }
.lede {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(16px, 2.4vw, 20px);
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 14px 0 0;
}
.deadline {
  display: inline-block;
  margin-top: 18px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  color: var(--paper);
  background: var(--pine);
  padding: 6px 12px; border-radius: 999px;
}

/* ---- Form structure ---- */
.form { margin-top: 8px; }
.fieldset { padding: 30px 0; border-bottom: 1px dotted var(--rule); }
.fieldset:last-of-type { border-bottom: none; }

.legend {
  font-family: var(--serif);
  font-weight: 600; font-size: 22px;
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 18px;
}
.legend__no {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  width: 28px; height: 28px; flex: none;
  display: grid; place-content: center;
  color: var(--paper); background: var(--pine);
  border-radius: 50%;
}
.note {
  font-size: 14px; color: var(--ink-soft);
  margin: -8px 0 18px; max-width: 60ch;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }

label, .label-as-question {
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  color: var(--ink);
}
.label-as-question { display: block; margin-bottom: 8px; }
.opt { font-weight: 400; color: var(--ink-soft); }

input, select, textarea {
  font-family: var(--sans); font-size: 16px; color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  padding: 11px 12px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: right 15px center, right 10px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(15,77,47,.15);
}

/* ---- Ruled-paper essay area ---- */
.essay-head { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.counter.over { color: var(--err); font-weight: 700; }

.paper {
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-2);
  overflow: hidden;
  margin-top: 6px;
}
.paper:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(15,77,47,.15); }
.salutation {
  font-family: var(--serif); font-size: 20px; font-weight: 500; font-style: italic;
  color: var(--pine-deep);
  margin: 0; padding: 16px 18px 0;
}
.paper textarea {
  border: none; background: transparent; box-shadow: none !important;
  border-radius: 0;
  line-height: 34px;
  padding: 6px 18px 18px;
  background-image: repeating-linear-gradient(
    to bottom, transparent, transparent 33px, var(--rule) 33px, var(--rule) 34px
  );
  background-attachment: local;
  resize: vertical;
  min-height: 260px;
}
.paper textarea:focus { outline: none; }

.meter { height: 4px; background: var(--rule); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--pine); transition: width .2s, background .2s; }
.meter span.over { background: var(--err); }

/* ---- Choices ---- */
.radio, .check {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 15px; font-weight: 400; line-height: 1.5;
  padding: 10px 0; cursor: pointer;
}
.radio input, .check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--pine); cursor: pointer; }
.check + .err { margin-top: -6px; }
.check span strong, .radio span strong { font-weight: 600; }

.privacy {
  font-size: 12.5px; line-height: 1.6; color: var(--ink-soft);
  background: rgba(15,77,47,.05);
  border-left: 3px solid var(--gold);
  padding: 12px 14px; margin-top: 18px; border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---- Errors ---- */
.err { color: var(--err); font-size: 12.5px; font-weight: 500; min-height: 0; margin: 0; }
.err:empty { display: none; }
input[aria-invalid="true"], select[aria-invalid="true"], .paper[aria-invalid="true"] { border-color: var(--err); }

/* ---- Actions ---- */
.actions { padding-top: 28px; text-align: center; }
.submit {
  font-family: var(--serif); font-weight: 600; font-size: 19px;
  color: var(--paper); background: var(--pine);
  border: none; border-radius: var(--radius);
  padding: 15px 40px; cursor: pointer;
  box-shadow: 0 6px 0 var(--pine-deep);
  transition: transform .08s, box-shadow .08s, background .15s;
}
.submit:hover { background: var(--pine-deep); }
.submit:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pine-deep); }
.submit:disabled { opacity: .6; cursor: progress; }
.form-error { color: var(--err); font-weight: 600; margin: 14px 0 0; }
.form-error:empty { display: none; }

/* ---- Success ---- */
.success { text-align: center; padding: 16px 0 8px; animation: rise .4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stamp-check {
  width: 72px; height: 72px; margin: 0 auto 16px;
  display: grid; place-content: center;
  font-size: 34px; color: var(--paper);
  background: var(--pine); border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(15,77,47,.15);
}
.success__title { font-family: var(--serif); font-weight: 900; font-size: clamp(28px,6vw,42px); color: var(--pine-deep); margin: 0 0 6px; }
.success__ref { font-family: var(--mono); font-size: 14px; color: var(--ink-soft); margin: 0 0 4px; }
.success__ref span { color: var(--pine); font-weight: 700; }
.success__msg { max-width: 46ch; margin: 8px auto 26px; color: var(--ink-soft); }

.card-wrap { max-width: 420px; margin: 0 auto 22px; }
#shareCard { width: 100%; height: auto; border-radius: var(--radius); box-shadow: 0 14px 36px -12px rgba(0,0,0,.5); display: block; }

.share { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.share__btn {
  font-family: var(--sans); font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--paper); background: var(--ink);
  padding: 12px 18px; border-radius: var(--radius); border: none; cursor: pointer;
  transition: opacity .15s;
}
.share__btn:hover { opacity: .88; }
.share__btn--dl { background: var(--gold); color: #2a1e05; }
.share__btn--wa { background: #1faa54; }
.share__btn--x  { background: #14171a; }
.share__btn--fb { background: #1877f2; }
.share__hint { font-size: 13px; color: var(--ink-soft); margin-top: 14px; }
.share__hint:empty { display: none; }

.foot { margin-top: 34px; padding-top: 18px; border-top: 2px solid var(--ink); text-align: center; font-family: var(--mono); font-size: 12px; letter-spacing: .05em; color: var(--ink-soft); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Mobile ---- */
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .postmark { width: 76px; height: 76px; top: -2px; }
  .sheet::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
