/*
 * research.css — Reusable classes for research views
 * Extends the foundation_os design-token system.
 */

/* ── Research tokens (extend root) ─────────────────── */
:root {
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-quaternary: #9ca3af;
  --green-light: #ecfdf5;
  --green-dark: #065f46;
  --blue-light: #eff6ff;
  --blue-dark: #1e40af;
  --amber-light: #fef3c7;
  --red-light: #fef2f2;
  --red-dark: #991b1b;
  --yellow-light: #fefce8;
  --yellow-dark: #854d0e;
}

/* ── Research page shell ──────────────────────────── */
.research-page { background: var(--cream); min-height: 100vh; }
.research-container { max-width: 820px; margin: 0 auto; padding: 0 24px; }
.research-container--narrow { max-width: 640px; margin: 0 auto; padding: 0 24px; }

/* ── Back nav bar ─────────────────────────────────── */
.research-topbar { display: flex; justify-content: space-between; align-items: center; padding-top: 16px; }
.research-back-link { font-size: 14px; color: var(--orange-dark); text-decoration: none; font-weight: 500; }
.research-action-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 8px; background: #fff; border: 1px solid var(--border); color: var(--text-tertiary); font-size: 13px; font-weight: 500; text-decoration: none; }

/* ── Hero image ───────────────────────────────────── */
.research-hero-image { border-radius: 12px; overflow: hidden; margin-bottom: 24px; height: 360px; }
.research-hero-image img { width: 100%; height: 360px; object-fit: cover; display: block; }

/* ── Project header ───────────────────────────────── */
.research-project-title { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; margin: 0 0 6px; }
.research-project-meta { font-size: 14px; color: var(--text-quaternary); margin: 0 0 16px; }
.research-project-description { font-size: 15px; color: var(--text-secondary); line-height: 1.7; }

/* ── Badge/pill ───────────────────────────────────── */
.research-badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px; font-size: 13px; }
.research-badge--location { background: var(--amber-light); color: var(--orange-dark); }
.research-badge--duration { background: var(--green-light); color: var(--green-dark); }
.research-badge--area { background: var(--blue-light); color: var(--blue-dark); }
.research-badge--public { background: var(--green-light); color: var(--green-dark); }
.research-badge--type { background: var(--green-light); color: var(--green-dark); font-size: 12px; padding: 3px 10px; }

/* ── Stats bar ────────────────────────────────────── */
.research-stats-bar { display: flex; justify-content: flex-start; gap: 32px; flex-wrap: wrap; padding: 24px 0 8px; }
.research-stat { text-align: center; }
.research-stat-number { font-size: 24px; font-weight: 700; color: var(--orange-dark); }
.research-stat-label { font-size: 12px; color: var(--text-quaternary); text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Card (generic white card) ────────────────────── */
.research-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.research-card-header { padding: 20px 24px 12px; border-bottom: 1px solid var(--border); }
.research-card-header h2 { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 2px; }
.research-card-header p { font-size: 13px; color: var(--text-quaternary); margin: 0; }
.research-card-body { padding: 16px 24px 20px; }

/* ── Record grid (Add Record) ─────────────────────── */
.research-record-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
@media (max-width: 480px) { .research-record-grid { grid-template-columns: 1fr; } }
.research-record-link { display: flex; align-items: center; padding: 14px; border-radius: 10px; text-decoration: none; gap: 12px; transition: opacity .15s; }
.research-record-link:hover { opacity: 0.85; }
.research-record-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 17px; }
.research-record-label { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.research-record-desc { display: block; font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }

/* ── Timeline ─────────────────────────────────────── */
.research-timeline { position: relative; padding-left: 32px; }
.research-timeline-line { position: absolute; left: 11px; top: 8px; bottom: 0; width: 2px; background: var(--border); }
.research-timeline-gap { position: relative; margin-bottom: 20px; padding-left: 16px; }
.research-timeline-gap-dot { position: absolute; left: -25px; top: 4px; width: 24px; height: 24px; background: var(--cream); border: 2px dashed #d6d3d1; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.research-timeline-gap-text { font-size: 12px; color: #d6d3d1; }
.research-timeline-date { position: relative; margin-bottom: 8px; }
.research-timeline-date-dot { position: absolute; left: -28px; top: 2px; width: 16px; height: 16px; background: var(--orange-dark); border-radius: 50%; border: 3px solid var(--cream); }
.research-timeline-date-text { font-size: 14px; font-weight: 700; color: var(--text); }
.research-timeline-group { margin-bottom: 28px; }

/* ── Timeline record card ─────────────────────────── */
.research-record-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; margin-bottom: 10px; }
.research-record-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.research-record-card-title { display: flex; align-items: center; gap: 8px; }
.research-record-card-title .icon { font-size: 16px; }
.research-record-card-title .label { font-size: 14px; font-weight: 600; color: var(--text); }
.research-record-card-body { font-size: 14px; color: var(--text-tertiary); line-height: 1.65; }
.research-record-card-body p { margin: 0.4rem 0 0; color: var(--text-secondary); }
.research-edit-link { font-size: 14px; color: var(--orange-dark); text-decoration: none; }

/* ── Component pills (amendment) ──────────────────── */
.research-component-pills { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.research-component-pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; background: var(--amber-light); color: var(--orange-dark); font-size: 12px; font-weight: 500; }
.research-component-pill .amount { opacity: .7; margin-left: 4px; }

/* ── Photo gallery ────────────────────────────────── */
.research-photos { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.research-photo-link { display: block; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.research-photo-link img { width: 120px; height: 120px; object-fit: cover; display: block; }
.research-analyze-btn { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--text-tertiary); font-size: 12px; cursor: pointer; margin-top: 4px; min-height: 44px; min-width: 44px; }

/* ── Analysis results ─────────────────────────────── */
.research-analysis { margin-top: 8px; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.research-analysis--complete { background: var(--green-light); border: 1px solid #bbf7d0; }
.research-analysis--failed { background: var(--red-light); border: 1px solid #fecaca; color: var(--red-dark); }
.research-analysis--processing { background: var(--blue-light); border: 1px solid #bfdbfe; color: var(--blue-dark); }
.research-analysis--pending { background: #f5f5f4; border: 1px solid var(--border); color: var(--text-tertiary); }
.research-analysis-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.research-analysis-diseases .tag { display: inline-block; padding: 1px 6px; margin: 2px; border-radius: 8px; background: var(--red-light); color: var(--red-dark); font-size: 12px; }
.research-analysis-deficiencies .tag { display: inline-block; padding: 1px 6px; margin: 2px; border-radius: 8px; background: var(--yellow-light); color: var(--yellow-dark); font-size: 12px; }

/* ── Explore cards ────────────────────────────────── */
.research-explore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
@media (max-width: 480px) { .research-explore-grid { grid-template-columns: 1fr; } }
.research-explore-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: box-shadow .15s; }
.research-explore-card:hover, .research-explore-card:focus-within { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.research-explore-card-cover { height: 160px; overflow: hidden; background: #f5f2ef; }
.research-explore-card-cover img { width: 100%; height: 160px; object-fit: cover; }
.research-explore-card-placeholder { height: 160px; background: linear-gradient(135deg, var(--amber-light), #d1fae5); display: flex; align-items: center; justify-content: center; font-size: 40px; }
.research-explore-card-body { padding: 16px; }
.research-explore-card-body h2 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0 0 6px; line-height: 1.3; }
.research-explore-card-body .meta { font-size: 13px; color: var(--text-quaternary); margin: 0 0 10px; }
.research-explore-card-body .desc { font-size: 13px; color: var(--text-tertiary); margin: 0 0 12px; line-height: 1.5; }
.research-explore-card-body .count { font-size: 12px; color: var(--text-quaternary); }

/* ── How it works ─────────────────────────────────── */
.research-hiw-header { max-width: 580px; margin: 0 auto; padding: 48px 24px 12px; text-align: center; }
.research-hiw-header h1 { font-size: 36px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; margin: 0 0 12px; }
@media (max-width: 640px) { .research-hiw-header h1 { font-size: 26px; } }
.research-hiw-header p { font-size: 17px; color: var(--text-tertiary); line-height: 1.6; max-width: 440px; margin: 0 auto; }
.research-hiw-steps { max-width: 580px; margin: 0 auto; padding: 40px 24px 20px; }
.research-hiw-step { display: flex; gap: 20px; margin-bottom: 40px; }
.research-hiw-step-number { flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; background: #fff7ed; border: 2px solid #fed7aa; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: var(--orange-dark); }
.research-hiw-step h2 { font-size: 19px; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.research-hiw-step p { font-size: 15px; color: var(--text-tertiary); line-height: 1.65; margin: 0 0 6px; }
.research-hiw-step .hint { font-size: 13px; color: var(--text-quaternary); margin: 0; }
.research-hiw-record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 480px) { .research-hiw-record-grid { grid-template-columns: 1fr; } }
.research-hiw-record-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.research-hiw-record-card .name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.research-hiw-record-card .desc { font-size: 13px; color: var(--text-quaternary); line-height: 1.5; }

/* ── How-it-works divider + FAQ wrapper ───────────── */
.research-hiw-divider { max-width: 520px; margin: 0 auto; padding: 0 24px; }
.research-hiw-divider > div { border-top: 1px solid var(--border); }
.research-hiw-faq-section { max-width: 580px; margin: 0 auto; padding: 48px 24px 20px; }
.research-hiw-faq-section > h2 { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; text-align: center; margin: 0 0 32px; }

/* ── FAQ accordion ────────────────────────────────── */
.research-faq { display: flex; flex-direction: column; gap: 1px; background: var(--border); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.research-faq-item { background: #fff; padding: 20px 24px; }
.research-faq-item h3 { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.research-faq-item p { font-size: 14px; color: var(--text-tertiary); line-height: 1.6; margin: 0; }

/* ── CTA section ──────────────────────────────────── */
.research-cta { max-width: 480px; margin: 0 auto; padding: 48px 24px 56px; text-align: center; }
.research-cta h2 { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; margin: 0 0 8px; }
.research-cta p { font-size: 15px; color: var(--text-tertiary); margin: 0 0 24px; }
.research-cta-buttons { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.research-cta-primary { display: inline-flex; align-items: center; justify-content: center; padding: 12px 28px; border-radius: 10px; background: var(--orange-dark); color: #fff; font-weight: 600; font-size: 15px; text-decoration: none; }
.research-cta-secondary { display: inline-flex; align-items: center; justify-content: center; padding: 12px 28px; border-radius: 10px; border: 1.5px solid var(--orange-dark); color: var(--orange-dark); font-weight: 600; font-size: 15px; text-decoration: none; background: transparent; }

/* ── Show page (record detail) ────────────────────── */
.research-detail { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.research-detail-date { font-size: 14px; color: var(--text-quaternary); margin: 0 0 12px; }
.research-detail-field { margin-bottom: 12px; }
.research-detail-field strong { font-size: 13px; color: var(--text-tertiary); }
.research-detail-field p { font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }
.research-brix-value { font-size: 20px; font-weight: 700; color: var(--green-dark); margin: 4px 0 0; }
.research-brix-comparison { font-size: 20px; font-weight: 700; color: var(--text-quaternary); margin: 4px 0 0; }

/* ── Nested form (amendment components) ───────────── */
.research-nested-row { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; padding: 10px; background: #fafaf9; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 640px) { .research-nested-row { grid-template-columns: 1fr 1fr; } .research-nested-row > div:last-child { grid-column: 1 / -1; } }
.research-nested-label { font-size: 12px; color: var(--text-tertiary); display: block; margin-bottom: 3px; }

/* ── Formula pills ────────────────────────────────── */
.research-formula-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.research-formula-pill { padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border); background: #fff; color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s; min-height: 44px; display: inline-flex; align-items: center; }
.research-formula-pill:hover { background: #fafaf9; border-color: var(--orange-dark); }

/* ── Visually hidden (a11y) ───────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Focus indicators ─────────────────────────────── */
.research-record-link:focus-visible,
.research-formula-pill:focus-visible,
.research-explore-card a:focus-visible,
.research-analyze-btn:focus-visible,
.research-edit-link:focus-visible {
  outline: 2px solid var(--orange-dark);
  outline-offset: 2px;
}
