:root {
  /* Brand palette */
  --bg: #002244;                        /* Indigo */
  --card: #002244;                      /* Indigo — tiles match background, defined by white borders */
  --card-hover: #002244;                /* hover feedback comes from border + lift, not fill */
  --text: #ffffff;                      /* White */
  --muted: rgba(255, 255, 255, 0.65);   /* secondary text */
  --border: rgba(255, 255, 255, 0.28);  /* white lines */
  --accent: #ff547c;                    /* Coral — CTA buttons */
  --accent-hover: #bf1b4f;              /* Coral Dark — CTA hover */
  --focus: #28b4ff;                     /* Sky — focus rings */
  /* Corner rounding. Everything rectangular uses these two, so the whole
     site can be tuned from here. Pills set 999px directly. */
  --radius: 6px;                        /* panels, cards, inputs */
  --radius-sm: 5px;                     /* small controls inside them */
  --serif: "Aleo", Georgia, "Times New Roman", serif;
  --sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Ensure [hidden] wins over display rules on flex containers */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  /* Render native controls (checkboxes, selects, date pickers, scrollbars)
     against the dark palette rather than the browser's light default. */
  color-scheme: dark;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 5.5rem 4rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.6rem;
  letter-spacing: 0.01em;
  margin: 0 0 3rem;
}

/* Cards grid */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  background: var(--card-hover);
  border-color: #ffffff;
  transform: translateY(-3px);
}

.card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.card-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0 0 1rem;
}

.card-desc {
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  max-width: 15em;
}

.card-arrow {
  position: absolute;
  right: 1.75rem;
  bottom: 1.6rem;
  color: var(--text);
  display: inline-flex;
  transition: transform 0.18s ease;
}

.card:hover .card-arrow { transform: translateX(3px); }

#card-edit[aria-expanded="true"] {
  background: var(--card-hover);
  border-color: var(--accent);
}

/* Edit panel */
.edit-panel {
  margin-top: 2.5rem;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fade-in 0.25s ease;
}

.edit-panel-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 0 1.5rem;
}

.portfolios {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.portfolio-btn {
  padding: 0.7rem 1.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.portfolio-btn:hover { background: var(--card-hover); border-color: #ffffff; }

.portfolio-btn[aria-pressed="true"] {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--bg);
  font-weight: 600;
}

.portfolio-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Edit options (form links after portfolio pick) */
.edit-options {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  animation: fade-in 0.25s ease;
}

.option-link {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  min-height: 150px;
  padding: 1.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.option-link:hover {
  background: var(--card-hover);
  border-color: #ffffff;
  transform: translateY(-2px);
}

.option-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.option-text strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.option-text span {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.45;
}

.option-link .card-arrow {
  position: absolute;
  right: 1.5rem;
  bottom: 1.4rem;
  color: var(--text);
}

/* Logo */
.logo {
  position: fixed;
  left: 1.75rem;
  bottom: 1.5rem;
  width: 64px;
  height: 64px;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .page { padding: 3.5rem 1.5rem 2rem; }
  .title { font-size: 2rem; margin-bottom: 2rem; }
  .cards { grid-template-columns: 1fr; }
  .card { min-height: auto; padding: 1.5rem; }
  .logo { width: 48px; height: 48px; left: 1rem; bottom: 1rem; }
}

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

/* ------------------------------------------------------------------ Forms */

.form-page { max-width: 860px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.15s ease;
}

.back-link:hover { color: var(--text); }
.back-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.form-loading { color: var(--muted); }

/* The up-front new-or-repeat choice, shown before the form itself. */
.gate { animation: fade-in 0.25s ease; }

/* A question put to the reader, not a heading, so it stays in the body face.
   The serif is reserved for titles and section headings. */
.gate-question {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.45;
  margin: 0 0 1.75rem;
  max-width: 34em;
}

.gate-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.gate-option {
  flex: 1 1 300px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.gate-option:hover {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.gate-option:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.gate-option strong {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
}

.gate-option span { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

/* The choice, once made, with a way back to it. */
.gate-chosen {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin: 0 0 2.5rem;
  padding: 0.8rem 1.1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.gate-change {
  padding: 0;
  background: none;
  border: 0;
  color: var(--focus);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

.gate-change:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* Sections */
.form-sections {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.form-section-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 1.5rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.field-counter {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.field-counter--full { color: var(--accent); }

.compose-meter {
  margin: 1.25rem 0 0;
  padding: 0.7rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.88rem;
}

.compose-meter--met {
  border-style: solid;
  border-color: rgba(0, 200, 117, 0.5);
  color: var(--text);
}

.field { display: flex; flex-direction: column; }

.field-label {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.field-required {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.field-desc {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.field-desc p { margin: 0 0 0.4rem; }
.field-desc p:last-child { margin-bottom: 0; }
.field-desc ul { margin: 0.25rem 0 0.4rem; padding-left: 1.25rem; }
.field-desc a { color: var(--focus); overflow-wrap: anywhere; }

.field-input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-input::placeholder { color: rgba(255, 255, 255, 0.35); }
.field-input:hover { border-color: rgba(255, 255, 255, 0.5); }

.field-input:focus {
  outline: none;
  border-color: var(--focus);
  background: rgba(255, 255, 255, 0.07);
}

.field-textarea { resize: vertical; min-height: 7rem; line-height: 1.55; }

/* Native pickers render dark-on-dark in some browsers without this. */
.field-select { appearance: none; padding-right: 2.5rem; cursor: pointer; }
.field-select option { background: var(--bg); color: var(--text); }

.field--singleselect { position: relative; }

/* Only a real dropdown gets the chevron. Tiles and the search box are single
   choices too, but showing them an arrow would promise a menu. */
.field--singleselect:has(.field-select)::after {
  content: "";
  position: absolute;
  right: 1rem;
  bottom: 1.15rem;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.field--singleselect:has(.field-select).field--invalid::after { bottom: 2.6rem; }


.field-range { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-range-cell { flex: 1 1 180px; display: flex; flex-direction: column; }

.field-range-label {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.field-checks { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.field-check {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-check:hover { border-color: #ffffff; }
.field-check:has(input:checked) { background: rgba(255, 255, 255, 0.1); border-color: #ffffff; }
.field-check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

/* Tiles: a single choice with every option visible, for short lists. */
.field-tiles {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.75rem;
}

.field-tile {
  flex: 1 1 200px;
  min-height: 3.5rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-tile:hover { border-color: #ffffff; background: rgba(255, 255, 255, 0.08); }
.field-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.field-tile[aria-checked="true"] {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--bg);
  font-weight: 600;
}

/* Search-as-you-type, for a list too long to scan comfortably. */
.combo { position: relative; }

.combo-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: 16rem;
  margin: 0;
  padding: 0.35rem;
  overflow-y: auto;
  list-style: none;
  background: #01192f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.combo-option {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.combo-option:hover,
.combo-option[aria-selected="true"] { background: rgba(255, 255, 255, 0.12); }

.combo-empty {
  padding: 0.6rem 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* The non-searchable flavour is a menu, so it should not invite typing. */
.combo-input--list { cursor: pointer; caret-color: transparent; }

.combo--chosen .combo-input {
  border-color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}

/* Resets an optional single-choice question, which tiles and radios cannot do
   on their own once one has been picked. */
.field-clear {
  align-self: center;
  padding: 0 0.4rem;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.field-clear:hover { color: var(--text); }
.field-clear:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.field-file {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.field-file::file-selector-button {
  margin-right: 0.9rem;
  padding: 0.45rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.field-file::file-selector-button:hover { border-color: #ffffff; }

.field-hint {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.field-error {
  margin: 0.5rem 0 0;
  color: var(--accent);
  font-size: 0.88rem;
}

.field--invalid .field-input,
.field--invalid .field-file { border-color: var(--accent); }

.form-error {
  margin: 1.75rem 0 0;
  padding: 0.9rem 1.1rem;
  background: rgba(255, 84, 124, 0.12);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}

.form-actions { margin-top: 2.5rem; }

.submit-btn {
  padding: 0.95rem 2.5rem;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: #ffffff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.submit-btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.submit-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.submit-btn:disabled { opacity: 0.6; cursor: default; }

.form-done {
  padding: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fade-in 0.25s ease;
}

.form-done-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.7rem;
  margin: 0 0 0.9rem;
}

.form-done-text { margin: 0 0 1.5rem; color: var(--muted); line-height: 1.6; }

/* Test mode. Deliberately loud, so a dry run is never mistaken for a real
   submission. */
.form-done--dry {
  border-color: var(--accent);
  background: rgba(255, 84, 124, 0.1);
}

.form-done--dry .form-done-title { color: var(--accent); }
.form-done-link { color: var(--focus); font-weight: 600; }

/* Spam trap. Hidden from sight without display:none, which some automated
   submitters check for. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 760px) {
  .form-page { padding-bottom: 4rem; }
  .fields { gap: 1.75rem; }
}

/* Embed mode (page loaded inside an iframe): size to content, drop the
   fixed logo, and tighten spacing so it sits neatly in a host page. */
body.embed .page {
  min-height: 0;
  padding: 2rem 2rem 2.25rem;
}
body.embed .logo { display: none; }

@media (max-width: 760px) {
  body.embed .page { padding: 1.5rem 1.25rem; }
}
