/* ===========================================================
   PRISM — visual identity
   Aesthetic: editorial / scientific journal
   Fonts:  Crimson Pro (display serif), Inter (UI sans),
           IBM Plex Mono (code/data)
   Palette: deep ink, warm parchment, viridian accent
   =========================================================== */

@import url("https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

/* ---- design tokens ---------------------------------------- */

:root[data-theme="light"] {
  --ink:        #0d1f2d;
  --ink-soft:   #2a3f53;
  --paper:      #faf5ed;
  --paper-2:    #f1ebde;
  --rule:       #d8cfba;
  --accent:     #0f766e;       /* viridian */
  --accent-2:   #047857;
  --gold:       #b08800;       /* warm highlight */
  --rose:       #b1364a;
  --shadow:     0 2px 4px rgba(13, 31, 45, .04), 0 8px 24px rgba(13, 31, 45, .06);
  --shadow-lg:  0 4px 12px rgba(13, 31, 45, .06), 0 24px 48px rgba(13, 31, 45, .12);
}

:root[data-theme="dark"] {
  --ink:        #f5efe1;
  --ink-soft:   #c8c0ad;
  --paper:      #11181f;
  --paper-2:    #1a242e;
  --rule:       #2c3a47;
  --accent:     #5eead4;
  --accent-2:   #34d399;
  --gold:       #facc15;
  --rose:       #f87171;
  --shadow:     0 2px 4px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg:  0 4px 12px rgba(0, 0, 0, .4), 0 24px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  transition: background-color .3s, color .3s;
}

/* Subtle parchment texture via repeating radial dots */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background-image: radial-gradient(circle at 1px 1px, var(--rule) 1px, transparent 0);
  background-size: 32px 32px;
  opacity: .25;
  pointer-events: none;
}

/* ---- typography ------------------------------------------- */

h1, h2, h3 {
  font-family: "Crimson Pro", Georgia, serif;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; }

code, pre, .mono { font-family: "IBM Plex Mono", monospace; font-size: .92em; }

/* ---- topbar ----------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  background: rgba(250, 245, 237, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
:root[data-theme="dark"] .topbar { background: rgba(17, 24, 31, 0.88); }

.brand {
  display: flex; align-items: center; gap: 14px;
  font-family: "Crimson Pro", serif;
  font-size: 22px; font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: "Crimson Pro", serif;
  font-weight: 700; font-size: 20px;
  border: 2px solid var(--gold);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  opacity: .45;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.tb-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  padding: 7px 13px;
  border-radius: 6px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  transition: all .15s;
}
.tb-btn:hover {
  color: var(--ink);
  border-color: var(--rule);
  background: var(--paper-2);
}
.theme-toggle {
  width: 36px; height: 36px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  margin-left: 4px;
}

/* ---- hero / page layout ---------------------------------- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 32px 100px;
}

.hero {
  text-align: center;
  margin-bottom: 56px;
  position: relative;
}
.hero-eyebrow {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  margin-bottom: 24px;
}
.hero h1 {
  font-size: clamp(40px, 5.5vw, 64px);
  line-height: 1.05;
  margin: 0 0 18px;
  font-weight: 700;
  letter-spacing: -.025em;
}
.hero h1 .accent {
  color: var(--accent);
  font-style: italic;
}
.hero-subtitle {
  font-family: "Crimson Pro", serif;
  font-size: clamp(18px, 2vw, 22px);
  font-style: italic;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 0 auto 12px;
}
.hero-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-soft);
  margin-top: 16px;
}
.hero-meta a { color: var(--accent); }

/* Decorative atom ring next to title (SVG drawn from HTML) */
.atom-deco {
  position: absolute;
  top: -10px; right: -10px;
  width: 120px; height: 120px;
  opacity: .15;
  animation: rotate-slow 60s linear infinite;
}
@media (max-width: 900px) { .atom-deco { display: none; } }
@keyframes rotate-slow { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---- card / form panel ------------------------------------ */

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  position: relative;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-lg); }

.section-title {
  display: flex; align-items: center; gap: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 18px;
}
.section-title::before {
  content: ""; width: 18px; height: 1px;
  background: var(--accent);
}
.section-title::after {
  content: ""; flex: 1; height: 1px;
  background: var(--rule);
}

/* ---- form fields ------------------------------------------ */

.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .field-row { grid-template-columns: 1fr; } }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: .005em;
}
label .opt {
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
  margin-left: 6px;
}
label .req { color: var(--rose); }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 11px 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: var(--paper);
}
textarea { resize: vertical; min-height: 110px; font-size: 13.5px; line-height: 1.55; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
}
.field-hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
  font-style: italic;
}

/* ---- buttons ---------------------------------------------- */

.btn-primary {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink);
  color: var(--paper);
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 14px 28px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.btn-primary::after {
  content: "→"; font-size: 18px;
  transition: transform .15s;
}
.btn-primary:hover::after { transform: translateX(3px); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ---- results page ----------------------------------------- */

.result-header {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 32px;
}
.result-header h2 {
  font-size: 36px;
  margin: 0;
  letter-spacing: -.02em;
}
.result-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--ink-soft);
}
.result-meta strong { color: var(--ink); font-weight: 600; }

/* Celebration banner */
.celebrate {
  position: relative;
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 14%, var(--paper)), var(--paper));
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 22px 28px;
  margin-bottom: 28px;
  display: flex; align-items: center; gap: 18px;
  animation: pop-in .5s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.celebrate::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 35%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 2.4s ease-in-out 0.6s 1;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes shimmer {
  to { transform: translateX(100%); }
}
.celebrate-icon {
  font-size: 32px;
  animation: bounce 1.6s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.celebrate-text {
  font-family: "Crimson Pro", serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}
.celebrate-text small {
  display: block;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* Section divider in results */
.results-section { margin-top: 48px; }
.results-section-title {
  font-family: "Crimson Pro", serif;
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 6px;
  display: flex; align-items: center; gap: 12px;
}
.results-section-title .badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--paper);
  padding: 3px 10px;
  border-radius: 4px;
}
.results-section-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 22px;
  font-style: italic;
}

/* Prediction grid + cards */
.pred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.pred {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px;
  position: relative;
  transition: all .2s;
  display: flex; flex-direction: column;
}
.pred:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }

.pred-rank {
  position: absolute;
  top: -10px; left: 16px;
  background: var(--ink);
  color: var(--paper);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 4px;
}
.pred-rank.match {
  background: var(--gold);
  color: var(--ink);
}
.pred-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  margin-bottom: 12px;
}
.pred-img img { max-width: 100%; max-height: 100%; }

.smiles-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 12px;
}
.smiles {
  flex: 1;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--paper-2);
  padding: 6px 9px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  overflow-x: auto;
  white-space: nowrap;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.smiles::-webkit-scrollbar { display: none; }
.copy-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 5px 9px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent-2); border-color: var(--accent-2); }

.metrics {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12.5px;
  margin-top: auto;
}
.metrics dt {
  color: var(--ink-soft);
  font-weight: 400;
}
.metrics dd {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink);
  font-weight: 500;
  text-align: right;
}
.metrics .tanimoto-perfect {
  color: var(--accent-2);
  font-weight: 700;
}

/* Ground-truth callout box */
.gt-box {
  background: color-mix(in srgb, var(--gold) 10%, var(--paper));
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 28px;
  text-align: center;
}
.gt-box h3 {
  font-family: "Crimson Pro", serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--ink);
  letter-spacing: .01em;
}
.gt-img {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px;
  display: inline-block;
  margin-bottom: 12px;
}
.gt-img img { max-width: 280px; max-height: 220px; }
.gt-smiles {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--paper);
  padding: 8px 14px;
  border-radius: 6px;
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  border: 1px solid var(--rule);
}

/* Pairwise tanimoto matrix */
.matrix-wrap { overflow-x: auto; margin-top: 24px; }
.matrix {
  border-collapse: collapse;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  margin: 0 auto;
}
.matrix th, .matrix td {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  text-align: center;
  min-width: 56px;
}
.matrix th {
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 600;
}

/* ---- footer + watermark ---------------------------------- */

.footer {
  margin-top: 80px;
  padding: 24px 32px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink-soft);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
}
.footer a { color: var(--ink-soft); }
.footer a:hover { color: var(--accent); }

.watermark {
  position: fixed;
  bottom: 18px; right: 18px;
  z-index: 10;
  font-family: "Crimson Pro", serif;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  opacity: .82;
  pointer-events: none;
  letter-spacing: .02em;
}
.watermark strong { color: var(--ink); font-weight: 600; font-style: normal; }
@media (max-width: 720px) { .watermark { display: none; } }

/* ---- modals ----------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(13, 31, 45, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in .2s;
}
.modal-backdrop.open { display: flex; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: slide-up .25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal h2 {
  margin: 0 0 8px;
  font-size: 26px;
}
.modal-eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.modal-close {
  position: absolute;
  top: 18px; right: 18px;
  background: transparent; border: none;
  font-size: 24px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }
.modal pre {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Contact / Cite cards */
.contact-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.contact-card .name {
  font-family: "Crimson Pro", serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.contact-card .role {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 8px;
}
.contact-card .email {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  color: var(--accent);
  display: block;
  margin-top: 4px;
}
