/* ==========================================================================
   Saving Stella - contract desk
   Tokens, fonts and component shapes taken from the band site's css/styles.css
   so the signing page reads as part of savingstella.com.
     - Heading font : Shrikhand
     - Body font    : Open Sans
     - accent       : #8f4427 (terracotta, from the logo)
   ========================================================================== */

:root {
  --charcoal:    #1e1d1d;
  --white:       #ffffff;
  --mid-gray:    #bfbfbf;
  --light-gray:  #dedede;
  --accent:      #8f4427;
  --accent-dark: #743620;

  --field-border: #b6b6b6;
  --muted: #5d5d5d;
  --ok: #1f6b46;
  --warn: #8a5a08;
  --danger: #8a1f1f;

  --font-heading: "Shrikhand", Georgia, serif;
  --font-body: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --maxw: 1180px;
  --radius: 12px;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--charcoal);
  background: var(--light-gray);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.site-header :focus-visible, .site-footer :focus-visible { outline-color: #fff; }

.skip-link {
  position: absolute; left: 8px; top: -56px; z-index: 100;
  background: var(--charcoal); color: var(--white);
  padding: 10px 16px; border-radius: 6px; font-weight: 700;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; text-decoration: none; }

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 400; line-height: 1.15;
  margin: 0 0 .5em; letter-spacing: .01em;
}
h1 { font-size: clamp(1.9rem, 5vw, 2.9rem); }
p { margin: 0 0 1.1em; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* --- header / footer, mirroring the site ---------------------------------- */
.site-header { background: var(--charcoal); }
.site-header .container {
  display: flex; align-items: center; justify-content: center;
  min-height: 84px; gap: 20px;
}
.brand { display: inline-flex; align-items: center; }
.brand img { height: 52px; width: auto; }

.site-footer {
  background: var(--charcoal); color: var(--white);
  text-align: center; padding: 40px 0; margin-top: 56px;
}
/* inline-block + padding gets these over the 24px minimum target size. */
.site-footer a {
  color: var(--white); text-decoration: underline;
  display: inline-block; padding: 3px 2px; min-height: 24px;
}
.site-footer p { margin: 0 0 .35em; font-size: .95rem; }
.site-footer .copyright { color: var(--mid-gray); font-size: .82rem; margin: 0; }

/* --- page intro ----------------------------------------------------------- */
.page-intro { text-align: center; padding: 44px 0 8px; }
.page-intro h1 { margin-bottom: .25em; }
.page-intro .lead {
  font-size: 1.05rem; color: var(--muted);
  max-width: 560px; margin: 0 auto;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 24px 24px 0; }
.wrap--narrow { max-width: 660px; }

/* --- cards ---------------------------------------------------------------- */
.card {
  background: var(--white);
  border: 1px solid rgba(30, 29, 29, .12);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 22px;
}

h2 {
  font-family: var(--font-body);
  font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; color: var(--charcoal);
  margin: 0 0 18px;
}

/* A heading that starts a distinct block within a card, set off by a rule. */
h2.divider {
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid rgba(30, 29, 29, .12);
}
/* Used in both headings and field labels, so not scoped to h2. */
.subtle { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.section-head h2 { margin-bottom: 18px; }
.section-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-head-actions .note { margin: 0; font-size: .78rem; }

/* --- form fields ---------------------------------------------------------- */
label {
  display: block;
  font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 7px;
}

input[type=text], input[type=email], input[type=tel], input[type=date],
input[type=number], input[type=password], select, textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 1rem;
  padding: 13px 16px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--white); color: var(--charcoal);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(143, 68, 39, .20);
}
input[readonly] { background: #f2f0ee; color: var(--muted); border-style: dashed; }

/* A required field left blank on submit. */
input.invalid, select.invalid {
  border-color: var(--danger);
  background: #fdf6f6;
}
input.invalid:focus { box-shadow: 0 0 0 3px rgba(138, 31, 31, .16); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid .full { grid-column: 1 / -1; }
.field { margin-bottom: 18px; }

/* --- buttons: the site's pill ---------------------------------------------- */
button {
  font-family: var(--font-body); font-weight: 700;
  font-size: .95rem; letter-spacing: .08em; text-transform: uppercase;
  padding: 16px 38px; border-radius: 999px;
  border: 2px solid var(--accent); background: var(--accent);
  color: var(--white); cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
button:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.secondary {
  background: transparent; color: var(--charcoal); border-color: var(--charcoal);
}
button.secondary:hover:not(:disabled) {
  background: var(--charcoal); color: var(--white); border-color: var(--charcoal);
}

button.tiny { padding: 9px 20px; font-size: .72rem; letter-spacing: .1em; }

/* --- package / add-on pickers --------------------------------------------- */
/* These option rows are <label>s, so they'd otherwise inherit the uppercase,
   letter-spaced treatment meant for field labels. Reset them to body text. */
.pkg-option, .addon, .consent {
  text-transform: none; letter-spacing: 0; font-weight: 400;
  font-size: 1rem; margin-bottom: 0;
}

.pkg { display: grid; gap: 12px; }
.pkg-option {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--field-border); border-radius: 10px;
  padding: 16px 18px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.pkg-option:has(input:checked) { border-color: var(--accent); background: rgba(143, 68, 39, .05); }
.pkg-option input { margin-top: 2px; }
.pkg-option strong { display: block; font-size: 1rem; }
.pkg-option span { font-size: .88rem; color: var(--muted); }

.addons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.addon {
  display: flex; align-items: center; gap: 11px; font-size: .95rem;
  border: 1px solid var(--field-border); border-radius: 10px;
  padding: 13px 16px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.addon:has(input:checked) { border-color: var(--accent); background: rgba(143, 68, 39, .05); }
.addon input { flex-shrink: 0; }

/* Checkboxes and radios default to ~13px, well under the 24px minimum tap
   target the band site follows (WCAG 2.5.8). Size them up everywhere. */
input[type=checkbox], input[type=radio] {
  width: 24px; height: 24px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* An inline <a> wrapping a button collapses to a text-height box; make it
   match its child so the whole control is the hit area. */
a:has(> button) { display: inline-block; }
.addon .price { margin-left: auto; color: var(--muted); font-size: .88rem; white-space: nowrap; }

/* --- totals --------------------------------------------------------------- */
.totals { border-top: 1px solid rgba(30, 29, 29, .15); margin-top: 22px; padding-top: 16px; }
.totals .row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: .95rem; }
.totals .row span:last-child { white-space: nowrap; }
.totals .row.sub { color: var(--muted); font-size: .9rem; }
.totals .row.grand {
  font-weight: 700; font-size: 1.15rem;
  border-top: 1px solid rgba(30, 29, 29, .15);
  margin-top: 10px; padding-top: 13px;
}

/* --- contract list -------------------------------------------------------- */
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th {
  text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  padding: 0 10px 10px 0; border-bottom: 1px solid rgba(30, 29, 29, .15);
}
table.list td {
  padding: 14px 10px 14px 0;
  border-bottom: 1px solid rgba(30, 29, 29, .1);
  vertical-align: middle;
}
table.list td:last-child { text-align: right; padding-right: 0; }

.badge {
  display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; padding: 5px 11px; border-radius: 999px;
}
.badge.sent { background: var(--light-gray); color: #4a4a4a; }
.badge.viewed { background: #f6e9cf; color: var(--warn); }
.badge.signed { background: #d9ebe0; color: var(--ok); }

/* --- misc ----------------------------------------------------------------- */
.linkbox {
  display: flex; gap: 10px; align-items: center; margin-top: 14px;
  background: #f2f0ee; border-radius: 10px; padding: 10px 12px;
}
.linkbox input {
  border: none; background: transparent; padding: 4px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem;
}
.linkbox input:focus { box-shadow: none; }

canvas#pad {
  display: block; /* ResizeObserver skips inline elements, and the pad relies
                     on it to size itself once its card becomes visible */
  width: 100%; height: 190px; touch-action: none; cursor: crosshair;
  background: var(--white);
  border: 2px dashed var(--field-border); border-radius: 10px;
}
canvas#pad.signed { border-style: solid; border-color: var(--accent); }

/* --- signature method: draw / type ---------------------------------------- */
.sigmode {
  display: inline-flex; gap: 4px; margin-bottom: 14px;
  background: #f2f0ee; padding: 4px; border-radius: 999px;
}
.sigmode-btn {
  /* width:auto beats the full-width button rule in the mobile block — these are
     segmented-control segments, not primary actions. */
  width: auto;
  white-space: nowrap;
  background: transparent; border: none; color: var(--muted);
  padding: 9px 22px; border-radius: 999px;
  font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
}
.sigmode-btn:hover:not(.is-active) { background: rgba(30, 29, 29, .06); color: var(--charcoal); }
.sigmode-btn.is-active { background: var(--accent); color: var(--white); }

/* Three equal choices, side by side at every width — they're short labels and
   stacking them full-width wastes a screen on a phone. */
.sigstyles {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.sigstyle {
  width: auto;
  background: var(--white); border: 1px solid var(--field-border); color: var(--charcoal);
  border-radius: 10px; padding: 10px 12px;
  font-size: 1.25rem; text-transform: none; letter-spacing: 0; font-weight: 400;
  line-height: 1.5;
}
.sigstyle:hover:not(.is-active) { background: #f7f5f3; border-color: var(--charcoal); }
.sigstyle.is-active {
  border-color: var(--accent); background: rgba(143, 68, 39, .06); color: var(--charcoal);
}

.sigpreview {
  display: flex; align-items: center; justify-content: center;
  min-height: 110px; padding: 12px 20px;
  border: 2px solid var(--accent); border-radius: 10px; background: var(--white);
  line-height: 1.3; color: var(--charcoal);
  /* One line, like the PDF — drawPreview() shrinks the type to fit so the
     preview is what actually lands on the contract. */
  white-space: nowrap; overflow: hidden; text-align: center;
}
.sigpreview.is-empty { border-style: dashed; border-color: var(--field-border); }
.sigpreview.is-empty::before {
  content: 'Your signature appears here';
  font-family: var(--font-body); font-size: .88rem; color: var(--muted);
}

.consent {
  display: flex; gap: 13px; align-items: flex-start;
  background: #f2f0ee; border-radius: 10px;
  padding: 18px; font-size: .92rem; line-height: 1.55;
}
.consent input { margin-top: 1px; }

.note { font-size: .88rem; color: var(--muted); margin: 0 0 16px; }

.error {
  background: #fbeaea; color: var(--danger);
  border-left: 5px solid var(--danger); border-radius: 10px;
  padding: 14px 16px; font-size: .95rem; font-weight: 600; margin-bottom: 18px;
}
/* Green, not the terracotta accent — this has to read as "it worked" at a
   glance, distinct from the brand colour used everywhere else on the page. */
.success {
  background: #eaf6ee;
  color: #10492b;
  border: 2px solid var(--ok);
  border-radius: 12px;
  padding: 18px 20px 18px 48px;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 18px;
  position: relative;
}
/* Tick drawn from a rotated box corner, so there's no icon font to load. */
.success::before {
  content: '';
  position: absolute;
  left: 20px; top: 50%;
  width: 7px; height: 13px;
  margin-top: -9px;
  border: solid var(--ok);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.hidden { display: none !important; }
.spacer { height: 14px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

/* --- responsive ----------------------------------------------------------- */
@media (max-width: 860px) {
  .addons { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .container, .wrap { padding-left: 18px; padding-right: 18px; }
  .wrap { padding-top: 16px; }
  .card { padding: 20px 18px; border-radius: 10px; }
  .grid { grid-template-columns: 1fr; gap: 0; }
  .page-intro { padding: 32px 0 4px; }
  .site-header .container { min-height: 68px; }
  .brand img { height: 42px; }
  .site-footer { padding: 32px 0; margin-top: 40px; }

  /* Full-width tap targets; 38px of side padding is wasteful on a phone. */
  button { width: 100%; padding: 16px 20px; }
  button.tiny { width: auto; padding: 9px 18px; }
  .actions button { width: 100%; }
  .section-head-actions { width: 100%; justify-content: space-between; }

  /* The contract table becomes stacked rows — five columns will not fit. */
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr {
    border: 1px solid rgba(30, 29, 29, .14); border-radius: 10px;
    padding: 16px; margin-bottom: 14px;
  }
  table.list td { border: none; padding: 3px 0; }
  table.list td:last-child { text-align: left; margin-top: 12px; }
  table.list td[data-label]::before {
    content: attr(data-label) " ";
    font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
    color: var(--muted); font-weight: 700; margin-right: 6px;
  }

  .linkbox { flex-direction: column; align-items: stretch; }
  .linkbox button { width: 100%; }
  canvas#pad { height: 200px; }
}
