/* Punt Vermell - Joc d'Eines. Tramiteonline design system.
   Tokens and component rules come from tramiteonline-design-system.md and
   punt-vermell-joc-deines-spec.md. Keep the token names and exact values. */

:root {
  --brand-navy: #1C244B;
  --brand-slate: #324A6D;
  --brand-blue: #467FF7;
  --brand-blue-hover: #8CB1FF;
  --surface-white: #FFFFFF;
  --surface-50: #F9FAFD;
  --surface-100: #F3F5F8;
  --surface-footer: #E0E4E9;
  --surface-tagline: rgba(50, 74, 109, 0.09);
  --border-200: #C8D5DC;
  --error: #B3261E;
  --error-surface: #FCEEEE;
  --shadow-header: 0 5px 30px rgba(0, 0, 0, .1);
  --shadow-raised: 0 15px 20px rgba(0, 0, 0, .1);
  --radius-button: 5px;
  --radius-card: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-50);
  color: var(--brand-slate);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 300;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header ----------------------------------------------------------------- */

.site-header {
  background: var(--surface-white);
  box-shadow: var(--shadow-header);
  padding: 27px 0;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.site-name {
  color: var(--brand-navy);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}
.pill {
  background: var(--surface-tagline);
  border-radius: 100px;
  padding: 8px 20px;
  font-size: 16px;
  color: var(--brand-slate);
}

/* Page -------------------------------------------------------------------- */

main { flex: 1; padding: 56px 0 72px; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: 10px;
  text-transform: uppercase;
}
h1 {
  margin: 0 0 16px;
  color: var(--brand-navy);
  font-size: clamp(40px, 6vw, 65px);
  font-weight: 600;
  line-height: 1.2;
}
h2 {
  margin: 0 0 8px;
  color: var(--brand-navy);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
}
.lead { margin: 0 0 40px; max-width: 820px; font-size: 22px; }
.helper { margin: 6px 0 0; font-size: 14px; }
.step-number {
  display: block;
  margin-bottom: 4px;
  color: var(--brand-blue);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}

a { color: var(--brand-blue); font-weight: 500; }
a:hover { color: var(--brand-blue-hover); }

/* Cards ------------------------------------------------------------------- */

.card {
  background: var(--surface-white);
  border: 2px solid var(--brand-slate);
  border-radius: var(--radius-card);
  padding: 28px;
  margin-bottom: 24px;
}
.card > p { margin: 0 0 20px; }

/* Fields ------------------------------------------------------------------ */

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px 24px;
}
.field.wide { grid-column: span 2; }
@media (max-width: 600px) { .field.wide { grid-column: auto; } }

label, .label {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-navy);
  font-size: 16px;
  font-weight: 500;
}
.optional { font-weight: 300; color: var(--brand-slate); }

input[type="text"], input[type="email"], input[type="tel"], select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--brand-slate);
  border-radius: 5px;
  background: var(--surface-white);
  color: var(--brand-navy);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
}
input:focus-visible, select:focus-visible, button:focus-visible,
a:focus-visible, .choice:focus-within, .file:focus-within {
  outline: 3px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Choices (radio cards) --------------------------------------------------- */

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--brand-slate);
  border-radius: 5px;
  background: var(--surface-white);
  font-weight: 400;
  cursor: pointer;
}
.choice input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--brand-blue);
}
.choice:has(input:checked) {
  border-color: var(--brand-blue);
  box-shadow: inset 0 0 0 1px var(--brand-blue);
}

/* Document uploads -------------------------------------------------------- */

.documents { display: grid; gap: 16px; }
.document {
  padding: 16px 0 0;
  border-top: 1px solid var(--border-200);
}
.document:first-child { border-top: 0; padding-top: 0; }
.file {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px dashed var(--brand-slate);
  border-radius: 5px;
  background: var(--surface-white);
  color: var(--brand-navy);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
}
.file::file-selector-button {
  margin-right: 14px;
  padding: 8px 16px;
  border: 1px solid var(--brand-slate);
  border-radius: var(--radius-button);
  background: var(--surface-white);
  color: var(--brand-slate);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

/* Buttons ----------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 16px 35px;
  border: 1px solid var(--brand-blue);
  border-radius: var(--radius-button);
  background: var(--brand-blue);
  color: var(--surface-white);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { box-shadow: var(--shadow-raised); color: var(--surface-white); }
.button[disabled] { opacity: .6; cursor: progress; box-shadow: none; }
.button.secondary {
  border-color: var(--brand-slate);
  background: var(--surface-white);
  color: var(--brand-slate);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.actions p { margin: 0; }

/* Errors ------------------------------------------------------------------ */

.errors {
  margin-bottom: 24px;
  padding: 20px 24px;
  border: 2px solid var(--error);
  border-radius: var(--radius-card);
  background: var(--error-surface);
  color: var(--brand-navy);
  font-weight: 400;
}
.errors h2 { font-size: 22px; }
.errors ul { margin: 8px 0 0; padding-left: 20px; }

/* Sent page --------------------------------------------------------------- */

.done { text-align: center; }
.done .lead { margin-left: auto; margin-right: auto; }
.check {
  width: 96px;
  height: 96px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--brand-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps {
  max-width: 900px;
  margin: 0 auto 32px;
  padding: 8px 28px;
  border-radius: var(--radius-card);
  background: var(--brand-slate);
  color: var(--surface-white);
  text-align: left;
}
.steps > div {
  display: flex;
  gap: 20px;
  padding: 20px 0;
  border-top: 1px solid var(--surface-white);
}
.steps > div:first-child { border-top: 0; }
.steps .step-number { color: var(--surface-white); margin: 0; min-width: 40px; }
.steps p { margin: 0; }
.steps strong { display: block; font-weight: 600; }
.reference {
  display: inline-block;
  margin-bottom: 32px;
  padding: 12px 20px;
  border-radius: 5px;
  background: var(--surface-100);
  color: var(--brand-navy);
  font-weight: 500;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  background: var(--surface-footer);
  padding: 28px 0;
  font-size: 16px;
}
.site-footer p { margin: 0; }

/* Internal screens -------------------------------------------------------- */

.header-right { display: flex; align-items: center; gap: 16px; }
.header-right form { margin: 0; }
.link-action {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-blue);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}
.link-action:hover { color: var(--brand-blue-hover); }

.narrow { max-width: 480px; }

.notice {
  margin: 0 0 24px;
  padding: 14px 20px;
  border-radius: 5px;
  background: var(--surface-100);
  color: var(--brand-navy);
  font-size: 16px;
  font-weight: 400;
}
.notice-error { background: var(--error-surface); border: 1px solid var(--error); }
.notice-ok { border: 1px solid var(--brand-slate); }

.tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 24px;
  margin-bottom: 24px;
}
.tool { display: flex; flex-direction: column; margin: 0; }
.tool:not(.is-soon):hover { box-shadow: var(--shadow-raised); }
.tool-icon { width: 56px; height: 56px; margin-bottom: 16px; color: var(--brand-navy); }
.tool > p { flex: 1; }
.tool > .button { align-self: flex-start; }
.tool.is-soon .button { cursor: default; opacity: .7; }
.tool.is-soon .button:hover { box-shadow: none; color: var(--brand-slate); }
.tool-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.tool-actions form { margin: 0; }

.link-box { margin-bottom: 20px; }
.link-row { display: flex; gap: 12px; flex-wrap: wrap; }
.link-row input { flex: 1 1 240px; background: var(--surface-100); }
.link-row .button { padding: 12px 20px; }

.table-card { padding: 0; overflow-x: auto; }
table.log { width: 100%; border-collapse: collapse; font-size: 16px; }
table.log th, table.log td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-200);
  text-align: left;
  white-space: nowrap;
}
table.log th { color: var(--brand-navy); font-weight: 500; }
table.log tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-warn { background: var(--brand-navy); color: var(--surface-white); }
.badge-ok { background: var(--surface-tagline); color: var(--brand-slate); }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 24px;
  margin: 0 0 24px;
}
.facts dt { font-size: 14px; }
.facts dd { margin: 0; color: var(--brand-navy); font-weight: 500; font-size: 16px; overflow-wrap: anywhere; }

.card-warn { border-color: var(--brand-navy); background: var(--surface-100); }
.review { margin: 0; padding-left: 20px; font-size: 16px; }
.review li { margin-bottom: 8px; }
.review strong { font-weight: 500; color: var(--brand-navy); }

.field.is-pending input { border-width: 2px; border-color: var(--brand-navy); background: var(--surface-100); }
