/* =========================================================
   Music Trivia Agent — Style Sheet
   ========================================================= */

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

:root {
  --bg:          #F5E6D3;
  --bg-card:     #FDF6EE;
  --bg-feed:     #FAF0E4;
  --text:        #2C1810;
  --text-muted:  #6B4D3E;
  --text-light:  #9A8070;
  --accent:      #C8703B;
  --accent-dark: #A3572A;
  --amber:       #D4912A;
  --red:         #B8372D;
  --green:       #4A8C5C;
  --groove:      #3A2518;
  --label:       #C8703B;
  --border:      #D9C4AD;
  --shadow:      rgba(44, 24, 16, .08);

  --font-serif:  Georgia, "Times New Roman", serif;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:   "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  --ease-out:    cubic-bezier(.22, 1, .36, 1);
  --transition:  .35s var(--ease-out);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* --- Layout ---------------------------------------------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* --- Header ---------------------------------------------- */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header__title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.header__subtitle {
  margin-top: .35rem;
  font-size: .9rem;
  color: var(--text-muted);
}

/* --- Sections -------------------------------------------- */
.section { transition: opacity var(--transition); }
.section[hidden] { display: none; }
.section--input { animation: fadeUp .4s var(--ease-out) both; max-width: 560px; margin: 0 auto; }
.section--research { animation: fadeUp .4s var(--ease-out) both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Input Form ------------------------------------------ */
.input-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.input-row {
  display: flex;
  width: 100%;
  gap: .5rem;
}

.input-url {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}

.input-url::placeholder { color: #A08876; }
.input-url:focus { border-color: var(--accent); }

.turnstile-wrapper {
  min-height: 65px;
  display: flex;
  justify-content: center;
}

/* --- Buttons --------------------------------------------- */
.btn {
  font-family: var(--font-sans);
  font-size: .9rem;
  font-weight: 600;
  padding: .65rem 1.25rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s, transform .15s;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn--secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn--secondary:hover:not(:disabled) { background: rgba(200, 112, 59, .08); }

.error-msg { font-size: .85rem; color: var(--red); text-align: center; }

/* --- Two-Column Research Layout -------------------------- */
.research-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* --- Left Column: Agent Feed ----------------------------- */
.research-feed {
  background: var(--bg-feed);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  max-height: 80vh;
  overflow-y: auto;
}

.feed-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

.feed-header__title {
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* Small spinning vinyl in feed header */
.vinyl-small__disc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--groove) 0%, #1A0E08 100%);
  animation: spin 2s linear infinite;
  position: relative;
}

.vinyl-small__label {
  position: absolute;
  width: 10px;
  height: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--label);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Status Feed Items ----------------------------------- */
.status-feed {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.status-feed__item {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: .75rem;
  line-height: 1.5;
  color: var(--text-muted);
  animation: feedIn .3s var(--ease-out) both;
}

@keyframes feedIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.status-feed__time {
  flex-shrink: 0;
  color: var(--text-light);
  font-size: .65rem;
  min-width: 48px;
}

.status-feed__text {
  color: var(--text);
  word-break: break-word;
}

/* Step type styles */
.step-thinking .status-feed__text,
.step-planning .status-feed__text {
  color: var(--text-muted);
  font-style: italic;
}

.step-searching .status-feed__text {
  color: var(--accent-dark);
}

.step-finding {
  background: rgba(200, 112, 59, .07);
  border-left: 2px solid var(--accent);
  padding: .5rem .65rem;
  border-radius: 0 6px 6px 0;
  margin: .25rem 0;
  align-items: flex-start;
}

.step-finding .status-feed__text {
  font-family: var(--font-sans);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--text);
}

.step-synthesizing .status-feed__text {
  color: var(--green);
  font-weight: 600;
}

.step-error .status-feed__text {
  color: var(--red);
}

/* --- Right Column: Video + Result Card ------------------- */
.research-result {
  position: sticky;
  top: 1.5rem;
  animation: fadeUp .5s var(--ease-out) both;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.video-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #1A0E08;
  box-shadow: 0 2px 12px var(--shadow);
}

.video-embed iframe {
  width: 100%;
  height: 100%;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 2px 12px var(--shadow);
}

.result-card__header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.result-card__song {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
}

.result-card__artist {
  margin-top: .2rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.result-card__fact {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding: .65rem 0 .65rem 1rem;
  margin: 0 0 1.5rem;
  quotes: none;
}

/* --- Surprise Meter -------------------------------------- */
.surprise-meter { margin-bottom: 1.5rem; }

.surprise-meter__label {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text-muted);
}

.surprise-meter__value { color: var(--text); }

.surprise-meter__track {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.surprise-meter__fill {
  height: 100%;
  border-radius: 4px;
  width: 0;
  background: linear-gradient(90deg, var(--amber), var(--accent), var(--red));
  transition: width .8s var(--ease-out);
}

/* --- Sources --------------------------------------------- */
.result-card__sources { margin-bottom: 1.5rem; }

.result-card__sources-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .4rem;
}

.result-card__sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.result-card__sources-list a {
  font-size: .8rem;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.result-card__sources-list a:hover { text-decoration: underline; }

/* --- Actions --------------------------------------------- */
.result-card__actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.copy-confirm {
  text-align: center;
  font-size: .8rem;
  color: var(--accent);
  margin-top: .6rem;
  animation: fadeUp .3s var(--ease-out) both;
}

.result-card__share {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .75rem;
}

.share-label {
  font-size: .8rem;
  color: var(--muted);
}

.btn--share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.btn--share:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(200, 112, 59, .08);
}

/* --- Footer ---------------------------------------------- */
.footer {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--text-muted);
}

/* --- Responsive: stack on mobile ------------------------- */
@media (max-width: 768px) {
  .container { max-width: 100%; padding: 1.5rem 1rem; }
  .header__title { font-size: 1.75rem; }

  .research-layout {
    grid-template-columns: 1fr;
  }

  .research-feed { max-height: 50vh; }
  .research-result { position: static; }

  .input-row { flex-direction: column; }
  .btn { width: 100%; text-align: center; }
  .result-card { padding: 1.25rem 1rem; }
  .result-card__actions { flex-direction: column; }
}
