/* ---------- Feedback widget ---------- */

:root {
  --sbfb-accent: #f5d76e;
  --sbfb-accent-strong: #d4a800;
  --sbfb-radius: 6px;
  --sbfb-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
html[data-theme="dark"], html:not([data-theme="light"]) {
  --sbfb-accent: #5a4d1a;
  --sbfb-accent-strong: #f5d76e;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --sbfb-accent: #5a4d1a;
    --sbfb-accent-strong: #f5d76e;
  }
}

/* SVG connector */
.sb-feedback-link {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1100;
}
.sb-feedback-link-path {
  fill: none;
  stroke: var(--sbfb-accent-strong);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.7;
}

/* Aside container holding form (desktop) and sent list */
.sb-feedback-aside {
  position: fixed;
  top: 96px;
  right: max(16px, calc((100vw - 1100px) / 2 - 380px));
  width: 360px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  z-index: 1200;
  font-size: 1.5rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: none;
}
.sb-feedback-aside > * {
  pointer-events: auto;
}

/* Form (desktop) */
.sb-feedback-form {
  background: var(--page-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: var(--sbfb-radius);
  padding: 18px;
  box-shadow: var(--sbfb-shadow);
  animation: sbfb-fade-in 150ms ease-out;
}
@keyframes sbfb-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.sb-feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sb-feedback-header strong {
  font-size: 1.7rem;
  font-weight: 700;
}
.sb-feedback-close {
  background: transparent;
  border: 0;
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  padding: 0 8px;
  margin: 0;
  height: auto;
}
.sb-feedback-close:hover { color: var(--sbfb-accent-strong); }

.sb-feedback-quote {
  border-left: 3px solid var(--sbfb-accent-strong);
  background: var(--surface-bg);
  padding: 10px 14px;
  margin: 0 0 14px;
  font-style: italic;
  font-size: 1.4rem;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  border-radius: 0 var(--sbfb-radius) var(--sbfb-radius) 0;
}

.sb-feedback-form textarea,
.sb-feedback-form input[type="text"],
.sb-feedback-form input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 1.6rem;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--sbfb-radius);
  background: var(--page-bg);
  color: var(--text-color);
  margin-bottom: 10px;
  resize: none;
  height: auto;
  line-height: 1.5;
}
.sb-feedback-form textarea {
  min-height: 90px;
}
.sb-feedback-form textarea:focus,
.sb-feedback-form input:focus {
  outline: 2px solid var(--sbfb-accent-strong);
  outline-offset: 0;
  border-color: var(--sbfb-accent-strong);
}

.sb-feedback-row {
  display: flex;
  gap: 10px;
}
.sb-feedback-row input {
  flex: 1 1 0;
  min-width: 0;
}

.sb-feedback-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

.sb-feedback-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.sb-feedback-form button[type="submit"] {
  background: var(--sbfb-accent-strong);
  color: #1c1e20;
  border: 0;
  border-radius: var(--sbfb-radius);
  padding: 10px 20px;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  height: auto;
  margin: 0;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.2;
}
.sb-feedback-form button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sb-feedback-error {
  margin: 10px 0 0;
  color: #c0392b;
  font-size: 1.4rem;
}
.sb-feedback-notice {
  margin: 14px 0 0;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--text-secondary);
  opacity: 0.85;
}

.sb-feedback-form[data-phase="sent"] .sb-feedback-actions::before {
  content: "✓ Sent, thanks!";
  color: var(--sbfb-accent-strong);
  font-weight: 700;
  margin-right: auto;
  align-self: center;
}
.sb-feedback-form[data-phase="sent"] button[type="submit"] {
  display: none;
}

/* Sent messages list */
.sb-feedback-sent-list {
  background: var(--page-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--sbfb-radius);
  padding: 14px 16px;
  font-size: 1.4rem;
  line-height: 1.5;
  box-shadow: var(--sbfb-shadow);
}
.sb-feedback-sent-list h3 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  letter-spacing: normal;
  text-transform: none;
  padding-top: 1rem;
}
.sb-feedback-sent-list details {
  border-top: 1px solid var(--border-light);
  padding: 8px 0;
}
.sb-feedback-sent-list details:first-of-type {
  border-top: 0;
}
.sb-feedback-sent-list summary {
  cursor: pointer;
  list-style: none;
  font-style: italic;
  color: var(--text-secondary);
  outline: none;
}
.sb-feedback-sent-list summary::-webkit-details-marker {
  display: none;
}
.sb-feedback-sent-list summary::before {
  content: "▸ ";
  font-style: normal;
}
.sb-feedback-sent-list details[open] > summary::before {
  content: "▾ ";
}
.sb-feedback-sent-body {
  padding: 8px 0 0 16px;
}
.sb-feedback-sent-meta {
  font-size: 1.2rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-bottom: 6px;
}
.sb-feedback-sent-msg {
  white-space: pre-wrap;
  word-break: break-word;
}
.sb-feedback-purge {
  display: block;
  margin: 12px 0 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 1.2rem;
  text-decoration: underline;
  cursor: pointer;
  height: auto;
  letter-spacing: normal;
  text-transform: none;
}

/* Mobile button (floating above selection) */
.sb-feedback-mobile-btn {
  position: fixed;
  z-index: 1300;
  background: var(--page-bg);
  color: var(--text-color);
  border: 1px solid var(--sbfb-accent-strong);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  height: auto;
  margin: 0;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.2;
}
.sb-feedback-mobile-btn:hover,
.sb-feedback-mobile-btn:focus-visible {
  background: var(--surface-bg);
}

/* Mobile bottom-sheet form */
.sb-feedback-form-mobile {
  position: fixed !important;
  inset: auto 0 0 0;
  width: 100%;
  max-height: 90vh;
  border-radius: 12px 12px 0 0;
  z-index: 1400;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
  animation: sbfb-slide-up 200ms ease-out;
}
@keyframes sbfb-slide-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

/* Hide aside when no content (mobile) */
@media (max-width: 1100px) {
  .sb-feedback-aside {
    right: 8px;
    width: 320px;
  }
}
@media (pointer: coarse), (max-width: 900px) {
  .sb-feedback-aside {
    position: static;
    width: auto;
    max-width: 100%;
    margin: 24px auto;
    right: auto;
    top: auto;
    max-height: none;
  }
  .sb-feedback-link { display: none; }
}
