/* ============================================================
   MeltingFace — Design System
   Concept E: Soft Verdict
   ============================================================ */

/* ── Fonts ── */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/fraunces.woff2') format('woff2');
  font-optical-sizing: auto;
}

@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url('../fonts/fraunces-italic.woff2') format('woff2');
  font-optical-sizing: auto;
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/manrope.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('../fonts/fira-code.woff2') format('woff2');
}

/* ── Color tokens ── */

:root {
  /* Backgrounds */
  --bg:           #121014;
  --surface:      #1A181E;
  --card:         #1F1D24;
  --card-hover:   #262430;
  --well:         #0E0D11;

  /* Borders */
  --border:       #2D2B34;
  --border-fine:  #232128;

  /* Text */
  --cream:        #E8E1D4;
  --sand:         #C0B8AA;
  --stone:        #9A928A;
  --slate:        #575050;
  --deep:         #3C3838;

  /* Accents */
  --science:      #64B8EA;
  --slop:         #E46B50;
  --signal:       #B08AE8;
  --divergence:   #E05898;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui:      'Manrope', -apple-system, sans-serif;
  --font-mono:    'Fira Code', monospace;
}

/* ── Reset ── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ── */

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ── Top glow ── */

body::before {
  content: '';
  position: fixed;
  top: -160px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(176, 138, 232, 0.03) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 32px 100px;
  position: relative;
  z-index: 1;
}

/* ── Typography helpers ── */

.display {
  font-family: var(--font-display);
  font-optical-sizing: auto;
}

.mono {
  font-family: var(--font-mono);
}

/* ── Links ── */

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--sand);
}

/* ── Header ── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--border-fine);
}

.logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  font-optical-sizing: auto;
}

.logo-icon {
  height: 1.1em;
  width: auto;
  vertical-align: -0.15em;
  margin-right: 6px;
  transition: transform 0.3s;
}

.logo:hover .logo-icon {
  transform: rotate(-8deg) scale(1.05);
}

.logo .m {
  color: var(--slop);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

.header-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--stone);
}

.header-link:hover {
  color: var(--sand);
}

.header-cta {
  font-size: 12px;
  font-weight: 600;
  color: var(--bg);
  background: var(--signal);
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  display: inline-block;
  transition: opacity 0.15s;
}

.header-cta:hover {
  opacity: 0.85;
  color: var(--bg);
}

/* ── Hero ── */

.hero {
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--border-fine);
}

.hero-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 24px;
}

.hero-text {
  flex: 1;
}

.hero-headline {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.hero-headline .hot {
  color: var(--slop);
}

.hero-sub {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--sand);
  line-height: 1.5;
  font-weight: 400;
}

.hero-counter {
  text-align: right;
  flex-shrink: 0;
}

.hero-counter .big {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 800;
  color: var(--slop);
  line-height: 1;
  letter-spacing: -0.04em;
  display: block;
}

.hero-counter .unit {
  font-size: 13px;
  color: var(--stone);
  display: block;
  margin-top: 2px;
}

/* ── Stacked bar chart ── */

.bar-chart {
  display: flex;
  width: 100%;
  height: 28px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.bar-chart .bar-seg:first-child {
  border-radius: 6px 0 0 6px;
}

.bar-chart .bar-seg:last-child {
  border-radius: 0 6px 6px 0;
}

.bar-seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  transition: flex 0.3s;
}

.bar-slop { background: var(--slop); color: #1a0f0c; }
.bar-sig  { background: var(--signal); color: #1a1028; }
.bar-sci  { background: var(--science); color: #0c1a22; }

.bar-legend {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--stone);
}

.bar-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.d-sci  { background: var(--science); }
.d-slop { background: var(--slop); }
.d-sig  { background: var(--signal); }

/* ── Search ── */

.search-bar {
  padding: 18px 0 0;
}

.search-bar input {
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  padding: 12px 16px;
  border-radius: 10px;
}

.search-bar input:focus {
  border-color: var(--signal);
  background: var(--card);
}

/* ── Controls ── */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-fine);
}

.pills {
  display: flex;
  gap: 6px;
}

.pill {
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--stone);
  border-radius: 24px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1;
}

.pill:hover {
  color: var(--sand);
  border-color: var(--slate);
}

.pill:active {
  transform: scale(0.96);
}

.pill.on,
.pill[aria-current="true"] {
  background: var(--cream);
  color: var(--bg);
  border-color: var(--cream);
  font-weight: 600;
}

.sort-ctl {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--stone);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239A928A'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  padding: 6px 28px 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* ── Card ── */

.card {
  background: var(--card);
  border: 1px solid var(--border-fine);
  border-radius: 12px;
  margin-top: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
  display: block;
}

.card:hover {
  background: var(--card-hover);
  border-color: var(--border);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px -6px rgba(0, 0, 0, 0.35);
}

.card.divergent {
  border-left: 3px solid var(--divergence);
}

.card-body {
  padding: 22px 24px 18px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.card-rank {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--deep);
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  padding-top: 2px;
}

.card-text {
  flex: 1;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.card-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
}

.card-src {
  font-size: 12px;
  color: var(--slate);
}

.card-conf {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--stone);
  background: var(--well);
  padding: 2px 8px;
  border-radius: 4px;
}

.card-mfdr {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  font-weight: 400;
  color: var(--sand);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Mini bar (card-level triangle replacement) ── */

.mini-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.mini-bar__track {
  display: flex;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar__seg {
  height: 100%;
}

.mini-bar__slop { background: var(--slop); }
.mini-bar__sig  { background: var(--signal); }
.mini-bar__sci  { background: var(--science); }

.mini-bar__verdict {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.verdict-slop   { color: var(--slop); }
.verdict-signal { color: var(--signal); }
.verdict-science { color: var(--science); }

/* ── Detail bar (detail page) ── */

.detail-bar {
  margin-bottom: 24px;
}

.detail-bar .bar-chart {
  height: 20px;
  margin-bottom: 8px;
}

.detail-bar__legend {
  display: flex;
  gap: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px 14px;
  background: var(--well);
  border-top: 1px solid var(--border-fine);
}

.card-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--slate);
  flex-shrink: 0;
}

.card-spark {
  flex: 1;
  height: 22px;
  min-width: 80px;
}

.card-spark svg {
  width: 100%;
  height: 100%;
}

.card-mfers {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--stone);
  white-space: nowrap;
}

/* ── Card entrance ── */

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.card {
  animation: card-in 0.3s ease-out both;
}

/* ── Badges ── */

.badge-clash {
  display: inline-block;
  font-size: 10px;
  color: var(--divergence);
  background: rgba(224, 88, 152, 0.08);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 20px;
}

/* ── Buttons ── */

.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s, opacity 0.15s;
  line-height: 1;
}

.btn-primary {
  background: var(--signal);
  color: var(--bg);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-ghost:active,
.header-cta:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  color: var(--stone);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--sand);
  border-color: var(--slate);
}

/* ── Well / recessed areas ── */

.well {
  background: var(--well);
  border-radius: 8px;
}

/* ── Inputs ── */

input[type="text"],
input[type="email"],
input[type="url"],
textarea {
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--signal);
}

input::placeholder,
textarea::placeholder {
  color: var(--slate);
  font-style: italic;
}

/* ── Detail page ── */

.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--stone);
  margin-top: 20px;
  margin-bottom: 8px;
}

.back-link:hover {
  color: var(--sand);
}

.detail {
  padding-top: 12px;
}

.detail-header {
  margin-bottom: 24px;
}

.detail-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.detail-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.detail-url {
  display: block;
  font-size: 13px;
  color: var(--slate);
  word-break: break-all;
}

.detail-url:hover {
  color: var(--signal);
}

.detail-mfdr {
  font-family: var(--font-display);
  font-size: 17px;
  font-style: italic;
  font-weight: 400;
  color: var(--sand);
  line-height: 1.6;
  margin-bottom: 28px;
}

.detail-triangles {
  margin-bottom: 24px;
}

.detail-reasoning {
  padding: 16px 20px;
  margin-bottom: 24px;
  color: var(--sand);
  font-size: 14px;
  line-height: 1.6;
}

.detail-sparkline {
  margin-bottom: 28px;
}

.detail-meta {
  display: flex;
  gap: 18px;
  font-size: 13px;
  color: var(--slate);
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-fine);
  margin-bottom: 28px;
}

.detail-section {
  margin-bottom: 32px;
}

.detail-section-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--stone);
  margin-bottom: 12px;
}

/* ── Triangle pair (agent vs community) ── */

.triangle-pair {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.triangle-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.triangle-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--stone);
}

/* ── Rating form ── */

.rating-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rating-triangle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.triangle-input {
  cursor: crosshair;
  border-radius: 8px;
  width: 200px;
  height: auto;
}

.triangle-readout {
  font-size: 12px;
  color: var(--stone);
  text-align: center;
}

.take-field textarea {
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
}

.form-field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--sand);
  display: block;
  margin-bottom: 6px;
}

.rating-flash {
  font-size: 13px;
  color: var(--signal);
  font-weight: 500;
  margin-bottom: 4px;
}

.rating-summary .take-text {
  margin-top: 8px;
  margin-bottom: 12px;
}

.rating-expand {
  margin-top: 12px;
}

.rating-expand summary {
  list-style: none;
  display: inline-block;
}

.rating-expand summary::-webkit-details-marker {
  display: none;
}

.rating-toggle::after {
  content: "Update your rating";
}

.rating-expand[open] .rating-toggle::after {
  content: "Cancel";
}

.rating-expand .rating-form {
  margin-top: 16px;
}

/* ── Takes ── */

.takes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.take-card {
  padding: 16px 20px;
}

.take-author {
  font-size: 12px;
  color: var(--stone);
  display: block;
  margin-bottom: 6px;
}

.take-text {
  color: var(--sand);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 10px;
}

/* ── Cosign button ── */

.cosign-btn {
  font-size: 11px;
  padding: 8px 14px;
}

.cosign-btn.cosigned {
  color: var(--signal);
  border-color: var(--signal);
}

/* ── Auth & nomination pages ── */

.auth {
  padding-top: 60px;
  max-width: 440px;
  margin: 0 auto;
}

.auth .display {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auth-tagline {
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--sand);
}

.form-hint {
  font-size: 12px;
  color: var(--slate);
}

.form-error {
  font-size: 13px;
  color: var(--slop);
  margin-top: 4px;
}

/* ── Profile ── */

.profile {
  padding-top: 32px;
}

.profile-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-fine);
}

.profile-header .display {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
}

#edit-pseudonym-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 12px;
}

#edit-pseudonym-form input {
  max-width: 200px;
}

/* ── Footer ── */

.footer {
  text-align: center;
  padding: 40px 0;
  margin-top: 32px;
  border-top: 1px solid var(--border-fine);
}

.footer-tagline {
  font-family: var(--font-display);
  font-size: 14px;
  font-style: italic;
  color: var(--slate);
}

/* ── Tooltips ── */

[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--cream);
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.4;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 10;
}

[data-tip]:hover::after {
  opacity: 1;
}

/* ── Screen reader only ── */

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

/* ── HTMX loading indicator ── */

.htmx-request #feed-list {
  opacity: 0.5;
  transition: opacity 0.15s;
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Utility ── */

.text-cream   { color: var(--cream); }
.text-sand    { color: var(--sand); }
.text-stone   { color: var(--stone); }
.text-slate   { color: var(--slate); }
.text-deep    { color: var(--deep); }
.text-science { color: var(--science); }
.text-slop    { color: var(--slop); }
.text-signal  { color: var(--signal); }

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--stone);
  font-style: italic;
}

/* ── Focus ── */

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible {
  outline: none;  /* border-color change handles this */
}

/* ============================================================
   Responsive — Mobile First Overrides
   ============================================================ */

@media (max-width: 640px) {

  /* Layout */
  .page {
    padding: 0 16px 60px;
  }

  /* Header */
  .header {
    padding: 16px 0 14px;
  }

  .logo {
    font-size: 20px;
  }

  .header-right {
    gap: 14px;
  }

  .header-link {
    font-size: 12px;
  }

  .header-cta {
    font-size: 11px;
    padding: 7px 14px;
  }

  /* Hero */
  .hero {
    padding: 24px 0 20px;
  }

  .hero-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .hero-headline {
    font-size: 22px;
  }

  .hero-counter {
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .hero-counter .big {
    font-size: 36px;
  }

  .hero-counter .unit {
    display: inline;
    margin-top: 0;
  }

  /* Bar chart */
  .bar-seg {
    font-size: 9px;
  }

  /* Controls */
  .controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .pills {
    flex-wrap: wrap;
  }

  .pill {
    padding: 8px 14px;  /* larger touch targets */
  }

  .sort-ctl {
    padding: 8px 14px;
  }

  /* Cards */
  .card-body {
    padding: 16px;
    gap: 12px;
  }

  .card-rank {
    font-size: 18px;
    width: 24px;
  }

  .card-name {
    font-size: 16px;
  }

  .card-mfdr {
    font-size: 14px;
  }

  .card:hover {
    transform: none;
    box-shadow: none;
  }

  .card-tri {
    display: none;  /* triangles too small to be useful on mobile */
  }

  .card-foot {
    padding: 10px 16px 12px;
  }

  .card-spark {
    min-width: 60px;
  }

  /* Detail page */
  .detail-name {
    font-size: 22px;
  }

  .detail-mfdr {
    font-size: 15px;
  }

  .triangle-pair {
    flex-direction: column;
    gap: 24px;
  }

  .detail-meta {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Auth */
  .auth {
    padding-top: 40px;
  }

  /* Tooltips: disable on touch */
  [data-tip]::after {
    display: none;
  }

  /* Footer */
  .footer {
    padding: 24px 0;
  }

  .footer-tagline {
    font-size: 13px;
  }
}
