/* "Reflection" theme for the anonymous consultation UI - an alternative to
   collab.css (the "Plain simple" theme). Loaded instead of collab.css by
   collab/base.html when site.theme == 'reflection' (see ConsultationSite.theme,
   projectspace/models.py). Same HTML/Bootstrap markup as the plain theme -
   this file only restyles it, so collab.js's DOM hooks and the e2e suite's
   selectors keep working unchanged.

   Written mobile-first: base rules target small screens, then
   `@media (min-width: ...)` blocks layer on the wider-screen layout. This is
   a first pass to prove theme switching end-to-end, not a finished design -
   expect it to be iterated on. */

:root {
  --rf-primary: #4f46e5;
  --rf-primary-dark: #3730a3;
  --rf-bg: #f1f1fa;
  --rf-surface: #ffffff;
  --rf-text: #20233a;
  --rf-muted: #6b7084;
  --rf-border: #e1e2f0;
  --rf-radius: 14px;
  --rf-radius-sm: 8px;
}

body.theme-reflection {
  --bs-primary: var(--rf-primary);
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: var(--rf-primary);
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: var(--rf-primary-dark);
  --bs-body-font-family: 'Inter', 'Segoe UI', sans-serif;
  --bs-body-color: var(--rf-text);
  --bs-border-radius: var(--rf-radius-sm);

  background-color: var(--rf-bg);
  color: var(--rf-text);
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

body.theme-reflection h1,
body.theme-reflection h2,
body.theme-reflection h3,
body.theme-reflection h4,
body.theme-reflection h5,
body.theme-reflection h6 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  color: var(--rf-text);
  letter-spacing: -0.01em;
}

/* Page frame
==========================================================*/
body.theme-reflection #content {
  padding: 0.75em;
}
body.theme-reflection #content .rf-page-frame {
  padding: 1.25em;
  border: none;
  border-radius: var(--rf-radius);
  background-color: var(--rf-surface);
  box-shadow: 0 1px 3px rgba(32, 35, 58, 0.06), 0 10px 30px rgba(32, 35, 58, 0.08);
  position: relative;
  overflow: hidden;
}
/* a thin accent bar along the top of the card, instead of a plain border */
body.theme-reflection #content .rf-page-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--rf-primary), #22d3ee);
}

@media (min-width: 768px) {
  body.theme-reflection #content {
    padding: 2.5em 1em;
  }
  body.theme-reflection #content .rf-page-frame {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5em 3em;
  }
}

/* Typography
==========================================================*/
body.theme-reflection div#content h1 {
  font-size: 22px;
}
body.theme-reflection div#content h2 {
  font-size: 19px;
  margin-top: 1.4em;
}
body.theme-reflection div#content h3 {
  font-size: 17px;
}
body.theme-reflection div#content li,
body.theme-reflection div#content p,
body.theme-reflection div#content th,
body.theme-reflection div#content td {
  font-size: 15px;
  line-height: 1.55;
  color: var(--rf-text);
}

@media (min-width: 768px) {
  body.theme-reflection div#content h1 {
    font-size: 28px;
  }
  body.theme-reflection div#content h2 {
    font-size: 21px;
  }
}

/* Navigation
==========================================================*/
/* nav.top/.bottom can hold one or two button groups - a lone prev OR next
   button, both, or a feedback-button <span> (partial_navbutton.html) whose
   *inner* buttons carry the next/prev class rather than the span itself.
   A flexbox `justify-content: space-between` collapses a single child to
   one edge instead of keeping it pinned to its intended side, which is
   what moved a lone "next" button from bottom-right to bottom-left here.
   Match collab.css's own float-based positioning exactly instead - it
   already handles every one of those shapes correctly (nav has
   `clearfix` in the markup to contain the floats). */
body.theme-reflection nav a.button.next,
body.theme-reflection nav button.next {
  float: right;
}

/* Buttons - rounded, flatter, no Bootstrap drop shadow */
body.theme-reflection .btn {
  border-radius: 999px;
  font-weight: 600;
  padding: 0.5em 1.4em;
  box-shadow: none;
  transition: transform 0.08s ease-in-out, box-shadow 0.08s ease-in-out;
}
body.theme-reflection .btn-primary {
  background-color: var(--rf-primary);
  border-color: var(--rf-primary);
}
body.theme-reflection .btn-primary:hover,
body.theme-reflection .btn-primary:focus {
  background-color: var(--rf-primary-dark);
  border-color: var(--rf-primary-dark);
}
body.theme-reflection .btn-outline-primary,
body.theme-reflection .btn-outline-secondary {
  border-color: var(--rf-border);
  color: var(--rf-text);
}
body.theme-reflection .btn-outline-primary:hover,
body.theme-reflection .btn-outline-secondary:hover {
  background-color: var(--rf-bg);
  border-color: var(--rf-primary);
  color: var(--rf-primary-dark);
}
body.theme-reflection .btn:hover {
  transform: translateY(-1px);
}

/* Document/external-resource feedback toolbar (document_view_content.html,
   external_wrapper.html) - the generic pill `.btn` sizing above is right
   for primary CTAs (next/prev, etc), but applied to these three buttons
   plus the "Return to previous page" link it's wide enough to wrap onto a
   second line inside the theme's narrower, centred page frame (unlike the
   Plain simple theme, which has no such max-width and so never needed to
   wrap). Match Plain simple's tighter, single-row layout here while
   keeping the flatter/rounder look of the rest of the theme. */
body.theme-reflection .btn_toolbar .btn,
body.theme-reflection .btn_return {
  padding: 0.3em 0.85em;
  font-size: 0.8125rem;
  font-weight: 500;
}
body.theme-reflection .btn_return {
  padding-left: 0;
}

/* Form inputs - including the bare, un-classed <input>/<select>/<textarea>
   that consultation page content (TinyMCE-authored questionnaires) renders
   directly, not just Bootstrap's own .form-control/.form-select. */
body.theme-reflection #document-content input[type='text'],
body.theme-reflection #document-content input[type='email'],
body.theme-reflection #document-content input[type='number'],
body.theme-reflection #document-content input[type='tel'],
body.theme-reflection #document-content input[type='date'],
body.theme-reflection #document-content textarea,
body.theme-reflection #document-content select,
body.theme-reflection .form-control,
body.theme-reflection .form-select {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  border: 1px solid var(--rf-border);
  border-radius: var(--rf-radius-sm);
  padding: 0.5em 0.75em;
  background-color: var(--rf-surface);
  color: var(--rf-text);
  box-shadow: none;
}
body.theme-reflection #document-content input[type='text']:focus,
body.theme-reflection #document-content input[type='email']:focus,
body.theme-reflection #document-content input[type='number']:focus,
body.theme-reflection #document-content input[type='tel']:focus,
body.theme-reflection #document-content input[type='date']:focus,
body.theme-reflection #document-content textarea:focus,
body.theme-reflection #document-content select:focus,
body.theme-reflection .form-control:focus,
body.theme-reflection .form-select:focus {
  border-color: var(--rf-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
body.theme-reflection #document-content input[type='text']:required,
body.theme-reflection #document-content textarea:required,
body.theme-reflection #document-content select:required {
  border-color: #e4a5a5;
  background-color: #fff8f8;
}
body.theme-reflection #document-content input[type='radio'],
body.theme-reflection #document-content input[type='checkbox'] {
  accent-color: var(--rf-primary);
  width: 1.1em;
  height: 1.1em;
}

/* Inline comment / edit controls
==========================================================*/
/* [data-commentid] is given `position: relative` so #controls (a single
   shared element, moved from paragraph to paragraph in collab.js) can be
   anchored inside whichever one is active with `position: absolute; top;
   right`, rather than the old page-relative pixel math - that kept landing
   #controls partly outside the page frame (and clipped by its rounded,
   overflow-hidden corners) for anything near the left edge. */
body.theme-reflection [data-commentid] {
  position: relative;
}
body.theme-reflection div#controls {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 20;
  display: flex;
  gap: 2px;
  background: var(--rf-surface);
  border: 1px solid var(--rf-border);
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 6px 16px rgba(32, 35, 58, 0.14);
}
body.theme-reflection .rf-inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  border: none;
  background: transparent;
  color: var(--rf-text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
}
body.theme-reflection .rf-inline-btn:hover,
body.theme-reflection .rf-inline-btn:focus-visible {
  background: var(--rf-bg);
  color: var(--rf-primary-dark);
  outline: none;
}
body.theme-reflection .rf-inline-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
body.theme-reflection .comment-hover {
  outline: 2px solid var(--rf-primary);
  outline-offset: 4px;
  border-radius: 3px;
}
/* The paragraph being edited directly (no textarea) - styled like an
   active input so it's obvious it's now live text, not just highlighted. */
body.theme-reflection [contenteditable='true'] {
  outline: 2px solid var(--rf-primary);
  outline-offset: 4px;
  border-radius: 3px;
  background: #fbfbff;
  cursor: text;
}

body.theme-reflection div#editor {
  position: absolute;
  z-index: 25;
  background: var(--rf-surface);
  border: 1px solid var(--rf-border);
  border-radius: var(--rf-radius);
  box-shadow: 0 12px 30px rgba(32, 35, 58, 0.16);
  padding: 12px;
  width: 420px;
  max-width: min(420px, 90vw);
}
/* Editing a paragraph directly has nothing to show here but Save/Cancel -
   no need for the wide, padded card the textarea otherwise needs. */
body.theme-reflection div#editor.rf-inline-editor--direct {
  width: auto;
  padding: 6px;
}
body.theme-reflection .rf-inline-textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  max-height: 55vh;
  resize: vertical;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--rf-border);
  border-radius: var(--rf-radius-sm);
  background: var(--rf-bg);
  color: var(--rf-text);
  box-sizing: border-box;
}
body.theme-reflection .rf-inline-textarea:focus {
  outline: none;
  border-color: var(--rf-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
body.theme-reflection .rf-inline-editor-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}
body.theme-reflection div#editor.rf-inline-editor--direct .rf-inline-editor-actions {
  margin-top: 0;
}
body.theme-reflection .rf-inline-btn-link {
  color: var(--rf-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
body.theme-reflection .rf-inline-btn-link:hover {
  color: var(--rf-text);
}
body.theme-reflection .rf-inline-btn-primary {
  display: inline-flex;
  align-items: center;
  background: var(--rf-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.45em 1.2em;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
body.theme-reflection .rf-inline-btn-primary:hover {
  background: var(--rf-primary-dark);
  color: #fff;
}

/* A saved edit/comment, shown as a box under its paragraph - class and tag
   (<blockquote class="comment|edit">) match what the server renders on
   reload (see CommentableDocument._make_node_commentable), and what
   collab.js's upsertAnnotationBox creates immediately after a save, so the
   two look identical rather than only matching up after a refresh. */
body.theme-reflection .comment,
body.theme-reflection .edit {
  padding: 8px 10px;
  margin: 4px;
  margin-left: 50px;
  border-radius: var(--rf-radius-sm);
  background-color: #eef2ff;
}
body.theme-reflection .edit {
  border-left: 3px solid var(--rf-primary);
}

/* First-visit hint for touch devices, where there's no hover state to
   reveal that paragraphs are interactive at all - see
   PS.Collab.Controls.maybeShowMobileHint in collab.js. */
body.theme-reflection .rf-inline-hint[hidden] {
  display: none;
}
body.theme-reflection .rf-inline-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--rf-bg);
  border: 1px solid var(--rf-border);
  border-radius: var(--rf-radius-sm);
  padding: 10px 12px;
  margin-bottom: 1em;
  font-size: 0.875rem;
  color: var(--rf-muted);
}
body.theme-reflection .rf-inline-hint-dismiss {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--rf-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
body.theme-reflection .rf-inline-hint-dismiss:hover {
  color: var(--rf-text);
}

/* Survey tables
==========================================================*/
/* Legacy border="1" table HTML attributes (older TinyMCE/Word-pasted
   content) leak through as a default browser grid unless reset - see
   collab.css's equivalent rule. :where() keeps this at plain-element
   specificity so the explicit border classes below (.tbl-bordered,
   .tbl_roc, ...) still opt back in regardless of source order. */
:where(body.theme-reflection #content) table,
:where(body.theme-reflection #content) table td,
:where(body.theme-reflection #content) table th {
  border: 0;
}
body.theme-reflection .tbl-bordered,
body.theme-reflection .tbl-bordered th,
body.theme-reflection .tbl-bordered td {
  border: 1px solid var(--rf-border);
}
body.theme-reflection .odd-even thead tr {
  background-color: var(--rf-bg);
  font-weight: 600 !important;
}
body.theme-reflection .odd-even tbody tr:nth-child(even) {
  background-color: #f7f8ff;
}
body.theme-reflection .odd-even tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

@media (max-width: 575px) {
  body.theme-reflection table.tbl_roc,
  body.theme-reflection .tbl-Survey {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Progress bar
==========================================================*/
body.theme-reflection .progress-bar-container {
  margin: 10px auto;
}
body.theme-reflection .progress-bar-container label {
  float: left;
  margin-right: 10px;
  color: var(--rf-muted);
}
body.theme-reflection .progress-bar {
  float: right;
  height: 12px;
  position: relative;
  background: var(--rf-border);
  border-radius: 25px;
  padding: 3px;
  box-shadow: none;
}
body.theme-reflection .progress-bar > span {
  display: block;
  height: 100%;
  border-radius: 20px;
  background-image: linear-gradient(90deg, var(--rf-primary), #22d3ee);
  box-shadow: none;
}
