/* DEDICATED STUDIOS: hard edges, black ground, one signal accent (matches the studio website). */

:root {
  --ink: #0A0A0B;
  --ink-2: #111113;
  --ink-3: #1A1A1D;
  --rule: #2E2E33;
  --bone: #F2F1EC;
  --muted: #A9A8A3;
  --accent: #FF5B23;
  --soft: #D6D5D0;

  --display: "Archivo", "Arial Black", sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--ink); }

/* ---------- Top bar and footer ---------- */

.top {
  display: flex;
  align-items: center;
  height: 72px;
  padding: 0 var(--gutter);
  border-bottom: 2px solid var(--rule);
}
.brand {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.foot {
  margin-top: auto;
  padding: 48px var(--gutter) 32px;
  border-top: 2px solid var(--rule);
  overflow: hidden;
}
.foot__mark { display: flex; flex-direction: column; align-items: center; gap: 12px; user-select: none; }
.foot__word {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 900;
  font-size: clamp(40px, 9vw, 120px);
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 2px var(--rule);
}
.foot__sub {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 0.9em;
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 900;
  font-size: clamp(14px, 2vw, 26px);
  letter-spacing: 0.6em;
  color: var(--accent);
}
.foot__sub::before, .foot__sub::after { content: ""; flex: 1; height: 3px; background: var(--accent); }
.foot__sub::after { margin-left: -0.6em; }

/* ---------- Layout and type ---------- */

main { width: 100%; max-width: 880px; margin: 0 auto; padding: 56px var(--gutter) 80px; }
main.wide { max-width: 1180px; }

h1 {
  margin: 0 0 20px;
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 900;
  /* Sized so "MEDLEMSKONTRAKT" (the longest heading) always fits the column. */
  font-size: clamp(22px, calc((min(100vw, 880px) - 2 * var(--gutter)) / 14.5), 72px);
  line-height: 0.9;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}
h2 {
  margin: 0;
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.lead { margin: 0 0 8px; font-size: clamp(18px, 1.8vw, 21px); line-height: 1.45; color: var(--soft); }
.lead strong { color: var(--bone); }
.muted, small { color: var(--muted); }
small { display: block; font-size: 14px; }
p a { color: var(--bone); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }

.card {
  background: var(--ink-2);
  border: 2px solid var(--rule);
  padding: clamp(18px, 3vw, 28px);
  margin: 24px 0;
}
.card.narrow { max-width: 520px; margin: 24px auto; }
.card.narrow h1 { font-size: clamp(24px, 6vw, 36px); }
.card.highlight { border-color: var(--accent); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack label { display: flex; flex-direction: column; gap: 8px; font-weight: 700; }

/* ---------- Controls ---------- */

input[type="text"], input[type="email"], input[type="password"], input:not([type]) {
  font: inherit;
  padding: 12px 14px;
  border: 2px solid var(--rule);
  width: 100%;
  background: var(--ink);
  color: var(--bone);
}
input::placeholder { color: #6E6D69; }
input:focus { outline: none; border-color: var(--accent); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  font-family: var(--display);
  font-stretch: 112%;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 0 var(--bone);
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
button:hover:not(:disabled), .button:hover { transform: translate(-4px, -4px); box-shadow: 4px 4px 0 var(--bone); }
button:active:not(:disabled), .button:active { transform: translate(0, 0); box-shadow: 0 0 0 var(--bone); }
button.secondary, .button.secondary { background: var(--ink); border-color: var(--bone); color: var(--bone); }
button.danger { background: var(--ink); border-color: var(--accent); color: var(--accent); }
button.small { min-height: 34px; padding: 0 12px; font-size: 12px; }
button:disabled { background: var(--ink-3); border-color: var(--rule); color: #6E6D69; cursor: not-allowed; }
.button.discord { background: #5865F2; border-color: #5865F2; color: #fff; }

.error {
  color: var(--bone);
  background: rgba(255, 91, 35, 0.12);
  border: 2px solid var(--accent);
  padding: 12px 14px;
}

/* ---------- Contract viewer ---------- */

.viewer {
  height: 70vh;
  overflow: auto;
  background: var(--ink);
  border: 2px solid var(--rule);
  margin: 18px 0 10px;
  padding: 14px;
}
.viewer canvas { display: block; width: 100%; height: auto; margin: 0 auto 14px; background: #fff; }
.read-done { color: var(--accent); font-weight: 700; }

/* ---------- Signature ---------- */

#sign-card h2 { margin-bottom: 16px; }
.pad-label { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 8px; }
/* Paper-white so the dark ink reads as it will on the contract. */
.pad {
  display: block;
  width: 100%;
  height: 200px;
  border: 2px dashed var(--muted);
  background: var(--bone);
  touch-action: none;
  cursor: crosshair;
}
.check { flex-direction: row !important; align-items: center; gap: 12px !important; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- Admin ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--ink-2); border: 2px solid var(--rule); }
th, td { text-align: left; padding: 14px; border-bottom: 2px solid var(--rule); vertical-align: top; }
th { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
td.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
form.inline { display: flex; gap: 10px; }
form.inline input { width: 220px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 2px solid var(--rule);
  color: var(--muted);
}
.badge.signed { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.badge.sent { border-color: var(--bone); color: var(--bone); }

.copy { display: flex; gap: 10px; }
.copy input { font-family: var(--mono); font-size: 14px; }

@media (max-width: 640px) {
  form.inline { flex-direction: column; width: 100%; }
  form.inline input { width: 100%; }
  .copy { flex-direction: column; }
  td.actions .button, td.actions button { width: 100%; }
}

.row-gap { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Demo ---------- */

.demo-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  padding: 12px 16px;
  border: 2px solid var(--accent);
  color: var(--soft);
  font-size: 15px;
}
.demo-bar strong { color: var(--accent); }
.demo-bar a { font-weight: 700; color: var(--bone); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }

/* ======================================================================
   Motion. Everything here is decoration: with reduced motion it is off.
   ====================================================================== */

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes wipeIn { from { clip-path: inset(0 0 100% 0); transform: translateY(0.25em); } to { clip-path: inset(0 0 0 0); transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes lineOut { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes nudge { 0%, 100% { transform: none; box-shadow: 0 0 0 var(--bone); } 40% { transform: translate(-4px, -4px); box-shadow: 4px 4px 0 var(--bone); } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Page load: the heading wipes up, then everything below rises in order. */
main > * { animation: rise 0.7s var(--ease-out) both; }
main > *:nth-child(2) { animation-delay: 0.08s; }
main > *:nth-child(3) { animation-delay: 0.16s; }
main > *:nth-child(4) { animation-delay: 0.24s; }
main > *:nth-child(5) { animation-delay: 0.32s; }
main > *:nth-child(n + 6) { animation-delay: 0.4s; }
main > h1 { animation: wipeIn 0.8s var(--ease-out) both; }
.top .brand { animation: fadeIn 0.6s ease both; }
.foot__sub::before, .foot__sub::after { animation: lineOut 1.1s var(--ease-out) 0.3s both; }
.foot__sub::before { transform-origin: right center; }
.foot__sub::after { transform-origin: left center; }

/* Contract pages slide in as pdf.js finishes each one. */
.viewer canvas { opacity: 0; transform: translateY(12px); transition: opacity 0.5s ease, transform 0.6s var(--ease-out); transition-delay: calc(var(--i, 0) * 90ms); }
.viewer canvas.is-in { opacity: 1; transform: none; }

/* "Read" hint: a tick draws in when the member reaches the end. */
.read-hint { display: flex; align-items: center; gap: 10px; transition: color 0.3s; }
.read-hint__tick { display: none; flex: none; width: 22px; height: 22px; background: var(--accent); }
.read-hint__tick svg, .who__tick svg { width: 100%; height: 100%; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: square; stroke-dasharray: 24; stroke-dashoffset: 24; }
.read-hint.is-done { color: var(--bone); font-weight: 700; }
.read-hint.is-done .read-hint__tick { display: block; animation: pop 0.35s var(--ease-out) both; }
.read-hint.is-done .read-hint__tick svg { animation: draw 0.35s ease-out 0.2s forwards; }

/* Login button: spinner while Discord opens. */
.spinner { display: none; width: 16px; height: 16px; margin-right: 10px; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
#login-btn.is-loading { pointer-events: none; }
#login-btn.is-loading .spinner { display: inline-block; }

/* Step change: login fades out, the form rises in, and the "logged in" tick pops. */
.step.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity 0.28s ease, transform 0.28s ease; }
.step.is-entering > * { animation: rise 0.6s var(--ease-out) both; }
.step.is-entering > *:nth-child(2) { animation-delay: 0.1s; }
.who { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; color: var(--muted); }
.who strong { color: var(--bone); }
.who__tick { flex: none; width: 22px; height: 22px; background: var(--accent); }
.who__tick svg { stroke-dashoffset: 0; }
.just-in .who__tick { animation: pop 0.4s var(--ease-out) 0.25s both; }
.just-in .who__tick svg { stroke-dashoffset: 24; animation: draw 0.35s ease-out 0.5s forwards; }

/* Signature pad. */
.pad { transition: border-color 0.25s, opacity 0.16s; }
.pad.has-ink { border-color: var(--accent); }
.pad.is-clearing { opacity: 0.2; }

/* Submit: one nudge when everything is filled in, then a sweeping bar while it sends. */
#submit { position: relative; overflow: hidden; transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out), background 0.25s, border-color 0.25s, color 0.25s; }
#submit.is-ready { animation: nudge 0.6s var(--ease-out); }
.busy-bar { display: none; position: absolute; left: 0; bottom: 0; width: 40%; height: 4px; background: var(--ink); }
#submit.is-busy { background: var(--accent); border-color: var(--accent); color: var(--ink); cursor: progress; }
#submit.is-busy .busy-bar { display: block; animation: sweep 1s var(--ease-out) infinite; }
form.is-busy .pad, form.is-busy input { opacity: 0.55; }

/* Errors shake once when they appear. */
.error { animation: shake 0.45s ease both; }
.error.is-shaking { animation: shake 0.45s ease; }

/* Signed: the card swaps out, a tick draws, the word wipes up and the orange line runs out from the middle. */
#sign-card { transition: opacity 0.3s ease, transform 0.3s ease; }
#sign-card.is-leaving { opacity: 0; transform: scale(0.98); }
#sign-card.is-done { border-color: var(--accent); }
.done { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 0 4px; }
.done__check { width: 76px; height: 76px; fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: square; }
.done__check circle { stroke-dasharray: 183; stroke-dashoffset: 183; animation: draw 0.7s var(--ease-out) forwards; transform: rotate(-90deg); transform-origin: center; }
.done__check path { stroke-dasharray: 45; stroke-dashoffset: 45; animation: draw 0.4s ease-out 0.55s forwards; }
.done__title { margin: 22px 0 0; font-size: clamp(30px, 6vw, 54px); line-height: 0.9; letter-spacing: -0.035em; }
.done__title span { display: block; animation: wipeIn 0.7s var(--ease-out) 0.7s both; }
.done__line { width: min(360px, 80%); height: 3px; margin: 18px 0 20px; background: var(--accent); transform: scaleX(0); animation: lineOut 0.9s var(--ease-out) 0.9s forwards; }
.done__text { max-width: 46ch; margin: 0 0 22px; color: var(--soft); animation: rise 0.6s var(--ease-out) 1.05s both; }
.done__actions { animation: rise 0.6s var(--ease-out) 1.2s both; }

/* Admin: the new link card's border draws attention once; copying flashes. */
.card.highlight { animation: rise 0.6s var(--ease-out) both; }
button.is-copied { background: var(--bone); border-color: var(--bone); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-delay: 0s !important; transition-duration: 0.001s !important; transition-delay: 0s !important; }
  .busy-bar { animation: none !important; left: 0; width: 100%; opacity: 0.5; }
  .spinner { animation: none !important; }
}
