/* ==========================================================================
   Ragascript — global design system  ("The Living Line")
   Warm, editorial, paper-and-ink. A continuous pitch-contour is the signature.
   Cormorant Garamond (display) · Spectral (body) · IBM Plex Mono (labels/UI).
   ========================================================================== */

:root {
  /* --- core palette (warm paper) --- */
  --paper: #f4efe3;        /* warm paper page background */
  --paper-2: #efe7d6;      /* alternating sections */
  --paper-3: #e7dfcc;
  --surface: #fbf8f0;      /* cards / raised surfaces */
  --surface-warm: #f0e8d6;
  --ink: #1b1a17;          /* near-black ink */
  --ink-2: #3b362e;        /* secondary text */
  --ink-3: #2a2620;        /* long-form prose */
  --muted: #6b6256;
  --muted-2: #8a8377;

  /* primary accent — rust / terracotta.
     NOTE: legacy accent names (saffron / teal / rose) are kept below so
     melograph.css + recording/upload/my-recordings styles keep resolving. */
  --accent: #9a3b1f;
  --accent-2: #b8542f;
  --accent-deep: #7d2f18;

  --line: #d8cfbd;         /* hairline rules */
  --line-2: #e3dcca;       /* fainter rules */
  --line-input: #cabfa9;   /* underline / input borders */

  --shadow-sm: 0 1px 2px rgba(27, 26, 23, 0.05);
  --shadow: 0 16px 40px rgba(27, 26, 23, 0.08);
  --shadow-lg: 0 30px 70px rgba(27, 26, 23, 0.12);
  --glow-saffron: 0 10px 26px rgba(154, 59, 31, 0.18);

  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --container: 1180px;
  --container-narrow: 720px;
  --gutter: clamp(20px, 7vw, 90px);

  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-body: "Spectral", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-sans: var(--font-body); /* legacy alias */

  /* --- legacy accent aliases (mapped onto the warm palette) --- */
  --saffron: var(--accent);
  --saffron-2: var(--accent-2);
  --saffron-deep: var(--accent-deep);
  --teal: #4a6b63;
  --teal-2: #5d8076;
  --rose: #a8512c;

  /* --- legacy structural aliases --- */
  --navy: var(--ink);
  --navy-deep: #100f0d;
  --navy-soft: #34302a;
  --warm-gold: var(--accent);
  --warm-gold-soft: #e0cba6;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.6;
  background-color: var(--paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.04;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

p { margin: 0 0 1em; }

a { color: var(--accent); text-decoration: none; transition: color 0.18s ease, border-color 0.18s ease; }
a:hover { color: var(--accent-deep); }

em { font-style: italic; color: var(--accent); }

::selection { background: rgba(154, 59, 31, 0.18); }

/* --- layout --- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: var(--container-narrow); margin-left: auto; margin-right: auto; }
main { display: block; }

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--accent);
}

.grad-text { color: var(--accent); font-style: italic; }

/* ===================== Top navigation ===================== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(244, 239, 227, 0.82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.site-nav.scrolled {
  border-bottom-color: var(--line);
  background: rgba(244, 239, 227, 0.92);
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 46px; height: 18px; display: inline-block; flex-shrink: 0; overflow: visible; }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.brand b { font-weight: 600; }
.brand .dot { display: none; }

.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-links a.nav-link,
.nav-links .nav-user {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}
.nav-links a.nav-link:hover { color: var(--accent); }
.nav-links a.nav-link.cta {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.nav-links a.nav-link.cta:hover { color: var(--accent-deep); border-bottom-color: var(--accent-deep); }
.nav-user { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; border: none; }
.nav-user .av {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem; font-weight: 500; color: var(--paper);
  background: var(--accent);
}
.nav-links form { display: inline; margin: 0; }
.nav-links button.linklike {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 15px; font-weight: 400;
  color: var(--ink); padding: 0 0 2px; border-bottom: 1.5px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.nav-links button.linklike:hover { color: var(--accent); }

.nav-toggle {
  display: none;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 1.6px;
  background: var(--ink);
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-toggle span::before { transform: translate(-50%, -6px); }
.nav-toggle span::after { transform: translate(-50%, 4px); }
.nav-open .nav-toggle span { background: transparent; }
.nav-open .nav-toggle span::before { transform: translate(-50%, -50%) rotate(45deg); }
.nav-open .nav-toggle span::after { transform: translate(-50%, -50%) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: fixed;
    inset: 78px 12px auto 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform-origin: top;
    transform: scaleY(0.9) translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .nav-open .nav-links { opacity: 1; transform: none; pointer-events: auto; }
  .nav-links a.nav-link, .nav-links button.linklike, .nav-user { width: 100%; text-align: left; }
}

/* ===================== Footer ===================== */
.site-footer {
  margin-top: 12vh;
  border-top: 1px solid var(--line);
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 6vh var(--gutter) 4vh;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 40px;
}
.footer-brand .brand { font-size: 1.4rem; margin-bottom: 12px; }
.footer-brand p { color: var(--muted); font-size: 0.92rem; line-height: 1.55; max-width: 34ch; }
.footer-col h4 {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 14px;
}
.footer-col a { display: block; color: var(--ink-2); font-size: 0.94rem; padding: 5px 0; }
.footer-col a:hover { color: var(--accent); }
.footer-base {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gutter) 6vh;
  font-family: var(--font-mono);
  color: var(--muted-2);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
@media (max-width: 680px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ===================== Buttons ===================== */
.btn-primary, .btn-ghost, .btn-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.04em;
  padding: 14px 26px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: #000; color: var(--paper); transform: translateY(-1px); }
.btn-ghost { background: var(--ink); color: var(--paper); }
.btn-ghost:hover { background: #000; color: var(--paper); transform: translateY(-1px); }
.btn-line { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-line:hover { background: rgba(27, 26, 23, 0.06); color: var(--ink); transform: translateY(-1px); }
.btn-lg { padding: 15px 30px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary:active, .btn-ghost:active, .btn-line:active { transform: translateY(0); }
.btn-primary:disabled, .btn-ghost:disabled, .btn-line:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* text-style link button (secondary CTA in the editorial layout) */
.btn-text {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 3px;
  cursor: pointer;
}
.btn-text:hover { color: var(--accent); border-color: var(--accent); }

/* ===================== Cards & surfaces ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 30px 32px; }
.lift { transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease; }
.lift:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--line-input); }

/* ===================== Badges / pills ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.badge-private { background: #e7dfcc; color: #6b6256; }
.badge-contributors { background: #e4ece4; color: #3f5f54; }
.badge-public { background: #e9e2d0; color: var(--accent-deep); }
.badge-status { background: #efe2d4; color: var(--accent-deep); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .badge-status.is-processing .badge-dot { animation: blink 1.1s ease-in-out infinite; }
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ===================== Forms (shared) ===================== */
.field { margin-bottom: 22px; }
.field > label, .field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.input, input.input, select.input, textarea.input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--radius-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(154, 59, 31, 0.12);
}
.field .hint { font-size: 0.84rem; color: var(--muted); margin-top: 6px; }
.req { color: var(--accent); }

.banner {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.94rem;
}
.banner-error { background: #f7e3dc; border: 1px solid #d9a48f; color: #8a2b14; }
.banner-success { background: #e7efe0; border: 1px solid #a9c6a0; color: #3f5f3a; }
.banner-info { background: #efe2d4; border: 1px solid var(--warm-gold-soft); color: var(--accent-deep); }

/* ===================== Hero (marketing) ===================== */
.hero { position: relative; overflow: hidden; }
.hero-canvas { display: none; } /* legacy canvas hero retired in favour of SVG melograph */
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--container);
  padding: 8vh var(--gutter) 0;
}
.hero h1 {
  font-size: clamp(46px, 7.4vw, 108px);
  line-height: 0.96;
  margin: 22px 0 0;
  max-width: 14ch;
}
.hero .lede {
  font-size: clamp(17px, 1.55vw, 21px);
  color: var(--ink-2);
  max-width: 48ch;
  margin: 30px 0 0;
}
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 30px; margin-top: 36px; }

/* melograph svg helpers */
.melo-grid path { fill: none; stroke: var(--ink); stroke-opacity: 0.12; stroke-width: 1; }
.melo-tonic { stroke: var(--accent); stroke-opacity: 0.55; stroke-width: 1.4; stroke-dasharray: 2 6; }
.melo-ribbon { fill: var(--accent); fill-opacity: 0.12; }
.melo-line { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ===================== Sections ===================== */
.section { padding: 13vh 0 0; position: relative; }
.section.alt { background: var(--paper-2); padding-top: 13vh; padding-bottom: 13vh; }
.section-head { max-width: 60ch; margin-bottom: 5vh; }
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.section-head h2 { font-size: clamp(34px, 4.6vw, 62px); margin: 16px 0 0; }
.section-head p { color: var(--muted); font-size: 1.05rem; margin-top: 14px; }

.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } }

.step-num {
  width: auto; height: auto;
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(48px, 6vw, 96px);
  font-weight: 500;
  line-height: 0.8;
  color: var(--accent);
  opacity: 0.85;
  margin-bottom: 0;
  background: none;
  box-shadow: none;
}
.feature h3 { font-size: clamp(22px, 2.4vw, 30px); font-weight: 600; margin-bottom: 8px; }
.feature p { color: var(--ink-2); font-size: 1rem; margin: 0; }

/* editorial three-step rows */
.steps { display: flex; flex-direction: column; }
.step-row {
  display: grid;
  grid-template-columns: 0.6fr 1.2fr 1.6fr;
  gap: 34px;
  align-items: start;
  padding: 38px 0;
  border-top: 1px solid var(--line);
}
.step-row:last-child { border-bottom: 1px solid var(--line); }
.step-row h3 { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.1; margin: 0; }
.step-row p { font-size: 17px; line-height: 1.6; color: var(--ink-2); max-width: 42ch; margin: 0; }
@media (max-width: 760px) {
  .step-row { grid-template-columns: 1fr; gap: 12px; }
}

/* animated thin contour divider (legacy) */
.wave-divider { display: block; width: 100%; height: 46px; color: var(--accent); opacity: 0.5; }
.wave-divider path { fill: none; stroke: currentColor; stroke-width: 1.6; }
@media (prefers-reduced-motion: no-preference) {
  .wave-divider path { stroke-dasharray: 2 8; animation: dash 9s linear infinite; }
}
@keyframes dash { to { stroke-dashoffset: -240; } }

/* CTA band */
.cta-band {
  position: relative; overflow: hidden;
  border-radius: 0;
  padding: 15vh var(--gutter);
  text-align: center;
  background: transparent;
  color: var(--ink);
}
.cta-band h2 { color: var(--ink); font-size: clamp(40px, 6.4vw, 92px); line-height: 0.98; }
.cta-band p { color: var(--ink-2); max-width: 50ch; margin-left: auto; margin-right: auto; }
.cta-band .blob { display: none; }

/* ===================== Decorative motion ===================== */
@keyframes draw { from { stroke-dashoffset: 6000; } to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes scan { 0% { left: 0%; } 100% { left: 100%; } }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(12px, -16px); } }

@media (prefers-reduced-motion: reduce) {
  [style*="animation"] { animation: none !important; opacity: 1 !important; }
}

/* ===================== Reveal on scroll ===================== */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ===================== Page shell helpers ===================== */
.page { max-width: var(--container); margin: 0 auto; padding: 7vh var(--gutter) 24px; }
.page-narrow { max-width: var(--container-narrow); margin: 0 auto; padding: 7vh var(--gutter) 24px; }
.page-head { margin-bottom: 30px; }
.page-head h1 { font-size: clamp(40px, 6vw, 86px); line-height: 0.98; margin: 16px 0 0; }
.page-head p { color: var(--muted); margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

/* ===================== Auth pages ===================== */
.auth {
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 7vw;
  align-items: center;
  max-width: var(--container);
  margin: 0 auto;
  padding: 11vh var(--gutter) 14vh;
}
@media (max-width: 820px) { .auth { grid-template-columns: 1fr; gap: 6vh; padding-top: 7vh; } }
.auth-aside .eyebrow { display: block; margin-bottom: 18px; }
.auth-aside h1 { font-size: clamp(38px, 5.2vw, 76px); line-height: 0.98; max-width: 13ch; margin: 0; }
.auth-aside .auth-contour { margin-top: 6vh; height: 160px; position: relative; }
.auth-aside .auth-contour svg { width: 100%; height: 100%; display: block; overflow: visible; }
.auth-aside .auth-contour path { fill: none; stroke: var(--accent); stroke-opacity: 0.55; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.auth-points { margin-top: 5vh; display: flex; flex-direction: column; gap: 16px; font-size: 16.5px; color: var(--ink-2); }
.auth-points .row { align-items: baseline; gap: 14px; flex-wrap: nowrap; }
.auth-points .gl { color: var(--accent); font-family: var(--font-display); font-size: 20px; }

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
}
.auth-card .brand { display: none; }
.auth-card h1 { display: none; }
.auth-card .sub { display: none; }
.auth-alt { color: var(--muted); font-size: 15px; margin: 12px 0 0; }
.auth-alt a { color: var(--accent); border-bottom: 1.5px solid var(--accent); padding-bottom: 1px; }

/* underline-style inputs for auth */
.auth-card .field { margin-bottom: 26px; }
.auth-card .field input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--line-input);
  border-radius: 0;
  padding: 10px 0;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--ink);
}
.auth-card .field input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
  background: transparent;
}

/* ===================== About page extras ===================== */
.about-hero { padding: 8vh 0 0; }
.principle { display: flex; gap: 16px; align-items: flex-start; }
.principle .ico {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 1.2rem;
  background: rgba(154, 59, 31, 0.10);
  color: var(--accent);
}
.principle.teal .ico { background: rgba(74, 107, 99, 0.12); color: var(--teal); }
.principle.rose .ico { background: rgba(168, 81, 44, 0.12); color: var(--rose); }
.principle h3 { font-size: 1.18rem; font-weight: 600; margin: 2px 0 6px; }
.principle p { color: var(--muted); font-size: 0.96rem; margin: 0; }
