/* PhotoPieces v2.0 - "Pip" help assistant styles (ruling R4, amendment A6).
   Loaded on EVERY page. index.html and library.html also load styles.css,
   but every content page (about/faq/privacy/articles/*) has only its own
   inline <style> and does NOT load styles.css - so every token this file
   needs is redeclared here, scoped to .pp-help, and never assumed to exist
   anywhere else. Values match the locked design tokens in site/styles.css. */

.pp-help {
  --primary: #E8622C;
  --primary-hover: #CF5322;
  --accent: #2E9E8F;
  --bg: #FBF7F0;
  --surface: #FFFFFF;
  --ink: #23262B;
  --ink-muted: #6B7076;
  --border: #E4DDD0;
  --success: #3FA34D;
  --error: #D64545;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fredoka", var(--font-body);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(35, 38, 43, 0.08);
  --shadow-md: 0 4px 12px rgba(35, 38, 43, 0.16);
  --pp-help-z: 900;
  --pp-help-duration: 220ms;
  --pp-help-ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-body);
  color: var(--ink);
}

.pp-help * {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------------------
   Launcher (A6: only rendered/shown outside the game screen; on the game
   screen help.js wires the existing #helpToolbarBtn instead of this button).
--------------------------------------------------------------------------- */
.pp-help-launcher {
  position: fixed;
  right: max(24px, env(safe-area-inset-right, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: var(--pp-help-z);
  transition: transform var(--pp-help-duration) var(--pp-help-ease), background-color var(--pp-help-duration) var(--pp-help-ease);
}

.pp-help-launcher:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.pp-help-launcher:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.pp-help-launcher svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.pp-help-launcher.pp-help-is-hidden {
  display: none;
}

.pp-help-tooltip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13px;
  line-height: 1.3;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--pp-help-duration) var(--pp-help-ease), transform var(--pp-help-duration) var(--pp-help-ease);
}

.pp-help-launcher:hover .pp-help-tooltip,
.pp-help-launcher:focus-visible .pp-help-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

@media (max-width: 600px) {
  .pp-help-launcher {
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
  }
}

/* ---------------------------------------------------------------------------
   Panel
--------------------------------------------------------------------------- */
.pp-help-panel {
  position: fixed;
  right: max(24px, env(safe-area-inset-right, 0px));
  bottom: max(92px, calc(24px + 56px + 12px + env(safe-area-inset-bottom, 0px)));
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: min(600px, calc(100vh - 120px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--pp-help-z);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity var(--pp-help-duration) var(--pp-help-ease), transform var(--pp-help-duration) var(--pp-help-ease);
}

.pp-help-panel[hidden] {
  display: none;
}

.pp-help-panel.pp-help-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .pp-help-panel {
    transition: none;
  }
  .pp-help-launcher,
  .pp-help-tooltip {
    transition: none;
  }
}

@media (max-width: 600px) {
  .pp-help-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: min(80vh, 640px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.pp-help-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.pp-help-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.pp-help-avatar svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.pp-help-header-text {
  flex: 1;
  min-width: 0;
}

.pp-help-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.pp-help-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 1px 0 0;
}

.pp-help-close {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.pp-help-close:hover {
  background: var(--bg);
  color: var(--ink);
}

.pp-help-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pp-help-close svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Tabs (Chat / Feedback) --------------------------------------------------- */
.pp-help-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  flex: none;
  border-bottom: 1px solid var(--border);
}

.pp-help-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
}

.pp-help-tab:hover {
  color: var(--ink);
}

.pp-help-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.pp-help-tab[aria-selected="true"] {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}

/* Views --------------------------------------------------------------------- */
.pp-help-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pp-help-view[hidden] {
  display: none;
}

/* Chat view ------------------------------------------------------------------ */
.pp-help-thread {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pp-help-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
}

.pp-help-msg p {
  margin: 0 0 6px;
}

.pp-help-msg p:last-child {
  margin-bottom: 0;
}

.pp-help-msg a {
  color: inherit;
  text-decoration: underline;
}

.pp-help-msg-bot {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.pp-help-msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.pp-help-msg-user a {
  color: #FFFFFF;
}

.pp-help-msg-action {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.pp-help-msg-action:hover {
  border-color: var(--primary);
}

.pp-help-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 14px 12px;
  flex: none;
}

.pp-help-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-align: left;
}

.pp-help-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pp-help-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pp-help-composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex: none;
}

.pp-help-input {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
}

.pp-help-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pp-help-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.pp-help-send:hover {
  background: var(--primary-hover);
}

.pp-help-send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pp-help-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.pp-help-footnote {
  margin: 0;
  padding: 0 14px 12px;
  font-size: 12px;
  color: var(--ink-muted);
  flex: none;
}

.pp-help-footnote button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* Shared form styling (compose + feedback views) ----------------------------- */
.pp-help-form {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pp-help-back {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 0;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  align-self: flex-start;
}

.pp-help-back:hover {
  color: var(--primary);
}

.pp-help-form h3 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0;
  color: var(--ink);
}

.pp-help-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pp-help-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.pp-help-field select,
.pp-help-field textarea,
.pp-help-field input[type="text"],
.pp-help-field input[type="email"] {
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
}

.pp-help-field textarea {
  min-height: 88px;
  resize: vertical;
}

.pp-help-field select:focus-visible,
.pp-help-field textarea:focus-visible,
.pp-help-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pp-help-note {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0;
}

.pp-help-error {
  font-size: 12px;
  color: var(--error);
  margin: 0;
}

.pp-help-btn-primary {
  appearance: none;
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

.pp-help-btn-primary:hover {
  background: var(--primary-hover);
}

.pp-help-btn-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pp-help-btn-primary[aria-disabled="true"] {
  background: var(--border);
  color: var(--ink-muted);
  cursor: not-allowed;
}

/* Feedback stars -------------------------------------------------------------- */
.pp-help-stars {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pp-help-stars legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 0;
}

.pp-help-star-row {
  display: flex;
  gap: 4px;
}

.pp-help-star {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pp-help-star input {
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  cursor: pointer;
}

.pp-help-star svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--ink-muted);
  stroke-width: 1.6;
  pointer-events: none;
}

.pp-help-star.is-filled svg {
  fill: var(--primary);
  stroke: var(--primary);
}

.pp-help-star input:focus-visible + svg {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* v2.1 feedback: star words, quick tags, thank-you, copy fallback */
.pp-help-star-word {
  margin: 4px 0 0;
  min-height: 1.3em;
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}
.pp-help-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-help-tag {
  appearance: none;
  min-height: 44px;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pp-help-tag[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.pp-help-thanks {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #E7F5F2;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}
.pp-help-thanks strong { color: var(--accent); }
.pp-help-copy {
  display: block;
  margin-top: 2px;
  min-height: 44px;
  padding: 0;
  text-align: left;
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* v2.1 Feedback buttons outside the panel */
.header-feedback {
  gap: 6px;
  min-width: 44px;
  justify-content: center;
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
.header-feedback-icon svg { width: 18px; height: 18px; fill: var(--primary); display: block; }
@media (max-width: 480px) {
  .header-feedback-text { display: none; }
}
.win-rate-link {
  appearance: none;
  margin-top: 4px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 44px;
}
.win-rate-link:hover { color: var(--primary); }

.pp-help-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
